Exemplo n.º 1
0
        private ApprovalEngine.ApprovalProcessResults HandleInitiationMessage(InitiationMessage initiationMessage)
        {
            if (initiationMessage.IsMapiInitiator)
            {
                if (!this.sender.Equals(this.recipient))
                {
                    return(ApprovalEngine.ApprovalProcessResults.Invalid);
                }
            }
            else if (string.Equals("ModeratedTransport", initiationMessage.ApprovalInitiator, StringComparison.OrdinalIgnoreCase))
            {
                this.messageItem[MessageItemSchema.ApprovalApplicationId] = 1;
                HeaderList headers    = this.message.MimeDocument.RootPart.Headers;
                TextHeader textHeader = headers.FindFirst("X-MS-Exchange-Organization-Moderation-Data") as TextHeader;
                string     value;
                if (textHeader != null && textHeader.TryGetValue(out value) && !string.IsNullOrEmpty(value))
                {
                    this.messageItem[MessageItemSchema.ApprovalApplicationData] = value;
                }
                this.StampModeratedTransportExpiry();
            }
            if (initiationMessage.DecisionMakers == null)
            {
                return(ApprovalEngine.ApprovalProcessResults.Invalid);
            }
            if (InitiationProcessor.CheckDuplicateInitiationAndUpdateIdIfNecessary(this.messageItem))
            {
                return(ApprovalEngine.ApprovalProcessResults.DuplicateInitiation);
            }
            InitiationProcessor initiationProcessor = new InitiationProcessor(this.mbxTransportMailItem, initiationMessage, this.messageItem, this.requestCreate, this.recipient);

            return(initiationProcessor.PrepareApprovalRequestData());
        }
Exemplo n.º 2
0
 public static bool TryCreate(EmailMessage message, out InitiationMessage initiationMessage)
 {
     initiationMessage = null;
     if (!InitiationMessage.IsInitiationMessage(message))
     {
         return(false);
     }
     initiationMessage = new InitiationMessage(message);
     return(true);
 }
Exemplo n.º 3
0
        public ApprovalEngine.ProcessResult CreateAndSubmitApprovalRequests(int?messageLocaleId)
        {
            InitiationMessage initiationMessage;

            if (InitiationMessage.TryCreate(this.message, out initiationMessage))
            {
                InitiationProcessor initiationProcessor = new InitiationProcessor(this.mbxTransportMailItem, initiationMessage, this.messageItem, this.requestCreate, this.recipient);
                return(initiationProcessor.CreateAndSubmitApprovalRequests(messageLocaleId));
            }
            return(ApprovalEngine.ProcessResult.Invalid);
        }
Exemplo n.º 4
0
        internal InitiationProcessor(MbxTransportMailItem mbxTransportMailItem, InitiationMessage initiationMessage, MessageItem initiationMessageItem, ApprovalEngine.ApprovalRequestCreateDelegate requestCreate, RoutingAddress approvalRequestSender)
        {
            this.mbxTransportMailItem  = mbxTransportMailItem;
            this.initiationMessage     = initiationMessage;
            this.initiationMessageItem = initiationMessageItem;
            this.requestCreate         = requestCreate;
            this.approvalRequestSender = approvalRequestSender;
            CultureInfo internalDsnDefaultLanguage = this.mbxTransportMailItem.TransportSettings.InternalDsnDefaultLanguage;

            if (internalDsnDefaultLanguage == null || !ClientCultures.IsCultureSupportedForDsn(internalDsnDefaultLanguage))
            {
                this.organizationFallbackCulture = InitiationProcessor.DefaultFallBackCulture;
                return;
            }
            this.organizationFallbackCulture = internalDsnDefaultLanguage;
        }
Exemplo n.º 5
0
        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);
        }
 internal static AutoGroupApprovalRequestWriter GetInstance(InitiationMessage initiationMessage)
 {
     return(new AutoGroupApprovalRequestWriter(initiationMessage));
 }
 private AutoGroupApprovalRequestWriter(InitiationMessage initiationMessage)
 {
     this.initiationMessage = initiationMessage;
 }
Exemplo n.º 8
0
        public static ApprovalRequestWriter GetInstance(ApprovalApplicationId?applicationId, OrganizationId organizationId, InitiationMessage initiationMessage)
        {
            if (applicationId != null)
            {
                switch (applicationId.Value)
                {
                case ApprovalApplicationId.AutoGroup:
                    return(AutoGroupApprovalRequestWriter.GetInstance(initiationMessage));

                case ApprovalApplicationId.ModeratedRecipient:
                    return(ModerationApprovalRequestWriter.GetInstance(organizationId, initiationMessage));
                }
            }
            return(DefaultApprovalRequestWriter.GetInstance(initiationMessage));
        }
Exemplo n.º 9
0
 private DefaultApprovalRequestWriter(InitiationMessage initiationMessage)
 {
     this.initiationMessage = initiationMessage;
 }
Exemplo n.º 10
0
 internal static DefaultApprovalRequestWriter GetInstance(InitiationMessage initiationMessage)
 {
     return(new DefaultApprovalRequestWriter(initiationMessage));
 }
 internal static ModerationApprovalRequestWriter GetInstance(OrganizationId organizationId, InitiationMessage initiationMessage)
 {
     return(new ModerationApprovalRequestWriter(organizationId, initiationMessage));
 }
 private ModerationApprovalRequestWriter(OrganizationId organizationId, InitiationMessage initiationMessage)
 {
     this.organizationId    = organizationId;
     this.initiationMessage = initiationMessage;
 }