Beispiel #1
0
 public ManifestHierarchyCallback(bool catchup, FolderHierarchyChangeDetector.MailboxChangesManifest changes)
 {
     this.catchup = catchup;
     this.changes = changes;
     this.changes.ChangedFolders = new Dictionary <StoreObjectId, string>();
     this.changes.DeletedFolders = new List <StoreObjectId>();
 }
Beispiel #2
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);
        }
Beispiel #3
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);
 }