Exemplo n.º 1
0
 /// <summary>
 /// 获取查询字符串
 /// </summary>
 /// <param name="search">查询字符</param>
 /// <param name="allLike">是否所有的匹配都查询,建议传递"%"字符</param>
 /// <returns>字符串</returns>
 public static string GetSearchString(string searchValue, bool allLike = false)
 {
     if (!string.IsNullOrEmpty(searchValue))
     {
         searchValue = searchValue.Trim();
         searchValue = SecretUtil.SqlSafe(searchValue);
         if (searchValue.Length > 0)
         {
             searchValue = searchValue.Replace('[', '_');
             searchValue = searchValue.Replace(']', '_');
         }
         if (searchValue == "%")
         {
             searchValue = "[%]";
         }
         if ((searchValue.Length > 0) && (searchValue.IndexOf('%') < 0) && (searchValue.IndexOf('_') < 0))
         {
             if (allLike)
             {
                 string searchLike = string.Empty;
                 for (int i = 0; i < searchValue.Length; i++)
                 {
                     searchLike += "%" + searchValue[i];
                 }
                 searchValue = searchLike + "%";
             }
             else
             {
                 searchValue = "%" + searchValue + "%";
             }
         }
     }
     return(searchValue);
 }
Exemplo n.º 2
0
        /// <summary>
        /// 读取配置项
        /// </summary>
        /// <param name="key">键</param>
        /// <returns>值</returns>
        public static string GetValue(string key, bool encrypt = false)
        {
            string result = string.Empty;

            result = GetValue(xmlDocument, SelectPath, key);
            if (!string.IsNullOrEmpty(result) && encrypt)
            {
                result = SecretUtil.Decrypt(result);
            }
            return(result);
        }
