You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

274 lines
8.8 KiB

  1. using Learun.Util;
  2. using System.Data;
  3. using Learun.Application.TwoDevelopment.LR_Desktop;
  4. using System.Web.Mvc;
  5. using System.Collections.Generic;
  6. using System.Collections;
  7. using System;
  8. using System.Linq;
  9. namespace Learun.Application.Web.Areas.LR_Desktop.Controllers
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  13. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2021-04-23 16:58
  16. /// 描 述:消息提醒
  17. /// </summary>
  18. public class MessageRindController : MvcControllerBase
  19. {
  20. private MessageRindIBLL messageRindIBLL = new MessageRindBLL();
  21. private PsychologyReplyInfoIBLL psychologyReplyInfoIBLL = new PsychologyReplyInfoBLL();
  22. #region 视图功能
  23. /// <summary>
  24. /// 主页面
  25. /// <summary>
  26. /// <returns></returns>
  27. [HttpGet]
  28. public ActionResult Index()
  29. {
  30. return View();
  31. }
  32. /// <summary>
  33. /// 未读消息页面
  34. /// <summary>
  35. /// <returns></returns>
  36. [HttpGet]
  37. public ActionResult UnreadIndex()
  38. {
  39. ViewBag.Name = (LoginUserInfo.Get()).realName;
  40. return View();
  41. }
  42. /// <summary>
  43. /// 表单页
  44. /// <summary>
  45. /// <returns></returns>
  46. [HttpGet]
  47. public ActionResult Form()
  48. {
  49. return View();
  50. }
  51. #endregion
  52. #region 获取数据
  53. /// <summary>
  54. /// 获取页面显示列表数据
  55. /// </summary>
  56. /// <param name="pagination">分页参数</param>
  57. /// <param name="queryJson">查询参数</param>
  58. /// <returns></returns>
  59. [HttpGet]
  60. [AjaxOnly]
  61. public ActionResult GetPageList(string pagination, string queryJson)
  62. {
  63. Pagination paginationobj = pagination.ToObject<Pagination>();
  64. var data = messageRindIBLL.GetPageList(paginationobj, queryJson);
  65. var jsonData = new
  66. {
  67. rows = data,
  68. total = paginationobj.total,
  69. page = paginationobj.page,
  70. records = paginationobj.records
  71. };
  72. return Success(jsonData);
  73. }
  74. /// <summary>
  75. /// 获取未读的消息的数量
  76. /// </summary>
  77. /// <param name="pagination">分页参数</param>
  78. /// <param name="queryJson">查询参数</param>
  79. /// <returns></returns>
  80. [HttpGet]
  81. [AjaxOnly]
  82. public ActionResult GetCountForUnread()
  83. {
  84. var count = messageRindIBLL.GetCountForUnread();
  85. return Success(count);
  86. }
  87. /// <summary>
  88. /// 获取未读的消息
  89. /// </summary>
  90. /// <param name="pagination">分页参数</param>
  91. /// <param name="queryJson">查询参数</param>
  92. /// <returns></returns>
  93. [HttpGet]
  94. [AjaxOnly]
  95. public ActionResult GetListForUnread()
  96. {
  97. var data = messageRindIBLL.GetListForUnread();
  98. //心理咨询数据
  99. var PsychologyReplyData = psychologyReplyInfoIBLL.GetListForUnread().OrderBy(x => x.IsReply).OrderBy(x => x.CreateTime);
  100. List<Hashtable> list = new List<Hashtable>();
  101. foreach (var item in PsychologyReplyData)
  102. {
  103. var url = "/LR_Desktop/PsychologyReplyInfo/Index";
  104. var title = "心理咨询";
  105. //跳转地址
  106. if (item.Description == "学生")
  107. {
  108. url = "/EducationalAdministration/PsychologyInfo/Index";
  109. }
  110. else
  111. {
  112. if (item.State == 2)
  113. {
  114. title = "心理回复-辅导员";
  115. }
  116. if (item.State == 3)
  117. {
  118. title = "心理回复-分院";
  119. url = "/LR_Desktop/PsychologyReplyInfo/Index3";
  120. }
  121. else if (item.State == 4)
  122. {
  123. title = "心理回复-学工";
  124. url = "/LR_Desktop/PsychologyReplyInfo/Index4";
  125. }
  126. else if (item.State == 5)
  127. {
  128. title = "心理回复-总站";
  129. url = "/LR_Desktop/PsychologyReplyInfo/IndexFive";
  130. }
  131. else if (item.State == 6)
  132. {
  133. title = "心理回复-老师";
  134. url = "/LR_Desktop/PsychologyReplyInfo/IndexSix";
  135. }
  136. if (item.IsReply == 0)
  137. url = "/LR_Desktop/PsychologyReplyInfo/IndexReply";
  138. else
  139. title = "心理咨询";
  140. }
  141. Hashtable ht = new Hashtable();
  142. ht["MessageId"] = item.Id;
  143. ht["SenderName"] = "";
  144. ht["TheTitle"] = title;
  145. ht["TheContent"] = item.Concent;
  146. ht["ConnectionUrl"] = url + "?type=" + item.State + "&keyvalue=";
  147. ht["InstanceId"] = item.Id;
  148. ht["isReply"] = item.IsReply;
  149. list.Add(ht);
  150. }
  151. //获取未处理的维修任务
  152. foreach (var entity in data)
  153. {
  154. Hashtable ht = new Hashtable();
  155. ht["MessageId"] = entity.MessageId;
  156. ht["SenderName"] = entity.SenderName;
  157. ht["TheTitle"] = entity.TheTitle;
  158. ht["TheContent"] = entity.TheContent;
  159. ht["ConnectionUrl"] = entity.ConnectionUrl;
  160. ht["InstanceId"] = entity.InstanceId;
  161. ht["isReply"] = 1;
  162. list.Add(ht);
  163. }
  164. return ToJsonResult(list);
  165. }
  166. /// <summary>
  167. /// 获取表单数据
  168. /// </summary>
  169. /// <param name="keyValue">主键</param>
  170. /// <returns></returns>
  171. [HttpGet]
  172. [AjaxOnly]
  173. public ActionResult GetFormData(string keyValue)
  174. {
  175. var MessageRemindData = messageRindIBLL.GetMessageRemindEntity(keyValue);
  176. var jsonData = new
  177. {
  178. MessageRemind = MessageRemindData,
  179. };
  180. return Success(jsonData);
  181. }
  182. #endregion
  183. #region 提交数据
  184. /// <summary>
  185. /// 删除实体数据
  186. /// </summary>
  187. /// <param name="keyValue">主键</param>
  188. /// <returns></returns>
  189. [HttpPost]
  190. [AjaxOnly]
  191. public ActionResult DeleteForm(string keyValue)
  192. {
  193. messageRindIBLL.DeleteEntity(keyValue);
  194. return Success("删除成功!");
  195. }
  196. /// <summary>
  197. /// 保存实体数据(新增、修改)
  198. /// </summary>
  199. /// <param name="keyValue">主键</param>
  200. /// <param name="strEntity">实体</param>
  201. /// <returns></returns>
  202. [HttpPost]
  203. [ValidateAntiForgeryToken]
  204. [AjaxOnly]
  205. public ActionResult SaveForm(string keyValue, string strEntity)
  206. {
  207. MessageRemindEntity entity = strEntity.ToObject<MessageRemindEntity>();
  208. messageRindIBLL.SaveEntity(keyValue, entity);
  209. if (string.IsNullOrEmpty(keyValue))
  210. {
  211. }
  212. return Success("保存成功!");
  213. }
  214. /// <summary>
  215. /// 更改状态为已读
  216. /// </summary>
  217. /// <param name="keyValue">主键</param>
  218. /// <param name="strEntity">实体</param>
  219. /// <returns></returns>
  220. [HttpPost]
  221. [AjaxOnly]
  222. public ActionResult SaveReadSigns(string keyValue, string title)
  223. {
  224. if (!string.IsNullOrEmpty(keyValue))
  225. {
  226. if (title.Contains("心理咨询"))
  227. {
  228. psychologyReplyInfoIBLL.UpdateEntity(keyValue);
  229. }
  230. //else if (title.Contains("维修通知"))
  231. //{
  232. //}
  233. else
  234. {
  235. messageRindIBLL.SaveReadSigns(keyValue);
  236. }
  237. }
  238. return Success("保存成功!");
  239. }
  240. /// <summary>
  241. /// 更改状态为已读
  242. /// </summary>
  243. /// <param name="keyValue">主键</param>
  244. /// <returns></returns>
  245. [HttpPost]
  246. [AjaxOnly]
  247. public ActionResult SaveReadSignsByUserId()
  248. {
  249. var loginUserInfo = LoginUserInfo.Get();
  250. if (!string.IsNullOrEmpty(loginUserInfo.userId))
  251. {
  252. messageRindIBLL.SaveReadSignsByUserId(loginUserInfo.userId);
  253. }
  254. return Success("保存成功!");
  255. }
  256. #endregion
  257. }
  258. }