Пример #1
0
        /// <summary>
        /// 获得新的数据库连接
        /// </summary>
        /// <param name="connectionString">数据库连接字符串</param>
        /// <returns>数据库连接</returns>
        public virtual IDbConnection Open(string connectionString)
        {
            // 这里数据库连接打开的时候,就判断注册属性的有效性
            if (!SecretHelper.CheckRegister())
            {
                // 若没有进行注册,让程序无法打开数据库比较好。
                connectionString = string.Empty;
                // 抛出异常信息显示给客户
                throw new Exception(SystemInfo.RegisterException);
            }

            this.ConnectionString = connectionString;
            this.dbConnection     = GetInstance().CreateConnection();
            this.dbConnection.ConnectionString = this.ConnectionString;
            this.dbConnection.Open();
            this.AutoOpenClose = false;

            return(this.dbConnection);
        }
Пример #2
0
        public virtual IDbConnection Open(string connectionString)
        {
            int tickCount = Environment.TickCount;

            Trace.WriteLine(DateTime.Now.ToString(SystemInfo.TimeFormat) + " :Begin: " + MethodBase.GetCurrentMethod().ReflectedType.Name + "." + MethodBase.GetCurrentMethod().Name);
            if (!SecretHelper.CheckRegister())
            {
                connectionString = string.Empty;
                throw new Exception(SystemInfo.RegisterException);
            }
            if ((this.dbConnection_0 == null) || (this.dbConnection_0.State == ConnectionState.Closed))
            {
                this.ConnectionString = connectionString;
                this.dbConnection_0   = this.GetInstance().CreateConnection();
                this.dbConnection_0.ConnectionString = this.ConnectionString;
                this.dbConnection_0.Open();
                int num2 = Environment.TickCount;
                Trace.WriteLine(DateTime.Now.ToString(SystemInfo.TimeFormat) + " Ticks: " + TimeSpan.FromMilliseconds((double)(num2 - tickCount)).ToString() + " :End: " + MethodBase.GetCurrentMethod().ReflectedType.Name + "." + MethodBase.GetCurrentMethod().Name);
            }
            return(this.dbConnection_0);
        }
