using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Bowin.Web.Controls.Mvc; using Bowin.Common.Linq.Entity; using Bowin.Common.Utility; using Bowin.Common.Data; using Bowin.Common.Exceptions; using Bowin.Common.JSON; using EMIS.Web.Controls; using EMIS.ViewModel; using EMIS.ViewModel.EducationManage; using EMIS.ViewModel.EducationManagement; using EMIS.ViewModel.UniversityManage.TeacherManage; using EMIS.CommonLogic.EducationManagement; using EMIS.CommonLogic.CalendarManage; using EMIS.CommonLogic.SystemServices; using EMIS.Utility; using System.IO; namespace EMIS.Web.Controllers.TeachingManagement { [Authorization] public class EducationMissionClassController : Controller { public IEducationMissionClassServices educationMissionClassServices { get; set; } public Lazy staffServices { get; set; } public ISchoolYearServices schoolYearServices { get; set; } public IParameterServices parameterServices { get; set; } /// /// 教学任务页面(普教) /// /// public ActionResult List() { var schoolYear = schoolYearServices.GetSchoolYearIsCurrent(true); ViewBag.SchoolYearID = schoolYear == null ? "-1" : schoolYear.SchoolyearID.ToString();//默认当前学年 return View(); } /// /// 查询教学任务班列表 /// /// /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown"); var coursematerialID = pararms.getExtraGuid("CoursematerialComboGrid"); var campusID = pararms.getExtraGuid("CampusDropdown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var CoursesTimeID = pararms.getExtraGuid("TimeComboGrid"); var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown"); var classmajorID = pararms.getExtraGuid("ClassmajorDropdown"); var gradeYearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown"); var approvalStatus = pararms.getExtraInt("ApprovalStatusDropdownList") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ApprovalStatusDropdownList"); var teachingMode = pararms.getExtraInt("DictionaryTeachingMode") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryTeachingMode"); var result = educationMissionClassServices.GetEducationMissionClassViewGrid(configuretView, campusID, collegeID, schoolyearID, standardID, coursematerialID, approvalStatus, teachingMode, classmajorID, gradeYearID, CoursesTimeID, (int)pararms.page, (int)pararms.rows); return Json(result); } /// /// 教学安排 /// /// /// public ActionResult Edit(Guid? educationMissionClassID) { EducationMissionClassView educationMissionClassView = new EducationMissionClassView(); if (educationMissionClassID != null && educationMissionClassID != Guid.Empty) { educationMissionClassView = educationMissionClassServices.GetEducationMissionClassView(educationMissionClassID); if (educationMissionClassView != null) { var schoolYear = schoolYearServices.GetSchoolYear(educationMissionClassView.SchoolyearID); List lct = new List(); if (schoolYear != null) { for (int i = 1; i <= schoolYear.WeeksNum; i++) { ListControlItem lt = new ListControlItem { Text = "第" + i + "周", Value = i, IsSelected = true }; lct.Add(lt); } } ViewData["lct"] = lct; } } return View(educationMissionClassView); } /// /// 教学安排 /// /// /// [HttpPost] public ActionResult Edit(EducationMissionClassView educationMissionClassView) { try { List list = new List(); var listWeekNum = Request.Form["WeekNum"]; if (listWeekNum != null) { for (int i = 0; i < listWeekNum.Split(',').Length; i++) { if (!string.IsNullOrEmpty(listWeekNum.Split(',')[i])) { int teachingModeID = Convert.ToInt32(listWeekNum.Split(',')[i]); list.Add(teachingModeID); } } } var teacherList = DataGrid.GetTableData("dgTeacherList"); educationMissionClassServices.EducationMissionClassUpdate(educationMissionClassView, list, teacherList); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功!" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message }); } } /// /// 合班 /// /// public ActionResult EducationMissionClassConjunctionList() { return View(); } /// /// 合班 /// /// /// [HttpPost] public ActionResult EducationMissionClassConjunctionList(QueryParamsModel pararms) { var educationMissionClassIDs = pararms.getExtraString("hidEducationMissionClassIDs"); var educationMissionClassIDList = educationMissionClassIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); var educationMissionClassList = educationMissionClassServices.GetEducationMissionClassViewList(educationMissionClassIDList); return Json(new GridResultSet { rows = educationMissionClassList, total = educationMissionClassList.Count }); } /// /// 排课分班 /// /// /// public ActionResult DivideIntoClassesEdit(Guid? educationMissionClassID) { DivideIntoClassesView divideIntoClassesView = new DivideIntoClassesView(); if (educationMissionClassID != null && educationMissionClassID != Guid.Empty) divideIntoClassesView = educationMissionClassServices.GetDivideIntoClassesView(educationMissionClassID); divideIntoClassesView.OrderType = false; divideIntoClassesView.IsNotBuildEducationMission = true; return View(divideIntoClassesView); } /// /// 排课分班 /// /// /// [HttpPost] public ActionResult DivideIntoClassesEdit(DivideIntoClassesView divideIntoClassesView) { try { divideIntoClassesView.GroupNum = Convert.ToInt32(Request.Form["hid_GroupNum"]); divideIntoClassesView.StudentNum = Convert.ToInt32(Request.Form["hid_StudentNum"]); educationMissionClassServices.DivideIntoClassesAdd(divideIntoClassesView); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功!" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message + "!" }); } } /// /// 更新排课序号 /// /// /// /// [HttpPost] public ActionResult TeachingScheduleEdit(string educationMissionClassIDs, string orderNos) { try { List listID = new List(); List listNo = new List(); for (int i = 0; i < educationMissionClassIDs.Split(',').Length; i++) { if (!string.IsNullOrEmpty(educationMissionClassIDs.Split(',')[i])) { Guid educationMissionClassID = new Guid(educationMissionClassIDs.Split(',')[i]); int orderNo = Convert.ToInt32(orderNos.Split(',')[i]); listID.Add(educationMissionClassID); listNo.Add(orderNo); } } educationMissionClassServices.UpdateEducationMissionClassOrderNo(listID, listNo); return Json("成功"); } catch (Exception ex) { return Json("失败,原因:" + ex.Message); } } public ActionResult CourseProcessSummary() { var schoolYearView = schoolYearServices.GetSchoolYearIsCurrent(true); var schoolyear = schoolYearServices.GetSchoolYearViewListAfterCurrent().OrderBy(x => x.Value).Where(x => x.Value > schoolYearView.Value).FirstOrDefault(); var ClassScheduleWeekTimeCount = parameterServices.GetParameterValue(ViewModel.CF_ParameterType.ClassScheduleWeekTimeCount); ViewBag.SchoolYearID = schoolyear.SchoolYearID; ViewBag.ClassScheduleWeekTimeCount = ClassScheduleWeekTimeCount; return View(); } [HttpPost] public ActionResult GetEducationMissionClassStatus() { //List list = new List(); //list = educationMissionClassServices.GetEducationMissionClassStatus().Select(x => x.ToString()).ToList(); var list = educationMissionClassServices.GetEducationMissionClassStatus(); return base.Json(list); } public ActionResult CourseProcessClassroomList() { return View(); } [HttpGet] public ActionResult EductionMissionClassStudentAdd() { return View(); } [HttpPost] public ActionResult EductionMissionClassStudentDelete(Guid? educationMissionClassID, string userIDs) { try { List list = new List(); for (int i = 0; i < userIDs.Split(',').Length; i++) { if (!string.IsNullOrEmpty(userIDs.Split(',')[i])) { Guid userID = new Guid(userIDs.Split(',')[i]); list.Add(userID); } } educationMissionClassServices.DeleteStudentbyEducationMissionClassID(educationMissionClassID, list); return Json("成功"); } catch (Exception ex) { return Json("删除学生失败,原因:" + ex.Message); } } /// /// 添加学生 /// /// /// /// [HttpPost] public ActionResult EductionMissionClassStudentAdd(Guid? educationMissionClassID, string userIDs) { try { List list = new List(); for (int i = 0; i < userIDs.Split(',').Length; i++) { if (!string.IsNullOrEmpty(userIDs.Split(',')[i])) { Guid userID = new Guid(userIDs.Split(',')[i]); list.Add(userID); } } educationMissionClassServices.AddStudentbyEducationMissionClassID(educationMissionClassID, list); return Json("成功"); } catch (Exception ex) { return Json("增加学生失败,原因:" + ex.Message); } } [HttpGet] public ActionResult TeacherSelect() { return View(); } /// /// 教师列表查询 /// /// /// [HttpPost] public ActionResult ALLTeacherList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var userID = pararms.getExtraGuid("SaffDropdown"); var campusID = pararms.getExtraGuid("CampusDropdown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var departmentID = pararms.getExtraGuid("DepartmentDropdown"); var isphotoUrl = pararms.getExtraInt("PhotoUrltmentDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("PhotoUrltmentDropdown"); return base.Json(staffServices.Value.GetStaffViewGrid(configuretView, campusID, collegeID, departmentID, isphotoUrl, userID, (int)pararms.page, (int)pararms.rows)); } //设置教师 public ActionResult SetTeacher(Guid? educationMissionClassID) { EducationMissionClassView educationMissionClassView = new EducationMissionClassView(); if (educationMissionClassID != null && educationMissionClassID != Guid.Empty) { educationMissionClassView = educationMissionClassServices.GetEducationMissionClassView(educationMissionClassID); } return View(educationMissionClassView); } [HttpPost] public ActionResult SetTeacher(EducationMissionClassView educationMissionClassView) { try { string teacherJson = Request.Form["hid_TeacherJsonStr"]; var teacherList = DataGrid.GetTableData("dgTeacherList"); // List teacherList = teacherJson.JsonToObject>();//Json数据转换 educationMissionClassServices.EducationMissionClassUpdateTeacher(educationMissionClassView, teacherList); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功!" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message + "!" }); } } public ActionResult CourseProcess(Guid? educationMissionClassID) { EducationMissionClassView educationMissionClassView = new EducationMissionClassView(); if (educationMissionClassID != null && educationMissionClassID != Guid.Empty) { educationMissionClassView = educationMissionClassServices.GetEducationMissionClassView(educationMissionClassID); } return View(educationMissionClassView); } public ActionResult CourseProcessTeacherEdit(Guid? courseProcessID) { return View(); } [HttpPost] public ActionResult CourseProcessTeacherList(Guid courseProcessID) { var courseProcessTeacherList = educationMissionClassServices.GetCourseProcessTeacherView(courseProcessID); return Json(new GridResultSet{ rows = courseProcessTeacherList, total = courseProcessTeacherList.Count }); } /// /// 周次设置 /// /// /// [HttpPost] public ActionResult CheckEducationMissionClassSettingsList(Guid? educationMissionClassID) { List list = new List(); if (educationMissionClassID != null && educationMissionClassID != Guid.Empty) list = educationMissionClassServices.GetEducationMissionClassSettings(educationMissionClassID); return Json(list); } /// /// 获取任务班授课老师 /// /// /// [HttpPost] public ActionResult TeacherList(Guid? educationMissionClassID) { var teacherList = educationMissionClassServices.GetEducationMissionClassTeacherListViewList(educationMissionClassID); return Json(new GridResultSet() { rows = teacherList, total = teacherList.Count }); } /// /// 查看排课班信息 /// /// public ActionResult EducationSchedulingClassList() { return View(); } /// /// 查看排课班信息 /// /// [HttpPost] public ActionResult EducationSchedulingClassList(QueryParamsModel pararms) { Guid? educationMissionClassID = Request["educationMissionClassID"].ParseStrTo(); return Json(educationMissionClassServices.GetEducationSchedulingClassViewGrid(educationMissionClassID, (int)pararms.page, (int)pararms.rows)); } /// /// 查看排课班学生信息 /// /// /// public ActionResult EducationSchedulingClassStudentList() { return View(); } /// /// 查看排课班学生信息 /// /// /// [HttpPost] public ActionResult EducationSchedulingClassStudentList(QueryParamsModel pararms) { Guid? educationSchedulingClassID = Request["educationSchedulingClassID"].ParseStrTo(); return Json(educationMissionClassServices.GetEducationMissionClassStudentViewGrid(educationSchedulingClassID, (int)pararms.page, (int)pararms.rows)); } /// /// 统计任务班对应排课班学生总人数 /// /// public ActionResult EducationSchedulingClassCountStudentList() { string approvalStatusName = Request["ApprovalStatusName"]; string mnu = Request["mnu"]; Guid? educationMissionClassID = Request["educationMissionClassID"].ParseStrTo(); ViewBag.approvalStatusName = approvalStatusName; ViewBag.mnu = mnu; ViewBag.educationMissionClassID = educationMissionClassID; return View(); } /// /// 统计任务班对应排课班学生总人数 /// /// /// [HttpPost] public ActionResult EducationSchedulingClassCountStudentList(QueryParamsModel pararms) { Guid? educationMissionClassID = Request["educationMissionClassID"].ParseStrTo(); //string approvalStatusName = Request["ApprovalStatusName"]; //string mnu = Request["mnu"]; //ViewBag.approvalStatusName = approvalStatusName; //ViewBag.mnu = mnu; return Json(educationMissionClassServices.GetEducationMissionClassSchedulingStudentViewGrid(educationMissionClassID, (int)pararms.page, (int)pararms.rows)); } /// /// 主任务班列表 /// /// public ActionResult EducationMissionConjunctionList() { return View(); } /// /// 合班提交 /// /// [HttpPost] public ActionResult EducationMissionClassConjunctionEdit() { try { var educationMissionClassList = DataGrid.GetTableData("dgEducationMissionClassConjunctionList"); Guid? EducationMissionClassID = new Guid(Request.Form["EducationMissionClassID"]); string Name = Request.Form["Name"]; if (educationMissionClassList.Count > 0) { List list = new List(); foreach (var educationMissionClass in educationMissionClassList) { list.Add(educationMissionClass.EducationMissionClassID); } EducationMissionClassView educationMissionClassView = new EducationMissionClassView(); educationMissionClassView.EducationMissionClassID = EducationMissionClassID; educationMissionClassView.Name = Name; educationMissionClassServices.EducationMissionClassConjunctionAdd(educationMissionClassView, list); } else { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,请选择您要合班的教学任务!" }); } return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功!" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message + "!" }); } } /// /// 提交 /// /// /// [HttpPost] public ActionResult EducationMissionClassUpdate(string educationMissionClassIDs) { try { List list = new List(); var educationMissionClassArray = educationMissionClassIDs.Split(','); for (int i = 0; i < educationMissionClassArray.Length; i++) { if (!string.IsNullOrEmpty(educationMissionClassArray[i])) { Guid? educationMissionClassID = new Guid(educationMissionClassArray[i]); list.Add(educationMissionClassID); } } educationMissionClassServices.EducationMissionClassUpdate(list); return Json("成功"); } catch (Exception ex) { return Json("提交失败,原因:" + ex.Message); } } /// /// 撤销提交 /// /// /// [HttpPost] public ActionResult UnSubmit(string educationMissionClassIDs) { try { List list = new List(); var educationMissionClassArray = educationMissionClassIDs.Split(','); for (int i = 0; i < educationMissionClassArray.Length; i++) { if (!string.IsNullOrEmpty(educationMissionClassArray[i])) { Guid? educationMissionClassID = new Guid(educationMissionClassArray[i]); list.Add(educationMissionClassID); } } educationMissionClassServices.UnSubmit(list); return Json("撤销成功。"); } catch (Exception ex) { return Json("撤销失败,原因:" + ex.Message); } } [HttpPost] public ActionResult Delete(string educationMissionClassIDs) { try { List list = new List(); var educationMissionClassArray = educationMissionClassIDs.Split(','); for (int i = 0; i < educationMissionClassArray.Length; i++) { if (!string.IsNullOrEmpty(educationMissionClassArray[i])) { Guid? educationMissionClassID = new Guid(educationMissionClassArray[i]); list.Add(educationMissionClassID); } } educationMissionClassServices.Delete(list); return Json(new ReturnMessage { IsSuccess = true }); } catch (Exception ex) { string mge = ex.Message; System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex); if (num != null) { if (num.Number == 547) mge = "请先删除所有关联的数据,排课课表,学生成绩,教学评价等"; } return Json(new ReturnMessage { IsSuccess = false, Message = "删除失败:" + mge }); } } /// /// 导出Excel /// /// /// [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var educationMissionClassIDs = Request.Form["EducationMissionClassIDs"]; var schoolyearID = Request.Form["SchoolyearDropdown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDropdown"].ParseStrTo(); var coursematerialID = Request.Form["CoursematerialComboGrid"].ParseStrTo(); var campusID = Request.Form["CampusDropdown"].ParseStrTo(); var collegeID = Request.Form["CollegeDropdown"].ParseStrTo(); var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo(); var classmajorID = Request.Form["ClassmajorDropdown"].ParseStrTo(); var gradeYearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo(); var approvalStatus = Request.Form["ApprovalStatusDropdownList"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ApprovalStatusDropdownList"].ParseStrTo(); var teachingMode = Request.Form["DictionaryTeachingMode"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryTeachingMode"].ParseStrTo(); List EducationMissionClassIDList = new List(); if (educationMissionClassIDs != "") { EducationMissionClassIDList = educationMissionClassIDs.SplitIDString(); } else { EducationMissionClassIDList = null; } var dt = educationMissionClassServices.GetEducationMissionClassViewList(configuretView, campusID, collegeID, schoolyearID, standardID, coursematerialID, approvalStatus, teachingMode, classmajorID, gradeYearID, null, null, null, EducationMissionClassIDList) .Select(x => new { x.OrderNo, x.Name, // x.SchoolyearCode, x.CourseCode, x.CourseName, x.DepartmentName, // x.CollegeName, x.ClassroomTypeName, x.ClassroomName, x.StartStopWeeklyNum, x.Totalhours, x.CourseProcessTimes, // x.SchedulingClassNum, x.ClassNum, x.TeacherName, x.ApprovalStatusName }).ToTable(); string[] liststring = { "排课序号", "任务班名称","课程代码", "课程名称", "教研室", "教室类型", "教室名称", "执行周次", "总学时", "执行学时", "班级人数","授课老师", "状态" }; neh.Export(dt, liststring, "教学任务班基础信息"); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功!" }); } [HttpPost] public ActionResult GetCourseProcessViewList(Guid educationMissionClassID) { var courseProcessList = this.educationMissionClassServices.GetCourseProcessView(educationMissionClassID); return Json(new GridResultSet { rows = courseProcessList, total = courseProcessList.Count }); } [HttpPost] public ActionResult CourseProcess(EducationMissionClassView educationMissionClassView) { try { var courseProcessList = DataGrid.GetTableData("dgCourseProcessList"); educationMissionClassServices.SaveCourseProcessView(educationMissionClassView, courseProcessList); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } [HttpPost] public ActionResult GetStudentCount(Guid educationMissionClassID) { return Json(educationMissionClassServices.GetStudentCount(educationMissionClassID)); } /// /// 列出课程进度中的可选教室 /// /// /// [HttpPost] public ActionResult GetCourseProcessClassroomList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); int? classroomType = pararms.getExtraString("ClassroomType").ParseStrTo() == DropdownList.SELECT_ALL ? null : pararms.getExtraString("ClassroomType").ParseStrTo(); int? minSeatCount = pararms.getExtraString("MinSeatCount").ParseStrTo() == DropdownList.SELECT_ALL ? null : pararms.getExtraString("MinSeatCount").ParseStrTo(); var collegeID = pararms.getExtraGuid("CollegeDropdown") ?? Guid.Empty; var buildingsID = pararms.getExtraInt("BuildingsDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraGuid("BuildingsDropdown"); return base.Json(educationMissionClassServices.GetAvailableClassroom(configuretView, collegeID, buildingsID, classroomType, minSeatCount, (int)pararms.page, (int)pararms.rows)); } public ActionResult StudentExport(Guid educationMissionClassID) { NpoiExcelHelper neh = new NpoiExcelHelper(); var dt = educationMissionClassServices.GetEducationMissionClassSchedulingStudentViewList(educationMissionClassID) .Select(x => new { x.LoginID, x.Name, x.ClassName, x.StudentStatusName }).ToTable(); string[] liststring = { "学号", "姓名","班级", "学籍状态" }; neh.Export(dt, liststring, "教学任务班学生信息"); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功!" }); } public ActionResult ClassRoomEdit(Guid educationMissionClassID) { EducationMissionClassView educationMissionClassView = new EducationMissionClassView(); if (educationMissionClassID != null && educationMissionClassID != Guid.Empty) { educationMissionClassView = educationMissionClassServices.GetEducationMissionClassView(educationMissionClassID); } return View(educationMissionClassView); } [HttpPost] public ActionResult ClassRoomEdit(EducationMissionClassView educationMissionClassView) { try { educationMissionClassServices.EducationMissionClassUpdateClassRoom(educationMissionClassView); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功!" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message + "!" }); } } /// /// 操作前验证 /// /// /// /// [HttpPost] [Obsolete] public ActionResult Verification(string collegeIDs, string SchoolyearIDs) { List collegeIDlist = collegeIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)) .Select(x => (Guid?)new Guid(x)).ToList(); List schoolyearIDlist = SchoolyearIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)) .Select(x => (Guid?)new Guid(x)).ToList(); var isOK = true; if (collegeIDlist.Count > 0 && schoolyearIDlist.Count>0) { isOK = educationMissionClassServices.Verification(collegeIDlist, schoolyearIDlist); } if (isOK) { return Json("成功"); } else { return Json("教学任务的提交有时间限制,当前时间不在提交时间范围内,不能进行提交。"); } } /// /// 操作前验证 /// /// /// /// [HttpPost] public ActionResult CheckEducationMissionClassOpenControl(string educationMissionClassIDs) { List educationMissionClassIDList = educationMissionClassIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)) .Select(x => new Guid(x)).ToList(); if (educationMissionClassIDList.Count > 0) { try { return Json(new ReturnMessage { IsSuccess = educationMissionClassServices.CheckEducationMissionClassOpenControl(educationMissionClassIDList) }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message }); } } return Json(new ReturnMessage { IsSuccess = true }); } [HttpPost] public ActionResult GZMSStudentListReport(List educationMissionClassIDList) { //ExcelForPDF.Worksheet AsposeExcelHelper excel = new AsposeExcelHelper(); var pageList = new List(); List cellItems = new List(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); List educationMissionClassViewList = educationMissionClassServices.GetEducationMissionClassViewList(configuretView, null, null, null, null, null, null, null, null, null, null, null, null, educationMissionClassIDList); var educationMissionClass = educationMissionClassViewList.FirstOrDefault(); List studentList = educationMissionClassServices.GetEducationMissionClassSchedulingStudentViewList(educationMissionClassIDList.FirstOrDefault()); CellItem cell = new CellItem(); cell.Row = 2; cell.Col = 2; cell.Value = educationMissionClass.Name; cellItems.Add(cell); CellItem cell1 = new CellItem(); cell1.Row = 3; cell1.Col = 2; cell1.Value = educationMissionClass.SpecialtyName; cellItems.Add(cell1); string [][] vs = studentList.Select((data, i) => new string[]{ (i+1).ToString(), data.Name }).ToArray(); var count = vs.Length; var vslist = vs.ToList(); if (count % 48 != 0) { do { var number = count + 1; vslist.Add(new string[]{ number.ToString(), "" }); count++; } while (count < 48 || (count > 48 && (count-48) % 55 != 0 )); } pageList.Add(new PageItem { CellItemList = cellItems, ListItemList = new List{ new ListItem { StartRow = 5, StartColumn = 0, EndColumn = 2, Values = vslist.ToArray() } }, }); var newExcelName = Guid.NewGuid().ToString() + DateTime.Now.Ticks.ToString() + ".xlsx"; FileInfo file = new FileInfo(Server.MapPath("~/Content/TemplateFile" + Path.DirectorySeparatorChar + "studentListReport.xlsx")); file.CopyTo(Server.MapPath("~/Content/TemplateFile" + Path.DirectorySeparatorChar + newExcelName)); FileInfo newfile = new FileInfo(Server.MapPath("~/Content/TemplateFile" + Path.DirectorySeparatorChar + newExcelName)); var stream = new FileStream(Server.MapPath("~/Content/TemplateFile" + Path.DirectorySeparatorChar + newExcelName), FileMode.Open); var excelNewStream = excel.ExportToTemplate(stream, pageList); var fileName = ExcelToPDF.ExportToFile(excelNewStream, Const.LOCAL_SETTING_UPLOAD_FILEPATH); var url = HttpContext.Request.Url.Scheme + "://" + HttpContext.Request.Url.Host + ":" + HttpContext.Request.Url.Port + Url.Content("~/").TrimEnd('/'); //var host = HttpContext.Request.Url; var fileUrl = url + fileName.Substring(1, fileName.Length - 1); stream.Close(); newfile.Delete(); return Json(new ReturnMessage() { IsSuccess = true, Message = fileUrl, }); //File(Server.MapPath(fileName), "application/x-pdf", "测试" + DateTime.Now.ToString("yyyyMMdd") + ".pdf"); } } }