Пример #1
0
        static void DoSync(KnowledgeSyncProvider providerNameA, KnowledgeSyncProvider providerNameB, SyncDirectionOrder syncOrder)
        {
            SyncOperationStatistics stats;

            // Set the provider's conflict resolution policy since we are doing remote sync, we don't
            // want to see callbacks.
            providerNameA.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.DestinationWins;
            providerNameB.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.DestinationWins;

            //Sync providers
            Console.WriteLine("Sync A -{0} and B -{1}...", providerNameA.ToString(), providerNameB.ToString());
            SyncOrchestrator agent = new SyncOrchestrator();

            agent.Direction      = syncOrder;
            agent.LocalProvider  = providerNameA;
            agent.RemoteProvider = providerNameB;
            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
        }
Пример #2
0
        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);
        }
Пример #3
0
        static void CleanUpProvider(KnowledgeSyncProvider provider)
        {
            AppointmentSyncProvider   outlookProvider = provider as AppointmentSyncProvider;
            CalendarEventSyncProvider ibnProvider     = provider as CalendarEventSyncProvider;

            if (outlookProvider != null)
            {
                // Remove the data store file
                string metafile = outlookProvider.CurrentSetting.CurrentSyncAppSetting.metaDataFileName;
                if (System.IO.File.Exists(metafile))
                {
                    System.IO.File.Delete(metafile);
                }
            }
            else if (ibnProvider != null)
            {
                FilterElement filterEl = new FilterElement(SynchronizationMetadataRow.ColumnReplicaId, FilterElementType.Equal, ibnProvider.ReplicaId.GetGuidId());
                foreach (SynchronizationMetadataRow row in SynchronizationMetadataRow.List(filterEl))
                {
                    BusinessManager.Delete(new CalendarEventEntity((PrimaryKeyId)row.Uri));

                    row.Delete();
                }
                SynchronizationReplicaRow.Delete(ibnProvider.ReplicaId.GetGuidId());
            }
        }
Пример #4
0
        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);
        }
Пример #5
0
        public void Sync_IBN_TO_Outlook()
        {
            KnowledgeSyncProvider ibnProvider     = GetProviderForSynchronization(providerNameA);
            KnowledgeSyncProvider outlookProvider = GetProviderForSynchronization(providerNameB);

            //Sync providers A and provider B
            DoSync(ibnProvider, outlookProvider, SyncDirectionOrder.Upload);
        }
Пример #6
0
        public void CleanupProvider()
        {
            KnowledgeSyncProvider providerA = GetProviderForSynchronization(providerNameA);
            KnowledgeSyncProvider providerB = GetProviderForSynchronization(providerNameB);

            CleanUpProvider(providerA);
            CleanUpProvider(providerB);
        }
Пример #7
0
        private SyncOperationStatistics SynchronizeProviders(KnowledgeSyncProvider localProvider, KnowledgeSyncProvider remoteProvider)
        {
            SyncOrchestrator orchestrator = new SyncOrchestrator();

            orchestrator.LocalProvider  = localProvider;
            orchestrator.RemoteProvider = remoteProvider;
            orchestrator.Direction      = SyncDirectionOrder.UploadAndDownload;

            var stats = orchestrator.Synchronize();

            return(stats);
        }
Пример #8
0
        public void BidirectionalSync_Outlook_IBN()
        {
            KnowledgeSyncProvider providerA = GetProviderForSynchronization(providerNameA);
            KnowledgeSyncProvider providerB = GetProviderForSynchronization(providerNameB);

            //Sync providers A and provider B
            DoSync(providerA, providerB, SyncDirectionOrder.DownloadAndUpload);

            //start clean
            //CleanUpProvider(providerA);
            //CleanUpProvider(providerB);
        }
