public override bool WriteSubjectAndBody(MessageItemApprovalRequest approvalRequest, CultureInfo cultureInfo, out CultureInfo cultureInfoWritten)
        {
            approvalRequest.MessageItem.Subject = this.initiationMessage.Subject;
            cultureInfoWritten = null;
            int?   messageItemLocale = this.initiationMessage.MessageItemLocale;
            string address           = (string)this.initiationMessage.Requestor;
            string approvalData      = this.initiationMessage.ApprovalData;

            if (string.IsNullOrEmpty(approvalData))
            {
                return(false);
            }
            Culture culture = null;

            if (messageItemLocale != null && Culture.TryGetCulture(messageItemLocale.Value, out culture))
            {
                cultureInfoWritten = culture.GetCultureInfo();
            }
            else
            {
                cultureInfoWritten = cultureInfo;
            }
            string displayNameFromSmtpAddress = ApprovalProcessor.GetDisplayNameFromSmtpAddress(address);
            string group = ApprovalProcessor.ResolveDisplayNameForDistributionGroupFromApprovalData(approvalData, ApprovalProcessor.CreateRecipientSessionFromSmtpAddress(address));
            string body  = ApprovalProcessor.GenerateMessageBodyForRequestMessage(Strings.AutoGroupRequestHeader(displayNameFromSmtpAddress, group), Strings.AutoGroupRequestBody, LocalizedString.Empty, cultureInfoWritten);

            approvalRequest.SetBody(body);
            return(true);
        }
Exemplo n.º 2
0
 public override bool WriteSubjectAndBody(MessageItemApprovalRequest approvalRequest, CultureInfo cultureInfo, out CultureInfo cultureInfoWritten)
 {
     cultureInfoWritten = null;
     approvalRequest.MessageItem.Subject = this.initiationMessage.Subject;
     approvalRequest.SetBody(this.initiationMessage.EmailMessage.Body);
     return(true);
 }
Exemplo n.º 3
0
        private static void AddVotingToApprovalRequest(MessageItemApprovalRequest approvalRequest, MimeConstant.ApprovalAllowedAction votingAction, CultureInfo cultureInfoWritten)
        {
            bool allowComments  = votingAction == MimeConstant.ApprovalAllowedAction.ApproveRejectComments || votingAction == MimeConstant.ApprovalAllowedAction.ApproveRejectCommentOnApprove;
            bool allowComments2 = votingAction == MimeConstant.ApprovalAllowedAction.ApproveRejectComments || votingAction == MimeConstant.ApprovalAllowedAction.ApproveRejectCommentOnReject;

            approvalRequest.AddVotingOption(SystemMessages.ApproveButtonText.ToString(cultureInfoWritten), allowComments);
            approvalRequest.AddVotingOption(SystemMessages.RejectButtonText.ToString(cultureInfoWritten), allowComments2);
        }
