locked
How to detect a constraint conflict with synchronization based on Standard Provider. RRS feed

  • Question

  • Hi All,

    I want to create sync ecosystem that synchronise data between  Outlook and web service.

    I have implement a Standard provider for each data source.

    The synchronisation metadata is based on ID of data in each data Source (the id is a GUID).

    The problem occur when i want to sync all data, and the two data source containt the same elements information but a différent ids.

    For example:

     

    Outlook Web Service
    id="db7c75be-4910-40b1-8ba9-e0ec9e5bca5e"
    FirstName="Jack"

    id="36fb8d41-e0af-4d5e-a61b-279dfe205d2e"
    FirstName="Jack"

     

    and after Sync:

     

    Outlook Web Service
    id="db7c75be-4910-40b1-8ba9-e0ec9e5bca5e"
    FirstName="Jack"

    id="36fb8d41-e0af-4d5e-a61b-279dfe205d2e"
    FirstName="Jack"
    id="36fb8d41-e0af-4d5e-a61b-279dfe205d2e"
    FirstName="Jack"

    id="db7c75be-4910-40b1-8ba9-e0ec9e5bca5e"
    FirstName="Jack"
    Any idea please. Thanks, RealTn
    Monday, June 21, 2010 11:12 AM

Answers

  • Since constraints are a property of the data, and not the metadata, it doesn't provide anything special to custom providers to detect constraint conflicts, so it's up to you to detect them.  Once you detect them, you can report them to the framework by doing the following:

    In native code:

    In your ISynchronousNotifyingChangeApplierTarget::SaveChange method, QueryInterface your ISaveChangeContext for ISaveChangeContext2 and calling SetContraintConflictOnChange

    In managed code:

    In INotifyingChangeApplierTarget.SaveItemChange, call SaveChangeContext.RecordConstraintConflictForItem.

    One note....in order to do this, you must call the ApplyChanges method that takes a conflict log (in native code, this is is on the ISynchronousNotifyingChangeApplier2 interface).  You can use the in-memory conflict log provided by the framework in order to do this.

    Aaron


    SDE, Microsoft Sync Framework
    • Proposed as answer by Adrian Mustea - MSFT Tuesday, June 22, 2010 7:32 PM
    • Marked as answer by realtn Saturday, June 26, 2010 4:38 PM
    Monday, June 21, 2010 5:22 PM
    Answerer

All replies

  • Since constraints are a property of the data, and not the metadata, it doesn't provide anything special to custom providers to detect constraint conflicts, so it's up to you to detect them.  Once you detect them, you can report them to the framework by doing the following:

    In native code:

    In your ISynchronousNotifyingChangeApplierTarget::SaveChange method, QueryInterface your ISaveChangeContext for ISaveChangeContext2 and calling SetContraintConflictOnChange

    In managed code:

    In INotifyingChangeApplierTarget.SaveItemChange, call SaveChangeContext.RecordConstraintConflictForItem.

    One note....in order to do this, you must call the ApplyChanges method that takes a conflict log (in native code, this is is on the ISynchronousNotifyingChangeApplier2 interface).  You can use the in-memory conflict log provided by the framework in order to do this.

    Aaron


    SDE, Microsoft Sync Framework
    • Proposed as answer by Adrian Mustea - MSFT Tuesday, June 22, 2010 7:32 PM
    • Marked as answer by realtn Saturday, June 26, 2010 4:38 PM
    Monday, June 21, 2010 5:22 PM
    Answerer
  • realtn,

    you can check the following link to get some more info regarding constraint conflicts - http://msdn.microsoft.com/en-us/library/dd937738(SQL.105).aspx

    you will need to add support for constraint-related functionality in the SaveChange() methods, and also hook the MemoryConflictLog to the ApplyChanges() call.

    let us know what your progress will be, and if you encounter any issues.

    Thanks.

    Adrian

    Tuesday, June 22, 2010 7:32 PM