using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using QMFrameWork.WebUI.Attribute; using QMFrameWork.WebUI.DataSource; using QMFrameWork.Data; using QMAPP.Entity.Sys; using QMAPP.Web.Models.Sys; using QMAPP.Common.Web.Controllers; using QMFrameWork.Common.Serialization; namespace QMAPP.Web.Controllers { /// /// 作 用:文件管理控制层 /// 作 者:王丹丹 /// 编写日期:2015年03月17日 /// public class FileManageController : QController { #region 文件类别管理 #region 编辑 /// /// 编辑载入 /// /// 处理结果 [HandleException] public ActionResult FileTypeEdit() { FileTypeModel model = new FileTypeModel(); string ID = Request.Params["TYPENO"]; FileType entity = new FileType(); try { if (string.IsNullOrEmpty(ID) == false) { //修改获取原数据 entity.TYPENO = ID; #region 调用服务 QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent(); entity = agent.InvokeServiceFunction(QMAPP.ServicesAgent.SystemService.FileTypeBLL_Get.ToString(), entity); #endregion model = CopyToModel(entity); } return View(model); } catch (Exception ex) { throw ex; } } #endregion #region 保存 /// /// 保存 /// /// /// 处理结果 [HttpPost] [HandleException] public ActionResult Save(FileTypeModel saveModel) { try { FileType entity = new FileType(); ; int count = 0;//是否保存成功 TryUpdateModel(saveModel); //获取保存信息 entity = CopyToModel(saveModel); try { //新增 if (string.IsNullOrEmpty(entity.TYPENO) == true) { #region 调用服务 QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent(); count = agent.InvokeServiceFunction(QMAPP.ServicesAgent.SystemService.FileTypeBLL_Insert.ToString(), entity); #endregion } //修改 else { #region 调用服务 QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent(); //修改 count = agent.InvokeServiceFunction(QMAPP.ServicesAgent.SystemService.FileTypeBLL_Update.ToString(), entity); #endregion } } catch (Exception ex) { throw ex; } if (count == -1) { return this.GetJsViewResult(string.Format("parent.Search();parent.showTitle('{0}');parent.closeAppWindow1();", AppResource.FileTypeIsHave)); } else { return this.GetJsViewResult(string.Format("parent.Search();parent.showTitle('{0}');parent.closeAppWindow1();", AppResource.SaveMessge)); } } catch (Exception ex) { throw ex; } } #endregion #region 删除 /// /// 删除 /// /// 结果 [HttpPost] [HandleException] public ActionResult Delete() { FileType file = new FileType(); IList listModel = new List(); string selectKey = Request.Params["ids"]; int count = 0; try { #region 调用服务 QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent(); count = agent.InvokeServiceFunction(QMAPP.ServicesAgent.SystemService.FileTypeBLL_Delete.ToString(), selectKey); #endregion SetMessage(AppResource.DeleteMessage); return List(); } catch (Exception ex) { throw ex; } } #endregion #region 获取列表 /// /// 加载列表 /// /// 结果 [HandleException] public ActionResult List() { FileTypeModel seachModel = new FileTypeModel(); TryGetSelectBuffer(out seachModel); seachModel.rownumbers = false; seachModel.url = "/FileType/GetList"; return View("FileType", seachModel); } /// /// 获取列表 /// /// 是否回调 /// 列表 [HandleException] public ActionResult GetList(bool? callBack) { FileTypeModel seachModel = null; DataPage page = null; FileType condition = null; try { //获取查询对象 seachModel = GetModel(); #region 获取缓存值 if (callBack != null) { TryGetSelectBuffer(out seachModel); } else { //保存搜索条件 SetSelectBuffer(seachModel); } #endregion //获取前台分页设置信息 page = this.GetDataPage(seachModel); condition = CopyToModel(seachModel); #region 调用服务 QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent(); page = agent.InvokeServiceFunction(QMAPP.ServicesAgent.SystemService.FileTypeBLL_GetList.ToString(), condition, page); #endregion DataGridResult result = new DataGridResult(); result.Total = page.RecordCount; result.Rows = JsonConvertHelper.GetDeserialize>(page.Result.ToString()); return Content(result.GetJsonSource()); } catch (Exception ex) { throw ex; } } #endregion #endregion #region 获取文件类型树形控件 /// /// 获取文件类型树形控件 /// /// public ActionResult GetTreeData() { List list = new List(); List menus = new List(); try { #region 调用服务 QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent(); menus = agent.InvokeServiceFunction >(QMAPP.ServicesAgent.SystemService.FileTypeBLL_GetAllList.ToString()); #endregion if (menus != null && menus.Count != 0) { for (int i = 0; i < menus.Count; i++) { TreeNodeResult treenode = new TreeNodeResult(); treenode.Tid = menus[i].TYPENO.ToString(); treenode.Ttext = menus[i].TYPENAME.ToString(); if (menus[i].Orgas != null) { for (int j = 0; j < menus[i].Orgas.Count; j++) { TreeNodeResult cTreeNode = new TreeNodeResult(); cTreeNode.Tid = menus[i].Orgas[j].TYPENO.ToString(); cTreeNode.Ttext = menus[i].Orgas[j].TYPENAME.ToString(); treenode.AddchildNode(cTreeNode); } } list.Add(treenode); } list[0].TChecked = true; } return Content(TreeNodeResult.GetResultJosnS(list.ToArray())); } catch (Exception ex) { throw ex; } } #endregion } }