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 { /// /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园 /// Copyright (c) 2013-2018 北京泉江科技有限公司 /// 创建人:陈彬彬 /// 日 期:2017.04.01 /// 描 述:系统日志 /// public class LogController : MvcControllerBase { #region 视图功能 /// /// 日志管理 /// /// [HttpGet] public ActionResult Index() { return View(); } [HttpGet] public ActionResult ApiIndex() { return View(); } /// /// 清空 /// /// [HttpGet] public ActionResult Form() { return View(); } /// /// 详情页面 /// /// [HttpGet] public ActionResult DetailForm() { return View(); } /// /// 系统使用统计页面 /// /// [HttpGet] public ActionResult UseStatistics() { return View(); } /// /// 在线人员页面 /// /// [HttpGet] public ActionResult OnlineUserIndex() { return View(); } #endregion #region 获取数据 /// /// 分页查询 /// /// 分页参数 /// 查询条件函数 /// [HttpGet] [AjaxOnly] public ActionResult GetPageList(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var data = LogBLL.GetPageList(paginationobj, queryJson, ""); var jsonData = new { rows = data, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return JsonResult(jsonData); } /// /// 分页查询(本人数据) /// /// /// /// [HttpGet] [AjaxOnly] public ActionResult GetPageListByMy(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); 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 提交数据 /// /// 清空日志 /// /// 日志分类Id /// 保留时间段内 /// [HttpPost] [ValidateAntiForgeryToken] [AjaxOnly] public ActionResult SaveRemoveLog(int categoryId, string keepTime) { LogBLL.RemoveLog(categoryId, keepTime); return Success("清空成功。"); } #endregion #region 接收访问日志信息 /// /// 访问功能 /// /// 功能Id /// 功能模块 /// 访问路径 /// [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 扩展数据 /// /// 获取报表数据 /// /// 查询条件函数 /// [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); } /// /// 获取图表数据 /// /// /// public ActionResult GetUseChartList(string queryJson) { var categorydata = new List(); categorydata.Add(new YearGrade { value = "1", text = "登录记录" }); categorydata.Add(new YearGrade { value = "2", text = "操作记录" }); var categorydata2 = new List(); 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(); //登录记录饼图数据 var seriesData = new List(); //访问记录饼图数据 var seriesData2 = new List(); 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(); //柱状图数据 var seriesLineData = new List(); //x轴数据 var xAxis = new List(); 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(); 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); } /// /// 获取在线人员 /// /// 查询条件函数 /// [HttpGet] [AjaxOnly] public ActionResult GetOnlineUserList() { var data = LogBLL.GetOnlineUserList(); return JsonResult(data); } #endregion } }