public void Synchronize(SyncDirectionOrder syncDirection, KnowledgeSyncProvider localProvider, KnowledgeSyncProvider remoteProvider, uint batchSize) { FileStoreSync fileStoreSync = localProvider as FileStoreSync; fileStoreSync.RequestedBatchSize = batchSize; ((FileStoreProxy)remoteProvider).RequestedBatchSize = batchSize; // Use sync-callbacks for conflicting items SyncCallbacks destCallbacks = localProvider.DestinationCallbacks; destCallbacks.ItemConflicting += new EventHandler <ItemConflictingEventArgs>(OnItemConflicting); destCallbacks.ItemConstraint += new EventHandler <ItemConstraintEventArgs>(OnItemConstraint); localProvider.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.SourceWins; remoteProvider.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.SourceWins; // Initiate orchestrator and sync SyncOrchestrator orchestrator = new SyncOrchestrator(); orchestrator.LocalProvider = localProvider; orchestrator.RemoteProvider = remoteProvider; // Set sync direction orchestrator.Direction = syncDirection; // Execute the synchronize process SyncOperationStatistics syncStats = orchestrator.Synchronize(); // Notify a synchronization took place FileSystemSynchronizedEventArgs ev = new FileSystemSynchronizedEventArgs(syncStats); OnSynchronized(orchestrator, ev); }
public override void ProcessFullEnumerationChangeBatch( ConflictResolutionPolicy resolutionPolicy, FullEnumerationChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics) { throw new NotImplementedException(); }
public void Synchronize(SyncDirectionOrder syncDirection, KnowledgeSyncProvider localProvider, KnowledgeSyncProvider remoteProvider) { // Register event handlers FileSyncProvider fileSyncProvider = localProvider as FileSyncProvider; fileSyncProvider.AppliedChange += new EventHandler <AppliedChangeEventArgs>(OnAppliedChange); fileSyncProvider.SkippedChange += new EventHandler <SkippedChangeEventArgs>(OnSkippedChange); // Use sync-callbacks for conflicting items SyncCallbacks destCallbacks = localProvider.DestinationCallbacks; destCallbacks.ItemConflicting += new EventHandler <ItemConflictingEventArgs>(OnItemConflicting); destCallbacks.ItemConstraint += new EventHandler <ItemConstraintEventArgs>(OnItemConstraint); // Initiate orchestrator and sync SyncOrchestrator orchestrator = new SyncOrchestrator(); orchestrator.LocalProvider = localProvider; orchestrator.RemoteProvider = remoteProvider; // Set sync direction orchestrator.Direction = syncDirection; // Execute the synchronize process SyncOperationStatistics syncStats = orchestrator.Synchronize(); // Notify a synchronization took place FileSystemSynchronizedEventArgs ev = new FileSystemSynchronizedEventArgs(syncStats); OnSynchronized(orchestrator, ev); }
protected override void SynchronizeSyncScope(string syncScope, SyncDirectionOrder synDirection, KnowledgeSyncProvider localProvider, KnowledgeSyncProvider remoteProvider) { // Create the sync orchestrator SyncOrchestrator orchestrator = new SyncOrchestrator(); // Set local provider of orchestrator to a sync provider associated with the sync scope in the client database orchestrator.LocalProvider = localProvider; // Set remote provider of orchestrator to a sync provider associated with the sync scope in the server database orchestrator.RemoteProvider = remoteProvider; // Set the direction of sync session orchestrator.Direction = synDirection; // Use sync-callbacks for conflicting items SyncCallbacks destCallbacks = ((KnowledgeSyncProvider)orchestrator.RemoteProvider).DestinationCallbacks; destCallbacks.ItemConflicting += new EventHandler <ItemConflictingEventArgs>(OnItemConfliting); destCallbacks.ItemConstraint += new EventHandler <ItemConstraintEventArgs>(OnItemConstraint); // Subcribe for errors that occur when applying changes to the client ((SqlSyncProvider)orchestrator.LocalProvider).ApplyChangeFailed += new EventHandler <DbApplyChangeFailedEventArgs>(OnApplyChangeFailed); ((SqlSyncProvider)orchestrator.LocalProvider).ChangesApplied += new EventHandler <DbChangesAppliedEventArgs>(OnChangesApplied); // Execute the synchronize process SyncOperationStatistics syncStats = orchestrator.Synchronize(); // Notify a synchronization took place DbSynchronizedEventArgs ev = new DbSynchronizedEventArgs(syncStats); OnSynchronized(orchestrator, ev); destCallbacks.ItemConflicting -= new EventHandler <ItemConflictingEventArgs>(OnItemConfliting); destCallbacks.ItemConstraint -= new EventHandler <ItemConstraintEventArgs>(OnItemConstraint); ((SqlSyncProvider)orchestrator.LocalProvider).ApplyChangeFailed -= new EventHandler <DbApplyChangeFailedEventArgs>(OnApplyChangeFailed); }
public override void ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallback, SyncSessionStatistics sessionStatistics) { SyncSessionStatistics remoteSessionStatistics = new SyncSessionStatistics(); syncProxy.ApplyChanges(resolutionPolicy, sourceChanges, changeDataRetriever, ref remoteSessionStatistics); sessionStatistics.ChangesApplied = remoteSessionStatistics.ChangesApplied; sessionStatistics.ChangesFailed = remoteSessionStatistics.ChangesFailed; }
public void ApplyChanges( ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeData, ref SyncSessionStatistics sessionStatistics) { SyncCallbacks syncCallback = new SyncCallbacks(); peerProvider.ProcessChangeBatch(resolutionPolicy, sourceChanges, changeData, syncCallback, sessionStatistics); }
public override void ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallback, SyncSessionStatistics sessionStatistics) { _metadataStore.BeginTransaction(); IEnumerable<ItemChange> localChanges = _metadataStore.Metadata.GetLocalVersions(sourceChanges); NotifyingChangeApplier changeApplier = new NotifyingChangeApplier(_idFormats); changeApplier.ApplyChanges(resolutionPolicy, sourceChanges, changeDataRetriever as IChangeDataRetriever, localChanges, _metadataStore.Metadata.GetKnowledge(), _metadataStore.Metadata.GetForgottenKnowledge(), _changeApplier, _currentSessionContext, syncCallback); _metadataStore.CommitTransaction(); }
public override void ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallback, SyncSessionStatistics sessionStatistics) { _metadataStore.BeginTransaction(); IEnumerable <ItemChange> localChanges = _metadataStore.Metadata.GetLocalVersions(sourceChanges); NotifyingChangeApplier changeApplier = new NotifyingChangeApplier(_idFormats); changeApplier.ApplyChanges(resolutionPolicy, sourceChanges, changeDataRetriever as IChangeDataRetriever, localChanges, _metadataStore.Metadata.GetKnowledge(), _metadataStore.Metadata.GetForgottenKnowledge(), _changeApplier, _currentSessionContext, syncCallback); _metadataStore.CommitTransaction(); }
//Change application! public override void ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallback, SyncSessionStatistics sessionStatistics) { _metadataStore.BeginTransaction(); //Get all my local change versions from the metadata store IEnumerable <ItemChange> localChanges = _metadata.GetLocalVersions(sourceChanges); //Create a changeapplier object to make change application easier (make the engine call me //when it needs data and when I should save data) NotifyingChangeApplier changeApplier = new NotifyingChangeApplier(_idFormats); changeApplier.ApplyChanges(resolutionPolicy, sourceChanges, changeDataRetriever as IChangeDataRetriever, localChanges, _metadata.GetKnowledge(), _metadata.GetForgottenKnowledge(), this, _currentSessionContext, syncCallback); _metadataStore.CommitTransaction(); }
/// <summary> /// Start the synchronization in one direction /// </summary> /// <param name="sourcePath">This parameter holds the source folder path</param> /// <param name="destPath">This parameter holds the destination folder path</param> /// <param name="filter">This parameter is the filter which will be used during synchronization</param> /// <param name="options">This parameter holds the synchronization options</param> private void SyncFileSystemReplicasOneWay(string sourcePath, string destPath, FileSyncScopeFilter filter, FileSyncOptions options) { FileSyncProvider sourceProvider = null; FileSyncProvider destProvider = null; try { sourceProvider = new FileSyncProvider(sourcePath, filter, options); destProvider = new FileSyncProvider(destPath, filter, options); sourceProvider.PreviewMode = true; destProvider.PreviewMode = true; destProvider.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.ApplicationDefined; SyncCallbacks destinationCallBacks = destProvider.DestinationCallbacks; destinationCallBacks.ItemConflicting += new EventHandler <ItemConflictingEventArgs>(OnItemConflicting); destinationCallBacks.ItemConstraint += new EventHandler <ItemConstraintEventArgs>(OnItemConstraint); destProvider.ApplyingChange += new EventHandler <ApplyingChangeEventArgs>(OnApplyingChange); SyncOrchestrator agent = new SyncOrchestrator(); agent.LocalProvider = sourceProvider; agent.RemoteProvider = destProvider; agent.Direction = SyncDirectionOrder.Upload; agent.Synchronize(); } finally { if (sourceProvider != null) { sourceProvider.Dispose(); } if (destProvider != null) { destProvider.Dispose(); } } }
public override void ProcessFullEnumerationChangeBatch( ConflictResolutionPolicy resolutionPolicy, FullEnumerationChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallback, SyncSessionStatistics sessionStatistics) { CachedChangeDataRetriever cachedChangeDataRetriever = new CachedChangeDataRetriever( changeDataRetriever as IChangeDataRetriever, sourceChanges); byte[] newChangeApplierInfo = this.client.ProcessFullEnumerationChangeBatch( resolutionPolicy, sourceChanges, cachedChangeDataRetriever, this.syncSessionContext.ChangeApplierInfo); this.syncSessionContext.ChangeApplierInfo = newChangeApplierInfo; }
private static void SyncFileSystemReplicaOneWay(string replicaSourcePath, string replicaTargetPath, FileSyncScopeFilter filter, FileSyncOptions options) { FileSyncProvider sourceProvider = null; FileSyncProvider targetProvider = null; try { sourceProvider = new FileSyncProvider(replicaSourcePath, filter, options); targetProvider = new FileSyncProvider(replicaTargetPath, filter, options); targetProvider.AppliedChange += new EventHandler <AppliedChangeEventArgs>(OnAppliedChange); targetProvider.SkippedChange += new EventHandler <SkippedChangeEventArgs>(OnSkippedChange); SyncCallbacks targetCallbacks = targetProvider.DestinationCallbacks; targetCallbacks.ItemConflicting += new EventHandler <ItemConflictingEventArgs>(OnItemConflicting); targetCallbacks.ItemConstraint += new EventHandler <ItemConstraintEventArgs>(OnItemConstraint); SyncOrchestrator agent = new SyncOrchestrator(); agent.LocalProvider = sourceProvider; agent.RemoteProvider = targetProvider; agent.Direction = SyncDirectionOrder.Upload; Console.WriteLine("Sincronizando cambios: {0}", targetProvider.RootDirectoryPath); agent.Synchronize(); } finally { if (sourceProvider != null) { sourceProvider.Dispose(); } if (targetProvider != null) { targetProvider.Dispose(); } } }
public override void ProcessChangeBatch( ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallback, SyncSessionStatistics sessionStatistics) { try { CachedChangeDataRetriever cachedChangeDataRetriever = new CachedChangeDataRetriever( changeDataRetriever as IChangeDataRetriever, sourceChanges); byte[] newChangeApplierInfo = this.client.ProcessChangeBatch( resolutionPolicy, sourceChanges, cachedChangeDataRetriever, this.syncSessionContext.ChangeApplierInfo); this.syncSessionContext.ChangeApplierInfo = newChangeApplierInfo; } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// Download Mechanism /// </summary> /// <param name="resolutionPolicy"></param> /// <param name="sourceChanges"></param> /// <param name="changeDataRetriever"></param> /// <param name="syncCallback"></param> /// <param name="sessionStatistics"></param> public override void ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallback, SyncSessionStatistics sessionStatistics) { ChangeBatch localVersions = sync.GetChanges(sourceChanges); ForgottenKnowledge destinationForgottenKnowledge = new ForgottenKnowledge(sync.IdFormats, sync.SyncKnowledge); NotifyingChangeApplier changeApplier = new NotifyingChangeApplier(sync.IdFormats); changeApplier.ApplyChanges(resolutionPolicy, CollisionConflictResolutionPolicy.Merge, sourceChanges, (IChangeDataRetriever)changeDataRetriever, localVersions, sync.SyncKnowledge.Clone(), destinationForgottenKnowledge, this, _memConflictLog, currentSessionContext, syncCallback); }
/// <inheritdoc /> public override void ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics) { // anyone know how to implement ??? throw new NotImplementedException(); }
public override void ProcessFullEnumerationChangeBatch(ConflictResolutionPolicy resolutionPolicy, FullEnumerationChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallback, SyncSessionStatistics sessionStatistics) { throw new NotImplementedException("The method or operation is not implemented."); }
/// <summary> /// Upload mechanism /// </summary> /// <param name="resolutionPolicy"></param> /// <param name="sourceChanges">Local File Changes</param> /// <param name="changeDataRetriever"></param> /// <param name="syncCallback"></param> /// <param name="sessionStatistics"></param> public override void ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallback, SyncSessionStatistics sessionStatistics) { myForgottenKnowledge = new ForgottenKnowledge(IdFormats, myKnowledge); NotifyingChangeApplier changeApplier = new NotifyingChangeApplier(IdFormats); changeApplier.ApplyChanges(resolutionPolicy, sourceChanges, (IChangeDataRetriever)changeDataRetriever, myKnowledge.Clone(), myForgottenKnowledge, this, currentSessionContext, syncCallback); }
public override void ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics) { ItemsChangeInfo localVersions = null; try { localVersions = Proxy.GetChanges(Path, sourceChanges, _filters); } catch (Exception ex) { throw ex; } // Now we call the change applier // The change applier will compare the local and remote versions, apply // non-conflicting changes, and will also detect conflicts and react as specified ForgottenKnowledge = new ForgottenKnowledge(IdFormats, SyncKnowledge); NotifyingChangeApplier changeApplier = new NotifyingChangeApplier(IdFormats); changeApplier.ApplyChanges(resolutionPolicy, sourceChanges, changeDataRetriever as IChangeDataRetriever, RemoteSyncDetails.GenerateChanges(localVersions), SyncKnowledge.Clone(), ForgottenKnowledge, this, SyncSessionContext, syncCallbacks); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public override void ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, ForgottenKnowledge sourceForgottenKnowledge, object changeDataRetriever, SyncCallbacks syncCallback, SyncSessionStatistics sessionStatistics) { throw new NotImplementedException(); }
//If full enumeration is needed because this provider is out of date due to tombstone cleanup, then this method will be called by the engine. public override void ProcessFullEnumerationChangeBatch(ConflictResolutionPolicy resolutionPolicy, FullEnumerationChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallback, SyncSessionStatistics sessionStatistics) { _metadataStore.BeginTransaction(); //Get all my local change versions from the metadata store IEnumerable<ItemChange> localChanges = _metadata.GetFullEnumerationLocalVersions(sourceChanges); //Create a changeapplier object to make change application easier (make the engine call me //when it needs data and when I should save data) NotifyingChangeApplier changeApplier = new NotifyingChangeApplier(_idFormats); changeApplier.ApplyFullEnumerationChanges(resolutionPolicy, sourceChanges, changeDataRetriever as IChangeDataRetriever, localChanges, _metadata.GetKnowledge(), _metadata.GetForgottenKnowledge(), this, _currentSessionContext, syncCallback); _metadataStore.CommitTransaction(); }
public override void ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics) { DbSyncContext context = changeDataRetriever as DbSyncContext; if (context != null && context.IsDataBatched) { string fileName = new FileInfo(context.BatchFileName).Name; //Retrieve the remote peer id from the MadeWithKnowledge.ReplicaId. MadeWithKnowledge is the local knowledge of the peer //that is enumerating the changes. string peerId = context.MadeWithKnowledge.ReplicaId.ToString(); //Check to see if service already has this file if (!this.proxy.HasUploadedBatchFile(fileName, peerId)) { //Upload this file to remote service FileStream stream = new FileStream(context.BatchFileName, FileMode.Open, FileAccess.Read); byte[] contents = new byte[stream.Length]; using (stream) { stream.Read(contents, 0, contents.Length); } this.proxy.UploadBatchFile(fileName, contents, peerId); } context.BatchFileName = fileName; } SyncSessionStatistics stats = this.proxy.ApplyChanges(resolutionPolicy, sourceChanges, changeDataRetriever); sessionStatistics.ChangesApplied += stats.ChangesApplied; sessionStatistics.ChangesFailed += stats.ChangesFailed; }
public override void ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics) { IEnumerable <ItemChange> localVersions = _sync.GetChanges(sourceChanges); // Now we call the change applier // The change applier will compare the local and remote versions, apply // non-conflicting changes, and will also detect conflicts and react as specified ForgottenKnowledge destinationForgottenKnowledge = new ForgottenKnowledge(_sync.IdFormats, _sync.SyncKnowledge); NotifyingChangeApplier changeApplier = new NotifyingChangeApplier(_sync.IdFormats); changeApplier.ApplyChanges(resolutionPolicy, sourceChanges, changeDataRetriever as IChangeDataRetriever, localVersions, _sync.SyncKnowledge.Clone(), destinationForgottenKnowledge, this, SyncSessionContext, syncCallbacks); }
/// <summary> /// When overridden in a derived class, processes a set of changes for a full enumeration by applying changes to the item store. /// </summary> /// <param name="resolutionPolicy">The conflict resolution policy to use when this method applies changes.</param> /// <param name="sourceChanges">A batch of changes from the source provider to be applied locally.</param> /// <param name="changeDataRetriever">An object that can be used to retrieve change data. It can be an <see cref="T:Microsoft.Synchronization.IChangeDataRetriever"/> object or a provider-specific object.</param> /// <param name="syncCallbacks">An object that receives event notifications during change application.</param> /// <param name="sessionStatistics">Tracks change statistics. For a provider that uses custom change application, this object must be updated with the results of the change application.</param> public override void ProcessFullEnumerationChangeBatch(ConflictResolutionPolicy resolutionPolicy, FullEnumerationChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics) { CachedChangeDataRetriever cachedChangeDataRetriever = new CachedChangeDataRetriever( changeDataRetriever as IChangeDataRetriever, sourceChanges); byte[] rawSourceChanges = sourceChanges.Serialize(); byte[] rawCachedChangeDataRetriever = SerializerHelper.BinarySerialize(cachedChangeDataRetriever); byte[] newChangeApplierInfo = _syncService.ProcessFullEnumerationChangeBatch( (int)resolutionPolicy, rawSourceChanges, rawCachedChangeDataRetriever, _syncSessionContext.ChangeApplierInfo); _syncSessionContext.ChangeApplierInfo = newChangeApplierInfo; }
public override void ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics) { var context = changeDataRetriever as DbSyncContext; if (context != null && context.IsDataBatched) { var fileName = new FileInfo(context.BatchFileName).Name; //Retrieve the remote peer id from the MadeWithKnowledge.ReplicaId. //MadeWithKnowledge is the local knowledge of the peer //that is enumerating the changes. var peerId = context.MadeWithKnowledge.ReplicaId.ToString(); //Check to see if service already has this file if (!_proxy.HasUploadedBatchFile(fileName, peerId)) { //Upload this file to remote service var stream = new FileStream(context.BatchFileName, FileMode.Open, FileAccess.Read); var contents = new byte[stream.Length]; using (stream) { stream.Read(contents, 0, contents.Length); } _proxy.UploadBatchFile(fileName, contents, peerId); } context.BatchFileName = fileName; } var stats = _proxy.ApplyChanges(resolutionPolicy, sourceChanges, changeDataRetriever); sessionStatistics.ChangesApplied += stats.ChangesApplied; sessionStatistics.ChangesFailed += stats.ChangesFailed; }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public override void ProcessFullEnumerationChangeBatch(ConflictResolutionPolicy resolutionPolicy, SyncId destinationVersionEnumerationRangeLowerBound, SyncId destinationVersionEnumerationRangeUpperBound, ChangeBatch sourceChanges, ForgottenKnowledge sourceForgottenKnowledge, object changeDataRetriever, SyncCallbacks syncCallback, SyncSessionStatistics sessionStatistics) { throw new NotImplementedException(); }
public override void ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics) { DbSyncContext context = changeDataRetriever as DbSyncContext; // Check if the data is batched if (context != null && context.IsDataBatched) { string filename = new FileInfo(context.BatchFileName).Name; // Retrieve the remote id from the MadeWithKnowledge.ReplicaId. MadeWithKnowledge is the local knowledge of the peer // that is enumerating the changes string remoteId = context.MadeWithKnowledge.ReplicaId.ToString(); // Check if service already has this file if (!Proxy.HasUploadedBatchFile(filename, remoteId)) { // Upload this file to remote service byte[] content = null; using (Stream stream = new FileStream(context.BatchFileName, FileMode.Open, FileAccess.Read)) { content = new byte[stream.Length]; stream.Read(content, 0, content.Length); } if (content != null) { Proxy.UploadBatchFile(filename, content, remoteId); } } context.BatchFileName = filename; } SyncSessionStatistics stats = Proxy.ApplyChanges(resolutionPolicy, sourceChanges, changeDataRetriever); sessionStatistics.ChangesApplied += stats.ChangesApplied; sessionStatistics.ChangesFailed += stats.ChangesFailed; }
public override void ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics) { SyncSessionStatistics stats = Proxy.ApplyChanges(resolutionPolicy, sourceChanges, changeDataRetriever); sessionStatistics.ChangesApplied += stats.ChangesApplied; sessionStatistics.ChangesFailed += stats.ChangesFailed; }
/// <inheritdoc /> public override void ProcessFullEnumerationChangeBatch(ConflictResolutionPolicy resolutionPolicy, FullEnumerationChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics) { // anyone know how to implement ??? throw new NotImplementedException(); }
/// <summary> /// Start the synchronization in one direction /// </summary> /// <param name="sourcePath">This parameter holds the source folder path</param> /// <param name="destPath">This parameter holds the destination folder path</param> /// <param name="filter">This parameter is the filter which will be used during synchronization</param> /// <param name="options">This parameter holds the synchronization options</param> /// <param name="isPreview">This parameter is a boolean which indicates if this method should be run in preview mode</param> /// <returns>Returns a boolean to indicate if the the synchronization was successful</returns> private bool SyncFileSystemReplicasOneWay(string sourcePath, string destPath, FileSyncScopeFilter filter, FileSyncOptions options, bool isPreview) { FileSyncProvider sourceProvider = null; FileSyncProvider destProvider = null; try { sourceProvider = new FileSyncProvider(sourcePath, filter, options); destProvider = new FileSyncProvider(destPath, filter, options); // When it's in preview mode, no actual changes are done. // This mode is used to compute the number of changes that will be carried out later if (isPreview) { sourceProvider.PreviewMode = true; destProvider.PreviewMode = true; } else { sourceProvider.PreviewMode = false; destProvider.PreviewMode = false; } if (isPreview) { if (!isCheckForLeftDone) { freeDiskSpaceForLeft = GetFreeDiskSpaceInBytes(sourcePath.Substring(0, 1)); freeDiskSpaceForRight = GetFreeDiskSpaceInBytes(destPath.Substring(0, 1)); } } destProvider.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.ApplicationDefined; SyncCallbacks destinationCallBacks = destProvider.DestinationCallbacks; destinationCallBacks.ItemConflicting += new EventHandler <ItemConflictingEventArgs>(OnItemConflicting); if (isPreview) { destProvider.ApplyingChange += new EventHandler <ApplyingChangeEventArgs>(OnApplyingChange); } else { destProvider.AppliedChange += new EventHandler <AppliedChangeEventArgs>(OnAppliedChange); } agent = new SyncOrchestrator(); agent.LocalProvider = sourceProvider; agent.RemoteProvider = destProvider; agent.Direction = SyncDirectionOrder.Upload; agent.Synchronize(); if (isPreview) { return(CheckSpace()); } return(true); } catch (SyncAbortedException e) { throw e; } finally { if (sourceProvider != null) { sourceProvider.Dispose(); } if (destProvider != null) { destProvider.Dispose(); } } }