CmisSync.Lib.Producer.ContentChange.ContentChanges.Handle C# (CSharp) Method

Handle() public method

Handle the specified e.
public Handle ( ISyncEvent e ) : bool
e ISyncEvent The event to handle.
return bool
        public override bool Handle(ISyncEvent e) {
            StartNextSyncEvent syncEvent = e as StartNextSyncEvent;
            if (syncEvent != null) {
                if (syncEvent.FullSyncRequested) {
                    // Get last change log token on server side.
                    string lastRemoteChangeLogTokenBeforeFullCrawlSync = this.session.Binding.GetRepositoryService().GetRepositoryInfo(this.session.RepositoryInfo.Id, null).LatestChangeLogToken;
                    if (this.storage.ChangeLogToken == null) {
                        syncEvent.LastTokenOnServer = lastRemoteChangeLogTokenBeforeFullCrawlSync;
                    }

                    // Use fallback sync algorithm
                    return false;
                } else {
                    Logger.Debug("Starting ContentChange Sync");
                    bool result = this.StartSync();
                    return result;
                }
            }

            // The above started full sync is finished.
            FullSyncCompletedEvent syncCompleted = e as FullSyncCompletedEvent;
            if (syncCompleted != null) {
                string lastTokenOnServer = syncCompleted.StartEvent.LastTokenOnServer;
                if (!string.IsNullOrEmpty(lastTokenOnServer)) {
                    this.storage.ChangeLogToken = lastTokenOnServer;
                }
            }

            return false;
        }

Usage Example

Ejemplo n.º 1
0
 public void IgnoresWrongEvent() {
     var storage = new Mock<IMetaDataStorage>();
     var queue = new Mock<ISyncEventQueue>();
     var session = new Mock<ISession>();
     var changes = new ContentChanges(session.Object, storage.Object, queue.Object);
     var startSyncEvent = new Mock<ISyncEvent>().Object;
     Assert.IsFalse(changes.Handle(startSyncEvent));
 }
All Usage Examples Of CmisSync.Lib.Producer.ContentChange.ContentChanges::Handle