Partager via


ProcessChangeBatch méthode

En cas de substitution dans une classe dérivée, traite un ensemble de modifications en détectant les conflits et en appliquant des modifications au magasin d'éléments.

Espace de noms :  Microsoft.Synchronization
Assembly :  Microsoft.Synchronization (dans Microsoft.Synchronization.dll)

Syntaxe

'Déclaration
Public MustOverride Sub ProcessChangeBatch ( _
    resolutionPolicy As ConflictResolutionPolicy, _
    sourceChanges As ChangeBatch, _
    changeDataRetriever As Object, _
    syncCallbacks As SyncCallbacks, _
    sessionStatistics As SyncSessionStatistics _
)
'Utilisation
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
)

Paramètres

  • changeDataRetriever
    Type : System. . :: . .Object
    Objet qui peut être utilisé pour récupérer des données de modification. Il peut s'agir d'un objet IChangeDataRetriever ou d'un objet spécifique au fournisseur.
  • sessionStatistics
    Type : Microsoft.Synchronization. . :: . .SyncSessionStatistics
    Effectue le suivi des statistiques de modification. Pour un fournisseur qui utilise une application des modifications personnalisée, cet objet doit être mis à jour avec les résultats de l'application des modifications.

Notes

Quand une modification de source contient des modifications d'unité de modification, le fournisseur de destination doit déterminer, le cas échéant, les versions d'unité de modification à inclure dans le lot des versions de destination envoyé à l'applicateur de modifications. Cette décision dépend du type de modification du fournisseur de source et du fait que l'élément est marqué, ou non, comme supprimé sur le réplica de destination. Pour plus d'informations, consultez Synchronisation des unités de modification.

Exemples

L'exemple suivant obtient la version de destination de tous les éléments figurant dans le lot de modifications, et crée un objet NotifyingChangeApplier qu'il utilise pour gérer la détection de conflit et l'application des modifications.

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);
}

L'exemple suivant affiche la méthode GetLocalVersions qui est appelée dans l'exemple précédent. Cet exemple énumère les modifications figurant dans le lot de modifications de la source et crée une liste de versions de destination.

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;
}

Voir aussi

Référence

KnowledgeSyncProvider Classe

Membres KnowledgeSyncProvider

Espace de noms Microsoft.Synchronization