ProjectRecordController.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.ViewModel;
  7. using Bowin.Common.Data;
  8. using EMIS.Web.Controls;
  9. using Bowin.Web.Controls.Mvc;
  10. using EMIS.CommonLogic.SupervisionManage;
  11. using EMIS.ViewModel.SupervisionManage;
  12. using EMIS.Utility;
  13. using Bowin.Common.Utility;
  14. using EMIS.CommonLogic.SystemServices;
  15. namespace EMIS.Web.Controllers.SupervisionManage
  16. {
  17. [Authorization]
  18. public class ProjectRecordController : Controller
  19. {
  20. public IProjectRecordServices projectRecordServices { get; set; }
  21. public IRoleServices IRoleServices { get; set; }
  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 schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
  31. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  32. var ddCcollegeID = pararms.getExtraGuid("DDCollegeDropdown");
  33. var supervisionType = pararms.getExtraInt("SupervisionType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SupervisionType");
  34. var startDate = pararms.getExtraDateTime("StartDate");
  35. var endDate = pararms.getExtraDateTime("EndDate");
  36. var dataRange = IRoleServices.GetDataRange();
  37. return base.Json(projectRecordServices.GetProjectRecordViewGrid(configuretView, schoolyearID, collegeID, supervisionType, ddCcollegeID, startDate, endDate,dataRange, (int)pararms.page, (int)pararms.rows));
  38. }
  39. [HttpGet]
  40. public ActionResult Edit(Guid? projectRecordID, int? isShow)
  41. {
  42. ProjectRecordView projectRecordView = new ProjectRecordView();
  43. var evaluation = (int)SUP_SupervisionType.Evaluation;
  44. if (projectRecordID.HasValue && projectRecordID != Guid.Empty)
  45. {
  46. projectRecordView = projectRecordServices.GetProjectRecordView(projectRecordID);
  47. }
  48. ViewBag.Evaluation = evaluation;
  49. return View(projectRecordView);
  50. }
  51. /// <summary>
  52. /// 编辑
  53. /// </summary>
  54. /// <param name="graduationConditionView"></param>
  55. /// <returns></returns>
  56. [HttpPost]
  57. public ActionResult Edit(ProjectRecordView projectRecordView)
  58. {
  59. try
  60. {
  61. var teacherList = DataGrid.GetTableData<ProjectRecordTeacherView>("dgTeacherList");
  62. if (teacherList.Count <= 0)
  63. {
  64. return Json(new ReturnMessage()
  65. {
  66. IsSuccess = false,
  67. Message = "保存失败,原因:督导组成员不能为空。"
  68. });
  69. }
  70. List<FileUploadView> filelist = new List<FileUploadView>();
  71. var sessionName = FileUploadHelper.GetFileUploadSessionName(projectRecordView.ProjectRecordID);
  72. var sessionfileList = (List<FileUploadView>)Session[sessionName];
  73. if (sessionfileList != null)
  74. {
  75. foreach (var file in sessionfileList)
  76. {
  77. filelist.Add(file);
  78. }
  79. }
  80. projectRecordServices.Save(projectRecordView, teacherList, filelist);
  81. return Json(new ReturnMessage()
  82. {
  83. IsSuccess = true,
  84. Message = "保存成功。"
  85. });
  86. }
  87. catch (Exception ex)
  88. {
  89. return Json(new ReturnMessage()
  90. {
  91. IsSuccess = false,
  92. Message = "保存失败,原因:" + ex.Message + "。"
  93. });
  94. }
  95. }
  96. [HttpPost]
  97. public ActionResult Delete(string projectRecordIDs)
  98. {
  99. try
  100. {
  101. var projectRecordIDList = projectRecordIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  102. projectRecordServices.Delete(projectRecordIDList);
  103. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功" });
  104. }
  105. catch (Exception ex)
  106. {
  107. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败,原因:" + ex.Message });
  108. }
  109. }
  110. [HttpPost]
  111. public ActionResult Excel()
  112. {
  113. NpoiExcelHelper neh = new NpoiExcelHelper();
  114. ConfiguretView conditionView = ConfiguretExtensions.GetConfiguretermsView(null);
  115. var schoolyearID = Request.Form["Schoolyear"].ParseStrTo<Guid>();
  116. var collegeID = Request.Form["College"].ParseStrTo<Guid>();
  117. var supervisionType = Request.Form["SupervisionType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SupervisionType"].ParseStrTo<int>();
  118. var supervisionCollegeID = Request.Form["SupervisionCollege"].ParseStrTo<Guid>();
  119. var startDate = Request.Form["StartDate"].ParseStrTo<DateTime>();
  120. var endDate = Request.Form["EndDate"].ParseStrTo<DateTime>();
  121. var projectRecordIDString = Request.Form["SelectedID"];
  122. var projectRecordIDList = projectRecordIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  123. var dataRange = IRoleServices.GetDataRange();
  124. List<ProjectRecordView> result;
  125. result = projectRecordServices.GetProjectRecordViewList(conditionView, schoolyearID, collegeID, supervisionType, supervisionCollegeID,
  126. startDate, endDate, projectRecordIDList, dataRange);
  127. var dt = result.Select(x => new
  128. {
  129. x.SchoolyearCode,
  130. x.SupervisionTypeDesc,
  131. x.CollegeName,
  132. x.SupervisionCollegeName,
  133. x.SupervisionTarget,
  134. x.DateWeekTimeDesc,
  135. x.Location,
  136. x.staffListDesc,
  137. x.CreateUserName,
  138. CreateTime = x.CreateTime.Value.ToShortDateString(),
  139. }).ToTable();
  140. string[] liststring = { "学年学期", "督导类型", "院系所", "督导院系", "督导对象", "督导时间","督导地点",
  141. "督导组成员", "创建人", "创建时间" };
  142. neh.Export(dt, liststring, "督导项目记录");
  143. return Json(new ReturnMessage()
  144. {
  145. IsSuccess = true,
  146. Message = "保存成功!"
  147. });
  148. }
  149. [HttpGet]
  150. public ActionResult TeacherSelect()
  151. {
  152. return View();
  153. }
  154. [HttpPost]
  155. public ActionResult TeacherList(QueryParamsModel pararms, Guid? projectRecordID)
  156. {
  157. if (projectRecordID.HasValue && projectRecordID != Guid.Empty)
  158. {
  159. return base.Json(projectRecordServices.GetProjectRecordTeacherViewGridByID(projectRecordID, (int)pararms.page, (int)pararms.rows));
  160. }
  161. else
  162. {
  163. return base.Json(projectRecordServices.GetDefaultTeacherViewGrid((int)pararms.page, (int)pararms.rows)); ;
  164. }
  165. }
  166. [HttpGet]
  167. public ActionResult Upload(Guid? projectRecordID)
  168. {
  169. ProjectRecordView projectRecordView = new ProjectRecordView();
  170. projectRecordView.ProjectRecordID = projectRecordID.Value;
  171. return View(projectRecordView);
  172. }
  173. [HttpPost]
  174. public ActionResult Upload()
  175. {
  176. return Json("上传成功");
  177. }
  178. [HttpPost]
  179. public ActionResult GetFileListByProjectRecordID(Guid? projectRecordID)
  180. {
  181. //var convertByApplyID = scoreConvertByApplyID.ParseStrTo<Guid>();
  182. var sessionName = FileUploadHelper.GetFileUploadSessionName(projectRecordID ?? Guid.Empty);
  183. var fileList = (List<FileUploadView>)Session[sessionName];
  184. return Json(fileList);
  185. }
  186. [HttpGet]
  187. public ActionResult SelectAdvise()
  188. {
  189. return View();
  190. }
  191. ///// <summary>
  192. ///// 教师列表查询
  193. ///// </summary>
  194. ///// <param name="pararms"></param>
  195. ///// <returns></returns>
  196. //[HttpPost]
  197. //public ActionResult ALLTeacherList(QueryParamsModel pararms)
  198. //{
  199. // ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  200. // var userID = pararms.getExtraGuid("SaffDropdown");
  201. // var campusID = pararms.getExtraGuid("CampusDropdown");
  202. // var collegeID = pararms.getExtraGuid("CollegeDropdown");
  203. // var departmentID = pararms.getExtraGuid("DepartmentDropdown");
  204. // var isphotoUrl = pararms.getExtraInt("PhotoUrltmentDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("PhotoUrltmentDropdown");
  205. // return base.Json(staffServices.Value.GetStaffViewGrid(configuretView, campusID, collegeID, departmentID, isphotoUrl, userID, (int)pararms.page, (int)pararms.rows));
  206. //}
  207. //public ActionResult GetLoginUser()
  208. //{
  209. // var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  210. // return View(curUser);
  211. //}
  212. }
  213. }