Пример #9
0
        private KnowledgeSyncProvider GetLocalSyncProviderBySyncType(Outlook.OlItemType oItemType)
        {
            //return new KnowledgeSyncProvider[] { ClientOutlook.TestProvider.MyProviderFactory.CreateAProvider() };
            KnowledgeSyncProvider retVal = null;

            lock (_lockObject)
            {
                if (!_syncProviderCache.TryGetValue(oItemType, out retVal))
                {
                    retVal = AppointmentSyncProvider.CreateInstance(_settings.CurrentSyncAppointentSetting, _outlookApplication);
                    _syncProviderCache.Add(oItemType, retVal);
                }
            }
            //TODO: Add other types
            return(retVal);
        }
Пример #10
0
       public void Synchronize(KnowledgeSyncProvider destinationProvider, KnowledgeSyncProvider sourceProvider, ConflictResolutionPolicy destinationPol, ConflictResolutionPolicy sourcePol, SyncDirectionOrder SyncOrder, uint batchSize, string scopeName)
       {
           ((LocalStore)destinationProvider).RequestedBatchSize = batchSize;
           ((RemoteStore)sourceProvider).RequestedBatchSize = batchSize;

           destinationProvider.Configuration.ConflictResolutionPolicy = destinationPol;
           sourceProvider.Configuration.ConflictResolutionPolicy = sourcePol;

           SyncOrchestrator syncAgent = new SyncOrchestrator();

           syncAgent.LocalProvider = destinationProvider;
           syncAgent.RemoteProvider = sourceProvider;
           syncAgent.Direction = SyncOrder;

           syncAgent.Synchronize();
       }
Пример #11
0
        private void SubscribeEvents(KnowledgeSyncProvider syncProvider)
        {
            if (syncProvider != null)
            {
                syncProvider.DestinationCallbacks.FullEnumerationNeeded -= OnFullEnumerationNeeded;
                syncProvider.DestinationCallbacks.ItemChangeSkipped     -= OnItemChangeSkipped;
                syncProvider.DestinationCallbacks.ItemChanging          -= OnItemChanging;
                syncProvider.DestinationCallbacks.ItemConflicting       -= OnItemConflicting;
                syncProvider.DestinationCallbacks.ProgressChanged       -= OnProgressChanged;

                syncProvider.DestinationCallbacks.FullEnumerationNeeded += OnFullEnumerationNeeded;
                syncProvider.DestinationCallbacks.ItemChangeSkipped     += OnItemChangeSkipped;
                syncProvider.DestinationCallbacks.ItemChanging          += OnItemChanging;
                syncProvider.DestinationCallbacks.ItemConflicting       += OnItemConflicting;
                syncProvider.DestinationCallbacks.ProgressChanged       += OnProgressChanged;
            }
        }
Пример #12
0
        /// <summary>
        /// Utility function that will create a SyncOrchestrator and synchronize the two passed in providers
        /// </summary>
        /// <param name="localProvider">Local store provider</param>
        /// <param name="remoteProvider">Remote store provider</param>
        /// <returns></returns>
        public SyncOperationStatistics SynchronizeProviders(KnowledgeSyncProvider localProvider, KnowledgeSyncProvider remoteProvider)
        {
            SyncOrchestrator orchestrator = new SyncOrchestrator();

            orchestrator.LocalProvider  = localProvider;
            orchestrator.RemoteProvider = remoteProvider;
            orchestrator.Direction      = SyncDirectionOrder.UploadAndDownload;


            //Check to see if any provider is a SqlCe provider and if it needs schema
            CheckIfProviderNeedsSchema(localProvider as SqlSyncProvider);
            CheckIfProviderNeedsSchema(remoteProvider as SqlSyncProviderProxy);
            connString = ((SqlSyncProvider)localProvider).Connection.ConnectionString;
            SyncOperationStatistics stats = orchestrator.Synchronize();

            return(stats);
        }
Пример #13
0
        static KnowledgeSyncProvider GetProviderForSynchronization(Guid replicaId)
        {
            KnowledgeSyncProvider retVal = null;

            // Return the real provider for endpoint A.
            if (replicaId == providerNameA)
            {
                retVal = CalendarEventSyncProvider.CreateInstance(Mediachase.Ibn.Data.Services.Security.CurrentUserId);
            }
            else if (replicaId == providerNameB)
            {
                retVal = new AppointmentSyncProvider();
            }
            else
            {
                throw new ArgumentOutOfRangeException("name");
            }

            return(retVal);
        }
