private static void Serialize(IMessageItem message, StringBuilder sb) { switch (message.Type) { case ItemType.Boolean: sb.Append(message.ValueAsBool() ? "true" : "false"); break; case ItemType.IntegerNumber: case ItemType.FloatNumber: sb.Append(message.ValueAsString()); break; case ItemType.String: sb.Append(JsonConvert.ToString(message.ValueAsString())); break; case ItemType.Null: sb.Append("null"); break; case ItemType.Object: SerializeAsObject(message, sb); break; case ItemType.Array: SerializeAsArray(message, sb); break; } }
private void EscalateMessageToYammer(IMailboxSession mailboxSession, IExtensibleLogger logger, IGroupEscalateItemPerformanceTracker performanceTracker, string yammerEscalateAddress, bool hasEscalatedUser, StoreObjectId draftsFolderId, IMessageItem escalatedMessage) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); performanceTracker.EscalateToYammer = true; GroupEscalation.Tracer.TraceDebug((long)this.GetHashCode(), "GroupEscalation.EscalateItem: Escalating message to yammer group: " + yammerEscalateAddress); if (hasEscalatedUser) { try { using (IMessageItem messageItem = this.CreateEscalationMessage(mailboxSession, draftsFolderId, escalatedMessage)) { this.SendEscalateMessageToYammer(messageItem, yammerEscalateAddress, mailboxSession); } goto IL_7D; } catch (Exception arg) { this.TraceAndLogError(logger, "EscalateItem", string.Format("GroupEscalation.EscalateItem: Escalation to yammer failed. Got exception: {0}", arg)); goto IL_7D; } } this.SendEscalateMessageToYammer(escalatedMessage, yammerEscalateAddress, mailboxSession); IL_7D: stopwatch.Stop(); performanceTracker.SendToYammerMilliseconds = stopwatch.ElapsedMilliseconds; }
private StoreObjectId CreateWhenDoesntExist(string provider, Guid providerGuid, string userId, string networkId) { StoreObjectId objectId; using (IMessageItem messageItem = this.xsoFactory.CreateMessageAssociated(this.session, this.session.GetDefaultFolderId(DefaultFolderType.Contacts))) { string text = "IPM.Microsoft.OSC.SyncLock." + new OscNetworkMoniker(providerGuid, networkId, userId).ToString(); messageItem.ClassName = text; messageItem.Subject = text; messageItem[MessageItemSchema.OscSyncEnabledOnServer] = true; messageItem.Save(SaveMode.ResolveConflicts); messageItem.Load(new StorePropertyDefinition[] { ItemSchema.Id }); OscSyncLockCreator.Tracer.TraceDebug((long)this.GetHashCode(), "SyncLock creator: successfully created SyncLock for provider '{0}' (GUID={1}), user id '{2}', and network id '{3}'; item class is '{4}'", new object[] { provider, providerGuid, userId, networkId, text }); objectId = ((VersionedId)messageItem[ItemSchema.Id]).ObjectId; } return(objectId); }
public bool InsertFooterToTheBody(IMessageItem originalMessage, IMessageItem escalatedMessage) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); string escalationLink = this.linkBuilder.GetEscalationLink(EscalationLinkType.Unsubscribe); stopwatch.Stop(); this.lastLinkBuildTimeMs = stopwatch.ElapsedMilliseconds; if (!originalMessage.IBody.IsBodyDefined || this.BodyContainsFooter(originalMessage.IBody, escalationLink)) { return(false); } stopwatch = new Stopwatch(); stopwatch.Start(); bool flag = this.InsertLinkToBodyFooter(escalationLink, originalMessage.IBody, escalatedMessage.IBody); if (flag) { escalatedMessage.StampMessageBodyTag(); } stopwatch.Stop(); this.lastLinkInsertOnBodyTimeMs = stopwatch.ElapsedMilliseconds; return(flag); }
protected override void SendEscalateMessage(IMessageItem escalatedMessage) { escalatedMessage.CommitReplyTo(); using (MemorySubmissionItem memorySubmissionItem = new MemorySubmissionItem((MessageItem)escalatedMessage, this.mbxTransportMailItem.OrganizationId)) { memorySubmissionItem.Submit(MessageTrackingSource.AGENT, new MemorySubmissionItem.OnConvertedToTransportMailItemDelegate(this.TransportMailItemHandler), this.mbxTransportMailItem); } }
// Token: 0x06001AFD RID: 6909 RVA: 0x000666DC File Offset: 0x000648DC private bool IsEditable(IItem item) { if (item is Task) { return(true); } IMessageItem messageItem = item as IMessageItem; return(messageItem != null && messageItem.IsDraft); }
private IMessageItem CreateEscalationMessage(IMailboxSession mailboxSession, StoreId escalationFolderId, IMessageItem originalMessage) { IMessageItem messageItem = this.xsoFactory.Create(mailboxSession, escalationFolderId); messageItem.Load(InternalSchema.ContentConversionProperties); CoreItem.CopyItemContentExcept(originalMessage.CoreItem, messageItem.CoreItem, GroupEscalation.PropertiesToExcludeFromCopy); messageItem.CharsetDetector.DetectionOptions = originalMessage.CharsetDetector.DetectionOptions; messageItem.SaveFlags |= (originalMessage.SaveFlags | PropertyBagSaveFlags.IgnoreMapiComputedErrors | PropertyBagSaveFlags.IgnoreAccessDeniedErrors); return(messageItem); }
private void InitializeLoadedItemPart(IItem item, IStorePropertyBag propertyBag, BodyFragmentInfo bodyFragmentInfo, bool didLoadSucceed, long bytesLoaded, AttachmentCollection attachmentCollection) { this.bodyFragmentInfo = bodyFragmentInfo; if (this.bodyFragmentInfo == null) { base.UniqueFragmentInfo = (base.DisclaimerFragmentInfo = FragmentInfo.Empty); } this.didLoadSucceed = didLoadSucceed; if (this.didLoadSucceed) { this.bytesLoaded = bytesLoaded; } base.ItemId = item.Id.ObjectId; base.Subject = (item.TryGetProperty(ItemSchema.Subject) as string); if (attachmentCollection != null) { foreach (AttachmentHandle handle in attachmentCollection) { using (Attachment attachment = attachmentCollection.Open(handle, null)) { base.RawAttachments.Add(new AttachmentInfo(item.Id.ObjectId, attachment)); } } } IMessageItem messageItem = item as IMessageItem; if (messageItem != null) { if (messageItem.Sender != null) { this.displayNameToParticipant[messageItem.Sender.DisplayName] = messageItem.Sender; } if (messageItem.From != null) { this.displayNameToParticipant[messageItem.From.DisplayName] = messageItem.From; } foreach (Recipient recipient in messageItem.Recipients) { recipient.Participant.Submitted = recipient.Submitted; this.displayNameToParticipant[recipient.Participant.DisplayName] = recipient.Participant; base.Recipients.Add(recipient.RecipientItemType, new IParticipant[] { recipient.Participant }); } foreach (Participant participant in messageItem.ReplyTo) { this.displayNameToParticipant[participant.DisplayName] = participant; } } if (propertyBag != null) { base.StorePropertyBag = propertyBag; } }
// Token: 0x0600157B RID: 5499 RVA: 0x0007EA98 File Offset: 0x0007CC98 internal bool IsResponseMessageToSingleMeeting(IMessageItem message) { string className = message.ClassName; if (ObjectClass.IsMeetingResponse(className)) { bool flag = InternalRecurrence.HasRecurrenceBlob(message.CoreItem.PropertyBag); return(!flag); } return(false); }
/// <summary> /// 检查来自请求方的 /// </summary> public static void CheckRequestTraceInfo(this IMessageItem message) { if (message.TraceInfo == null) { message.TraceInfo = CreateTraceInfo(message); } else if (message.TraceInfo.Option.HasFlag(MessageTraceType.Request)) { message.TraceInfo.LocalApp = ZeroAppOption.Instance.LocalApp; message.TraceInfo.LocalMachine = ZeroAppOption.Instance.LocalMachine; } }
private static void SerializeAsArray(IMessageItem message, StringBuilder sb) { sb.Append("["); var obj = message.ValueAsObject(); var comma = false; foreach (var i in obj.Enumerate()) { if (comma) sb.Append(","); comma = true; Serialize(i.Value, sb); } sb.Append("]"); }
private static void SerializeAsObject(IMessageItem message, StringBuilder sb) { sb.Append("{"); var obj = message.ValueAsObject(); var comma = false; foreach (var i in obj.Enumerate()) { if (comma) sb.Append(","); comma = true; sb.AppendFormat("\"{0}\":", i.Key); Serialize(i.Value, sb); } sb.Append("}"); }
private void AddSubscriber(string message, IMessageItem messageItem) { if (_subscribers.TryGetValue(message, out List <IMessageItem> subscribers)) { var array = new IMessageItem[subscribers.Count + 1]; subscribers.CopyTo(array); array[subscribers.Count] = messageItem; _subscribers.TryUpdate(message, array.ToList(), subscribers); } else { _subscribers.TryAdd(message, new List <IMessageItem>() { messageItem }); } }
private void SendEscalateMessageToYammer(IMessageItem escalatedMessage, string yammerEscalateAddress, IMailboxSession mailboxSession) { foreach (Recipient recipient in escalatedMessage.Recipients) { recipient.Submitted = true; recipient[ItemSchema.Responsibility] = false; } this.SetUniqueBody(escalatedMessage, mailboxSession); Participant.Builder builder = new Participant.Builder { EmailAddress = yammerEscalateAddress, RoutingType = "SMTP" }; Recipient recipient2 = escalatedMessage.Recipients.Add(builder.ToParticipant(), RecipientItemType.Bcc); recipient2[ItemSchema.Responsibility] = true; this.SendEscalateMessage(escalatedMessage); }
private void SetUniqueBody(IMessageItem escalatedMessage, IMailboxSession mailboxSession) { StoreId messageStoreId = this.GetMessageStoreId(escalatedMessage.InReplyTo, mailboxSession); if (messageStoreId != null) { using (IMessageItem messageItem = this.xsoFactory.BindToMessage(mailboxSession, messageStoreId, null)) { BodyDiffer bodyDiffer = new BodyDiffer(messageItem.Body.GetConversationBodyScanner(), escalatedMessage.Body.GetConversationBodyScanner()); FragmentInfo uniqueBodyPart = bodyDiffer.UniqueBodyPart; using (TextWriter textWriter = escalatedMessage.Body.OpenTextWriter(new BodyWriteConfiguration(BodyFormat.TextHtml))) { using (HtmlWriter htmlWriter = new HtmlWriter(textWriter)) { uniqueBodyPart.WriteHtml(htmlWriter); } } } } }
public object Deserialize(Type type, IMessageItem message) { if (message.Type == ItemType.Boolean) { var value = message.ValueAsBool(); var intVal = value ? 1 : 0; if (type == typeof (bool)) return value; if (type == typeof (string)) return value.ToString(); if (type == typeof (int)) return intVal; if (type == typeof(byte)) return (byte)intVal; if (type == typeof(sbyte)) return (sbyte)intVal; if (type == typeof(short)) return (short)intVal; if (type == typeof(ushort)) return (ushort)intVal; if (type == typeof(long)) return (long)intVal; if (type == typeof(ulong)) return (ulong)intVal; } else if (message.Type == ItemType.IntegerNumber) { var value = long.Parse(message.ValueAsString()); if (type == typeof(bool)) return value==0?false:true; if (type == typeof(string)) return value.ToString(); if (type == typeof(int)) return (int)value; if (type == typeof(byte)) return (byte)value; if (type == typeof(sbyte)) return (sbyte)value; if (type == typeof(short)) return (short)value; if (type == typeof(ushort)) return (ushort)value; if (type == typeof(long)) return (long)value; if (type == typeof(ulong)) return (ulong)value; } else if (message.Type == ItemType.Null) { return null; } else if (message.Type == ItemType.String) ; return null; // var result = Activator.CreateInstance(type); //return result; }
public MessageDetailPage(IMessageItem item) { Title = "消息详情"; ToolbarItems.Add(new ToolbarItem() { Text = "删除", Command = item.Delete }); Content = new ScrollView { Content = new StackLayout { Spacing = 10, Padding = new Thickness(20), Children = { new Label { Text = item.Title, FontSize = 24, TextColor = Color.Black }, new Label { Text = "发件人:" + item.Sender, FontSize = 14 }, new Label { Text = "时间:" + item.Time.ToString(), FontSize = 14 }, new BoxView { Color = Color.Gray, Margin = new Thickness(0, 5, 0, 5), HeightRequest = 1 }, new Label { Text = item.Body, FontSize = 16 } } }, Orientation = ScrollOrientation.Vertical }; #if __IOS__ Xamarin.Forms.PlatformConfiguration.iOSSpecific.Page.SetUseSafeArea(this, true); #endif }
private StoreObjectId SetOscSyncEnabledOnServer(StoreObjectId syncLockId) { StoreObjectId result; using (IMessageItem messageItem = this.xsoFactory.BindToMessage(this.session, syncLockId, OscSyncLockCreator.PropertiesToLoadFromSyncLock)) { if (messageItem.GetValueOrDefault <bool>(MessageItemSchema.OscSyncEnabledOnServer, false)) { OscSyncLockCreator.Tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "SyncLock creator: OscSyncEnabledOnServer is already TRUE in SyncLock with id '{0}'", syncLockId); result = syncLockId; } else { OscSyncLockCreator.Tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "SyncLock creator: setting OscSyncEnabledOnServer to TRUE and saving SyncLock with id '{0}'", syncLockId); messageItem.OpenAsReadWrite(); messageItem[MessageItemSchema.OscSyncEnabledOnServer] = true; messageItem.Save(SaveMode.ResolveConflicts); result = syncLockId; } } return(result); }
static IInlineMessage CheckMessage(IMessagePoster poster, IMessageItem message) { var re = poster.CheckMessage(message); if (re != null) { return(re); } var ctx = GlobalContext.CurrentNoLazy; if (message is IInlineMessage inline) { if (ctx != null && ctx.Message == message) { inline = inline.CopyToRequest(); } else { inline.ResetToRequest(); } } else { inline = new InlineMessage { ID = message.ID, Service = message.Service, Method = message.Method, Result = message.Result, Argument = message.Argument, DataState = MessageDataState.ArgumentOffline }; } inline.CheckPostTraceInfo(); return(inline); }
/// <summary> /// 构造 /// </summary> public static TraceInfo CreateTraceInfo(this IMessageItem message) { var ctxMessage = GlobalContext.CurrentNoLazy?.Message; var opt = ZeroAppOption.Instance.GetTraceOption(message.Service); if (opt.HasFlag(MessageTraceType.LinkTrace)) { return new TraceInfo { TraceId = ctxMessage?.ID ?? message.ID, Option = opt, Start = DateTime.Now, LocalId = message.ID, LocalApp = ZeroAppOption.Instance.LocalApp, LocalMachine = ZeroAppOption.Instance.LocalMachine } } ; return(new TraceInfo { Option = opt, Start = DateTime.Now }); }
protected virtual void SendEscalateMessage(IMessageItem escalatedMessage) { escalatedMessage.SendWithoutSavingMessage(); }
/// <summary> /// 投递消息 /// </summary> /// <param name="message">消息</param> /// <param name="defPoster">服务未注册时,是否使用缺省投递器</param> /// <param name="autoOffline">是否自动离线</param> /// <returns>返回值,如果未进行离线交换message返回为空,此时请检查state</returns> public static async Task <IInlineMessage> Post(IMessageItem message, bool autoOffline = true, bool defPoster = true) { if (message == null || string.IsNullOrEmpty(message.Service) || string.IsNullOrEmpty(message.Method)) { FlowTracer.MonitorError($"参数错误:Service:{message?.Service} Method:{message?.Method}"); throw new ArgumentException("参数[message]不能为空且[message.Topic]与[message.Title]必须为有效值"); } using var scope = FlowTracer.DebugStepScope(() => $"[MessagePoster] {message.Service}/{message.Method}"); if (!ZeroAppOption.Instance.CanRun) { FlowTracer.MonitorError($"系统未运行,当前状态为:{ZeroAppOption.Instance.ApplicationState}"); if (message is IInlineMessage inlineMessage) { message.State = MessageState.Cancel; return(inlineMessage); } else { return(new InlineMessage { ID = message.ID, State = MessageState.Cancel, Service = message.Service, Method = message.Method, Result = message.Result, Argument = message.Argument, TraceInfo = message.TraceInfo }); } } var producer = MessagePostOption.Instance.GetService(message.Service, defPoster); if (producer == null) { FlowTracer.MonitorError($"服务({message.Service})不存在"); if (message is IInlineMessage inlineMessage) { message.State = MessageState.Unhandled; return(inlineMessage); } else { return(new InlineMessage { ID = message.ID, State = MessageState.Unhandled, Service = message.Service, Method = message.Method, Result = message.Result, Argument = message.Argument, TraceInfo = message.TraceInfo }); } } FlowTracer.MonitorDetails(() => $"[Poster] {producer.GetTypeName()}"); var inline = CheckMessage(producer, message); try { FlowTracer.MonitorTrace(() => $"[Context] {message.Context?.ToInnerString()}"); FlowTracer.MonitorTrace(() => $"[User] {message.User?.ToInnerString()}"); FlowTracer.MonitorTrace(() => $"[TraceInfo] {message.TraceInfo?.ToInnerString()}"); FlowTracer.MonitorDetails(() => $"[Argument] {inline.Argument ?? inline.ArgumentData?.ToInnerString()}"); var msg = await producer.Post(inline); if (msg != null) { inline.CopyResult(msg); } if (autoOffline) { inline.OfflineResult(); } FlowTracer.MonitorDetails(() => $"[State] {inline.State} [Result] {inline.Result ?? inline.ResultData?.ToJson() ?? "无返回值"}"); return(inline); } catch (MessagePostException ex) { logger.Exception(ex); inline.State = MessageState.NetworkError; return(inline); } catch (Exception ex) { logger.Exception(ex); inline.State = MessageState.FrameworkError; return(inline); } finally { } }
public static void ChunkSmsConversation(IXSOFactory xsoFactory, IMailboxSession session, ConversationIndex conversationIndex, ConversationIndexTrackingEx conversationIndexTrackingEx) { Util.ThrowOnNullArgument(session, "session"); Util.ThrowOnNullArgument(conversationIndex, "conversationIndex"); byte[] conversationIdBytes = ConversationId.Create(conversationIndex.Guid).GetBytes(); int conversationIdHash = (int)AllItemsFolderHelper.GetHashValue(conversationIdBytes); Stopwatch stopwatch = Stopwatch.StartNew(); List <IStorePropertyBag> list = xsoFactory.RunQueryOnAllItemsFolder <List <IStorePropertyBag> >(session, AllItemsFolderHelper.SupportedSortBy.ConversationIdHash, conversationIdHash, null, delegate(QueryResult queryResult) { List <IStorePropertyBag> list2 = null; bool flag = false; while (!flag) { IStorePropertyBag[] propertyBags = queryResult.GetPropertyBags(10); if (propertyBags == null || propertyBags.Length <= 0) { break; } for (int i = 0; i < propertyBags.Length; i++) { int?num2 = propertyBags[i].TryGetProperty(ItemSchema.ConversationIdHash) as int?; if (num2 == null) { break; } if (num2.Value != conversationIdHash) { flag = true; break; } byte[] array = propertyBags[i].TryGetProperty(InternalSchema.MapiConversationId) as byte[]; if (array != null && Util.CompareByteArray(conversationIdBytes, array)) { if (list2 == null) { list2 = new List <IStorePropertyBag>(10); } list2.Add(propertyBags[i]); } } } return(list2); }, new StorePropertyDefinition[] { ItemSchema.Id, ItemSchema.ConversationIdHash, ItemSchema.ReceivedTime, InternalSchema.MapiConversationId }); stopwatch.Stop(); if (conversationIndexTrackingEx != null) { conversationIndexTrackingEx.Trace("SBSMSCID", stopwatch.ElapsedMilliseconds.ToString()); } if (list == null || list.Count < 79) { return; } list.Sort(delegate(IStorePropertyBag x, IStorePropertyBag y) { ExDateTime?exDateTime = x.TryGetProperty(ItemSchema.ReceivedTime) as ExDateTime?; ExDateTime?exDateTime2 = y.TryGetProperty(ItemSchema.ReceivedTime) as ExDateTime?; if (exDateTime == null && exDateTime2 == null) { return(0); } if (exDateTime == null) { return(1); } if (exDateTime2 == null) { return(-1); } return(exDateTime.Value.CompareTo(exDateTime2.Value)); }); string str = conversationIndex.Guid.ToString("D").Substring("472e2878-19b1-4ac1-a21a-".Length); string text; do { text = Guid.NewGuid().ToString("D").Substring(0, "472e2878-19b1-4ac1-a21a-".Length); }while (string.Equals(text, "472e2878-19b1-4ac1-a21a-")); ConversationIndex conversationIndex2 = ConversationIndex.Create(new Guid(text + str)); int num = 0; while (num < list.Count && num < 50) { VersionedId versionedId = (VersionedId)list[num].TryGetProperty(ItemSchema.Id); if (versionedId != null) { StoreObjectId objectId = versionedId.ObjectId; if (objectId != null) { using (IMessageItem messageItem = xsoFactory.BindToMessage(session, objectId, null)) { messageItem.OpenAsReadWrite(); messageItem[ItemSchema.ConversationIndex] = conversationIndex2.ToByteArray(); messageItem[ItemSchema.ConversationIndexTracking] = true; messageItem.Save(SaveMode.ResolveConflicts); } } } num++; } }
// Token: 0x0600157A RID: 5498 RVA: 0x0007EA6C File Offset: 0x0007CC6C internal bool IsMeetingRelatedMessage(IMessageItem message) { string className = message.ClassName; return(ObjectClass.IsMeetingRequest(className) || ObjectClass.IsMeetingCancellation(className) || ObjectClass.IsMeetingResponse(className)); }
private void SetReadState(IMessageItem item) { Task.Run(async() => { await Core.App.Message.SetReadState(item.Id, true); item.Unread = false; }); }
private object DeserializeItem(IMessageItem item) { return null; }
/// <summary> /// 检查发送请求的跟踪信息 /// </summary> public static void CheckPostTraceInfo(this IMessageItem message) { var opttion = ZeroAppOption.Instance.GetTraceOption(message.Service); var ctx = GlobalContext.CurrentNoLazy; if (opttion.HasFlag(MessageTraceType.Context)) { message.Context = ctx?.ToDictionary(); } if (opttion.HasFlag(MessageTraceType.User)) { message.User = ScopeRuner.ScopeUser?.ToDictionary(); } if (!opttion.AnyFlags(MessageTraceType.LinkTrace, MessageTraceType.Token, MessageTraceType.Headers, MessageTraceType.Request)) { message.TraceInfo = null; return; } var info = message.TraceInfo = new TraceInfo { Option = opttion, Start = DateTime.Now }; var ctxTraceInfo = ctx?.TraceInfo; if (opttion.HasFlag(MessageTraceType.LinkTrace)) { if (ctxTraceInfo != null) { info.Level = ctxTraceInfo.Level + 1; info.TraceId = ctxTraceInfo.TraceId; info.LocalId = message.ID; info.CallId = ctxTraceInfo.LocalId; } else { info.TraceId = message.ID; info.CallId = message.ID; info.LocalId = message.ID; } } if (opttion.HasFlag(MessageTraceType.Request)) { if (ctxTraceInfo != null) { info.RequestApp = ctxTraceInfo.RequestApp; info.RequestPage = ctxTraceInfo.RequestPage; info.CallApp = ctxTraceInfo.LocalApp; info.CallMachine = ctxTraceInfo.LocalMachine; } else { info.RequestApp = ZeroAppOption.Instance.LocalApp; info.CallApp = ZeroAppOption.Instance.LocalApp; info.CallMachine = ZeroAppOption.Instance.LocalMachine; } } if (opttion.HasFlag(MessageTraceType.Token) && ctxTraceInfo != null) { info.Token = ctxTraceInfo.Token; } if (opttion.HasFlag(MessageTraceType.Headers) && ctxTraceInfo != null) { info.Headers = ctxTraceInfo.Headers; } }
public bool EscalateItem(IMessageItem item, IMailboxSession mailboxSession, out bool isTransientError, bool isFromYammer = false) { Util.ThrowOnNullArgument(item, "item"); Util.ThrowOnNullArgument(mailboxSession, "mailboxSession"); isTransientError = false; string yammerEscalateAddress; List <string> escalatedUsersList = this.GetEscalatedUsersList(mailboxSession, out yammerEscalateAddress); bool flag = GroupEscalation.ShouldEscalateToYammer(isFromYammer, yammerEscalateAddress, item.ClassName); if (escalatedUsersList.Count < 1 && !flag) { GroupEscalation.Tracer.TraceDebug((long)this.GetHashCode(), "GroupEscalation.EscalateItem: Skipping Escalation as there are no users in need to escalate"); return(true); } bool result = false; IExtensibleLogger logger = GroupEscalateItemDiagnosticsFrameFactory.Default.CreateLogger(mailboxSession.MailboxGuid, mailboxSession.OrganizationId); IGroupEscalateItemPerformanceTracker groupEscalateItemPerformanceTracker = GroupEscalateItemDiagnosticsFrameFactory.Default.CreatePerformanceTracker(mailboxSession); using (GroupEscalateItemDiagnosticsFrameFactory.Default.CreateDiagnosticsFrame("XSO", "EscalateItem", logger, groupEscalateItemPerformanceTracker)) { try { if (item.From != null) { groupEscalateItemPerformanceTracker.OriginalMessageSender = (item.From.EmailAddress ?? string.Empty); groupEscalateItemPerformanceTracker.OriginalMessageSenderRecipientType = ((item.From.Origin != null) ? item.From.Origin.ToString() : string.Empty); groupEscalateItemPerformanceTracker.OriginalMessageClass = (item.ClassName ?? string.Empty); groupEscalateItemPerformanceTracker.OriginalMessageId = ((item.Id != null) ? item.Id.ToBase64String() : string.Empty); groupEscalateItemPerformanceTracker.OriginalInternetMessageId = (item.InternetMessageId ?? string.Empty); } StoreObjectId escalationFolderId = GroupEscalation.GetEscalationFolderId(mailboxSession); using (IMessageItem messageItem = this.CreateEscalationMessage(mailboxSession, escalationFolderId, item)) { ExDateTime?valueOrDefault = item.PropertyBag.GetValueOrDefault <ExDateTime?>(ItemSchema.SentTime); if (valueOrDefault != null) { messageItem[InternalSchema.OriginalSentTimeForEscalation] = valueOrDefault; } else { this.TraceAndLogError(logger, "EscalateItem", "GroupEscalation.EscalateItem: Couldn't find client submit time."); } IExchangePrincipal mailboxOwner = mailboxSession.MailboxOwner; Participant participant = new Participant(mailboxOwner); if (!ObjectClass.IsMeetingMessage(messageItem.ClassName)) { messageItem.Sender = participant; } messageItem.SuppressAllAutoResponses(); messageItem.IsGroupEscalationMessage = true; Participant[] array = new Participant[messageItem.Recipients.Count]; int num = 0; foreach (Recipient recipient in messageItem.Recipients) { recipient[ItemSchema.Responsibility] = false; array[num] = recipient.Participant; num++; } groupEscalateItemPerformanceTracker.ParticipantsInOriginalMessage = array.Length; List <Participant> list = new List <Participant>(array); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); if (!participant.ExistIn(array)) { Recipient recipient2 = messageItem.Recipients.Add(participant, RecipientItemType.To); list.Add(participant); recipient2[ItemSchema.Responsibility] = false; groupEscalateItemPerformanceTracker.IsGroupParticipantAddedToParticipants = true; } stopwatch.Stop(); groupEscalateItemPerformanceTracker.EnsureGroupParticipantAddedMilliseconds = stopwatch.ElapsedMilliseconds; stopwatch.Reset(); stopwatch.Start(); bool flag2 = false; foreach (string emailAddress in escalatedUsersList) { Participant participant2 = new Participant.Builder { EmailAddress = emailAddress, RoutingType = "EX" }.ToParticipant(); if (!participant2.ExistIn(array)) { Recipient recipient3 = messageItem.Recipients.Add(participant2, RecipientItemType.Bcc); recipient3[ItemSchema.Responsibility] = true; flag2 = true; groupEscalateItemPerformanceTracker.IncrementParticipantsAddedToEscalatedMessage(); } else { groupEscalateItemPerformanceTracker.IncrementParticipantsSkippedInEscalatedMessage(); } } stopwatch.Stop(); groupEscalateItemPerformanceTracker.DedupeParticipantsMilliseconds = stopwatch.ElapsedMilliseconds; groupEscalateItemPerformanceTracker.HasEscalatedUser = flag2; if (!flag2 && !flag) { GroupEscalation.Tracer.TraceDebug((long)this.GetHashCode(), "GroupEscalation.EscalateItem: Skipping Escalation as there are no additional users in need to escalate"); return(true); } messageItem.MarkRecipientAsSubmitted(list.ToArray()); if (flag) { this.EscalateMessageToYammer(mailboxSession, logger, groupEscalateItemPerformanceTracker, yammerEscalateAddress, flag2, escalationFolderId, messageItem); } if (flag2) { this.InsertUnsubscribeLinkToBody(groupEscalateItemPerformanceTracker, logger, mailboxOwner, item, messageItem); this.SendEscalateMessage(messageItem); } result = true; } } catch (StoragePermanentException arg) { this.TraceAndLogError(logger, "EscalateItem", string.Format("GroupEscalation.EscalateItem: Escalation failed. Got store permanent exception: {0}", arg)); } catch (StorageTransientException arg2) { this.TraceAndLogError(logger, "EscalateItem", string.Format("GroupEscalation.EscalateItem: Escalation failed. Got store transient exception: {0}", arg2)); isTransientError = true; } catch (Exception arg3) { this.TraceAndLogError(logger, "EscalateItem", string.Format("GroupEscalation.EscalateItem: Escalation failed. Got exception: {0}", arg3)); throw; } } return(result); }
public string SerializeToString(IMessageItem message) { var sb = new StringBuilder(); Serialize(message, sb); return sb.ToString(); }
private void InsertUnsubscribeLinkToBody(IGroupEscalateItemPerformanceTracker performanceTracker, IExtensibleLogger logger, IExchangePrincipal groupExchangePrincipal, IMessageItem originalItem, IMessageItem escalatedMessage) { performanceTracker.UnsubscribeUrlInserted = false; if (!this.groupEscalationFlightInfo.IsGroupEscalationFooterEnabled()) { GroupEscalation.Tracer.TraceDebug((long)this.GetHashCode(), "GroupEscalation.InsertUnsubscribeLinkToBody: Skipping inserting link as the GroupsDeepLink flight isn't enabled"); return; } GroupEscalationFooter groupEscalationFooter = new GroupEscalationFooter(groupExchangePrincipal.MailboxInfo.DisplayName, this.GetPreferredCulture(groupExchangePrincipal), new EscalationLinkBuilder(groupExchangePrincipal, this.mailboxUrls)); try { bool unsubscribeUrlInserted = groupEscalationFooter.InsertFooterToTheBody(originalItem, escalatedMessage); performanceTracker.UnsubscribeUrlInserted = unsubscribeUrlInserted; } catch (Exception ex) { this.TraceAndLogError(logger, "EscalateItem", string.Format("GroupEscalation.InsertUnsubscribeLinkToBody: Escalation footer not inserted because of exception:{0}", ex.ToString())); } performanceTracker.BuildUnsubscribeUrlMilliseconds = groupEscalationFooter.LastLinkBuildTimeMs; performanceTracker.LinkBodySize = groupEscalationFooter.LastBodySizeBytes; performanceTracker.LinkOnBodyDetectionMilliseconds = groupEscalationFooter.LastLinkOnBodyDetectionTimeMs; performanceTracker.LinkInsertOnBodyMilliseconds = groupEscalationFooter.LastLinkInsertOnBodyTimeMs; }
public Message(MessageName name, IMessageItem item) { _item = item; Name = name; }