using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using QMFrameWork.WebUI.Attribute; using QMAPP.Web.Models.Sys; using QMAPP.Common.Web.Controllers; using QMFrameWork.Data; using QMAPP.Entity.Sys; using QMFrameWork.WebUI.DataSource; using QMFrameWork.Common.Serialization; using System.Collections; using System.Data; using QMAPP.ServicesAgent; namespace QMAPP.Web.Controllers { /// /// 问题类型控制器 /// 创建人:wangyf /// 创建时间:2015.03.30 /// public class SIProblemTypeController : QController { #region 添加 /// /// 添加载入 /// /// 处理结果 [HandleException] public ActionResult SIProblemTypeAdd() { try { return View("SIProblemTypeEdit", new SIProblemTypeModel()); } catch (Exception ex) { throw ex; } } #endregion #region 编辑 /// /// 编辑载入 /// /// 处理结果 [HandleException] public ActionResult SIProblemTypeEdit() { SIProblemTypeModel model = new SIProblemTypeModel(); string id = Request.Params["PID"]; SIProblemType entity = new SIProblemType(); try { if (string.IsNullOrEmpty(id) == false) { //修改获取原数据 entity.PID = id; QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent(); entity = agent.InvokeServiceFunction("SIProblemTypeBLL_Get", entity); model = CopyToModel(entity); } return View("SIProblemTypeEdit", model); } catch (Exception ex) { throw ex; } } /// /// 保存 /// /// /// 处理结果 [HttpPost] [HandleException] public ActionResult SIProblemTypeSave(SIProblemTypeModel saveModel) { SIProblemType info = null; try { info = CopyToModel(saveModel); QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent(); if (string.IsNullOrEmpty(info.PID) == true) { //新增 agent.InvokeServiceFunction("SIProblemTypeBLL_Insert", info); } else { //修改 agent.InvokeServiceFunction("SIProblemTypeBLL_Update", info); } return this.GetJsViewResult(string.Format("parent.List(1);parent.showTitle('{0}');parent.closeAppWindow1();" , AppResource.SaveMessge)); } catch (Exception ex) { throw ex; } } #endregion #region 判断类型名称是否已经存在 /// /// 判断类型名称是否已经存在 /// /// /// 处理结果 [HttpPost] [HandleException] public ActionResult CheckProblemTypeNameExist(SIProblemTypeModel saveModel) { SIProblemType info = null; bool result = false; try { info = CopyToModel(saveModel); QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent(); result = agent.InvokeServiceFunction("SIProblemTypeBLL_CheckProblemTypeNameExist", info); return Json(result); } catch (Exception ex) { throw ex; } } #endregion #region 删除 /// /// 删除 /// /// 结果 [HttpPost] [HandleException] public ActionResult SIProblemTypeDelete() { string selectKey = Request.Form["selectKey"]; try { if (!string.IsNullOrEmpty(selectKey)) { QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent(); agent.InvokeServiceFunction("SIProblemTypeBLL_Delete", selectKey); SetMessage(AppResource.DeleteMessage); } return SIProblemTypeList(); } catch (Exception ex) { throw ex; } } #endregion #region 获取列表 /// /// 加载列表 /// /// 结果 [HandleException] public ActionResult SIProblemTypeList() { SIProblemTypeModel seachModel = new SIProblemTypeModel(); TryGetSelectBuffer(out seachModel); seachModel.rownumbers = false; seachModel.url = "/SIProblemType/GetList"; return View("SIProblemTypeList", seachModel); } /// /// 获取列表 /// /// 是否回调 /// 列表 [HttpPost] [HandleException] public ActionResult GetList(bool? callBack) { List users = new List(); SIProblemTypeModel seachModel = null; DataPage page = new DataPage(); SIProblemType condition = null; try { //获取查询对象 seachModel = GetModel(); #region 获取缓存值 if (callBack != null) { TryGetSelectBuffer(out seachModel); } else { //保存搜索条件 SetSelectBuffer(seachModel); } #endregion //获取前台分页设置信息 page = this.GetDataPage(seachModel); condition = CopyToModel(seachModel); QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent(); page = agent.InvokeServiceFunction("SIProblemTypeBLL_GetList", condition, page); 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 #region 获取部门下的人员 /// /// 取得当前部门下的人员 /// /// 结果 [HttpPost] [HandleException] public ActionResult GetUserList() { string organId = Request["orgaID"].ToString(); QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent(); List userlist = agent.InvokeServiceFunction>("UserManageBLL_GetOrgaUserList", organId); //List userlist = userBll.GetOrgaUserList(organId); //插入第一行空行 if (userlist != null && userlist.Count > 0) { userlist.Insert(0, new User() { UserID = "", UserName = new DictController().EmptyItemTitle }); } return Content(QMFrameWork.Common.Serialization.JsonConvertHelper.GetSerializes(userlist)); } #endregion #region 导出excel /// /// 导出excel /// /// 结果 [HttpPost] [HandleException] public ActionResult ExportExcel() { SIProblemTypeModel seachModel = null; SIProblemType seachEntity= null; ServiceAgent wcfAgent = this.GetServiceAgent(); string selectKey = Request.Form["selectKey"]; DataTable exportDt = null; try { //获取查询条件 TryGetSelectBuffer(out seachModel); seachEntity = CopyToModel(seachModel); //获取数据 exportDt = wcfAgent.InvokeServiceFunction(QMAPP.ServicesAgent.SupportMutualService.SIProblemTypeBLL_GetExportData.ToString(), seachEntity); //导出 if (selectKey != "") { DataView dv = new DataView(exportDt); string strWhere = ""; string[] list = selectKey.Split(":".ToCharArray()); foreach (string pid in list) { strWhere += " PID='" + pid + "' or"; } if (strWhere != "") { strWhere = strWhere.Remove((strWhere.Length - 2), 2); } dv.RowFilter = strWhere; exportDt = dv.ToTable(); } exportDt.Columns.Add("CD"); exportDt.Columns.Add("UP"); //设置问题状态 foreach (DataRow dr in exportDt.Rows) { string cd = dr["CREATEDATE"].ToString(); if (!string.IsNullOrEmpty(cd)) { dr["CD"] = Convert.ToDateTime(cd).ToString("yyyy-MM-dd hh:mm:ss"); } string ud = dr["UPDATEDATE"].ToString(); if (!string.IsNullOrEmpty(ud)) { dr["UP"] = Convert.ToDateTime(cd).ToString("yyyy-MM-dd hh:mm:ss"); } } //导出 QMFrameWork.WebUI.Util.IEFileTool efTool = new QMFrameWork.WebUI.Util.IEFileTool(); return efTool.GetExcelFileResult("SIProblemType", "问题类型.xls", exportDt); } catch (Exception ex) { throw ex; } } #endregion #region 获取问题类型下拉列表数据 /// /// 获取问题类型下拉列表数据 /// /// [HttpPost] [HandleException] public ActionResult GetPTypeList() { ComboboxResult model = new ComboboxResult(); return Content(model.ToString()); } #endregion #region 组织机构信息下拉菜单 /// [HttpPost] [HandleException] public ActionResult GetOrgaList() { try { Orgaization orgaModel = new Orgaization(); List list = new List(); //list = userBll.GetUserOrgaList(""); QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent(); list = agent.InvokeServiceFunction>("UserManageBLL_GetUserOrgaList", ""); ComboboxResult model = new ComboboxResult(); //添加第一行空行 if (list != null && list.Count > 0) { model.Add(new ComboboxItem { ID = "", Text = new DictController().EmptyItemTitle }); } foreach (Orgaization o in list) { model.Add(new ComboboxItem { ID = o.OrgaID, Text = o.OrgaDESC }); } return Content(model.ToString()); } catch (Exception ex) { throw ex; } } #endregion } }