2012-04-03 29 views
1

我已經實現了一個FullEnumerationSimpleSyncProvider,似乎沒有處理衝突。同步框架:在SimpleSyncProvider中沒有處理衝突

在我已經設置了下列屬性的構造:

this.Configuration.CollisionConflictResolutionPolicy = CollisionConflictResolutionPolicy.ApplicationDefined; 
this.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.ApplicationDefined; 

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

我的事件處理程序約束和衝突:

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

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

然而,當我報告了InsertItem()約束的衝突/衝突事件處理程序從不被調用。

public override void InsertItem(
     object itemData, 
     IEnumerable<SyncId> changeUnitsToCreate, 
     RecoverableErrorReportingContext recoverableErrorReportingContext, 
     out ItemFieldDictionary keyAndUpdatedVersion, 
     out bool commitKnowledgeAfterThisItem) { 

      // ...snip... 

      // Check if it is already there --- name collision 
      if (itemAlreadyExists) 
      { 
       recoverableErrorReportingContext.RecordConstraintError(ConstructDictionary(item.ID)); 
       keyAndUpdatedVersion = null; 
       commitKnowledgeAfterThisItem = false; 

       return; 
      } 

      // ...snip... 
} 

我打電話RecordConstraintError當同步框架將調用適當的事件處理程序InsertItem退出後想通。

任何有識之士將不勝感激!

+0

你是否修復過這個問題?我在同一個問題上奮戰了幾天。 – jacktric 2017-03-04 16:55:13

回答

0

如果你正在處理併發衝突,並設置SetResolutionAction到ConflictResolutionAction.Merge,那麼你的供應商需要實現ISimpleSyncProviderConcurrencyConflictResolver接口(ResolveUpdateUpdateConflict,ResolveLocalDeleteRemoteUpdateConflict和ResolveLocalUpdateRemoteDeleteConflict。)

如果你正在處理約束衝突,並設置ConstraintConflictResolutionAction要麼合併,RenameDestination或RenameSource,那麼你的提供者需要實現ISimpleSyncProviderConstraintConflictResolver接口。

Microsoft Sync Framework Simple Provider – Concurrency Conflict Handling

+1

問題不在於實現接口。問題在於,在使用recoverableErrorReportingContext.RecordConstraintError和recoverableErrorReportingContext.RecordRecoverableErrorForChange時,從未引發委託。如果這些問題從未出現過,我們應該如何解決同步問題? – 2012-11-19 16:20:50