Пример #1
0
        internal ApprovalEngine.ProcessResult CreateAndSubmitApprovalRequests(int?messageLocaleId)
        {
            this.initiationMessageItem.Load(InitiationProcessor.PropertiesFromInitiationForApprovalRequestCreation);
            this.CopyPropertiesToInitiationMessageFromMessageItem();
            this.initiationMessage.MessageItemLocale = messageLocaleId;
            ApprovalApplicationId?valueAsNullable = this.initiationMessageItem.GetValueAsNullable <ApprovalApplicationId>(MessageItemSchema.ApprovalApplicationId);
            string valueOrDefault = this.initiationMessageItem.GetValueOrDefault <string>(MessageItemSchema.ApprovalRequestMessageId);

            if (string.IsNullOrEmpty(valueOrDefault) || this.initiationMessageItem.VotingInfo == null)
            {
                return(ApprovalEngine.ProcessResult.Invalid);
            }
            string local;
            string domain;

            if (!FindMessageUtils.TryParseMessageId(valueOrDefault, out local, out domain))
            {
                return(ApprovalEngine.ProcessResult.Invalid);
            }
            byte[] messageCorrelationBlob = this.initiationMessageItem.VotingInfo.MessageCorrelationBlob;
            using (ApprovalRequestWriter instance = ApprovalRequestWriter.GetInstance(valueAsNullable, this.mbxTransportMailItem.OrganizationId, this.initiationMessage))
            {
                Dictionary <CultureInfo, List <RoutingAddress> > dictionary = null;
                if (instance.SupportMultipleRequestsForDifferentCultures && ApprovalProcessor.TryGetCulturesForDecisionMakers(this.initiationMessage.DecisionMakers, this.mbxTransportMailItem.ADRecipientCache.ADSession, this.organizationFallbackCulture, out dictionary))
                {
                    int num = 0;
                    using (Dictionary <CultureInfo, List <RoutingAddress> > .KeyCollection.Enumerator enumerator = dictionary.Keys.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            CultureInfo            cultureInfo = enumerator.Current;
                            IList <RoutingAddress> list        = dictionary[cultureInfo];
                            string text = ApprovalRequestWriter.FormatApprovalRequestMessageId(local, num++, domain, false);
                            this.SendApprovalRequest(instance, list, cultureInfo, text, messageCorrelationBlob);
                            InitiationProcessor.diag.TraceDebug <string, int, long>((long)this.GetHashCode(), "Approval request '{0}' submitted for {1} decision makers, init message internal id '{2}'", text, list.Count, this.mbxTransportMailItem.RecordId);
                        }
                        goto IL_19C;
                    }
                }
                string text2 = ApprovalRequestWriter.FormatApprovalRequestMessageId(local, 0, domain, false);
                this.SendApprovalRequest(instance, null, this.organizationFallbackCulture, text2, messageCorrelationBlob);
                InitiationProcessor.diag.TraceDebug <string, long>((long)this.GetHashCode(), "Approval request '{0}' submitted for all decision makers for init message with internal id '{1}'", text2, this.mbxTransportMailItem.RecordId);
                IL_19C :;
            }
            return(ApprovalEngine.ProcessResult.InitiationMessageOk);
        }
        // Token: 0x06000038 RID: 56 RVA: 0x00003BFC File Offset: 0x00001DFC
        private void SendModeratorExpiryNotification(MessageItem messageItem, ApprovalInformation.ApprovalNotificationType notificationType)
        {
            ModeratedDLApplication.diag.TraceDebug((long)this.GetHashCode(), "Entering SendModeratorExpiryNotification");
            if (!this.ShouldSendNotification(messageItem))
            {
                return;
            }
            string valueOrDefault = messageItem.GetValueOrDefault <string>(MessageItemSchema.ApprovalAllowedDecisionMakers);

            RoutingAddress[] collection;
            if (!ApprovalUtils.TryGetDecisionMakers(valueOrDefault, out collection))
            {
                return;
            }
            MailboxSession mailboxSession = (MailboxSession)messageItem.Session;

            messageItem.Load(ModeratedDLApplication.NotificationPropertiesFromInitMessage);
            ICollection <string> moderatedRecipients = this.GetModeratedRecipients(messageItem, false);
            string valueOrDefault2 = messageItem.GetValueOrDefault <string>(ItemSchema.InternetReferences, string.Empty);
            int    value           = messageItem.GetValueAsNullable <int>(StoreObjectSchema.RetentionPeriod) ?? 2;
            Dictionary <CultureInfo, List <RoutingAddress> > dictionary = null;
            IRecipientSession      tenantOrRootOrgRecipientSession      = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(false, ConsistencyMode.FullyConsistent, mailboxSession.GetADSessionSettings(), 587, "SendModeratorExpiryNotification", "f:\\15.00.1497\\sources\\dev\\Approval\\src\\Applications\\ModeratedDLApplication\\ModeratedDLApplication.cs");
            DsnHumanReadableWriter defaultDsnHumanReadableWriter        = DsnHumanReadableWriter.DefaultDsnHumanReadableWriter;
            StoreObjectId          defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Outbox);

            if (ClientCultures.IsCultureSupportedForDsn(CultureInfo.CurrentCulture))
            {
                this.defaultFallBackCulture = CultureInfo.CurrentCulture;
            }
            else
            {
                this.defaultFallBackCulture = CultureInfo.GetCultureInfo("en-US");
            }
            if (ApprovalProcessor.TryGetCulturesForDecisionMakers(new List <RoutingAddress>(collection), tenantOrRootOrgRecipientSession, this.defaultFallBackCulture, out dictionary))
            {
                foreach (CultureInfo cultureInfo in dictionary.Keys)
                {
                    IList <RoutingAddress> list = dictionary[cultureInfo];
                    using (MessageItem messageItem2 = MessageItem.Create(mailboxSession, defaultFolderId))
                    {
                        ApprovalInformation approvalInformation = null;
                        string text;
                        this.AttachOriginalMessageToNotification(messageItem, messageItem2, out text);
                        if (string.IsNullOrEmpty(text))
                        {
                            RoutingAddress routingAddress;
                            if (!this.TryGetOriginalSender(messageItem, out routingAddress))
                            {
                                break;
                            }
                            text = routingAddress.ToString();
                        }
                        approvalInformation  = defaultDsnHumanReadableWriter.GetMessageInModerationModeratorExpiredInformation(notificationType, messageItem.Subject, moderatedRecipients, text, new int?(value), cultureInfo.Name, this.defaultFallBackCulture);
                        messageItem2.Subject = approvalInformation.Subject;
                        BodyWriteConfiguration configuration = new BodyWriteConfiguration(BodyFormat.TextHtml, approvalInformation.MessageCharset.Name);
                        using (Stream stream = messageItem2.Body.OpenWriteStream(configuration))
                        {
                            defaultDsnHumanReadableWriter.WriteHtmlModerationBody(stream, approvalInformation);
                        }
                        this.StampCommonNotificationProperties(messageItem2, messageItem, list, valueOrDefault2, approvalInformation.Culture);
                        messageItem2.ClassName = "IPM.Note.Microsoft.Approval.Reply.Reject";
                        messageItem2.SendWithoutSavingMessage();
                        ModeratedDLApplication.diag.TraceDebug <int, string>((long)this.GetHashCode(), "Expiry Notification sent for {0} decision makers, original message id '{1}'", list.Count, valueOrDefault2);
                    }
                }
            }
        }