Exemplo n.º 1
0
        /// <summary>
        /// Occurs when a custom command is issued via the SCM
        /// </summary>
        /// <param name="command"></param>
        protected override void OnCustomCommand(int command)
        {
            try
            {
                ConfigLogger.Instance.LogDebug(String.Format("Received custom command: {0}", (EmailImportServiceCommand)command));

                switch ((EmailImportServiceCommand)command)
                {
                case EmailImportServiceCommand.ReloadMailboxProfiles:
                    try
                    {
                        // Pause the Imap Collector and Email Monitor
                        if (collector != null)
                        {
                            collector.Pause();
                        }

                        if (monitor != null)
                        {
                            monitor.Pause();
                        }

                        // Wait for all in progress conversions to complete
                        EmailConverter.WaitOnComplete();

                        // Refresh the Mailbox Profiles
                        Settings.LoadMailboxProfiles();
                    }
                    finally
                    {
                        // Resume the Imap Collector and Email Monitor
                        if (collector != null)
                        {
                            collector.Resume();
                        }

                        if (monitor != null)
                        {
                            monitor.Resume();
                        }
                    }

                    ConfigLogger.Instance.LogInfo("Mailbox Profiles Reloaded.");

                    break;
                }
            }
            catch (Exception e)
            {
                ConfigLogger.Instance.LogError(e);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// When implemented in a derived class, executes when a Stop command is sent to the service by the Service Control Manager (SCM). Specifies actions to take when a service stops running.
        /// </summary>
        protected override void OnStop()
        {
            if (collector != null)
            {
                collector.Dispose();
                collector = null;
            }

            if (monitor != null)
            {
                monitor.Dispose();
                monitor = null;
            }

            EmailConverter.WaitOnComplete();
            ImageProcessingEngine.Complete();

            ConfigLogger.Instance.LogInfo(String.Format("{0} Stopped.", GetServiceName()));
        }