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.Web.Models.Basic;
using QMAPP.FJC.Web.Models.EM;
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 EmMeterReadingsController : QController
{
#region 获取列表
///
/// 加载列表
///
/// 结果
[HandleException]
public ActionResult List(bool? callBack)
{
EmMeterReadingsModel seachModel = new EmMeterReadingsModel();
seachModel.STARTCREATEDATE = DateTime.Now.Date.AddMonths(-1).ToString("yyyy-MM-dd HH:mm:ss");
seachModel.ENDCREATEDATE = DateTime.Now.Date.AddDays(1).ToString("yyyy-MM-dd HH:mm:ss");
if (callBack == true)
TryGetSelectBuffer(out seachModel);
seachModel.rownumbers = false;
seachModel.url = "/EmMeterReadings/GetList";
return View("EmMeterReadingsList", seachModel);
}
///
/// 获取列表
///
/// 是否回调
/// 列表
[HandleException]
public ActionResult GetList(bool? callBack)
{
EmMeterReadingsModel seachModel = null;
DataPage page = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
EmMeterReadings condition = null;
DataResult pageResult = new DataResult();
try
{
//获取查询对象
seachModel = GetModel();
if (string.IsNullOrEmpty(seachModel.STARTCREATEDATE) || string.IsNullOrEmpty(seachModel.ENDCREATEDATE))
{
seachModel.STARTCREATEDATE = DateTime.Now.Date.AddMonths(-1).ToString("yyyy-MM-dd HH:mm:ss");
seachModel.ENDCREATEDATE = DateTime.Now.Date.AddDays(1).ToString("yyyy-MM-dd HH:mm:ss");
}
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer(seachModel);
}
#endregion
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
//page.PageSize = 15;
condition = CopyToModel(seachModel);
#region wcf服务统一接口
pageResult = wcfAgent.InvokeServiceFunction>("EmMeterReadingsBLL_GetList", condition, page);
if (pageResult.IsSuccess == false)
{
SetMessage(pageResult.Msg);
return List(true);
}
if (pageResult.IsSuccess)
{
page = pageResult.Result;
}
DateGridResult result = new DateGridResult();
result.Total = page.RecordCount;
result.Rows = JsonConvertHelper.GetDeserialize>(page.Result.ToString());
#endregion
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 统计
///
/// 结果
[HandleException]
public ActionResult Count(bool? callBack)
{
EmMeterCountModel seachModel = new EmMeterCountModel();
if (callBack == true)
TryGetSelectBuffer(out seachModel);
seachModel.rownumbers = false;
string ids = Request.Params["PID"];
string stime = Request.Params["STARTCREATEDATE"];
string etime = Request.Params["ENDCREATEDATE"];
string ftime = Request.Params["FLAG_TIME"];
seachModel.url = "/EmMeterReadings/GetCountList?PID=" + ids + "&STARTCREATEDATE=" + stime + "&ENDCREATEDATE=" + etime + "&FLAG_TIME=" + ftime;
return View("EmMeterReadingsCountList", seachModel);
}
///
/// 获取统计列表
///
/// 是否回调
/// 列表
[HandleException]
public ActionResult GetCountList(bool? callBack)
{
EmMeterCountModel seachModel = null;
DataPage page = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
EmMeterReadings 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"];
ids = ids.Replace(",", "");
string stime = Request.Params["STARTCREATEDATE"];
string etime = Request.Params["ENDCREATEDATE"];
string ftime = Request.Params["FLAG_TIME"];
condition.PID = ids;
condition.STARTCREATEDATE = stime;
condition.ENDCREATEDATE = etime;
condition.FLAG_TIME = ftime;
#region wcf服务统一接口
pageResult = wcfAgent.InvokeServiceFunction>("EmMeterReadingsBLL_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
}
}