static void RegisterCallbacks(MySyncProvider provider) { provider.DestinationCallbacks.FullEnumerationNeeded += new EventHandler <FullEnumerationNeededEventArgs>(DestinationCallbacks_FullEnumerationNeeded); provider.DestinationCallbacks.ItemChangeSkipped += new EventHandler <ItemChangeSkippedEventArgs>(DestinationCallbacks_ItemChangeSkipped); provider.DestinationCallbacks.ItemChanging += new EventHandler <ItemChangingEventArgs>(DestinationCallbacks_ItemChanging); provider.DestinationCallbacks.ItemConflicting += new EventHandler <ItemConflictingEventArgs>(DestinationCallbacks_ItemConflicting); provider.DestinationCallbacks.ProgressChanged += new EventHandler <SyncStagedProgressEventArgs>(DestinationCallbacks_ProgressChanged); }
static void DoBidirectionalSync(string nameA, MySimpleDataStore storeA, string nameB, MySimpleDataStore storeB) { SyncOperationStatistics stats; MySyncProvider providerA = new MySyncProvider(nameA, storeA); MySyncProvider providerB = new MySyncProvider(nameB, storeB); //Set the provider's conflict resolution policy to custom (in order to show how to do complex resolution actions) providerA.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.ApplicationDefined; providerB.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.ApplicationDefined; //Register callbacks so we can handle conflicts in the event that they're detected... And other things. RegisterCallbacks(providerA); RegisterCallbacks(providerB); //Sync providers Console.WriteLine("Sync {0} and {1}...", nameA, nameB); SyncOrchestrator agent = new SyncOrchestrator(); agent.Direction = SyncDirectionOrder.DownloadAndUpload; agent.LocalProvider = providerA; agent.RemoteProvider = providerB; stats = agent.Synchronize(); // Display the SyncOperationStatistics Console.WriteLine("Download Applied:\t {0}", stats.DownloadChangesApplied); Console.WriteLine("Download Failed:\t {0}", stats.DownloadChangesFailed); Console.WriteLine("Download Total:\t\t {0}", stats.DownloadChangesTotal); Console.WriteLine("Upload Total:\t\t {0}", stats.UploadChangesApplied); Console.WriteLine("Upload Total:\t\t {0}", stats.UploadChangesFailed); Console.WriteLine("Upload Total:\t\t {0}", stats.UploadChangesTotal); //Show the results of sync Console.WriteLine(providerA.ToString()); Console.WriteLine(storeA.ToString()); Console.WriteLine(providerB.ToString()); Console.WriteLine(storeB.ToString()); }
static void RegisterCallbacks(MySyncProvider provider) { provider.DestinationCallbacks.FullEnumerationNeeded += new EventHandler<FullEnumerationNeededEventArgs>(DestinationCallbacks_FullEnumerationNeeded); provider.DestinationCallbacks.ItemChangeSkipped += new EventHandler<ItemChangeSkippedEventArgs>(DestinationCallbacks_ItemChangeSkipped); provider.DestinationCallbacks.ItemChanging += new EventHandler<ItemChangingEventArgs>(DestinationCallbacks_ItemChanging); provider.DestinationCallbacks.ItemConflicting += new EventHandler<ItemConflictingEventArgs>(DestinationCallbacks_ItemConflicting); provider.DestinationCallbacks.ProgressChanged += new EventHandler<SyncStagedProgressEventArgs>(DestinationCallbacks_ProgressChanged); }
static void DoBidirectionalSync(string nameA, MySimpleDataStore storeA, string nameB, MySimpleDataStore storeB) { SyncOperationStatistics stats; MySyncProvider providerA = new MySyncProvider(nameA, storeA); MySyncProvider providerB = new MySyncProvider(nameB, storeB); //Set the provider's conflict resolution policy to custom (in order to show how to do complex resolution actions) providerA.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.ApplicationDefined; providerB.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.ApplicationDefined; //Register callbacks so we can handle conflicts in the event that they're detected... And other things. RegisterCallbacks(providerA); RegisterCallbacks(providerB); //Sync providers Console.WriteLine("Sync {0} and {1}...", nameA, nameB); SyncOrchestrator agent = new SyncOrchestrator(); agent.Direction = SyncDirectionOrder.DownloadAndUpload; agent.LocalProvider = providerA; agent.RemoteProvider = providerB; stats = agent.Synchronize(); // Display the SyncOperationStatistics Console.WriteLine("Download Applied:\t {0}", stats.DownloadChangesApplied); Console.WriteLine("Download Failed:\t {0}", stats.DownloadChangesFailed); Console.WriteLine("Download Total:\t\t {0}", stats.DownloadChangesTotal); Console.WriteLine("Upload Total:\t\t {0}", stats.UploadChangesApplied); Console.WriteLine("Upload Total:\t\t {0}", stats.UploadChangesFailed); Console.WriteLine("Upload Total:\t\t {0}", stats.UploadChangesTotal); //Show the results of sync Console.WriteLine(providerA.ToString()); Console.WriteLine(storeA.ToString()); Console.WriteLine(providerB.ToString()); Console.WriteLine(storeB.ToString()); }