我已經實現了一個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
退出後想通。
任何有識之士將不勝感激!
你是否修復過這個問題?我在同一個問題上奮戰了幾天。 – jacktric 2017-03-04 16:55:13