ShareRecordController.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using Bowin.Common.Data;
  2. using Bowin.Common.Utility;
  3. using Bowin.Web.Controls.Mvc;
  4. using EMIS.CommonLogic.ProjectShareManage;
  5. using EMIS.ViewModel;
  6. using EMIS.ViewModel.ProjectShareManage;
  7. using EMIS.Web.Controls;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Web;
  12. using System.Web.Mvc;
  13. namespace EMIS.Web.Controllers.ProjectShareManage
  14. {
  15. public class ShareRecordController : Controller
  16. {
  17. public IShareRecordServices shareRecordServices { 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. var startTime = pararms.getExtraDateTime("StartTime");
  31. var endTime = pararms.getExtraDateTime("EndTime");
  32. var title = pararms.getExtraString("Title");
  33. var userID = pararms.getExtraGuid("StudentsComboGrid");
  34. return base.Json(shareRecordServices.GetShareRecordViewGrid(configuretView, startTime, endTime, title, userID, (int)pararms.page, (int)pararms.rows));
  35. }
  36. /// <summary>
  37. /// Excel导出
  38. /// </summary>
  39. /// <param name="pararms"></param>
  40. /// <returns></returns>
  41. [HttpPost]
  42. public ActionResult Excel()
  43. {
  44. NpoiExcelHelper neh = new NpoiExcelHelper();
  45. ConfiguretView conditionView = ConfiguretExtensions.GetConfiguretermsView(null);
  46. var startTime = Request.Form["StartTime"].ParseStrTo<DateTime>();
  47. var endTime = Request.Form["EndTime"].ParseStrTo<DateTime>();
  48. var title = Request.Form["Title"].ToString();
  49. var userID = Request.Form["StudentsComboGrid"].ParseStrTo<Guid>();
  50. var shareRecordIDs = Request.Form["selectedIDs"].Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList();
  51. var dt = shareRecordServices.GetShareRecordViewList(conditionView, startTime, endTime, title, userID, shareRecordIDs).Select(x => new
  52. {
  53. x.YearMonthDay,
  54. x.Time,
  55. x.Title,
  56. x.UserName,
  57. x.ClassmajorName,
  58. x.Count,
  59. }).ToTable();
  60. string[] liststring = { "年月日", "时间", "文章标题", "分享人", "班级", "积分" };
  61. neh.Export(dt, liststring, "分享信息" + DateTime.Now.ToString("yyyyMMdd"));
  62. return Json(new ReturnMessage()
  63. {
  64. IsSuccess = true,
  65. Message = "导出成功。"
  66. });
  67. }
  68. [HttpGet]
  69. public ActionResult GetCodeBack()
  70. {
  71. var headers = HttpContext.Request;
  72. return View();
  73. }
  74. }
  75. }