using SqlSugar; using System; using System.Collections.Generic; using System.Text; using WCS.Entity; namespace WCS.Core { /// /// 配置中心 /// public static class Configs { #region 配置中心 /// /// 数据库连接字符串集合 /// public static List? DbConnectionStrings { get; set; } = null!; /// /// Redis连接字符串集合 /// public static List? RedisConnectionStrings { get; set; } = null!; #endregion 配置中心 /// /// ProtocolProxyBase在业务中具体实现类的Type /// public static Type ProtocolProxyBaseType { get; set; } #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 static Encoding StringEncoding { get; set; } /// /// 用户写入PLC记录 /// public static Action> DoCmds { get; set; } #region 异常上抛WMS /// /// 异常发布事件 /// public static event Action PublishEvent; /// /// 触发一下异常发布 /// internal static void Publish() { PublishEvent?.Invoke(); } /// /// 待上传的WMS的异常信息队列 /// public static Action UploadException { get; set; } #endregion 异常上抛WMS } /// /// 系统模式 /// 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; } } }