Пример #14
0
        /// <summary>
        /// Utility function that will create a SyncOrchestrator and synchronize the two passed in providers
        /// </summary>
        /// <param name="localProvider">Local store provider</param>
        /// <param name="remoteProvider">Remote store provider</param>
        /// <returns></returns>
        public SyncOperationStatistics SynchronizeProviders(KnowledgeSyncProvider localProvider, KnowledgeSyncProvider remoteProvider)
        {
            SyncOrchestrator orchestrator = new SyncOrchestrator();

            orchestrator.LocalProvider  = localProvider;
            orchestrator.RemoteProvider = remoteProvider;
            orchestrator.Direction      = SyncDirectionOrder.UploadAndDownload;

            progressForm = new ProgressForm();
            progressForm.Show();

            //Check to see if any provider is a Sql provider and if it needs schema
            CheckIfProviderNeedsSchema(localProvider as SqlSyncProvider);
            CheckIfProviderNeedsSchema(remoteProvider as SqlSyncProvider);

            SyncOperationStatistics stats = orchestrator.Synchronize();

            progressForm.ShowStatistics(stats);
            progressForm.EnableClose();
            return(stats);
        }
Пример #15
0
        static void DoBidirectionalSync(string nameA, string nameB)
        {
            SyncOperationStatistics stats;
            KnowledgeSyncProvider   providerNameA = GetProviderForSynchronization(nameA);
            KnowledgeSyncProvider   providerNameB = GetProviderForSynchronization(nameB);

            // Set the provider's conflict resolution policy since we are doing remote sync, we don't
            // want to see callbacks.
            providerNameA.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.DestinationWins;
            providerNameB.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.DestinationWins;

            //Sync providers
            Console.WriteLine("Sync {0} and {1}...", nameA, nameB);
            SyncOrchestrator agent = new SyncOrchestrator();

            agent.Direction      = SyncDirectionOrder.DownloadAndUpload;
            agent.LocalProvider  = providerNameA;
            agent.RemoteProvider = providerNameB;
            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
            MySyncProvider    mySyncproviderNameA = new MySyncProvider(folderPathForDataAndMetadata, nameA);
            MySyncProvider    mySyncproviderNameB = new MySyncProvider(folderPathForDataAndMetadata, nameB);
            MySimpleDataStore storeA = MySimpleDataStore.ReadStoreFromFile(folderPathForDataAndMetadata, nameA);
            MySimpleDataStore storeB = MySimpleDataStore.ReadStoreFromFile(folderPathForDataAndMetadata, nameB);

            Console.WriteLine(mySyncproviderNameA.ToString());
            Console.WriteLine(storeA.ToString());
            Console.WriteLine(mySyncproviderNameB.ToString());
            Console.WriteLine(storeB.ToString());
        }
        /// <summary>
        ///     Utility function that will create a SyncOrchestrator and
        ///     synchronize the two passed in providers
        /// </summary>
        /// <param name="localProvider">Local store provider</param>
        /// <param name="remoteProvider">Remote store provider</param>
        /// <param name="direction"></param>
        /// <returns></returns>
        private SyncOperationStatistics SynchronizeProviders(
            KnowledgeSyncProvider localProvider, KnowledgeSyncProvider remoteProvider,
            SyncDirectionOrder direction)
        {
            var orchestrator = new SyncOrchestrator();

            orchestrator.LocalProvider  = localProvider;
            orchestrator.RemoteProvider = remoteProvider;
            orchestrator.Direction      = direction;

            // subscribe for errors that occur when applying changes to the client
            ((SqlSyncProvider)orchestrator.LocalProvider).ChangesSelected   += Program_ChangesSelected;
            ((SqlSyncProvider)orchestrator.LocalProvider).SyncProgress      += Program_LocalProgress;
            ((SqlSyncProvider)orchestrator.LocalProvider).ApplyChangeFailed += Program_ApplyChangeFailed;
            ((SqlSyncProvider)orchestrator.LocalProvider).ApplyingChanges   += Program_ApplyingChanges;
            ((SqlSyncProvider)orchestrator.LocalProvider).ChangesApplied    += Program_ChangesApplied;


            // These are used for file sync...
            //((RelationalProviderTestProxy) orchestrator.RemoteProvider).DestinationCallbacks.ItemConflicting +=
            //    Program_RemoteItemConflicting;
            //((RelationalProviderTestProxy) orchestrator.RemoteProvider).DestinationCallbacks.ItemChanging +=
            //    Program_RemoteItemChanging;
            //((RelationalProviderTestProxy) orchestrator.RemoteProvider).DestinationCallbacks.ProgressChanged +=
            //    Program_ProgressChange;
            //((RelationalProviderTestProxy) orchestrator.RemoteProvider).DestinationCallbacks.ItemChangeSkipped +=
            //    Program_ItemChangeSkipped;
            ((SqlSyncProvider)orchestrator.LocalProvider).MemoryDataCacheSize = 100000;

            ((SqlSyncProvider)orchestrator.LocalProvider).ApplicationTransactionSize = 4096;


            //Check to see if any provider is a SqlCe provider and if it needs schema
            CheckIfProviderNeedsSchema(localProvider as SqlSyncProvider);
            var stats = orchestrator.Synchronize();

            return(stats);
        }
