TG.WXCRM.V4/WEB/Controllers/WeiXin/ScreenRecordController.cs

114 lines
4.0 KiB
C#

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using WX.CRM.Common;
using WX.CRM.Common.Layui;
using WX.CRM.Common.StockHelper;
using WX.CRM.IBLL.Util;
using WX.CRM.Model.DTO;
using WX.CRM.Model.Enum;
using WX.CRM.WebHelper;
namespace WX.CRM.WEB.Controllers.WeiXin
{
public class ScreenRecordController : BaseController
{
private readonly ICACHE_Q cache_BL;
public readonly string webapi = "";
public ScreenRecordController(ICACHE_Q cache_BL)
{
this.cache_BL = cache_BL;
webapi = cache_BL.GetValue_Parameter("Zxd_WebApi");
//webapi = "http://localhost:7009";
}
[AuthorizeRedirect(Roles = InitRights.CONST_录屏列表)]
public ActionResult Index()
{
return View();
}
[HttpPost]
[AuthorizeRedirect(Roles = InitRights.CONST_录屏列表)]
public JsonResult GetHtmlList(Laypage pager, ScreenRecordRequest dto)
{
var layUidata = new LayuiData<ScreenRecordResponse>();
try
{
var url = $"{webapi}/Api/ScreenRecord/Page";
var appid = ConfigurationManager.AppSettings["appid"];
var para = $"AppId={appid}&Type={dto.Type}&Eid={dto.Eid}&Name={dto.Name}&ResId={dto.ResId}" +
$"&UserName={dto.UserName}&InitConnectStartTime={dto.InitConnectStartTime}" +
$"&InitConnectEndTime={dto.InitConnectEndTime}&PageIndex={pager.page}&PageSize={pager.limit}";
var result = Utility.GetData(url, para, Encoding.UTF8);
var data = JsonConvert.DeserializeObject<ApiResult<PageResult<ScreenRecordResponse>>>(result);
var list = new List<ScreenRecordResponse>();
if (data.Code == 0)
list = data.Data.Data.ToList();
layUidata.msg = "数据加载成功";
layUidata.code = 0;
layUidata.data = list;
layUidata.count = data.Data.Total;
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
layUidata.SetFail(1, "出现错误!" + ex.Message);
}
return Json(layUidata);
}
public JsonResult ScreenReocrdListHtml(string ResId)
{
Table tab = new Table("", true);
if (!string.IsNullOrEmpty(ResId))
{
var url = $"{webapi}/Api/ScreenRecord/Page";
var appid = ConfigurationManager.AppSettings["appid"];
var para = $"AppId={appid}&ResId={ResId}" +
$"&PageIndex=1&PageSize=1000";
var result = Utility.GetData(url, para, Encoding.UTF8);
var data = JsonConvert.DeserializeObject<ApiResult<PageResult<ScreenRecordResponse>>>(result);
var list = new List<ScreenRecordResponse>();
if (data.Code == 0)
list = data.Data.Data.ToList();
foreach (var model in list)
{
tab.AddCol(model.Id);
tab.AddCol(model.MasterEidStr);
tab.AddCol(model.MasterUmid);
tab.AddCol(model.MasterName);
tab.AddCol(model.MasterUserName);
tab.AddCol(model.SlaveEidStr);
tab.AddCol(model.SlaveUmid);
tab.AddCol(model.SlaveName);
tab.AddCol(model.SlaveUserName);
tab.AddCol(model.InitConnectTime);
tab.AddCol(model.RealStartTime);
tab.AddCol(model.RealEndTime);
tab.AddCol(model.RealLongTime);
tab.AddRow();
}
}
var json = new
{
rowsList = tab.GetRows()
};
return Json(json, JsonRequestBehavior.AllowGet);
}
}
}