using Bowin.Web.Controls.Mvc; using EMIS.CommonLogic.SystemServices; using EMIS.Entities; using EMIS.ViewModel; using EMIS.ViewModel.SystemView; using EMIS.Web.Controls; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace EMIS.Web.Controllers.ProjectShareManage { [Authorization] public class ProjectInformationController : Controller { public IAnnouncementServices AnnouncementServices { get; set; } /// /// 项目资讯页面 /// /// public ActionResult List() { return View(); } [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); //避开全选值 if (configuretView.Attribute == DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = ""; List typeList = AnnouncementServices.GetUsableAnnouncementTypeViewList().ToList(); var type = typeList.Where(x => x.No == "05").FirstOrDefault(); Guid? typeID = null; if (type != null) { typeID = type.AnnouncementTypeID; } return base.Json(AnnouncementServices.GetAnnouncementViewList(configuretView, (int)pararms.page, (int)pararms.rows, typeID)); } [HttpGet] public ActionResult Edit(Guid? announcementID) { AnnouncementView announcementView = new AnnouncementView(); if (announcementID != null && announcementID != Guid.Empty) { announcementView = AnnouncementServices.GetAnnouncementViewInfo(announcementID); } List typeList = AnnouncementServices.GetUsableAnnouncementTypeViewList().ToList(); var type = typeList.Where(x => x.No == "05").FirstOrDefault(); Guid? typeID = null; if (type != null) { typeID = type.AnnouncementTypeID; } announcementView.AnnouncementTypeID = typeID; return View(announcementView); } /// /// 保存 /// /// [HttpPost] public ActionResult Edit(AnnouncementView announcementView) { try { var roleList = DataGrid.GetTableData("dgRoleList"); var userList = DataGrid.GetTableData("dgUserList"); var roleIDList = roleList.Select(x => (Guid?)x.RoleID).ToList(); var userIDList = userList.Select(x => (Guid?)x.UserID).ToList(); var msg = ""; Sys_Announcement Announcement = AnnouncementServices.Save(announcementView, roleIDList, userIDList); //if (announcementView.IsSendWXEdit) //{ // var openIDList = WechatMPServices.GetOpenIDList(roleIDList, userIDList); // openIDList.Remove("null"); // //暂时不考虑针对角色发送的消息 // if (openIDList.Count() < userIDList.Count()) // { // msg = "但有部分学生未在微信端登陆或未关注公众号,无法发送消息给他们!"; // } // WechatHelper.SendAnnouncement(announcementView.Title, announcementView.textContent, openIDList, null, Announcement.CreateTime); //} return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功!" + msg }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } /// /// 删除 /// /// /// [HttpPost] public ActionResult Delete(string announcementIDs) { try { var announcementIDList = announcementIDs.Split(',').Select(x => (Guid?)new Guid(x)).ToList(); AnnouncementServices.Delete(announcementIDList); return base.Json("删除成功!"); } catch (Exception ex) { return base.Json("删除失败,原因:" + ex.Message + "。"); } } } }