예제 #1
0
        /// <inheritdoc cref="ISyncSession.Start"/>.
        public void Start()
        {
            _log.DebugFormat($"Synchronization of {_senderEmailAddress} started");
            var mailbox = GetMailbox();
            var filters = mailbox.GetFilters(_userConnection);

            StartSynchronization(mailbox, filters);
            _log.DebugFormat($"Synchronization of {_senderEmailAddress} initialization ended");
        }
 /// <summary>
 /// Check exchange mailboxes subscriptions state. Starts exchange events service.
 /// Fail handler for mailboxes without subscription.
 /// </summary>
 /// <param name="userConnection"><see cref="UserConnection"/> instance.</param>
 /// <param name="parameters">Process parameters collection.</param>
 public void Execute(UserConnection userConnection, IDictionary <string, object> parameters)
 {
     _log = ClassFactory.Get <ISynchronizationLogger>(new ConstructorArgument("userId", userConnection.CurrentUser.Id));
     try {
         _log.InfoFormat("ListenerServiceFailJob started");
         if (!GetIsFeatureEnabled(userConnection, "ExchangeListenerEnabled"))
         {
             return;
         }
         UserConnection  = userConnection;
         ListenerManager = GetExchangeListenerManager();
         _log.DebugFormat("ListenerServiceFailJob: _listenerManager initiated");
         var mailboxes = GetMailboxesWithoutSubscriptions();
         ScheduleFailoverHandlers(mailboxes);
     } finally {
         int periodMin = Core.Configuration.SysSettings.GetValue(userConnection, "ListenerServiceFailJobPeriod", 1);
         if (periodMin == 0)
         {
             var schedulerWraper = ClassFactory.Get <IAppSchedulerWraper>();
             schedulerWraper.RemoveGroupJobs(ListenerServiceFailJobFactory.JobGroupName);
             _log.ErrorFormat("ListenerServiceFailJobPeriod is 0, ListenerServiceFailJob stopped");
         }
         _log.InfoFormat("ListenerServiceFailJob ended");
     }
 }
        /// <summary>
        /// Starts events subscription and email synchronization process for period.
        /// </summary>
        /// <param name="userConnection"><see cref="UserConnection"/> instance.</param>
        /// <param name="parameters">Parameters collection.</param>
        public void Execute(UserConnection userConnection, IDictionary <string, object> parameters)
        {
            _log = ClassFactory.Get <ISynchronizationLogger>(new ConstructorArgument("userId", userConnection.CurrentUser.Id));
            _log.DebugFormat("ListenerServiceFailHandler started");
            UserConnection = userConnection;
            if (!GetIsFeatureEnabled("ExchangeListenerEnabled"))
            {
                _log.DebugFormat("ExchangeListenerEnabled feature disabled, ListenerServiceFailHandler ended");
                return;
            }
            ListenerManager = GetExchangeListenerManager();
            _log.DebugFormat("ExchangeListenerManager created");
            Guid mailboxId = (Guid)parameters["MailboxId"];
            var  mailbox   = GetMailbox(mailboxId);

            StartSubscription(mailbox);
            _log.DebugFormat("Events subscription for {0} mailbox created", mailboxId);
            StartPeriodSyncJob(mailbox);
            _log.DebugFormat("Email synchronization process for {0} mailbox created", mailboxId);
            _log.DebugFormat("ListenerServiceFailHandler ended");
        }
        /// <summary>
        /// Checks existing mailboxes subscriptions state. Returns mailboxes without subscriptions.
        /// </summary>
        private List <Mailbox> GetMailboxesWithoutSubscriptions( )
        {
            _log.DebugFormat("GetMailboxesWithoutSubscriptions method started");
            var mailboxes = GetSynchronizableMailboxes();

            _log.InfoFormat("GetMailboxesWithoutSubscriptions: selected {0} mailboxes", mailboxes.Count);
            if (!NeedProceed(mailboxes))
            {
                _log.DebugFormat("GetMailboxesWithoutSubscriptions method ended");
                return(new List <Mailbox>());
            }
            if (GetIsListenerServiceAvaliable())
            {
                _log.DebugFormat("GetMailboxesWithoutSubscriptions: listener service avaliable, mailboxes subscriptions check started");
                mailboxes = FilterActiveMailboxes(mailboxes);
                mailboxes = FilterMailboxesWithLicensedOwners(mailboxes);
                _log.InfoFormat("GetMailboxesWithoutSubscriptions: filtered to {0} mailboxes", mailboxes.Count);
            }
            if (!NeedProceed(mailboxes))
            {
                _log.DebugFormat("GetMailboxesWithoutSubscriptions method ended");
                return(new List <Mailbox>());
            }
            _log.DebugFormat("GetMailboxesWithoutSubscriptions method ended");
            return(mailboxes);
        }