using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QMAPP.Common.Web.Controllers;
using QMAPP.Entity;
using QMAPP.FJC.Entity.Basic;
using QMAPP.FJC.Entity.EM;
using QMAPP.FJC.Entity.Equipment;
using QMAPP.FJC.Web.Models.Basic;
using QMAPP.FJC.Web.Models.EM;
using QMAPP.FJC.Web.Models.Equipment;
using QMAPP.ServicesAgent;
using QMFrameWork.Common.Serialization;
using QMFrameWork.Data;
using QMFrameWork.WebUI.Attribute;
using QMFrameWork.WebUI.DataSource;
namespace QMAPP.FJC.Web.Controllers
{
public class UsageLogController : QController
{
#region 获取列表
///
/// 加载列表
///
/// 结果
[HandleException]
public ActionResult List(bool? callBack)
{
UsageLogModel seachModel = new UsageLogModel();
seachModel.START_OPERATION_DATE = DateTime.Now.Date.AddDays(-10).ToString("yyyy-MM-dd HH:mm:ss");
seachModel.END_OPERATION_DATE = DateTime.Now.Date.AddDays(1).ToString("yyyy-MM-dd HH:mm:ss");
if (callBack == true)
TryGetSelectBuffer(out seachModel);
seachModel.rownumbers = false;
seachModel.url = "/UsageLog/GetList";
return View("UsageLogList", seachModel);
}
///
/// 获取列表
///
/// 是否回调
/// 列表
[HandleException]
public ActionResult GetList(bool? callBack)
{
UsageLogModel seachModel = null;
DataPage page = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
UsageLogEntity condition = null;
DataResult pageResult = new DataResult();
try
{
//获取查询对象
seachModel = GetModel();
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer(seachModel);
}
#endregion
if (string.IsNullOrEmpty(seachModel.START_OPERATION_DATE) || string.IsNullOrEmpty(seachModel.END_OPERATION_DATE))
{
seachModel.START_OPERATION_DATE = DateTime.Now.Date.AddDays(-10).ToString("yyyy-MM-dd HH:mm:ss");
seachModel.END_OPERATION_DATE = DateTime.Now.Date.AddDays(1).ToString("yyyy-MM-dd HH:mm:ss");
}
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
condition = CopyToModel(seachModel);
#region wcf服务统一接口
pageResult = wcfAgent.InvokeServiceFunction>("UsageLogBLL_GetList", condition, page);
if (pageResult.IsSuccess == false)
{
SetMessage(pageResult.Msg);
return List(true);
}
DateGridResult result = new DateGridResult();
result.Total = pageResult.Result.RecordCount;
result.Rows = JsonConvertHelper.GetDeserialize>(pageResult.Result.Result.ToString());
#endregion
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 统计
///
/// 结果
[HandleException]
public ActionResult Count(bool? callBack)
{
UsageLogCountModel seachModel = new UsageLogCountModel();
if (callBack == true)
TryGetSelectBuffer(out seachModel);
seachModel.rownumbers = false;
string ids = Request.Params["PID"];
string stime = Request.Params["STARTDATE"];
string etime = Request.Params["ENDDATE"];
string ftime = Request.Params["FLAG_TIME"];
seachModel.url = "/UsageLog/GetCountList?PID=" + ids + "&STARTDATE=" + stime + "&ENDDATE=" + etime + "&FLAG_TIME=" + ftime;
return View("UsageLogCountList", seachModel);
}
///
/// 获取统计列表
///
/// 是否回调
/// 列表
[HandleException]
public ActionResult GetCountList(bool? callBack)
{
UsageLogCountModel seachModel = null;
DataPage page = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
UsageLogEntity condition = null;
DataResult pageResult = new DataResult();
try
{
//获取查询对象
seachModel = GetModel();
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer(seachModel);
}
#endregion
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
condition = CopyToModel(seachModel);
string ids = Request.Params["PID"];
string stime = Request.Params["STARTDATE"];
string etime = Request.Params["ENDDATE"];
string ftime = Request.Params["FLAG_TIME"];
condition.PID = ids;
condition.START_OPERATION_DATE = stime;
condition.END_OPERATION_DATE = etime;
condition.FLAG_TIME = ftime;
#region wcf服务统一接口
pageResult = wcfAgent.InvokeServiceFunction>("UsageLogBLL_GetCountList", condition, page);
if (pageResult.IsSuccess == false)
{
SetMessage(pageResult.Msg);
return List(true);
}
DateGridResult result = new DateGridResult();
result.Total = pageResult.Result.RecordCount;
result.Rows = JsonConvertHelper.GetDeserialize>(pageResult.Result.Result.ToString());
#endregion
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取统计标识下拉列表
///
/// 获取统计标识下拉列表
///
///
public ContentResult GetFlagTimeComboxSource()
{
ComboboxResult model = new ComboboxResult();
model.Add(new ComboboxItem { ID = "", Text = new DictController().EmptyItemTitle });
model.Add(new ComboboxItem { ID = "0", Text = "年" });
model.Add(new ComboboxItem { ID = "1", Text = "月" });
model.Add(new ComboboxItem { ID = "2", Text = "日" });
return Content(model.ToString());
}
#endregion
}
}