public void OnPromotedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs e) { StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)e; if (storeDriverDeliveryEventArgsImpl.IsPublicFolderRecipient || storeDriverDeliveryEventArgsImpl.IsJournalReport) { UMPlayonPhoneAgent.Tracer.TraceError((long)this.GetHashCode(), "not supported for public folder or journal reports"); return; } if (!storeDriverDeliveryEventArgsImpl.ReplayItem.IsRestricted || !storeDriverDeliveryEventArgsImpl.ReplayItem.ClassName.StartsWith("IPM.Note.rpmsg.Microsoft.Voicemail.UM", StringComparison.OrdinalIgnoreCase)) { return; } UMMailboxPolicy ummailboxPolicy; if (!UMAgentUtil.TryGetUMMailboxPolicy(UMPlayonPhoneAgent.Tracer, storeDriverDeliveryEventArgsImpl.ADRecipientCache, storeDriverDeliveryEventArgsImpl.MailRecipient, out ummailboxPolicy)) { return; } if (storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies == null) { storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies = new Dictionary <PropertyDefinition, object>(); } if (ummailboxPolicy.RequireProtectedPlayOnPhone) { storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[MessageItemSchema.RequireProtectedPlayOnPhone] = "true"; } }
public void OnDemotedMessageHandler(StoreDriverEventSource source, StoreDriverSubmissionEventArgs args) { MailItem mailItem = args.MailItem; StoreDriverSubmissionEventArgsImpl storeDriverSubmissionEventArgsImpl = (StoreDriverSubmissionEventArgsImpl)args; MessageItem item = storeDriverSubmissionEventArgsImpl.SubmissionItem.Item; if (ApprovalInitiation.IsArbitrationMailbox((ADRecipientCache <TransportMiniRecipient>)mailItem.RecipientCache, mailItem.FromAddress)) { item.Load(ApprovalSubmitterAgent.ModeratedTransportProperties); ApprovalStatus?valueAsNullable = item.GetValueAsNullable <ApprovalStatus>(MessageItemSchema.ApprovalStatus); string valueOrDefault = item.GetValueOrDefault <string>(MessageItemSchema.ApprovalDecisionMaker, string.Empty); if (valueAsNullable != null && (valueAsNullable.Value & ApprovalStatus.Approved) == ApprovalStatus.Approved) { TransportMailItem transportMailItem = ((TransportMailItemWrapper)mailItem).TransportMailItem; ModeratedTransportHandling.ResubmitApprovedMessage(item, transportMailItem, valueOrDefault); return; } if (ObjectClass.IsOfClass(item.ClassName, "IPM.Microsoft.Approval.Initiation") || ObjectClass.IsOfClass(item.ClassName, "IPM.Note.Microsoft.Approval.Request.Recall")) { Header header = (TextHeader)Header.Create("X-MS-Exchange-Organization-Do-Not-Journal"); header.Value = "ArbitrationMailboxSubmission"; mailItem.MimeDocument.RootPart.Headers.AppendChild(header); Header newChild = new AsciiTextHeader("X-MS-Exchange-Organization-Approval-Initiator", "mapi"); mailItem.MimeDocument.RootPart.Headers.AppendChild(newChild); } } }
public void OnCompletedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { if (this.logValues != null) { this.classificationAgentLogger.LogClassificationProperties(this.logValues, (!this.wasMessageDelivered) ? InferenceClassificationAgentLogger.Status.DeliveryFailed.ToString() : null); } }
public void OnCreatedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; if (RetentonPolicyTagProcessingAgent.IsRetentionPolicyEnabled(storeDriverDeliveryEventArgsImpl.ADRecipientCache, storeDriverDeliveryEventArgsImpl.MailRecipient.Email)) { RetentionTagHelper.ApplyPolicy(storeDriverDeliveryEventArgsImpl.MailboxSession, storeDriverDeliveryEventArgsImpl.RetentionPolicyTag, storeDriverDeliveryEventArgsImpl.RetentionFlags, storeDriverDeliveryEventArgsImpl.RetentionPeriod, storeDriverDeliveryEventArgsImpl.ArchiveTag, storeDriverDeliveryEventArgsImpl.ArchivePeriod, storeDriverDeliveryEventArgsImpl.CompactDefaultRetentionPolicy, storeDriverDeliveryEventArgsImpl.MessageItem); } }
private void OnPromotedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; if (MeetingSeriesMessageOrderingAgent.SeriesMessageOrderingEnabled(storeDriverDeliveryEventArgsImpl.MailboxOwner)) { this.OrderMessages(storeDriverDeliveryEventArgsImpl); } }
internal override void Invoke(string eventTopic, object source, object e) { Delegate @delegate = (Delegate)base.Handlers[eventTopic]; if (@delegate == null) { return; } StoreDriverEventSource source2 = (StoreDriverEventSource)source; StoreDriverDeliveryEventArgs storeDriverDeliveryEventArgs = (StoreDriverDeliveryEventArgs)e; ((SmtpServer)this.HostState).AddressBook.RecipientCache = storeDriverDeliveryEventArgs.MailItem.RecipientCache; if (eventTopic != null) { if (!(eventTopic == "OnInitializedMessage")) { if (!(eventTopic == "OnPromotedMessage")) { if (!(eventTopic == "OnCreatedMessage")) { if (!(eventTopic == "OnDeliveredMessage")) { if (!(eventTopic == "OnCompletedMessage")) { goto IL_DA; } ((CompletedMessageEventHandler)@delegate)(source2, storeDriverDeliveryEventArgs); } else { ((DeliveredMessageEventHandler)@delegate)(source2, storeDriverDeliveryEventArgs); } } else { ((CreatedMessageEventHandler)@delegate)(source2, storeDriverDeliveryEventArgs); } } else { ((PromotedMessageEventHandler)@delegate)(source2, storeDriverDeliveryEventArgs); } } else { ((InitializedMessageEventHandler)@delegate)(source2, storeDriverDeliveryEventArgs); } if (base.Synchronous) { ((SmtpServer)this.HostState).AddressBook.RecipientCache = null; } return; } IL_DA: throw new InvalidOperationException("Internal error: unsupported event topic: " + (eventTopic ?? "null")); }
public void OnCreatedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; if (this.ShouldProcessMessage(storeDriverDeliveryEventArgsImpl)) { MeetingMessageProcessing.ProcessMessage(storeDriverDeliveryEventArgsImpl.MessageItem, storeDriverDeliveryEventArgsImpl.MailRecipient, this.GetCachedCalendarItemIdFromHeaders(storeDriverDeliveryEventArgsImpl), storeDriverDeliveryEventArgsImpl.DeliverToFolder); this.SaveChangedPropertiesForDelegateForward(storeDriverDeliveryEventArgsImpl); } }
private void OnPromotedMessageImplementation(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { this.logger.TraceDebug(new string[] { "SharedMailboxSentItemsAgent.OnPromotedMessageHandler: entering." }); StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = args as StoreDriverDeliveryEventArgsImpl; if (storeDriverDeliveryEventArgsImpl == null) { this.logger.TraceDebug(new string[] { "SharedMailboxSentItemsAgent.OnPromotedMessageHandler: args is null or not a StoreDriverDeliveryEventArgsImpl; exiting." }); return; } if (!SharedMailboxSentItemsAgent.IsSharedMailboxSentItemsDeliveryAgentFeatureEnabled(storeDriverDeliveryEventArgsImpl.MailboxOwner)) { this.logger.TraceDebug(new string[] { "SharedMailboxSentItemsAgent.OnPromotedMessageHandler: Flight for the feature is not enabled; exiting." }); return; } if (storeDriverDeliveryEventArgsImpl.MailboxSession == null) { this.logger.TraceDebug(new string[] { "SharedMailboxSentItemsAgent.OnPromotedMessageHandler: Mailbox session is null; exiting." }); return; } if (args.MailItem.Message == null) { this.logger.TraceDebug(new string[] { "SharedMailboxSentItemsAgent.OnPromotedMessageHandler: Message is null; exiting." }); return; } if (storeDriverDeliveryEventArgsImpl.ReplayItem == null) { this.logger.TraceDebug(new string[] { "SharedMailboxSentItemsAgent.OnPromotedMessageHandler: ReplayItem is null; exiting." }); return; } EmailMessage message = args.MailItem.Message; MailboxSession mailboxSession = storeDriverDeliveryEventArgsImpl.MailboxSession; MessageItem replayItem = storeDriverDeliveryEventArgsImpl.ReplayItem; string mdbGuid = storeDriverDeliveryEventArgsImpl.MailboxSession.MdbGuid.ToString(); this.ProcessSentItemWrapperMessage(message, mdbGuid, replayItem, new StoreOperations(mailboxSession, this.logger), new AgentInfoWriter(args, "SharedMailboxSentItemsAgent")); }
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); } }
public void OnCompletedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { using (new MailboxRulesPerformanceTracker(this.stopwatch)) { this.DisposeAgentState(); } long num = Math.Max(0L, this.stopwatch.ElapsedMilliseconds); MailboxRulesAgent.processingTime.AddValue(num); MSExchangeStoreDriver.MailboxRulesMilliseconds90thPercentile.RawValue = MailboxRulesAgent.processingTime.PercentileQuery(90.0); MailboxRulesAgent.averageMilliseconds.Update((float)num); MSExchangeStoreDriver.MailboxRulesMilliseconds.RawValue = (long)MailboxRulesAgent.averageMilliseconds.Value; }
public void OnCreatedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; MailRecipient mailRecipient = storeDriverDeliveryEventArgsImpl.MailRecipient; DeliverableMailItem mailItem = storeDriverDeliveryEventArgsImpl.MailItem; MbxTransportMailItem mbxTransportMailItem = storeDriverDeliveryEventArgsImpl.MailItemDeliver.MbxTransportMailItem; MessageItem messageItem = storeDriverDeliveryEventArgsImpl.MessageItem; bool flag = false; bool flag2 = ApprovalInitiation.IsArbitrationMailbox(mbxTransportMailItem.ADRecipientCache, mailRecipient.Email); if (!flag2 && string.Equals(messageItem.ClassName, "IPM.Note.Microsoft.Approval.Request.Recall", StringComparison.OrdinalIgnoreCase)) { flag = true; } EmailMessage message = mailItem.Message; TestMessageConfig testMessageConfig = new TestMessageConfig(message); if (testMessageConfig.IsTestMessage && (testMessageConfig.LogTypes & LogTypesEnum.Arbitration) != LogTypesEnum.None) { EmailMessage emailMessage = ArbitrationMailboxReport.GenerateContentReport(new SmtpAddress(mailRecipient.Email.ToString()), testMessageConfig.ReportToAddress, messageItem.Session, flag2); if (emailMessage != null) { ApprovalProcessingAgent.diag.TraceDebug(0L, "Submit arbitration mailbox content report message"); this.server.SubmitMessage(mbxTransportMailItem, emailMessage, mbxTransportMailItem.OrganizationId, mbxTransportMailItem.ExternalOrganizationId, false); } else { ApprovalProcessingAgent.diag.TraceDebug(0L, "Failed to generate arbitration mailbox content report"); } throw new SmtpResponseException(AckReason.ApprovalUpdateSuccess, base.Name); } if (!flag) { if (flag2) { ApprovalEngine approvalEngineInstance = ApprovalEngine.GetApprovalEngineInstance(message, (RoutingAddress)message.From.SmtpAddress, mailRecipient.Email, messageItem, mbxTransportMailItem, ApprovalProcessingAgent.MessageItemCreationDelegate); ApprovalEngine.ApprovalProcessResults resultInfo = approvalEngineInstance.ProcessMessage(); this.HandleResults(resultInfo, messageItem, mbxTransportMailItem, mailRecipient); } return; } if (!MultilevelAuth.IsInternalMail(message)) { return; } if (ApprovalRequestUpdater.Result.InvalidUpdateMessage == ApprovalRequestUpdater.TryUpdateExistingApprovalRequest(messageItem)) { throw new SmtpResponseException(AckReason.ApprovalInvalidMessage); } throw new SmtpResponseException(AckReason.ApprovalUpdateSuccess, base.Name); }
public void OnInitializedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; string arg = args.MailItem.FromAddress.ToString(); string text = storeDriverDeliveryEventArgsImpl.MailRecipient.MsgId.ToString(); UnJournalAgent.Tracer.TraceDebug <string, string>(0L, "OnInitializedMessageHandler: MessageId {0}, Invoked Sender {1}", text, arg); if (this.ShouldProcess(storeDriverDeliveryEventArgsImpl.ADRecipientCache.OrganizationId, args.MailItem, text) && this.IsSender(args)) { AddressHeader addressHeader = args.MailItem.Message.MimeDocument.RootPart.Headers.FindFirst("X-MS-Exchange-Organization-BCC") as AddressHeader; UnJournalAgent.Tracer.TraceDebug <string, string, string>(0L, "OnInitializedMessageHandler: MessageId {0}, GetBccRecipients Sender {1}, BccHeader {2} = ", text, arg, (addressHeader == null) ? string.Empty : addressHeader.ToString()); this.bccRecipients = this.GetBccRecipients(addressHeader); } }
public void OnCreatedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { if (this.evaluationResult != null) { ExTraceGlobals.FaultInjectionTracer.TraceTest(40592U); using (new MailboxRulesPerformanceTracker(this.stopwatch)) { StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; this.evaluationResult.Context.FinalDeliveryFolderId = storeDriverDeliveryEventArgsImpl.DeliverToFolder; this.evaluationResult.Context.DeliveredMessage = storeDriverDeliveryEventArgsImpl.MessageItem; this.evaluationResult.Execute(ExecutionStage.OnCreatedMessage); } } }
private void OnPromotedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { if (StoreDriverConfig.Instance.IsAutoAcceptForGroupAndSelfForwardedEventEnabled) { StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; if ((ObjectClass.IsMeetingRequest(storeDriverDeliveryEventArgsImpl.MessageClass) || ObjectClass.IsMeetingResponse(storeDriverDeliveryEventArgsImpl.MessageClass)) && !this.IsEHAMigrationMeetingMessage(storeDriverDeliveryEventArgsImpl.MailItem)) { MailboxSession mailboxSession = storeDriverDeliveryEventArgsImpl.MailboxSession; if (mailboxSession == null || storeDriverDeliveryEventArgsImpl.ReplayItem == null) { MeetingMessageProcessingAgent.tracer.TraceError((long)this.GetHashCode(), "MeetingMessageProcessingAgent::OnPromotedMessageHandler() MailboxSession or StoreDriverDeliveryEventArgsImpl.ReplayItem is null"); return; } if (ObjectClass.IsMeetingRequest(storeDriverDeliveryEventArgsImpl.MessageClass) && !mailboxSession.IsGroupMailbox()) { MeetingRequest meetingRequest = null; try { meetingRequest = (Item.ConvertFrom(storeDriverDeliveryEventArgsImpl.ReplayItem, mailboxSession) as MeetingRequest); if (meetingRequest != null && MeetingMessageProcessing.IsSentToSelf(meetingRequest, mailboxSession)) { MeetingMessageProcessingAgent.tracer.TraceDebug <string, IExchangePrincipal>((long)this.GetHashCode(), "Attempting to deliver self forwarded message {0} to mailbox {1} to Deleted Items", meetingRequest.InternetMessageId, mailboxSession.MailboxOwner); this.DeliverToDeletedItems(mailboxSession, meetingRequest, storeDriverDeliveryEventArgsImpl); } } finally { if (meetingRequest != null) { Item.SafeDisposeConvertedItem(storeDriverDeliveryEventArgsImpl.ReplayItem, meetingRequest); } } } if (ObjectClass.IsMeetingResponse(storeDriverDeliveryEventArgsImpl.MessageClass) && mailboxSession.IsGroupMailbox()) { MeetingResponse meetingResponse = Item.ConvertFrom(storeDriverDeliveryEventArgsImpl.ReplayItem, mailboxSession) as MeetingResponse; if (meetingResponse != null && meetingResponse.IsSilent) { ADRecipient adrecipient = null; if (meetingResponse.From.TryGetADRecipient(mailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid), out adrecipient) && adrecipient != null && adrecipient.RecipientDisplayType != RecipientDisplayType.ConferenceRoomMailbox && adrecipient.RecipientDisplayType != RecipientDisplayType.SyncedConferenceRoomMailbox && adrecipient.RecipientDisplayType != RecipientDisplayType.EquipmentMailbox && adrecipient.RecipientDisplayType != RecipientDisplayType.SyncedEquipmentMailbox && !meetingResponse.IsCounterProposal) { MeetingMessageProcessingAgent.tracer.TraceDebug <string, IExchangePrincipal>((long)this.GetHashCode(), "Attempting to deliver empty response {0} to mailbox {1} to Deleted Items", meetingResponse.InternetMessageId, mailboxSession.MailboxOwner); this.DeliverToDeletedItems(mailboxSession, meetingResponse, storeDriverDeliveryEventArgsImpl); } } } } } }
public void OnPromotedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; if (this.msgClassifications == null) { this.msgClassifications = ClassificationUtils.ExtractClassifications(storeDriverDeliveryEventArgsImpl.MailItemDeliver.MbxTransportMailItem.RootPart.Headers); } if (this.IsJournalReport(storeDriverDeliveryEventArgsImpl.MailItemDeliver.MbxTransportMailItem)) { this.ProcessClassificationsForJournalReport(storeDriverDeliveryEventArgsImpl); return; } this.ProcessClassifications(storeDriverDeliveryEventArgsImpl); }
public void OnPromotedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { if (args == null) { return; } StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; MailboxSession mailboxSession = storeDriverDeliveryEventArgsImpl.MailboxSession; string messageClass = storeDriverDeliveryEventArgsImpl.MessageClass; if (GroupEscalationAgent.ShouldBlockMessageForGroup(mailboxSession, messageClass)) { storeDriverDeliveryEventArgsImpl.DeliverToFolder = mailboxSession.GetDefaultFolderId(DefaultFolderType.DeletedItems); GroupEscalationAgent.Tracer.TraceDebug <string>((long)this.GetHashCode(), "GroupEscalationAgent.OnPromotedMessageHandler: message is blocked. Its class is {0}", messageClass); } }
public void OnDeliveredMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { if (this.evaluationResult != null) { using (new MailboxRulesPerformanceTracker(this.stopwatch)) { StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; this.evaluationResult.Context.DeliveredMessage = storeDriverDeliveryEventArgsImpl.MessageItem; this.evaluationResult.Context.PropertiesForAllMessageCopies = storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies; this.evaluationResult.Context.PropertiesForDelegateForward = storeDriverDeliveryEventArgsImpl.PropertiesForDelegateForward; this.evaluationResult.Execute(ExecutionStage.OnDeliveredMessage); this.evaluationContext.UpdateDeferredError(); this.HandleTestMessage(storeDriverDeliveryEventArgsImpl); List <string> errorRecords = ((RuleEvaluationContext)this.evaluationResult.Context).ErrorRecords; storeDriverDeliveryEventArgsImpl.AddDeliveryErrors(errorRecords); } } }
public void OnDemotedMessageHandler(StoreDriverEventSource source, StoreDriverSubmissionEventArgs args) { StoreDriverSubmissionEventArgsImpl storeDriverSubmissionEventArgsImpl = (StoreDriverSubmissionEventArgsImpl)args; if (MfnSubmitterAgent.ShouldGenerateMfn(storeDriverSubmissionEventArgsImpl.SubmissionItem.MessageClass)) { using (MfnSubmitter mfnSubmitter = new MfnSubmitter(storeDriverSubmissionEventArgsImpl.SubmissionItem, storeDriverSubmissionEventArgsImpl.MailItemSubmitter)) { TransportMailItem originalMailItem = null; TransportMailItemWrapper transportMailItemWrapper = args.MailItem as TransportMailItemWrapper; if (transportMailItemWrapper != null) { originalMailItem = transportMailItemWrapper.TransportMailItem; } mfnSubmitter.CheckAndSubmitMfn(originalMailItem); } } }
public void OnPromotedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs e) { StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)e; Header header = storeDriverDeliveryEventArgsImpl.MailItem.Message.MimeDocument.RootPart.Headers.FindFirst("X-MS-Exchange-Organization-Network-Message-Id"); this.diagnosticsSession.TraceDebug <string>("Processing message {0}", (header != null) ? header.Value : "unknown"); if (this.mimeHeaders != null) { this.diagnosticsSession.TraceDebug("Already processed this message", new object[0]); return; } this.mimeHeaders = storeDriverDeliveryEventArgsImpl.MailItem.Message.MimeDocument.RootPart.Headers; string property = this.GetProperty("X-MS-Exchange-Forest-IndexAgent"); if (property == null || !XHeaderStream.IsVersionSupported(property)) { this.diagnosticsSession.TraceDebug("X-header not present.", new object[0]); return; } bool invalidAnnotationToken = false; EmailMessageHash emailMessageHash; if (EmailMessageHash.TryGetFromHeader(this.mimeHeaders, out emailMessageHash)) { EmailMessageHash emailMessageHash2 = new EmailMessageHash(storeDriverDeliveryEventArgsImpl.MailItem.Message); this.diagnosticsSession.TraceDebug <EmailMessageHash>("Computed hash value for current message: {0}.", emailMessageHash2); if (!StringComparer.OrdinalIgnoreCase.Equals(emailMessageHash.ToString(), emailMessageHash2.ToString())) { this.diagnosticsSession.TraceDebug <EmailMessageHash, EmailMessageHash>("The current hash value ({0}) doesn't match the original({1})", emailMessageHash2, emailMessageHash); invalidAnnotationToken = true; } } try { using (XHeaderStream xheaderStream = new XHeaderStream(new Func <string, string>(this.GetProperty))) { this.PromoteProperties(xheaderStream, storeDriverDeliveryEventArgsImpl.ReplayItem, invalidAnnotationToken); } } catch (Exception arg) { this.diagnosticsSession.TraceError <Exception>("Exception during PromoteProperties: {0}", arg); } }
public void OnPromotedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; MbxTransportMailItem mbxTransportMailItem = storeDriverDeliveryEventArgsImpl.MailItemDeliver.MbxTransportMailItem; if (storeDriverDeliveryEventArgsImpl.IsPublicFolderRecipient || storeDriverDeliveryEventArgsImpl.IsJournalReport) { return; } Guid?guidHeaderValue = ContentAggregationAgentFactory.ContentAggregationAgent.GetGuidHeaderValue(mbxTransportMailItem, "X-MS-Exchange-Organization-Sharing-Instance-Guid"); if (guidHeaderValue == null) { return; } storeDriverDeliveryEventArgsImpl.ShouldRunMailboxRulesBasedOnDeliveryFolder = true; if (storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies == null) { storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies = new Dictionary <PropertyDefinition, object>(3); } storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies.Add(MessageItemSchema.SharingInstanceGuid, guidHeaderValue.Value); ExTraceGlobals.DeliveryAgentTracer.TraceDebug <Guid?>(mbxTransportMailItem.RecordId, "Sharing Instance Guid: {0}", guidHeaderValue); string textHeaderValue = ContentAggregationAgentFactory.ContentAggregationAgent.GetTextHeaderValue(mbxTransportMailItem, "X-MS-Exchange-Organization-Cloud-Id"); if (!string.IsNullOrEmpty(textHeaderValue)) { storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies.Add(ItemSchema.CloudId, textHeaderValue); } ExTraceGlobals.DeliveryAgentTracer.TraceDebug <string>(mbxTransportMailItem.RecordId, "Cloud Id: {0}", textHeaderValue); string textHeaderValue2 = ContentAggregationAgentFactory.ContentAggregationAgent.GetTextHeaderValue(mbxTransportMailItem, "X-MS-Exchange-Organization-Cloud-Version"); if (!string.IsNullOrEmpty(textHeaderValue2)) { storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies.Add(ItemSchema.CloudVersion, textHeaderValue2); } ExTraceGlobals.DeliveryAgentTracer.TraceDebug <string>(mbxTransportMailItem.RecordId, "Cloud Version: {0}", textHeaderValue2); StoreId storeId; if (this.TryGetDeliveryFolderId(mbxTransportMailItem, storeDriverDeliveryEventArgsImpl.MailboxSession, out storeId)) { storeDriverDeliveryEventArgsImpl.DeliverToFolder = storeId; } ExTraceGlobals.DeliveryAgentTracer.TraceDebug <StoreId>(mbxTransportMailItem.RecordId, "Delivery Folder: {0}", storeId); }
public void OnDeliveredMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; MailboxSession mailboxSession = storeDriverDeliveryEventArgsImpl.MailboxSession; if (mailboxSession == null || !mailboxSession.IsGroupMailbox()) { GroupEscalationAgent.Tracer.TraceDebug((long)this.GetHashCode(), "GroupEscalationAgent.OnDeliveredMessageHandler: Session null or not a group mailbox."); return; } MessageItem messageItem = storeDriverDeliveryEventArgsImpl.MessageItem; messageItem.Load(new PropertyDefinition[] { ItemSchema.InternetMessageId, ItemSchema.SentTime }); this.processedMessages.ClearMessageFromProcessedList(messageItem.InternetMessageId, messageItem.SentTime, mailboxSession.MailboxGuid); }
public void OnDemotedMessageHandler(StoreDriverEventSource source, StoreDriverSubmissionEventArgs args) { if (SubmissionConfiguration.Instance.App.EnableUnparkedMessageRestoring) { MailItem mailItem = args.MailItem; StoreDriverSubmissionEventArgsImpl storeDriverSubmissionEventArgsImpl = (StoreDriverSubmissionEventArgsImpl)args; MessageItem item = storeDriverSubmissionEventArgsImpl.SubmissionItem.Item; StoreSession session = storeDriverSubmissionEventArgsImpl.SubmissionItem.Session; if (ObjectClass.IsParkedMeetingMessage(storeDriverSubmissionEventArgsImpl.SubmissionItem.MessageClass)) { DateTime utcNow = DateTime.UtcNow; TransportMailItem transportMailItem = ((TransportMailItemWrapper)mailItem).TransportMailItem; ModerationHelper.RestoreOriginalMessage(item, transportMailItem, TraceHelper.ParkedItemSubmitterAgentTracer, TraceHelper.MessageProbeActivityId); transportMailItem.RootPart.Headers.RemoveAll("X-MS-Exchange-Organization-OriginalArrivalTime"); transportMailItem.RootPart.Headers.AppendChild(new AsciiTextHeader("X-MS-Exchange-Organization-OriginalArrivalTime", Util.FormatOrganizationalMessageArrivalTime(utcNow))); transportMailItem.ExtendedProperties.Clear(); transportMailItem.UpdateDirectionalityAndScopeHeaders(); transportMailItem.UpdateCachedHeaders(); } } }
public void OnCreatedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; MessageItem messageItem = storeDriverDeliveryEventArgsImpl.MessageItem; MbxTransportMailItem mbxTransportMailItem = storeDriverDeliveryEventArgsImpl.MailItemDeliver.MbxTransportMailItem; if (messageItem == null || mbxTransportMailItem == null) { GroupEscalationAgent.Tracer.TraceError((long)this.GetHashCode(), "No message to process"); return; } MailboxSession mailboxSession = messageItem.Session as MailboxSession; if (GroupEscalationAgent.ShouldGenerateIrmNdr(mailboxSession, messageItem, storeDriverDeliveryEventArgsImpl.MailboxOwner)) { GroupEscalationAgent.Tracer.TraceDebug((long)this.GetHashCode(), "GroupEscalationAgent.ShouldProcessMessage: NDR the message since it's irm message sent to group"); throw new SmtpResponseException(GroupEscalationAgent.IrmMessageDeliveryToGroupMailBoxError); } if (!this.ShouldProcessMessage(mailboxSession, storeDriverDeliveryEventArgsImpl)) { return; } IGroupEscalationFlightInfo groupEscalationFlightInfo = new GroupEscalationFlightInfo(storeDriverDeliveryEventArgsImpl.MailboxOwner.GetContext(null)); TransportGroupEscalation transportGroupEscalation = new TransportGroupEscalation(mbxTransportMailItem, XSOFactory.Default, groupEscalationFlightInfo, new MailboxUrls(mailboxSession.MailboxOwner, false)); bool flag; if (transportGroupEscalation.EscalateItem(messageItem, mailboxSession, out flag, false)) { GroupEscalationAgent.Tracer.TraceDebug <string>((long)this.GetHashCode(), "GroupEscalationAgent.EscalateItem: Escalation of message {0} from group mailbox successful", messageItem.InternetMessageId); this.processedMessages.AddMessageToProcessedList(messageItem.InternetMessageId, messageItem.SentTime, mailboxSession.MailboxGuid, DeliveryStage.CreatedMessageEventHandled); return; } GroupEscalationAgent.Tracer.TraceError <string, bool>((long)this.GetHashCode(), "GroupEscalationAgent.EscalateItem: Escalation of message {0} from group mailbox failed. IsTransientError: {1}", messageItem.InternetMessageId, flag); this.processedMessages.ClearMessageFromProcessedList(messageItem.InternetMessageId, messageItem.SentTime, mailboxSession.MailboxGuid); if (flag) { throw new SmtpResponseException(GroupEscalationAgent.EscalationFailedTransientError); } throw new SmtpResponseException(GroupEscalationAgent.EscalationFailedPermanentError); }
public void OnPromotedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; string arg = args.MailItem.FromAddress.ToString(); string text = storeDriverDeliveryEventArgsImpl.MailRecipient.MsgId.ToString(); UnJournalAgent.Tracer.TraceDebug <string, string>(0L, "OnPromotedMessageHandler: MessageId {0}, Sender {1}", text, arg); if (this.IsSender(args) && this.ShouldProcess(storeDriverDeliveryEventArgsImpl.ADRecipientCache.OrganizationId, args.MailItem, text) && !this.IsSenderARecipient(args.MailItem, text)) { this.ChangeDestinationFolder(DefaultFolderType.SentItems, args); return; } if (this.ShouldProcessWithNdrCheck(storeDriverDeliveryEventArgsImpl.ADRecipientCache.OrganizationId, args.MailItem, text)) { this.ChangeDestinationFolder(DefaultFolderType.LegacyArchiveJournals, args); return; } if (this.ShouldProcess(storeDriverDeliveryEventArgsImpl.ADRecipientCache.OrganizationId, args.MailItem, text)) { this.ChangeDestinationFolder(DefaultFolderType.Inbox, args); } }
public void OnDeliveredMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; MailRecipient mailRecipient = storeDriverDeliveryEventArgsImpl.MailRecipient; MbxTransportMailItem mbxTransportMailItem = storeDriverDeliveryEventArgsImpl.MailItemDeliver.MbxTransportMailItem; if (!ApprovalInitiation.IsArbitrationMailbox(mbxTransportMailItem.ADRecipientCache, mailRecipient.Email)) { return; } DeliverableMailItem mailItem = storeDriverDeliveryEventArgsImpl.MailItem; MessageItem messageItem = storeDriverDeliveryEventArgsImpl.MessageItem; EmailMessage message = mailItem.Message; int?messageLocaleId = (storeDriverDeliveryEventArgsImpl.ReplayItem != null) ? storeDriverDeliveryEventArgsImpl.ReplayItem.GetValueAsNullable <int>(MessageItemSchema.MessageLocaleId) : null; this.CheckArbitrationMailboxCapacity(messageItem.Session as MailboxSession, mbxTransportMailItem.OrganizationId); ApprovalEngine approvalEngineInstance = ApprovalEngine.GetApprovalEngineInstance(message, (RoutingAddress)message.From.SmtpAddress, mailRecipient.Email, messageItem, mbxTransportMailItem, ApprovalProcessingAgent.MessageItemCreationDelegate); if (approvalEngineInstance.CreateAndSubmitApprovalRequests(messageLocaleId) != ApprovalEngine.ProcessResult.InitiationMessageOk) { throw new SmtpResponseException(AckReason.ApprovalInvalidMessage); } }
public void OnCreatedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; string arg = args.MailItem.FromAddress.ToString(); string text = storeDriverDeliveryEventArgsImpl.MailRecipient.MsgId.ToString(); UnJournalAgent.Tracer.TraceDebug <string, string>(0L, "OnCreatedMessageHandler: MessageId {0}, Invoked, Sender {1}", text, arg); if (this.ShouldProcess(storeDriverDeliveryEventArgsImpl.ADRecipientCache.OrganizationId, args.MailItem, text)) { UnJournalAgent.Tracer.TraceDebug <string, string>(0L, "OnCreatedMessageHandler: MessageId {0}, Sender {1}: This message is coming from unjournal routing agent, we need to process it", text, arg); if (this.IsSender(args)) { UnJournalAgent.Tracer.TraceDebug <string, string>(0L, "OnCreatedMessageHandler: MessageId {0}, Sender {1} : This is a sender, trying to add bcc recipients if needed", text, arg); this.AddBccRecipientsToMessage(args, ((StoreDriverDeliveryEventArgsImpl)args).MessageItem); } MailboxSession mailboxSession = storeDriverDeliveryEventArgsImpl.MailboxSession; ExDateTime exDateTime; if (this.TryGetExpiryDateForMigratedMessage(storeDriverDeliveryEventArgsImpl.MailItem, out exDateTime)) { UnJournalAgent.Tracer.TraceDebug <string, string, string>(0L, "OnCreatedMessageHandler: MessageId {0}, Sender {1}: This is a migrated message , expiry date exists on this message. ExpiryDate = {2}", text, arg, exDateTime.ToString()); MessageItem messageItem = storeDriverDeliveryEventArgsImpl.MessageItem; if (RetentonPolicyTagProcessingAgent.IsRetentionPolicyEnabled(storeDriverDeliveryEventArgsImpl.ADRecipientCache, storeDriverDeliveryEventArgsImpl.MailRecipient.Email)) { messageItem.DeleteProperties(new PropertyDefinition[] { StoreObjectSchema.PolicyTag, StoreObjectSchema.ArchiveTag, ItemSchema.RetentionDate, ItemSchema.ArchiveDate }); UnJournalAgent.Tracer.TraceDebug <string, string>(0L, "OnCreatedMessageHandler: MessageId {0}, Sender {1}: Deleted Retention Policy Guids", text, arg); } messageItem[ItemSchema.EHAMigrationExpiryDate] = exDateTime; UnJournalAgent.Tracer.TraceDebug <string, string>(0L, "OnCreatedMessageHandler: MessageId {0}, Sender {1}: Stamped migration date", text, arg); } } }
public void OnPromotedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { WorkingSetAgent.tracer.TraceDebug((long)this.traceId, "WorkingSetAgent.OnPromotedMessageHandler: entering"); StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = args as StoreDriverDeliveryEventArgsImpl; if (storeDriverDeliveryEventArgsImpl == null) { WorkingSetAgent.tracer.TraceError((long)this.traceId, "WorkingSetAgent.OnPromotedMessageHandler: args is null or not a StoreDriverDeliveryEventArgsImpl; exiting"); return; } if (!this.Validate(storeDriverDeliveryEventArgsImpl)) { return; } string arg = storeDriverDeliveryEventArgsImpl.MailboxSession.MdbGuid.ToString(); WorkingSetAgent.tracer.TraceDebug <string>((long)this.traceId, "WorkingSetAgent.OnPromotedMessageHandler: mdbGuid is {0}", arg); WorkingSetAgentPerfLogging logger = new WorkingSetAgentPerfLogging(); DateTime utcNow = DateTime.UtcNow; bool workingSetSignalMailProcessed = false; try { WorkingSet.ProcessingAccepted.Increment(); using (new StopwatchPerformanceTracker("OnPromotedMessageHandler", logger)) { using (new CpuPerformanceTracker("OnPromotedMessageHandler", logger)) { using (new StorePerformanceTracker("OnPromotedMessageHandler", logger)) { this.Process(storeDriverDeliveryEventArgsImpl); workingSetSignalMailProcessed = true; } } } } catch (Exception ex) { if (ex is OutOfMemoryException || ex is StackOverflowException || ex is ThreadAbortException) { throw; } if (ex is SmtpResponseException) { workingSetSignalMailProcessed = true; throw; } WorkingSetAgent.tracer.TraceError <Exception>((long)this.traceId, "WorkingSetAgent.OnPromotedMessageHandler encountered an exception: {0}", ex); StoreDriverDeliveryDiagnostics.LogEvent(MailboxTransportEventLogConstants.Tuple_WorkingSetAgentException, ex.Message, new object[] { ex }); storeDriverDeliveryEventArgsImpl.MailRecipient.DsnRequested = DsnRequestedFlags.Never; throw new SmtpResponseException(WorkingSetAgent.UnprocessedSignalMailResponse, base.Name); } finally { this.UpdatePerfCounters(utcNow, workingSetSignalMailProcessed, logger); WorkingSetAgent.tracer.TraceDebug((long)this.traceId, "WorkingSetAgent.OnPromotedMessageHandler: exiting"); } }
public void OnPromotedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { this.wasMessageDelivered = false; this.logValues = null; StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; Stopwatch stopwatch = Stopwatch.StartNew(); InferencePropertyBag inferencePropertyBag = new InferencePropertyBag(); MdbDocument mdbDocument = null; VariantConfigurationSnapshot variantConfigurationSnapshot = null; try { InferenceClassificationAgent.tracer.TraceDebug(0L, "Called InferenceClassificationAgent.OnPromotedMessageHandler"); inferencePropertyBag.Add(InferenceSchema.MessageClassificationTime, ExDateTime.UtcNow); inferencePropertyBag.Add(InferenceSchema.ServerName, this.server.Name); if (storeDriverDeliveryEventArgsImpl.MailboxSession != null) { inferencePropertyBag.Add(DocumentSchema.MailboxId, storeDriverDeliveryEventArgsImpl.MailboxSession.MailboxGuid.ToString()); inferencePropertyBag.Add(InferenceSchema.ClutterEnabled, storeDriverDeliveryEventArgsImpl.MailboxSession.Mailbox.GetValueOrDefault <bool>(MailboxSchema.InferenceClutterEnabled, false)); inferencePropertyBag.Add(InferenceSchema.ClassificationEnabled, storeDriverDeliveryEventArgsImpl.MailboxSession.Mailbox.GetValueOrDefault <bool>(MailboxSchema.InferenceClassificationEnabled, false)); inferencePropertyBag.Add(InferenceSchema.HasBeenClutterInvited, storeDriverDeliveryEventArgsImpl.MailboxSession.Mailbox.GetValueOrDefault <bool>(MailboxSchema.InferenceHasBeenClutterInvited, false)); } inferencePropertyBag.Add(InferenceSchema.InternetMessageId, storeDriverDeliveryEventArgsImpl.ReplayItem.InternetMessageId); inferencePropertyBag.Add(InferenceSchema.Locale, InferenceClassificationAgent.GetLocale(storeDriverDeliveryEventArgsImpl)); if (storeDriverDeliveryEventArgsImpl.MailboxOwner != null && storeDriverDeliveryEventArgsImpl.MailboxOwner.OrganizationId != null && storeDriverDeliveryEventArgsImpl.MailboxOwner.OrganizationId.OrganizationalUnit != null) { inferencePropertyBag.Add(InferenceSchema.TenantName, storeDriverDeliveryEventArgsImpl.MailboxOwner.OrganizationId.OrganizationalUnit.Name); } if (!InferenceClassificationAgent.IsMailboxInteresting(storeDriverDeliveryEventArgsImpl)) { inferencePropertyBag.Add(InferenceSchema.ClassificationStatus, InferenceClassificationAgentLogger.Status.Skipped); inferencePropertyBag.Add(InferenceSchema.ClassificationStatusMessage, "MailboxNotInteresting"); } else if (!InferenceClassificationAgent.IsMessageInteresting(storeDriverDeliveryEventArgsImpl)) { inferencePropertyBag.Add(InferenceSchema.ClassificationStatus, InferenceClassificationAgentLogger.Status.Skipped); inferencePropertyBag.Add(InferenceSchema.ClassificationStatusMessage, "MessageNotInteresting"); } else { storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies = (storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies ?? new Dictionary <PropertyDefinition, object>()); Guid guid = Guid.NewGuid(); storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[MessageItemSchema.InferenceMessageIdentifier] = guid; inferencePropertyBag.Add(InferenceSchema.MessageIdentifier, guid); variantConfigurationSnapshot = FlightModule.GetFlightFeatures(storeDriverDeliveryEventArgsImpl.MailboxOwner); if (variantConfigurationSnapshot != null) { inferencePropertyBag.Add(InferenceSchema.UserFlightFeatures, variantConfigurationSnapshot); } IDeliveryClassificationStrategy deliveryClassificationStrategy = ClassificationStrategyFactory.Create(storeDriverDeliveryEventArgsImpl.MailboxSession, variantConfigurationSnapshot); inferencePropertyBag.Add(InferenceSchema.IsUiEnabled, deliveryClassificationStrategy != null); OriginalDeliveryFolderInfo originalDeliveryFolderInfo = InferenceClassificationAgent.GetOriginalDeliveryFolderInfo(storeDriverDeliveryEventArgsImpl); storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.OriginalDeliveryFolderInfo] = originalDeliveryFolderInfo.Serialize(); inferencePropertyBag.Add(InferenceSchema.OriginalDeliveryFolder, originalDeliveryFolderInfo); if (!InferenceClassificationAgent.IsDeliveryFolderInteresting(originalDeliveryFolderInfo)) { inferencePropertyBag.Add(InferenceSchema.ClassificationStatus, InferenceClassificationAgentLogger.Status.Skipped); inferencePropertyBag.Add(InferenceSchema.ClassificationStatusMessage, "DeliveryFolderNotInteresting"); } else if (!this.isPipelineEnabled) { inferencePropertyBag.Add(InferenceSchema.ClassificationStatus, InferenceClassificationAgentLogger.Status.Failed); inferencePropertyBag.Add(InferenceSchema.ClassificationStatusMessage, "PipelineDisabled"); InferenceClassificationProcessing.NumberOfItemsSkippedDueToDisabledPipeline.Increment(); } else { ConversationClutterInformation conversationClutterInformation = null; bool flag = false; InferenceClassificationResult inferenceClassificationResult = InferenceClassificationResult.None; if (this.RunClassificationPipeline(storeDriverDeliveryEventArgsImpl, inferencePropertyBag, variantConfigurationSnapshot, out mdbDocument, out flag, out conversationClutterInformation)) { if (flag) { inferenceClassificationResult |= InferenceClassificationResult.IsClutterModel; } string value = string.Empty; bool flag2 = false; bool flag3; InferenceClassificationResult inferenceClassificationResult2; string text; bool flag4; if (InferenceClassificationAgent.CheckForRuleAndConversationOverrides(storeDriverDeliveryEventArgsImpl.SharedPropertiesBetweenAgents, originalDeliveryFolderInfo, out flag3, out inferenceClassificationResult2, out text, out flag4)) { flag = flag3; value = text; } inferenceClassificationResult |= inferenceClassificationResult2; if (flag4 && conversationClutterInformation != null) { flag = conversationClutterInformation.IsNewMessageClutter(flag, out flag2); } inferencePropertyBag.Add(InferenceSchema.IsClutter, flag); if (flag) { inferenceClassificationResult |= InferenceClassificationResult.IsClutterFinal; } if (deliveryClassificationStrategy != null) { deliveryClassificationStrategy.ApplyClassification(storeDriverDeliveryEventArgsImpl, inferenceClassificationResult); if (flag2 && conversationClutterInformation != null) { conversationClutterInformation.MarkItemsAsNotClutter(); } } storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[ItemSchema.InferenceClassificationResult] = inferenceClassificationResult; inferencePropertyBag.Add(InferenceSchema.InferenceClassificationResult, inferenceClassificationResult); inferencePropertyBag.Add(InferenceSchema.ClassificationStatus, InferenceClassificationAgentLogger.Status.Succeeded); inferencePropertyBag.Add(InferenceSchema.ClassificationStatusMessage, value); } } } } catch (Exception ex) { if (ex is OutOfMemoryException || ex is StackOverflowException || ex is ThreadAbortException) { throw; } Exception innerException = ex.InnerException; if (innerException is StorageTransientException) { InferenceClassificationProcessing.NumberOfTransientExceptions.Increment(); } else if (innerException is QuotaExceededException) { InferenceClassificationProcessing.NumberOfQuotaExceededExceptions.Increment(); } this.diagnosticsSession.LogDiagnosticsInfo(DiagnosticsLoggingTag.Failures, "Received exception {0}", new object[] { ex }); inferencePropertyBag.Add(InferenceSchema.ClassificationStatus, InferenceClassificationAgentLogger.Status.Failed); inferencePropertyBag.Add(InferenceSchema.ClassificationStatusMessage, "Exception"); inferencePropertyBag.Add(InferenceSchema.ClassificationAgentException, ex); } finally { stopwatch.Stop(); InferenceClassificationAgent.tracer.TraceDebug <long>((long)this.GetHashCode(), "InferenceClassification agent took {0} ms to process the item.", stopwatch.ElapsedMilliseconds); inferencePropertyBag.Add(InferenceSchema.TimeTakenToClassify, stopwatch.ElapsedMilliseconds); if (storeDriverDeliveryEventArgsImpl.MailboxSession != null) { InferenceClassificationAgent.RecordPerformanceCounter(storeDriverDeliveryEventArgsImpl.MailboxSession.MdbGuid.ToString(), stopwatch.ElapsedMilliseconds); } InferenceClassificationTracking inferenceClassificationTracking = InferenceClassificationTracking.Create(); this.logValues = this.classificationAgentLogger.ExtractClassificationProperties(inferencePropertyBag, mdbDocument, inferenceClassificationTracking); if (variantConfigurationSnapshot != null && variantConfigurationSnapshot.Inference.InferenceStampTracking.Enabled) { storeDriverDeliveryEventArgsImpl.PropertiesForAllMessageCopies[MessageItemSchema.InferenceClassificationTrackingEx] = inferenceClassificationTracking.ToString(); } if (mdbDocument != null) { mdbDocument.Dispose(); mdbDocument = null; } } }
public void OnDeliveredMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { this.wasMessageDelivered = true; }
public void OnPromotedMessageHandler(StoreDriverEventSource source, StoreDriverDeliveryEventArgs args) { int hashCode = this.GetHashCode(); PeopleIKnowAgent.tracer.TraceDebug((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: entering"); if (args == null || !(args is StoreDriverDeliveryEventArgsImpl)) { PeopleIKnowAgent.tracer.TraceError((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: args is null or not a StoreDriverDeliveryEventArgsImpl; exiting"); return; } StoreDriverDeliveryEventArgsImpl storeDriverDeliveryEventArgsImpl = (StoreDriverDeliveryEventArgsImpl)args; MailboxSession mailboxSession = storeDriverDeliveryEventArgsImpl.MailboxSession; if (mailboxSession == null) { PeopleIKnowAgent.tracer.TraceError((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: MailboxSession is null; exiting"); return; } string text = null; MessageItem messageItem = null; if (storeDriverDeliveryEventArgsImpl.MailItem != null && storeDriverDeliveryEventArgsImpl.MailItem.Message != null && storeDriverDeliveryEventArgsImpl.MailItem.Message.Sender != null && !string.IsNullOrEmpty(storeDriverDeliveryEventArgsImpl.MailItem.Message.Sender.SmtpAddress) && storeDriverDeliveryEventArgsImpl.ReplayItem != null) { text = storeDriverDeliveryEventArgsImpl.MailItem.Message.Sender.SmtpAddress; messageItem = storeDriverDeliveryEventArgsImpl.ReplayItem; PeopleIKnowAgent.tracer.TraceDebug <string>((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: senderSmtpAddress is {0}", text); string text2 = mailboxSession.MdbGuid.ToString(); PeopleIKnowAgent.tracer.TraceDebug <string>((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: mdbGuid is {0}", text2); PeopleIKnowAgent.PeopleIKnowAgentPerfLogging peopleIKnowAgentPerfLogging = new PeopleIKnowAgent.PeopleIKnowAgentPerfLogging(); try { using (new StopwatchPerformanceTracker("OnPromotedMessageHandler", peopleIKnowAgentPerfLogging)) { using (new CpuPerformanceTracker("OnPromotedMessageHandler", peopleIKnowAgentPerfLogging)) { using (new StorePerformanceTracker("OnPromotedMessageHandler", peopleIKnowAgentPerfLogging)) { using (Folder folder = Folder.Bind(mailboxSession, mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox), new PropertyDefinition[] { FolderSchema.PeopleIKnowEmailAddressCollection, FolderSchema.PeopleIKnowEmailAddressRelevanceScoreCollection })) { if (folder == null) { PeopleIKnowAgent.tracer.TraceDebug((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: inbox folder could not be found"); } else { byte[] array = (folder.TryGetProperty(FolderSchema.PeopleIKnowEmailAddressRelevanceScoreCollection) as byte[]) ?? (folder.TryGetProperty(FolderSchema.PeopleIKnowEmailAddressCollection) as byte[]); if (array == null || array.Length == 0) { PeopleIKnowAgent.tracer.TraceDebug((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: The property PeopleIKnowAddressList did not exist on the folder"); } else { bool flag = false; PeopleIKnowEmailAddressCollection peopleIKnowEmailAddressCollection = PeopleIKnowEmailAddressCollection.CreateFromByteArray(array, PeopleIKnowAgent.tracer, hashCode); if (peopleIKnowEmailAddressCollection != null) { PeopleIKnowMetadata peopleIKnowMetadata; flag = peopleIKnowEmailAddressCollection.Contains(text, out peopleIKnowMetadata); if (flag && peopleIKnowMetadata != null) { messageItem[MessageItemSchema.SenderRelevanceScore] = peopleIKnowMetadata.RelevanceScore; } } PeopleIKnowAgent.tracer.TraceDebug <string, string>((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: The senderSmtpAddress {0} {1} contained in the list of people I know", text, flag ? "is" : "is not"); messageItem.IsFromFavoriteSender = flag; } } } } } } } catch (Exception ex) { if (ex is OutOfMemoryException || ex is StackOverflowException || ex is ThreadAbortException) { throw; } PeopleIKnowAgent.tracer.TraceError <Exception>((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler encountered an exception: {0}", ex); StoreDriverDeliveryDiagnostics.LogEvent(MailboxTransportEventLogConstants.Tuple_PeopleIKnowAgentException, ex.Message, new object[] { ex }); } finally { PeopleIKnowAgent.tracer.TraceDebug <TimeSpan>((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: StopwatchTime = {0}", peopleIKnowAgentPerfLogging.StopwatchTime); PeopleIKnowAgent.tracer.TraceDebug <TimeSpan>((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: CpuTime = {0}", peopleIKnowAgentPerfLogging.CpuTime); PeopleIKnowAgent.tracer.TraceDebug <uint>((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: StoreRPCs = {0}", peopleIKnowAgentPerfLogging.StoreRPCs); PeopleIKnow.GetInstance(text2).AverageStopWatchTime.IncrementBy(peopleIKnowAgentPerfLogging.StopwatchTime.Ticks); PeopleIKnow.GetInstance(text2).AverageStopWatchTimeBase.Increment(); PeopleIKnow.GetInstance(text2).AverageCpuTime.IncrementBy(peopleIKnowAgentPerfLogging.CpuTime.Ticks); PeopleIKnow.GetInstance(text2).AverageCpuTimeBase.Increment(); PeopleIKnow.GetInstance(text2).AverageStoreRPCs.IncrementBy((long)((ulong)peopleIKnowAgentPerfLogging.StoreRPCs)); PeopleIKnow.GetInstance(text2).AverageStoreRPCsBase.Increment(); PeopleIKnowAgent.tracer.TraceDebug((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: exiting"); } return; } PeopleIKnowAgent.tracer.TraceError <string, string>((long)hashCode, "PeopleIKnowAgent.OnPromotedMessageHandler: senderSmtpAddress {0} null, replayItem {1} null; exiting", string.IsNullOrEmpty(text) ? "is" : "is not", (messageItem == null) ? "is" : "is not"); }