Beispiel #1
0
        public DbConfig(string tDbType, string tConnectionString, DbLogCallback tLogCallback = null, string tLogKeyword = null)
        {
            _DbType           = tDbType;
            _ConnectionString = tConnectionString;

            _LogCallback = tLogCallback;
            if (tLogKeyword != null)
            {
                _LogKeywords = new List <string>();
                if (!string.IsNullOrWhiteSpace(tLogKeyword))
                {
                    var arrAnd = tLogKeyword.Split('&');
                    if (arrAnd.Length >= 2)
                    {
                        _IsAndKeyword = true;
                        _LogKeywords.AddRange(arrAnd);
                    }
                    else
                    {
                        var arrOr = tLogKeyword.Split('|');
                        _LogKeywords.AddRange(arrOr);
                    }
                }
            }
        }
Beispiel #2
0
        public DbReadWrite(string keyRead, string keyWrite = null, DbLogCallback readLog = null, DbLogCallback writeLog = null)
        {
            if (string.IsNullOrWhiteSpace(keyWrite) || keyWrite.Trim().ToLower() == "null")
            {
                keyWrite = keyRead;
            }
            var dbread  = System.Configuration.ConfigurationManager.ConnectionStrings[keyRead];
            var dbwrite = System.Configuration.ConfigurationManager.ConnectionStrings[keyWrite];

            _DbReadConfig  = new DbConfig(dbread.ProviderName, dbread.ConnectionString);
            _DbWriteConfig = new DbConfig(dbwrite.ProviderName, dbwrite.ConnectionString);

            var tDbLogMode = AppSettings.DbLogMode;

            if (tDbLogMode != null)
            {
                tDbLogMode = tDbLogMode.Trim().ToLower();
                if (tDbLogMode == "web" || tDbLogMode == "1")
                {
                    dbLogMode = 1;
                }
                if (tDbLogMode == "all" || tDbLogMode == "2")
                {
                    dbLogMode = 2;
                }

                var logKeyword = AppSettings.DbLogKeyword;
                if (logKeyword != null)
                {
                    _DbReadConfigLog  = new DbConfig(dbread.ProviderName, dbread.ConnectionString, readLog, logKeyword);
                    _DbWriteConfigLog = new DbConfig(dbwrite.ProviderName, dbwrite.ConnectionString, writeLog, logKeyword);
                }
            }
        }