Conflicts and constraints not being handled in SimpleSyncProvider

Proposed Answer Conflicts and constraints not being handled in SimpleSyncProvider

  • 2 kwietnia 2012 18:41
     
      Zawiera kod

    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!







    • Zmodyfikowany przez evoltix 2 kwietnia 2012 18:43
    • Zmodyfikowany przez evoltix 2 kwietnia 2012 18:44
    • Zmodyfikowany przez evoltix 2 kwietnia 2012 21:32
    • Zmodyfikowany przez evoltix 11 kwietnia 2012 22:07
    • Zmodyfikowany przez evoltix 11 kwietnia 2012 22:08
    •  

Wszystkie odpowiedzi

  • 11 kwietnia 2012 21:12
     
     
    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?
    • Zmodyfikowany przez evoltix 11 kwietnia 2012 22:07
    •  
  • 12 kwietnia 2012 09:21
    Moderator
     
     
    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
  • 12 kwietnia 2012 15:06
     
     

    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.

  • 12 kwietnia 2012 15:34
    Moderator
     
      Zawiera kod

    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

  • 12 kwietnia 2012 16:26
     
     
    This worked. Now what should I do?
  • 14 kwietnia 2012 02:30
     
     Proponowana odpowiedź

    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

    • Zaproponowany jako odpowiedź przez zhongchen zhou 14 kwietnia 2012 03:17
    •  
  • 16 kwietnia 2012 00:08
     
     

    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.
  • 6 września 2012 04:48
     
     
    Hi, did you ever get the conflict events to fire? I have the same issue as you :(