/// <summary>
 /// Creates events subscription for mailbox.
 /// </summary>
 /// <param name="mailbox">Mailbox unique identifier.</param>
 protected void StartSubscription(Mailbox mailbox)
 {
     try {
         if (ListenerManager.GetIsServiceAvaliable())
         {
             ListenerManager.RecreateListener(mailbox.Id);
         }
     } catch (Exception e) {
         _log.ErrorFormat("Events listener subscription for {0} mailbox create failed.", e, mailbox.Id);
     }
 }
 /// <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");
     }
 }