CommonController.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Autofac;
  7. using EMIS.Utility.OnlinePay;
  8. using Bowin.Common.JSON;
  9. using EMIS.Entities;
  10. using Bowin.Common.Linq.Entity;
  11. using EMIS.CommonLogic.AdministrativeOrgan;
  12. using EMIS.ViewModel;
  13. using EMIS.CommonLogic.SystemServices;
  14. using Bowin.Web.Controls.Mvc;
  15. using Bowin.Common.Utility;
  16. using System.Data;
  17. using EMIS.Utility;
  18. using EMIS.ViewModel.SystemView;
  19. using System.Text;
  20. using EMIS.CommonLogic.Specialtyclass;
  21. using System.IO;
  22. using System.Drawing.Imaging;
  23. using System.Reflection;
  24. namespace EMIS.Web.Controllers
  25. {
  26. [Authorization]
  27. public class CommonController : Controller
  28. {
  29. public IConfiguretermsInfoServices ConfiguretermsInfoServices { get; set; }
  30. public IBatchModifyServices BatchModifyServices { get; set; }
  31. public IMailVerifyServices MailVerifyServices { get; set; }
  32. public IUserServices UserServices { get; set; }
  33. public IContextMenuServices ContextMenuServices { get; set; }
  34. public IClassmajorServices ClassmajorServices { get; set; }
  35. public IControlItemServices ControlItemServices { get; set; }
  36. public IAnnouncementServices AnnouncementServices { get; set; }
  37. public IWechatMPServices WechatMPServices { get; set; }
  38. [HttpPost]
  39. [AllowAnonymous]
  40. public ActionResult DictionaryDropDown(DropdownListBindType? bindType, string dictionaryCode)
  41. {
  42. List<DropdownListItem> list = DictionaryHelper.GetDictionaryValue(dictionaryCode)
  43. .Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  44. .Select(x => new DropdownListItem { Text = x.Name, Value = x.Value.ToString() }).ToList();
  45. DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
  46. DropdownList.FormatDropdownItemList(dbt, list);
  47. return base.Json(list);
  48. }
  49. [HttpPost]
  50. public ActionResult SchoolYearDropDown(DropdownListBindType? bindType)
  51. {
  52. List<DropdownListItem> list = DictionaryHelper.GetDictionaryValue(typeof(EMIS.ViewModel.CF_Schoolyear).Name)
  53. .Select(x => new DropdownListItem { Text = x.Name, Value = x.Value.ToString() })
  54. .OrderByDescending(x => x.Value).ToList();
  55. DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
  56. DropdownList.FormatDropdownItemList(dbt, list);
  57. return base.Json(list);
  58. }
  59. [HttpPost]
  60. public ActionResult DynamicConditionDropDown(DropdownListBindType? bindType, string menuNo, string formClass)
  61. {
  62. if (menuNo == "")
  63. {
  64. menuNo = null;
  65. }
  66. var listAttribute = ConfiguretermsInfoServices.GetConfiguretermsInfo(menuNo, formClass);
  67. List<DropdownListItem> listdl = new List<DropdownListItem>();
  68. foreach (var item in listAttribute)
  69. {
  70. if (item.ControlType == "DictionaryDropDownList")
  71. {
  72. item.PostUrl = Url.Action("DictionaryDropDown") + "?dictionaryCode=" + item.DictionaryCode + "&bindType=" + (int)DropdownListBindType.SelectAll;
  73. item.ControlTextFiled = "Text";
  74. item.ControlValueFiled = "Value";
  75. }
  76. else if (!string.IsNullOrEmpty(item.PostUrl))
  77. {
  78. var temp = item.PostUrl.Split('?');
  79. if (temp.Length > 1)
  80. {
  81. item.PostUrl = item.PostUrl + "&bindType=" + (int)DropdownListBindType.SelectAll;
  82. }
  83. else
  84. {
  85. item.PostUrl = item.PostUrl + "?bindType=" + (int)DropdownListBindType.SelectAll;
  86. }
  87. item.PostUrl = Url.Content(item.PostUrl);
  88. }
  89. DropdownListItem ddl = new DropdownListItem { Text = item.Name, Value = item.ToJson() };
  90. listdl.Add(ddl);
  91. }
  92. DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
  93. DropdownList.FormatDropdownItemList(dbt, listdl);
  94. return base.Json(listdl);
  95. }
  96. [HttpPost]
  97. public JsonResult GetPositionConditionData(string menuClass, string mnu)
  98. {
  99. //var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  100. if (mnu == "")
  101. {
  102. mnu = null;
  103. }
  104. var configuretermsInfos = ConfiguretermsInfoServices.GetConfiguretermsInfo(mnu, menuClass);
  105. var result = new
  106. {
  107. Url = Url.Action("DynamicConditionDropDown") + "?menuNo=" + mnu + "&formClass=" + menuClass + "&bindType=" + (int)DropdownListBindType.None,
  108. TextField = "Text",
  109. ValueField = "Value",
  110. Condition = configuretermsInfos[0].listControl,
  111. };
  112. return Json(result, JsonRequestBehavior.AllowGet);
  113. }
  114. [HttpPost]
  115. public ActionResult GetPositionConditionComboGrid(string controlName, string dataCondition, string textField, string valueFiled,
  116. string url, string configuretermsExpandJson)
  117. {
  118. var configuretermsExpandList = configuretermsExpandJson.JsonToObject<List<Sys_ConfiguretermsExpand>>();
  119. List<DataGridColumn> columList = new List<DataGridColumn>();
  120. foreach (var configuretermsExpand in configuretermsExpandList)
  121. {
  122. BoundFieldColumn bfc = new BoundFieldColumn { FieldName = configuretermsExpand.ColumnValue, HeaderText = configuretermsExpand.ColumnName, Width = 0.1, Align = AlignStyle.Center };
  123. columList.Add(bfc);
  124. }
  125. ComboGridOptions comboGridOptions = new ComboGridOptions
  126. {
  127. TextField = textField,
  128. ValueField = valueFiled,
  129. ID = controlName,
  130. Name = controlName,
  131. EmptyText = "全部",
  132. GridOptions = new DataGridOptions
  133. {
  134. Columns = columList,
  135. IsCheckOnSelect = true,
  136. DataSourceUrl = Url.Content(url),
  137. IsPagination = true,
  138. IsShowRowNumbers = true,
  139. IsSingleSelect = false
  140. }
  141. };
  142. IDictionary<string, string> htmlAttributes = new Dictionary<string, string>() { { "data-condition", dataCondition } };
  143. return Json(MvcHtmlString.Create(Bowin.Web.Controls.Mvc.ComboGrid.CreateControl(comboGridOptions, htmlAttributes).Render()).ToHtmlString());
  144. }
  145. [HttpPost]
  146. public ActionResult BatchUpdateDropDown(DropdownListBindType? bindType, string menuNo)
  147. {
  148. List<DropdownListItem> listdl = new List<DropdownListItem>();
  149. string columnName = string.Empty;
  150. var listAttribute = BatchModifyServices.GetBatchModifyList(menuNo);
  151. foreach (var item in listAttribute)
  152. {
  153. DropdownListItem ddl = new DropdownListItem { Text = item.Name, Value = item.ToJson() };
  154. listdl.Add(ddl);
  155. }
  156. DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
  157. DropdownList.FormatDropdownItemList(dbt, listdl);
  158. return base.Json(listdl);
  159. }
  160. public ActionResult MsgShow(string msg, string url, string windowId = "")
  161. {
  162. ViewBag.msg = msg;
  163. ViewBag.url = url;
  164. ViewBag.WindowID = string.IsNullOrEmpty(windowId) ? Request["WindowID"] : windowId;
  165. return View();
  166. }
  167. public ActionResult Messager(string msg)
  168. {
  169. ViewBag.msg = msg;
  170. return View();
  171. }
  172. //弹出提示并关闭上级弹窗
  173. public ActionResult MsgShowAndClose(string msg, string WindowID)
  174. {
  175. ViewBag.msg = msg;
  176. ViewBag.WindowID = string.IsNullOrEmpty(WindowID) ? Request["WindowID"] : WindowID;
  177. return View();
  178. }
  179. //弹出提示并打开原先弹窗
  180. public ActionResult MsgShowAndOpen(string msg, string WindowID)
  181. {
  182. ViewBag.msg = msg;
  183. ViewBag.WindowID = string.IsNullOrEmpty(WindowID) ? Request["WindowID"] : WindowID;
  184. return View();
  185. }
  186. //弹出提示并打开原先弹窗
  187. public ActionResult MsgShowAndOpenAddUrl(string msg,string url, string WindowID,string title = "", int? height = null, int? width = null)
  188. {
  189. ViewBag.newtitle = title;
  190. ViewBag.msg = msg;
  191. ViewBag.WindowID = string.IsNullOrEmpty(WindowID) ? Request["WindowID"] : WindowID;
  192. ViewBag.url = url;
  193. ViewBag.Height = height;
  194. ViewBag.Width = width;
  195. return View();
  196. }
  197. /// <summary>
  198. /// 批量修改
  199. /// </summary>
  200. /// <returns></returns>
  201. [HttpPost]
  202. public ActionResult BatchModify()
  203. {
  204. string batchModifyName = Request["DropdownBatchModify"];
  205. var BatchModify = batchModifyName.JsonToObject<Sys_BatchModify>();
  206. string batchModifyValue = string.Empty;
  207. string hidBatchModify = Request["PL_hiddenBatchModify"];
  208. try
  209. {
  210. if (BatchModify.ControlType == "TextBox")
  211. batchModifyValue = Request[BatchModify.Value + "_TextBox"];
  212. else if (BatchModify.ControlType == "DropdownList")
  213. batchModifyValue = Request[BatchModify.Value + "_DropdownList"];
  214. else if (BatchModify.ControlType == "DictionaryDropDownList")
  215. batchModifyValue = Request[BatchModify.Value + "_DictionaryDropDownList"];
  216. else if (BatchModify.ControlType == "CheckBox")
  217. batchModifyValue = Request[BatchModify.Value + "_CheckBox"].Split(',').Length > 1 ? Request[BatchModify.Value + "_CheckBox"].Split(',')[0] : Request[BatchModify.Value + "_CheckBox"];
  218. else if (BatchModify.ControlType == "ComboGrid")
  219. batchModifyValue = Request[BatchModify.Value + "_ComboGrid"];
  220. else if (BatchModify.ControlType == "TextBoxDate")
  221. batchModifyValue = Request[BatchModify.Value + "_TextBoxDate"];
  222. else if (BatchModify.ControlType == "TextBoxDateTime")
  223. batchModifyValue = Request[BatchModify.Value + "_TextBoxDateTime"];
  224. else if (BatchModify.ControlType == "NumberBox")
  225. batchModifyValue = Request[BatchModify.Value + "_NumberBox"];
  226. if (BatchModify.ControlType != "TextBox")
  227. {
  228. if (batchModifyValue == "")
  229. {
  230. batchModifyValue = null;
  231. }
  232. else if (BatchModify.ControlType == "DropdownList" || BatchModify.ControlType == "DictionaryDropDownList")
  233. {
  234. if (batchModifyValue == DropdownList.PLEASE_SELECT.ToString())
  235. {
  236. batchModifyValue = null;
  237. }
  238. }
  239. }
  240. //获取修改的ID 转换成数组
  241. List<Guid> listID = new List<Guid>();
  242. for (int i = 0; i < hidBatchModify.Split(',').Length; i++)
  243. {
  244. string batchmodify = hidBatchModify.Split(',')[i];
  245. if (!string.IsNullOrEmpty(batchmodify))
  246. {
  247. listID.Add(new Guid(batchmodify));
  248. }
  249. }
  250. //List<string> funcationstringlist = BatchModifyServices.GetBatchModifyEvents(BatchModify.MNUID, BatchModify.MUNClass, BatchModify.Value);
  251. BatchModifyServices.BatchUpdate(BatchModify.MNUID, BatchModify.MUNClass, BatchModify.Value, (object)batchModifyValue, listID);
  252. return Json(new ReturnMessage { IsSuccess = true, Message = "批量修改成功。" });
  253. //return RedirectToAction("MsgShow", "Common", new
  254. //{
  255. // WindowID = "none",
  256. // msg = "批量修改成功。",
  257. // url = Url.Content(BatchModify.ReturnUrl).AddMenuParameter()
  258. //});
  259. }
  260. catch (Exception ex)
  261. {
  262. return Json(new ReturnMessage { IsSuccess = false, Message = "批量修改失败,原因:" + ex.Message });
  263. //return RedirectToAction("MsgShow", "Common", new
  264. //{
  265. // WindowID = "none",
  266. // msg = "批量修改失败,原因:" + ex.Message,
  267. // url = Url.Content(BatchModify.ReturnUrl).AddMenuParameter()
  268. //});
  269. }
  270. }
  271. public ActionResult UserRole(Guid userID)
  272. {
  273. return View();
  274. }
  275. public ActionResult RoleSelector()
  276. {
  277. return View();
  278. }
  279. public ActionResult CollegeSelector()
  280. {
  281. return View();
  282. }
  283. public ActionResult DepartmentSelector()
  284. {
  285. return View();
  286. }
  287. public ActionResult Uploader(string n, Guid? v, int? t)
  288. {
  289. string sessionCookieName = Const.LOCAL_SETTING_LOGIN_COOKIENAME;
  290. if (Request.Cookies[sessionCookieName] != null)
  291. ViewBag.hfcookieName = Request.Cookies[sessionCookieName].Value;
  292. if (v.HasValue)
  293. {
  294. ViewBag.name = n;
  295. ViewBag.value = v;
  296. ViewBag.type = t;
  297. }
  298. return View();
  299. }
  300. public ActionResult UploaderInit(Guid? id, string n)
  301. {
  302. Response.Cache.SetNoStore();
  303. List<FileUploadView> result = new List<FileUploadView>();
  304. string sessionName = FileUploadHelper.GetFileUploadSessionName(id.Value);
  305. if (Session[sessionName] == null)
  306. {
  307. Session[sessionName] = new List<FileUploadView>();
  308. }
  309. using (var scope = AutofacHelper.RequestLifetimeScope.BeginLifetimeScope())
  310. {
  311. IFileUploadServices uploadService = scope.ResolveNamed<IFileUploadServices>(n);
  312. result = uploadService.GetFileList(id);
  313. Session[sessionName] = result;
  314. }
  315. return Json(result, JsonRequestBehavior.AllowGet);
  316. }
  317. public ActionResult UploaderSave(FormCollection form)
  318. {
  319. Response.Cache.SetNoStore();
  320. try
  321. {
  322. FileUploadView upfile = new FileUploadView();
  323. var files = Request.Files;
  324. var formID = (!string.IsNullOrEmpty(Request["v"])) ? new Guid(Request["v"]) : (Guid?)null;
  325. string sessionName = FileUploadHelper.GetFileUploadSessionName(formID.Value);
  326. //检查文件扩展名字
  327. var postedFile = files["Filedata"]; //得到要上传文件
  328. if (postedFile.FileName == null)
  329. {
  330. return Json(new FileUploadView(), JsonRequestBehavior.AllowGet);
  331. }
  332. upfile.FileID = Function.NewPKGuid();
  333. string fileUrl = FileUploadHelper.UploadFile(postedFile);
  334. upfile.FileUrl = fileUrl;
  335. upfile.FileName = postedFile.FileName;
  336. upfile.FormID = formID;
  337. if (Session[sessionName] == null)
  338. {
  339. Session[sessionName] = new List<FileUploadView>();
  340. }
  341. ((List<FileUploadView>)Session[sessionName]).Add(upfile);
  342. return Json(upfile, JsonRequestBehavior.AllowGet);
  343. }
  344. catch
  345. {
  346. }
  347. return Json(new FileUploadView(), JsonRequestBehavior.AllowGet);
  348. }
  349. public ActionResult UploaderDel(Guid? id, Guid? fileid)
  350. {
  351. string result = "";
  352. if (id.HasValue)
  353. {
  354. List<FileUploadView> fileList = new List<FileUploadView>();
  355. string sessionName = FileUploadHelper.GetFileUploadSessionName(id.Value);
  356. if (Session[sessionName] == null)
  357. {
  358. Session[sessionName] = new List<FileUploadView>();
  359. }
  360. fileList = (List<FileUploadView>)Session[sessionName];
  361. var file = fileList.Where(x => x.FileID == fileid).FirstOrDefault();
  362. if (file != null)
  363. {
  364. fileList.Remove(file);
  365. FileUploadHelper.DeleteFile(file.FileUrl);
  366. }
  367. else
  368. {
  369. result = "删除文件失败!";
  370. }
  371. }
  372. else
  373. {
  374. result = "文件ID为空,删除文件失败!";
  375. }
  376. return Content(result);
  377. }
  378. public ActionResult UserVerify(Guid UserID, string Code)
  379. {
  380. if (MailVerifyServices.Verify(UserID, Code))
  381. {
  382. return View();
  383. }
  384. else
  385. {
  386. return RedirectToAction("MsgShow", "Common", new
  387. {
  388. msg = "邮件连接已失效或不正确,请重新申请。",
  389. url = Url.Content("~/Account/Login")
  390. });
  391. }
  392. }
  393. [HttpPost]
  394. public ActionResult UserVerify(ChangePasswordView changeView)
  395. {
  396. var userID = new Guid(Request["UserID"]);
  397. UserServices.ChangePassword(changeView, userID);
  398. return RedirectToAction("MsgShow", "Common", new
  399. {
  400. msg = "密码已经修改,请重新登录验证修改结果。",
  401. url = Url.Content("~/Account/Login")
  402. });
  403. }
  404. /// <summary>
  405. /// 添加教师
  406. /// </summary>
  407. /// <returns></returns>
  408. public ActionResult TeacherSelect()
  409. {
  410. return View();
  411. }
  412. /// <summary>
  413. /// 添加学生
  414. /// </summary>
  415. /// <returns></returns>
  416. public ActionResult StudentViewSelect() {
  417. return View();
  418. }
  419. /// <summary>
  420. /// 添加专业
  421. /// </summary>
  422. /// <returns></returns>
  423. public ActionResult SpecialtySelect()
  424. {
  425. return View();
  426. }
  427. /// <summary>
  428. /// 添加班级
  429. /// </summary>
  430. /// <returns></returns>
  431. public ActionResult ClassmajorSelect()
  432. {
  433. ViewBag.GrademajorID = Request.Params["GrademajorID"];
  434. return View();
  435. }
  436. /// <summary>
  437. /// 添加班级
  438. /// </summary>
  439. /// <returns></returns>
  440. public ActionResult ClassmajorViewSelect()
  441. {
  442. ViewBag.CollegeID = Request.Params["CollegeID"];
  443. ViewBag.GradeYearID = Request.Params["GradeYearID"];
  444. ViewBag.StandardID = Request.Params["StandardID"];
  445. return View();
  446. }
  447. /// <summary>
  448. /// 添加学生(学生发放专用)
  449. /// </summary>
  450. /// <returns></returns>
  451. public ActionResult StudentSelect()
  452. {
  453. ViewBag.studentDistributeID = Request.Params["studentDistributeID"];
  454. ViewBag.GrademajorID = Request.Params["GrademajorID"];
  455. return View();
  456. }
  457. public ActionResult ClassroomSelect()
  458. {
  459. return View();
  460. }
  461. public ActionResult CoursematerialSelect()
  462. {
  463. return View();
  464. }
  465. public ActionResult StudentBatchSelect()
  466. {
  467. return View();
  468. }
  469. /// <summary>
  470. ///
  471. /// </summary>
  472. /// <param name="formClass"></param>
  473. /// <param name="mnu"></param>
  474. /// <returns></returns>
  475. [HttpPost]
  476. public JsonResult GetContextMenuList(string formClass, string mnu)
  477. {
  478. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  479. //以后好好想想怎么控制按钮
  480. //var controlContextMenuList = ControlItemServices.GetNeedControlContextMenuNo().Where(x => x.MenuNo == mnu).ToList();
  481. var contextMenuList = ContextMenuServices.GetContextMenuListByUserAndRoleID((mnu == "" ? null : mnu), formClass, user.UserID, user.RoleID);
  482. var result = contextMenuList.OrderBy(x => x.SeqNo).Select(x => new
  483. {
  484. Name = x.ContextMnuNo,
  485. Text = x.Title,
  486. Icon = x.IconName,
  487. OnClick = x.Scripts
  488. })
  489. .ToList();
  490. return Json(result, JsonRequestBehavior.AllowGet);
  491. }
  492. /// <summary>
  493. /// 审核历史页面
  494. /// </summary>
  495. /// <returns></returns>
  496. public ActionResult ApproveStatus()
  497. {
  498. return View();
  499. }
  500. /// <summary>
  501. /// 审批页面
  502. /// </summary>
  503. /// <returns></returns>
  504. public ActionResult ApproveHandler()
  505. {
  506. return View();
  507. }
  508. /// <summary>
  509. ///
  510. /// </summary>
  511. /// <returns></returns>
  512. public ActionResult ReportViewer()
  513. {
  514. return View();
  515. }
  516. public ActionResult UserAnnouncementSend()
  517. {
  518. return View(new AnnouncementView());
  519. }
  520. [HttpPost]
  521. public ActionResult UserAnnouncementSend(AnnouncementView announcementView)
  522. {
  523. var userIDList = (Request.Form["UserIDs"] ?? "").Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  524. try
  525. {
  526. var msg = "";
  527. Sys_Announcement Announcement = AnnouncementServices.UserAnnouncementSave(announcementView, userIDList);
  528. if (announcementView.IsSendWXEdit)
  529. {
  530. var openIDList = WechatMPServices.GetOpenIDList(null, userIDList);
  531. if (openIDList.Count() < userIDList.Count())
  532. {
  533. msg = "但有部分学生未在微信端登陆或未关注公众号,无法发送消息给他们!";
  534. }
  535. WechatHelper.SendAnnouncement(announcementView.Title, announcementView.textContent, openIDList, null, Announcement.CreateTime);
  536. }
  537. return Json(new ReturnMessage()
  538. {
  539. IsSuccess = true,
  540. Message = "发送成功。"+ msg
  541. });
  542. }
  543. catch (Exception ex)
  544. {
  545. return Json(new ReturnMessage()
  546. {
  547. IsSuccess = false,
  548. Message = "发送失败:" + ex.Message
  549. });
  550. }
  551. }
  552. public ActionResult UserAnnouncementSendGDCX()
  553. {
  554. return View(new AnnouncementView());
  555. }
  556. [HttpPost]
  557. public ActionResult UserAnnouncementSendGDCX(AnnouncementView announcementView)
  558. {
  559. var userIDList = (Request.Form["UserIDs"] ?? "").Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  560. try
  561. {
  562. var msg = "";
  563. Sys_Announcement Announcement = AnnouncementServices.UserAnnouncementSave(announcementView, userIDList);
  564. if (announcementView.IsSendWXEdit)
  565. {
  566. var ann = AnnouncementServices.GetAnnouncementViewInfo(Announcement.AnnouncementID);
  567. var openIDList = WechatMPServices.GetOpenIDList(null, userIDList);
  568. if (openIDList.Count() < userIDList.Count())
  569. {
  570. msg = "但有部分学生未在微信端登陆或未关注公众号,无法发送消息给他们!";
  571. }
  572. WechatHelper.SendAnnouncementGDCX(announcementView.Title, announcementView.textContent, ann.CreateUserName, openIDList, null, Announcement.CreateTime);
  573. }
  574. return Json(new ReturnMessage()
  575. {
  576. IsSuccess = true,
  577. Message = "发送成功。" + msg
  578. });
  579. }
  580. catch (Exception ex)
  581. {
  582. return Json(new ReturnMessage()
  583. {
  584. IsSuccess = false,
  585. Message = "发送失败:" + ex.Message
  586. });
  587. }
  588. }
  589. [AllowAnonymous]
  590. public ActionResult ResImage(string key)
  591. {
  592. var context = this.HttpContext;
  593. var image = RSI.Get(key);
  594. context.Response.Buffer = true;
  595. context.Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);
  596. context.Response.Expires = 0;
  597. context.Response.CacheControl = "no-cache";
  598. context.Response.AppendHeader("Pragma", "No-Cache");
  599. image.Save(context.Response.OutputStream, image.RawFormat);
  600. Type imageFormatType = typeof(ImageFormat);
  601. System.Reflection.PropertyInfo[] _ImageFormatList = imageFormatType.GetProperties(BindingFlags.Static | BindingFlags.Public);
  602. for (int i = 0; i != _ImageFormatList.Length; i++)
  603. {
  604. ImageFormat _FormatClass = (ImageFormat)_ImageFormatList[i].GetValue(null, null);
  605. if (_FormatClass.Guid.Equals(image.RawFormat.Guid))
  606. {
  607. context.Response.ContentType = "image/" + _ImageFormatList[i].Name.ToLower();
  608. }
  609. }
  610. context.Response.End();
  611. return new EmptyResult();
  612. }
  613. }
  614. }