// Token: 0x0600003F RID: 63 RVA: 0x00004608 File Offset: 0x00002808
        private bool TryWriteNotificationWithAppendedComments(DsnHumanReadableWriter notificationWriter, MessageItem rejectItem, StreamAttachment commentAttachment, ApprovalInformation info)
        {
            bool     result             = true;
            string   htmlModerationBody = notificationWriter.GetHtmlModerationBody(info);
            Charset  textCharset        = commentAttachment.TextCharset;
            Encoding inputEncoding      = null;

            if (textCharset == null || !textCharset.TryGetEncoding(out inputEncoding))
            {
                return(false);
            }
            Charset charset = textCharset;

            if (!ModeratedDLApplication.IsEncodingMatch(info.Codepages, textCharset.CodePage))
            {
                charset = Charset.UTF8;
            }
            BodyWriteConfiguration configuration = new BodyWriteConfiguration(BodyFormat.TextHtml, charset.Name);

            using (Stream stream = rejectItem.Body.OpenWriteStream(configuration))
            {
                HtmlToHtml htmlToHtml = new HtmlToHtml();
                htmlToHtml.Header             = htmlModerationBody;
                htmlToHtml.HeaderFooterFormat = HeaderFooterFormat.Html;
                htmlToHtml.InputEncoding      = inputEncoding;
                htmlToHtml.OutputEncoding     = charset.GetEncoding();
                try
                {
                    using (Stream contentStream = commentAttachment.GetContentStream(PropertyOpenMode.ReadOnly))
                    {
                        htmlToHtml.Convert(contentStream, stream);
                        stream.Flush();
                    }
                }
                catch (ExchangeDataException arg)
                {
                    ModeratedDLApplication.diag.TraceDebug <ExchangeDataException>(0L, "Attaching comments failed with {0}", arg);
                    result = false;
                }
            }
            return(result);
        }
        // Token: 0x06000039 RID: 57 RVA: 0x00003EA4 File Offset: 0x000020A4
        private void SendRejectNotification(MessageItem messageItem)
        {
            ModeratedDLApplication.diag.TraceDebug((long)this.GetHashCode(), "Entering SendRejectNotification");
            if (!this.ShouldSendNotification(messageItem))
            {
                return;
            }
            RoutingAddress routingAddress;

            if (!this.TryGetOriginalSender(messageItem, out routingAddress))
            {
                return;
            }
            MailboxSession mailboxSession = (MailboxSession)messageItem.Session;

            messageItem.Load(ModeratedDLApplication.NotificationPropertiesFromInitMessage);
            string valueOrDefault = messageItem.GetValueOrDefault <string>(MessageItemSchema.AcceptLanguage, string.Empty);
            DsnHumanReadableWriter defaultDsnHumanReadableWriter = DsnHumanReadableWriter.DefaultDsnHumanReadableWriter;
            ICollection <string>   moderatedRecipients           = this.GetModeratedRecipients(messageItem, false);
            string        valueOrDefault2 = messageItem.GetValueOrDefault <string>(ItemSchema.InternetReferences, string.Empty);
            StoreObjectId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Outbox);

            using (MessageItem messageItem2 = MessageItem.Create(mailboxSession, defaultFolderId))
            {
                StreamAttachment streamAttachment = null;
                try
                {
                    bool flag = ModeratedDLApplication.TryGetCommentAttachment(messageItem, out streamAttachment) && streamAttachment.Size > 0L;
                    messageItem2.ClassName = "IPM.Note.Microsoft.Approval.Reply.Reject";
                    bool flag2 = true;
                    ApprovalInformation approvalInformation = null;
                    if (flag)
                    {
                        approvalInformation  = defaultDsnHumanReadableWriter.GetModerateRejectInformation(messageItem.Subject, moderatedRecipients, flag, valueOrDefault2, valueOrDefault);
                        messageItem2.Subject = approvalInformation.Subject;
                        flag2 = this.TryWriteNotificationWithAppendedComments(defaultDsnHumanReadableWriter, messageItem2, streamAttachment, approvalInformation);
                    }
                    if (!flag || !flag2)
                    {
                        approvalInformation  = defaultDsnHumanReadableWriter.GetModerateRejectInformation(messageItem.Subject, moderatedRecipients, false, valueOrDefault2, valueOrDefault);
                        messageItem2.Subject = approvalInformation.Subject;
                        BodyWriteConfiguration configuration = new BodyWriteConfiguration(BodyFormat.TextHtml, approvalInformation.MessageCharset.Name);
                        using (Stream stream = messageItem2.Body.OpenWriteStream(configuration))
                        {
                            defaultDsnHumanReadableWriter.WriteHtmlModerationBody(stream, approvalInformation);
                            stream.Flush();
                        }
                    }
                    if (flag && !flag2)
                    {
                        using (StreamAttachment streamAttachment2 = messageItem2.AttachmentCollection.Create(AttachmentType.Stream) as StreamAttachment)
                        {
                            streamAttachment2.FileName = defaultDsnHumanReadableWriter.GetModeratorsCommentFileName(approvalInformation.Culture);
                            using (Stream contentStream = streamAttachment2.GetContentStream())
                            {
                                using (Stream contentStream2 = streamAttachment.GetContentStream(PropertyOpenMode.ReadOnly))
                                {
                                    byte[] buffer = new byte[8192];
                                    ApprovalProcessor.CopyStream(contentStream2, contentStream, buffer);
                                }
                                contentStream.Flush();
                            }
                            streamAttachment2.Save();
                        }
                    }
                    this.StampCommonNotificationProperties(messageItem2, messageItem, new RoutingAddress[]
                    {
                        routingAddress
                    }, valueOrDefault2, approvalInformation.Culture);
                    messageItem2.SendWithoutSavingMessage();
                }
                finally
                {
                    if (streamAttachment != null)
                    {
                        streamAttachment.Dispose();
                    }
                }
            }
        }
        // Token: 0x06000031 RID: 49 RVA: 0x000037D4 File Offset: 0x000019D4
        internal override bool OnExpire(MessageItem messageItem, out bool sendUpdate)
        {
            sendUpdate = false;
            string valueOrDefault  = messageItem.GetValueOrDefault <string>(ItemSchema.InternetReferences, string.Empty);
            string valueOrDefault2 = messageItem.GetValueOrDefault <string>(MessageItemSchema.ApprovalRequestor);

            if ((!VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled && !Datacenter.IsPartnerHostedOnly(true)) || ModeratedDLApplication.ExpiryNotificationCounterWrapper.Instance.IncrementCountAndCheckLimit())
            {
                sendUpdate = true;
                this.SendExpiryNdrOofNotification(messageItem, ApprovalInformation.ApprovalNotificationType.ExpiryNotification);
                this.SendModeratorExpiryNotification(messageItem, ApprovalInformation.ApprovalNotificationType.ModeratorExpiryNotification);
            }
            MessageTrackingLog.TrackModeratorExpired(MessageTrackingSource.APPROVAL, messageItem.InternetMessageId, valueOrDefault, valueOrDefault2, this.GetModeratedRecipients(messageItem, true), ModeratedDLApplication.GetOrganizationIdFromMessage(messageItem), sendUpdate);
            return(true);
        }
        // Token: 0x06000036 RID: 54 RVA: 0x00003A30 File Offset: 0x00001C30
        private void TrackDecision(MessageItem messageItem, bool isApproved)
        {
            string valueOrDefault  = messageItem.GetValueOrDefault <string>(ItemSchema.InternetReferences, string.Empty);
            string valueOrDefault2 = messageItem.GetValueOrDefault <string>(MessageItemSchema.ApprovalRequestor);

            MessageTrackingLog.TrackModeratorDecision(MessageTrackingSource.APPROVAL, messageItem.InternetMessageId, valueOrDefault, valueOrDefault2, this.GetModeratedRecipients(messageItem, true), isApproved, ModeratedDLApplication.GetOrganizationIdFromMessage(messageItem));
        }
        // Token: 0x06000030 RID: 48 RVA: 0x00003784 File Offset: 0x00001984
        internal override void OnAllDecisionMakersNdred(MessageItem messageItem)
        {
            string valueOrDefault  = messageItem.GetValueOrDefault <string>(ItemSchema.InternetReferences, string.Empty);
            string valueOrDefault2 = messageItem.GetValueOrDefault <string>(MessageItemSchema.ApprovalRequestor);

            MessageTrackingLog.TrackModeratorsAllNdr(MessageTrackingSource.APPROVAL, messageItem.InternetMessageId, valueOrDefault, valueOrDefault2, this.GetModeratedRecipients(messageItem, true), ModeratedDLApplication.GetOrganizationIdFromMessage(messageItem));
            this.SendExpiryNdrOofNotification(messageItem, ApprovalInformation.ApprovalNotificationType.ModeratorsNdrNotification);
        }