Пример #3
0
        /// <summary>
        /// 从配置信息获取配置信息
        /// </summary>
        /// <param name="configuration">配置</param>
        public static void GetConfig()
        {
            // 客户信息配置
            SystemInfo.CustomerCompanyName = ConfigurationManager.AppSettings["CustomerCompanyName"];
            SystemInfo.ConfigurationFrom   = BaseConfiguration.GetConfiguration(ConfigurationManager.AppSettings["ConfigurationFrom"]);
            SystemInfo.SoftName            = ConfigurationManager.AppSettings["SoftName"];
            SystemInfo.SoftFullName        = ConfigurationManager.AppSettings["SoftFullName"];
            SystemInfo.Version             = ConfigurationManager.AppSettings["Version"];
            SystemInfo.RootMenuCode        = ConfigurationManager.AppSettings["RootMenuCode"];
            SystemInfo.ServiceUserName     = ConfigurationManager.AppSettings["ServiceUserName"];
            SystemInfo.ServicePassword     = ConfigurationManager.AppSettings["ServicePassword"];
            SystemInfo.ServicePassword     = SecretHelper.AESDecrypt(SystemInfo.ServicePassword);
            SystemInfo.RootMenuCode        = ConfigurationManager.AppSettings["RootMenuCode"];

            //SystemInfo.CurrentLanguage = ConfigurationManager.AppSettings["CurrentLanguage"];
            // SystemInfo.Service = ConfigurationManager.AppSettings["Service"];
            // SystemInfo.EnableRecordLog = (ConfigurationManager.AppSettings["EnableRecordLog"].ToUpper(), true.ToString().ToUpper(), true);

            if (ConfigurationManager.AppSettings["EnableEncryptServerPassword"] != null)
            {
                SystemInfo.EnableEncryptServerPassword = ConfigurationManager.AppSettings["EnableEncryptServerPassword"].ToUpper().Equals(true.ToString().ToUpper());
            }
            if (ConfigurationManager.AppSettings["EncryptClientPassword"] != null)
            {
                SystemInfo.EncryptClientPassword = ConfigurationManager.AppSettings["EncryptClientPassword"].ToUpper().Equals(true.ToString().ToUpper());
            }

            if (ConfigurationManager.AppSettings["EnableCheckIPAddress"] != null)
            {
                SystemInfo.EnableCheckIPAddress = ConfigurationManager.AppSettings["EnableCheckIPAddress"].ToUpper().Equals(true.ToString().ToUpper());
            }

            // SystemInfo.AutoLogOn = (ConfigurationManager.AppSettings["AutoLogOn"].ToUpper(), true.ToString().ToUpper(), true);
            // SystemInfo.LogOnAssembly = ConfigurationManager.AppSettings["LogOnAssembly"];
            // SystemInfo.LogOnForm = ConfigurationManager.AppSettings["LogOnAssembly"];
            // SystemInfo.MainForm = ConfigurationManager.AppSettings["MainForm"];

            if (ConfigurationManager.AppSettings["CheckOnLine"] != null)
            {
                SystemInfo.CheckOnLine = ConfigurationManager.AppSettings["CheckOnLine"].ToUpper().Equals(true.ToString().ToUpper());
            }
            // SystemInfo.LoadAllUser = (ConfigurationManager.AppSettings["LoadAllUser"].ToUpper(), true.ToString().ToUpper(), true);
            // SystemInfo.AllowUserToRegister = (ConfigurationManager.AppSettings["AllowUserToRegister"].ToUpper(), true.ToString().ToUpper(), true);
            // SystemInfo.EnableUserAuthorizationScope = (ConfigurationManager.AppSettings["EnableUserAuthorizationScope"].ToUpper(), true.ToString().ToUpper(), true);
            // SystemInfo.EnableTableFieldPermission = (ConfigurationManager.AppSettings["EnableTableFieldPermission"].ToUpper(), true.ToString().ToUpper(), true);
            // SystemInfo.EnableTableConstraintPermission = (ConfigurationManager.AppSettings["EnableTableConstraintPermission"].ToUpper(), true.ToString().ToUpper(), true);

            if (ConfigurationManager.AppSettings["EnableUserAuthorization"] != null)
            {
                SystemInfo.EnableUserAuthorization = ConfigurationManager.AppSettings["EnableUserAuthorization"].ToUpper().Equals(true.ToString().ToUpper());
            }

            if (ConfigurationManager.AppSettings["EnableUserAuthorizationScope"] != null)
            {
                SystemInfo.EnableUserAuthorizationScope = ConfigurationManager.AppSettings["EnableUserAuthorizationScope"].ToUpper().Equals(true.ToString().ToUpper());
            }

            if (ConfigurationManager.AppSettings["EnableModulePermission"] != null)
            {
                SystemInfo.EnableModulePermission = ConfigurationManager.AppSettings["EnableModulePermission"].ToUpper().Equals(true.ToString().ToUpper());
            }

            if (ConfigurationManager.AppSettings["EnablePermissionItem"] != null)
            {
                SystemInfo.EnablePermissionItem = ConfigurationManager.AppSettings["EnablePermissionItem"].ToUpper().Equals(true.ToString().ToUpper());
            }

            if (ConfigurationManager.AppSettings["EnableOrganizePermission"] != null)
            {
                SystemInfo.EnableOrganizePermission = ConfigurationManager.AppSettings["EnableOrganizePermission"].ToUpper().Equals(true.ToString().ToUpper());
            }

            if (ConfigurationManager.AppSettings["EnableTableFieldPermission"] != null)
            {
                SystemInfo.EnableTableFieldPermission = ConfigurationManager.AppSettings["EnableTableFieldPermission"].ToUpper().Equals(true.ToString().ToUpper());
            }

            if (ConfigurationManager.AppSettings["EnableTableConstraintPermission"] != null)
            {
                SystemInfo.EnableTableConstraintPermission = ConfigurationManager.AppSettings["EnableTableConstraintPermission"].ToUpper().Equals(true.ToString().ToUpper());
            }

            // 数据库连接
            if (ConfigurationManager.AppSettings["RDIFrameworkDbType"] != null)
            {
                SystemInfo.RDIFrameworkDbType = BaseConfiguration.GetDbType(ConfigurationManager.AppSettings["RDIFrameworkDbType"]);
            }
            if (ConfigurationManager.AppSettings["BusinessDbType"] != null)
            {
                SystemInfo.BusinessDbType = BaseConfiguration.GetDbType(ConfigurationManager.AppSettings["BusinessDbType"]);
            }
            if (ConfigurationManager.AppSettings["WorkFlowDbType"] != null)
            {
                SystemInfo.WorkFlowDbType = BaseConfiguration.GetDbType(ConfigurationManager.AppSettings["WorkFlowDbType"]);
            }
            if (ConfigurationManager.AppSettings["EncryptDbConnection"] != null)
            {
                SystemInfo.EncryptDbConnection = ConfigurationManager.AppSettings["EncryptDbConnection"].ToUpper().Equals(true.ToString().ToUpper());
            }

            SystemInfo.BusinessDbConnectionString    = ConfigurationManager.AppSettings["BusinessDbConnection"];
            SystemInfo.RDIFrameworkDbConectionString = ConfigurationManager.AppSettings["RDIFrameworkDbConection"];
            SystemInfo.WorkFlowDbConnectionString    = ConfigurationManager.AppSettings["WorkFlowDbConnection"];
            // 对加密的数据库连接进行解密操作
            if (SystemInfo.EncryptDbConnection)
            {
                SystemInfo.BusinessDbConnection    = SecretHelper.AESDecrypt(SystemInfo.BusinessDbConnectionString);
                SystemInfo.RDIFrameworkDbConection = SecretHelper.AESDecrypt(SystemInfo.RDIFrameworkDbConectionString);
                SystemInfo.WorkFlowDbConnection    = SecretHelper.AESDecrypt(SystemInfo.WorkFlowDbConnectionString);
            }
            else
            {
                SystemInfo.BusinessDbConnection    = ConfigurationManager.AppSettings["BusinessDbConnection"];
                SystemInfo.RDIFrameworkDbConection = ConfigurationManager.AppSettings["RDIFrameworkDbConection"];
                SystemInfo.WorkFlowDbConnection    = ConfigurationManager.AppSettings["WorkFlowDbConnection"];
            }

            SystemInfo.RegisterKey = ConfigurationManager.AppSettings["RegisterKey"];
        }
