using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QMFrameWork.WebUI.Attribute;
using QMAPP.Common.Web.Controllers;
using QMAPP.FJC.Web.Models.FIS;
using QMFrameWork.Data;
using QMAPP.ServicesAgent;
using QMAPP.FJC.Entity.FIS;
using QMAPP.Entity;
using QMFrameWork.WebUI.DataSource;
using QMFrameWork.Common.Serialization;
namespace QMAPP.FJC.Web.Controllers
{
public class FISPhraseController : QController
{
#region 获取信息
///
/// 加载列表
///
/// 结果
[HandleException]
public ActionResult List(bool? callback)
{
FISAssemblyModel seachModel = new FISAssemblyModel();
seachModel.checkbox = false;
seachModel.pagination = false;
seachModel.singleSelect = true;
seachModel.ImmediateSearch = false;
if (callback == true)
TryGetSelectBuffer(out seachModel);
seachModel.url = "/FISPhrase/GetList";
return View("List", seachModel);
}
#endregion
#region 获取列表
///
/// 获取列表
///
/// 是否回调
/// 列表
[HandleException]
public ActionResult GetList(bool? callBack)
{
FISAssemblyModel seachModel = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
//wcfAgent.InvokeServiceFunction("FISPhraseBLL_PhraseSync");
FISAssembly condition = null;
try
{
//获取查询对象
seachModel = GetModel();
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer(seachModel);
}
#endregion
condition = CopyToModel(seachModel);
#region wcf服务统一接口
var list = wcfAgent.InvokeServiceFunction>("FISPhraseBLL_GetAssemblyList", condition);
DateGridResult result = new DateGridResult();
result.Total = list.Count;
result.Rows = list;
#endregion
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 编辑
///
/// 编辑载入
///
/// 处理结果
[HandleException]
public ActionResult Edit()
{
FISAssemblyModel model = new FISAssemblyModel();
string ID = Request.Params["PID"];
FISAssembly Entity = new FISAssembly();
ServiceAgent wcfAgent = this.GetServiceAgent();
try
{
if (string.IsNullOrEmpty(ID) == false)
{
//修改获取原数据
Entity.Id = ID;
Entity = wcfAgent.InvokeServiceFunction("FISPhraseBLL_GetAssembly", Entity);
model = CopyToModel(Entity);
}
return View("Edit", model);
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 保存
///
///
/// 处理结果
[HttpPost]
[HandleException]
[ValidateInput(false)]
public ActionResult Save(FISAssemblyModel saveModel)
{
FISAssembly Entity = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
try
{
Entity = CopyToModel(saveModel);
//修改
var result = wcfAgent.InvokeServiceFunction("FISPhraseBLL_UpdateAssembly", Entity);
if (result == 0)
{
SetMessage("保存失败!");
return View("Edit", saveModel);
}
return this.GetJsViewResult(string.Format("parent.List(1);parent.showTitle('{0}');parent.closeAppWindow1();", AppResource.SaveMessge));
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
///
/// 同步数据
///
///
/// 处理结果
[HttpPost]
[HandleException]
[ValidateInput(false)]
public ActionResult Sync()
{
ServiceAgent wcfAgent = this.GetServiceAgent();
try
{
var result = wcfAgent.InvokeServiceFunction("FISPhraseBLL_PhraseSync");
SetMessage("同步数据完成");
return List(true);
}
catch (Exception ex)
{
SetMessage("数据同步失败:"+ex.Message);
return List(true);
}
}
}
}