Beispiel #1
0
        /// <summary>
        /// 统计页面
        /// </summary>
        /// <returns></returns>
        public ActionResult Welcome()
        {
            return(RunActionWhenLogin((loginuser) =>
            {
                var udal = new UserDal();
                ViewData["c1"] = udal.GetCount(null);

                var now = DateTime.Now;
                var reqdal = new ReqLogDal();
                reqdal.PrepareIQueryable((query) =>
                {
                    query = query.Where(x => x.UpdateTime < now).OrderByDescending(x => x.UpdateTime).Skip(0).Take(1000);
                    var avgreqtime = query.Average(x => x.ReqTime);
                    ViewData["avgreqtime"] = avgreqtime ?? 0;
                    return true;
                });

                /////////////////////////////////////////////

                var userdata = _IUserService.GetCountGroupBySex();
                if (!ValidateHelper.IsPlumpList(userdata))
                {
                    return GetJson(new { success = false });
                }
                ViewData["user_data"] = JsonHelper.ObjectToJson(new
                {
                    success = true,
                    legend_data = userdata.Select(x => x.Sex).ToArray(),
                    data = userdata.Select(x => new { value = x.Count, name = x.Sex })
                });
                return View();
            }));
        }
Beispiel #2
0
        public List <ReqLogModel> GetList(DateTime?start = null,
                                          string area    = null, string controller = null, string action = null,
                                          int count      = 50)
        {
            string key = Com.GetCacheKey("ReqLogBll.GetList",
                                         ConvertHelper.GetString(start), area, controller, action, count.ToString());

            return(Cache(key, () =>
            {
                var dal = new ReqLogDal();
                List <ReqLogModel> list = null;
                dal.PrepareIQueryable((query) =>
                {
                    if (start != null)
                    {
                        query = query.Where(x => x.UpdateTime > start.Value);
                    }
                    if (ValidateHelper.IsPlumpString(area))
                    {
                        query = query.Where(x => x.AreaName == area);
                    }
                    if (ValidateHelper.IsPlumpString(controller))
                    {
                        query = query.Where(x => x.ControllerName == controller);
                    }
                    if (ValidateHelper.IsPlumpString(action))
                    {
                        query = query.Where(x => x.ActionName == action);
                    }
                    list = query.OrderByDescending(x => x.ReqTime).Skip(0).Take(count).ToList();
                    return true;
                });
                return list;
            }));
        }
Beispiel #3
0
        public List <ReqLogGroupModel> GetGroupedList(DateTime?start = null, int count = 50)
        {
            string key = Com.GetCacheKey("ReqLogBll.GetGroupedList",
                                         ConvertHelper.GetString(start), count.ToString());

            return(Cache(key, () =>
            {
                var dal = new ReqLogDal();
                List <ReqLogGroupModel> list = null;
                dal.PrepareIQueryable((query) =>
                {
                    if (start != null)
                    {
                        query = query.Where(x => x.UpdateTime > start.Value);
                    }
                    list = query.GroupBy(x => new { x.AreaName, x.ControllerName, x.ActionName })
                           .Select(x => new ReqLogGroupModel()
                    {
                        AreaName = x.Key.AreaName,
                        ControllerName = x.Key.ControllerName,
                        ActionName = x.Key.ActionName,
                        ReqTime = x.Average(m => m.ReqTime),
                        ReqCount = x.Count()
                    })
                           .OrderByDescending(x => x.ReqTime)
                           .Skip(0).Take(count).ToList();
                    return true;
                });
                return list;
            }));
        }
Beispiel #4
0
        public List <ReqLogModel> GetList(DateTime?start = null,
                                          string area    = null, string controller = null, string action = null,
                                          int count      = 50)
        {
            var dal = new ReqLogDal();
            List <ReqLogModel> list = null;

            dal.PrepareIQueryable((query) =>
            {
                if (start != null)
                {
                    query = query.Where(x => x.UpdateTime > start.Value);
                }
                if (ValidateHelper.IsPlumpString(area))
                {
                    query = query.Where(x => x.AreaName == area);
                }
                if (ValidateHelper.IsPlumpString(controller))
                {
                    query = query.Where(x => x.ControllerName == controller);
                }
                if (ValidateHelper.IsPlumpString(action))
                {
                    query = query.Where(x => x.ActionName == action);
                }
                list = query.OrderByDescending(x => x.ReqTime).Skip(0).Take(count).ToList();
                return(true);
            });
            return(list);
        }
Beispiel #5
0
        public List <ReqLogGroupModel> GetGroupedList(DateTime?start = null, int count = 50)
        {
            var dal = new ReqLogDal();
            List <ReqLogGroupModel> list = null;

            dal.PrepareIQueryable((query) =>
            {
                if (start != null)
                {
                    query = query.Where(x => x.UpdateTime > start.Value);
                }
                list = query.GroupBy(x => new { x.AreaName, x.ControllerName, x.ActionName })
                       .Select(x => new ReqLogGroupModel()
                {
                    AreaName       = x.Key.AreaName,
                    ControllerName = x.Key.ControllerName,
                    ActionName     = x.Key.ActionName,
                    ReqTime        = x.Average(m => m.ReqTime),
                    ReqCount       = x.Count()
                })
                       .OrderByDescending(x => x.ReqTime)
                       .Skip(0).Take(count).ToList();
                return(true);
            });
            return(list);
        }
Beispiel #6
0
        public string AddLog(ReqLogModel model)
        {
            var err = CheckModel(model);

            if (ValidateHelper.IsPlumpString(err))
            {
                return(err);
            }
            var dal = new ReqLogDal();

            return(dal.Add(model) > 0 ? SUCCESS : "添加错误");
        }