private DBConfig LoadConfig() { string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Configuration\Data\DB.config"); if (File.Exists(filePath)) { DBConfig config = XmlSerializationHelper.LoadFromXml <DBConfig>(filePath); return(config); } else { throw new MSException(string.Format("Not found sql file {0}", filePath)); } }
private List <SQL> LoadConfigs() { List <SQL> list = new List <SQL>(); Regex regex = new Regex(@"@\w*", RegexOptions.IgnoreCase); DBConfig dbConfig = _dbConfigProvider.ConfigSetting(); if (dbConfig != null && dbConfig.SQLFileList != null) { lock (_obj) { foreach (string file in dbConfig.SQLFileList) { string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._configuration.ConfigPath, file); if (File.Exists(filePath)) { SQLConfig sqlConfig = XmlSerializationHelper.LoadFromXml <SQLConfig>(filePath); if (sqlConfig.SQLList != null) { foreach (SQL sql in sqlConfig.SQLList) { sql.ParameterNameList = new List <string>(); MatchCollection matches = regex.Matches(sql.Text.Trim()); if (matches != null && matches.Count > 0) { foreach (Match match in matches) { if (!sql.ParameterNameList.Exists(f => f.Trim().ToLower() == match.Value.Trim().ToLower())) { sql.ParameterNameList.Add(match.Value); } } } if (sql.TimeOut == 0) { DBConnection conn = _dbConfigProvider.ConfigSetting().DBConnectionList.Find(f => f.Key.ToLower().Trim() == sql.ConnectionKey.ToLower().Trim()); if (conn != null) { sql.TimeOut = conn.TimeOut; } else { sql.TimeOut = 180; } } } list.AddRange(sqlConfig.SQLList); } } else { throw new System.Exception(string.Format("Not found sql file {0}", filePath)); } } } } return(list); }