none
Conflicts and constraints not being handled in SimpleSyncProvider RRS feed

  • Question

  • I have implemented a FullEnumerationSimpleSyncProvider that doesn't seem to be handling conflicts.

    In the constructor I have set the following properties:

    this.Configuration.CollisionConflictResolutionPolicy = CollisionConflictResolutionPolicy.ApplicationDefined;
    this.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.ApplicationDefined;
    
    this.ItemConstraint += new EventHandler<SimpleSyncItemConstraintEventArgs>(OnItemConstraint);
    this.ItemConflicting += new EventHandler<SimpleSyncItemConflictingEventArgs>(OnItemConflicting);

    I set the event handlers to have a resolution action of merge:

    void OnItemConstraint(object sender, SimpleSyncItemConstraintEventArgs e)
    {
        e.SetResolutionAction(ConstraintConflictResolutionAction.Merge);
    }
    
    void OnItemConflicting(object sender, SimpleSyncItemConflictingEventArgs e)
    {
        e.SetResolutionAction(ConflictResolutionAction.Merge);
    }

    However, when I report a conflict in InsertItem() nothing happens afterwards and the sync process completes as normal.

    public override void InsertItem(
                object itemData, 
                IEnumerable<SyncId> changeUnitsToCreate, 
                RecoverableErrorReportingContext recoverableErrorReportingContext, 
                out ItemFieldDictionary keyAndUpdatedVersion, 
                out bool commitKnowledgeAfterThisItem) {
    
                    // other code left out for brevity
    
                    // Check if it is already there --- name collision
                    if (itemAlreadyExists)
                    {
                        recoverableErrorReportingContext.RecordConstraintError(ConstructDictionary(item.ID));
                        keyAndUpdatedVersion = null;
                        commitKnowledgeAfterThisItem = false;
    
                        return;
                    }
    
                    // other code left out for brevity
    }

    I figured that calling RecordConstraintError would trigger the event handler to deal with the conflict.

    Any help on this matter would be much appreciated!







    • Edited by evoltix Wednesday, April 11, 2012 10:08 PM
    Monday, April 2, 2012 6:41 PM

All replies

  • I have been thoroughly working on trying to get constraint handling working but haven't been able to. Can anybody shed some light that might point me in the right direction?
    • Edited by evoltix Wednesday, April 11, 2012 10:07 PM
    Wednesday, April 11, 2012 9:12 PM
  • been trying to run the sample fsp to simplesyncprovider as well and it doesnt fire the ItemConstraint event as well. on the other hand, it does fire the a skipped change event
    Thursday, April 12, 2012 9:21 AM
    Moderator
  • Thanks for your response! :)

    Is this expected behavior of a simple provider? The documentation leads me to believe that you can handle conflicts in simple providers. I too noticed that the FSP will fire the skipped change event but the simple provider won't handle conflicts.

    Thursday, April 12, 2012 3:06 PM
  • on the your custom simple provider, try adding this:

      public override void OnItemConstraint(SimpleSyncItemConstraintEventArgs args)
            {
                base.OnItemConstraint(args);
            }

    then on the InsertItem:

    OnItemConstraint(null); //just testing firing the event with a null event args

    Thursday, April 12, 2012 3:34 PM
    Moderator
  • This worked. Now what should I do?
    Thursday, April 12, 2012 4:26 PM
  • If you are handling concurrency conflict and set SetResolutionAction to ConflictResolutionAction.Merge, then your provider need to implement ISimpleSyncProviderConcurrencyConflictResolver Interface (ResolveUpdateUpdateConflict, ResolveLocalDeleteRemoteUpdateConflict, and ResolveLocalUpdateRemoteDeleteConflict.)

    If you are handling constraint conflict and set ConstraintConflictResolutionAction to either Merge, RenameDestination or RenameSource, then your provider need to implement ISimpleSyncProviderConstraintConflictResolver interface.

    Microsoft Sync Framework Simple Provider – Concurrency Conflict Handling


    Zhongchen Zhou

    • Proposed as answer by zhongchen zhou Saturday, April 14, 2012 3:17 AM
    Saturday, April 14, 2012 2:30 AM
  • If you are handling concurrency conflict and set SetResolutionAction to ConflictResolutionAction.Merge, then your provider need to implement ISimpleSyncProviderConcurrencyConflictResolver Interface (ResolveUpdateUpdateConflict, ResolveLocalDeleteRemoteUpdateConflict, and ResolveLocalUpdateRemoteDeleteConflict.)

    If you are handling constraint conflict and set ConstraintConflictResolutionAction to either Merge, RenameDestination or RenameSource, then your provider need to implement ISimpleSyncProviderConstraintConflictResolver interface.

    Microsoft Sync Framework Simple Provider – Concurrency Conflict Handling


    Zhongchen Zhou

    I have implemented the methods of ISimpleSyncProviderConstraintConflictResolver. The problem is that when I report a constraint conflict the methods never get called.
    Monday, April 16, 2012 12:08 AM
  • Hi, did you ever get the conflict events to fire? I have the same issue as you :(
    Thursday, September 6, 2012 4:48 AM