1

FullEnumerationSimpleSyncProvider競合を処理していないように見える を実装しました。

コンストラクターで、次のプロパティを設定しました。

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

どんな洞察も大歓迎です!

4

1 に答える 1

0

同時実行の競合を処理し、SetResolutionAction を ConflictResolutionAction.Merge に設定する場合、プロバイダは ISimpleSyncProviderConcurrencyConflictResolver インターフェイス (ResolveUpdateUpdateConflict、ResolveLocalDeleteRemoteUpdateConflict、および ResolveLocalUpdateRemoteDeleteConflict) を実装する必要があります。

制約の競合を処理し、ConstraintConflictResolutionAction を Merge、RenameDestination、または RenameSource に設定する場合、プロバイダは ISimpleSyncProviderConstraintConflictResolver インターフェイスを実装する必要があります。

Microsoft Sync Framework シンプル プロバイダー – 同時実行競合の処理

于 2012-04-14T02:58:43.537 に答える