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.MinorManage.MinorApply; using Bowin.Common.JSON; using EMIS.ViewModel.MinorManage.MinorApply; using EMIS.ViewModel.WorkflowManage; using Bowin.Common.Utility; using Bowin.Common.Data; namespace EMIS.Web.Controllers.MinorManage.MinorApply { [Authorization] public class MinorRegistApproveController : Controller { // // GET: /MinorApply/ public IMinorApplyServices minorApplyServices { get; set; } public ActionResult List() { return View(); } [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown"); var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown"); var classmajorID = pararms.getExtraGuid("ClassmajorDropdown"); var minorStandardID = pararms.getExtraInt("MinorStandardDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("MinorStandardDropDown"); var approvalStatus = -1; return base.Json(minorApplyServices.MinorApplyViewGrid(configuretView, schoolyearID, collegeID, yearID, standardID, classmajorID, minorStandardID, approvalStatus, (int)pararms.page, (int)pararms.rows)); } public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var schoolyearID = Request.Form["SchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["SchoolyearDropdown"].ParseStrTo(); var collegeID = Request.Form["CollegeDropdown"].ParseStrTo(); var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo(); var standardID = Request.Form["StandardDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDropDown"].ParseStrTo(); var classmajorID = Request.Form["ClassmajorDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["ClassmajorDropdown"].ParseStrTo(); var minorStandardID = Request.Form["MinorStandardDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["MinorStandardDropDown"].ParseStrTo(); var approvalStatus = -1; var minorApplyIDString = Request.Form["SelectedID"]; var minorApplyIDList = minorApplyIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); var dt = minorApplyServices.GetMinorApplyViewList(configuretView, schoolyearID, collegeID, yearID, standardID, classmajorID, minorStandardID, approvalStatus, minorApplyIDList) .Select(x => new { x.SchoolyearCode, x.GrademajorName, x.ClassmajorName, x.LoginID, x.UserName, x.GrademinorCode, x.GrademinorName, x.RecordStatusStr }).ToTable(); string[] liststring = { "学年学期", "年级专业", "班级名称", "学号", "姓名", "辅修专业代码", "辅修专业名称", "状态"}; neh.Export(dt, liststring, "辅修报名信息" + DateTime.Now.ToString("yyyyMMdd")); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功。" }); } /// /// 审核(单个页面) /// /// /// [HttpGet] public ActionResult Approve(string minorApplyID) { //查询对应的审核信息 var minorID = new Guid(minorApplyID); var minorApplyView = minorApplyServices.GetMinorApplyView(minorID); if (minorApplyView == null) { return RedirectToAction("MsgShow", "Common", new { WindowID = Request["WindowID"], msg = "操作失败,原因:数据有误。", url = Url.Action("List").AddMenuParameter() }); } //对已结束的流程状态进行判断(包括正常结束、非正常结束[BP]标识) var endStatusList = minorApplyServices.GetBackpointStatus(); var correctEndStatusID = minorApplyServices.GetCorrectEndStatus(); endStatusList.Add(correctEndStatusID); foreach (var endStatus in endStatusList) { if (minorApplyView.RecordStatus == endStatus) { return RedirectToAction("MsgShow", "Common", new { WindowID = Request["WindowID"], msg = "无法对已结束的流程进行审核。", url = Url.Action("List").AddMenuParameter() }); } } var user = EMIS.Utility.FormValidate.CustomPrincipal.Current; //根据当前环节ID、用户ID查询下一步审批动作信息List(ActionView) var actionViewList = minorApplyServices.GetActionView((Guid)minorID, user.UserID); if (actionViewList == null || actionViewList.Count() <= 0) { return RedirectToAction("MsgShow", "Common", new { WindowID = Request["WindowID"], msg = "对不起,您没权限操作。", url = Url.Action("List").AddMenuParameter() }); } var dropList = actionViewList.Select(x => new DropdownListItem { Text = x.ActionName, Value = x.ToJson() }).ToList(); ViewData["listAction"] = dropList; ViewData["minorApplyID"] = minorApplyID; return View(minorApplyView); } /// /// 审核(单个页面) /// /// /// [HttpPost] public ActionResult Approve(MinorApplyView minorApplyView) { try { List list = new List(); list.Add(minorApplyView.StudentMinorRegistID); var user = EMIS.Utility.FormValidate.CustomPrincipal.Current; string action = Request.Form["ddlAction"]; if (string.IsNullOrEmpty(action)) { throw new Exception("请选择处理动作"); } var actionID = action.JsonToObject().ActionID; minorApplyServices.MinorApproveConfirm(list, user.UserID, actionID, minorApplyView.Comment); return Json(new ReturnMessage() { IsSuccess = true, Message = "审核成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "审核失败,原因:" + ex.Message + "。" }); } } [HttpPost] public ActionResult ApproveConfirm(string minorRegistRegistIDs, Guid actionID, string comment) { try { List list = minorRegistRegistIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)) .Select(x => (Guid?)new Guid(x)).ToList(); var user = EMIS.Utility.FormValidate.CustomPrincipal.Current; minorApplyServices.MinorApproveConfirm(list, user.UserID, actionID, comment); return Json(new ReturnMessage() { IsSuccess = true, Message = "审核成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "审核失败,原因:" + ex.Message + "。" }); } } } }