Share via


ProcessChangeBatch メソッド

派生クラスでオーバーライドされると、競合を検出して変更を項目ストアに適用することで、一連の変更を処理します。

名前空間:  Microsoft.Synchronization
アセンブリ:  Microsoft.Synchronization (Microsoft.Synchronization.dll 内)

構文

'宣言
Public MustOverride Sub ProcessChangeBatch ( _
    resolutionPolicy As ConflictResolutionPolicy, _
    sourceChanges As ChangeBatch, _
    changeDataRetriever As Object, _
    syncCallbacks As SyncCallbacks, _
    sessionStatistics As SyncSessionStatistics _
)
'使用
Dim instance As KnowledgeSyncProvider
Dim resolutionPolicy As ConflictResolutionPolicy
Dim sourceChanges As ChangeBatch
Dim changeDataRetriever As Object
Dim syncCallbacks As SyncCallbacks
Dim sessionStatistics As SyncSessionStatistics

instance.ProcessChangeBatch(resolutionPolicy, _
    sourceChanges, changeDataRetriever, _
    syncCallbacks, sessionStatistics)
public abstract void ProcessChangeBatch(
    ConflictResolutionPolicy resolutionPolicy,
    ChangeBatch sourceChanges,
    Object changeDataRetriever,
    SyncCallbacks syncCallbacks,
    SyncSessionStatistics sessionStatistics
)
public:
virtual void ProcessChangeBatch(
    ConflictResolutionPolicy resolutionPolicy, 
    ChangeBatch^ sourceChanges, 
    Object^ changeDataRetriever, 
    SyncCallbacks^ syncCallbacks, 
    SyncSessionStatistics^ sessionStatistics
) abstract
abstract ProcessChangeBatch : 
        resolutionPolicy:ConflictResolutionPolicy * 
        sourceChanges:ChangeBatch * 
        changeDataRetriever:Object * 
        syncCallbacks:SyncCallbacks * 
        sessionStatistics:SyncSessionStatistics -> unit 
public abstract function ProcessChangeBatch(
    resolutionPolicy : ConflictResolutionPolicy, 
    sourceChanges : ChangeBatch, 
    changeDataRetriever : Object, 
    syncCallbacks : SyncCallbacks, 
    sessionStatistics : SyncSessionStatistics
)

パラメーター

  • changeDataRetriever
    型 : System. . :: . .Object
    変更データを取得するために使用できるオブジェクトです。これには、IChangeDataRetriever オブジェクトまたはプロバイダー固有のオブジェクトを指定できます。
  • sessionStatistics
    型 : Microsoft.Synchronization. . :: . .SyncSessionStatistics
    変更の統計を追跡します。カスタム変更の適用を使用するプロバイダーの場合、このオブジェクトは、変更を適用した結果で更新する必要があります。

説明

同期元の変更に変更単位の変更が含まれている場合は、変更適用元に送られる変更単位のどのバージョンを同期先バージョンのバッチに含めるかを同期先プロバイダーが決定する必要があります。この決定は、同期元プロバイダーからの変更の種類と、同期先レプリカで項目に削除マークが付いているかどうかによって異なります。詳細については、「変更単位の同期」を参照してください。

次の例では、変更バッチのすべての項目の同期先バージョンを取得してから、NotifyingChangeApplier オブジェクトを作成し、これを使用して競合の検出と変更の適用を処理します。

public override void ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics)
{
    // Use the metadata store to get the local versions of changes received from the source provider.
    IEnumerable<ItemChange> destVersions = _itemStore.ContactReplicaMetadata.GetLocalVersions(sourceChanges);

    // Use a NotifyingChangeApplier object to process the changes. Note that this object is passed as the INotifyingChangeApplierTarget
    // object that will be called to apply changes to the item store.
    NotifyingChangeApplier changeApplier = new NotifyingChangeApplier(IdFormats);
    changeApplier.ApplyChanges(resolutionPolicy, sourceChanges, (IChangeDataRetriever)changeDataRetriever, destVersions,
        _itemStore.ContactReplicaMetadata.GetKnowledge(), _itemStore.ContactReplicaMetadata.GetForgottenKnowledge(), 
        this, _sessionContext, syncCallbacks);
}

次の例は、前の例で呼び出された GetLocalVersions メソッドを示しています。この例では、同期元の変更バッチの変更を列挙し、同期先バージョンの一覧を作成します。

public override IEnumerable<ItemChange> GetLocalVersions(ChangeBatch sourceChanges)
{
    List<ItemChange> localVersions = new List<ItemChange>();

    // Enumerate the source changes and retrieve the destination version for each source change. 
    foreach (ItemChange srcItem in sourceChanges)
    {
        ItemChange localVer;

        // When the source item exists in the destination metadata store, retrieve the destination version of the item.
        if (_items.ContainsKey(srcItem.ItemId))
        {
            XmlItemMetadata localMeta = _items[srcItem.ItemId];
            ChangeKind kind = (localMeta.IsDeleted) ? ChangeKind.Deleted : ChangeKind.Update;
            localVer = new ItemChange(IdFormats, ReplicaId, srcItem.ItemId, kind, localMeta.CreationVersion, localMeta.ChangeVersion);
        }
        // When the source item does not exist in the destination metadata store, create a new change with unknown
        // version information.
        else
        {
            localVer = new ItemChange(IdFormats, ReplicaId, srcItem.ItemId, ChangeKind.UnknownItem, SyncVersion.UnknownVersion, SyncVersion.UnknownVersion);
        }

        localVersions.Add(localVer);
    }

    return localVersions;
}

参照

参照

KnowledgeSyncProviderクラス

KnowledgeSyncProvider メンバー

Microsoft.Synchronization 名前空間