SysManagerController.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Web;
  8. using System.Web.Mvc;
  9. using PMS.BusinessModels.SysManager;
  10. using PMS.EntityModels.SysManager;
  11. using PMS.Interface;
  12. using PMS.Interface.SysManager;
  13. using QWPlatform.SystemLibrary;
  14. namespace PMS.WebUI.Controllers
  15. {
  16. /// <summary>
  17. /// 创 建 人:王海洋
  18. /// 创建日期:2018-12-10
  19. /// 功能描述:系统管理模块控制器
  20. /// </summary>
  21. public class SysManagerController : BaseController
  22. {
  23. ISystemModule systemModule = InterfaceFactory.CreateBusinessInstance<ISystemModule>();
  24. IButton button = InterfaceFactory.CreateBusinessInstance<IButton>();
  25. //配置服务
  26. ISysConfig sys_config = InterfaceFactory.CreateBusinessInstance<ISysConfig>();
  27. #region 模块管理
  28. // GET: SysManager
  29. public ActionResult ModuleList()
  30. {
  31. //toolbar
  32. ViewBag.toolbar = this.GetToolbar("toolbar");
  33. return View();
  34. }
  35. [HttpGet]
  36. public ActionResult ModuleQueryList()
  37. {
  38. var json = systemModule.GetTreeGridView();
  39. return Content(json, "application/json");
  40. }
  41. //获取module的树型json(所有菜单,包含未启用的菜单)
  42. public ActionResult GetModuleTree()
  43. {
  44. var json = systemModule.GetEasyUIJson();
  45. return Content(json, "application/json");
  46. }
  47. //获取所有菜单的目录(可用的)
  48. public ActionResult GetModuleTreeActive()
  49. {
  50. var json = systemModule.GetActiveTreemenu();
  51. return Content(json, "application/json");
  52. }
  53. //模块信息页面
  54. public ActionResult ModuleInfo(string id)
  55. {
  56. ViewBag.id = id;
  57. return View();
  58. }
  59. /// <summary>
  60. /// 获取模块信息(根据ID信息获取对应的json对象)
  61. /// </summary>
  62. /// <param name="id"></param>
  63. /// <returns></returns>
  64. [HttpGet]
  65. public ActionResult GetModuleInfo(string id)
  66. {
  67. var dt = systemModule.GetModuleInfo(int.Parse(id));
  68. return this.ResponseJson(System.Net.HttpStatusCode.OK, "读取成功", dt);
  69. }
  70. //编辑数据并保存(可能是新增加)
  71. [HttpPost]
  72. public ActionResult PostSaveModule(form_menu_model model)
  73. {
  74. //调用业务接口进行保存
  75. var r = systemModule.SaveInfo(model);
  76. if (r)
  77. {//保存成功
  78. return this.ResponseJson(System.Net.HttpStatusCode.OK, "保存成功");
  79. }
  80. else
  81. {//保存失败
  82. return this.ResponseJson(System.Net.HttpStatusCode.InternalServerError, "保存失败");
  83. }
  84. }
  85. //根据ID删除模块记录
  86. [HttpPost]
  87. public ActionResult DeleteModule(int id)
  88. {
  89. var r = systemModule.DeleteModule(id);
  90. if (r)
  91. {
  92. return this.ResponseJson(System.Net.HttpStatusCode.OK, "删除成功");
  93. }
  94. return this.ResponseJson(System.Net.HttpStatusCode.InternalServerError, "删除失败");
  95. }
  96. //模块按钮
  97. public ActionResult ModuleButtonList(int id)
  98. {
  99. ViewBag.id = id;
  100. return View();
  101. }
  102. //获取所有按钮列表(已启用)
  103. [HttpGet]
  104. public ActionResult ButtonListActive(int id)
  105. {
  106. DataTable dt = null;
  107. if (id <= 0)
  108. {//加载所有的功能清单
  109. dt = button.GetListJson(true);
  110. }
  111. else
  112. {//加载已授权的功能列表(模块ID)
  113. dt = systemModule.GetButtonListByID(id);
  114. }
  115. return Content(dt.ToEasyUIGridJson(0, null));
  116. }
  117. //对指定的模块进行授权(分配按钮到模块上)
  118. [HttpPost]
  119. public ActionResult PostAuthButtons(int id, string buttonids, string group)
  120. {
  121. bool r = systemModule.AuthButtons(id, buttonids, group);
  122. if (r)
  123. {
  124. return ResponseJson(System.Net.HttpStatusCode.OK, "分配按钮成功");
  125. }
  126. else
  127. {
  128. return ResponseJson(System.Net.HttpStatusCode.Forbidden, "分配按钮失败,填写数据不完整");
  129. }
  130. }
  131. //移除模块的指定按钮
  132. [HttpPost]
  133. public ActionResult PostRemoveAuthButtons(string ids)
  134. {
  135. bool r = systemModule.RemoveAuthButtons(ids);
  136. if (r)
  137. {
  138. return ResponseJson(System.Net.HttpStatusCode.OK, "撤销分配成功");
  139. }
  140. else
  141. {
  142. return ResponseJson(System.Net.HttpStatusCode.Forbidden, "分配按钮成功");
  143. }
  144. }
  145. //验证是否存在相同的模块名称
  146. public ActionResult CheckModuleNameExists(string name, int id)
  147. {
  148. var r = systemModule.CheckNameExists(name, id);
  149. if (r)
  150. {//存在,验证失败
  151. return Content("false");
  152. }
  153. //不存在,验证成功
  154. return Content("true");
  155. }
  156. #endregion
  157. #region 按钮管理
  158. public ActionResult Buttons()
  159. {//系统按钮
  160. ViewBag.toolbar = this.GetToolbar("toolbar");
  161. return View();
  162. }
  163. //编辑按钮页面
  164. public ActionResult ButtonInfo(string id)
  165. {
  166. ViewBag.id = id;
  167. return View();
  168. }
  169. //获取按钮信息
  170. [HttpGet]
  171. public ActionResult GetButtonInfo(int id)
  172. {
  173. string json = button.GetButtonInfoJson(id);
  174. return this.ResponseJson(System.Net.HttpStatusCode.OK, "加载成功", json);
  175. }
  176. //获取所有按钮列表
  177. [HttpGet]
  178. public ActionResult ButtonList()
  179. {
  180. var dt = button.GetListJson(false);
  181. return Content(dt.ToEasyUIGridJson(0, null));
  182. }
  183. //提交保存
  184. [HttpPost]
  185. public ActionResult PostButtonInfo(form_button_model model)
  186. {
  187. var r = button.PostSaveInfo(model);
  188. if (r)
  189. {//执行成功
  190. return this.ResponseJson(System.Net.HttpStatusCode.OK, "保存成功");
  191. }
  192. else
  193. {
  194. return this.ResponseJson(System.Net.HttpStatusCode.InternalServerError, "保存失败");
  195. }
  196. }
  197. //根据Button tag检查是否重复
  198. [HttpGet]
  199. public ActionResult GetButtonTag(string tag, string id)
  200. {
  201. return Content("");
  202. }
  203. #endregion
  204. #region 系统日志
  205. //返回系统日志信息
  206. public ActionResult SysLogIndex()
  207. {
  208. //读取当前目录下的log-data文件夹
  209. var logpath = Path.Combine(QWPlatform.SystemLibrary.Utils.Strings.AppDomainPath, "../log-data", DateTime.Now.ToString("yyyy-MM-dd") + ".log");
  210. if (System.IO.File.Exists(logpath))
  211. {//文件存在
  212. var textlines = System.IO.File.ReadAllLines(logpath, Encoding.Default);
  213. ViewBag.log = textlines;
  214. }
  215. return View();
  216. }
  217. #endregion
  218. #region 系统参数
  219. public ActionResult SystemSettigns()
  220. {
  221. var model = sys_config.GetEmailConfig();
  222. if (model == null)
  223. {
  224. model = new emailConfig();
  225. }
  226. return View(model);
  227. }
  228. //保存邮件配置信息
  229. public ActionResult SaveEmailConfig(emailConfig config)
  230. {
  231. var r = sys_config.SaveEmailConfig(config);
  232. return Content(r ? "1" : "0");
  233. }
  234. //返回配置信息的json
  235. public ActionResult GetEmailConfig1()
  236. {
  237. var model = sys_config.GetEmailConfig();
  238. return Content(model.ToJson(),"text/json");
  239. }
  240. #endregion
  241. #region 环节超时配置
  242. //返回问题流环节程配置
  243. [HttpPost]
  244. public ActionResult RingInfo()
  245. {
  246. return Content(sys_config.RingInfo(), "application/json");
  247. }
  248. //配置超时时间
  249. [HttpPost]
  250. public ActionResult TimeOutConfig(string id, string minute, string dealtime, string state)
  251. {
  252. return Content(sys_config.TimeOutConfig(id,minute,dealtime,state), "application/json");
  253. }
  254. public ActionResult Time_Window(string id )
  255. {
  256. ViewBag.id = id;
  257. return View();
  258. }
  259. public ActionResult LoadTime(string id)
  260. {
  261. return Content(sys_config.LoadTime(id), "application/json");
  262. }
  263. #endregion
  264. }
  265. }