ProjectInformationController.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using Bowin.Web.Controls.Mvc;
  2. using EMIS.CommonLogic.SystemServices;
  3. using EMIS.Entities;
  4. using EMIS.ViewModel;
  5. using EMIS.ViewModel.SystemView;
  6. using EMIS.Web.Controls;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Web;
  11. using System.Web.Mvc;
  12. namespace EMIS.Web.Controllers.ProjectShareManage
  13. {
  14. [Authorization]
  15. public class ProjectInformationController : Controller
  16. {
  17. public IAnnouncementServices AnnouncementServices { get; set; }
  18. /// <summary>
  19. /// 项目资讯页面
  20. /// </summary>
  21. /// <returns></returns>
  22. public ActionResult List()
  23. {
  24. return View();
  25. }
  26. [HttpPost]
  27. public ActionResult List(QueryParamsModel pararms)
  28. {
  29. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  30. //避开全选值
  31. if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  32. List<AnnouncementTypeView> typeList = AnnouncementServices.GetUsableAnnouncementTypeViewList().ToList();
  33. var type = typeList.Where(x => x.No == "05").FirstOrDefault();
  34. Guid? typeID = null;
  35. if (type != null)
  36. {
  37. typeID = type.AnnouncementTypeID;
  38. }
  39. return base.Json(AnnouncementServices.GetAnnouncementViewList(configuretView, (int)pararms.page, (int)pararms.rows, typeID));
  40. }
  41. [HttpGet]
  42. public ActionResult Edit(Guid? announcementID)
  43. {
  44. AnnouncementView announcementView = new AnnouncementView();
  45. if (announcementID != null && announcementID != Guid.Empty)
  46. {
  47. announcementView = AnnouncementServices.GetAnnouncementViewInfo(announcementID);
  48. }
  49. List<AnnouncementTypeView> typeList = AnnouncementServices.GetUsableAnnouncementTypeViewList().ToList();
  50. var type = typeList.Where(x => x.No == "05").FirstOrDefault();
  51. Guid? typeID = null;
  52. if (type != null)
  53. {
  54. typeID = type.AnnouncementTypeID;
  55. }
  56. announcementView.AnnouncementTypeID = typeID;
  57. return View(announcementView);
  58. }
  59. /// <summary>
  60. /// 保存
  61. /// </summary>
  62. /// <returns></returns>
  63. [HttpPost]
  64. public ActionResult Edit(AnnouncementView announcementView)
  65. {
  66. try
  67. {
  68. var roleList = DataGrid.GetTableData<RoleView>("dgRoleList");
  69. var userList = DataGrid.GetTableData<StudentUserView>("dgUserList");
  70. var roleIDList = roleList.Select(x => (Guid?)x.RoleID).ToList();
  71. var userIDList = userList.Select(x => (Guid?)x.UserID).ToList();
  72. var msg = "";
  73. Sys_Announcement Announcement = AnnouncementServices.Save(announcementView, roleIDList, userIDList);
  74. //if (announcementView.IsSendWXEdit)
  75. //{
  76. // var openIDList = WechatMPServices.GetOpenIDList(roleIDList, userIDList);
  77. // openIDList.Remove("null");
  78. // //暂时不考虑针对角色发送的消息
  79. // if (openIDList.Count() < userIDList.Count())
  80. // {
  81. // msg = "但有部分学生未在微信端登陆或未关注公众号,无法发送消息给他们!";
  82. // }
  83. // WechatHelper.SendAnnouncement(announcementView.Title, announcementView.textContent, openIDList, null, Announcement.CreateTime);
  84. //}
  85. return Json(new ReturnMessage()
  86. {
  87. IsSuccess = true,
  88. Message = "保存成功!" + msg
  89. });
  90. }
  91. catch (Exception ex)
  92. {
  93. return Json(new ReturnMessage()
  94. {
  95. IsSuccess = false,
  96. Message = "保存失败:" + ex.Message
  97. });
  98. }
  99. }
  100. /// <summary>
  101. /// 删除
  102. /// </summary>
  103. /// <param name="roleID"></param>
  104. /// <returns></returns>
  105. [HttpPost]
  106. public ActionResult Delete(string announcementIDs)
  107. {
  108. try
  109. {
  110. var announcementIDList = announcementIDs.Split(',').Select(x => (Guid?)new Guid(x)).ToList();
  111. AnnouncementServices.Delete(announcementIDList);
  112. return base.Json("删除成功!");
  113. }
  114. catch (Exception ex)
  115. {
  116. return base.Json("删除失败,原因:" + ex.Message + "。");
  117. }
  118. }
  119. }
  120. }