using Learun.Util; using System.Data; using Learun.Application.TwoDevelopment.EducationalAdministration; using System.Web.Mvc; using System.Collections.Generic; using System; using System.Linq; using Newtonsoft.Json; namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers { /// /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架 /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司 /// 创 建:超级管理员 /// 日 期:2022-04-14 18:12 /// 描 述:考试记录表 /// public class Exam_ExamPlanController : MvcControllerBase { private Exam_ExamPlanIBLL exam_ExamPlanIBLL = new Exam_ExamPlanBLL(); private Exam_ExamPlanLessonIBLL exam_ExamPlanLessonIBLL = new Exam_ExamPlanLessonBLL(); private Exam_ExamPlanClassIBLL exam_ExamPlanClassIBLL = new Exam_ExamPlanClassBLL(); private Exam_ExamPlanRoomIBLL exam_ExamPlanRoomIBLL = new Exam_ExamPlanRoomBLL(); #region 视图功能 /// /// 主页面 /// /// [HttpGet] public ActionResult Index() { return View(); } /// /// 表单页 /// /// [HttpGet] public ActionResult Form() { return View(); } /// /// 表单页 /// /// [HttpGet] public ActionResult GenerateForm() { return View(); } /// /// 表单页 /// /// [HttpGet] public ActionResult ClearForm() { return View(); } /// /// 安排时间 /// /// [HttpGet] public ActionResult FormTime() { return View(); } #endregion #region 获取数据 /// /// 获取页面显示列表数据 /// /// 分页参数 /// 查询参数 /// [HttpGet] [AjaxOnly] public ActionResult GetPageList(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var data = exam_ExamPlanIBLL.GetPageList(paginationobj, queryJson); var jsonData = new { rows = data, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records }; return Success(jsonData); } /// /// 获取表单数据 /// /// 主键 /// [HttpGet] [AjaxOnly] public ActionResult GetFormData(string keyValue) { var Exam_ExamPlanData = exam_ExamPlanIBLL.GetExam_ExamPlanEntity(keyValue); var jsonData = new { Exam_ExamPlan = Exam_ExamPlanData, }; return Success(jsonData); } /// /// 安排时间 /// /// /// [HttpGet] [AjaxOnly] public ActionResult GetPlanTimeList(string EPId) { var data = exam_ExamPlanIBLL.GetPlanTimeList(EPId); return Success(data); } #endregion #region 提交数据 /// /// 删除实体数据 /// /// 主键 /// [HttpPost] [AjaxOnly] public ActionResult DeleteForm(string keyValue) { exam_ExamPlanIBLL.DeleteEntity(keyValue); return Success("删除成功!"); } /// /// 生成排考名单 /// /// /// [HttpPost] [AjaxOnly] public ActionResult Generate(string keyValue) { var data = exam_ExamPlanIBLL.IsGenerate(keyValue); if (!data.flag) { return Fail(data.str); } exam_ExamPlanIBLL.Generate(keyValue); return Success("生成成功!"); } /// /// 安排考试 /// /// /// [HttpPost] [AjaxOnly] public ActionResult SavePlanTime(string EPId, List list) { if (list.Count <= 0) { return Fail("请安排时间!"); } foreach (var entity in list) { DateTime time; if (!DateTime.TryParse(entity.ExamTimeStart, out time)) { return Fail("开始时间格式不正确!"); } if (!DateTime.TryParse(entity.ExamTimeEnd, out time)) { return Fail("结束时间格式不正确!"); } var startTime = Convert.ToDateTime(entity.ExamDate.Value.ToString("yyyy-MM-dd") + " " + entity.ExamTimeStart); var endTime = Convert.ToDateTime(entity.ExamDate.Value.ToString("yyyy-MM-dd") + " " + entity.ExamTimeEnd); if (endTime <= startTime) { return Fail("结束时间必须大于开始时间!"); } //考试时长 entity.ExamTimeLength = (endTime - startTime).TotalMinutes; } exam_ExamPlanIBLL.SavePlanTime(EPId, list); return Success("保存成功!"); } /// /// 清除排考名单/清除所有排考记录 /// /// 排考记录主表Id /// 1:清除排考名单;2:清除所有排考记录 /// [HttpPost] [AjaxOnly] public ActionResult ClearGenerate(string keyValue, int type) { exam_ExamPlanIBLL.ClearGenerate(keyValue, type); return Success("操作成功!"); } /// /// 保存实体数据(新增、修改) /// /// 主键 /// 实体 /// [HttpPost] [ValidateAntiForgeryToken] [AjaxOnly] public ActionResult SaveForm(string keyValue, string strEntity) { Exam_ExamPlanEntity entity = strEntity.ToObject(); exam_ExamPlanIBLL.SaveEntity(keyValue, entity); if (string.IsNullOrEmpty(keyValue)) { } return Success("保存成功!"); } /// /// 生成排考名单 /// /// /// /// /// [HttpPost] [ValidateAntiForgeryToken] [AjaxOnly] public ActionResult GenerateForm(string AcademicYearNo, string Semester, string PlanType) { int res = exam_ExamPlanIBLL.ClaerForm(AcademicYearNo, Semester, PlanType); return Success("清空(" + res + ")条数据成功!"); } /// /// 清除排考名单 /// /// /// /// /// [HttpPost] [ValidateAntiForgeryToken] [AjaxOnly] public ActionResult ClearForm(string AcademicYearNo, string Semester, string PlanType) { int res = exam_ExamPlanIBLL.GenerateForm(AcademicYearNo, Semester, PlanType); return Success("清空(" + res + ")条数据成功!"); } /// /// 一键安排课程 /// /// /// [HttpPost] [AjaxOnly] public ActionResult PlanLessonByEPId(string keyValue) { exam_ExamPlanLessonIBLL.InitExamPlanLesson(keyValue); return Success("操作成功!"); } /// /// 一键安排班级 /// /// /// [HttpPost] [AjaxOnly] public ActionResult PlanClassByEPId(string keyValue) { var count = exam_ExamPlanLessonIBLL.GetListByEPId(keyValue).Count(); if (count <= 0) { return Fail("请先安排课程!"); } exam_ExamPlanClassIBLL.PlanClassByEPId(keyValue); return Success("操作成功!"); } /// /// 自动生成考试课程排考时间 /// /// /// [HttpPost] [AjaxOnly] public ActionResult PlanLessonTimeByEPId(string keyValue) { var count = exam_ExamPlanLessonIBLL.GetListByEPId(keyValue).Count(); if (count <= 0) { return Fail("请先安排课程!"); } var res = exam_ExamPlanLessonIBLL.PlanLessonTimeByEPId(keyValue); if (res.flag) { return Success("操作成功!"); } else { return Fail(res.msg); } return Success("操作成功!"); } /// /// 一键安排考场 /// /// /// [HttpPost] [AjaxOnly] public ActionResult PlanRoomByEPId(string keyValue) { var res = exam_ExamPlanRoomIBLL.PlanRoomByEPId(keyValue); if (!res.flag) { return Fail(res.str); } return Success("操作成功!"); } /// /// 一键安排监考老师 /// /// /// [HttpPost] [AjaxOnly] public ActionResult PlanTeacherByEPId(string keyValue) { var res = exam_ExamPlanRoomIBLL.PlanTeacherByEPId(keyValue); if (!res.flag) { return Fail(res.str); } return Success("操作成功!"); } /// /// 审核所有考试课程 /// /// /// [HttpPost] [AjaxOnly] public ActionResult CheckAllPlanLesson(string keyValue) { var res = exam_ExamPlanLessonIBLL.CheckAllPlanLesson(keyValue); if (!res.flag) { return Fail(res.str); } return Success("操作成功!"); } #endregion } }