Beispiel #1
0
        /// <summary>
        /// 详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Detail(int id)
        {
            TLogsDebugLog debugLog = null;
            var           rs       = _debugLogService.GetDebugLogById(id);

            if (rs.ReturnCode == ReturnCodeType.Success)
            {
                debugLog = rs.Content;
            }

            return(View(debugLog));
        }
Beispiel #2
0
        /// <summary>
        /// 插入
        /// </summary>
        /// <param name="item">待插入的记录</param>
        public bool Insert(TLogsDebugLog item)
        {
            using (var conn = DapperHelper.CreateConnection())
            {
                var effectRows = conn.Execute(@"INSERT INTO dbo.t_logs_debug_log VALUES (@SystemCode ,@Source ,@MachineName ,@IpAddress ,@ProcessId ,@ProcessName ,@ThreadId,@ThreadName ,@AppdomainName ,@CreatedTime ,@Detail ,@Message, @ClientIp);", item);
                if (effectRows > 0)
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #3
0
        /// <summary>
        /// 依id查询
        /// </summary>
        /// <param name="id">id</param>
        /// <returns></returns>
        public TLogsDebugLog GetById(int id)
        {
            TLogsDebugLog result = null;

            using (var conn = DapperHelper.CreateConnection())
            {
                result = conn.Query <TLogsDebugLog>(@"SELECT  debugLogs.system_code AS SystemCode ,
                            debugLogs.machine_name AS MachineName ,
                            debugLogs.ip_address AS IpAddress ,
                            debugLogs.client_ip AS ClientIp,
                            debugLogs.process_id AS ProcessId ,
                            debugLogs.process_name AS ProcessName ,
                            debugLogs.thread_id AS ThreadId ,
                            debugLogs.thread_name AS ThreadName ,
                            debugLogs.appdomain_name AS AppdomainName ,
                            debugLogs.created_time AS CreatedTime ,
                            *
                    FROM    dbo.t_logs_debug_log AS debugLogs
                    WHERE   debugLogs.id = @Id;", new { @Id = id }).FirstOrDefault();
            }

            return(result);
        }
Beispiel #4
0
        /// <summary>
        /// 插入调试日志(批量)
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public ServiceResult <bool> AddDebugLogs(List <AddDebugLogRequest> list)
        {
            var result = new ServiceResult <bool>
            {
                ReturnCode = ReturnCodeType.Error
            };

            if (!list.HasValue())
            {
                result.ReturnCode = ReturnCodeType.Success;
                result.Content    = true;
                return(result);
            }

            //黑名单过滤
            var matchedDebugLogs          = new List <AddDebugLogRequest>();
            var debugLogBlackListCacheKey = "Log.Cache.DebugLogBlackList";
            var debugLogBlackList         = CacheHelper.Get(debugLogBlackListCacheKey) as List <TLogsDebugLogBlackList>;

            if (debugLogBlackList == null)
            {
                debugLogBlackList = _debugLogBlackListDao.GetAll();
                CacheHelper.Set(debugLogBlackListCacheKey, debugLogBlackList);
            }

            if (debugLogBlackList.HasValue())
            {
                foreach (var debugLog in list)
                {
                    var isMatchBlackList = IsMatchDebugLogBlackList(debugLog, debugLogBlackList);
                    if (isMatchBlackList)
                    {
                        matchedDebugLogs.Add(debugLog);
                    }
                }
            }

            list = list.Except(matchedDebugLogs).ToList();
            if (!list.HasValue())
            {
                result.ReturnCode = ReturnCodeType.Success;
                result.Content    = true;
                return(result);
            }

            //EmitMapper对象映射
            var           insertedDebugLogs = new List <TLogsDebugLog>();
            TLogsDebugLog insertedDebugLog  = null;

            foreach (var debugLog in list)
            {
                var mapper = ObjectMapperManager.DefaultInstance.GetMapper <AddDebugLogRequest, TLogsDebugLog>();
                insertedDebugLog = mapper.Map(debugLog);
                insertedDebugLogs.Add(insertedDebugLog);
            }

            var rs = _debugLogDao.BatchInsert(insertedDebugLogs);

            if (rs == true)
            {
                result.ReturnCode = ReturnCodeType.Success;
                result.Content    = true;
            }

            return(result);
        }