using SqlSugar;
namespace ServiceCenter
{
    /// 
    ///  服务中心
    /// 
    public static class ServiceHub
    {
        #region 配置中心
        /// 
        /// 数据库连接字符串集合
        /// 
        public static List? DbConnectionStrings { get; set; } = null!;
        /// 
        /// Redis连接字符串集合
        /// 
        public static List? RedisConnectionStrings { get; set; } = null!;
        /// 
        /// 设备IP集合
        /// 
        public static List DeviceIPList { get; set; } = null!;
        /// 
        /// 仓库名称
        /// 
        private static string _WarehouseName { get; set; } = null!;
        /// 
        ///  Http请求超时时间
        /// 
        private static int _HttpTimeout { get; set; }
        /// 
        ///  Http请求超时时间
        /// 
        public static int HttpTimeout
        {
            get
            {
                return _HttpTimeout;
            }
        }
        /// 
        /// 仓库名称
        /// 
        public static string WarehouseName
        {
            get
            {
                return _WarehouseName;
            }
        }
        /// 
        /// 设置仓库名称
        /// 
        /// 
        public static void SetWarehouseName(string warehouseName)
        {
            _WarehouseName = warehouseName;
        }
        /// 
        ///  设置Http请求超时时间
        /// 
        /// 
        public static void SetHttpTimeout(int timeout)
        {
            _HttpTimeout = timeout;
        }
        #endregion 配置中心
        #region 系统运行模式
        /// 
        /// 系统运行模式
        /// 
        private static List SystemModes { get; set; } = new List();
        /// 
        /// 添加一种模式
        /// 
        /// 系统模式
        public static void AddSystemMode(SystemMode mode)
        {
            if (SystemModes.Contains(mode)) return;
            SystemModes.Add(mode);
        }
        /// 
        /// 是否包含传入模式
        /// 
        /// 系统模式
        /// 
        public static bool Any(SystemMode mode)
        {
            return SystemModes.Contains(mode);
        }
        #endregion 系统运行模式
    }
    /// 
    /// 系统模式
    /// 
    public enum SystemMode
    {
        /// 
        /// 虚拟plc,启用该模式后,将在Redis中建立一个虚拟PLC用于流程测试
        /// 
        虚拟plc = 1,
    }
    /// 
    /// 数据库连接
    /// 
    public class DataBaseConnectionString
    {
        /// 
        /// 构造函数
        /// 
        /// 连接对应的Key
        /// 连接字符串
        /// 数据库类型
        /// 是否为默认数据库连接
        public DataBaseConnectionString(string key, string connectionString, DbType dbType, bool isDefault)
        {
            Key = key;
            ConnectionString = connectionString;
            DbType = dbType;
            IsDefault = isDefault;
        }
        /// 
        /// 连接对应的Key
        /// 
        public string Key { get; set; }
        /// 
        /// 连接字符串
        /// 
        public string ConnectionString { get; set; }
        /// 
        /// 数据库类型
        /// 
        public DbType DbType { get; set; }
        /// 
        /// 是否为默认数据库连接
        /// 
        public bool IsDefault { get; set; }
    }
}