Пример #1
0
        public ApprovalEngine.ApprovalProcessResults Process()
        {
            MailboxSession mailboxSession = (MailboxSession)this.messageItem.Session;
            Stopwatch      stopwatch      = new Stopwatch();

            stopwatch.Start();
            StoreObjectId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox);
            VersionedId   correlatedItem  = this.messageItem.VotingInfo.GetCorrelatedItem(defaultFolderId);

            stopwatch.Stop();
            long elapsedMilliseconds = stopwatch.ElapsedMilliseconds;

            if (correlatedItem == null)
            {
                DecisionHandler.diag.TraceDebug((long)this.GetHashCode(), "Initiation message not found");
                return(new ApprovalEngine.ApprovalProcessResults(ApprovalEngine.ProcessResult.InitiationNotFoundForDecision, elapsedMilliseconds));
            }
            string           existingDecisionMakerAddress;
            ApprovalStatus?  existingApprovalStatus;
            ExDateTime?      existingDecisionTime;
            DecisionConflict conflict;

            if (DecisionHandler.ApproveTextList.Contains(this.messageItem.VotingInfo.Response))
            {
                conflict = ApprovalProcessor.ApproveRequest(mailboxSession, correlatedItem.ObjectId, (SmtpAddress)this.sender, this.messageItem.Body, out existingDecisionMakerAddress, out existingApprovalStatus, out existingDecisionTime);
            }
            else
            {
                conflict = ApprovalProcessor.RejectRequest(mailboxSession, correlatedItem.ObjectId, (SmtpAddress)this.sender, this.messageItem.Body, out existingDecisionMakerAddress, out existingApprovalStatus, out existingDecisionTime);
            }
            return(DecisionHandler.GetApprovalProcessResults(conflict, existingDecisionMakerAddress, existingApprovalStatus, existingDecisionTime, elapsedMilliseconds));
        }
Пример #2
0
        private void BulkQueueOperation(bool isJoin, bool isApprove)
        {
            if (this.DataObject.ArbitrationMailbox == null)
            {
                base.WriteError(new RecipientTaskException(Strings.ErrorArbitrationMailboxNotSet(this.Identity.ToString())), ExchangeErrorCategory.Client, this.Identity);
            }
            ADRecipient adrecipient = (ADRecipient)base.GetDataObject <ADRecipient>(new MailboxIdParameter(this.DataObject.ArbitrationMailbox), base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(this.DataObject.ArbitrationMailbox.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(this.DataObject.ArbitrationMailbox.ToString())), ExchangeErrorCategory.Client);

            if (adrecipient.RecipientTypeDetails != RecipientTypeDetails.ArbitrationMailbox)
            {
                base.WriteError(new RecipientTaskException(Strings.ErrorInvalidArbitrationMbxType(adrecipient.Identity.ToString())), ExchangeErrorCategory.Client, this.DataObject.Identity);
            }
            if (!adrecipient.IsValid)
            {
                base.WriteError(new RecipientTaskException(Strings.ErrorInvalidArbitrationMailbox(adrecipient.Identity.ToString())), ExchangeErrorCategory.Client, this.DataObject.Identity);
            }
            ADObjectId identity;

            if (!base.TryGetExecutingUserId(out identity))
            {
                this.WriteWarning(Strings.WarningBulkOperationCannotDetermineRequester);
                return;
            }
            ADRecipient adrecipient2 = (ADRecipient)base.TenantGlobalCatalogSession.Read <ADRecipient>(identity);
            string      text;

            if (isJoin)
            {
                text = AutoGroupApplication.BuildApprovalData("Add-DistributionGroupMember", this.DataObject.Id);
            }
            else
            {
                text = AutoGroupApplication.BuildApprovalData("Remove-DistributionGroupMember", this.DataObject.Id);
            }
            QueryFilter additionalFilter = new AndFilter(new QueryFilter[]
            {
                new ComparisonFilter(ComparisonOperator.Equal, MessageItemSchema.ApprovalApplicationId, 0),
                new TextFilter(MessageItemSchema.ApprovalApplicationData, text, MatchOptions.FullString, MatchFlags.IgnoreCase)
            });

            StoreObjectId[] array = ApprovalProcessor.QueryRequests(adrecipient.PrimarySmtpAddress, SmtpAddress.Empty, SmtpAddress.Empty, SmtpAddress.Empty, new ApprovalStatus?(ApprovalStatus.Unhandled), additionalFilter, null);
            if (array == null || array.Length == 0)
            {
                return;
            }
            foreach (StoreObjectId itemId in array)
            {
                if (isApprove)
                {
                    ApprovalProcessor.ApproveRequest(adrecipient.PrimarySmtpAddress, itemId, adrecipient2.PrimarySmtpAddress, null);
                }
                else
                {
                    ApprovalProcessor.RejectRequest(adrecipient.PrimarySmtpAddress, itemId, adrecipient2.PrimarySmtpAddress, null);
                }
            }
        }