Example #1
0
        private readonly string sql       = "";        // 日志sql语句
        public DbLogEventHandler(DbLogOptions dbLogOptions)
        {
            _dbLogOptions = dbLogOptions;
            if (_dbLogOptions.IsDbSharding)
            {
                switch (_dbLogOptions.DbShardingRule)
                {
                case 1:
                    tableName = tableName + "_" + DbShardingHelper.DayRule(DateTime.Now);
                    break;

                case 2:
                    tableName = tableName + "_" + DbShardingHelper.MonthRule(DateTime.Now);
                    break;
                }
            }
            sql = string.Format(@"INSERT INTO {0} (Id,AddTime,ClassName,ProjectName, LogTag, LogType, LogMessage, IP) 
                                      VALUES (@Id,@AddTime,@ClassName,@ProjectName, @LogTag, @LogType, @LogMessage, @IP)"
                                , tableName);
        }
 public DbLogEventHandler(DbLogOptions dbLogOptions)
 {
     _dbLogOptions = dbLogOptions;
 }