public void ParseRequest(XmlNode node) { foreach (object obj in node.ChildNodes) { XmlNode xmlNode = (XmlNode)obj; string name; if ((name = xmlNode.Name) != null) { if (name == "ConversationId") { this.conversationIdNode = xmlNode; AirSyncByteArrayProperty airSyncByteArrayProperty = new AirSyncByteArrayProperty("ItemOperations:", "ConversationId", false); airSyncByteArrayProperty.Bind(xmlNode); if (airSyncByteArrayProperty.ByteArrayData != null) { try { this.conversationId = ConversationId.Create(airSyncByteArrayProperty.ByteArrayData); continue; } catch (CorruptDataException innerException) { throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, innerException, false) { ErrorStringForProtocolLogger = "BadConversationIdOnMove" }; } } throw new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, false) { ErrorStringForProtocolLogger = "InvalidConversationId(" + xmlNode.Name + ")OnMove" }; } if (name == "DstFldId") { this.dstSyncFolderId = xmlNode.InnerText; continue; } if (name == "Options") { this.ParseOptions(xmlNode); continue; } } throw new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, false) { ErrorStringForProtocolLogger = "InvalidNode(" + xmlNode.Name + ")OnConversationMove" }; } if (string.IsNullOrEmpty(this.dstSyncFolderId) || this.conversationId == null) { throw new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, false) { ErrorStringForProtocolLogger = "NoDstFldOrIdOnConversationMove" }; } }
protected virtual ConversationAggregationResult ConstructResult(ConversationIndex.FixupStage bySubjectResultingStage, ConversationIndex bySubjectResultingIndex, IStorePropertyBag parentItem) { return(new ConversationAggregationResult { Stage = bySubjectResultingStage, ConversationIndex = bySubjectResultingIndex, SupportsSideConversation = false, ConversationFamilyId = ConversationId.Create(bySubjectResultingIndex) }); }
protected override ConversationAggregationResult ConstructResult(ConversationIndex.FixupStage bySubjectResultingStage, ConversationIndex bySubjectResultingIndex, IStorePropertyBag parentItem, bool participantRemoved) { ConversationAggregationResult conversationAggregationResult = this.ConstructResult(bySubjectResultingStage, bySubjectResultingIndex, parentItem); if (participantRemoved) { conversationAggregationResult.Stage |= ConversationIndex.FixupStage.TC; conversationAggregationResult.ConversationFamilyId = ConversationId.Create(Guid.NewGuid()); } return(conversationAggregationResult); }
/// <summary> /// /// </summary> /// <param name="creatureId"></param> /// <param name="sequenceId"></param> /// <param name="startIndex"></param> /// <param name="endIndex"></param> public void ShowTalk(int sequenceId, int startIndex, int endIndex) { for (int i = startIndex; i <= endIndex; i++) { ConversationId conversationId = ConversationId.Create(this.ChapterId(), sequenceId, i); string key = conversationId.GetKeyForId(); if (chapterDefinition.ConversationIds.ContainsKey(key)) { int creatureId = chapterDefinition.ConversationIds[key]; FDCreature creature = this.GetCreature(creatureId); TalkPack pack = new TalkPack(creature.Clone(), conversationId); gameCallback.OnHandlePack(pack); } } }
protected override ConversationAggregationResult ConstructResult(ConversationIndex.FixupStage bySubjectResultingStage, ConversationIndex bySubjectResultingIndex, IStorePropertyBag parentItem) { ConversationAggregationResult conversationAggregationResult = base.ConstructResult(bySubjectResultingStage, bySubjectResultingIndex, parentItem); if (AudienceBasedConversationAggregator.IsMessageCreatingNewConversation(parentItem, bySubjectResultingStage)) { conversationAggregationResult.SupportsSideConversation = true; conversationAggregationResult.ConversationFamilyId = ConversationId.Create(bySubjectResultingIndex); } else { conversationAggregationResult.SupportsSideConversation = AudienceBasedConversationAggregator.SupportsSideConversation(parentItem); conversationAggregationResult.ConversationFamilyId = parentItem.GetValueOrDefault <ConversationId>(ItemSchema.ConversationFamilyId, null); } return(conversationAggregationResult); }
private QueryFilter ParseConversationId(XmlNode node) { if (this.Conversation != null) { throw new SearchFilterTooComplexException { ErrorStringForProtocolLogger = "SearchTooComplexError4" }; } AirSyncByteArrayProperty airSyncByteArrayProperty = new AirSyncByteArrayProperty("Search:", "ConversationId", false); airSyncByteArrayProperty.Bind(node); byte[] byteArrayData = airSyncByteArrayProperty.ByteArrayData; if (byteArrayData == null) { throw new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, false) { ErrorStringForProtocolLogger = "BadConversationIdInSearch" }; } ConversationId conversationId; try { conversationId = ConversationId.Create(byteArrayData); } catch (CorruptDataException innerException) { throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, innerException, false) { ErrorStringForProtocolLogger = "BadConversationIdInSearch2" }; } Conversation conversation; Command.CurrentCommand.GetOrCreateConversation(conversationId, false, out conversation); this.Conversation = conversation; return(new ComparisonFilter(ComparisonOperator.Equal, ItemSchema.ConversationTopic, this.Conversation.Topic)); }
public static OwaStoreObjectId CreateFromString(string owaStoreObjectIdString) { OwaStoreObjectIdType owaStoreObjectIdType = OwaStoreObjectIdType.MailBoxObject; if (owaStoreObjectIdString.StartsWith("PSF.", StringComparison.Ordinal)) { owaStoreObjectIdType = OwaStoreObjectIdType.PublicStoreFolder; } else if (owaStoreObjectIdString.StartsWith("PSI.", StringComparison.Ordinal)) { owaStoreObjectIdType = OwaStoreObjectIdType.PublicStoreItem; } else if (owaStoreObjectIdString.StartsWith("OUM.", StringComparison.Ordinal)) { owaStoreObjectIdType = OwaStoreObjectIdType.OtherUserMailboxObject; } else if (owaStoreObjectIdString.StartsWith("CID.", StringComparison.Ordinal)) { owaStoreObjectIdType = OwaStoreObjectIdType.Conversation; } else if (owaStoreObjectIdString.StartsWith("AMB.", StringComparison.Ordinal)) { owaStoreObjectIdType = OwaStoreObjectIdType.ArchiveMailboxObject; } else if (owaStoreObjectIdString.StartsWith("ACI.", StringComparison.Ordinal)) { owaStoreObjectIdType = OwaStoreObjectIdType.ArchiveConversation; } else if (owaStoreObjectIdString.StartsWith("GS.", StringComparison.Ordinal)) { owaStoreObjectIdType = OwaStoreObjectIdType.GSCalendar; } StoreObjectId folderStoreObjectId = null; StoreObjectId folderStoreObjectId2 = null; string text = null; switch (owaStoreObjectIdType) { case OwaStoreObjectIdType.PublicStoreFolder: folderStoreObjectId = Utilities.CreateStoreObjectId(owaStoreObjectIdString.Substring("PSF".Length + 1)); OwaStoreObjectId.ValidateFolderId(folderStoreObjectId); break; case OwaStoreObjectIdType.PublicStoreItem: { int num = owaStoreObjectIdString.LastIndexOf(".", StringComparison.Ordinal); if (num == "PSI".Length) { throw new OwaInvalidIdFormatException(string.Format("There should be two separator \"{0}\" in the id of the public item. Invalid Id string: {1}", ".", owaStoreObjectIdString)); } folderStoreObjectId2 = Utilities.CreateStoreObjectId(owaStoreObjectIdString.Substring("PSI".Length + 1, num - "PSI".Length - 1)); folderStoreObjectId = Utilities.CreateStoreObjectId(owaStoreObjectIdString.Substring(num + 1)); OwaStoreObjectId.ValidateFolderId(folderStoreObjectId2); break; } case OwaStoreObjectIdType.Conversation: { string[] array = owaStoreObjectIdString.Split(new char[] { "."[0] }); OwaStoreObjectId owaStoreObjectId; if (array.Length == 4) { owaStoreObjectId = new OwaStoreObjectId(ConversationId.Create(array[1]), string.IsNullOrEmpty(array[2]) ? null : Utilities.CreateStoreObjectId(array[2]), string.IsNullOrEmpty(array[3]) ? null : Utilities.CreateInstanceKey(array[3])); } else if (array.Length == 3) { owaStoreObjectId = new OwaStoreObjectId(ConversationId.Create(array[1]), Utilities.CreateStoreObjectId(array[2]), null); } else { if (array.Length != 2) { throw new OwaInvalidRequestException(string.Format("There should be one or two separator \"{0}\" in the id of the conversation item", ".")); } owaStoreObjectId = new OwaStoreObjectId(ConversationId.Create(array[1]), null, null); } owaStoreObjectId.bufferedIdString = owaStoreObjectIdString; return(owaStoreObjectId); } case OwaStoreObjectIdType.OtherUserMailboxObject: { int num = owaStoreObjectIdString.LastIndexOf(".", StringComparison.Ordinal); folderStoreObjectId = OwaStoreObjectId.CreateStoreObjectIdFromString(owaStoreObjectIdString, "OUM", num); text = OwaStoreObjectId.ParseLegacyDnBase64String(owaStoreObjectIdString.Substring(num + 1)); break; } case OwaStoreObjectIdType.ArchiveMailboxObject: { int num = owaStoreObjectIdString.LastIndexOf(".", StringComparison.Ordinal); folderStoreObjectId = OwaStoreObjectId.CreateStoreObjectIdFromString(owaStoreObjectIdString, "AMB", num); text = OwaStoreObjectId.ParseLegacyDnBase64String(owaStoreObjectIdString.Substring(num + 1)); break; } case OwaStoreObjectIdType.ArchiveConversation: { string[] array = owaStoreObjectIdString.Split(new char[] { "."[0] }); OwaStoreObjectId owaStoreObjectId; if (array.Length == 5) { text = OwaStoreObjectId.ParseLegacyDnBase64String(array[3]); owaStoreObjectId = new OwaStoreObjectId(ConversationId.Create(array[1]), string.IsNullOrEmpty(array[2]) ? null : Utilities.CreateStoreObjectId(array[2]), text, string.IsNullOrEmpty(array[4]) ? null : Utilities.CreateInstanceKey(array[4])); } else if (array.Length == 4) { text = OwaStoreObjectId.ParseLegacyDnBase64String(array[3]); owaStoreObjectId = new OwaStoreObjectId(ConversationId.Create(array[1]), Utilities.CreateStoreObjectId(array[2]), text, null); } else { if (array.Length != 3) { throw new OwaInvalidRequestException(string.Format("There should be two or three separator \"{0}\" in the id of the archive conversation item", ".")); } text = OwaStoreObjectId.ParseLegacyDnBase64String(array[2]); owaStoreObjectId = new OwaStoreObjectId(ConversationId.Create(array[1]), null, text, null); } owaStoreObjectId.bufferedIdString = owaStoreObjectIdString; return(owaStoreObjectId); } case OwaStoreObjectIdType.GSCalendar: { string[] array = owaStoreObjectIdString.Split(new char[] { "."[0] }); if (array.Length != 2) { throw new OwaInvalidRequestException(string.Format("There should be two separator \"{0}\" in the id of the GS calendar item", ".")); } text = OwaStoreObjectId.ParseLegacyDnBase64String(array[1]); break; } default: return(OwaStoreObjectId.CreateFromStoreObjectId(Utilities.CreateStoreObjectId(owaStoreObjectIdString), null)); } return(new OwaStoreObjectId(owaStoreObjectIdType, folderStoreObjectId, folderStoreObjectId2, text) { bufferedIdString = owaStoreObjectIdString }); }
internal static IDictionary <string, string> ExtractDeliveryDetails(StoreSession session, Item item) { IDictionary <string, string> customProperties = null; ActivityLogHelper.CatchNonFatalExceptions(delegate { MessageItem messageItem = item as MessageItem; if (messageItem == null) { return; } bool flag = false; bool flag2 = false; string value = null; ConversationId conversationId = null; string value2 = null; bool?flag3 = null; if (((IDirectPropertyBag)messageItem.PropertyBag).IsLoaded(InternalSchema.InferenceClassificationResult)) { InferenceClassificationResult?valueAsNullable = messageItem.GetValueAsNullable <InferenceClassificationResult>(InternalSchema.InferenceClassificationResult); flag3 = new bool?(valueAsNullable != null && valueAsNullable.Value.HasFlag(InferenceClassificationResult.IsClutterFinal)); } string value3 = string.Empty; if (flag3 != null) { value3 = (flag3.Value ? bool.TrueString : bool.FalseString); } bool?flag4 = new bool?(messageItem.IsGroupEscalationMessage); string value4 = string.Empty; if (flag4 != null) { value4 = (flag4.Value ? bool.TrueString : bool.FalseString); } StoreObjectId parentId = messageItem.ParentId; DefaultFolderType defaultFolderType = DefaultFolderType.None; bool flag5 = false; if (parentId != null) { StoreObjectId defaultFolderId = session.GetDefaultFolderId(DefaultFolderType.Inbox); flag = parentId.Equals(defaultFolderId); StoreObjectId defaultFolderId2 = session.GetDefaultFolderId(DefaultFolderType.Clutter); flag2 = (defaultFolderId2 != null && parentId.Equals(defaultFolderId2)); MailboxSession mailboxSession = session as MailboxSession; if (mailboxSession != null) { defaultFolderType = mailboxSession.IsDefaultFolderType(parentId); flag5 = true; } } value = messageItem.InternetMessageId; ConversationIndex index; if (ConversationIndex.TryCreate(messageItem.ConversationIndex, out index)) { conversationId = ConversationId.Create(index); } string value5 = string.Empty; if (((IDirectPropertyBag)messageItem.PropertyBag).IsLoaded(InternalSchema.InferenceMessageIdentifier)) { value5 = messageItem.GetValueAsNullable <Guid>(InternalSchema.InferenceMessageIdentifier).ToString(); } if (messageItem.Sender != null) { value2 = messageItem.Sender.SmtpEmailAddress; } List <string> list = null; List <string> list2 = null; foreach (Recipient recipient in messageItem.Recipients) { if (recipient.Participant != null) { if (recipient.IsDistributionList() == true) { if (list == null) { list = new List <string>(2); } list.Add(recipient.SmtpAddress()); } else if (recipient.IsGroupMailbox() == true) { if (list2 == null) { list2 = new List <string>(2); } list2.Add(recipient.SmtpAddress()); } } } Dictionary <string, string> dictionary = new Dictionary <string, string> { { "IsClutter", value3 }, { "DeliveredToInbox", flag ? bool.TrueString : bool.FalseString }, { "DeliveredToClutter", flag2 ? bool.TrueString : bool.FalseString }, { "IsGroupEscalationMessage", value4 }, { "InternetMessageId", value }, { "ConversationId", (conversationId == null) ? string.Empty : conversationId.ToString() }, { "MessageGuid", value5 }, { "SenderSmtpAddress", value2 } }; if (list != null && list.Count > 0) { dictionary.Add("DLRecipients", string.Join(";", list)); } if (list2 != null) { dictionary.Add("GMRecipients", string.Join(";", list2)); } if (flag5) { Dictionary <string, string> dictionary2 = dictionary; string key = "DeliveredFolderType"; int num = (int)defaultFolderType; dictionary2.Add(key, num.ToString()); if (defaultFolderType == DefaultFolderType.None && parentId != null) { dictionary.Add("DeliveredFolderId", parentId.ToString()); } } customProperties = dictionary; }, null); return(customProperties); }
public void OnPromotedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { ConversationsProcessingAgent.tracer.TraceDebug(0L, "Called ConversationsProcessingAgent.OnPromotedMessageHandler"); if (args == null) { return; } StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; if (ConversationsProcessingAgent.ShouldSkipMessageProcessing(storeDriverDeliveryEventArgsImpl)) { return; } if (storeDriverDeliveryEventArgsImpl.MailboxOwner == null) { return; } MailboxSession mailboxSession = storeDriverDeliveryEventArgsImpl.MailboxSession; if (mailboxSession.MailboxOwner.MailboxInfo.Location.ServerVersion <= 1937801369) { if (ConversationsProcessingAgent.tracer.IsTraceEnabled(TraceType.DebugTrace)) { ConversationsProcessingAgent.tracer.TraceDebug <string, string>((long)this.GetHashCode(), "Backend server version (0x{0}) is less than minimum required (0x{1})", mailboxSession.MailboxOwner.MailboxInfo.Location.ServerVersion.ToString("X"), 1937801369.ToString("X")); } return; } ConversationsProcessingAgent.tracer.TraceDebug((long)this.GetHashCode(), "Processing incoming message"); Stopwatch stopwatch = Stopwatch.StartNew(); try { if (storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies == null) { storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies = new Dictionary <PropertyDefinition, object>(); } ConversationIndexTrackingEx conversationIndexTrackingEx = ConversationIndexTrackingEx.Create(); this.performanceContext = ConversationsProcessingAgent.conversationLatencyDetectionContextFactory.CreateContext("15.00.1497.012", "FIXUP", new IPerformanceDataProvider[0]); if (!this.isBodyTagCalculated) { ConversationsProcessingAgent.tracer.TraceDebug((long)this.GetHashCode(), "Calculating body tag"); Stopwatch stopwatch2 = Stopwatch.StartNew(); if (storeDriverDeliveryEventArgsImpl.ReplayItem.IsRestricted) { if (!this.TryCalculateIrmBodyTag(storeDriverDeliveryEventArgsImpl)) { this.bodyTag = null; } } else if (PropertyError.IsPropertyNotFound(storeDriverDeliveryEventArgsImpl.ReplayItem.TryGetProperty(ItemSchema.BodyTag))) { this.bodyTag = storeDriverDeliveryEventArgsImpl.ReplayItem.Body.CalculateBodyTag(out this.latestMessageWordCount); } else { this.bodyTag = storeDriverDeliveryEventArgsImpl.ReplayItem.GetValueOrDefault <byte[]>(ItemSchema.BodyTag); this.latestMessageWordCount = storeDriverDeliveryEventArgsImpl.ReplayItem.GetValueOrDefault <int>(MessageItemSchema.LatestMessageWordCount, int.MinValue); } stopwatch2.Stop(); conversationIndexTrackingEx.Trace("BT", stopwatch2.ElapsedMilliseconds.ToString()); this.isBodyTagCalculated = true; } if (this.bodyTag != null) { storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.BodyTag] = this.bodyTag; if (this.latestMessageWordCount >= 0) { storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[MessageItemSchema.LatestMessageWordCount] = this.latestMessageWordCount; storeDriverDeliveryEventArgsImpl.ReplayItem.SafeSetProperty(MessageItemSchema.LatestMessageWordCount, this.latestMessageWordCount); } } if (this.forceAllAttachmentsHidden) { storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[MessageItemSchema.AllAttachmentsHidden] = true; } if (!ConversationIndex.CompareTopics(storeDriverDeliveryEventArgsImpl.ReplayItem.TryGetProperty(ItemSchema.ConversationTopic) as string, storeDriverDeliveryEventArgsImpl.ReplayItem.TryGetProperty(ItemSchema.NormalizedSubject) as string)) { storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationTopic] = ((storeDriverDeliveryEventArgsImpl.ReplayItem.TryGetProperty(ItemSchema.NormalizedSubject) as string) ?? string.Empty); } if (!storeDriverDeliveryEventArgsImpl.MessageClass.Equals("IPM.WorkingSet.Signal", StringComparison.InvariantCulture)) { ConversationAggregationResult conversationAggregationResult = new ConversationAggregationResult(); ConversationsProcessingAgent.tracer.TraceDebug((long)this.GetHashCode(), "Fixing up the conversation id"); try { IConversationAggregator conversationAggregator; if (ConversationAggregatorFactory.TryInstantiateAggregatorForDelivery(mailboxSession, storeDriverDeliveryEventArgsImpl.MailboxOwner, conversationIndexTrackingEx, out conversationAggregator)) { conversationAggregationResult = conversationAggregator.Aggregate(storeDriverDeliveryEventArgsImpl.ReplayItem.CoreItem); } else { ConversationsProcessingAgent.tracer.TraceError((long)this.GetHashCode(), "Not able to identify a valid conversationAggregator"); conversationAggregationResult.ConversationIndex = ConversationIndex.CreateNew(); conversationAggregationResult.Stage = ConversationIndex.FixupStage.Error; } } catch (ObjectNotFoundException arg) { ConversationsProcessingAgent.tracer.TraceError <ObjectNotFoundException>((long)this.GetHashCode(), "Exception - {0}", arg); conversationAggregationResult.ConversationIndex = ConversationIndex.CreateNew(); conversationAggregationResult.Stage = ConversationIndex.FixupStage.Error; } this.performanceContext.StopAndFinalizeCollection(); conversationIndexTrackingEx.Trace("FIXUP", this.performanceContext.Elapsed.TotalMilliseconds.ToString()); ConversationsProcessingAgent.tracer.TraceDebug <int>((long)this.GetHashCode(), "FixupStage = {0}", (int)conversationAggregationResult.Stage); ConversationId conversationId = ConversationId.Create(conversationAggregationResult.ConversationIndex); ConversationsProcessingAgent.tracer.TraceDebug <ConversationId>((long)this.GetHashCode(), "ConversationId (CID) for item: {0}", conversationId); storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationIndex] = conversationAggregationResult.ConversationIndex.ToByteArray(); storeDriverDeliveryEventArgsImpl.ReplayItem.SafeSetProperty(ItemSchema.ConversationIndex, storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationIndex]); storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationFamilyId] = conversationAggregationResult.ConversationFamilyId; storeDriverDeliveryEventArgsImpl.ReplayItem.SafeSetProperty(ItemSchema.ConversationFamilyId, storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationFamilyId]); storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.SupportsSideConversation] = conversationAggregationResult.SupportsSideConversation; storeDriverDeliveryEventArgsImpl.ReplayItem.SafeSetProperty(ItemSchema.SupportsSideConversation, storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.SupportsSideConversation]); byte[] value; if (this.TryCalculateConversationCreatorSid(mailboxSession, storeDriverDeliveryEventArgsImpl.MailboxOwner, conversationAggregationResult, storeDriverDeliveryEventArgsImpl.ReplayItem.PropertyBag, out value)) { storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationCreatorSID] = value; storeDriverDeliveryEventArgsImpl.ReplayItem.SafeSetProperty(ItemSchema.ConversationCreatorSID, storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationCreatorSID]); } conversationIndexTrackingEx.TraceVersionAndHeuristics(conversationAggregationResult.Stage.ToString()); storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationIndexTrackingEx] = conversationIndexTrackingEx.ToString(); if (conversationAggregationResult.Stage != ConversationIndex.FixupStage.L1) { storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationIndexTracking] = true; storeDriverDeliveryEventArgsImpl.ReplayItem.SafeSetProperty(ItemSchema.ConversationIndexTracking, storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.ConversationIndexTracking]); } ConversationsProcessingAgent.tracer.TraceDebug <ConversationIndexTrackingEx>((long)this.GetHashCode(), "Time Spent in different stages - {0}", conversationIndexTrackingEx); ConversationsProcessingAgent.tracer.TraceDebug((long)this.GetHashCode(), "Processing conversation actions"); if (!ConversationIndex.IsFixUpCreatingNewConversation(conversationAggregationResult.Stage)) { this.ProcessConversationActions(conversationId, storeDriverDeliveryEventArgsImpl); } if (ConversationIndex.IsFixupAddingOutOfOrderMessageToConversation(conversationAggregationResult.Stage)) { if (storeDriverDeliveryEventArgsImpl.SharedPropertiesBetweenAgents == null) { storeDriverDeliveryEventArgsImpl.SharedPropertiesBetweenAgents = new Dictionary <PropertyDefinition, object>(); } storeDriverDeliveryEventArgsImpl.SharedPropertiesBetweenAgents[ItemSchema.ConversationLoadRequiredByInference] = true; } } } finally { stopwatch.Stop(); MSExchangeConversationsProcessing.LastMessageProcessingTime.RawValue = stopwatch.ElapsedMilliseconds; ConversationsProcessingAgent.averageMessageProcessingTime.Update(stopwatch.ElapsedMilliseconds); ConversationsProcessingAgent.tracer.TraceDebug <long>((long)this.GetHashCode(), "Exiting ConversationsProcessing.ProcessMessage. Total execution time = {0} ms.", stopwatch.ElapsedMilliseconds); } }
private static bool SearchByTopic(IXSOFactory xsoFactory, IMailboxSession session, ICorePropertyBag persistPropertyBag, ConversationIndexTrackingEx indexTrackingEx, out IStorePropertyBag foundPropertyBag, out bool didConversationIdMatch, out bool didReferencesMatch, params PropertyDefinition[] propsToReturn) { foundPropertyBag = null; didConversationIdMatch = false; didReferencesMatch = false; Util.ThrowOnNullArgument(session, "session"); Util.ThrowOnNullArgument(persistPropertyBag, "persistPropertyBag"); Util.ThrowOnNullArgument(propsToReturn, "propsToReturn"); ICollection <PropertyDefinition> properties = InternalSchema.Combine <PropertyDefinition>(propsToReturn, new PropertyDefinition[] { ItemSchema.ConversationTopicHash }); string incomingConversationTopic = persistPropertyBag.GetValueOrDefault <string>(ItemSchema.ConversationTopic); ConversationIndex conversationIndex; bool isValidIncomingIndex = ConversationIndex.TryCreate(persistPropertyBag.TryGetProperty(ItemSchema.ConversationIndex) as byte[], out conversationIndex); ConversationId incomingConversationId = isValidIncomingIndex ? ConversationId.Create(conversationIndex.Guid) : null; if (incomingConversationTopic == null) { return(false); } bool didConversationIdMatchLocal = false; bool didReferencesMatchLocal = false; int incomingConversationTopicHash = (int)AllItemsFolderHelper.GetHashValue(incomingConversationTopic); Stopwatch stopwatch = Stopwatch.StartNew(); IStorePropertyBag storePropertyBag = xsoFactory.RunQueryOnAllItemsFolder <IStorePropertyBag>(session, AllItemsFolderHelper.SupportedSortBy.ConversationTopicHash, incomingConversationTopicHash, null, delegate(QueryResult queryResult) { bool flag = queryResult.SeekToCondition(SeekReference.OriginBeginning, new ComparisonFilter(ComparisonOperator.Equal, ItemSchema.ConversationTopicHash, incomingConversationTopicHash)); if (flag) { IStorePropertyBag storePropertyBag2 = null; for (int i = 0; i < 5; i++) { IStorePropertyBag[] propertyBags = queryResult.GetPropertyBags(1); if (propertyBags.Length != 1) { break; } int?num = propertyBags[0].TryGetProperty(ItemSchema.ConversationTopicHash) as int?; if (num == null || num.Value != incomingConversationTopicHash) { break; } string foundTopic = propertyBags[0].TryGetProperty(ItemSchema.ConversationTopic) as string; if (ConversationIndex.CompareTopics(incomingConversationTopic, foundTopic)) { if (storePropertyBag2 == null) { storePropertyBag2 = propertyBags[0]; } ConversationIndex conversationIndex2; bool flag2 = ConversationIndex.TryCreate(propertyBags[0].TryGetProperty(ItemSchema.ConversationIndex) as byte[], out conversationIndex2); if (flag2) { if (isValidIncomingIndex) { ConversationId conversationId = ConversationId.Create(conversationIndex2.Guid); if (conversationId.Equals(incomingConversationId)) { didConversationIdMatchLocal = true; return(propertyBags[0]); } } else if (AggregationByItemClassReferencesSubjectProcessor.MatchMessageIdWithReferences(persistPropertyBag, propertyBags[0])) { didReferencesMatchLocal = true; return(propertyBags[0]); } } } if (!queryResult.SeekToCondition(SeekReference.OriginCurrent, new ComparisonFilter(ComparisonOperator.Equal, ItemSchema.ConversationTopicHash, incomingConversationTopicHash))) { break; } } if (storePropertyBag2 != null) { return(storePropertyBag2); } } return(null); }, properties); stopwatch.Stop(); if (indexTrackingEx != null) { indexTrackingEx.Trace("SBT", stopwatch.ElapsedMilliseconds.ToString()); } if (storePropertyBag != null) { foundPropertyBag = storePropertyBag; didConversationIdMatch = didConversationIdMatchLocal; didReferencesMatch = didReferencesMatchLocal; return(true); } return(false); }
public void Aggregate(ICorePropertyBag item, bool shouldSearchForDuplicatedMessage, out IStorePropertyBag parentItem, out ConversationIndex newIndex, out ConversationIndex.FixupStage stage) { newIndex = ConversationIndex.Empty; stage = ConversationIndex.FixupStage.Unknown; string valueOrDefault = item.GetValueOrDefault <string>(InternalSchema.ItemClass, string.Empty); parentItem = null; if (!string.IsNullOrEmpty(valueOrDefault)) { if (ObjectClass.IsMeetingMessage(valueOrDefault)) { if (AggregationByItemClassReferencesSubjectProcessor.FixupMeetingMessage(this.xsoFactory, this.session, new AggregationByItemClassReferencesSubjectProcessor.PropertyDefinitionListConstructorDelegate(this.GetSearchPropertyDefinitions), item, ref newIndex, ref stage, out parentItem)) { return; } } else if (ObjectClass.IsSmsMessage(valueOrDefault)) { AggregationBySmsItemClassProcessor aggregationBySmsItemClassProcessor = new AggregationBySmsItemClassProcessor(this.xsoFactory, this.session, this.indexTrackingEx); aggregationBySmsItemClassProcessor.Aggregate(item, out newIndex, out stage); return; } } ConversationIndex conversationIndex; bool flag = ConversationIndex.TryCreate(item.TryGetProperty(ItemSchema.ConversationIndex) as byte[], out conversationIndex); if (this.indexTrackingEx != null) { if (flag) { this.indexTrackingEx.Trace(conversationIndex); } else { this.indexTrackingEx.Trace("II", "<invalid>"); } } if (AggregationByItemClassReferencesSubjectProcessor.SearchByReferences(this.xsoFactory, this.session, item, this.indexTrackingEx, shouldSearchForDuplicatedMessage, out parentItem, this.GetSearchPropertyDefinitions(null))) { bool flag2 = false; if (shouldSearchForDuplicatedMessage) { string a = item.TryGetProperty(ItemSchema.InternetMessageId) as string; string text = parentItem.TryGetProperty(ItemSchema.InternetMessageId) as string; flag2 = (!string.IsNullOrEmpty(text) && string.Equals(a, text, StringComparison.OrdinalIgnoreCase)); } if (flag2) { this.CalculateBasedOnMessageWithSameInternetMessageId(item, parentItem, out stage, out newIndex); } else { this.CalculateBasedOnReferenceMessage(item, parentItem, out stage, out newIndex); } } string text2 = item.TryGetProperty(ItemSchema.NormalizedSubject) as string; if (stage == ConversationIndex.FixupStage.Unknown) { if (string.IsNullOrEmpty(item.GetValueOrDefault <string>(ItemSchema.SubjectPrefix)) && flag) { if (conversationIndex.Components.Count > 1) { byte[] incomingConversationIdBytes = ConversationId.Create(conversationIndex.Guid).GetBytes(); int conversationIdHash = (int)AllItemsFolderHelper.GetHashValue(incomingConversationIdBytes); Stopwatch stopwatch = Stopwatch.StartNew(); parentItem = this.xsoFactory.RunQueryOnAllItemsFolder <IStorePropertyBag>(this.session, AllItemsFolderHelper.SupportedSortBy.ConversationIdHash, conversationIdHash, null, delegate(QueryResult queryResult) { IStorePropertyBag[] propertyBags; byte[] array; do { propertyBags = queryResult.GetPropertyBags(1); if (propertyBags == null || propertyBags.Length != 1) { goto IL_69; } int?num = propertyBags[0].TryGetProperty(ItemSchema.ConversationIdHash) as int?; if (num == null || num.Value != conversationIdHash) { goto IL_69; } array = (propertyBags[0].TryGetProperty(InternalSchema.MapiConversationId) as byte[]); }while (array == null || !Util.CompareByteArray(incomingConversationIdBytes, array)); return(propertyBags[0]); IL_69: return(null); }, this.GetSearchPropertyDefinitions(new StorePropertyDefinition[] { InternalSchema.MapiConversationId, ItemSchema.ConversationIdHash })); stopwatch.Stop(); if (this.indexTrackingEx != null) { this.indexTrackingEx.Trace("SBCID", stopwatch.ElapsedMilliseconds.ToString()); } if (parentItem != null && !ConversationIndex.CompareTopics(parentItem.TryGetProperty(ItemSchema.ConversationTopic) as string, text2)) { newIndex = ConversationIndex.CreateNew(); stage = ConversationIndex.FixupStage.H11; if (this.indexTrackingEx != null) { string text3 = parentItem.TryGetProperty(ItemSchema.InternetMessageId) as string; if (text3 != null) { this.indexTrackingEx.Trace("S3", text3); } } } } if (stage == ConversationIndex.FixupStage.Unknown) { newIndex = conversationIndex; bool flag3 = parentItem != null; if (flag3) { bool?flag4 = parentItem.TryGetProperty(ItemSchema.ConversationIndexTracking) as bool?; stage = ((flag4 == null || !flag4.Value) ? ConversationIndex.FixupStage.L1 : ConversationIndex.FixupStage.H14); } else { stage = ConversationIndex.FixupStage.H4; } } } else { if (string.IsNullOrEmpty(item.GetValueOrDefault <string>(ItemSchema.InReplyTo, string.Empty)) && string.IsNullOrEmpty(item.GetValueOrDefault <string>(ItemSchema.InternetReferences, string.Empty)) && string.IsNullOrEmpty(item.GetValueOrDefault <string>(ItemSchema.SubjectPrefix)) && !flag) { TopicHashCache topicHashCache = TopicHashCache.Load(this.xsoFactory, this.session, 50); if (string.IsNullOrEmpty(text2) || !topicHashCache.Contains(AllItemsFolderHelper.GetHashValue(text2))) { newIndex = ConversationIndex.CreateNew(); stage = ConversationIndex.FixupStage.H12; } } bool flag5; bool flag6; if (stage == ConversationIndex.FixupStage.Unknown && AggregationByItemClassReferencesSubjectProcessor.SearchByTopic(this.xsoFactory, this.session, item, this.indexTrackingEx, out parentItem, out flag5, out flag6, this.GetSearchPropertyDefinitions(new StorePropertyDefinition[] { ItemSchema.ReceivedTime, ItemSchema.InReplyTo, ItemSchema.InternetReferences }))) { if (this.indexTrackingEx != null) { string text4 = parentItem.TryGetProperty(ItemSchema.InternetMessageId) as string; if (text4 != null) { this.indexTrackingEx.Trace("S2", text4); } } bool?flag7 = parentItem.TryGetProperty(ItemSchema.ConversationIndexTracking) as bool?; bool flag8 = flag7 == null || !flag7.Value; if (flag5) { newIndex = conversationIndex; stage = (flag8 ? ConversationIndex.FixupStage.L1 : ConversationIndex.FixupStage.H5); } else { ConversationIndex conversationIndex2; bool flag9 = ConversationIndex.TryCreate(parentItem.TryGetProperty(ItemSchema.ConversationIndex) as byte[], out conversationIndex2); if (flag6) { ExDateTime?valueAsNullable = item.GetValueAsNullable <ExDateTime>(ItemSchema.SentTime); newIndex = ((valueAsNullable != null) ? ConversationIndex.Create(conversationIndex2.Guid, valueAsNullable.Value) : ConversationIndex.Create(conversationIndex2.Guid)); stage = (flag8 ? ConversationIndex.FixupStage.L1 : ConversationIndex.FixupStage.H6); } else { object obj = parentItem.TryGetProperty(ItemSchema.ReceivedTime); string valueOrDefault2 = item.GetValueOrDefault <string>(ItemSchema.SubjectPrefix); if (obj != null && obj is ExDateTime) { ExDateTime dt = (ExDateTime)obj; TimeSpan timeSpan = ExDateTime.Now - dt; if (timeSpan.TotalHours >= -72.0 && timeSpan.TotalHours <= 72.0 && flag9) { if (flag) { newIndex = conversationIndex.UpdateGuid(conversationIndex2.Guid); stage = (flag8 ? ConversationIndex.FixupStage.L1 : ConversationIndex.FixupStage.H9); } else if (!string.IsNullOrEmpty(valueOrDefault2)) { ExDateTime?valueAsNullable2 = item.GetValueAsNullable <ExDateTime>(ItemSchema.SentTime); if (valueAsNullable2 != null) { newIndex = ConversationIndex.Create(conversationIndex2.Guid, valueAsNullable2.Value); } else { newIndex = ConversationIndex.Create(conversationIndex2.Guid); } stage = (flag8 ? ConversationIndex.FixupStage.L1 : ConversationIndex.FixupStage.H6); } } } } } } } } if (stage == ConversationIndex.FixupStage.Unknown) { if (!string.IsNullOrEmpty(item.GetValueOrDefault <string>(ItemSchema.SubjectPrefix))) { TopicHashCache topicHashCache2 = TopicHashCache.Load(this.xsoFactory, this.session, 50); uint hashValue = AllItemsFolderHelper.GetHashValue(text2); topicHashCache2.Add(hashValue); TopicHashCache.Save(topicHashCache2, this.xsoFactory, this.session); if (this.indexTrackingEx != null) { this.indexTrackingEx.Trace("THA", hashValue.ToString()); } } if (flag) { newIndex = conversationIndex; stage = ConversationIndex.FixupStage.H7; return; } newIndex = ConversationIndex.CreateNew(); stage = ConversationIndex.FixupStage.H8; } }
private Conversation LoadConversationForConversationCreatorSidDefinition() { ConversationId conversationId = ConversationId.Create(this.conversationIndex.Guid); return(Conversation.Load(this.mailboxSession, conversationId, ConversationCreatorHelper.ConversationCreatorDefinitionData.ConversationCreatorRelevantProperties)); }
private IConversation LoadConversation(ConversationIndex index) { ConversationId conversationId = ConversationId.Create(index); return(this.conversationFactory.CreateConversation(conversationId, ConversationCreatorSidCalculator.ConversationCreatorRelevantProperties)); }