protected override void MapSourceToTargetMessage(MessageRec sourceMR, EntryIdMap <MessageRec> targetBySourceEntryId, EntryIdMap <MessageRec> targetBySecondaryKey, HashSet <byte[]> duplicateTargetSecondaryKeys, HashSet <byte[]> duplicateSourceSecondaryKeys, out MessageRec targetMR) { targetMR = null; byte[] array = ImapFolderContentsMapper.GetImapSyncPropertiesHash(sourceMR, this.sourceHierarchy); if (array != null) { targetBySecondaryKey.TryGetValue(array, out targetMR); } if (targetMR == null) { array = ImapFolderContentsMapper.GetSyncMessageIdHash(sourceMR, MessageRecType.Source, this.sourceHierarchy); targetBySecondaryKey.TryGetValue(array, out targetMR); } }
protected override MailboxChangesManifest EnumerateSourceHierarchyChanges(MailboxCopierBase mbxCtx, bool catchup, SyncContext syncContext) { if (catchup) { if (!mbxCtx.IsRoot) { return(null); } return(base.EnumerateSourceHierarchyChanges(mbxCtx, catchup, syncContext)); } else { if (mbxCtx.IsRoot) { return(base.EnumerateSourceHierarchyChanges(mbxCtx, catchup, syncContext)); } FolderMap destinationFolderMap = base.GetRootMailboxContext().GetDestinationFolderMap(GetFolderMapFlags.None); EntryIdMap <FolderRecWrapper> primaryMailboxFolderRecWrappers = new EntryIdMap <FolderRecWrapper>(); destinationFolderMap.EnumerateFolderHierarchy(EnumHierarchyFlags.NormalFolders | EnumHierarchyFlags.RootFolder, delegate(FolderRecWrapper primaryFolderRecWrapper, FolderMap.EnumFolderContext enumFolderContext) { if (mbxCtx.IsContentAvailableInTargetMailbox(primaryFolderRecWrapper)) { byte[] key = (byte[])primaryFolderRecWrapper.FolderRec[PropTag.LTID]; primaryMailboxFolderRecWrappers[key] = primaryFolderRecWrapper; } }); EntryIdMap <FolderRecWrapper> secondaryMailboxFolderRecWrappers = new EntryIdMap <FolderRecWrapper>(); syncContext.TargetFolderMap.EnumerateFolderHierarchy(EnumHierarchyFlags.NormalFolders | EnumHierarchyFlags.RootFolder, delegate(FolderRecWrapper secondaryFolderRecWrapper, FolderMap.EnumFolderContext enumFolderContext) { if (mbxCtx.IsContentAvailableInTargetMailbox(secondaryFolderRecWrapper)) { byte[] key = (byte[])secondaryFolderRecWrapper.FolderRec[PropTag.LTID]; secondaryMailboxFolderRecWrappers[key] = secondaryFolderRecWrapper; } }); MailboxChangesManifest mailboxChangesManifest = new MailboxChangesManifest(); mailboxChangesManifest.ChangedFolders = new List <byte[]>(); mailboxChangesManifest.DeletedFolders = new List <byte[]>(); foreach (KeyValuePair <byte[], FolderRecWrapper> keyValuePair in primaryMailboxFolderRecWrappers) { FolderRecWrapper folderRecWrapper; if (!secondaryMailboxFolderRecWrappers.TryGetValue(keyValuePair.Key, out folderRecWrapper) || folderRecWrapper.FolderRec.LastModifyTimestamp != keyValuePair.Value.FolderRec.LastModifyTimestamp) { mailboxChangesManifest.ChangedFolders.Add(mbxCtx.SourceMailbox.GetSessionSpecificEntryId(keyValuePair.Key)); } } foreach (KeyValuePair <byte[], FolderRecWrapper> keyValuePair2 in secondaryMailboxFolderRecWrappers) { FolderRecWrapper folderRecWrapper2; if (!primaryMailboxFolderRecWrappers.TryGetValue(keyValuePair2.Key, out folderRecWrapper2)) { mailboxChangesManifest.DeletedFolders.Add(mbxCtx.SourceMailbox.GetSessionSpecificEntryId(keyValuePair2.Key)); } } return(mailboxChangesManifest); } }
private void MapSourceToTargetMessageBySourceEntryId(MessageRec sourceMR, EntryIdMap <MessageRec> targetBySourceEntryId, out MessageRec targetMR) { targetMR = null; byte[] keyPlusLMTHash = this.GetKeyPlusLMTHash(sourceMR, PropTag.EntryId, PropTag.LastModificationTime); if (keyPlusLMTHash != null) { targetBySourceEntryId.TryGetValue(keyPlusLMTHash, out targetMR); } }
protected virtual void MapSourceToTargetMessage(MessageRec sourceMR, EntryIdMap <MessageRec> targetBySourceEntryId, EntryIdMap <MessageRec> targetBySecondaryKey, HashSet <byte[]> duplicateTargetSecondaryKeys, HashSet <byte[]> duplicateSourceSecondaryKeys, out MessageRec targetMR) { targetMR = null; this.MapSourceToTargetMessageBySourceEntryId(sourceMR, targetBySourceEntryId, out targetMR); if (targetMR == null) { byte[] keyPlusLMTHash = this.GetKeyPlusLMTHash(sourceMR, PropTag.SearchKey, PropTag.LastModificationTime); if (keyPlusLMTHash != null && !duplicateSourceSecondaryKeys.Contains(keyPlusLMTHash)) { targetBySecondaryKey.TryGetValue(keyPlusLMTHash, out targetMR); } } }
protected override MailboxChangesManifest RunManualHierarchySync(bool catchup, SyncHierarchyManifestState hierState) { MrsTracer.Provider.Function("EasSourceMailbox.RunManualHierarchySync", new object[0]); base.VerifyMailboxConnection(VerifyMailboxConnectionFlags.None); EasHierarchySyncState easHierarchySyncState = EasHierarchySyncState.Deserialize(hierState.ProviderSyncState); hierState.ProviderSyncState = null; EasHierarchySyncState easHierarchySyncState2 = base.RefreshFolderCache(); EntryIdMap <EasHierarchySyncState.EasFolderData> entryIdMap = new EntryIdMap <EasHierarchySyncState.EasFolderData>(); foreach (EasHierarchySyncState.EasFolderData easFolderData in easHierarchySyncState.FolderData) { entryIdMap[EasMailbox.GetEntryId(easFolderData.ServerId)] = easFolderData; } EntryIdMap <EasHierarchySyncState.EasFolderData> entryIdMap2 = new EntryIdMap <EasHierarchySyncState.EasFolderData>(); foreach (EasHierarchySyncState.EasFolderData easFolderData2 in easHierarchySyncState2.FolderData) { entryIdMap2[EasMailbox.GetEntryId(easFolderData2.ServerId)] = easFolderData2; } MailboxChangesManifest mailboxChangesManifest = new MailboxChangesManifest(); mailboxChangesManifest.DeletedFolders = new List <byte[]>(); foreach (byte[] array in entryIdMap.Keys) { if (!entryIdMap2.ContainsKey(array)) { mailboxChangesManifest.DeletedFolders.Add(array); } } mailboxChangesManifest.ChangedFolders = new List <byte[]>(); foreach (KeyValuePair <byte[], EasHierarchySyncState.EasFolderData> keyValuePair in entryIdMap2) { byte[] key = keyValuePair.Key; EasHierarchySyncState.EasFolderData value = keyValuePair.Value; EasHierarchySyncState.EasFolderData easFolderData3; if (entryIdMap.TryGetValue(key, out easFolderData3)) { if (easFolderData3.ParentId != value.ParentId || easFolderData3.DisplayName != value.DisplayName) { mailboxChangesManifest.ChangedFolders.Add(key); } } else { mailboxChangesManifest.ChangedFolders.Add(key); } } return(mailboxChangesManifest); }
public ReplayActionsQueue GetAndTranslateActions(string replaySyncState, int maxNumberOfActions, MergeSyncContext syncContext, out string retrieveSyncState, out bool moreActions) { MrsTracer.Service.Function("MailboxMerger.GetAndTranslateActions", new object[0]); List <ReplayAction> actions = base.DestMailbox.GetActions(replaySyncState, maxNumberOfActions); moreActions = (actions.Count == maxNumberOfActions); retrieveSyncState = ((actions.Count == 0) ? replaySyncState : actions[actions.Count - 1].Watermark); ReplayActionsQueue replayActionsQueue = new ReplayActionsQueue(actions.Count); foreach (ReplayAction action in actions) { replayActionsQueue.Enqueue(action); } EntryIdMap <List <byte[]> > entryIdMap = new EntryIdMap <List <byte[]> >(); foreach (ReplayAction replayAction in actions) { if (!replayAction.Ignored) { foreach (KeyValuePair <byte[], byte[]> keyValuePair in replayAction.GetMessageEntryIdsToTranslate()) { byte[] key = keyValuePair.Key; byte[] value = keyValuePair.Value; List <byte[]> list; if (!entryIdMap.TryGetValue(key, out list)) { list = new List <byte[]>(); entryIdMap.Add(key, list); } list.Add(value); } } } syncContext.PrefetchSourceMessageIdsFromTargetMessageIds(entryIdMap); foreach (ReplayAction replayAction2 in actions) { if (!replayAction2.Ignored) { replayAction2.TranslateEntryIds(syncContext); } } return(replayActionsQueue); }
public void ComputeFolderMapping(FolderHierarchy targetHierarchy, bool createMissingFolderRecs) { if (!this.folderFilterApplied) { this.SetFolderFilter(null, false, null, string.Empty, false, Guid.Empty); } EntryIdMap <FolderMapping> targetBySourceEntryID = new EntryIdMap <FolderMapping>(); targetHierarchy.EnumerateSubtree(EnumHierarchyFlags.AllFolders, targetHierarchy.RootFolder, delegate(FolderRecWrapper fRec, FolderMap.EnumFolderContext ctx) { FolderMapping folderMapping = (FolderMapping)fRec; byte[] array = folderMapping.FolderRec[targetHierarchy.SourceEntryIDPtag] as byte[]; if (array != null && !targetBySourceEntryID.ContainsKey(array)) { targetBySourceEntryID.Add(array, folderMapping); } }); base.EnumerateFolderHierarchy(EnumHierarchyFlags.AllFolders, delegate(FolderRecWrapper fRec, FolderMap.EnumFolderContext ctx) { FolderMapping folderMapping = (FolderMapping)fRec; FolderMapping wellKnownFolder; if (folderMapping.WKFType != WellKnownFolderType.None) { wellKnownFolder = targetHierarchy.GetWellKnownFolder(folderMapping.WKFType); if (wellKnownFolder != null) { folderMapping.TargetFolder = wellKnownFolder; wellKnownFolder.SourceFolder = folderMapping; this.MapPublicFolderDumpster(folderMapping, wellKnownFolder); return; } } if (targetBySourceEntryID.TryGetValue(folderMapping.EntryId, out wellKnownFolder)) { folderMapping.TargetFolder = wellKnownFolder; wellKnownFolder.SourceFolder = folderMapping; this.MapPublicFolderDumpster(folderMapping, wellKnownFolder); } }); base.EnumerateFolderHierarchy(EnumHierarchyFlags.AllFolders, delegate(FolderRecWrapper fRec, FolderMap.EnumFolderContext ctx) { FolderMapping folderMapping = (FolderMapping)fRec; if (folderMapping.TargetFolder != null) { this.MapSubtreeByName(folderMapping, createMissingFolderRecs); ctx.Result = EnumHierarchyResult.SkipSubtree; } }); FolderMapping ipmSubtree = this.GetWellKnownFolder(WellKnownFolderType.IpmSubtree); if (ipmSubtree != null) { base.EnumerateFolderHierarchy(EnumHierarchyFlags.AllFolders, delegate(FolderRecWrapper fRec, FolderMap.EnumFolderContext ctx) { FolderMapping folderMapping = (FolderMapping)fRec; if (folderMapping.IsIncluded && folderMapping.TargetFolder == null) { this.MapFolderByName(folderMapping, ipmSubtree.TargetFolder, createMissingFolderRecs); if (folderMapping.TargetFolder != null) { this.MapSubtreeByName(folderMapping, createMissingFolderRecs); } ctx.Result = EnumHierarchyResult.SkipSubtree; } }); } }
public static void LookupBadMessagesInMailbox(ISourceMailbox mailbox, List <MessageRec> messages, out EntryIdMap <MessageRec> lookedUpMsgs, out EntryIdMap <FolderRec> folderRecs) { EntryIdMap <EntryIdMap <MessageRec> > entryIdMap = new EntryIdMap <EntryIdMap <MessageRec> >(); folderRecs = new EntryIdMap <FolderRec>(); lookedUpMsgs = new EntryIdMap <MessageRec>(); foreach (MessageRec messageRec in messages) { EntryIdMap <MessageRec> entryIdMap2; if (!entryIdMap.TryGetValue(messageRec.FolderId, out entryIdMap2)) { entryIdMap2 = new EntryIdMap <MessageRec>(); entryIdMap.Add(messageRec.FolderId, entryIdMap2); } entryIdMap2[messageRec.EntryId] = null; } MrsTracer.Common.Debug("Looking up {0} messages in {1} folders.", new object[] { messages.Count, entryIdMap.Count }); foreach (KeyValuePair <byte[], EntryIdMap <MessageRec> > keyValuePair in entryIdMap) { using (ISourceFolder folder = mailbox.GetFolder(keyValuePair.Key)) { if (folder == null) { MrsTracer.Common.Warning("Folder {0} disappeared.", new object[] { TraceUtils.DumpEntryId(keyValuePair.Key) }); } else { FolderRec folderRec = folder.GetFolderRec(null, GetFolderRecFlags.None); folderRecs[folderRec.EntryId] = folderRec; EntryIdMap <MessageRec> value = keyValuePair.Value; MrsTracer.Common.Debug("Looking up {0} messages in folder '{1}'.", new object[] { value.Count, folderRec.FolderName }); int num = 0; if (mailbox.IsCapabilitySupported(MRSProxyCapabilities.SimpleExport)) { List <byte[]> keysToLookup = new List <byte[]>(value.Keys); List <MessageRec> list = folder.LookupMessages(PropTag.EntryId, keysToLookup, BadMessageRec.BadItemPtags); if (list == null) { goto IL_230; } using (List <MessageRec> .Enumerator enumerator3 = list.GetEnumerator()) { while (enumerator3.MoveNext()) { MessageRec messageRec2 = enumerator3.Current; lookedUpMsgs[messageRec2.EntryId] = messageRec2; num++; } goto IL_230; } } List <MessageRec> list2 = folder.EnumerateMessages(EnumerateMessagesFlags.RegularMessages, BadMessageRec.BadItemPtags); foreach (MessageRec messageRec3 in list2) { if (value.ContainsKey(messageRec3.EntryId)) { lookedUpMsgs[messageRec3.EntryId] = messageRec3; num++; } } IL_230: MrsTracer.Common.Debug("Found {0} messages.", new object[] { num }); } } } MrsTracer.Common.Debug("Looked up {0} messages.", new object[] { lookedUpMsgs.Count }); }