private void OnPromotedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = args as StoreDriverDeliveryEventArgsImpl; if (storeDriverDeliveryEventArgsImpl.IsPublicFolderRecipient || !ObjectClass.IsSmsMessage(storeDriverDeliveryEventArgsImpl.MessageClass)) { return; } SmsDeliveryAgent.Tracer.TraceDebug((long)this.GetHashCode(), "Processing incoming message"); Stopwatch stopwatch = Stopwatch.StartNew(); try { MimePart rootPart = storeDriverDeliveryEventArgsImpl.MailItem.Message.RootPart; Header header = rootPart.Headers.FindFirst("X-MS-Reply-To-Mobile"); if (header == null || string.IsNullOrEmpty(header.Value)) { SmsDeliveryAgent.Tracer.TraceDebug <string>((long)this.GetHashCode(), "There's no {0} header or the header value is empty in MimePart of the inbound SMS message", "X-MS-Reply-To-Mobile"); } else { string value = header.Value; string displayName = value; using (SmsRecipientInfoCache smsRecipientInfoCache = new SmsRecipientInfoCache(storeDriverDeliveryEventArgsImpl.MailboxSession, SmsDeliveryAgent.Tracer)) { RecipientInfoCacheEntry recipientInfoCacheEntry = smsRecipientInfoCache.LookUp(value); if (recipientInfoCacheEntry != null) { displayName = recipientInfoCacheEntry.DisplayName; } } storeDriverDeliveryEventArgsImpl.ReplayItem.From = new Participant(displayName, value, "MOBILE"); SmsDeliveryAgent.Tracer.TraceDebug((long)this.GetHashCode(), "Found entry from SMS recipient which matches"); string text = storeDriverDeliveryEventArgsImpl.ReplayItem.Body.GetPartialTextBody(160); if (!string.IsNullOrEmpty(text)) { text = text.Replace("\r\n", " ").Trim(); } storeDriverDeliveryEventArgsImpl.ReplayItem.Subject = (text ?? string.Empty); } } finally { stopwatch.Stop(); MSExchangeInboundSmsDelivery.MessageReceived.Increment(); if (MSExchangeInboundSmsDelivery.MaximumMessageProcessingTime.RawValue < stopwatch.ElapsedMilliseconds) { MSExchangeInboundSmsDelivery.MaximumMessageProcessingTime.RawValue = stopwatch.ElapsedMilliseconds; } SmsDeliveryAgent.averageMessageProcessingTime.Update(stopwatch.ElapsedMilliseconds); SmsDeliveryAgent.Tracer.TraceDebug <long>((long)this.GetHashCode(), "Exiting ConversationsProcessing.ProcessMessage. Total execution time = {0} ms.", stopwatch.ElapsedMilliseconds); } }
// Token: 0x06000114 RID: 276 RVA: 0x00006EAC File Offset: 0x000050AC private static void HandleSmsMessage(MailboxSession session, Item item, MailboxData mailboxData, ConversationIndexTrackingEx indexTrackingEx) { MessageItem messageItem = item as MessageItem; if (messageItem == null) { SentItemsProcessor.Tracer.TraceDebug(0L, "{0}: the SMS message is not MessageItem", new object[] { TraceContext.Get() }); return; } RecipientCollection recipients = messageItem.Recipients; if (recipients.Count == 0) { return; } using (SmsRecipientInfoCache smsRecipientInfoCache = SmsRecipientInfoCache.Create(session, SentItemsProcessor.Tracer)) { Dictionary <ConversationIndex, Recipient> dictionary = new Dictionary <ConversationIndex, Recipient>(recipients.Count); for (int i = recipients.Count - 1; i >= 0; i--) { Recipient recipient = recipients[i]; Participant participant = recipient.Participant; if (!(participant == null) && !string.IsNullOrEmpty(participant.EmailAddress)) { string text = null; if (string.Equals(participant.RoutingType, "MOBILE", StringComparison.OrdinalIgnoreCase)) { text = participant.EmailAddress; smsRecipientInfoCache.AddRecipient(participant); } else if (string.Equals(participant.RoutingType, "SMTP", StringComparison.OrdinalIgnoreCase)) { ProxyAddress proxyAddress; if (SmtpProxyAddress.TryDeencapsulate(participant.EmailAddress, out proxyAddress) && string.Equals(proxyAddress.PrefixString, "MOBILE", StringComparison.OrdinalIgnoreCase)) { text = proxyAddress.AddressString; } smsRecipientInfoCache.AddRecipient(new Participant(participant.DisplayName, text, "MOBILE")); } if (text != null) { ConversationIndex conversationIndex = ConversationIndex.GenerateFromPhoneNumber(text); if (!(conversationIndex == ConversationIndex.Empty)) { recipients.RemoveAt(i); if (!dictionary.ContainsKey(conversationIndex)) { dictionary.Add(conversationIndex, recipient); } } } } } if (recipients.Count > 0) { messageItem.Save(SaveMode.ResolveConflicts); messageItem.Load(); } int num = 0; foreach (KeyValuePair <ConversationIndex, Recipient> keyValuePair in dictionary) { num++; AggregationBySmsItemClassProcessor.ChunkSmsConversation(XSOFactory.Default, session, keyValuePair.Key, indexTrackingEx); if (num < dictionary.Count || recipients.Count > 0) { SentItemsProcessor.CloneSmsItem(session, messageItem, mailboxData, keyValuePair.Value, keyValuePair.Key); } else { recipients.Add(keyValuePair.Value); SentItemsProcessor.SaveSmsItem(messageItem, keyValuePair.Key); messageItem.Load(); } } smsRecipientInfoCache.Commit(); } }