private void UpdateAggregationSubscription(PimSubscriptionProxy pimSubscriptionProxy) { PimAggregationSubscription subscription = pimSubscriptionProxy.Subscription; try { using (MailboxSession mailboxSession = this.OpenMailboxSession(subscription.SubscriptionIdentity)) { IList <AggregationSubscription> allSubscriptions = this.GetAllSubscriptions(); this.aggregationSubscriptionConstraintChecker.CheckUpdateSubscriptionConstraints(subscription, allSubscriptions); DelayedEmailSender delayedEmailSender = null; if (pimSubscriptionProxy.SendAsCheckNeeded) { delayedEmailSender = this.SetAppropriateSendAsState(subscription); } SubscriptionManager.SetSubscriptionAndSyncNow(mailboxSession, subscription); if (pimSubscriptionProxy.SendAsCheckNeeded) { this.PostSaveSendAsStateProcessing(subscription, delayedEmailSender, mailboxSession); } } } catch (LocalizedException ex) { CommonLoggingHelper.SyncLogSession.LogError((TSLID)1246UL, AggregationTaskUtils.Tracer, "UpdateAggregationSubscription: {0} hit exception: {1}.", new object[] { subscription.Name, ex }); throw new FailedSetAggregationSubscriptionException(subscription.Name, ex); } }
private DelayedEmailSender SetAppropriateSendAsState(PimAggregationSubscription subscription) { IEmailSender toWrap = subscription.CreateEmailSenderFor(this.adUser, this.primaryExchangePrincipal); DelayedEmailSender delayedEmailSender = new DelayedEmailSender(toWrap); SendAsAutoProvision sendAsAutoProvision = new SendAsAutoProvision(); sendAsAutoProvision.SetAppropriateSendAsState(subscription, delayedEmailSender); return(delayedEmailSender); }
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 PostSaveSendAsStateProcessing(PimAggregationSubscription subscription, DelayedEmailSender delayedEmailSender, MailboxSession mailboxSession) { SyncUtilities.ThrowIfArgumentNull("delayedEmailSender", delayedEmailSender); if (subscription.SendAsState == SendAsState.Enabled) { AggregationTaskUtils.EnableAlwaysShowFrom(this.primaryExchangePrincipal); } if (!delayedEmailSender.SendAttempted) { return; } IEmailSender emailSender = delayedEmailSender.TriggerDelayedSend(); SendAsManager sendAsManager = new SendAsManager(); sendAsManager.UpdateSubscriptionWithDiagnostics(subscription, emailSender); SubscriptionManager.SetSubscription(mailboxSession, subscription); }