none
MS Sync Framework 2.1 Handle Conflicts using WCF Sync Service RRS feed

  • Question

  • Hi,

        I am using the example here 'http://www.systenics.com/blog/sync-sql-server-2012-data-with-sql-ce-35-sp2-over-the-internet-using-wcf-services-using-ms-sync-framework-v21/' for synchronizing using a WCF service. Everything works fine except I can not figure out how to handle conflicts. When I sync directly without using a WCF service I use the below code where I can get to all the information I require:

    private void RemoteSync_ApplyChangeFailedRemote(object sender, DbApplyChangeFailedEventArgs e)
    {
     
     //e.Conflict.RemoteChange.TableName;
     //DataRow row = e.Conflict.RemoteChange.Rows[0];
     //e.Conflict.ErrorMessage
     //The local peer deleted a row that the remote peer updated & the metadata for that row was cleaned up
        if (e.Conflict.Type == DbConflictType.LocalCleanedupDeleteRemoteUpdate)
        {
            e.Action = ApplyAction.RetryWithForceWrite;
        }

    }

    How can I handle conflict in a similar fashion when using a WCF service?

    Thanks

    Paul.


    Paul Wainwright

    Monday, February 1, 2016 3:44 PM

Answers

  • Hi Paul,

    I checked the example at 'http://www.systenics.com/blog/sync-sql-server-2012-data-with-sql-ce-35-sp2-over-the-internet-using-wcf-services-using-ms-sync-framework-v21,

    If you want to handle conflict in WCF service, you can try to register the ApplyChangeFailed event for SqlSyncProvider object when it's instantiated, in the source code in that blog, you can do the following updates:

    1. Locate SyncService project.

    2. Open ServerSynchronizationHelper.cs, and locate ConfigureSqlSyncProvider method.

    3. In the 4th line in that method, add the following code which is similar with the code in your post:

    provider.ApplyChangeFailed += (s, e) =>
    {
      if (e.Conflict.Type == DbConflictType.LocalCleanedupDeleteRemoteUpdate)
          {
           e.Action = ApplyAction.RetryWithForceWrite;
          }
    };

    Please let me know if it does not work.

    Thanks,

    Jie Rong

    Wednesday, February 3, 2016 4:14 PM

All replies

  • Hello,

    Welcome to the Developing Universal Windows apps forum!

    As a friendly reminder please make sure to add the appropriate tags to the title of your post as per Guide to posting: subject line tag 

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, February 2, 2016 1:01 PM
    Moderator
  • Hi Paul,

    I checked the example at 'http://www.systenics.com/blog/sync-sql-server-2012-data-with-sql-ce-35-sp2-over-the-internet-using-wcf-services-using-ms-sync-framework-v21,

    If you want to handle conflict in WCF service, you can try to register the ApplyChangeFailed event for SqlSyncProvider object when it's instantiated, in the source code in that blog, you can do the following updates:

    1. Locate SyncService project.

    2. Open ServerSynchronizationHelper.cs, and locate ConfigureSqlSyncProvider method.

    3. In the 4th line in that method, add the following code which is similar with the code in your post:

    provider.ApplyChangeFailed += (s, e) =>
    {
      if (e.Conflict.Type == DbConflictType.LocalCleanedupDeleteRemoteUpdate)
          {
           e.Action = ApplyAction.RetryWithForceWrite;
          }
    };

    Please let me know if it does not work.

    Thanks,

    Jie Rong

    Wednesday, February 3, 2016 4:14 PM
  • Jie,

        Thanks for the reply. Your suggestion worked fine.

    Regards

    Paul.


    Paul Wainwright

    Thursday, February 4, 2016 10:21 AM