Beispiel #1
0
        private void NewAggregationSubscription(PimSubscriptionProxy pimSubscriptionProxy)
        {
            PimAggregationSubscription      subscription      = pimSubscriptionProxy.Subscription;
            ExchangePrincipal               exchangePrincipal = this.primaryExchangePrincipal;
            IList <AggregationSubscription> allSubscriptions  = this.GetAllSubscriptions();
            int userMaximumSubscriptionAllowed = this.GetUserMaximumSubscriptionAllowed();

            this.aggregationSubscriptionConstraintChecker.CheckNewSubscriptionConstraints(subscription, allSubscriptions, userMaximumSubscriptionAllowed);
            bool flag = false;

            try
            {
                DelayedEmailSender delayedEmailSender = null;
                if (pimSubscriptionProxy.SendAsCheckNeeded)
                {
                    delayedEmailSender = this.SetAppropriateSendAsState(subscription);
                }
                flag = true;
                using (MailboxSession mailboxSession = this.OpenMailboxSession(exchangePrincipal))
                {
                    SubscriptionManager.CreateSubscription(mailboxSession, subscription);
                    if (pimSubscriptionProxy.SendAsCheckNeeded)
                    {
                        this.PostSaveSendAsStateProcessing(subscription, delayedEmailSender, mailboxSession);
                    }
                }
            }
            catch (LocalizedException ex)
            {
                if (!flag)
                {
                    CommonLoggingHelper.SyncLogSession.LogError((TSLID)1504UL, AggregationTaskUtils.Tracer, "NewAggregationSubscription: {0}. Failed to set send as state with exception: {1}.", new object[]
                    {
                        subscription.Name,
                        ex
                    });
                }
                else
                {
                    CommonLoggingHelper.SyncLogSession.LogError((TSLID)1505UL, AggregationTaskUtils.Tracer, "NewAggregationSubscription: {0}. Failed to open mailbox session with exception: {1}.", new object[]
                    {
                        subscription.Name,
                        ex
                    });
                }
                throw new FailedCreateAggregationSubscriptionException(subscription.Name, ex);
            }
        }
        private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            backgroundWorker1.ReportProgress(0, "Waiting for subscriber host to be opened...");

            backgroundWorker1.ReportProgress(0, "Starting subscription...");
            try
            {
                subscriptionId = SubscriptionManager
                                 .CreateSubscription(ConnectionInfo, "SUBSCRIBE System.QueryExecuted", SubscriptionIndicationReceived);
                backgroundWorker1.ReportProgress(0, "Waiting for notifications");
            }
            catch (ApplicationException ex)
            {
                e.Result = ex;
            }
        }
Beispiel #3
0
        private void subscriptionWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            var arg = (QueryArguments)e.Argument;

            subscriptionWorker.ReportProgress(0, "Waiting for subscriber host to be opened...");


            subscriptionWorker.ReportProgress(0, "Starting subscription...");

            try
            {
                subscriptionId = SubscriptionManager
                                 .CreateSubscription(ConnectionInfo, arg.Query, SubscriptionIndicationReceived);
                Invoke(new Action(() => ApplicationService.RefreshSelectedConnections()));
                subscriptionWorker.ReportProgress(0, "Waiting for notifications");
            }
            catch (Exception ex)
            {
                e.Result = new QueryErrorResult {
                    ErrorMessage = ex.Message, Log = ex.ToString()
                };
            }
        }