Пример #4
0
        public static void GetConfig()
        {
            bool flag;

            SystemInfo.CustomerCompanyName = ConfigurationManager.AppSettings["CustomerCompanyName"];
            SystemInfo.ConfigurationFrom   = BaseConfiguration.GetConfiguration(ConfigurationManager.AppSettings["ConfigurationFrom"]);
            SystemInfo.SoftName            = ConfigurationManager.AppSettings["SoftName"];
            SystemInfo.SoftFullName        = ConfigurationManager.AppSettings["SoftFullName"];
            SystemInfo.RootMenuCode        = ConfigurationManager.AppSettings["RootMenuCode"];
            SystemInfo.ServiceUserName     = ConfigurationManager.AppSettings["ServiceUserName"];
            SystemInfo.ServicePassword     = ConfigurationManager.AppSettings["ServicePassword"];
            if (ConfigurationManager.AppSettings["EnableEncryptServerPassword"] != null)
            {
                flag = true;
                SystemInfo.EnableEncryptServerPassword = ConfigurationManager.AppSettings["EnableEncryptServerPassword"].ToUpper().Equals(flag.ToString().ToUpper());
            }
            if (ConfigurationManager.AppSettings["EncryptClientPassword"] != null)
            {
                flag = true;
                SystemInfo.EncryptClientPassword = ConfigurationManager.AppSettings["EncryptClientPassword"].ToUpper().Equals(flag.ToString().ToUpper());
            }
            if (ConfigurationManager.AppSettings["EnableCheckIPAddress"] != null)
            {
                flag = true;
                SystemInfo.EnableCheckIPAddress = ConfigurationManager.AppSettings["EnableCheckIPAddress"].ToUpper().Equals(flag.ToString().ToUpper());
            }
            if (ConfigurationManager.AppSettings["CheckOnLine"] != null)
            {
                flag = true;
                SystemInfo.CheckOnLine = ConfigurationManager.AppSettings["CheckOnLine"].ToUpper().Equals(flag.ToString().ToUpper());
            }
            if (ConfigurationManager.AppSettings["RDIFrameworkDbType"] != null)
            {
                SystemInfo.RDIFrameworkDbType = BaseConfiguration.GetDbType(ConfigurationManager.AppSettings["RDIFrameworkDbType"]);
            }
            if (ConfigurationManager.AppSettings["BusinessDbType"] != null)
            {
                SystemInfo.BusinessDbType = BaseConfiguration.GetDbType(ConfigurationManager.AppSettings["BusinessDbType"]);
            }
            if (ConfigurationManager.AppSettings["WorkFlowDbType"] != null)
            {
                SystemInfo.WorkFlowDbType = BaseConfiguration.GetDbType(ConfigurationManager.AppSettings["WorkFlowDbType"]);
            }
            if (ConfigurationManager.AppSettings["EncryptDbConnection"] != null)
            {
                flag = true;
                SystemInfo.EncryptDbConnection = ConfigurationManager.AppSettings["EncryptDbConnection"].ToUpper().Equals(flag.ToString().ToUpper());
            }
            SystemInfo.BusinessDbConnectionString    = ConfigurationManager.AppSettings["BusinessDbConnection"];
            SystemInfo.RDIFrameworkDbConectionString = ConfigurationManager.AppSettings["RDIFrameworkDbConection"];
            SystemInfo.WorkFlowDbConnectionString    = ConfigurationManager.AppSettings["WorkFlowDbConnection"];
            if (SystemInfo.EncryptDbConnection)
            {
                SystemInfo.BusinessDbConnection    = SecretHelper.smethod_1(SystemInfo.BusinessDbConnectionString);
                SystemInfo.RDIFrameworkDbConection = SecretHelper.smethod_1(SystemInfo.RDIFrameworkDbConectionString);
                SystemInfo.WorkFlowDbConnection    = SecretHelper.smethod_1(SystemInfo.WorkFlowDbConnectionString);
            }
            else
            {
                SystemInfo.BusinessDbConnection    = ConfigurationManager.AppSettings["BusinessDbConnection"];
                SystemInfo.RDIFrameworkDbConection = ConfigurationManager.AppSettings["RDIFrameworkDbConection"];
                SystemInfo.WorkFlowDbConnection    = ConfigurationManager.AppSettings["WorkFlowDbConnection"];
            }
            SystemInfo.RegisterKey = ConfigurationManager.AppSettings["RegisterKey"];
        }
        /// <summary>
        /// 保存到指定的文件
        /// </summary>
        /// <param name="fileName">配置文件</param>
        public static void SaveConfig(string fileName)
        {
            var xmlDocument = new XmlDocument();

            xmlDocument.Load(fileName);

            SetValue(xmlDocument, "CurrentUserName", SystemInfo.CurrentUserName);
            SetValue(xmlDocument, "CurrentPassword", SystemInfo.CurrentPassword);
            SetValue(xmlDocument, "MultiLanguage", SystemInfo.MultiLanguage.ToString());
            SetValue(xmlDocument, "CurrentLanguage", SystemInfo.CurrentLanguage);
            SetValue(xmlDocument, "RememberPassword", SystemInfo.RememberPassword.ToString());
            SetValue(xmlDocument, "EncryptClientPassword", SystemInfo.EncryptClientPassword.ToString());
            SetValue(xmlDocument, "EnableCheckIPAddress", SystemInfo.EnableCheckIPAddress.ToString());
            SetValue(xmlDocument, "CurrentStyle", SystemInfo.CurrentStyle.ToString());
            SetValue(xmlDocument, "CurrentThemeColor", SystemInfo.CurrentThemeColor.ToString());

            SetValue(xmlDocument, "EnableCheckPasswordStrength", SystemInfo.EnableCheckPasswordStrength.ToString());
            SetValue(xmlDocument, "EnableEncryptServerPassword", SystemInfo.EnableEncryptServerPassword.ToString());
            SetValue(xmlDocument, "PasswordMiniLength", SystemInfo.PasswordMiniLength.ToString());
            SetValue(xmlDocument, "NumericCharacters", SystemInfo.NumericCharacters.ToString());
            SetValue(xmlDocument, "PasswordChangeCycle", SystemInfo.PasswordChangeCycle.ToString());
            SetValue(xmlDocument, "CheckOnLine", SystemInfo.CheckOnLine.ToString());
            SetValue(xmlDocument, "OnLineTime0ut", SystemInfo.OnLineTime0ut.ToString());
            SetValue(xmlDocument, "AccountMinimumLength", SystemInfo.AccountMinimumLength.ToString());
            SetValue(xmlDocument, "PasswordErrorLockLimit", SystemInfo.PasswordErrorLockLimit.ToString());
            SetValue(xmlDocument, "PasswordErrorLockCycle", SystemInfo.PasswordErrorLockCycle.ToString());
            SetValue(xmlDocument, "DefaultPassword", SecretHelper.AESEncrypt(SystemInfo.DefaultPassword.ToString()));

            SetValue(xmlDocument, "UseMessage", SystemInfo.UseMessage.ToString());
            SetValue(xmlDocument, "AutoLogOn", SystemInfo.AutoLogOn.ToString());
            SetValue(xmlDocument, "AllowUserToRegister", SystemInfo.AllowUserToRegister.ToString());
            SetValue(xmlDocument, "EnableRecordLog", SystemInfo.EnableRecordLog.ToString());

            // 客户信息配置
            SetValue(xmlDocument, "CustomerCompanyName", SystemInfo.CustomerCompanyName);
            SetValue(xmlDocument, "ConfigurationFrom", SystemInfo.ConfigurationFrom.ToString());
            SetValue(xmlDocument, "SoftName", SystemInfo.SoftName);
            SetValue(xmlDocument, "SoftFullName", SystemInfo.SoftFullName);

            SetValue(xmlDocument, "RootMenuCode", SystemInfo.RootMenuCode);
            SetValue(xmlDocument, "Version", SystemInfo.Version);

            SetValue(xmlDocument, "EnableUserAuthorization", SystemInfo.EnableUserAuthorization.ToString());
            SetValue(xmlDocument, "EnableModulePermission", SystemInfo.EnableModulePermission.ToString());
            SetValue(xmlDocument, "EnableTableFieldPermission", SystemInfo.EnableTableFieldPermission.ToString());
            SetValue(xmlDocument, "EnableTableConstraintPermission", SystemInfo.EnableTableConstraintPermission.ToString());
            SetValue(xmlDocument, "LoadAllUser", SystemInfo.LoadAllUser.ToString());

            SetValue(xmlDocument, "Service", SystemInfo.Service);
            SetValue(xmlDocument, "ServiceUserName", SystemInfo.ServiceUserName);
            SetValue(xmlDocument, "ServicePassword", SecretHelper.AESEncrypt(SystemInfo.ServicePassword));



            SetValue(xmlDocument, "LogOnAssembly", SystemInfo.LogOnAssembly);
            SetValue(xmlDocument, "LogOnForm", SystemInfo.LogOnForm);
            SetValue(xmlDocument, "MainForm", SystemInfo.MainForm);

            SetValue(xmlDocument, "OnLineLimit", SystemInfo.OnLineLimit.ToString());
            //SetValue(xmlDocument, "DbType", SystemInfo.BusinessDbType.ToString());

            // 保存数据库配置
            SetValue(xmlDocument, "BusinessDbType", SystemInfo.BusinessDbType.ToString());
            SetValue(xmlDocument, "RDIFrameworkDbType", SystemInfo.RDIFrameworkDbType.ToString());
            SetValue(xmlDocument, "WorkFlowDbType", SystemInfo.WorkFlowDbType.ToString());

            SetValue(xmlDocument, "EncryptDbConnection", SystemInfo.EncryptDbConnection.ToString());
            SetValue(xmlDocument, "RDIFrameworkDbConection", SystemInfo.RDIFrameworkDbConectionString);
            SetValue(xmlDocument, "BusinessDbConnection", SystemInfo.BusinessDbConnectionString);
            SetValue(xmlDocument, "WorkFlowDbConnection", SystemInfo.WorkFlowDbConnectionString);

            SetValue(xmlDocument, "RegisterKey", SystemInfo.RegisterKey);
            SetValue(xmlDocument, "NodeTimeout", SystemInfo.NodeTimeout);

            //错误报告反馈配置
            SetValue(xmlDocument, "ErrorReportFrom", SystemInfo.ErrorReportFrom);
            SetValue(xmlDocument, "ErrorReportMailServer", SystemInfo.ErrorReportMailServer);
            SetValue(xmlDocument, "ErrorReportMailUserName", SystemInfo.ErrorReportMailUserName);
            SetValue(xmlDocument, "ErrorReportMailPassword", SecretHelper.AESEncrypt(SystemInfo.ErrorReportMailPassword));
            SetValue(xmlDocument, "RDIFrameworkBlog", SystemInfo.RDIFrameworkBlog);
            SetValue(xmlDocument, "RDIFrameworkWeibo", SystemInfo.RDIFrameworkWeibo);
            xmlDocument.Save(fileName);
        }
        /// <summary>
        /// 从指定的文件读取配置项
        /// </summary>
        /// <param name="fileName">配置文件</param>
        public static void GetConfig(string fileName)
        {
            var xmlDocument = new XmlDocument();

            xmlDocument.Load(fileName);

            SystemInfo.ConfigFile = Exists("ConfigFile") ? GetValue(xmlDocument, "ConfigFile") : SystemInfo.ConfigFile;
            SystemInfo.Host       = Exists("Host") ? GetValue(xmlDocument, "Host") : SystemInfo.Host;

            if (Exists("Port"))
            {
                int.TryParse(GetValue(xmlDocument, "Port"), out SystemInfo.Port);
            }

            // 客户信息配置
            SystemInfo.CurrentUserName = Exists("CurrentUserName") ? GetValue(xmlDocument, "CurrentUserName") : SystemInfo.CurrentUserName;
            SystemInfo.CurrentPassword = Exists("CurrentPassword") ? GetValue(xmlDocument, "CurrentPassword") : SystemInfo.CurrentPassword;

            if (Exists("MultiLanguage"))
            {
                SystemInfo.MultiLanguage = (String.Compare(GetValue(xmlDocument, "MultiLanguage"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }

            SystemInfo.CurrentLanguage = Exists("CurrentLanguage") ? GetValue(xmlDocument, "CurrentLanguage") : SystemInfo.CurrentLanguage;

            if (Exists("RememberPassword"))
            {
                SystemInfo.RememberPassword = (String.Compare(GetValue(xmlDocument, "RememberPassword"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }

            if (Exists("AutoLogOn"))
            {
                SystemInfo.AutoLogOn = (String.Compare(GetValue(xmlDocument, "AutoLogOn"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }

            if (Exists("EnableCheckPasswordStrength"))
            {
                SystemInfo.EnableCheckPasswordStrength = (String.Compare(GetValue(xmlDocument, "EnableCheckPasswordStrength"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }

            if (Exists("EncryptClientPassword"))
            {
                SystemInfo.EncryptClientPassword = (String.Compare(GetValue(xmlDocument, "EncryptClientPassword"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("EnableEncryptServerPassword"))
            {
                SystemInfo.EnableEncryptServerPassword = (String.Compare(GetValue(xmlDocument, "EnableEncryptServerPassword"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }

            SystemInfo.CurrentStyle      = Exists("CurrentStyle") ? GetValue(xmlDocument, "CurrentStyle") : SystemInfo.CurrentStyle;
            SystemInfo.CurrentThemeColor = Exists("CurrentThemeColor") ? GetValue(xmlDocument, "CurrentThemeColor") : SystemInfo.CurrentThemeColor;

            if (Exists("OnLineTime0ut"))
            {
                var valueOnLineTimeOut = GetValue(xmlDocument, "OnLineTime0ut");
                if (!string.IsNullOrEmpty(valueOnLineTimeOut) && MathHelper.IsInteger(valueOnLineTimeOut))
                {
                    SystemInfo.OnLineTime0ut = Convert.ToInt16(valueOnLineTimeOut);
                }
            }

            if (Exists("EnableCheckIPAddress"))
            {
                SystemInfo.EnableCheckIPAddress = (String.Compare(GetValue(xmlDocument, "EnableCheckIPAddress"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("CheckOnLine"))
            {
                SystemInfo.CheckOnLine = (String.Compare(GetValue(xmlDocument, "CheckOnLine"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("UseMessage"))
            {
                SystemInfo.UseMessage = (String.Compare(GetValue(xmlDocument, "UseMessage"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("AllowUserToRegister"))
            {
                SystemInfo.AllowUserToRegister = (String.Compare(GetValue(xmlDocument, "AllowUserToRegister"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("EnableRecordLog"))
            {
                SystemInfo.EnableRecordLog = (String.Compare(GetValue(xmlDocument, "EnableRecordLog"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }

            SystemInfo.CustomerCompanyName = GetValue(xmlDocument, "CustomerCompanyName");
            SystemInfo.ConfigurationFrom   = BaseConfiguration.GetConfiguration(GetValue(xmlDocument, "ConfigurationFrom"));
            SystemInfo.SoftName            = GetValue(xmlDocument, "SoftName");
            SystemInfo.SoftFullName        = GetValue(xmlDocument, "SoftFullName");
            SystemInfo.RootMenuCode        = GetValue(xmlDocument, "RootMenuCode");
            SystemInfo.Version             = GetValue(xmlDocument, "Version");

            if (Exists("EnableUserAuthorization"))
            {
                SystemInfo.EnableUserAuthorization = (String.Compare(GetValue(xmlDocument, "EnableUserAuthorization"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("EnableModulePermission"))
            {
                SystemInfo.EnableModulePermission = (String.Compare(GetValue(xmlDocument, "EnableModulePermission"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("EnablePermissionItem"))
            {
                SystemInfo.EnablePermissionItem = (String.Compare(GetValue(xmlDocument, "EnablePermissionItem"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("EnableTableFieldPermission"))
            {
                SystemInfo.EnableTableFieldPermission = (String.Compare(GetValue(xmlDocument, "EnableTableFieldPermission"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("EnableTableConstraintPermission"))
            {
                SystemInfo.EnableTableConstraintPermission = (String.Compare(GetValue(xmlDocument, "EnableTableConstraintPermission"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("EnableUserAuthorizationScope"))
            {
                SystemInfo.EnableUserAuthorizationScope = (String.Compare(GetValue(xmlDocument, "EnableUserAuthorizationScope"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("EnableHandWrittenSignature"))
            {
                SystemInfo.EnableHandWrittenSignature = (String.Compare(GetValue(xmlDocument, "EnableHandWrittenSignature"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("EnableOrganizePermission"))
            {
                SystemInfo.EnableOrganizePermission = (String.Compare(GetValue(xmlDocument, "EnableOrganizePermission"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }

            if (Exists("DefaultPassword"))
            {
                SystemInfo.DefaultPassword = GetValue(xmlDocument, "DefaultPassword");
                SystemInfo.DefaultPassword = SecretHelper.AESDecrypt(SystemInfo.DefaultPassword);
            }

            if (Exists("LoadAllUser"))
            {
                SystemInfo.LoadAllUser = (String.Compare(GetValue(xmlDocument, "LoadAllUser"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }

            SystemInfo.Service       = GetValue(xmlDocument, "Service");
            SystemInfo.LogOnAssembly = Exists("LogOnAssembly") ? GetValue(xmlDocument, "LogOnAssembly") : SystemInfo.LogOnAssembly;
            SystemInfo.LogOnForm     = Exists("LogOnForm") ? GetValue(xmlDocument, "LogOnForm") : SystemInfo.LogOnForm;
            SystemInfo.MainForm      = Exists("MainForm") ? GetValue(xmlDocument, "MainForm") : SystemInfo.MainForm;
            int.TryParse(GetValue(xmlDocument, "OnLineLimit"), out SystemInfo.OnLineLimit);

            // 打开数据库连接
            SystemInfo.RDIFrameworkDbType            = Exists("RDIFrameworkDbType") ? BaseConfiguration.GetDbType(GetValue(xmlDocument, "RDIFrameworkDbType")) : SystemInfo.RDIFrameworkDbType;
            SystemInfo.BusinessDbType                = Exists("BusinessDbType") ? BaseConfiguration.GetDbType(GetValue(xmlDocument, "BusinessDbType")) : SystemInfo.BusinessDbType;
            SystemInfo.WorkFlowDbType                = Exists("WorkFlowDbType") ? BaseConfiguration.GetDbType(GetValue(xmlDocument, "WorkFlowDbType")) : SystemInfo.WorkFlowDbType;
            SystemInfo.EncryptDbConnection           = (String.Compare(GetValue(xmlDocument, "EncryptDbConnection"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            SystemInfo.BusinessDbConnectionString    = GetValue(xmlDocument, "BusinessDbConnection");
            SystemInfo.WorkFlowDbConnectionString    = GetValue(xmlDocument, "WorkFlowDbConnection");
            SystemInfo.RDIFrameworkDbConectionString = GetValue(xmlDocument, "RDIFrameworkDbConection");

            if (SystemInfo.EncryptDbConnection)
            {
                SystemInfo.WorkFlowDbConnection    = SecretHelper.AESDecrypt(SystemInfo.WorkFlowDbConnectionString);
                SystemInfo.BusinessDbConnection    = SecretHelper.AESDecrypt(SystemInfo.BusinessDbConnectionString);
                SystemInfo.RDIFrameworkDbConection = SecretHelper.AESDecrypt(SystemInfo.RDIFrameworkDbConectionString);
            }
            else
            {
                SystemInfo.WorkFlowDbConnection    = SystemInfo.WorkFlowDbConnectionString;
                SystemInfo.BusinessDbConnection    = SystemInfo.BusinessDbConnectionString;
                SystemInfo.RDIFrameworkDbConection = SystemInfo.RDIFrameworkDbConectionString;
            }

            SystemInfo.ServiceUserName = GetValue(xmlDocument, "ServiceUserName");
            SystemInfo.ServicePassword = GetValue(xmlDocument, "ServicePassword");
            SystemInfo.ServicePassword = SecretHelper.AESDecrypt(SystemInfo.ServicePassword);

            SystemInfo.RegisterKey = GetValue(xmlDocument, "RegisterKey");
            SystemInfo.NodeTimeout = GetValue(xmlDocument, "NodeTimeout");

            // 错误报告相关
            SystemInfo.ErrorReportFrom         = GetValue(xmlDocument, "ErrorReportFrom");
            SystemInfo.ErrorReportMailUserName = GetValue(xmlDocument, "ErrorReportMailUserName");
            SystemInfo.ErrorReportMailPassword = GetValue(xmlDocument, "ErrorReportMailPassword");
            //SMTP服务器,如:smtp.126.com
            SystemInfo.ErrorReportMailServer   = GetValue(xmlDocument, "ErrorReportMailServer");
            SystemInfo.ErrorReportMailPassword = SecretHelper.AESDecrypt(SystemInfo.ErrorReportMailPassword);
            var blog = GetValue(xmlDocument, "RDIFrameworkBlog");

            if (!string.IsNullOrEmpty(blog))
            {
                SystemInfo.RDIFrameworkBlog = blog;
            }
            var weibo = GetValue(xmlDocument, "RDIFrameworkWeibo");

            if (!string.IsNullOrEmpty(weibo))
            {
                SystemInfo.RDIFrameworkWeibo = weibo;
            }
        }
Пример #7
0
        public static void GetConfig(string fileName)
        {
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(fileName);
            if (Exists("CurrentUserName"))
            {
                SystemInfo.CurrentUserName = GetValue(xmlDocument, "CurrentUserName");
            }
            if (Exists("CurrentPassword"))
            {
                SystemInfo.CurrentPassword = GetValue(xmlDocument, "CurrentPassword");
            }
            if (Exists("MultiLanguage"))
            {
                SystemInfo.MultiLanguage = string.Compare(GetValue(xmlDocument, "MultiLanguage"), "TRUE", true, CultureInfo.CurrentCulture) == 0;
            }
            if (Exists("CurrentLanguage"))
            {
                SystemInfo.CurrentLanguage = GetValue(xmlDocument, "CurrentLanguage");
            }
            if (Exists("RememberPassword"))
            {
                SystemInfo.RememberPassword = string.Compare(GetValue(xmlDocument, "RememberPassword"), "TRUE", true, CultureInfo.CurrentCulture) == 0;
            }
            if (Exists("AutoLogOn"))
            {
                SystemInfo.AutoLogOn = string.Compare(GetValue(xmlDocument, "AutoLogOn"), "TRUE", true, CultureInfo.CurrentCulture) == 0;
            }
            if (Exists("EnableCheckPasswordStrength"))
            {
                SystemInfo.EnableCheckPasswordStrength = string.Compare(GetValue(xmlDocument, "EnableCheckPasswordStrength"), "TRUE", true, CultureInfo.CurrentCulture) == 0;
            }
            if (Exists("EncryptClientPassword"))
            {
                SystemInfo.EncryptClientPassword = string.Compare(GetValue(xmlDocument, "EncryptClientPassword"), "TRUE", true, CultureInfo.CurrentCulture) == 0;
            }
            if (Exists("EnableEncryptServerPassword"))
            {
                SystemInfo.EnableEncryptServerPassword = string.Compare(GetValue(xmlDocument, "EnableEncryptServerPassword"), "TRUE", true, CultureInfo.CurrentCulture) == 0;
            }
            if (Exists("CurrentStyle"))
            {
                SystemInfo.CurrentStyle = GetValue(xmlDocument, "CurrentStyle");
            }
            if (Exists("CurrentThemeColor"))
            {
                SystemInfo.CurrentThemeColor = GetValue(xmlDocument, "CurrentThemeColor");
            }
            if (Exists("OnLineTime0ut"))
            {
                string str = GetValue(xmlDocument, "OnLineTime0ut");
                if (!(string.IsNullOrEmpty(str) || !MathHelper.IsInteger(str)))
                {
                    SystemInfo.OnLineTime0ut = Convert.ToInt16(str);
                }
            }
            if (Exists("EnableCheckIPAddress"))
            {
                SystemInfo.EnableCheckIPAddress = string.Compare(GetValue(xmlDocument, "EnableCheckIPAddress"), "TRUE", true, CultureInfo.CurrentCulture) == 0;
            }
            if (Exists("CheckOnLine"))
            {
                SystemInfo.CheckOnLine = string.Compare(GetValue(xmlDocument, "CheckOnLine"), "TRUE", true, CultureInfo.CurrentCulture) == 0;
            }
            if (Exists("UseMessage"))
            {
                SystemInfo.UseMessage = string.Compare(GetValue(xmlDocument, "UseMessage"), "TRUE", true, CultureInfo.CurrentCulture) == 0;
            }
            if (Exists("AllowUserToRegister"))
            {
                SystemInfo.AllowUserToRegister = string.Compare(GetValue(xmlDocument, "AllowUserToRegister"), "TRUE", true, CultureInfo.CurrentCulture) == 0;
            }
            if (Exists("EnableRecordLog"))
            {
                SystemInfo.EnableRecordLog = string.Compare(GetValue(xmlDocument, "EnableRecordLog"), "TRUE", true, CultureInfo.CurrentCulture) == 0;
            }
            SystemInfo.CustomerCompanyName = GetValue(xmlDocument, "CustomerCompanyName");
            SystemInfo.ConfigurationFrom   = BaseConfiguration.GetConfiguration(GetValue(xmlDocument, "ConfigurationFrom"));
            SystemInfo.SoftName            = GetValue(xmlDocument, "SoftName");
            SystemInfo.SoftFullName        = GetValue(xmlDocument, "SoftFullName");
            SystemInfo.RootMenuCode        = GetValue(xmlDocument, "RootMenuCode");
            SystemInfo.Version             = GetValue(xmlDocument, "Version");
            if (Exists("EnableUserAuthorization"))
            {
                SystemInfo.EnableUserAuthorization = string.Compare(GetValue(xmlDocument, "EnableUserAuthorization"), "TRUE", true, CultureInfo.CurrentCulture) == 0;
            }
            if (Exists("EnableModulePermission"))
            {
                SystemInfo.EnableModulePermission = string.Compare(GetValue(xmlDocument, "EnableModulePermission"), "TRUE", true, CultureInfo.CurrentCulture) == 0;
            }
            if (Exists("EnablePermissionItem"))
            {
                SystemInfo.EnablePermissionItem = string.Compare(GetValue(xmlDocument, "EnablePermissionItem"), "TRUE", true, CultureInfo.CurrentCulture) == 0;
            }
            if (Exists("EnableTableFieldPermission"))
            {
                SystemInfo.EnableTableFieldPermission = string.Compare(GetValue(xmlDocument, "EnableTableFieldPermission"), "TRUE", true, CultureInfo.CurrentCulture) == 0;
            }
            if (Exists("EnableTableConstraintPermission"))
            {
                SystemInfo.EnableTableConstraintPermission = string.Compare(GetValue(xmlDocument, "EnableTableConstraintPermission"), "TRUE", true, CultureInfo.CurrentCulture) == 0;
            }
            if (Exists("EnableUserAuthorizationScope"))
            {
                SystemInfo.EnableUserAuthorizationScope = string.Compare(GetValue(xmlDocument, "EnableUserAuthorizationScope"), "TRUE", true, CultureInfo.CurrentCulture) == 0;
            }
            if (Exists("EnableHandWrittenSignature"))
            {
                SystemInfo.EnableHandWrittenSignature = string.Compare(GetValue(xmlDocument, "EnableHandWrittenSignature"), "TRUE", true, CultureInfo.CurrentCulture) == 0;
            }
            if (Exists("DefaultPassword"))
            {
                SystemInfo.DefaultPassword = GetValue(xmlDocument, "DefaultPassword");
                SystemInfo.DefaultPassword = SecretHelper.smethod_1(SystemInfo.DefaultPassword);
            }
            if (Exists("LoadAllUser"))
            {
                SystemInfo.LoadAllUser = string.Compare(GetValue(xmlDocument, "LoadAllUser"), "TRUE", true, CultureInfo.CurrentCulture) == 0;
            }
            SystemInfo.Service = GetValue(xmlDocument, "Service");
            if (Exists("LogOnAssembly"))
            {
                SystemInfo.LogOnAssembly = GetValue(xmlDocument, "LogOnAssembly");
            }
            if (Exists("LogOnForm"))
            {
                SystemInfo.LogOnForm = GetValue(xmlDocument, "LogOnForm");
            }
            if (Exists("MainForm"))
            {
                SystemInfo.MainForm = GetValue(xmlDocument, "MainForm");
            }
            int.TryParse(GetValue(xmlDocument, "OnLineLimit"), out SystemInfo.OnLineLimit);
            if (Exists("RDIFrameworkDbType"))
            {
                SystemInfo.RDIFrameworkDbType = BaseConfiguration.GetDbType(GetValue(xmlDocument, "RDIFrameworkDbType"));
            }
            if (Exists("BusinessDbType"))
            {
                SystemInfo.BusinessDbType = BaseConfiguration.GetDbType(GetValue(xmlDocument, "BusinessDbType"));
            }
            if (Exists("WorkFlowDbType"))
            {
                SystemInfo.WorkFlowDbType = BaseConfiguration.GetDbType(GetValue(xmlDocument, "WorkFlowDbType"));
            }
            SystemInfo.EncryptDbConnection           = string.Compare(GetValue(xmlDocument, "EncryptDbConnection"), "TRUE", true, CultureInfo.CurrentCulture) == 0;
            SystemInfo.BusinessDbConnectionString    = GetValue(xmlDocument, "BusinessDbConnection");
            SystemInfo.WorkFlowDbConnectionString    = GetValue(xmlDocument, "WorkFlowDbConnection");
            SystemInfo.RDIFrameworkDbConectionString = GetValue(xmlDocument, "RDIFrameworkDbConection");
            if (SystemInfo.EncryptDbConnection)
            {
                SystemInfo.WorkFlowDbConnection    = SecretHelper.smethod_1(SystemInfo.WorkFlowDbConnectionString);
                SystemInfo.BusinessDbConnection    = SecretHelper.smethod_1(SystemInfo.BusinessDbConnectionString);
                SystemInfo.RDIFrameworkDbConection = SecretHelper.smethod_1(SystemInfo.RDIFrameworkDbConectionString);
            }
            else
            {
                SystemInfo.WorkFlowDbConnection    = SystemInfo.WorkFlowDbConnectionString;
                SystemInfo.BusinessDbConnection    = SystemInfo.BusinessDbConnectionString;
                SystemInfo.RDIFrameworkDbConection = SystemInfo.RDIFrameworkDbConectionString;
            }
            SystemInfo.ServiceUserName         = GetValue(xmlDocument, "ServiceUserName");
            SystemInfo.ServicePassword         = GetValue(xmlDocument, "ServicePassword");
            SystemInfo.ServicePassword         = SecretHelper.smethod_1(SystemInfo.ServicePassword);
            SystemInfo.RegisterKey             = GetValue(xmlDocument, "RegisterKey");
            SystemInfo.ErrorReportFrom         = GetValue(xmlDocument, "ErrorReportFrom");
            SystemInfo.ErrorReportMailUserName = GetValue(xmlDocument, "ErrorReportMailUserName");
            SystemInfo.ErrorReportMailPassword = GetValue(xmlDocument, "ErrorReportMailPassword");
            SystemInfo.ErrorReportMailServer   = GetValue(xmlDocument, "ErrorReportMailServer");
            SystemInfo.ErrorReportMailPassword = SecretHelper.smethod_1(SystemInfo.ErrorReportMailPassword);
            string str2 = GetValue(xmlDocument, "RDIFrameworkBlog");

            if (!string.IsNullOrEmpty(str2))
            {
                SystemInfo.RDIFrameworkBlog = str2;
            }
            string str3 = GetValue(xmlDocument, "RDIFrameworkWeibo");

            if (!string.IsNullOrEmpty(str3))
            {
                SystemInfo.RDIFrameworkWeibo = str3;
            }
        }