using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using QMFrameWork.Data; using QMFrameWork.WebUI.Attribute; using QMFrameWork.WebUI.DataSource; using QMAPP.Common.Web.Models; namespace QMAPP.Common.Web.Controllers { /// /// 智能感知文本控件 /// public class PerceptTextController : QController { #region 显示智能感知全部数据 /// /// 获取智能感知控件数据 /// /// 感知值 /// 数据 [HandleException] public ActionResult ShowPerceptData(string term) { string kind = Request.Params["kind"]; List parameters = new List(); string pList = Request.Params["paramList"]; string mode = Request.Params["mode"]; PerceptModel model = new PerceptModel(); try { model.rownumbers = false; model.url = string.Format("/PerceptText/GetPerceptData?kind={0}¶mList={1}&term={2}&mode=list", kind, pList, term); return View("ShowPerceptList", model); } catch (Exception ex) { throw ex; } } #endregion #region 获取智能感知控件数据 /// /// 获取智能感知控件数据 /// /// 感知值 /// 数据 [HandleException] public ActionResult GetPerceptData(string term) { // 添加:智能感知不区分大小写 李鹏飞 2015-03-12 开始 term = term.ToUpper(); // 添加:智能感知不区分大小写 李鹏飞 2015-03-12 结束 string kind = Request.Params["kind"]; List list = null; List parameters = new List(); string pList = Request.Params["paramList"]; string mode = Request.Params["mode"]; try { if (string.IsNullOrEmpty(pList) == false) { //转换参数格式 string[] ps = pList.Split("|".ToCharArray()); foreach (string p in ps) { if (p == "none") { parameters.Add(""); continue; } parameters.Add(p); } } //获取数据 list = new AppDataGeter().GetList(kind, parameters.ToArray()).ToList(); if (string.IsNullOrEmpty(mode) == true) { mode = ""; } foreach (QListItem item in list) { if (item.code != item.text) item.label = item.code + "|" + item.text; else item.label = item.text; } //过滤 switch (mode) { case "": list = list.Where(p => p.code.IndexOf(term) >= 0).ToList(); break; case "list": list = list.Where(p => p.code.IndexOf(term) >= 0).ToList(); break; case "is": list = list.Where(p => p.code == term.Trim()).ToList(); break; } if (mode == "list") { int totalCount = list.Count; //分页 PerceptModel seachModel = GetModel(); //获取前台分页设置信息 DataPage page = this.GetDataPage(seachModel); list = new DataPageManager().SplitPageByDataTable(list, page); //格式转换 DataGridResult result = new DataGridResult(); result.Total = totalCount; result.Rows = list.Select(t => new PerceptModel { id = t.id, code = t.code, text = t.text }).ToList(); ; return Content(result.GetJsonSource()); } else { return Content(QMFrameWork.Common.Serialization.JsonConvertHelper.GetSerializes(list)); } } catch (Exception ex) { throw ex; } } #endregion #region 多条件查询 [HandleException] public ActionResult ShowQueryMore(string kind, string idName, string contentName) { string kind1 = Request.Params["kind"]; List parameters = new List(); string pList = Request.Params["paramList"]; string mode1 = Request.Params["mode"]; QueryMoreModel obj = new QueryMoreModel(); try { obj.QueryType = idName; //obj.HidCom = contentName; //model.Url = string.Format("/PerceptText/GetPerceptData?kind={0}¶mList={1}&term={2}&mode=list", kind, pList, term); return View("ShowPerceptList1", obj); } catch (Exception ex) { throw ex; } } #region 下载模板 /// /// 下载导入模板 /// /// [HttpPost] public FilePathResult GetTemplate() { try { string path = AppDomain.CurrentDomain.BaseDirectory + "Temp/"; string fileName = "MoreQuery.xls"; return File(path + fileName, "application/vnd.ms-excel", Url.Encode("多条件查询导入模板.xls")); } catch (Exception ex) { throw ex; } } #endregion [HandleException] public ActionResult BackQueryMore(QueryMoreModel queryMore) { return this.GetJsViewResult(""); } #endregion } }