Example #1
0
 /// <summary>
 /// 获取数据
 /// </summary>
 /// <param name="pageIndex"></param>
 /// <param name="pageSize"></param>
 /// <param name="total"></param>
 /// <param name="w_totalTime"></param>
 /// <returns></returns>
 public static List <SyLogMonitorList> SyLogMonitor_GetList(int pageIndex, int pageSize, out int total, decimal?w_totalTime, string controller)
 {
     total = 0;
     using (var db = new fz_bigdataEntities())
     {
         IQueryable <log_operation> dbList = db.log_operation.OrderByDescending(o => o.CreateTime).AsQueryable();
         if (!string.IsNullOrWhiteSpace(controller))
         {
             dbList = dbList.Where(w => w.ControllerName == controller);
         }
         if (w_totalTime != null)
         {
             dbList = dbList.Where(w => w.TotalTime > w_totalTime);
         }
         total = dbList.Count();
         return(dbList.Skip((pageIndex - 1) * pageSize).Take(pageSize).Select(s => new SyLogMonitorList
         {
             Id = s.Id,
             DType = s.Type,
             ControllerName = s.ControllerName,
             ActionName = s.ActionName,
             HttpMethod = s.HttpMethod,
             Url = s.Url,
             ResponseTime = s.ResponseTime,
             RenderTime = s.RenderTime,
             TotalTime = s.TotalTime,
             CreateIp = s.CreateIp,
             CreateTime = s.CreateTime,
             CreateUserId = s.CreateUserId,
             CreateUserName = s.CreateUserName,
             CreateAccount = s.CreateAccount
         }).ToList());
     }
 }
Example #2
0
        /// <summary>
        /// 写监控
        /// </summary>
        /// <param name="m"></param>
        /// <param name="dtype"></param>
        private static async Task SyLogMonitor_Add(SyLogMonitorAdd m, int dtype)
        {
            await Task.Run(() =>
            {
                try
                {
                    using (var db = new fz_bigdataEntities())
                    {
                        db.log_operation.Add(new log_operation
                        {
                            Id             = Guid.NewGuid().ToString(),
                            Type           = dtype,
                            ControllerName = m.ControllerName,
                            ActionName     = m.ActionName,
                            HttpMethod     = m.HttpMethod,
                            Url            = m.Url,
                            ResponseTime   = m.ResponseTime,
                            RenderTime     = m.RenderTime,
                            TotalTime      = m.ResponseTime + m.RenderTime,
                            CreateIp       = m.CreateIp,
                            CreateUserId   = m.CreateUserId,
                            CreateUserName = m.CreateUserName,
                            CreateAccount  = m.CreateAccount,
                            CreateTime     = DateTime.Now
                        });

                        db.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    LogHelper.WriteLog(string.Format("{0}", DateTime.Now), e);
                }
            });
        }
Example #3
0
 /// <summary>
 /// 获取Error数据
 /// </summary>
 /// <param name="pageIndex"></param>
 /// <param name="pageSize"></param>
 /// <param name="total"></param>
 /// <returns></returns>
 public static List <SyLogErrorList> SyLogError_GetList(int pageIndex, int pageSize, out int total, string controller)
 {
     total = 0;
     using (var db = new fz_bigdataEntities())
     {
         IQueryable <log_error> dbList = db.log_error.OrderByDescending(o => o.CreateTime);
         if (!string.IsNullOrWhiteSpace(controller))
         {
             dbList = dbList.Where(w => w.ControllerName == controller);
         }
         total = dbList.Count();
         return(dbList.Skip((pageIndex - 1) * pageSize).Take(pageSize).Select(s => new SyLogErrorList
         {
             Id = s.Id,
             DType = s.Type,
             ControllerName = s.ControllerName,
             ActionName = s.ActionName,
             HttpMethod = s.HttpMethod,
             Url = s.Url,
             Message = s.Message,
             CreateIp = s.CreateIp,
             CreateTime = s.CreateTime,
             CreateUserId = s.CreateUserId,
             CreateUserName = s.CreateUserName,
             CreateAccount = s.CreateAccount
         }).ToList());
     }
 }
Example #4
0
        /// <summary>
        /// 获取智慧校园操作日志
        /// </summary>
        /// <param name="sdate"></param>
        /// <param name="edate"></param>
        /// <returns></returns>
        public static List <RoomLogList> ClrLogMonitorWeb_GetListAll(DateTime?sdate, DateTime?edate)
        {
            DateTime _sdate = DateTime.Parse("1900-01-01");
            DateTime _edate = DateTime.Parse("1900-01-01");

            if (sdate != null)
            {
                _sdate = ((DateTime)sdate).Date;
            }
            if (edate != null)
            {
                _edate = ((DateTime)edate).Date;
            }
            using (var db = new fz_bigdataEntities())
            {
                IQueryable <data_room_log_operation> dbList = db.data_room_log_operation.OrderByDescending(o => o.CreateTime);
                if (sdate != null)
                {
                    dbList = dbList.Where(w => System.Data.Entity.DbFunctions.TruncateTime(w.CreateTime) >= _sdate);
                }
                if (edate != null)
                {
                    dbList = dbList.Where(w => System.Data.Entity.DbFunctions.TruncateTime(w.CreateTime) <= _edate);
                }
                return(dbList.Select(s => new RoomLogList
                {
                    Id = s.Id,
                    CreateTime = s.CreateTime,
                    CreateUserId = s.CreateUserId,
                    CreateUserType = s.CreateUserType,
                    OperId = s.OperId,
                    OperContent = s.OperContent
                }).ToList());
            }
        }
 public void Post([FromBody] Operator operatorInfo)
 {
     try
     {
         using (var db = new fz_bigdataEntities())
         {
             data_room_log_operation roomlog = new data_room_log_operation();
             roomlog.Id             = Guid.NewGuid().ToString();
             roomlog.CreateUserId   = operatorInfo.userId;
             roomlog.CreateUserType = operatorInfo.userType;
             roomlog.OperId         = operatorInfo.OperId;
             roomlog.OperContent    = operatorInfo.content;
             roomlog.CreateTime     = DateTime.Now;
             db.data_room_log_operation.Add(roomlog);
             db.SaveChanges();
         }
     }
     catch (Exception e)
     {
         LogHelper.WriteLog(string.Format("{0}", DateTime.Now), e);
     }
 }