Пример #1
0
        /// <summary>
        /// Starts mailbox synchronization.
        /// </summary>
        /// <param name="mailbox"><see cref="Mailbox"/> instance.</param>
        /// <param name="filters">Synchronization session filters.</param>
        private void StartSynchronization(Mailbox mailbox, string filters)
        {
            if (!mailbox.CheckSynchronizationSettings())
            {
                _log.Warn($"mailbox {mailbox.SenderEmailAddress} synchronization settings not valid");
                return;
            }
            var    credentials   = GetCredentials(mailbox);
            var    emailProvider = GetProvider();
            Action action        = () => {
                emailProvider.StartSynchronization(credentials, filters);
            };

            try {
                ListenerUtils.TryDoListenerAction(action, credentials.SenderEmailAddress, _userConnection);
            } catch (Exception e) {
                _log.Error($"Synchronization of {_senderEmailAddress} failed", e);
                throw;
            }
        }