public void Stop()
        {
            EventLogHelper.Write(string.Format("{0}服务被停止。", this.ServiceName));

            // 关闭所有的监听服务
            ServiceObserverManagement.Close();

            // 关闭所有的WCF服务
            ServiceHostManagement.Close();
        }
        public void Start()
        {
            // 启动所有的监听服务
            EventLogHelper.Write(string.Format("{0}正在启动自定义监听器。", this.ServiceName));

            ServiceObserverManagement.Start();

            // 启动所有的WCF服务
            EventLogHelper.Write(string.Format("{0}正在启动自定义服务。", this.ServiceName));

            ServiceHostManagement.Start();
        }
        /// <summary>启动</summary>
        public static void Start()
        {
            try
            {
                ServicesConfiguration configuration = ServicesConfigurationView.Instance.Configuration;

                foreach (ServiceObserverConfigurationElement observer in configuration.Observers)
                {
                    IServiceObserver serviceObserver = (IServiceObserver)Assembly.Load(observer.TypeName.Substring(observer.TypeName.IndexOf(",") + 1).Trim()).CreateInstance(observer.TypeName.Substring(0, observer.TypeName.IndexOf(",")).Trim(), false, BindingFlags.Default, null, new object[] { observer.Name, observer.Args }, null, null);

                    EventLogHelper.Information("正在创建监听器【" + observer.Name + "】。");

                    if (serviceObserver == null)
                    {
                        EventLogHelper.Error(string.Format("监听器【{0}】初始化类型【{1}】失败,请确认配置是否正确。", observer.Name, observer.TypeName));
                    }
                    else
                    {
                        serviceObserver.Start();

                        serviceObservers.Add(serviceObserver);
                    }
                }
            }
            catch (Exception ex)
            {
                EventLogHelper.Error(ex.ToString());

                throw ex;
            }

            // -------------------------------------------------------
            // 设置定时器
            // -------------------------------------------------------

            timer.Enabled = true;

            timer.Interval = ServicesConfigurationView.Instance.TimerInterval * 1000;

            timer.Elapsed += delegate(object sender, ElapsedEventArgs e)
            {
                ServiceObserverManagement.Run();
            };

            timer.Start();
        }