public MsgStoresEnumeratorJob() { _msgStores = OutlookSession.GetMsgStores(); if (_msgStores == null) { return; } }
protected override void Execute() { Tracer._Trace("DoEnum()"); if (Settings.IdleModeManager.CheckIdleAndSyncComplete()) { Tracer._Trace("IsSyncComplete()"); return; } Settings.IdleModeManager.SetIdleFlag(); MailSync mailSync = new MailSync(_computeCount, _indexStartDate, _idle); mailSync.PrepareMailResources(); foreach (IEMsgStore msgStore in OutlookSession.GetMsgStores()) { if (msgStore == null) { continue; } if (OutlookProcessor.IsIgnoredInfoStore(msgStore)) { continue; } string storeID = msgStore.GetBinProp(MAPIConst.PR_STORE_ENTRYID); string name = msgStore.GetStringProp(MAPIConst.PR_DISPLAY_NAME); FolderDescriptorEnumerator.Do(msgStore, storeID, name, mailSync); if (Settings.IdleModeManager.Interrupted) { if (Settings.IdleIndexing) { Settings.IdleModeManager.DropInterrupted(); OutlookSession.OutlookProcessor.QueueIdleJob(this); } break; } } if (Settings.IdleModeManager.CompletedIdle) { OutlookSession.OutlookProcessor.SetSyncComplete(); mailSync.RemoveDeletedMailsFromIndex(); } else if (!Settings.IdleModeManager.Idle) { if (mailSync.IndexStartDate == DateTime.MinValue) { OutlookSession.OutlookProcessor.SetSyncComplete(); } mailSync.RemoveDeletedMailsFromIndex(); } return; }
private void SynchronizeMAPIInfoStoresImpl() { bool isInitialStart = IsInitialStart(); HashMap infoStores = new HashMap(); foreach (IResource infoStore in Core.ResourceStore.GetAllResources(STR.MAPIInfoStore).ValidResources) { string storeId = infoStore.GetStringProp(PROP.EntryID); if (storeId != null) { if (!OutlookSession.WereProblemWithOpeningStorage(storeId)) { infoStores.Add(storeId, infoStore); } } else { new ResourceProxy(infoStore).DeleteAsync(); } } foreach (IEMsgStore msgStore in OutlookSession.GetMsgStores()) { if (msgStore == null) { continue; } string storeID = msgStore.GetBinProp(MAPIConst.PR_ENTRYID); infoStores.Remove(storeID); MAPIInfoStoreDescriptor infoStoreJob = new MAPIInfoStoreDescriptor(msgStore); if (isInitialStart) { Core.ResourceAP.RunJob(infoStoreJob); } else { Core.ResourceAP.QueueJob(JobPriority.Immediate, infoStoreJob); } } foreach (HashMap.Entry entry in infoStores) { IResource infoStore = (IResource)entry.Value; new ResourceProxy(infoStore).Delete(); } }
protected override void Execute() { if (OutlookSession.OutlookProcessor.ShuttingDown) { return; } IStatusWriter statusWriter = Core.UIManager.GetStatusWriter(this, StatusPane.Network); statusWriter.ShowStatus("Performing background mail synchronization..."); Tracer._Trace("MailSyncBackground is executed"); foreach (IEMsgStore msgStore in OutlookSession.GetMsgStores()) { if (OutlookSession.OutlookProcessor.ShuttingDown) { break; } OutlookSession.ProcessJobs(); if (msgStore == null) { continue; } if (OutlookProcessor.IsIgnoredInfoStore(msgStore)) { continue; } string storeID = msgStore.GetBinProp(MAPIConst.PR_STORE_ENTRYID); string name = msgStore.GetStringProp(MAPIConst.PR_DISPLAY_NAME); FolderDescriptorEnumerator.Do(msgStore, storeID, name, this); } statusWriter.ClearStatus(); ProcessedFolders.DecRef(); }
private void SynchronizeFolderStructureImpl() { _tracer.Trace("Start SynchronizeFolderStructureImpl"); IResourceList folders = Core.ResourceStore.GetAllResources(STR.MAPIFolder); foreach (IResource folder in folders.ValidResources) { string entryID = folder.GetStringProp(PROP.EntryID); if (entryID != null) { _folders.Add(entryID); } else { new ResourceProxy(folder).DeleteAsync(); } } _tracer.Trace("Start enumeration for info stores"); foreach (IEMsgStore msgStore in OutlookSession.GetMsgStores()) { if (msgStore == null) { continue; } _tracer.Trace("GetRootFolder"); IEFolder rootFolder = msgStore.GetRootFolder(); string storeID = msgStore.GetBinProp(MAPIConst.PR_STORE_ENTRYID); if (IsIgnoredInfoStore(msgStore)) { _tracer.Trace("MsgStore is ignored"); if (rootFolder == null) { continue; } using ( rootFolder ) { string entryID = OutlookSession.GetFolderID(rootFolder); IResource rootMAPIFolder = Folder.Find(entryID); if (rootMAPIFolder != null) { _tracer.Trace("Delete folder recursive for " + rootMAPIFolder.DisplayName); Core.ResourceAP.QueueJob("Delete folder recursive", new ResourceDelegate(Folder.DeleteFolderRecursive), rootMAPIFolder); } } } else { string name = msgStore.GetStringProp(MAPIConst.PR_DISPLAY_NAME); _tracer.Trace("MsgStore name = " + name); SynchronizeFolderRecursive(rootFolder, name, storeID, null); } } _tracer.Trace("Delete folders recursively if necessary"); foreach (HashSet.Entry entry in _folders) { IResource folderToDelete = Core.ResourceStore.FindUniqueResource(STR.MAPIFolder, PROP.EntryID, (string)entry.Key); if (folderToDelete != null) { PairIDs folderIDs = PairIDs.Get(folderToDelete); if (folderIDs != null) { if (OutlookSession.WereProblemWithOpeningStorage(folderIDs.StoreId)) { continue; } if (OutlookSession.WereProblemWithOpeningFolder(folderIDs.EntryId)) { continue; } } Core.ResourceAP.QueueJob(new ResourceDelegate(Folder.DeleteFolderRecursive), folderToDelete); } } _folders.Clear(); _tracer.Trace("Finish SynchronizeFolderStructureImpl"); }