Ejemplo n.º 1
0
 public FolderHierarchyChangeDetector.SyncHierarchyManifestState Clone()
 {
     FolderHierarchyChangeDetector.SyncHierarchyManifestState result;
     lock (this.instanceLock)
     {
         result = new FolderHierarchyChangeDetector.SyncHierarchyManifestState
         {
             IdsetGiven = (byte[])this.IdsetGiven.Clone(),
             CnsetSeen  = (byte[])this.CnsetSeen.Clone()
         };
     }
     return(result);
 }
Ejemplo n.º 2
0
        public void RecordLatestFolderHierarchySnapshot(MailboxSession mailboxSession, ISyncLogger syncLogger = null)
        {
            if (syncLogger == null)
            {
                syncLogger = TracingLogger.Singleton;
            }
            FolderHierarchyChangeDetector.SyncHierarchyManifestState syncHierarchyManifestState = this.SyncHierarchyManifestState;
            bool catchup = false;

            if (syncHierarchyManifestState == null)
            {
                syncLogger.TraceDebug(ExTraceGlobals.SyncProcessTracer, (long)this.GetHashCode(), "[DeviceSyncStateMetadata.RecordLatestFolderHierarchySnapshot] Last ICS snapshot was null.  Doing a catchup sync.");
                syncHierarchyManifestState      = new FolderHierarchyChangeDetector.SyncHierarchyManifestState();
                this.SyncHierarchyManifestState = syncHierarchyManifestState;
                catchup = true;
            }
            FolderHierarchyChangeDetector.RunICSManifestSync(catchup, syncHierarchyManifestState, mailboxSession, syncLogger);
        }
Ejemplo n.º 3
0
        public static FolderHierarchyChangeDetector.MailboxChangesManifest RunICSManifestSync(bool catchup, FolderHierarchyChangeDetector.SyncHierarchyManifestState hierState, MailboxSession mailboxSession, ISyncLogger syncLogger = null)
        {
            if (syncLogger == null)
            {
                syncLogger = TracingLogger.Singleton;
            }
            syncLogger.TraceDebug <SmtpAddress, bool>(ExTraceGlobals.SyncProcessTracer, 0L, "[FolderHierarchyChangeDetector.RunICSManifestSync] Checking for folder hierarhcy changes for Mailbox: {0}.  Catchup? {1}", mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress, catchup);
            MapiStore _ContainedMapiStore = mailboxSession.__ContainedMapiStore;

            FolderHierarchyChangeDetector.MailboxChangesManifest    mailboxChangesManifest = new FolderHierarchyChangeDetector.MailboxChangesManifest();
            FolderHierarchyChangeDetector.ManifestHierarchyCallback iMapiManifestCallback  = new FolderHierarchyChangeDetector.ManifestHierarchyCallback(catchup, mailboxChangesManifest);
            try
            {
                using (MapiFolder ipmSubtreeFolder = _ContainedMapiStore.GetIpmSubtreeFolder())
                {
                    SyncConfigFlags syncConfigFlags = SyncConfigFlags.ManifestHierReturnDeletedEntryIds;
                    int             serverVersion   = mailboxSession.MailboxOwner.MailboxInfo.Location.ServerVersion;
                    if ((serverVersion >= Server.E14MinVersion && serverVersion < Server.E15MinVersion) || (long)serverVersion >= FolderHierarchyChangeDetector.E15MinVersionSupportsOnlySpecifiedPropsForHierarchy)
                    {
                        syncConfigFlags |= SyncConfigFlags.OnlySpecifiedProps;
                    }
                    using (MapiHierarchyManifestEx mapiHierarchyManifestEx = ipmSubtreeFolder.CreateExportHierarchyManifestEx(syncConfigFlags, hierState.IdsetGiven, hierState.CnsetSeen, iMapiManifestCallback, FolderHierarchyChangeDetector.PropsToFetch, null))
                    {
                        while (mapiHierarchyManifestEx.Synchronize() != ManifestStatus.Done)
                        {
                        }
                        byte[] idSetGiven;
                        byte[] cnetSeen;
                        mapiHierarchyManifestEx.GetState(out idSetGiven, out cnetSeen);
                        syncLogger.TraceDebug <SmtpAddress, int, int>(ExTraceGlobals.SyncProcessTracer, 0L, "[FolderHierarchyChangeDetector.RunICSManifestSync] Updating ICS state for mailbox: '{0}'.  Change Count: {1}, Delete Count: {2}", mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress, mailboxChangesManifest.ChangedFolders.Count, mailboxChangesManifest.DeletedFolders.Count);
                        hierState.Update(idSetGiven, cnetSeen);
                    }
                }
            }
            catch (MapiPermanentException arg)
            {
                syncLogger.TraceDebug <SmtpAddress, MapiPermanentException>(ExTraceGlobals.SyncProcessTracer, 0L, "[FolderHierarchyChangeDetector.RunICSManifestSync] Caught MapiPermanentException when determining folder ICS changes for mailbox: {0}.  Exception: {1}", mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress, arg);
                return(null);
            }
            catch (MapiRetryableException arg2)
            {
                syncLogger.TraceDebug <SmtpAddress, MapiRetryableException>(ExTraceGlobals.SyncProcessTracer, 0L, "[FolderHierarchyChangeDetector.RunICSManifestSync] Caught MapiRetryableException when determining folder ICS changes for mailbox: {0}.  Exception: {1}", mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress, arg2);
                return(null);
            }
            return(mailboxChangesManifest);
        }
Ejemplo n.º 4
0
 public FolderHierarchyChangeDetector.MailboxChangesManifest GetFolderHierarchyICSChanges(MailboxSession mailboxSession, out FolderHierarchyChangeDetector.SyncHierarchyManifestState latestState, ISyncLogger syncLogger = null)
 {
     if (syncLogger == null)
     {
         syncLogger = TracingLogger.Singleton;
     }
     latestState = this.SyncHierarchyManifestState;
     if (latestState == null)
     {
         syncLogger.TraceDebug(ExTraceGlobals.SyncProcessTracer, (long)this.GetHashCode(), "[DeviceSyncStateMetadata.GetFolderHierarchyICSChanges] Old ICS state was missing from cache.  Must do expensive check instead.");
         return(null);
     }
     latestState = latestState.Clone();
     FolderHierarchyChangeDetector.MailboxChangesManifest mailboxChangesManifest = FolderHierarchyChangeDetector.RunICSManifestSync(false, latestState, mailboxSession, syncLogger);
     syncLogger.TraceDebug <string, string>(ExTraceGlobals.SyncProcessTracer, (long)this.GetHashCode(), "[DeviceSyncStateMetadata.GetFolderHierarchyICSChanges] Changes: {0}, Deletes: {1}", (mailboxChangesManifest == null || mailboxChangesManifest.ChangedFolders == null) ? "<NULL>" : mailboxChangesManifest.ChangedFolders.Count.ToString(), (mailboxChangesManifest == null || mailboxChangesManifest.DeletedFolders == null) ? "<NULL>" : mailboxChangesManifest.DeletedFolders.Count.ToString());
     return(mailboxChangesManifest);
 }
Ejemplo n.º 5
0
 public void RecordLatestFolderHierarchySnapshot(FolderHierarchyChangeDetector.SyncHierarchyManifestState lastState)
 {
     this.SyncHierarchyManifestState = lastState;
 }