ComplianceServer/oldcode/WEB/Controllers/WeiXin/AliveServiceController.cs

88 lines
3.6 KiB
C#

using Ninject;
using System;
using System.Linq;
using System.Web.Mvc;
using WX.CRM.Common;
using WX.CRM.IBLL.Wx;
using WX.CRM.WebHelper;
namespace WX.CRM.WEB.Controllers.WeiXin
{
public class AliveServiceController : BaseController
{
private ValidationErrors errors = new ValidationErrors();
[Inject]
public IWX_ALIVE_SERVICE wx_AliveService_BL { get; set; }
[AuthorizeRedirect(Roles = InitRights.CONST_微信服务心跳)]
public ActionResult Index()
{
ToolBar tool = new ToolBar();
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights., userRightId);
tool.AllowButton(toolbtn);
ViewBag.ToolBar = tool;
Table tab = new Table("tablist");
tab.AddHeadCol("InnerUserId", "", "员工", true);
tab.AddHeadCol("GroupName", "", "销售组", true);
tab.AddHeadCol("ALIAS", "", "工作微信");
tab.AddHeadCol("LASTTIME", "", "最后更新时间", true);
tab.AddHeadCol("VERSION", "", "版本号", true);
tab.AddHeadCol("IMEI", "", "IMEI");
tab.AddHeadCol("PHONEMODE", "", "手机型号", true);
tab.AddHeadCol("status", "", "在线状态");
tab.AddHeadRow();
Pager pager = new Pager() { page = 1, rows = 2000 };
ViewBag.gridTable = tab.GetHead() + Pagination.GetPage(pager, "tablist", "2000");
var versionList = wx_AliveService_BL.GetVersions();
var phoneModeList = wx_AliveService_BL.GetPhoneModes();
ViewBag.versionList = versionList.Select(m => new SelectListItem() { Value = m, Text = m }).ToList();
ViewBag.phoneModeList = phoneModeList.Select(m => new SelectListItem() { Value = m, Text = m }).ToList();
ViewBag.inneruserid = UserId;
ViewBag.userGroupId = userGroupId;
ViewBag.saleDeptId = saleDeptId;
ViewBag.roleCodes = DataCacheHelper.GetCache().Get_RoleCodes(userRoleId);
return View();
}
[HttpPost]
[AuthorizeRedirect(Roles = InitRights.CONST_微信服务心跳)]
public JsonResult GetHtmlList(Pager pager, string version, string phoneMode, string groupId, decimal? eid, string alias, string columns, decimal? zaixian)
{
var list = wx_AliveService_BL.GetList(ref pager, version, phoneMode, groupId, eid, alias, zaixian);
Table table = new Table(columns, true);
foreach (var model in list)
{
table.AddCol(InnerUserHelper.Instance.GetEidAndTrueName(model.InnerUserId));
table.AddCol(model.GroupName);
table.AddCol(model.WX_Alive_Service.ALIAS);
table.AddCol(model.WX_Alive_Service.LASTTIME);
table.AddCol(model.WX_Alive_Service.VERSION);
table.AddCol(model.WX_Alive_Service.IMEI);
table.AddCol(model.WX_Alive_Service.PHONEMODE);
if (model.WX_Alive_Service.LASTTIME.HasValue && model.WX_Alive_Service.LASTTIME.Value.AddMinutes(15) > DateTime.Now)
{
table.AddCol("<font style=\"color:blue\">在线</span>");
}
else
{
table.AddCol("<font style=\"color:#AAAAAA\">离线</span>");
}
table.AddRow();
}
var json = new
{
totalPages = pager.totalPages,
totalRows = pager.totalRows,
rowsList = table.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
}
}