/// <summary> /// 获取注册表的值 /// </summary> private static void GetValues() { SubKey = "Software\\" + "DotNet" + "\\" + BaseSystemInfo.SoftName; // 客户信息配置 BaseSystemInfo.CustomerCompanyId = GetValue("CustomerCompanyId"); BaseSystemInfo.CustomerCompanyName = GetValue("CustomerCompanyName"); BaseSystemInfo.ConfigurationFrom = BaseConfiguration.GetConfiguration(GetValue("ConfigurationFrom")); BaseSystemInfo.TimeFormat = GetValue("TimeFormat"); BaseSystemInfo.DateFormat = GetValue("DateFormat"); BaseSystemInfo.DateTimeFormat = GetValue("DateTimeFormat"); BaseSystemInfo.DateTimeLongFormat = GetValue("DateTimeLongFormat"); BaseSystemInfo.SoftName = GetValue("SoftName"); BaseSystemInfo.SoftFullName = GetValue("SoftFullName"); BaseSystemInfo.CurrentLanguage = GetValue("CurrentLanguage"); BaseSystemInfo.Version = GetValue("Version"); // 数据库连接 BaseSystemInfo.BusinessDbConnection = GetValue("BusinessDbConnection"); BaseSystemInfo.UserCenterDbConnection = GetValue("UserCenterDbConnection"); BaseSystemInfo.BusinessDbType = DbTypeUtil.GetDbType(GetValue("DbType")); BaseSystemInfo.RegisterKey = GetValue("RegisterKey"); }
/// <summary> /// 数据库配置信息 /// </summary> public static void GetDatabaseConfig() { // 数据库连接 if (ConfigurationManager.AppSettings["ServerDbType"] != null) { BaseSystemInfo.ServerDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["ServerDbType"]); } //慢查询毫秒数 if (ConfigurationManager.AppSettings["SlowQueryMilliseconds"] != null) { if (ValidateUtil.IsInt(ConfigurationManager.AppSettings["SlowQueryMilliseconds"])) { BaseSystemInfo.SlowQueryMilliseconds = int.Parse(ConfigurationManager.AppSettings["SlowQueryMilliseconds"]); } } if (ConfigurationManager.AppSettings["UserCenterDbType"] != null) { BaseSystemInfo.UserCenterDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["UserCenterDbType"]); BaseSystemInfo.LogonLogDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["UserCenterDbType"]); BaseSystemInfo.MessageDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["UserCenterDbType"]); } if (ConfigurationManager.AppSettings["BusinessDbType"] != null) { BaseSystemInfo.BusinessDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["BusinessDbType"]); } if (ConfigurationManager.AppSettings["WorkFlowDbType"] != null) { BaseSystemInfo.WorkFlowDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["WorkFlowDbType"]); } if (ConfigurationManager.AppSettings["LogonLogDbType"] != null) { BaseSystemInfo.LogonLogDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["LogonLogDbType"]); } if (ConfigurationManager.AppSettings["MessageDbType"] != null) { BaseSystemInfo.MessageDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["MessageDbType"]); } if (ConfigurationManager.AppSettings["WebAppDbType"] != null) { BaseSystemInfo.WebAppDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["WebAppDbType"]); } if (ConfigurationManager.AppSettings["BPMDbType"] != null) { BaseSystemInfo.BpmDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["BPMDbType"]); } if (ConfigurationManager.AppSettings["ERPDbType"] != null) { BaseSystemInfo.ErpDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["ERPDbType"]); } if (ConfigurationManager.AppSettings["MESDbType"] != null) { BaseSystemInfo.MesDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["MESDbType"]); } if (ConfigurationManager.AppSettings["HRMDbType"] != null) { BaseSystemInfo.HrmDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["HRMDbType"]); } if (ConfigurationManager.AppSettings["CRMDbType"] != null) { BaseSystemInfo.CrmDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["CRMDbType"]); } if (ConfigurationManager.AppSettings["OADbType"] != null) { BaseSystemInfo.OaDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["OADbType"]); } if (ConfigurationManager.AppSettings["LabelDbType"] != null) { BaseSystemInfo.LabelDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["LabelDbType"]); } if (ConfigurationManager.AppSettings["WebDbType"] != null) { BaseSystemInfo.WebDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["WebDbType"]); } if (ConfigurationManager.AppSettings["CMSDbType"] != null) { BaseSystemInfo.CmsDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["CMSDbType"]); } if (ConfigurationManager.AppSettings["DTcmsDbType"] != null) { BaseSystemInfo.DTcmsDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["DTcmsDbType"]); } if (ConfigurationManager.AppSettings["FlowPortalDbType"] != null) { BaseSystemInfo.FlowPortalDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["FlowPortalDbType"]); } if (ConfigurationManager.AppSettings["CustomerPortalDbType"] != null) { BaseSystemInfo.CustomerPortalDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["CustomerPortalDbType"]); } if (ConfigurationManager.AppSettings["SupplierPortalDbType"] != null) { BaseSystemInfo.SupplierPortalDbType = DbTypeUtil.GetDbType(ConfigurationManager.AppSettings["SupplierPortalDbType"]); } if (ConfigurationManager.AppSettings["EncryptDbConnection"] != null) { BaseSystemInfo.EncryptDbConnection = ConfigurationManager.AppSettings["EncryptDbConnection"].Equals(true.ToString(), StringComparison.OrdinalIgnoreCase); } if (ConfigurationManager.AppSettings["UserCenterDbConnection"] != null) { BaseSystemInfo.UserCenterDbConnectionString = ConfigurationManager.AppSettings["UserCenterDbConnection"]; BaseSystemInfo.LogonLogDbConnectionString = ConfigurationManager.AppSettings["UserCenterDbConnection"]; BaseSystemInfo.MessageDbConnectionString = ConfigurationManager.AppSettings["UserCenterDbConnection"]; } if (ConfigurationManager.AppSettings["BusinessDbConnection"] != null) { BaseSystemInfo.BusinessDbConnectionString = ConfigurationManager.AppSettings["BusinessDbConnection"]; } if (ConfigurationManager.AppSettings["MessageDbConnection"] != null) { BaseSystemInfo.MessageDbConnectionString = ConfigurationManager.AppSettings["MessageDbConnection"]; } if (ConfigurationManager.AppSettings["WorkFlowDbConnection"] != null) { BaseSystemInfo.WorkFlowDbConnectionString = ConfigurationManager.AppSettings["WorkFlowDbConnection"]; } if (ConfigurationManager.AppSettings["LogonLogDbConnection"] != null) { BaseSystemInfo.LogonLogDbConnectionString = ConfigurationManager.AppSettings["LogonLogDbConnection"]; } if (ConfigurationManager.AppSettings["WebAppDbConnection"] != null) { BaseSystemInfo.WebAppDbConnectionString = ConfigurationManager.AppSettings["WebAppDbConnection"]; } if (ConfigurationManager.AppSettings["BPMDbConnection"] != null) { BaseSystemInfo.BpmDbConnectionString = ConfigurationManager.AppSettings["BPMDbConnection"]; } if (ConfigurationManager.AppSettings["ERPDbConnection"] != null) { BaseSystemInfo.ErpDbConnectionString = ConfigurationManager.AppSettings["ERPDbConnection"]; } if (ConfigurationManager.AppSettings["WMSDbConnection"] != null) { BaseSystemInfo.WmsDbConnectionString = ConfigurationManager.AppSettings["WMSDbConnection"]; } if (ConfigurationManager.AppSettings["ZBWMSDbConnection"] != null) { BaseSystemInfo.ZbwmsDbConnectionString = ConfigurationManager.AppSettings["ZBWMSDbConnection"]; } if (ConfigurationManager.AppSettings["MESDbConnection"] != null) { BaseSystemInfo.MesDbConnectionString = ConfigurationManager.AppSettings["MESDbConnection"]; } if (ConfigurationManager.AppSettings["HRMDbConnection"] != null) { BaseSystemInfo.HrmDbConnectionString = ConfigurationManager.AppSettings["HRMDbConnection"]; } if (ConfigurationManager.AppSettings["CRMDbConnection"] != null) { BaseSystemInfo.CrmDbConnectionString = ConfigurationManager.AppSettings["CRMDbConnection"]; } if (ConfigurationManager.AppSettings["OADbConnection"] != null) { BaseSystemInfo.OaDbConnectionString = ConfigurationManager.AppSettings["OADbConnection"]; } if (ConfigurationManager.AppSettings["LabelDbConnection"] != null) { BaseSystemInfo.LabelDbConnectionString = ConfigurationManager.AppSettings["LabelDbConnection"]; } if (ConfigurationManager.AppSettings["WebDbConnection"] != null) { BaseSystemInfo.WebDbConnectionString = ConfigurationManager.AppSettings["WebDbConnection"]; } if (ConfigurationManager.AppSettings["CMSDbConnection"] != null) { BaseSystemInfo.CmsDbConnectionString = ConfigurationManager.AppSettings["CMSDbConnection"]; } if (ConfigurationManager.AppSettings["DTcmsDbConnection"] != null) { BaseSystemInfo.DTcmsDbConnectionString = ConfigurationManager.AppSettings["DTcmsDbConnection"]; } if (ConfigurationManager.AppSettings["FlowPortalDbConnection"] != null) { BaseSystemInfo.FlowPortalDbConnectionString = ConfigurationManager.AppSettings["FlowPortalDbConnection"]; } if (ConfigurationManager.AppSettings["DealerPortalDbConnection"] != null) { BaseSystemInfo.DealerPortalDbConnectionString = ConfigurationManager.AppSettings["DealerPortalDbConnection"]; } if (ConfigurationManager.AppSettings["CustomerPortalDbConnection"] != null) { BaseSystemInfo.CustomerPortalDbConnectionString = ConfigurationManager.AppSettings["CustomerPortalDbConnection"]; } if (ConfigurationManager.AppSettings["SupplierPortalDbConnection"] != null) { BaseSystemInfo.SupplierPortalDbConnectionString = ConfigurationManager.AppSettings["SupplierPortalDbConnection"]; } if (ConfigurationManager.AppSettings["ReportDbConnection"] != null) { BaseSystemInfo.ReportDbConnectionString = ConfigurationManager.AppSettings["ReportDbConnection"]; } if (ConfigurationManager.AppSettings["ScmDbConnection"] != null) { BaseSystemInfo.ScmDbConnectionString = ConfigurationManager.AppSettings["ScmDbConnection"]; } if (ConfigurationManager.AppSettings["ImsDbConnection"] != null) { BaseSystemInfo.ImsDbConnectionString = ConfigurationManager.AppSettings["ImsDbConnection"]; } if (ConfigurationManager.AppSettings["OmsDbConnection"] != null) { BaseSystemInfo.OmsDbConnectionString = ConfigurationManager.AppSettings["OmsDbConnection"]; } if (ConfigurationManager.AppSettings["MemberDbConnection"] != null) { BaseSystemInfo.MemberDbConnectionString = ConfigurationManager.AppSettings["MemberDbConnection"]; } if (ConfigurationManager.AppSettings["BudgetDbConnection"] != null) { BaseSystemInfo.BudgetDbConnectionString = ConfigurationManager.AppSettings["BudgetDbConnection"]; } if (ConfigurationManager.AppSettings["ItamsDbConnection"] != null) { BaseSystemInfo.ItamsDbConnectionString = ConfigurationManager.AppSettings["ItamsDbConnection"]; } if (ConfigurationManager.AppSettings["CardTicketDbConnection"] != null) { BaseSystemInfo.CardTicketDbConnectionString = ConfigurationManager.AppSettings["CardTicketDbConnection"]; } // 对加密的数据库连接进行解密操作 if (BaseSystemInfo.EncryptDbConnection) { BaseSystemInfo.UserCenterDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.UserCenterDbConnectionString); BaseSystemInfo.BusinessDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.BusinessDbConnectionString); BaseSystemInfo.MessageDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.MessageDbConnectionString); BaseSystemInfo.WorkFlowDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.WorkFlowDbConnectionString); BaseSystemInfo.LogonLogDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.LogonLogDbConnectionString); BaseSystemInfo.WebAppDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.WebAppDbConnectionString); BaseSystemInfo.BpmDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.BpmDbConnectionString); BaseSystemInfo.ErpDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.ErpDbConnectionString); BaseSystemInfo.WmsDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.WmsDbConnectionString); BaseSystemInfo.ZbwmsDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.ZbwmsDbConnectionString); BaseSystemInfo.MesDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.MesDbConnectionString); BaseSystemInfo.HrmDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.HrmDbConnectionString); BaseSystemInfo.CrmDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.CrmDbConnectionString); BaseSystemInfo.OaDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.OaDbConnectionString); BaseSystemInfo.LabelDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.LabelDbConnectionString); BaseSystemInfo.WebDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.WebDbConnectionString); BaseSystemInfo.CmsDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.CmsDbConnectionString); BaseSystemInfo.DTcmsDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.DTcmsDbConnectionString); BaseSystemInfo.FlowPortalDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.FlowPortalDbConnectionString); BaseSystemInfo.DealerPortalDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.DealerPortalDbConnectionString); BaseSystemInfo.CustomerPortalDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.CustomerPortalDbConnectionString); BaseSystemInfo.SupplierPortalDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.SupplierPortalDbConnectionString); BaseSystemInfo.ReportDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.ReportDbConnectionString); BaseSystemInfo.ScmDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.ScmDbConnectionString); BaseSystemInfo.ImsDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.ImsDbConnectionString); BaseSystemInfo.OmsDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.OmsDbConnectionString); BaseSystemInfo.MemberDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.MemberDbConnectionString); BaseSystemInfo.BudgetDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.BudgetDbConnectionString); BaseSystemInfo.ItamsDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.ItamsDbConnectionString); BaseSystemInfo.CardTicketDbConnection = SecretUtil.DesDecrypt(BaseSystemInfo.CardTicketDbConnectionString); } else { BaseSystemInfo.UserCenterDbConnection = BaseSystemInfo.UserCenterDbConnectionString; BaseSystemInfo.BusinessDbConnection = BaseSystemInfo.BusinessDbConnectionString; BaseSystemInfo.MessageDbConnection = BaseSystemInfo.MessageDbConnectionString; BaseSystemInfo.WorkFlowDbConnection = BaseSystemInfo.WorkFlowDbConnectionString; BaseSystemInfo.LogonLogDbConnection = BaseSystemInfo.LogonLogDbConnectionString; BaseSystemInfo.WebAppDbConnection = BaseSystemInfo.WebAppDbConnectionString; BaseSystemInfo.BpmDbConnection = BaseSystemInfo.BpmDbConnectionString; BaseSystemInfo.ErpDbConnection = BaseSystemInfo.ErpDbConnectionString; BaseSystemInfo.WmsDbConnection = BaseSystemInfo.WmsDbConnectionString; BaseSystemInfo.ZbwmsDbConnection = BaseSystemInfo.ZbwmsDbConnectionString; BaseSystemInfo.MesDbConnection = BaseSystemInfo.MesDbConnectionString; BaseSystemInfo.HrmDbConnection = BaseSystemInfo.HrmDbConnectionString; BaseSystemInfo.CrmDbConnection = BaseSystemInfo.CrmDbConnectionString; BaseSystemInfo.OaDbConnection = BaseSystemInfo.OaDbConnectionString; BaseSystemInfo.LabelDbConnection = BaseSystemInfo.LabelDbConnectionString; BaseSystemInfo.WebDbConnection = BaseSystemInfo.WebDbConnectionString; BaseSystemInfo.CmsDbConnection = BaseSystemInfo.CmsDbConnectionString; BaseSystemInfo.DTcmsDbConnection = BaseSystemInfo.DTcmsDbConnectionString; BaseSystemInfo.FlowPortalDbConnection = BaseSystemInfo.FlowPortalDbConnectionString; BaseSystemInfo.DealerPortalDbConnection = BaseSystemInfo.DealerPortalDbConnectionString; BaseSystemInfo.CustomerPortalDbConnection = BaseSystemInfo.CustomerPortalDbConnectionString; BaseSystemInfo.SupplierPortalDbConnection = BaseSystemInfo.SupplierPortalDbConnectionString; BaseSystemInfo.ReportDbConnection = BaseSystemInfo.ReportDbConnectionString; BaseSystemInfo.ScmDbConnection = BaseSystemInfo.ScmDbConnectionString; BaseSystemInfo.ImsDbConnection = BaseSystemInfo.ImsDbConnectionString; BaseSystemInfo.OmsDbConnection = BaseSystemInfo.OmsDbConnectionString; BaseSystemInfo.MemberDbConnection = BaseSystemInfo.MemberDbConnectionString; BaseSystemInfo.BudgetDbConnection = BaseSystemInfo.BudgetDbConnectionString; BaseSystemInfo.ItamsDbConnection = BaseSystemInfo.ItamsDbConnectionString; BaseSystemInfo.CardTicketDbConnection = BaseSystemInfo.CardTicketDbConnectionString; } BaseSystemInfo.UserCenterReadDbConnection = BaseSystemInfo.UserCenterDbConnection; BaseSystemInfo.UserCenterWriteDbConnection = BaseSystemInfo.UserCenterDbConnection; // 这里重新给静态数据库连接对象进行赋值 // DotNet.Util.DbTypeUtil.DbConnection = BaseSystemInfo.BusinessDbConnection; // DotNet.Util.DbTypeUtil.DbType = BaseSystemInfo.BusinessDbType; // 这里是处理读写分离功能,读取数据与写入数据进行分离的方式 if (ConfigurationManager.AppSettings["UserCenterReadDbConnection"] != null) { BaseSystemInfo.UserCenterReadDbConnection = ConfigurationManager.AppSettings["UserCenterReadDbConnection"]; } if (ConfigurationManager.AppSettings["UserCenterWriteDbConnection"] != null) { BaseSystemInfo.UserCenterWriteDbConnection = ConfigurationManager.AppSettings["UserCenterWriteDbConnection"]; } if (ConfigurationManager.AppSettings["DatabaseTableVersion"] != null) { if (ValidateUtil.IsInt(ConfigurationManager.AppSettings["DatabaseTableVersion"])) { BaseSystemInfo.DatabaseTableVersion = int.Parse(ConfigurationManager.AppSettings["DatabaseTableVersion"]); } } }