Exemplo n.º 3
0
        public static string BuildSecurityRequest(string key, string request)
        {
            // 需要传输的url参数
            string result = string.Empty;

            // 把服务名传输过来,2边能对上才可以
            request = "ServiceUserName="******"&" + request;
            // 把字符串进行加密
            result = SecretUtil.Encrypt(request);
            // 头部在加个8个随机字符
            VerifyCodeImage verifyCodeImage = new VerifyCodeImage();

            result = verifyCodeImage.CreateVerifyCode(8).ToUpper() + result;
            // 需要打开的网址
            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获取签名密码
        /// </summary>
        /// <param name="digitalSignatureFile">数字证书文件</param>
        /// <returns>私钥</returns>
        public static string GetSignedPassword(string digitalSignatureFile)
        {
            // 0:这里需要处理异常信息
            // 1:定义私钥
            string signedPassword = string.Empty;
            // 2:读取证书文件
            string digitalSignature = FileUtil.ReadBinaryFile(digitalSignatureFile);
            // 3:解密文件
            string xmlFile = SecretUtil.Decrypt(digitalSignature);
            // 4:按XML文件读取
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(xmlFile);
            signedPassword = xmlDocument.SelectSingleNode("//DigitalSignature/Key").Attributes["SignedPassword"].Value;
            return(signedPassword);
        }
Exemplo n.º 5
0
        public static NameValueCollection ProcessSecurityRequest(HttpContext context, out bool valid, out string function)
        {
            valid    = false;
            function = string.Empty;

            NameValueCollection result = null;
            // 输入的参数是否有效,进行严格限制访问
            string key = string.Empty;

            if (context.Request["Key"] != null)
            {
                key = context.Request["Key"].ToString();
                if (!string.IsNullOrEmpty(key) && key.Length > 8)
                {
                    // 去掉头部8个多余的字符串
                    key = key.Substring(8);
                    key = SecretUtil.Decrypt(key);
                    if (!string.IsNullOrEmpty(key))
                    {
                        valid = true;
                    }
                }
                else
                {
                    valid = false;
                }
            }
            else
            {
                valid = false;
            }

            if (valid)
            {
                result = HttpUtility.ParseQueryString(key);
                if (!string.IsNullOrEmpty(result["ServiceUserName"]))
                {
                    string serviceUserName = result["ServiceUserName"];
                    valid = BaseSystemInfo.ServiceUserName == serviceUserName;
                }
                if (valid && !string.IsNullOrEmpty(result["Function"]))
                {
                    function = result["Function"];
                }
            }
            return(result);
        }
Exemplo n.º 6
0
        public static string AppSettings(string key, bool encrypt)
        {
            string result = string.Empty;

            if (ConfigurationManager.AppSettings[key] != null)
            {
                result = ConfigurationManager.AppSettings[key];
            }
            if (!string.IsNullOrEmpty(result))
            {
                if (encrypt)
                {
                    result = SecretUtil.Decrypt(result);
                }
            }

            return(result);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 获得新的数据库连接
        /// </summary>
        /// <param name="connectionString">数据库连接字符串</param>
        /// <returns>数据库连接</returns>
        public virtual IDbConnection Open(string connectionString)
        {
            // 写入调试信息
#if (DEBUG)
            int milliStart = Environment.TickCount;
            Trace.WriteLine(DateTime.Now.ToString(BaseSystemInfo.TimeFormat) + " :Begin: " +
                            MethodBase.GetCurrentMethod().ReflectedType.Name + "." + MethodBase.GetCurrentMethod().Name);
#endif

            // 这里数据库连接打开的时候,就判断注册属性的有效性
            if (!SecretUtil.CheckRegister())
            {
                // 若没有进行注册,让程序无法打开数据库比较好。
                connectionString = string.Empty;

                // 抛出异常信息显示给客户
                throw new Exception(BaseSystemInfo.RegisterException);
            }
            // 若是空的话才打开
            if (this.dbConnection == null || this.dbConnection.State == ConnectionState.Closed)
            {
                this.ConnectionString = connectionString;
                this.dbConnection     = GetInstance().CreateConnection();
                this.dbConnection.ConnectionString = this.ConnectionString;
                this.dbConnection.Open();

                // 创建对象
                // this.dbCommand = this.DbConnection.CreateCommand();
                // this.dbCommand.Connection = this.dbConnection;
                // this.dbDataAdapter = this.dbProviderFactory.CreateDataAdapter();
                // this.dbDataAdapter.SelectCommand = this.dbCommand;

                // 写入调试信息
#if (DEBUG)
                int milliEnd = Environment.TickCount;
                Trace.WriteLine(DateTime.Now.ToString(BaseSystemInfo.TimeFormat) + " Ticks: " +
                                TimeSpan.FromMilliseconds(milliEnd - milliStart).ToString() + " :End: " +
                                MethodBase.GetCurrentMethod().ReflectedType.Name + "." + MethodBase.GetCurrentMethod().Name);
#endif
            }

            this.AutoOpenClose = false;
            return(this.dbConnection);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 获得新的数据库连接
        /// </summary>
        /// <param name="connectionString">数据库连接字符串</param>
        /// <returns>数据库连接</returns>
        public virtual IDbConnection Open(string connectionString)
        {
            // 这里数据库连接打开的时候,就判断注册属性的有效性
            if (!SecretUtil.CheckRegister())
            {
                // 若没有进行注册,让程序无法打开数据库比较好。
                connectionString = string.Empty;

                // 抛出异常信息显示给客户
                throw new Exception(BaseSystemInfo.RegisterException);
            }

            // 若是空的话才打开,不可以,每次应该打开新的数据库连接才对,这样才能保证不是一个数据库连接上执行的
            this.ConnectionString = connectionString;
            this.dbConnection     = GetInstance().CreateConnection();
            this.dbConnection.ConnectionString = this.ConnectionString;
            this.dbConnection.Open();
            this.MustCloseConnection = false;
            return(this.dbConnection);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 获取私钥
        /// </summary>
        /// <param name="digitalSignatureFile">数字证书文件</param>
        /// <param name="signedPassword">签名密码</param>
        /// <returns>私钥</returns>
        public static string GetPrivateKey(string digitalSignatureFile, string signedPassword)
        {
            // 0:这里需要处理异常信息
            // 1:定义私钥
            string privateKey = string.Empty;
            // 2:读取证书文件
            string digitalSignature = FileUtil.ReadBinaryFile(digitalSignatureFile);
            // 3:解密文件
            string xmlFile = SecretUtil.Decrypt(digitalSignature);
            // 4:按XML文件读取
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(xmlFile);
            string keySignedPassword = xmlDocument.SelectSingleNode("//DigitalSignature/Key").Attributes["SignedPassword"].Value;

            // 5:若签名密码不对,不应该能读取私钥
            if (md5(signedPassword, 32).Equals(keySignedPassword))
            {
                privateKey = xmlDocument.SelectSingleNode("//DigitalSignature/Key").Attributes["PrivateKey"].Value;
            }
            return(privateKey);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 从指定的文件读取配置项
        /// </summary>
        public static void GetConfig(XmlDocument document)
        {
            xmlDocument = document;
            if (Exists("ConfigFile"))
            {
                BaseSystemInfo.ConfigFile = GetValue(xmlDocument, "ConfigFile");
            }
            if (Exists("Host"))
            {
                BaseSystemInfo.Host = GetValue(xmlDocument, "Host");
            }
            if (Exists("Port"))
            {
                int.TryParse(GetValue(xmlDocument, "Port"), out BaseSystemInfo.Port);
            }
            if (Exists("MobileHost"))
            {
                if (!string.IsNullOrWhiteSpace(GetValue(xmlDocument, "MobileHost")))
                {
                    BaseSystemInfo.MobileHost = GetValue(xmlDocument, "MobileHost");
                }
            }
            // 客户信息配置
            if (Exists("NeedRegister"))
            {
                BaseSystemInfo.NeedRegister = (String.Compare(GetValue(xmlDocument, "NeedRegister"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            // 客户信息配置
            if (Exists("CurrentCompany"))
            {
                BaseSystemInfo.CurrentCompany = GetValue(xmlDocument, "CurrentCompany");
            }
            if (Exists("CurrentUserName"))
            {
                BaseSystemInfo.CurrentUserName = GetValue(xmlDocument, "CurrentUserName");
            }
            if (Exists("CurrentNickName"))
            {
                BaseSystemInfo.CurrentNickName = GetValue(xmlDocument, "CurrentNickName");
            }
            if (Exists("CurrentPassword"))
            {
                BaseSystemInfo.CurrentPassword = GetValue(xmlDocument, "CurrentPassword");
            }
            //历史登录用户记录
            if (Exists("HistoryUsers"))
            {
                string   strUserList   = GetValue(xmlDocument, "HistoryUsers");
                string[] userInfoArray = strUserList.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                BaseSystemInfo.HistoryUsers = userInfoArray;
            }
            if (Exists("MultiLanguage"))
            {
                BaseSystemInfo.MultiLanguage = (String.Compare(GetValue(xmlDocument, "MultiLanguage"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("CurrentLanguage"))
            {
                BaseSystemInfo.CurrentLanguage = GetValue(xmlDocument, "CurrentLanguage");
            }
            if (Exists("RememberPassword"))
            {
                BaseSystemInfo.RememberPassword = (String.Compare(GetValue(xmlDocument, "RememberPassword"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("OnInternet"))
            {
                BaseSystemInfo.OnInternet = (String.Compare(GetValue(xmlDocument, "OnInternet"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("AutoLogOn"))
            {
                BaseSystemInfo.AutoLogOn = (String.Compare(GetValue(xmlDocument, "AutoLogOn"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("ClientEncryptPassword"))
            {
                BaseSystemInfo.ClientEncryptPassword = (String.Compare(GetValue(xmlDocument, "ClientEncryptPassword"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("ServerEncryptPassword"))
            {
                BaseSystemInfo.ServerEncryptPassword = (String.Compare(GetValue(xmlDocument, "ServerEncryptPassword"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }

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

            // add by zgl
            if (Exists("CheckIPAddress"))
            {
                BaseSystemInfo.CheckIPAddress = (String.Compare(GetValue(xmlDocument, "CheckIPAddress"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("CheckOnLine"))
            {
                BaseSystemInfo.CheckOnLine = (String.Compare(GetValue(xmlDocument, "CheckOnLine"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("UseMessage"))
            {
                BaseSystemInfo.UseMessage = (String.Compare(GetValue(xmlDocument, "UseMessage"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("Synchronous"))
            {
                BaseSystemInfo.Synchronous = (String.Compare(GetValue(xmlDocument, "Synchronous"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("CheckBalance"))
            {
                BaseSystemInfo.CheckBalance = (String.Compare(GetValue(xmlDocument, "CheckBalance"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("AllowUserRegister"))
            {
                BaseSystemInfo.AllowUserRegister = (String.Compare(GetValue(xmlDocument, "AllowUserRegister"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("RecordLog"))
            {
                BaseSystemInfo.RecordLog = (String.Compare(GetValue(xmlDocument, "RecordLog"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }

            if (Exists("CustomerCompanyName"))
            {
                BaseSystemInfo.CustomerCompanyName = GetValue(xmlDocument, "CustomerCompanyName");
            }
            if (Exists("ConfigurationFrom"))
            {
                BaseSystemInfo.ConfigurationFrom = BaseConfiguration.GetConfiguration(GetValue(xmlDocument, "ConfigurationFrom"));
            }
            if (Exists("SoftName"))
            {
                BaseSystemInfo.SoftName = GetValue(xmlDocument, "SoftName");
            }
            if (Exists("SoftFullName"))
            {
                BaseSystemInfo.SoftFullName = GetValue(xmlDocument, "SoftFullName");
            }

            if (Exists("SystemCode"))
            {
                BaseSystemInfo.SystemCode = GetValue(xmlDocument, "SystemCode");
            }
            if (Exists("Version"))
            {
                BaseSystemInfo.Version = GetValue(xmlDocument, "Version");
            }

            if (Exists("UseOrganizePermission"))
            {
                BaseSystemInfo.UseOrganizePermission = (String.Compare(GetValue(xmlDocument, "UseOrganizePermission"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("UseUserPermission"))
            {
                BaseSystemInfo.UseUserPermission = (String.Compare(GetValue(xmlDocument, "UseUserPermission"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("UseTableColumnPermission"))
            {
                BaseSystemInfo.UseTableColumnPermission = (String.Compare(GetValue(xmlDocument, "UseTableColumnPermission"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("UseTableScopePermission"))
            {
                BaseSystemInfo.UseTableScopePermission = (String.Compare(GetValue(xmlDocument, "UseTableScopePermission"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("UsePermissionScope"))
            {
                BaseSystemInfo.UsePermissionScope = (String.Compare(GetValue(xmlDocument, "UsePermissionScope"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("UseAuthorizationScope"))
            {
                BaseSystemInfo.UseAuthorizationScope = (String.Compare(GetValue(xmlDocument, "UseAuthorizationScope"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("HandwrittenSignature"))
            {
                BaseSystemInfo.HandwrittenSignature = (String.Compare(GetValue(xmlDocument, "HandwrittenSignature"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }

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

            if (Exists("Service"))
            {
                BaseSystemInfo.Service = GetValue(xmlDocument, "Service");
            }
            if (Exists("LogOnForm"))
            {
                BaseSystemInfo.LogOnForm = GetValue(xmlDocument, "LogOnForm");
            }
            if (Exists("MainForm"))
            {
                BaseSystemInfo.MainForm = GetValue(xmlDocument, "MainForm");
            }
            if (Exists("OnLineLimit"))
            {
                int.TryParse(GetValue(xmlDocument, "OnLineLimit"), out BaseSystemInfo.OnLineLimit);
            }
            if (Exists("UserCenterDbType"))
            {
                BaseSystemInfo.UserCenterDbType = DbHelper.GetDbType(GetValue(xmlDocument, "UserCenterDbType"));
                BaseSystemInfo.MessageDbType    = BaseSystemInfo.UserCenterDbType;
                BaseSystemInfo.BusinessDbType   = BaseSystemInfo.UserCenterDbType;
                BaseSystemInfo.WorkFlowDbType   = BaseSystemInfo.UserCenterDbType;
                BaseSystemInfo.LoginLogDbType   = BaseSystemInfo.UserCenterDbType;
            }
            // 打开数据库连接
            if (Exists("MessageDbType"))
            {
                BaseSystemInfo.MessageDbType = DbHelper.GetDbType(GetValue(xmlDocument, "MessageDbType"));
            }
            if (Exists("WorkFlowDbType"))
            {
                BaseSystemInfo.WorkFlowDbType = DbHelper.GetDbType(GetValue(xmlDocument, "WorkFlowDbType"));
            }
            if (Exists("BusinessDbType"))
            {
                BaseSystemInfo.BusinessDbType = DbHelper.GetDbType(GetValue(xmlDocument, "BusinessDbType"));
            }
            if (Exists("LoginLogDbType"))
            {
                BaseSystemInfo.LoginLogDbType = DbHelper.GetDbType(GetValue(xmlDocument, "LoginLogDbType"));
            }

            if (Exists("UserCenterDbConnection"))
            {
                BaseSystemInfo.UserCenterDbConnectionString = GetValue(xmlDocument, "UserCenterDbConnection");
                BaseSystemInfo.UserCenterReadDbConnection   = BaseSystemInfo.UserCenterDbConnectionString;
                BaseSystemInfo.UserCenterWriteDbConnection  = BaseSystemInfo.UserCenterDbConnectionString;
                BaseSystemInfo.MessageDbConnectionString    = BaseSystemInfo.UserCenterDbConnectionString;
                BaseSystemInfo.LoginLogDbConnectionString   = BaseSystemInfo.UserCenterDbConnectionString;
                BaseSystemInfo.BusinessDbConnectionString   = BaseSystemInfo.UserCenterDbConnectionString;
                // BaseSystemInfo.WorkFlowDbConnectionString = BaseSystemInfo.UserCenterDbConnectionString;
            }

            if (Exists("OrganizeDynamicLoading"))
            {
                BaseSystemInfo.OrganizeDynamicLoading = (String.Compare(GetValue(xmlDocument, "OrganizeDynamicLoading"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("MessageDbConnection"))
            {
                BaseSystemInfo.MessageDbConnectionString = GetValue(xmlDocument, "MessageDbConnection");
            }
            if (Exists("LoginLogDbConnection"))
            {
                BaseSystemInfo.LoginLogDbConnectionString = GetValue(xmlDocument, "LoginLogDbConnection");
            }
            if (Exists("WorkFlowDbConnection"))
            {
                BaseSystemInfo.WorkFlowDbConnectionString = GetValue(xmlDocument, "WorkFlowDbConnection");
            }
            if (Exists("BusinessDbConnection"))
            {
                BaseSystemInfo.BusinessDbConnectionString = GetValue(xmlDocument, "BusinessDbConnection");
            }

            BaseSystemInfo.UserCenterDbConnection = BaseSystemInfo.UserCenterDbConnectionString;
            BaseSystemInfo.LoginLogDbConnection   = BaseSystemInfo.LoginLogDbConnectionString;
            BaseSystemInfo.MessageDbConnection    = BaseSystemInfo.MessageDbConnectionString;
            BaseSystemInfo.BusinessDbConnection   = BaseSystemInfo.BusinessDbConnectionString;
            BaseSystemInfo.WorkFlowDbConnection   = BaseSystemInfo.WorkFlowDbConnectionString;

            if (Exists("EncryptDbConnection"))
            {
                BaseSystemInfo.EncryptDbConnection = (String.Compare(GetValue(xmlDocument, "EncryptDbConnection"), "TRUE", true, CultureInfo.CurrentCulture) == 0);

                if (BaseSystemInfo.EncryptDbConnection)
                {
                    BaseSystemInfo.UserCenterDbConnection = SecretUtil.Decrypt(BaseSystemInfo.UserCenterDbConnectionString);
                    BaseSystemInfo.LoginLogDbConnection   = SecretUtil.Decrypt(BaseSystemInfo.LoginLogDbConnectionString);
                    BaseSystemInfo.MessageDbConnection    = SecretUtil.Decrypt(BaseSystemInfo.MessageDbConnectionString);
                    BaseSystemInfo.BusinessDbConnection   = SecretUtil.Decrypt(BaseSystemInfo.BusinessDbConnectionString);
                    BaseSystemInfo.WorkFlowDbConnection   = SecretUtil.Decrypt(BaseSystemInfo.WorkFlowDbConnectionString);
                }
            }

            // 若是本地模式运行,然后还缺少数据库配置?
            if (BaseSystemInfo.Service.Equals("DotNet.Business"))
            {
                if (string.IsNullOrEmpty(BaseSystemInfo.UserCenterDbConnection))
                {
                    BaseSystemInfo.UserCenterDbConnection = "Data Source=localhost;Initial Catalog=UserCenterV42;Integrated Security=SSPI;";
                }
                if (string.IsNullOrEmpty(BaseSystemInfo.LoginLogDbConnection))
                {
                    BaseSystemInfo.LoginLogDbConnection = "Data Source=localhost;Initial Catalog=UserCenterV42;Integrated Security=SSPI;";
                }
                if (string.IsNullOrEmpty(BaseSystemInfo.MessageDbConnection))
                {
                    BaseSystemInfo.MessageDbConnection = BaseSystemInfo.UserCenterDbConnection;
                }
                if (string.IsNullOrEmpty(BaseSystemInfo.WorkFlowDbConnection))
                {
                    // BaseSystemInfo.WorkFlowDbConnection = "Data Source=localhost;Initial Catalog=WorkFlowV42;Integrated Security=SSPI;";
                }
                if (string.IsNullOrEmpty(BaseSystemInfo.BusinessDbConnection))
                {
                    // BaseSystemInfo.BusinessDbConnection = "Data Source=localhost;Initial Catalog=ProjectV42;Integrated Security=SSPI;";
                }
            }

            if (Exists("ServiceUserName"))
            {
                BaseSystemInfo.ServiceUserName = GetValue(xmlDocument, "ServiceUserName");
            }
            if (Exists("ServicePassword"))
            {
                BaseSystemInfo.ServicePassword = GetValue(xmlDocument, "ServicePassword");
            }
            if (Exists("RegisterKey"))
            {
                BaseSystemInfo.RegisterKey = GetValue(xmlDocument, "RegisterKey");
            }

            // 错误报告相关
            if (Exists("ErrorReportTo"))
            {
                BaseSystemInfo.ErrorReportTo = GetValue(xmlDocument, "ErrorReportTo");
            }
            if (Exists("MailServer"))
            {
                BaseSystemInfo.MailServer = GetValue(xmlDocument, "MailServer");
            }
            if (Exists("MailUserName"))
            {
                BaseSystemInfo.MailUserName = GetValue(xmlDocument, "MailUserName");
            }
            if (Exists("MailPassword"))
            {
                BaseSystemInfo.MailPassword = GetValue(xmlDocument, "MailPassword");
                // BaseSystemInfo.MailPassword = SecretUtil.Encrypt(BaseSystemInfo.MailPassword);
                // BaseSystemInfo.MailPassword = SecretUtil.Decrypt(BaseSystemInfo.MailPassword);
            }
            if (Exists("UploadBlockSize"))
            {
                BaseSystemInfo.UploadBlockSize = Convert.ToInt32(GetValue(xmlDocument, "UploadBlockSize"));
            }
            if (Exists("UploadStorageMode"))
            {
                BaseSystemInfo.UploadStorageMode = GetValue(xmlDocument, "UploadStorageMode");
            }
            if (Exists("UploadPath"))
            {
                BaseSystemInfo.UploadPath = GetValue(xmlDocument, "UploadPath");
            }
            if (Exists("UseWorkFlow"))
            {
                BaseSystemInfo.UseWorkFlow = (String.Compare(GetValue(xmlDocument, "UseWorkFlow"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }

            // 这里重新给静态数据库连接对象进行赋值
            // DotNet.Utilities.DbHelper.DbConnection = BaseSystemInfo.BusinessDbConnection;
            // DotNet.Utilities.DbHelper.DbType = BaseSystemInfo.BusinessDbType;

            // 这里是处理读写分离功能,读取数据与写入数据进行分离的方式
            if (Exists("UserCenterReadDbConnection"))
            {
                BaseSystemInfo.UserCenterReadDbConnection = GetValue(xmlDocument, "UserCenterReadDbConnection");
            }
            if (Exists("UserCenterWriteDbConnection"))
            {
                BaseSystemInfo.UserCenterWriteDbConnection = GetValue(xmlDocument, "UserCenterWriteDbConnection");
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// 从配置信息获取配置信息
        /// </summary>
        /// <param name="configuration">配置</param>
        public static void GetConfig()
        {
            // 读取注册码
            BaseSystemInfo.RegisterKey = ConfigurationManager.AppSettings["RegisterKey"];

            if (ConfigurationManager.AppSettings["MailServer"] != null)
            {
                BaseSystemInfo.MailServer = ConfigurationManager.AppSettings["MailServer"];
            }
            if (ConfigurationManager.AppSettings["MailUserName"] != null)
            {
                BaseSystemInfo.MailUserName = ConfigurationManager.AppSettings["MailUserName"];
            }
            if (ConfigurationManager.AppSettings["MailPassword"] != null)
            {
                BaseSystemInfo.MailPassword = ConfigurationManager.AppSettings["MailPassword"];
                if (BaseSystemInfo.EncryptDbConnection)
                {
                    BaseSystemInfo.MailPassword = SecretUtil.Decrypt(BaseSystemInfo.MailPassword);
                }
            }

            // 客户信息配置
            if (ConfigurationManager.AppSettings["CustomerCompanyName"] != null)
            {
                BaseSystemInfo.CustomerCompanyName = ConfigurationManager.AppSettings["CustomerCompanyName"];
            }
            if (ConfigurationManager.AppSettings["ConfigurationFrom"] != null)
            {
                BaseSystemInfo.ConfigurationFrom = BaseConfiguration.GetConfiguration(ConfigurationManager.AppSettings["ConfigurationFrom"]);
            }
            if (ConfigurationManager.AppSettings["SoftName"] != null)
            {
                BaseSystemInfo.SoftName = ConfigurationManager.AppSettings["SoftName"];
            }
            if (ConfigurationManager.AppSettings["CompanyName"] != null)
            {
                BaseSystemInfo.CompanyName = ConfigurationManager.AppSettings["CompanyName"];
            }
            if (ConfigurationManager.AppSettings["SoftFullName"] != null)
            {
                BaseSystemInfo.SoftFullName = ConfigurationManager.AppSettings["SoftFullName"];
            }
            if (ConfigurationManager.AppSettings["SystemCode"] != null)
            {
                BaseSystemInfo.SystemCode = ConfigurationManager.AppSettings["SystemCode"];
            }
            if (ConfigurationManager.AppSettings["ServiceUserName"] != null)
            {
                BaseSystemInfo.ServiceUserName = ConfigurationManager.AppSettings["ServiceUserName"];
            }
            if (ConfigurationManager.AppSettings["ServicePassword"] != null)
            {
                BaseSystemInfo.ServicePassword = ConfigurationManager.AppSettings["ServicePassword"];
            }

            if (ConfigurationManager.AppSettings["PasswordErrorLockLimit"] != null)
            {
                BaseSystemInfo.PasswordErrorLockLimit = int.Parse(ConfigurationManager.AppSettings["PasswordErrorLockLimit"]);
            }
            if (ConfigurationManager.AppSettings["PasswordErrorLockCycle"] != null)
            {
                BaseSystemInfo.PasswordErrorLockCycle = int.Parse(ConfigurationManager.AppSettings["PasswordErrorLockCycle"]);
            }

            // BaseSystemInfo.CurrentLanguage = ConfigurationManager.AppSettings[BaseConfiguration.CURRENT_LANGUAGE];
            // BaseSystemInfo.Version = ConfigurationManager.AppSettings[BaseConfiguration.VERSION];

            // BaseSystemInfo.UseModulePermission = (ConfigurationManager.AppSettings[BaseConfiguration.USE_MODULE_PERMISSION].ToUpper(), true.ToString().ToUpper(), true);
            // BaseSystemInfo.UsePermissionScope = (ConfigurationManager.AppSettings[BaseConfiguration.USE_PERMISSIONS_COPE].ToUpper(), true.ToString().ToUpper(), true);
            // BaseSystemInfo.UseTablePermission = (ConfigurationManager.AppSettings[BaseConfiguration.USE_TABLE_PERMISSION].ToUpper(), true.ToString().ToUpper(), true);

            // BaseSystemInfo.Service = ConfigurationManager.AppSettings[BaseConfiguration.SERVICE];

            if (ConfigurationManager.AppSettings["RecordLogOnLog"] != null)
            {
                BaseSystemInfo.RecordLogOnLog = ConfigurationManager.AppSettings["RecordLogOnLog"].ToUpper().Equals(true.ToString().ToUpper());
            }
            if (ConfigurationManager.AppSettings["RecordLog"] != null)
            {
                BaseSystemInfo.RecordLog = ConfigurationManager.AppSettings["RecordLog"].ToUpper().Equals(true.ToString().ToUpper());
            }
            if (ConfigurationManager.AppSettings["LogOnStatistics"] != null)
            {
                BaseSystemInfo.LogOnStatistics = ConfigurationManager.AppSettings["LogOnStatistics"].ToUpper().Equals(true.ToString().ToUpper());
            }
            if (ConfigurationManager.AppSettings["ServerEncryptPassword"] != null)
            {
                BaseSystemInfo.ServerEncryptPassword = ConfigurationManager.AppSettings["ServerEncryptPassword"].ToUpper().Equals(true.ToString().ToUpper());
            }
            if (ConfigurationManager.AppSettings["ClientEncryptPassword"] != null)
            {
                BaseSystemInfo.ClientEncryptPassword = ConfigurationManager.AppSettings["ClientEncryptPassword"].ToUpper().Equals(true.ToString().ToUpper());
            }
            if (ConfigurationManager.AppSettings["CookieExpires"] != null)
            {
                BaseSystemInfo.CookieExpires = int.Parse(ConfigurationManager.AppSettings["CookieExpires"].ToString());
            }
            if (ConfigurationManager.AppSettings["CheckIPAddress"] != null)
            {
                BaseSystemInfo.CheckIPAddress = ConfigurationManager.AppSettings["CheckIPAddress"].ToUpper().Equals(true.ToString().ToUpper());
            }
            if (ConfigurationManager.AppSettings["CheckPasswordStrength"] != null)
            {
                BaseSystemInfo.CheckPasswordStrength = ConfigurationManager.AppSettings["CheckPasswordStrength"].ToUpper().Equals(true.ToString().ToUpper());
            }
            if (ConfigurationManager.AppSettings["UseOrganizePermission"] != null)
            {
                BaseSystemInfo.UseOrganizePermission = ConfigurationManager.AppSettings["UseOrganizePermission"].ToUpper().Equals(true.ToString().ToUpper());
            }

            // BaseSystemInfo.AutoLogOn = (ConfigurationManager.AppSettings[BaseConfiguration.AUTO_LOGON].ToUpper(), true.ToString().ToUpper(), true);
            // BaseSystemInfo.LogOnAssembly = ConfigurationManager.AppSettings[BaseConfiguration.LOGON_ASSEMBLY];
            // BaseSystemInfo.LogOnForm = ConfigurationManager.AppSettings[BaseConfiguration.LOGON_FORM];
            // BaseSystemInfo.MainForm = ConfigurationManager.AppSettings[BaseConfiguration.MAIN_FORM];
            if (ConfigurationManager.AppSettings["CheckOnLine"] != null)
            {
                BaseSystemInfo.CheckOnLine = ConfigurationManager.AppSettings["CheckOnLine"].ToUpper().Equals(true.ToString().ToUpper());
            }
            if (ConfigurationManager.AppSettings["AllowUserRegister"] != null)
            {
                BaseSystemInfo.AllowUserRegister = ConfigurationManager.AppSettings["AllowUserRegister"].ToUpper().Equals(true.ToString().ToUpper());
            }

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

            // BaseSystemInfo.LoadAllUser = (ConfigurationManager.AppSettings[BaseConfiguration.LOAD_All_USER].ToUpper(), true.ToString().ToUpper(), true);

            // 数据库连接
            if (ConfigurationManager.AppSettings["ServerDbType"] != null)
            {
                BaseSystemInfo.ServerDbType = DbHelper.GetDbType(ConfigurationManager.AppSettings["ServerDbType"]);
            }
            if (ConfigurationManager.AppSettings["UserCenterDbType"] != null)
            {
                BaseSystemInfo.UserCenterDbType = DbHelper.GetDbType(ConfigurationManager.AppSettings["UserCenterDbType"]);
                BaseSystemInfo.LoginLogDbType   = DbHelper.GetDbType(ConfigurationManager.AppSettings["UserCenterDbType"]);
                BaseSystemInfo.MessageDbType    = DbHelper.GetDbType(ConfigurationManager.AppSettings["UserCenterDbType"]);
            }
            if (ConfigurationManager.AppSettings["BusinessDbType"] != null)
            {
                BaseSystemInfo.BusinessDbType = DbHelper.GetDbType(ConfigurationManager.AppSettings["BusinessDbType"]);
            }
            if (ConfigurationManager.AppSettings["WorkFlowDbType"] != null)
            {
                BaseSystemInfo.WorkFlowDbType = DbHelper.GetDbType(ConfigurationManager.AppSettings["WorkFlowDbType"]);
            }
            if (ConfigurationManager.AppSettings["LoginLogDbType"] != null)
            {
                BaseSystemInfo.LoginLogDbType = DbHelper.GetDbType(ConfigurationManager.AppSettings["LoginLogDbType"]);
            }
            if (ConfigurationManager.AppSettings["MessageDbType"] != null)
            {
                BaseSystemInfo.MessageDbType = DbHelper.GetDbType(ConfigurationManager.AppSettings["MessageDbType"]);
            }
            if (ConfigurationManager.AppSettings["EncryptDbConnection"] != null)
            {
                BaseSystemInfo.EncryptDbConnection = ConfigurationManager.AppSettings["EncryptDbConnection"].ToUpper().Equals(true.ToString().ToUpper());
            }

            if (ConfigurationManager.AppSettings["UserCenterDbConnection"] != null)
            {
                BaseSystemInfo.UserCenterDbConnectionString = ConfigurationManager.AppSettings["UserCenterDbConnection"];
                BaseSystemInfo.LoginLogDbConnectionString   = 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["LoginLogDbConnection"] != null)
            {
                BaseSystemInfo.LoginLogDbConnectionString = ConfigurationManager.AppSettings["LoginLogDbConnection"];
            }
            // 对加密的数据库连接进行解密操作
            if (BaseSystemInfo.EncryptDbConnection)
            {
                BaseSystemInfo.UserCenterDbConnection = SecretUtil.Decrypt(BaseSystemInfo.UserCenterDbConnectionString);
                BaseSystemInfo.BusinessDbConnection   = SecretUtil.Decrypt(BaseSystemInfo.BusinessDbConnectionString);
                BaseSystemInfo.MessageDbConnection    = SecretUtil.Decrypt(BaseSystemInfo.MessageDbConnectionString);
                BaseSystemInfo.WorkFlowDbConnection   = SecretUtil.Decrypt(BaseSystemInfo.WorkFlowDbConnectionString);
                BaseSystemInfo.LoginLogDbConnection   = SecretUtil.Decrypt(BaseSystemInfo.LoginLogDbConnectionString);
            }
            else
            {
                BaseSystemInfo.UserCenterDbConnection = BaseSystemInfo.UserCenterDbConnectionString;
                BaseSystemInfo.BusinessDbConnection   = BaseSystemInfo.BusinessDbConnectionString;
                BaseSystemInfo.MessageDbConnection    = BaseSystemInfo.MessageDbConnectionString;
                BaseSystemInfo.WorkFlowDbConnection   = BaseSystemInfo.WorkFlowDbConnectionString;
                BaseSystemInfo.LoginLogDbConnection   = BaseSystemInfo.LoginLogDbConnectionString;
            }

            BaseSystemInfo.UserCenterReadDbConnection  = BaseSystemInfo.UserCenterDbConnection;
            BaseSystemInfo.UserCenterWriteDbConnection = BaseSystemInfo.UserCenterDbConnection;

            // 这里重新给静态数据库连接对象进行赋值
            // DotNet.Utilities.DbHelper.DbConnection = BaseSystemInfo.BusinessDbConnection;
            // DotNet.Utilities.DbHelper.DbType = BaseSystemInfo.BusinessDbType;

            // 这里是处理读写分离功能,读取数据与写入数据进行分离的方式
            if (ConfigurationManager.AppSettings["UserCenterReadDbConnection"] != null)
            {
                BaseSystemInfo.UserCenterReadDbConnection = ConfigurationManager.AppSettings["UserCenterReadDbConnection"];
            }
            if (ConfigurationManager.AppSettings["UserCenterWriteDbConnection"] != null)
            {
                BaseSystemInfo.UserCenterWriteDbConnection = ConfigurationManager.AppSettings["UserCenterWriteDbConnection"];
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// 从指定的文件读取配置项
        /// </summary>
        /// <param name="fileName">配置文件</param>
        public static void GetConfig(string fileName)
        {
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(fileName);

            // 客户信息配置
            if (Exists("CurrentUserName"))
            {
                BaseSystemInfo.CurrentUserName = GetValue(xmlDocument, "CurrentUserName");
            }
            if (Exists("CurrentPassword"))
            {
                BaseSystemInfo.CurrentPassword = GetValue(xmlDocument, "CurrentPassword");
            }
            if (Exists("MultiLanguage"))
            {
                BaseSystemInfo.MultiLanguage = (String.Compare(GetValue(xmlDocument, "MultiLanguage"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("CurrentLanguage"))
            {
                BaseSystemInfo.CurrentLanguage = GetValue(xmlDocument, "CurrentLanguage");
            }
            if (Exists("RememberPassword"))
            {
                BaseSystemInfo.RememberPassword = (String.Compare(GetValue(xmlDocument, "RememberPassword"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("AutoLogOn"))
            {
                BaseSystemInfo.AutoLogOn = (String.Compare(GetValue(xmlDocument, "AutoLogOn"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("ClientEncryptPassword"))
            {
                BaseSystemInfo.ClientEncryptPassword = (String.Compare(GetValue(xmlDocument, "ClientEncryptPassword"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("ServerEncryptPassword"))
            {
                BaseSystemInfo.ServerEncryptPassword = (String.Compare(GetValue(xmlDocument, "ServerEncryptPassword"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }

            // add by zgl
            if (Exists("CheckIPAddress"))
            {
                BaseSystemInfo.CheckIPAddress = (String.Compare(GetValue(xmlDocument, "CheckIPAddress"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("CheckOnLine"))
            {
                BaseSystemInfo.CheckOnLine = (String.Compare(GetValue(xmlDocument, "CheckOnLine"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("UseMessage"))
            {
                BaseSystemInfo.UseMessage = (String.Compare(GetValue(xmlDocument, "UseMessage"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("AllowUserRegister"))
            {
                BaseSystemInfo.AllowUserRegister = (String.Compare(GetValue(xmlDocument, "AllowUserRegister"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("RecordLog"))
            {
                BaseSystemInfo.RecordLog = (String.Compare(GetValue(xmlDocument, "RecordLog"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }

            BaseSystemInfo.CustomerCompanyName = GetValue(xmlDocument, "CustomerCompanyName");
            BaseSystemInfo.ConfigurationFrom   = BaseConfiguration.GetConfiguration(GetValue(xmlDocument, "ConfigurationFrom"));
            BaseSystemInfo.SoftName            = GetValue(xmlDocument, "SoftName");
            BaseSystemInfo.SoftFullName        = GetValue(xmlDocument, "SoftFullName");

            if (Exists("SystemCode"))
            {
                BaseSystemInfo.SystemCode = GetValue(xmlDocument, "SystemCode");
            }
            if (Exists("RootMenuCode"))
            {
                BaseSystemInfo.RootMenuCode = GetValue(xmlDocument, "RootMenuCode");
            }
            BaseSystemInfo.Version = GetValue(xmlDocument, "Version");

            if (Exists("UseOrganizePermission"))
            {
                BaseSystemInfo.UseOrganizePermission = (String.Compare(GetValue(xmlDocument, "UseOrganizePermission"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("UseUserPermission"))
            {
                BaseSystemInfo.UseUserPermission = (String.Compare(GetValue(xmlDocument, "UseUserPermission"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("UseModulePermission"))
            {
                BaseSystemInfo.UseModulePermission = (String.Compare(GetValue(xmlDocument, "UseModulePermission"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("UsePermissionItem"))
            {
                BaseSystemInfo.UsePermissionItem = (String.Compare(GetValue(xmlDocument, "UsePermissionItem"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("UseTableColumnPermission"))
            {
                BaseSystemInfo.UseTableColumnPermission = (String.Compare(GetValue(xmlDocument, "UseTableColumnPermission"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("UseTableScopePermission"))
            {
                BaseSystemInfo.UseTableScopePermission = (String.Compare(GetValue(xmlDocument, "UseTableScopePermission"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("UsePermissionScope"))
            {
                BaseSystemInfo.UsePermissionScope = (String.Compare(GetValue(xmlDocument, "UsePermissionScope"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("UseAuthorizationScope"))
            {
                BaseSystemInfo.UseAuthorizationScope = (String.Compare(GetValue(xmlDocument, "UseAuthorizationScope"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }
            if (Exists("HandwrittenSignature"))
            {
                BaseSystemInfo.HandwrittenSignature = (String.Compare(GetValue(xmlDocument, "HandwrittenSignature"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            }

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

            if (Exists("Service"))
            {
                BaseSystemInfo.Service = GetValue(xmlDocument, "Service");
            }
            if (Exists("LogOnForm"))
            {
                BaseSystemInfo.LogOnForm = GetValue(xmlDocument, "LogOnForm");
            }
            if (Exists("MainForm"))
            {
                BaseSystemInfo.MainForm = GetValue(xmlDocument, "MainForm");
            }

            int.TryParse(GetValue(xmlDocument, "OnLineLimit"), out BaseSystemInfo.OnLineLimit);

            // 打开数据库连接
            if (Exists("UserCenterDbType"))
            {
                BaseSystemInfo.UserCenterDbType = BaseConfiguration.GetDbType(GetValue(xmlDocument, "UserCenterDbType"));
            }
            if (Exists("BusinessDbType"))
            {
                BaseSystemInfo.BusinessDbType = BaseConfiguration.GetDbType(GetValue(xmlDocument, "BusinessDbType"));
            }
            if (Exists("WorkFlowDbType"))
            {
                BaseSystemInfo.WorkFlowDbType = BaseConfiguration.GetDbType(GetValue(xmlDocument, "WorkFlowDbType"));
            }
            BaseSystemInfo.EncryptDbConnection          = (String.Compare(GetValue(xmlDocument, "EncryptDbConnection"), "TRUE", true, CultureInfo.CurrentCulture) == 0);
            BaseSystemInfo.BusinessDbConnectionString   = GetValue(xmlDocument, "BusinessDbConnection");
            BaseSystemInfo.WorkFlowDbConnectionString   = GetValue(xmlDocument, "WorkFlowDbConnection");
            BaseSystemInfo.UserCenterDbConnectionString = GetValue(xmlDocument, "UserCenterDbConnection");
            if (BaseSystemInfo.EncryptDbConnection)
            {
                BaseSystemInfo.WorkFlowDbConnection   = SecretUtil.Decrypt(BaseSystemInfo.WorkFlowDbConnectionString);
                BaseSystemInfo.BusinessDbConnection   = SecretUtil.Decrypt(BaseSystemInfo.BusinessDbConnectionString);
                BaseSystemInfo.UserCenterDbConnection = SecretUtil.Decrypt(BaseSystemInfo.UserCenterDbConnectionString);
            }
            else
            {
                BaseSystemInfo.WorkFlowDbConnection   = BaseSystemInfo.WorkFlowDbConnectionString;
                BaseSystemInfo.BusinessDbConnection   = BaseSystemInfo.BusinessDbConnectionString;
                BaseSystemInfo.UserCenterDbConnection = BaseSystemInfo.UserCenterDbConnectionString;
            }

            if (Exists("ServiceUserName"))
            {
                BaseSystemInfo.ServiceUserName = GetValue(xmlDocument, "ServiceUserName");
            }
            if (Exists("ServicePassword"))
            {
                BaseSystemInfo.ServicePassword = GetValue(xmlDocument, "ServicePassword");
            }

            BaseSystemInfo.RegisterKey = GetValue(xmlDocument, "RegisterKey");

            // 错误报告相关
            BaseSystemInfo.ErrorReportTo           = GetValue(xmlDocument, "ErrorReportTo");
            BaseSystemInfo.ErrorReportMailUserName = GetValue(xmlDocument, "ErrorReportMailUserName");
            BaseSystemInfo.ErrorReportMailPassword = GetValue(xmlDocument, "ErrorReportMailPassword");
            // BaseSystemInfo.ErrorReportMailPassword = SecretUtil.Encrypt(BaseSystemInfo.ErrorReportMailPassword);
            BaseSystemInfo.ErrorReportMailPassword = SecretUtil.Decrypt(BaseSystemInfo.ErrorReportMailPassword);

            // 这里重新给静态数据库连接对象进行赋值
            // DotNet.Utilities.DbHelper.DbConnection = BaseSystemInfo.BusinessDbConnection;
            // DotNet.Utilities.DbHelper.DbType = BaseSystemInfo.BusinessDbType;
        }
Exemplo n.º 13
0
        /// <summary>
        /// 从配置信息获取配置信息
        /// </summary>
        /// <param name="configuration">配置</param>
        public static void GetConfig()
        {
            // 读取注册码
            BaseSystemInfo.RegisterKey = ConfigurationManager.AppSettings["RegisterKey"];

            // 客户信息配置
            if (ConfigurationManager.AppSettings["CustomerCompanyName"] != null)
            {
                BaseSystemInfo.CustomerCompanyName = ConfigurationManager.AppSettings["CustomerCompanyName"];
            }
            if (ConfigurationManager.AppSettings["ConfigurationFrom"] != null)
            {
                BaseSystemInfo.ConfigurationFrom = BaseConfiguration.GetConfiguration(ConfigurationManager.AppSettings["ConfigurationFrom"]);
            }
            if (ConfigurationManager.AppSettings["SoftName"] != null)
            {
                BaseSystemInfo.SoftName = ConfigurationManager.AppSettings["SoftName"];
            }
            if (ConfigurationManager.AppSettings["SoftFullName"] != null)
            {
                BaseSystemInfo.SoftFullName = ConfigurationManager.AppSettings["SoftFullName"];
            }
            if (ConfigurationManager.AppSettings["SystemCode"] != null)
            {
                BaseSystemInfo.SystemCode = ConfigurationManager.AppSettings["SystemCode"];
            }
            if (ConfigurationManager.AppSettings["RootMenuCode"] != null)
            {
                BaseSystemInfo.RootMenuCode = ConfigurationManager.AppSettings["RootMenuCode"];
            }
            if (ConfigurationManager.AppSettings["ServiceUserName"] != null)
            {
                BaseSystemInfo.ServiceUserName = ConfigurationManager.AppSettings["ServiceUserName"];
            }
            if (ConfigurationManager.AppSettings["ServicePassword"] != null)
            {
                BaseSystemInfo.ServicePassword = ConfigurationManager.AppSettings["ServicePassword"];
            }
            // BaseSystemInfo.CurrentLanguage = ConfigurationManager.AppSettings[BaseConfiguration.CURRENT_LANGUAGE];
            // BaseSystemInfo.Version = ConfigurationManager.AppSettings[BaseConfiguration.VERSION];

            // BaseSystemInfo.UseModulePermission = (ConfigurationManager.AppSettings[BaseConfiguration.USE_MODULE_PERMISSION].ToUpper(), true.ToString().ToUpper(), true);
            // BaseSystemInfo.UsePermissionScope = (ConfigurationManager.AppSettings[BaseConfiguration.USE_PERMISSIONS_COPE].ToUpper(), true.ToString().ToUpper(), true);
            // BaseSystemInfo.UseTablePermission = (ConfigurationManager.AppSettings[BaseConfiguration.USE_TABLE_PERMISSION].ToUpper(), true.ToString().ToUpper(), true);

            // BaseSystemInfo.Service = ConfigurationManager.AppSettings[BaseConfiguration.SERVICE];
            // BaseSystemInfo.RecordLog = (ConfigurationManager.AppSettings[BaseConfiguration.RECORD_LOG].ToUpper(), true.ToString().ToUpper(), true);

            if (ConfigurationManager.AppSettings["ServerEncryptPassword"] != null)
            {
                BaseSystemInfo.ServerEncryptPassword = ConfigurationManager.AppSettings["ServerEncryptPassword"].ToUpper().Equals(true.ToString().ToUpper());
            }
            if (ConfigurationManager.AppSettings["ClientEncryptPassword"] != null)
            {
                BaseSystemInfo.ClientEncryptPassword = ConfigurationManager.AppSettings["ClientEncryptPassword"].ToUpper().Equals(true.ToString().ToUpper());
            }
            if (ConfigurationManager.AppSettings["CheckIPAddress"] != null)
            {
                BaseSystemInfo.CheckIPAddress = ConfigurationManager.AppSettings["CheckIPAddress"].ToUpper().Equals(true.ToString().ToUpper());
            }

            // BaseSystemInfo.AutoLogOn = (ConfigurationManager.AppSettings[BaseConfiguration.AUTO_LOGON].ToUpper(), true.ToString().ToUpper(), true);
            // BaseSystemInfo.LogOnAssembly = ConfigurationManager.AppSettings[BaseConfiguration.LOGON_ASSEMBLY];
            // BaseSystemInfo.LogOnForm = ConfigurationManager.AppSettings[BaseConfiguration.LOGON_FORM];
            // BaseSystemInfo.MainForm = ConfigurationManager.AppSettings[BaseConfiguration.MAIN_FORM];

            if (ConfigurationManager.AppSettings["CheckOnLine"] != null)
            {
                BaseSystemInfo.CheckOnLine = ConfigurationManager.AppSettings["CheckOnLine"].ToUpper().Equals(true.ToString().ToUpper());
            }
            // BaseSystemInfo.LoadAllUser = (ConfigurationManager.AppSettings[BaseConfiguration.LOAD_All_USER].ToUpper(), true.ToString().ToUpper(), true);
            // BaseSystemInfo.AllowUserRegister = (ConfigurationManager.AppSettings[BaseConfiguration.ALLOW_USER_REGISTER].ToUpper(), true.ToString().ToUpper(), true);

            // 数据库连接
            if (ConfigurationManager.AppSettings["UserCenterDbType"] != null)
            {
                BaseSystemInfo.UserCenterDbType = BaseConfiguration.GetDbType(ConfigurationManager.AppSettings["UserCenterDbType"]);
            }
            if (ConfigurationManager.AppSettings["BusinessDbType"] != null)
            {
                BaseSystemInfo.BusinessDbType = BaseConfiguration.GetDbType(ConfigurationManager.AppSettings["BusinessDbType"]);
            }
            if (ConfigurationManager.AppSettings["WorkFlowDbType"] != null)
            {
                BaseSystemInfo.WorkFlowDbType = BaseConfiguration.GetDbType(ConfigurationManager.AppSettings["WorkFlowDbType"]);
            }
            if (ConfigurationManager.AppSettings["EncryptDbConnection"] != null)
            {
                BaseSystemInfo.EncryptDbConnection = ConfigurationManager.AppSettings["EncryptDbConnection"].ToUpper().Equals(true.ToString().ToUpper());
            }
            if (ConfigurationManager.AppSettings["BusinessDbConnection"] != null)
            {
                BaseSystemInfo.BusinessDbConnectionString = ConfigurationManager.AppSettings["BusinessDbConnection"];
            }
            if (ConfigurationManager.AppSettings["UserCenterDbConnection"] != null)
            {
                BaseSystemInfo.UserCenterDbConnectionString = ConfigurationManager.AppSettings["UserCenterDbConnection"];
            }
            if (ConfigurationManager.AppSettings["WorkFlowDbConnection"] != null)
            {
                BaseSystemInfo.WorkFlowDbConnectionString = ConfigurationManager.AppSettings["WorkFlowDbConnection"];
            }
            // 对加密的数据库连接进行解密操作
            if (BaseSystemInfo.EncryptDbConnection)
            {
                BaseSystemInfo.BusinessDbConnection   = SecretUtil.Decrypt(BaseSystemInfo.BusinessDbConnectionString);
                BaseSystemInfo.UserCenterDbConnection = SecretUtil.Decrypt(BaseSystemInfo.UserCenterDbConnectionString);
                BaseSystemInfo.WorkFlowDbConnection   = SecretUtil.Decrypt(BaseSystemInfo.WorkFlowDbConnectionString);
            }
            else
            {
                BaseSystemInfo.BusinessDbConnection   = BaseSystemInfo.BusinessDbConnectionString;
                BaseSystemInfo.UserCenterDbConnection = BaseSystemInfo.UserCenterDbConnectionString;
                BaseSystemInfo.WorkFlowDbConnection   = BaseSystemInfo.WorkFlowDbConnectionString;
            }

            // 这里重新给静态数据库连接对象进行赋值
            // DotNet.Utilities.DbHelper.DbConnection = BaseSystemInfo.BusinessDbConnection;
            // DotNet.Utilities.DbHelper.DbType = BaseSystemInfo.BusinessDbType;
        }