Пример #17
0
 public void EndSession()
 {
     try
     {
         KnowledgeSyncProvider provider = GetSessionProvider();
         provider.EndSession(null);
     }
     catch
     {
     }
     //catch(SyncException e)
     //{
     //    throw SoapErrorCreator.RaiseException(HttpContext.Current.Request.Url.ToString(),
     //                                      new SyncronizationServiceError(SyncronizationServiceError.eServiceErrorType.SyncFramework, e),
     //                                      true);
     //}
     //catch (Exception e)
     //{
     //    throw SoapErrorCreator.RaiseException(HttpContext.Current.Request.Url.ToString(),
     //                                      new SyncronizationServiceError(SyncronizationServiceError.eServiceErrorType.SyncProvider, e),
     //                                      true);
     //}
 }
Пример #18
0
        public byte[] GetIdFormats()
        {
            KnowledgeSyncProvider provider = GetSessionProvider();

            byte[] retVal = null;
            try
            {
                retVal = SerializerHelper.BinarySerialize(provider.IdFormats);
            }
            catch (SyncException e)
            {
                throw SoapErrorCreator.RaiseException(HttpContext.Current.Request.Url.ToString(),
                                                      new SyncronizationServiceError(SyncronizationServiceError.eServiceErrorType.SyncFramework, e),
                                                      true);
            }
            catch (Exception e)
            {
                throw SoapErrorCreator.RaiseException(HttpContext.Current.Request.Url.ToString(),
                                                      new SyncronizationServiceError(SyncronizationServiceError.eServiceErrorType.SyncProvider, e),
                                                      true);
            }

            return(retVal);
        }
