using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using EMIS.ViewModel; using EMIS.Web.Controls; using Bowin.Web.Controls.Mvc; using EMIS.CommonLogic.DQPSystem; using Bowin.Common.Utility; using EMIS.ViewModel.DQPSystem; using EMIS.Utility; using EMIS.CommonLogic.SystemServices; namespace EMIS.Web.Controllers.DQPSystem { [Authorization] public partial class SOCController : Controller { // // GET: /SOC/ public ISOCServices SOCServices { get; set; } public IRoleServices RoleServices { get; set; } public ActionResult List() { return View(); } [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown"); var coursematerialID = pararms.getExtraGuid("CoursematerialIDDropdownGridBo"); var collegeID = pararms.getExtraGuid("CollegeComboGrid"); //var educationMissionID = pararms.getExtraGuid("EducationMissionGrid"); var result = SOCServices.GetSOCViewGrid(configuretView, schoolyearID, coursematerialID, collegeID, (int)pararms.page, (int)pararms.rows); return Json(result); } [HttpGet] public ActionResult SOCDetail(Guid? SOCID) { ViewBag.SOCID = SOCID; return View(); } [HttpPost] public ActionResult SOCDetail() { var SOCID = Request["SOCID"].ParseStrTo(); return Json(SOCServices.GetSOCDetailViewGridByID(SOCID)); } public ActionResult Edit(string SOCIDList) { ViewBag.SOCIDList = SOCIDList; var socIDs = SOCIDList.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); var socView = SOCServices.GetSOCViewByID(socIDs.FirstOrDefault()); return View(socView); } [HttpPost] public ActionResult Edit(SOCView SOCView) { try { List filelist = new List(); var socID = Request.Form["socIDList"] ?? ""; var socIDs = socID.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); var TDList = DataGrid.GetTableData("dgSOCDetailList");//获取底部列表项数据 if (TDList.Count <= 0) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:SOC不能为空。" }); } else { var detailIDList = TDList.Select(x => x.SOCDetailID).ToList(); foreach (var id in detailIDList) { var sessionName = FileUploadHelper.GetFileUploadSessionName(id); var sessionfileList = (List)Session[sessionName]; if (sessionfileList != null) { foreach (var file in sessionfileList) { filelist.Add(file); } } } SOCServices.SOCEdit(SOCView, TDList, filelist, socIDs); } return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message }); } } [HttpGet] public ActionResult SOCDetailEdit(Guid? detailID) { //ViewBag.DetailID = detailID; //var detailView = Request["detailView"]; //var SOCDetailView = SOCServices.GetSOCDetailViewByID(detailID); //if (SOCDetailView == null) //{ // SOCDetailView = new SOCDetailView(); // SOCDetailView.SOCDetailID = detailID.Value; //} SOCDetailView SOCDetailView = new SOCDetailView(); SOCDetailView.SOCDetailID = detailID.Value; return View(SOCDetailView); } [HttpPost] public ActionResult SOCDetailEdit(SOCDetailView SOCDetailView) { var SOCID = Request["SOCID"].ParseStrTo(); ViewBag.SOCDetailView = SOCDetailView; return Json(new ReturnMessage() { IsSuccess = true, Message = "成功", }); } [HttpPost] public ActionResult Generate(QueryParamsModel pararms) { try { //var collegeID = Request.Form["CollegeDropdown"].ParseStrTo(); //var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo(); //var facultymajorID = Request.Form["FacultymajorDropDown"].ParseStrTo(); //var coursematerialID = Request.Form["CoursematerialDropDown"].ParseStrTo(); SOCServices.GenerateSOC(); return Json(new ReturnMessage() { IsSuccess = true, Message = "生成成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "生成失败:" + ex.Message }); } } [HttpGet] public ActionResult Upload(Guid? detailID) { SOCDetailView SOCDetailView = new SOCDetailView(); SOCDetailView.SOCDetailID = detailID.Value; return View(SOCDetailView); } [HttpPost] public ActionResult Upload() { return Json("上传成功"); } [HttpPost] public ActionResult GetFileListByDetailID(string DetailID) { var detailID = DetailID.ParseStrTo(); var sessionName = FileUploadHelper.GetFileUploadSessionName(detailID ?? Guid.Empty); var fileList = (List)Session[sessionName]; //var count = Session.Count; //List filelist = new List(); //for (int i = 0; i < count; i++) //{ // var file = Session[i]; // if (file.GetType() == typeof(List)) // { // filelist = (List)file; // } //} //ViewBag.FileList = filelist; //foreach (var file in filelist) //{ //} return Json(fileList); } /// /// 学生名单 /// /// /// [HttpGet] public ActionResult SOCStudentList() { return View(); } /// /// 学生名单 /// /// /// [HttpPost] public ActionResult SOCStudentList(QueryParamsModel pararms) { var SOCID = pararms.getExtraGuid("hidSOCID"); ; return Json(SOCServices.GetSOCStudent(SOCID, (int)pararms.page, (int)pararms.rows)); } public ActionResult AttachmentList(Guid? detailID) { return View(); } public ActionResult DeleteDetailCheck(string detailIDs) { var detailIDList = detailIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); var isOK = SOCServices.CheckDetailIsHaveMessage(detailIDList); if (isOK) { return Json(new ReturnMessage() { IsSuccess = false, Message = "选中的soc明细存在关联数据(SOC分组、SOC学生成果、SOC学生成绩等),不能删除!" }); } else { return Json(new ReturnMessage() { IsSuccess = true, Message = "删除" }); } } public ActionResult SOCCheck(string SOCIDs) { var socIDList = SOCIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); var isOK = SOCServices.CheckSOCIsHaveMessage(socIDList); if (isOK) { return Json(new ReturnMessage() { IsSuccess = false, Message = "选中的soc存在已经设置过明细的数据,是否重新设置?" }); } else { return Json(new ReturnMessage() { IsSuccess = true, Message = "删除" }); } } public ActionResult CheckCanSetting() { var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current; var role = RoleServices.GetEnabledTeacherRoleViewList(); var teacherRole = role.Where(x => x.RoleName == "教师"); if (curUser.RoleID != teacherRole.FirstOrDefault().RoleID) { return Json(new ReturnMessage() { IsSuccess = false, Message = "只有教师角色才能进行设置" }); } else { return Json(new ReturnMessage() { IsSuccess = true, Message = "" }); } } [HttpPost] public ActionResult EducationMissionList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var result = SOCServices.GetEducationMissionViewGrid(configuretView, (int)pararms.page, (int)pararms.rows); return Json(result); } /// /// 根据登录教师获取对应院系所 /// /// /// public ActionResult TeacherCollegeList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("ddlSchoolyear"); var result = SOCServices.GetTeacherCollegeViewGrid(configuretView, schoolyearID, (int)pararms.page, (int)pararms.rows); return Json(result); } /// /// 根据登录教师获取对应班级 /// /// /// public ActionResult TeacherClassmajorList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("ddlSchoolyear"); var collegeID = pararms.getExtraGuid("cgbCollege"); var year = pararms.getExtraInt("ddlYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear"); var standardID = pararms.getExtraInt("cbgStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("cbgStandard"); var result = SOCServices.GetTeacherClassmajorViewGrid(configuretView, schoolyearID, collegeID, year, standardID, (int)pararms.page, (int)pararms.rows); return Json(result); } } }