/// <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);
        }
 /// <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");
     }
 }