|
- using Learun.Application.Base.SystemModule;
- using Learun.Application.WorkFlow;
- using Learun.Util;
- using Learun.Util.Operat;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web.Mvc;
- using static Learun.Util.WebHelper;
-
- namespace Learun.Application.Web.Areas.LR_SystemModule.Controllers
- {
- /// <summary>
- /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
- /// Copyright (c) 2013-2018 北京泉江科技有限公司
- /// 创建人:陈彬彬
- /// 日 期:2017.04.01
- /// 描 述:系统日志
- /// </summary>
- public class LogController : MvcControllerBase
- {
- #region 视图功能
- /// <summary>
- /// 日志管理
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Index()
- {
- return View();
- }
- [HttpGet]
- public ActionResult ApiIndex()
- {
- return View();
- }
- /// <summary>
- /// 清空
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Form()
- {
- return View();
- }
- /// <summary>
- /// 详情页面
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult DetailForm()
- {
- return View();
- }
-
- /// <summary>
- /// 系统使用统计页面
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult UseStatistics()
- {
- return View();
- }
-
- /// <summary>
- /// 在线人员页面
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult OnlineUserIndex()
- {
- return View();
- }
- #endregion
-
- #region 获取数据
- /// <summary>
- /// 分页查询
- /// </summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="queryJson">查询条件函数</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetPageList(string pagination, string queryJson)
- {
-
- Pagination paginationobj = pagination.ToObject<Pagination>();
- var data = LogBLL.GetPageList(paginationobj, queryJson, "");
- var jsonData = new
- {
- rows = data,
- total = paginationobj.total,
- page = paginationobj.page,
- records = paginationobj.records,
- };
- return JsonResult(jsonData);
- }
- /// <summary>
- /// 分页查询(本人数据)
- /// </summary>
- /// <param name="pagination"></param>
- /// <param name="queryJson"></param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetPageListByMy(string pagination, string queryJson)
- {
-
- Pagination paginationobj = pagination.ToObject<Pagination>();
- UserInfo userInfo = LoginUserInfo.Get();
- var data = LogBLL.GetPageList(paginationobj, queryJson, userInfo.userId);
- var jsonData = new
- {
- rows = data,
- total = paginationobj.total,
- page = paginationobj.page,
- records = paginationobj.records,
- };
- return JsonResult(jsonData);
- }
- #endregion
-
- #region 提交数据
- /// <summary>
- /// 清空日志
- /// </summary>
- /// <param name="categoryId">日志分类Id</param>
- /// <param name="keepTime">保留时间段内</param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveRemoveLog(int categoryId, string keepTime)
- {
- LogBLL.RemoveLog(categoryId, keepTime);
- return Success("清空成功。");
- }
- #endregion
-
- #region 接收访问日志信息
- /// <summary>
- /// 访问功能
- /// </summary>
- /// <param name="moduleId">功能Id</param>
- /// <param name="moduleName">功能模块</param>
- /// <param name="moduleUrl">访问路径</param>
- /// <returns></returns>
- [AjaxOnly]
- [HttpPost]
- public ActionResult VisitModules(string moduleName, string moduleUrl)
- {
- LogEntity logEntity = new LogEntity();
- var userInfo = LoginUserInfo.Get();
-
- logEntity.F_CategoryId = 2;
- logEntity.F_OperateTypeId = ((int)OperationType.Visit).ToString();
- logEntity.F_OperateType = EnumAttribute.GetDescription(OperationType.Visit);
-
- logEntity.F_OperateAccount = userInfo.account + "(" + userInfo.realName + ")";
- logEntity.F_OperateUserId = userInfo.userId;
- logEntity.F_Module = moduleName;
- logEntity.F_ExecuteResult = 1;
- logEntity.F_ExecuteResultJson = "访问地址:" + moduleUrl;
- logEntity.F_Description = "PC端";
- logEntity.WriteLog();
- return Success("");
- }
- #endregion
-
- #region 接收操作日志信息
-
- #endregion
-
- #region 扩展数据
- /// <summary>
- /// 获取报表数据
- /// </summary>
- /// <param name="queryJson">查询条件函数</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetUseList(string queryJson, int CategoryId)
- {
- var data = LogBLL.GetList(queryJson, false);
-
- var jsonData = data.Where(x => x.F_CategoryId == CategoryId).GroupBy(x => new { x.Department, x.F_Description }).Select(x => new
- {
- category = CategoryId,
- department = x.Key.Department,
- source = x.Key.F_Description,
- total = x.Select(y => y.F_OperateUserId).Distinct().Count()
- });
- return JsonResult(jsonData);
- }
-
- /// <summary>
- /// 获取图表数据
- /// </summary>
- /// <param name="queryJson"></param>
- /// <returns></returns>
- public ActionResult GetUseChartList(string queryJson)
- {
- var categorydata = new List<YearGrade>();
- categorydata.Add(new YearGrade { value = "1", text = "登录记录" });
- categorydata.Add(new YearGrade { value = "2", text = "操作记录" });
- var categorydata2 = new List<YearGrade>();
- categorydata2.Add(new YearGrade { value = "1", text = "PC端" });
- categorydata2.Add(new YearGrade { value = "2", text = "移动端" });
-
- var usedata = LogBLL.GetList(queryJson, false).ToList();
- var usedataOfYear = LogBLL.GetList(queryJson, true).ToList();
-
- var aa = usedata.Where(x => x.F_CategoryId == 1 && x.F_Description != null).GroupBy(x => x.F_Description).Select(x => new WfSchemeReportModelOfPie()
- {
- name = x.Key,
- value = x.Select(y => y.F_OperateUserId).Distinct().Count()
- });
- var aa2 = usedata.Where(x => x.F_CategoryId == 2 && x.F_Description != null).GroupBy(x => x.F_Description).Select(x => new WfSchemeReportModelOfPie()
- {
- name = x.Key,
- value = x.Select(y => y.F_OperateUserId).Distinct().Count()
- });
- var bb = usedataOfYear.Where(x => x.F_OperateTime.HasValue).GroupBy(x => new { x.F_CategoryId, x.F_OperateTime.Value.Month }).Select(x => new
- {
- name = x.Key.F_CategoryId.ToString(),
- month = x.Key.Month,
- value = x.Select(y => y.F_OperateUserId).Distinct().Count()
- });
-
- //饼图项
- var legendData = new List<string>();
- //登录记录饼图数据
- var seriesData = new List<WfSchemeReportModelOfPie>();
- //访问记录饼图数据
- var seriesData2 = new List<WfSchemeReportModelOfPie>();
- foreach (var item in categorydata2)
- {
- legendData.Add(item.text);
- var model = new WfSchemeReportModelOfPie()
- {
- value = aa.FirstOrDefault(x => x.name == item.text) == null ? 0 : aa.FirstOrDefault(x => x.name == item.text).value,
- name = item.text
- };
- seriesData.Add(model);
- var model2 = new WfSchemeReportModelOfPie()
- {
- value = aa2.FirstOrDefault(x => x.name == item.text) == null ? 0 : aa.FirstOrDefault(x => x.name == item.text).value,
- name = item.text
- };
- seriesData2.Add(model2);
- }
- //柱状图项
- var legendDataOfLine = new List<string>();
- //柱状图数据
- var seriesLineData = new List<WfSchemeReportModelOfLine>();
- //x轴数据
- var xAxis = new List<string>();
- for (int i = 0; i < 12; i++)
- {
- xAxis.Add(string.Format("{0}月", i + 1));
- }
- foreach (var item in categorydata)
- {
- legendDataOfLine.Add(item.text);
- var monthData = new List<int>();
- for (int i = 0; i < 12; i++)
- {
- monthData.Add(0);
- }
- var linemodel = new WfSchemeReportModelOfLine()
- {
- name = item.text,
- type = "line",
- stack = "人数",
- data = monthData
- };
- var bbb = bb.Where(x => x.name == item.value);
- if (bbb.Any())
- {
- foreach (var bbbb in bbb)
- {
- linemodel.data[bbbb.month - 1] = bbbb.value;
- }
- }
- seriesLineData.Add(linemodel);
- }
-
- var jsonData = new
- {
- legendData = legendData,
- seriesData = seriesData,
- seriesData2 = seriesData2,
- legendDataOfLine = legendDataOfLine,
- seriesLineData = seriesLineData,
- xAxis = xAxis
- };
-
- return Success(jsonData);
- }
-
- /// <summary>
- /// 获取在线人员
- /// </summary>
- /// <param name="queryJson">查询条件函数</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetOnlineUserList()
- {
- var data = LogBLL.GetOnlineUserList();
- return JsonResult(data);
- }
- #endregion
- }
- }
|