private static ApprovalEngine.ApprovalProcessResults GetApprovalProcessResults(DecisionConflict conflict, string existingDecisionMakerAddress, ApprovalStatus?existingApprovalStatus, ExDateTime?existingDecisionTime, long messageSearchElapsedMilliseconds) { ApprovalEngine.ApprovalProcessResults approvalProcessResults = new ApprovalEngine.ApprovalProcessResults(); approvalProcessResults.InitiationMessageSearchTimeMilliseconds = messageSearchElapsedMilliseconds; if (conflict == DecisionConflict.NoConflict || conflict == DecisionConflict.SameApproverAndDecision || conflict == DecisionConflict.DifferentApproverSameDecision) { approvalProcessResults.ProcessResults = ApprovalEngine.ProcessResult.DecisionMarked; } else if (conflict == DecisionConflict.MissingItem) { approvalProcessResults.ProcessResults = ApprovalEngine.ProcessResult.InitiationNotFoundForDecision; } else if (conflict == DecisionConflict.Unauthorized) { approvalProcessResults.ProcessResults = ApprovalEngine.ProcessResult.UnauthorizedMessage; } else { approvalProcessResults.ProcessResults = ApprovalEngine.ProcessResult.DecisionAlreadyMade; approvalProcessResults.ExistingDecisionMakerAddress = existingDecisionMakerAddress; approvalProcessResults.ExistingDecisionTime = existingDecisionTime; approvalProcessResults.ExistingApprovalStatus = existingApprovalStatus; } return(approvalProcessResults); }
private void HandleResults(ApprovalEngine.ApprovalProcessResults resultInfo, MessageItem messageItem, MbxTransportMailItem rmi, MailRecipient recipient) { if (resultInfo.ProcessResults == ApprovalEngine.ProcessResult.InitiationMessageOk) { messageItem.VotingInfo.MessageCorrelationBlob = resultInfo.ApprovalTrackingBlob; messageItem[MessageItemSchema.ApprovalRequestMessageId] = resultInfo.ApprovalRequestMessageId; messageItem[MessageItemSchema.ApprovalDecisionMakersNdred] = NdrOofHandler.FormatNdrOofProperty(resultInfo.TotalDecisionMakers, 0, 0); messageItem[MessageItemSchema.ApprovalStatus] = ApprovalStatus.Unhandled; this.perfCounter.InitiationMessages.Increment(); return; } if (resultInfo.ProcessResults == ApprovalEngine.ProcessResult.UnauthorizedMessage) { throw new SmtpResponseException(AckReason.ApprovalUnAuthorizedMessage); } if (resultInfo.ProcessResults == ApprovalEngine.ProcessResult.InitiationMessageDuplicate) { recipient.DsnRequested = DsnRequestedFlags.Never; throw new SmtpResponseException(AckReason.ApprovalDuplicateInitiation, base.Name); } if (resultInfo.ProcessResults == ApprovalEngine.ProcessResult.DecisionMarked) { this.perfCounter.DecisionUsed.Increment(); this.perfCounter.DecisionMessages.Increment(); this.perfCounter.DecisionInitiationMessageSearchTimeMilliseconds.IncrementBy(resultInfo.InitiationMessageSearchTimeMilliseconds); recipient.DsnRequested = DsnRequestedFlags.Never; throw new SmtpResponseException(AckReason.ApprovalDecisionSuccsess, base.Name); } if (resultInfo.ProcessResults == ApprovalEngine.ProcessResult.InitiationNotFoundForDecision || resultInfo.ProcessResults == ApprovalEngine.ProcessResult.DecisionAlreadyMade) { byte[] conversationIndex = messageItem.ConversationIndex; string threadIndex = Convert.ToBase64String(ConversationIndex.CreateFromParent(conversationIndex).ToByteArray()); this.SendNotifications(recipient.Email, (RoutingAddress)rmi.Message.Sender.SmtpAddress, rmi, threadIndex, messageItem.ConversationTopic, resultInfo.ExistingDecisionMakerAddress, resultInfo.ExistingApprovalStatus, resultInfo.ExistingDecisionTime); this.perfCounter.DecisionMessages.Increment(); this.perfCounter.DecisionInitiationMessageSearchTimeMilliseconds.IncrementBy(resultInfo.InitiationMessageSearchTimeMilliseconds); recipient.DsnRequested = DsnRequestedFlags.Never; throw new SmtpResponseException(AckReason.ApprovalDecisionSuccsess, base.Name); } if (resultInfo.ProcessResults == ApprovalEngine.ProcessResult.NdrOrOofUpdated || resultInfo.ProcessResults == ApprovalEngine.ProcessResult.NdrOrOofUpdateSkipped || resultInfo.ProcessResults == ApprovalEngine.ProcessResult.InitiationNotFoundForNdrOrOof || resultInfo.ProcessResults == ApprovalEngine.ProcessResult.NdrOrOofInvalid) { this.perfCounter.TotalNdrOofHandled.Increment(); if (resultInfo.ProcessResults != ApprovalEngine.ProcessResult.NdrOrOofInvalid) { this.perfCounter.TotalSearchesForInitiationBasedOnNdrAndOof.Increment(); this.perfCounter.NdrOofInitiationMessageSearchTimeMilliseconds.IncrementBy(resultInfo.InitiationMessageSearchTimeMilliseconds); } if (resultInfo.ProcessResults == ApprovalEngine.ProcessResult.NdrOrOofUpdated) { this.perfCounter.TotalNdrOofUpdated.Increment(); } recipient.DsnRequested = DsnRequestedFlags.Never; throw new SmtpResponseException(AckReason.ApprovalNdrOofUpdateSuccess, base.Name); } throw new SmtpResponseException(AckReason.ApprovalInvalidMessage); }
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 ApprovalEngine.ApprovalProcessResults ProcessMessage() { if (!MultilevelAuth.IsInternalMail(this.message)) { return(ApprovalEngine.ApprovalProcessResults.Invalid); } DecisionHandler decisionHandler = null; ApprovalEngine.ApprovalProcessResults result; try { InitiationMessage initiationMessage; NdrOofHandler ndrOofHandler; if (InitiationMessage.TryCreate(this.message, out initiationMessage)) { result = this.HandleInitiationMessage(initiationMessage); } else if (DecisionHandler.TryCreate(this.messageItem, this.sender.ToString(), this.mbxTransportMailItem.OrganizationId, out decisionHandler)) { ApprovalEngine.ApprovalProcessResults approvalProcessResults = decisionHandler.Process(); result = approvalProcessResults; } else if (NdrOofHandler.TryCreate(this.messageItem, out ndrOofHandler)) { result = ndrOofHandler.Process(); } else { result = ApprovalEngine.ApprovalProcessResults.Invalid; } } finally { if (decisionHandler != null) { decisionHandler.Dispose(); } } return(result); }