Пример #19
0
 protected abstract void SynchronizeSyncScope(string syncScope, SyncDirectionOrder synDirection, KnowledgeSyncProvider localProvider, KnowledgeSyncProvider remoteProvider);
        /// <summary>
        /// Utility function that will create a SyncOrchestrator and synchronize the two passed in providers
        /// </summary>
        /// <param name="localProvider">Local store provider</param>
        /// <param name="remoteProvider">Remote store provider</param>
        /// <returns></returns>
        public SyncOperationStatistics SynchronizeProviders(string ScopeName, string clientConnectionString, string serverConnectionString, KnowledgeSyncProvider localProvider, KnowledgeSyncProvider remoteProvider)
        {
            SyncOrchestrator orchestrator = new SyncOrchestrator();

            orchestrator.LocalProvider  = localProvider;
            orchestrator.RemoteProvider = remoteProvider;


            orchestrator.Direction = SyncDirectionOrder.UploadAndDownload;
            SyncConflictResolver ConflictResolver = new SyncConflictResolver();

            ConflictResolver.ClientDeleteServerUpdateAction = ResolveAction.ServerWins;
            ConflictResolver.ClientUpdateServerDeleteAction = ResolveAction.ServerWins;
            ConflictResolver.ClientInsertServerInsertAction = ResolveAction.ServerWins;
            ConflictResolver.ClientUpdateServerUpdateAction = ResolveAction.ServerWins;

            //Check to see if any provider is a SqlCe provider and if it needs schema
            CheckIfProviderNeedsSchema(localProvider as SqlSyncProvider, serverConnectionString);
            CheckIfProviderNeedsSchema(ScopeName, clientConnectionString, serverConnectionString, remoteProvider as SqlSyncProviderProxy);

            SyncOperationStatistics stats = orchestrator.Synchronize();

            return(stats);
        }
Пример #21
0
 public void Synchronize(KnowledgeSyncProvider remoteProvider, uint batchSize)
 {
     Synchronize(SyncDirection, this, remoteProvider, batchSize);
 }
Пример #22
0
        /// <summary>
        /// Does the sync. Выполняется в другом потоке отличном от AddinModule
        /// </summary>
        /// <param name="oItemType">Type of the o item.</param>
        private void DoSync(Outlook.OlItemType oItemType)
        {
            //reset last error
            LastSyncErrorDescr = string.Empty;
            LastSyncErrorOccur = false;
            //reset skipped items
            _skippedItems.Clear();

            KnowledgeSyncProvider localProvider  = null;
            KnowledgeSyncProvider remoteProvider = null;

            CurrentProcessedSyncType = oItemType;
            try
            {
                remoteProvider = GetRemoteSyncProvidersBySyncType(oItemType);
                localProvider  = GetLocalSyncProviderBySyncType(oItemType);

                if (localProvider != null)
                {
                    //Create sync session
                    if (_syncAgent == null)
                    {
                        _syncAgent = new SyncOrchestrator();
                        //Subscribe sync framework events
                        SubscribeEvents(_syncAgent);
                    }

                    //ISyncProviderSetting providerSetting = localProvider.ProviderSetting;
                    ISyncProviderSetting providerSetting = localProvider as ISyncProviderSetting;
                    if (providerSetting != null)
                    {
                        SyncDirectionOrder       direction          = providerSetting.SyncDirectionOrderSetting;
                        ConflictResolutionPolicy conflictResolution = providerSetting.ConflictResolutionPolicySetting;

                        remoteProvider.Configuration.ConflictResolutionPolicy = conflictResolution;
                        localProvider.Configuration.ConflictResolutionPolicy  = conflictResolution;

                        _syncAgent.Direction      = direction;
                        _syncAgent.LocalProvider  = localProvider;
                        _syncAgent.RemoteProvider = remoteProvider;

                        //Subscribe to knowledege provider events
                        SubscribeEvents(localProvider);
                        SubscribeEvents(remoteProvider);
                        //raise sync process begin event
                        OnSyncProcessBegin(new SyncProcessEventArgs());

                        SyncOperationStatistics syncStats = _syncAgent.Synchronize();
                        CollectStatistics(syncStats);
                    }
                }
            }
            catch (UriFormatException e)
            {
                DebugAssistant.Log(DebugSeverity.Error, e.Message);
                LastSyncErrorOccur = true;
                LastSyncErrorDescr = OutlookAddin.Resources.ERR_SYNC_SERVICE_INVALID_URL;
                //DebugAssistant.Log(DebugSeverity.Error | DebugSeverity.MessageBox,
                //					OutlookAddin.Resources.ERR_SYNC_SERVICE_INVALID_URL);
            }
            catch (SoapException e)
            {
                LastSyncErrorOccur = true;
                SyncronizationServiceError syncError = SoapErrorHandler.HandleError(e);

                string msg = OutlookAddin.Resources.ERR_SYNC_SERVICE_UKNOW;
                if (syncError != null)
                {
                    DebugAssistant.Log(DebugSeverity.Error, syncError.errorType.ToString() + " "
                                       + syncError.message + " " + syncError.stackTrace);

                    switch (syncError.errorType)
                    {
                    case SyncronizationServiceError.eServiceErrorType.AuthFailed:
                        msg = Resources.ERR_SYNC_SERVICE_AUTH_FAILED;
                        break;

                    case SyncronizationServiceError.eServiceErrorType.NotAuthRequest:
                        msg = Resources.ERR_SYNC_SERVICE_NOT_AUTH;
                        break;

                    case SyncronizationServiceError.eServiceErrorType.ProviderNotSpecified:
                        msg = Resources.ERR_SYNC_SERVICE_INVALID_PROVIDER;
                        break;

                    case SyncronizationServiceError.eServiceErrorType.SyncFramework:
                        msg = Resources.ERR_SYNC_SERVICE_FRAMEWORK;
                        break;

                    case SyncronizationServiceError.eServiceErrorType.SyncProvider:
                        msg = Resources.ERR_SYNC_SERVICE_PROVIDER;
                        break;

                    case SyncronizationServiceError.eServiceErrorType.ServerError:
                        msg = Resources.ERR_SYNC_SERVICE_SERVER;
                        break;

                    case SyncronizationServiceError.eServiceErrorType.Undef:
                        msg = Resources.ERR_SYNC_SERVICE_UKNOW;
                        break;
                    }
                }

                LastSyncErrorDescr = msg;

                //DebugAssistant.Log(DebugSeverity.Error | DebugSeverity.MessageBox, msg);
            }
            catch (System.Net.WebException e)
            {
                LastSyncErrorOccur = true;
                LastSyncErrorDescr = Resources.ERR_SYNC_CONNECTION;
                DebugAssistant.Log(DebugSeverity.Error, e.Message);
            }
            catch (Exception e)
            {
                LastSyncErrorOccur = true;
                LastSyncErrorDescr = OutlookAddin.Resources.ERR_ADDIN_UNKNOW;
                DebugAssistant.Log(DebugSeverity.Error, e.Message);
                //DebugAssistant.Log(DebugSeverity.Error | DebugSeverity.MessageBox, OutlookAddin.Resources.ERR_ADDIN_UNKNOW);
            }
            finally
            {
                if (localProvider != null)
                {
                    localProvider.EndSession(null);
                }
                if (remoteProvider != null)
                {
                    remoteProvider.EndSession(null);
                }
                OnSyncProcessEnd(new SyncProcessEventArgs());
                CurrentProcessedSyncType = null;
            }
        }
