TG.WXCRM.V4/WEB/Controllers/Base/ActionLogController.cs

84 lines
2.8 KiB
C#

using Ninject;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web.Mvc;
using WX.CRM.Common;
using WX.CRM.IBLL.Base;
using WX.CRM.WebHelper;
namespace WX.CRM.WEB.Controllers.Base
{
public class ActionLogController : BaseController
{
[Inject]
public IBAS_ACTIONLOG bas_ActionLog_BL { get; set; }
[Inject]
public IBAS_ACTIONLOGCONFIG bas_ActionLogConfig_BL { get; set; }
[HttpGet]
[AuthorizeRedirect(Roles = InitRights.CONST_报表页面访问记录)]
public ActionResult CountIndex()
{
var tool = new ToolBar();
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.访, userRightId);
tool.AllowButton(toolbtn);
ViewBag.ToolBar = tool;
ViewBag.UrlNameList = bas_ActionLogConfig_BL.GetDistinctUrlName();
return View();
}
[HttpPost]
[AuthorizeRedirect(Roles = InitRights.CONST_报表页面访问记录)]
public JsonResult GetCountIndexHtml(string stime, string etime, string columns)
{
DataSet ds = bas_ActionLog_BL.CountActionLog(stime, etime);
List<CountActionLog> list = new List<CountActionLog>();
List<string> urlNameList = bas_ActionLogConfig_BL.GetDistinctUrlName();
DataTable dt = new DataTable();
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
dt = ds.Tables[0];
list = dt.ToList<CountActionLog>();
}
List<decimal> userList = list.GroupBy(m => m.UserId).Select(n => n.Key).ToList();
Table table = new Table("tablist");
if (userList != null)
{
foreach (var userId in userList)
{
table.AddCol(InnerUserHelper.Instance.GetEidAndTrueName(userId));
if (urlNameList != null)
{
foreach (var urlName in urlNameList)
{
var model = list.Where(m => m.UserId == userId && m.UrlName == urlName).SingleOrDefault();
table.AddCol(model != null ? model.Num : 0);
}
}
table.AddRow();
}
}
var json = new
{
rowsList = table.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
private class CountActionLog
{
public decimal UserId { get; set; }
public decimal ActionId { get; set; }
public decimal Num { get; set; }
public string UrlName { get; set; }
}
}
}