/// <summary>
        /// 数据库配置
        /// </summary>
        /// <param name="serviceType"></param>
        /// <returns></returns>
        protected static bool ConnectionStringsChecking(LESServiceType serviceType)
        {
            bool   result           = true;
            string connectionString = ConfigurationManager.ConnectionStrings["LES"].ConnectionString;

            if (string.IsNullOrEmpty(connectionString))
            {
                Log.WriteInfo(string.Format("【{0}】服务数据库连接字浮串为空.", LESCache[serviceType].ServiceName));
                result = false;
            }

            try
            {
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    connection.Open();
                }
            }
            catch (SqlException ex)
            {
                Log.WriteInfo(string.Format("【{0}】服务数据库连接字浮串无效,数据库连接字段【{1}】.", LESCache[serviceType].ServiceName, connectionString));
                Log.WriteInfo(ex.Message);

                return(false);
            }

            return(result);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="serviceType"></param>
        public static bool ServiceConfigurationChecking(LESServiceType serviceType)
        {
            //配置文件检查,如不存在写入日志.
            if (!ServiceConfigurationFileChecking(serviceType))
            {
                return(false);
            }

            //检查 appsettings 节点配置
            bool result = true;

            if (!AppSettingsChecking(serviceType))
            {
                result = false;
            }

            //检查 数据库连接 配置是否正常
            if (!ConnectionStringsChecking(serviceType))
            {
                result = false;
            }

            //检查日志是否正常
            if (!LogConfigurationChecking(serviceType))
            {
                result = false;
            }

            Log.Flush();

            return(result);
        }
        /// <summary>
        /// 检查Infas订单配置文件是否存在
        /// </summary>
        /// <returns></returns>
        protected static bool ServiceConfigurationFileChecking(LESServiceType serviceType)
        {
            string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, LESCache[serviceType].ConfigurationFileName);

            if (!File.Exists(filePath))
            {
                try
                {
                    Log.WriteInfo(string.Format("【{0}】配置文件不存在【{1}】", LESCache[serviceType].ServiceName, LESCache[serviceType].ConfigurationFileName));
                    Log.Flush();
                }
                catch
                {
                }

                return(false);
            }
            return(true);
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected static bool BaseAppSettingChecking(LESServiceType serviceType)
        {
            string serviceId            = ConfigurationManager.AppSettings["ServiceId"];
            string operateFilePath      = ConfigurationManager.AppSettings["OperateFilePath"];
            string bakupFilePath        = ConfigurationManager.AppSettings["BakupFilePath"];
            string invalidBakupFilePath = ConfigurationManager.AppSettings["InvalidBakupFilePath"];

            bool result = true;

            string serviceName = LESCache[serviceType].ServiceName;

            #region 基本配置项检查 serviceType,operateFilePath,bakupFilePath

            //基本配置项serviceId检查
            if (string.IsNullOrEmpty(serviceId))
            {
                Logger.Instance.Info(typeof(ServiceConfiguration), string.Format("【{0}】服务 'ServiceId'字段内容为空.", serviceName));

                result = false;
            }
            else
            {
                Regex regex = new Regex(@"^\d*$");
                if (!regex.IsMatch(serviceId.Trim()))
                {
                    Logger.Instance.Info(typeof(ServiceConfiguration), string.Format("【{0}】服务 'ServiceId'字段内容不为数字.", serviceName));
                    result = false;
                }
            }

            if (serviceType == LESServiceType.PartsResolve ||
                serviceType == LESServiceType.InhousePullCombine ||
                serviceType == LESServiceType.InboundPullCombine ||
                serviceType == LESServiceType.InboundDiff ||
                serviceType == LESServiceType.InhouseDiff ||
                serviceType == LESServiceType.EPSSignalCollection ||
                serviceType == LESServiceType.EPSCounter ||
                serviceType == LESServiceType.JISGenReckoning ||
                serviceType == LESServiceType.A100PartsResolve)
            {
                //零件分解时,不检查文件及文件备份目录

                return(result);
            }

            //检查配置项OperateFilePath
            if (string.IsNullOrEmpty(operateFilePath))
            {
                Logger.Instance.Info(typeof(ServiceConfiguration), string.Format("【{0}】服务 'OperateFilePath'字段内容为空.", serviceName));

                result = false;
            }
            else if (!Directory.Exists(operateFilePath))
            {
                Logger.Instance.Info(typeof(ServiceConfiguration), string.Format("【{0}】服务 'OperateFilePath'目录无法访问.", serviceName));

                result = false;
            }

            //检查配置项BakupFilePath
            if (string.IsNullOrEmpty(bakupFilePath))
            {
                Logger.Instance.Info(typeof(ServiceConfiguration), string.Format("【{0}】服务 'BakupFilePath'字段内容为空.", serviceName));

                result = false;
            }
            else if (!Directory.Exists(bakupFilePath))
            {
                Logger.Instance.Info(typeof(ServiceConfiguration), string.Format("【{0}】服务 'BakupFilePath'目录无法访问.", serviceName));

                result = false;
            }

            //检查配置项InvalidBakupFilePath
            if (string.IsNullOrEmpty(bakupFilePath))
            {
                Logger.Instance.Info(typeof(ServiceConfiguration), string.Format("【{0}】服务 'InvalidBakupFilePath'字段内容为空.", serviceName));

                result = false;
            }
            else if (!Directory.Exists(invalidBakupFilePath))
            {
                Logger.Instance.Info(typeof(ServiceConfiguration), string.Format("【{0}】服务 'InvalidBakupFilePath'目录无法访问.", serviceName));

                result = false;
            }
            #endregion

            return(result);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="serviceType"></param>
        /// <returns></returns>
        protected static bool AppSettingsChecking(LESServiceType serviceType)
        {
            bool result = BaseAppSettingChecking(serviceType);

            return(result);
        }
 /// <summary>
 /// 日志配置检查
 /// </summary>
 /// <param name="serviceType"></param>
 /// <returns></returns>
 protected static bool LogConfigurationChecking(LESServiceType serviceType)
 {
     return(true);
 }