Пример #23
0
 public void Synchronize(KnowledgeSyncProvider remoteProvider)
 {
     Synchronize(SyncDirection, Provider, remoteProvider);
 }
Пример #24
0
 public void Synchronize(KnowledgeSyncProvider remoteProvider)
 {
     _clientSync.Synchronize(remoteProvider);
 }
        /// <summary>
        /// Utility function that will create a SyncOrchestrator and synchronize the two passed in providers
        /// </summary>
        /// <param name="localProvider">Local store provider</param>
        /// <param name="remoteProvider">Remote store provider</param>
        /// <returns></returns>
        public SyncOperationStatistics SynchronizeProviders(string ScopeName, string clientConnectionString, string serverConnectionString, KnowledgeSyncProvider localProvider, KnowledgeSyncProvider remoteProvider)
        {
            SyncOrchestrator orchestrator = new SyncOrchestrator();

            orchestrator.LocalProvider = localProvider;
            orchestrator.RemoteProvider = remoteProvider;

            orchestrator.Direction = SyncDirectionOrder.UploadAndDownload;
            SyncConflictResolver ConflictResolver = new SyncConflictResolver();
            ConflictResolver.ClientDeleteServerUpdateAction = ResolveAction.ServerWins;
            ConflictResolver.ClientUpdateServerDeleteAction = ResolveAction.ServerWins;
            ConflictResolver.ClientInsertServerInsertAction = ResolveAction.ServerWins;
            ConflictResolver.ClientUpdateServerUpdateAction = ResolveAction.ServerWins;

            //Check to see if any provider is a SqlCe provider and if it needs schema
            CheckIfProviderNeedsSchema(localProvider as SqlSyncProvider, serverConnectionString);
            CheckIfProviderNeedsSchema(ScopeName, clientConnectionString, serverConnectionString, remoteProvider as SqlSyncProviderProxy);

            SyncOperationStatistics stats = orchestrator.Synchronize();
            return stats;
        }