Exemplo n.º 4
0
        private void SendApprovalRequest(ApprovalRequestWriter writer, ICollection <RoutingAddress> p1DecisionMakers, CultureInfo cultureInfo, string messageId, byte[] corelationBlob)
        {
            IList <RoutingAddress> decisionMakers = this.initiationMessage.DecisionMakers;

            byte[] conversationIndex = this.initiationMessageItem.ConversationIndex;
            (string)this.initiationMessage.Requestor;
            using (MessageItemApprovalRequest messageItemApprovalRequest = this.requestCreate(this.mbxTransportMailItem))
            {
                messageItemApprovalRequest.SetSender(this.approvalRequestSender);
                foreach (RoutingAddress routingAddress in decisionMakers)
                {
                    bool flag = p1DecisionMakers == null || p1DecisionMakers.Contains(routingAddress);
                    messageItemApprovalRequest.AddRecipient(routingAddress, flag);
                    InitiationProcessor.diag.TraceDebug <RoutingAddress, bool>(0L, "Added recipient '{0}' with promote to P1={1}.", routingAddress, flag);
                }
                CultureInfo cultureInfo2;
                if (!writer.WriteSubjectAndBody(messageItemApprovalRequest, cultureInfo, out cultureInfo2))
                {
                    InitiationProcessor.diag.TraceError <ApprovalRequestWriter>(0L, "Approval request body cannot be written with writer {0}", writer);
                }
                messageItemApprovalRequest.ApprovalRequestor = this.initiationMessage.Requestor;
                messageItemApprovalRequest.MessageItem[ItemSchema.NormalizedSubject] = this.initiationMessageItem.ConversationTopic;
                messageItemApprovalRequest.MessageItem.Importance = this.initiationMessageItem.Importance;
                messageItemApprovalRequest.MessageItem.References = InitiationProcessor.ConstructApprovalRequestReferences(this.initiationMessageItem);
                ConversationIndex o = ConversationIndex.CreateFromParent(conversationIndex);
                if (!ConversationIndex.Empty.Equals(o))
                {
                    messageItemApprovalRequest.MessageItem.ConversationIndex = o.ToByteArray();
                }
                if (cultureInfo2 != null)
                {
                    InitiationProcessor.diag.TraceDebug <CultureInfo>(0L, "Approval request written in {0}", cultureInfo2);
                    messageItemApprovalRequest.MessageItem[MessageItemSchema.MessageLocaleId] = cultureInfo2.LCID;
                }
                foreach (Attachment attachment in this.initiationMessage.EmailMessage.Attachments)
                {
                    messageItemApprovalRequest.AddAttachment(attachment, this.mbxTransportMailItem.ADRecipientCache.ADSession);
                }
                if (this.initiationMessage.EmailMessage.RootPart != null && this.initiationMessage.EmailMessage.RootPart.Headers != null)
                {
                    HeaderList headers = this.initiationMessage.EmailMessage.RootPart.Headers;
                    Header[]   array   = headers.FindAll("X-MS-Exchange-Inbox-Rules-Loop");
                    if (array != null && array.Length > 0)
                    {
                        string[] array2 = new string[array.Length];
                        for (int i = 0; i < array.Length; i++)
                        {
                            array2[i] = array[i].Value;
                        }
                        messageItemApprovalRequest.MessageItem.SafeSetProperty(MessageItemSchema.XLoop, array2);
                    }
                }
                InitiationProcessor.AddVotingToApprovalRequest(messageItemApprovalRequest, this.initiationMessage.VotingActions, cultureInfo2);
                messageItemApprovalRequest.Send(messageId, corelationBlob, this.mbxTransportMailItem);
            }
        }
        public override bool WriteSubjectAndBody(MessageItemApprovalRequest approvalRequest, CultureInfo cultureInfo, out CultureInfo cultureInfoWritten)
        {
            cultureInfoWritten = cultureInfo;
            ModerationApprovalRequestWriter.diag.TraceDebug <CultureInfo>((long)this.GetHashCode(), "Generating approval request. cultureInfo={0}", cultureInfo);
            DsnHumanReadableWriter defaultDsnHumanReadableWriter = DsnHumanReadableWriter.DefaultDsnHumanReadableWriter;

            this.CacheDataFromOriginalMessage();
            if (this.originalMessageStream == null)
            {
                ModerationApprovalRequestWriter.diag.TraceError <string>((long)this.GetHashCode(), "No original message to write approval request body.  Approval data: {0}", this.initiationMessage.ApprovalData);
                return(false);
            }
            bool flag = !this.hasInlineAttachment && !this.isOpaqueMessage;

            if (this.hasInlineAttachment)
            {
                ModerationApprovalRequestWriter.diag.TraceDebug <string>((long)this.GetHashCode(), "Not writing preview for message with approval data: {0}, because it has inline attachment", this.initiationMessage.ApprovalData);
            }
            ApprovalInformation approvalRequestMessageInformation = defaultDsnHumanReadableWriter.GetApprovalRequestMessageInformation(this.initiationMessage.Subject, this.originalSenderDisplayName, this.originalToFormattedLine, this.originalCcFormattedLine, this.moderatedRecipients, flag, cultureInfo);

            approvalRequest.MessageItem.Subject = approvalRequestMessageInformation.Subject;
            this.WriteApprovalRequestBody(approvalRequest.MessageItem.Body, defaultDsnHumanReadableWriter, approvalRequestMessageInformation, flag);
            return(true);
        }
Exemplo n.º 6
0
 public abstract bool WriteSubjectAndBody(MessageItemApprovalRequest approvalRequest, CultureInfo cultureInfo, out CultureInfo cultureInfoWritten);