using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.IO; using Bowin.Web.Controls.Mvc; using EMIS.Web.Controls; using EMIS.Utility; using EMIS.ViewModel; using EMIS.ViewModel.StudentManage.StudentProfile; using EMIS.CommonLogic.StudentManage.StudentProfile; using EMIS.CommonLogic.StudentWeb.InfoCenter; namespace EMIS.Web.Controllers.StudentWeb.InfoCenter { [Authorization] public class PersonalInfoController : Controller { public Lazy PersonalInfoServices { get; set; } public Lazy StudentServices { get; set; } /// /// 个人信息(学生)页面 /// /// public ActionResult Index() { var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal; var studentView = StudentServices.Value.GetStudentView(user.UserID); return View(studentView); } /// /// 编辑 /// /// public ActionResult Edit() { var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal; return View(); } /// /// 编辑 /// /// /// [HttpPost] public ActionResult Edit(StudentView studentView) { try { var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal; return RedirectToAction("MsgShow", "Common", new { WindowID = Request["WindowID"], msg = "保存成功。", url = Url.Action("Index").AddMenuParameter() }); } catch (Exception ex) { return RedirectToAction("MsgShowAndOpen", "Common", new { WindowID = Request["WindowID"], msg = "保存失败,原因:" + ex.Message }); } } /// /// 网上校对开放对象信息 /// /// [HttpPost] public ActionResult CheckOpenObject() { try { var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal; PersonalInfoServices.Value.StudentOpenObject(user.UserID); return Json(new ReturnMessage() { IsSuccess = true, Message = "允许校对。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "禁止校对:" + ex.Message }); } } /// /// 个人信息校对 /// /// public ActionResult CheckEdit() { var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal; var studentEditFeildList = PersonalInfoServices.Value.GetStudentEditFeildList(); if (studentEditFeildList != null && studentEditFeildList.Count() > 0) { ViewBag.EditFeildViews = studentEditFeildList; ViewBag.TypeNames = studentEditFeildList.OrderBy(x => x.OrderNo).GroupBy(x => x.TypeName).Select(x => x.Key).ToList(); var studentView = StudentServices.Value.GetStudentView(user.UserID); return View(studentView); } else { throw new Exception("对应的校对控制信息为空(未配置)。"); } } /// /// 个人信息校对 /// /// /// [HttpPost] public ActionResult CheckEdit(StudentView studentView) { try { var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal; Dictionary studentViewDataList = new Dictionary(); foreach (var key in typeof(StudentView).GetProperties()) { if (key.PropertyType.IsValueType || key.PropertyType.Name.StartsWith("String")) { studentViewDataList.Add(key.Name, key.GetValue(studentView, null)); } } PersonalInfoServices.Value.StudentCheckEdit(studentViewDataList, user.UserID); return Json(new ReturnMessage() { IsSuccess = true, Message = "提交成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "提交失败,原因:" + ex.Message }); } } /// /// 核对 /// /// [HttpPost] public ActionResult Proofread() { try { var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal; PersonalInfoServices.Value.StudentProofread(user.UserID); return Json(new ReturnMessage() { IsSuccess = true, Message = "核对成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "核对失败:" + ex.Message }); } } /// /// 学籍报表(个性化配置) /// /// public ActionResult CradReport() { var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current; ViewBag.LoginUserID = curUser.UserID.ToString(); return View(); } /// /// Excel导出 /// /// [HttpPost] public ActionResult Excel() { return null; } } }