Пример #26
0
 public void Synchronize(KnowledgeSyncProvider localProvider, KnowledgeSyncProvider remoteProvider)
 {
     SynchronizeSyncScope(SyncScopeName, SyncDirection, localProvider, remoteProvider);
 }
Пример #27
0
        static void CleanUpProvider(KnowledgeSyncProvider provider)
        {
            AppointmentSyncProvider outlookProvider = provider as AppointmentSyncProvider;
            CalendarEventSyncProvider ibnProvider = provider as CalendarEventSyncProvider;
            if (outlookProvider != null)
            {
                // Remove the data store file
                string metafile = outlookProvider.CurrentSetting.CurrentSyncAppSetting.metaDataFileName;
                if (System.IO.File.Exists(metafile))
                {
                    System.IO.File.Delete(metafile);
                }
            }
            else if (ibnProvider != null)
            {
                FilterElement filterEl = new FilterElement(SynchronizationMetadataRow.ColumnReplicaId, FilterElementType.Equal, ibnProvider.ReplicaId.GetGuidId());
                foreach (SynchronizationMetadataRow row in SynchronizationMetadataRow.List(filterEl))
                {
                    BusinessManager.Delete(new CalendarEventEntity((PrimaryKeyId)row.Uri));

                    row.Delete();
                }
                SynchronizationReplicaRow.Delete(ibnProvider.ReplicaId.GetGuidId());
            }
        }
Пример #28
0
        private void SubscribeEvents(KnowledgeSyncProvider syncProvider)
        {
            if (syncProvider != null)
            {
                syncProvider.DestinationCallbacks.FullEnumerationNeeded -= OnFullEnumerationNeeded;
                syncProvider.DestinationCallbacks.ItemChangeSkipped -= OnItemChangeSkipped;
                syncProvider.DestinationCallbacks.ItemChanging -= OnItemChanging;
                syncProvider.DestinationCallbacks.ItemConflicting -= OnItemConflicting;
                syncProvider.DestinationCallbacks.ProgressChanged -= OnProgressChanged;

                syncProvider.DestinationCallbacks.FullEnumerationNeeded += OnFullEnumerationNeeded;
                syncProvider.DestinationCallbacks.ItemChangeSkipped += OnItemChangeSkipped;
                syncProvider.DestinationCallbacks.ItemChanging += OnItemChanging;
                syncProvider.DestinationCallbacks.ItemConflicting += OnItemConflicting;
                syncProvider.DestinationCallbacks.ProgressChanged += OnProgressChanged;

            }
        }
Пример #29
0
        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);
        }
Пример #30
0
        static void DoSync(KnowledgeSyncProvider providerNameA, KnowledgeSyncProvider providerNameB, SyncDirectionOrder syncOrder)
        {
            SyncOperationStatistics stats;

            // Set the provider's conflict resolution policy since we are doing remote sync, we don't
            // want to see callbacks.
            providerNameA.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.DestinationWins;
            providerNameB.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.DestinationWins;

            //Sync providers
            Console.WriteLine("Sync A -{0} and B -{1}...", providerNameA.ToString(), providerNameB.ToString());
            SyncOrchestrator agent = new SyncOrchestrator();
            agent.Direction = syncOrder;
            agent.LocalProvider = providerNameA;
            agent.RemoteProvider = providerNameB;
            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
        }