using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Web; using System.Web.Mvc; using Bowin.Common; using Bowin.Common.Data; using Bowin.Common.Exceptions; using Bowin.Common.Utility; using Bowin.Web.Controls.Mvc; using EMIS.CommonLogic.CalendarManage; using EMIS.CommonLogic.Students; using EMIS.CommonLogic.SystemServices; using EMIS.Entities; using EMIS.Utility; using EMIS.ViewModel; using EMIS.ViewModel.Students; using EMIS.Web.Controls; using System.Net; using System.Globalization; using Newtonsoft.Json; using EMIS.CommonLogic.StudentManage.StudentProfile; using EMIS.ViewModel.StudentManage.StudentProfile; using EMIS.ViewModel.DifferentDynamic; using System.Drawing; using System.Drawing.Imaging; namespace EMIS.Web.Controllers.Students { [Authorization] public class StudentsController : Controller { public Lazy StudentfileServices { get; set; } public Lazy userServices { get; set; } public Lazy schoolYearServices { get; set; } public IStudentExperienceServices StudentExperienceServices { get; set; } public IStudentFamilyServices StudentFamilyServices { get; set; } public IDifferentDynamicServices differentDynamicServices { get; set; } public IDifferentDynamicServices DifferentDynamicServices { get; set; } public IStudentEncourageServices StudentEncourageServices { get; set; } /// /// 学生信息页面 /// /// public ActionResult List() { return View(); } /// /// 列表查询 /// /// /// 在校状态 /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); //避开全选值 var campusID = pararms.getExtraGuid("CampusDropdown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var classmajorID = pararms.getExtraGuid("ClassmajorDropdown"); var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown"); var learningformID = pararms.getExtraInt("LearningformDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("LearningformDictionaryDropDown"); var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown"); var inSchoolStatusID = pararms.getExtraInt("InSchoolStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("InSchoolStatusDictionaryDropDown"); var generalPurposeID = pararms.getExtraInt("GeneralPurposeDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("GeneralPurposeDictionaryDropDown"); var isPhotos = pararms.getExtraInt("YesOrNoStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatusDictionaryDropDown");//是否有照片 var isDream = pararms.getExtraInt("YesOrNoStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatus");//是否圆梦计划 var planningGraduateDate = pararms.getExtraString("PlanningGraduateDropDown"); var LearnSystem = pararms.getExtraString("DictionaryLearnSystem"); var education = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation"); var reportStatusID = pararms.getExtraInt("ReportStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ReportStatusDictionaryDropDown"); //DateTimeFormatInfo dtFormat = new DateTimeFormatInfo(); //dtFormat.ShortDatePattern = "yyyyMMdd"; //var planningGraduateDate; //if (str != "" && !str.Equals("")) //{ // planningGraduateDate = Convert.ToDateTime(str, dtFormat); //== DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatus"); //} return base.Json(StudentfileServices.Value.GetStudentUserViewList(configuretView, campusID, collegeID, yearID, standardID, learningformID, classmajorID, generalPurposeID, inSchoolStatusID, isPhotos, isDream, planningGraduateDate, LearnSystem, education, reportStatusID, (int)pararms.page, (int)pararms.rows)); } /// /// 学生信息页面 /// /// public ActionResult GdssList() { return View(); } /// /// 列表查询 /// /// /// 在校状态 /// [HttpPost] public ActionResult GdssList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); //避开全选值 var campusID = pararms.getExtraGuid("CampusDropdown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var classmajorID = pararms.getExtraGuid("ClassmajorDropdown"); var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown"); var learningformID = pararms.getExtraInt("LearningformDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("LearningformDictionaryDropDown"); var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown"); var inSchoolStatusID = pararms.getExtraInt("InSchoolStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("InSchoolStatusDictionaryDropDown"); var generalPurposeID = pararms.getExtraInt("GeneralPurposeDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("GeneralPurposeDictionaryDropDown"); var isPhotos = pararms.getExtraInt("YesOrNoStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatusDictionaryDropDown");//是否有照片 var isDream = pararms.getExtraInt("YesOrNoStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatus");//是否圆梦计划 var planningGraduateDate = pararms.getExtraString("PlanningGraduateDropDown"); var LearnSystem = pararms.getExtraString("DictionaryLearnSystem"); var education = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation"); var reportStatusID = pararms.getExtraInt("ReportStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ReportStatusDictionaryDropDown"); //DateTimeFormatInfo dtFormat = new DateTimeFormatInfo(); //dtFormat.ShortDatePattern = "yyyyMMdd"; //var planningGraduateDate; //if (str != "" && !str.Equals("")) //{ // planningGraduateDate = Convert.ToDateTime(str, dtFormat); //== DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatus"); //} return base.Json(StudentfileServices.Value.GetStudentUserViewList(configuretView, campusID, collegeID, yearID, standardID, learningformID, classmajorID, generalPurposeID, inSchoolStatusID, isPhotos, isDream, planningGraduateDate, LearnSystem, education, reportStatusID, (int)pararms.page, (int)pararms.rows)); } /// /// 查询学生信息 /// /// /// [HttpPost] public ActionResult BaseStudentViewList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var collegeID = pararms.getExtraGuid("CollegeComboGrid"); var grademajorID = pararms.getExtraGuid("GrademajorComboGrid"); var classmajorID = pararms.getExtraGuid("ClassmajorComboGrid"); var userID = pararms.getExtraGuid("StudentComboGrid"); //var inSchool = Request.Form["InSchool"]; return Json(StudentfileServices.Value.GetBaseStudentView(configuretView, collegeID, grademajorID, classmajorID, userID, (int)pararms.page, (int)pararms.rows)); } // //编辑页面 // // [HttpGet] public ActionResult Edit(Guid? Userids,string type) { StudentsView StudentfileServicesr = new StudentsView(); if (Userids != null && Userids != Guid.Empty) StudentfileServicesr = StudentfileServices.Value.GetStudentfileView((Guid)Userids); //设置预计毕业学期 方案二 if (StudentfileServicesr.GradeMajorID.HasValue) { string GetPlanningGraduate = StudentfileServices.Value.GetPlanningGraduate((Guid)StudentfileServicesr.GradeMajorID); if (GetPlanningGraduate != "") { StudentfileServicesr.PlanningGraduateDate = Convert.ToDateTime(GetPlanningGraduate); StudentfileServicesr.PlanningGraduateDateStr = Convert.ToDateTime(GetPlanningGraduate); } } if (type == "copyAdd" && Userids!=null) { StudentfileServicesr.UserID = Guid.Empty; StudentfileServicesr.LoginID = null; StudentfileServicesr.IDNumber = null; StudentfileServicesr.UserName = null; StudentfileServicesr.PhotoUrl = null; } return View(StudentfileServicesr); } /// /// 编辑页面 /// /// [HttpPost] public ActionResult Edit(StudentsView studentfileView) { try { //获取用户 var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal; var accepts = new List { ".jpg", ".jpeg", ".png", ".bmp" }; var postedFile = Request.Files["PhotoUrl"]; if (!string.IsNullOrEmpty(postedFile.FileName) && !accepts.Contains(Path.GetExtension(postedFile.FileName).ToLower())) { throw new Exception("只允许上传.jpg、.jpeg、.png、.bmp格式的文件。"); } string photoUrl = FileUploadHelper.UploadFile(postedFile); if (photoUrl != null) { studentfileView.PhotoUrl = photoUrl; } this.StudentfileServices.Value.Save(studentfileView); string UrlStr = Url.Action("Edit").AddMenuParameter() + "&Userids=" + studentfileView.UserID; if (studentfileView.UserID != null && studentfileView.UserID != Guid.Empty) { UrlStr = Url.Action("Edit").AddMenuParameter() + "&Userids=" + studentfileView.UserID + "&type=copyEdit"; } return RedirectToAction("MsgShowAndOpenAddUrl", "Common", new { WindowID = Request["WindowID"], msg = "保存成功!", url = UrlStr }); } catch (Exception ex) { string UrlStr = Url.Action("Edit").AddMenuParameter() + "&Userids=" + studentfileView.UserID; if (studentfileView.UserID != null && studentfileView.UserID != Guid.Empty) { UrlStr = Url.Action("Edit").AddMenuParameter() + "&Userids=" + studentfileView.UserID + "&type=copyEdit"; } return RedirectToAction("MsgShowAndOpenAddUrl", "Common", new { WindowID = Request["WindowID"], msg = "保存失败!" + ex.Message, url = UrlStr }); } } // //编辑页面 // // [HttpGet] public ActionResult EditForGD(Guid? userIds, string type) { StudentsView StudentfileServicesr = new StudentsView(); if (userIds != null && userIds != Guid.Empty) StudentfileServicesr = StudentfileServices.Value.GetStudentfileView((Guid)userIds); //设置预计毕业学期 方案二 if (StudentfileServicesr.GradeMajorID.HasValue) { string GetPlanningGraduate = StudentfileServices.Value.GetPlanningGraduate((Guid)StudentfileServicesr.GradeMajorID); if (GetPlanningGraduate != "") { StudentfileServicesr.PlanningGraduateDate = Convert.ToDateTime(GetPlanningGraduate); StudentfileServicesr.PlanningGraduateDateStr = Convert.ToDateTime(GetPlanningGraduate); } } return View(StudentfileServicesr); } #region TODO:原学生信息Excel导出 /// /// 导出数据 /// /// //[HttpPost] //public ActionResult Excel() //{ // NpoiExcelHelper neh = new NpoiExcelHelper(); // ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); // var campusID = Request.Form["CampusDropdown"].ParseStrTo(); // var collegeID = Request.Form["CollegeDropdown"].ParseStrTo(); // var classmajorID = Request.Form["ClassmajorDropdown"].ParseStrTo(); // var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo(); // var learningformID = Request.Form["LearningformDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["LearningformDictionaryDropDown"].ParseStrTo(); // var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo(); // var inSchoolStatusID = Request.Form["InSchoolStatusDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["InSchoolStatusDictionaryDropDown"].ParseStrTo(); // var generalPurposeID = Request.Form["GeneralPurposeDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["GeneralPurposeDictionaryDropDown"].ParseStrTo(); // var dt = StudentfileServices.Value.GetStudentViewList(configuretView, campusID, collegeID, yearID, standardID, // learningformID, classmajorID, generalPurposeID, inSchoolStatusID) // .Select(x => new // { // x.LoginID, // x.UserName, // x.SexName, // x.PhotoUrl, // Certificatestypename = x.CertificatesTypeName, // x.IDNumber, // Studentcardno = x.StudentCardNo, // PlanningGraduateDate = x.PlanningGraduateDate.ToStringEx(MsgConsts.dateFormat), // CultureModelname = x.CultureModelName, // Studenttypename = x.StudentTypeName, // x.InSchoolStatusName, // ClassmajorName = x.ClassMajorName, // x.ExamineeNum, // ExamineeTypename = x.ExamineeTypeName, // EntranceDate = x.EntranceDate.ToStringEx(MsgConsts.dateFormat), // EntranceWayname = x.EntranceWayName, // x.Placebirth, // Featuresname = x.FeaturesName, // x.Score, // x.TerritorialName, // x.Area, // x.UsedName, // x.DirectorName, // BirthDate = x.BirthDate.ToStringEx(MsgConsts.dateFormat), // x.Country, // x.Politics, // Nationname = x.NationName, // x.Place, // Healthyname = x.HealthyName, // BloodGroupname = x.BloodGroupName, // x.Specialty, // x.Height, // x.Weight, // x.Email, // x.QQ, // x.Mobile, // x.Telephone, // x.MicroMsgNo, // Zipcode = x.ZipCode, // x.Address, // x.WorkUnit, // x.HomeAddress, // x.Recipient, // x.Dormitory, // x.Remarks // }).ToTable(); // string[] liststring = { "学号", "姓名", "性别", "图片路径", "证件类型", "证件号码", "学籍卡编号", "预毕业日期", "培养方式", // "学生类别", "在校状态", "班级名称", "教育部考生号", "考生类别", "入学日期", "入学方式", "出生地", "考生特征", // "分数", "生源所属地", "来源地区", "曾用名", "导师姓名", "出生日期", "国籍", "政治面貌", "民族", "籍贯", "健康状态", // "血型", "特长", "身高", "体重", "电子邮箱", "QQ", "移动电话", "固定电话", "微信号", "邮编", "通信地址", // "工作单位", "家庭地址", "收件人", "宿舍编号", "备注"}; // neh.Export(dt, liststring, "学生信息"); // return RedirectToAction("MsgShow", "Common", new // { // msg = "导出成功!", // url = Url.Content("~/Students/List").AddMenuParameter() // }); //} #endregion public ActionResult StudentExperience() { return View(); } [HttpPost] public ActionResult StudentExperienceList(QueryParamsModel pararms) { return Json(StudentExperienceServices.GetTopStudentExperienceGridView(EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID, 5, pararms.page, pararms.rows)); } [HttpPost] public ActionResult SaveStudentExperience() { var userID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID; var studentExperienceList = DataGrid.GetTableData("dgStudentExperienceList"); try { this.StudentExperienceServices.Save(userID, studentExperienceList); return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } public ActionResult StudentFamily() { return View(); } [HttpPost] public ActionResult StudentFamilyList(QueryParamsModel pararms) { return Json(StudentFamilyServices.GetTopStudentFamilyGridView(EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID, 4, pararms.page, pararms.rows)); } [HttpPost] public ActionResult SaveStudentFamily() { var userID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID; var studentFamilyList = DataGrid.GetTableData("dgStudentFamilyList"); try { this.StudentFamilyServices.Save(userID, studentFamilyList); return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message }); } } [HttpGet] public ActionResult Import(string errorFile) { ViewBag.ErrorFile = errorFile; return View(); } [HttpPost] public ActionResult Import(HttpPostedFileBase file) { try { var accept = new[] { ".xls" }; var p = Path.GetExtension(file.FileName); if (!accept.Contains(p)) { throw new Exception("只允许上传xls格式的Excel文件!"); } string sourceWebPath = FileUploadHelper.UploadFile(file); var sourcePhysicalPath = Server.MapPath(sourceWebPath); var excel = new NpoiExcelHelper(); var dataSource = excel.ImpotColumns(sourcePhysicalPath); System.IO.File.Delete(sourcePhysicalPath); var errorSource = StudentfileServices.Value.Import(dataSource); var errorCount = errorSource.Rows.Count; if (errorCount > 0) { var errorPhysicalPath = sourcePhysicalPath; excel.SaveInServer(errorSource, errorPhysicalPath); var errorWebPath = sourceWebPath; return RedirectToAction("MsgShow", "Common", new { WindowID = "none", msg = "导入失败!", url = Url.Action("Import").AddMenuParameter() + "&errorFile=" + errorWebPath + "&WindowID=" + Request["WindowID"] }); } else { return RedirectToAction("MsgShow", "Common", new { WindowID = Request["WindowID"], msg = "导入成功!", url = Url.Action("List").AddMenuParameter() }); } } catch (Exception ex) { return RedirectToAction("MsgShow", "Common", new { WindowID = Request["WindowID"], msg = "导入发生错误!" + ex.Message, url = Url.Action("List").AddMenuParameter() }); } } [HttpGet] public ActionResult PicImport() { return View(); } [HttpPost] public ActionResult PicImport(HttpPostedFileBase file) { try { if (file.ContentLength <= 0) { throw new Exception("请选择上传文件!"); } var acceptFileExtensions = new[] { ".zip", ".rar" }; var p = Path.GetExtension(file.FileName); if (!acceptFileExtensions.Contains(p)) { throw new Exception("只允许上传zip或rar格式的压缩包!"); } var photoPaths = FileUploadHelper.UploadFileAndExtractFile(file); if (photoPaths.Count <= 0) { throw new Exception("压缩包中没有文件!"); } List listphotoPaths = new List(); var acceptPicExtensions = new[] { ".jpg", ".jpeg", ".png", ".bmp" }; foreach (var path in photoPaths) { string pathxiao = Path.GetExtension(path).ToLower(); if (acceptPicExtensions.Contains(pathxiao)) { listphotoPaths.Add(path); } //{ // throw new Exception("压缩包中含有不支持的图片格式!"); //} //if (!acceptPicExtensions.Contains(Path.GetExtension(path))) //{ // throw new Exception("压缩包中含有不支持的图片格式!"); //} } StudentfileServices.Value.PicImport(listphotoPaths); return RedirectToAction("MsgShow", "Common", new { WindowID = Request["WindowID"], msg = "导入照片成功!", url = Url.Action("List").AddMenuParameter() }); } catch (Exception ex) { return RedirectToAction("MsgShow", "Common", new { WindowID = "none", msg = "导入照片失败!" + ex.Message, url = Url.Action("PicImport").AddMenuParameter() + "&WindowID=" + Request["WindowID"] }); } } [HttpGet] public ActionResult GraduatePicImport() { return View(); } [HttpPost] public ActionResult GraduationPicImport(HttpPostedFileBase file) { try { if (file.ContentLength <= 0) { throw new Exception("请选择上传文件!"); } var acceptFileExtensions = new[] { ".zip", ".rar" }; var p = Path.GetExtension(file.FileName); if (!acceptFileExtensions.Contains(p)) { throw new Exception("只允许上传zip或rar格式的压缩包!"); } var photoPaths = FileUploadHelper.UploadFileAndExtractFile(file); if (photoPaths.Count <= 0) { throw new Exception("压缩包中没有文件!"); } List listphotoPaths = new List(); var acceptPicExtensions = new[] { ".jpg", ".jpeg", ".png", ".bmp" }; foreach (var path in photoPaths) { string pathxiao = Path.GetExtension(path).ToLower(); if (acceptPicExtensions.Contains(pathxiao)) { listphotoPaths.Add(path); } } StudentfileServices.Value.GraduationPicImport(listphotoPaths); return RedirectToAction("MsgShow", "Common", new { WindowID = Request["WindowID"], msg = "导入学历照片成功!", url = Url.Action("List").AddMenuParameter() }); } catch (Exception ex) { return RedirectToAction("MsgShow", "Common", new { WindowID = "none", msg = "导入学历照片失败!" + ex.Message, url = Url.Action("GraduatePicImport").AddMenuParameter() + "&WindowID=" + Request["WindowID"] }); } } /// /// 添加更新前验证 /// /// /// /// [HttpPost] public ActionResult Verification(Guid? Userid, string Code, string ReplaceGraduateNo) { Sys_User userNo = null; Sys_User userInfo = null; if (!string.IsNullOrEmpty(Code)) { userNo = userServices.Value.GetUserByLoginID(Code.Trim()); if (!string.IsNullOrEmpty(Code) && Userid != Guid.Empty) { if (!string.IsNullOrEmpty(ReplaceGraduateNo)) { var isexistReplaceGraduateNo = StudentfileServices.Value.GetReplaceGraduateNo(ReplaceGraduateNo,Userid); if (isexistReplaceGraduateNo != null) { return base.Json("保存失败,补证号已经存在,请重新输入。"); } } userInfo = StudentfileServices.Value.GetStudenter(Userid).Sys_User; if (userNo == userInfo) { return base.Json("成功"); } else { if (userNo != null) { return base.Json("保存失败,学生号已经存在,请重新输入!"); } } } else { if (userNo != null) { return base.Json("保存失败,学生号已经存在,请重新输入!"); } } } if (Userid.HasValue && Userid != Guid.Empty) { userInfo = StudentfileServices.Value.GetStudenter(Userid).Sys_User; if (userInfo == null) { return base.Json("保存失败,未能找到相对应的数据!"); } } return base.Json("成功"); } /// /// 删除 /// /// /// [HttpPost] public ActionResult Delete(string userIDs) { try { List list = new List(); for (int i = 0; i < userIDs.Split(',').Length; i++) { string id = userIDs.Split(',')[i]; if (!string.IsNullOrEmpty(id)) { Guid userID = new Guid(id); list.Add(userID); } } StudentfileServices.Value.UserDelete(list); return base.Json("删除成功!"); } catch (Exception ex) { string mge = ex.Message; System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex); if (num != null) { if (num.Number == 547) mge = "请先删除所有关联的数据,学期注册,任务管理,学生成绩等"; } return base.Json("删除失败,原因:" + mge + "!"); } } /// /// 计算毕业日期 /// /// public ActionResult GetPlanningGraduateDate(Guid? GradeMajorID) { string planningGraduateDate = string.Empty; //var schoolyear = schoolYearServices.Value.GetSchoolYear(schoolYearID); //if (schoolyear != null) //{ // DateTime dtime = PlanningGraduateDateHelper.GetPlanningGraduateDate(schoolyear); // planningGraduateDate = dtime.ToString("yyyy-MM-dd"); //} //if (GradeMajorID.HasValue) //{ // planningGraduateDate = StudentfileServices.Value.ReckonPlanningGraduateDate((Guid)GradeMajorID).Value.ToString("yyyy-MM-dd") + ""; //} if (GradeMajorID.HasValue) { string PlanningGraduate = StudentfileServices.Value.GetPlanningGraduate((Guid)GradeMajorID); //planningGraduateDate = StudentfileServices.Value.GetPlanningGraduate((Guid)GradeMajorID).Value.ToString("yyyy-MM-dd") + ""; } return base.Json(planningGraduateDate); } /// /// /// /// /// public ActionResult ClassStudentReport(string LoginID) { int? status = differentDynamicServices.GetCorrectEndStatus(); var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current; var dataRange= StudentfileServices.Value.GetDataRange(); ViewBag.DataRange = dataRange; ViewBag.UserID = curUser.UserID.ToString(); ViewBag.Status = status; return View(); } public ActionResult StudentProofReport(string LoginID) { var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current; var dataRange = StudentfileServices.Value.GetDataRange(); ViewBag.DataRange = dataRange; ViewBag.UserID = curUser.UserID.ToString(); return View(); } [HttpGet] public ActionResult ExportPictures(string selectedIDs) { ViewBag.selectedID = selectedIDs; return View(); } [HttpPost] public ActionResult ExportPictures(QueryParamsModel pararms, string selectedIDs, string ExportPictureType, string windowsssss) { try { string WindowStr = Request.UrlReferrer.ToString(); int IndexofID = WindowStr.LastIndexOf("="); WindowStr = WindowStr.Remove(0,IndexofID+1); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var campusID = pararms.getExtraGuid("CampusDropdown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var classmajorID = pararms.getExtraGuid("ClassmajorDropdown"); var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown"); var learningformID = pararms.getExtraInt("LearningformDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("LearningformDictionaryDropDown"); var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown"); var inSchoolStatusID = pararms.getExtraInt("InSchoolStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("InSchoolStatusDictionaryDropDown"); var generalPurposeID = pararms.getExtraInt("GeneralPurposeDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("GeneralPurposeDictionaryDropDown"); var isPhotos = pararms.getExtraInt("YesOrNoStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatusDictionaryDropDown");//是否有照片 var isDream = pararms.getExtraInt("YesOrNoStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatus");//是否圆梦计划 var planningGraduateDate = pararms.getExtraString("PlanningGraduateDropDown"); var LearnSystem = pararms.getExtraString("DictionaryLearnSystem"); var education = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation"); var reportStatusID = pararms.getExtraInt("ReportStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ReportStatusDictionaryDropDown"); //WebClient conn = new WebClient(); List studentList = new List(); if (!string.IsNullOrEmpty(selectedIDs)) { var selectedIDList = selectedIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); studentList = this.StudentfileServices.Value.GetStudentViewListByIDList(selectedIDList).ToList(); } else { studentList = this.StudentfileServices.Value.GetStudentViewList(configuretView, campusID, collegeID, yearID, standardID, learningformID, classmajorID, generalPurposeID, inSchoolStatusID, isPhotos, isDream, planningGraduateDate, LearnSystem, education, reportStatusID,null).ToList(); } var remoteFileList = studentList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x => new EMIS.Utility.FileUploadHelper.RemoteFileInfo { FileName = x.LoginID + Path.GetExtension(x.PhotoUrl.Trim()), RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : Url.Content(x.PhotoUrl.Trim())) }).ToList(); if (ExportPictureType == "IDNumberToPicture") { remoteFileList = studentList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x => new EMIS.Utility.FileUploadHelper.RemoteFileInfo { FileName = x.IDNumber + Path.GetExtension(x.PhotoUrl.Trim()), RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : Url.Content(x.PhotoUrl.Trim())) }).ToList(); } if (ExportPictureType == "ExamineeNumToPicture") { remoteFileList = studentList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x => new EMIS.Utility.FileUploadHelper.RemoteFileInfo { FileName = x.ExamineeNum + Path.GetExtension(x.PhotoUrl.Trim()), RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : Url.Content(x.PhotoUrl.Trim())) }).ToList(); } if (ExportPictureType == "LoginIDandUserNameToPicture") { remoteFileList = studentList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x => new EMIS.Utility.FileUploadHelper.RemoteFileInfo { FileName = x.LoginID + x.UserName + Path.GetExtension(x.PhotoUrl.Trim()), RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : Url.Content(x.PhotoUrl.Trim())) }).ToList(); } if (remoteFileList.Count > 0) { var zipFileStream = FileUploadHelper.DownLoadFiles(Guid.NewGuid().ToString(), "学生照片", remoteFileList); return File(zipFileStream, System.Net.Mime.MediaTypeNames.Application.Zip, "学生照片.zip"); } else { return RedirectToAction("MsgShowAndOpen", "Common", new { WindowID = WindowStr, msg = "没有照片可导出!", }); } } catch (Exception ex) { string mge = ex.Message; return base.Json("导出失败,原因:" + mge + "!"); } } [HttpPost] public ActionResult PlanningGraduateList() { //Dictionary PlanningGraduateList = StudentfileServices.Value.GetPlanningGraduateList(); return Json(StudentfileServices.Value.GetPlanningGraduateList()); } [HttpPost] public ActionResult GetDataRange() { return Json(StudentfileServices.Value.GetDataRange()); } [HttpPost] public ActionResult StudentOnlyInSchool(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); return base.Json(StudentfileServices.Value.GetStudentOnlyInSchool(configuretView, (int)pararms.page, (int)pararms.rows)); } /// /// 列表查询 /// /// /// 在校状态 /// [HttpPost] public ActionResult BatchSelectList(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); //避开全选值 var campusID = pararms.getExtraGuid("cbgCampus"); var collegeID = pararms.getExtraGuid("cbgCollege"); var education = pararms.getExtraInt("ddlEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlEducation"); var yearID = pararms.getExtraInt("ddlYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear"); var standardID = pararms.getExtraInt("cbgStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("cbgStandard"); var learningformID = pararms.getExtraInt("ddlLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlLearningform"); var classNum = pararms.getExtraInt("ddlClassNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlClassNum"); var studentStatusID = pararms.getExtraInt("ddlStudentStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlStudentStatus"); var isPhotos = pararms.getExtraInt("ddlHasPhoto") == DropdownList.SELECT_ALL ? null : (bool?)(pararms.getExtraInt("ddlHasPhoto") == (int)CF_YesOrNoStatus.Yes);//是否有照片 var isOnlyGraduation = pararms.getExtraBool("chkOnlyGraduation"); var isPreviousNotGraduated = pararms.getExtraBool("chkPreviousNotGraduated"); return base.Json(StudentfileServices.Value.GetStudentUserViewList(configuretView, campusID, collegeID, education, yearID, standardID, learningformID, classNum, studentStatusID, isPhotos, isOnlyGraduation, isPreviousNotGraduated, (int)pararms.page, (int)pararms.rows)); } /// /// 上报导出 /// /// /// public ActionResult InfoExport(string selectedIDs) { ViewBag.selectedID = selectedIDs; return View(); } /// /// dbf /// /// /// /// /// /// [HttpPost] public ActionResult DbfExport(QueryParamsModel pararms, string selectedIDs, string colnames, string showname) { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); string WindowStr = Request.UrlReferrer.ToString(); int IndexofID = WindowStr.LastIndexOf("="); WindowStr = WindowStr.Remove(0, IndexofID + 1); var campusID = pararms.getExtraGuid("CampusDropdown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var classmajorID = pararms.getExtraGuid("ClassmajorDropdown"); var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown"); var learningformID = pararms.getExtraInt("LearningformDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("LearningformDictionaryDropDown"); var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown"); var inSchoolStatusID = pararms.getExtraInt("InSchoolStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("InSchoolStatusDictionaryDropDown"); var generalPurposeID = pararms.getExtraInt("GeneralPurposeDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("GeneralPurposeDictionaryDropDown"); var isPhotos = pararms.getExtraInt("YesOrNoStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatusDictionaryDropDown");//是否有照片 var isDream = pararms.getExtraInt("YesOrNoStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatus");//是否圆梦计划 var planningGraduateDate = pararms.getExtraString("PlanningGraduateDropDown"); var LearnSystem = pararms.getExtraString("DictionaryLearnSystem"); var education = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation"); var reportStatusID = pararms.getExtraInt("ReportStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ReportStatusDictionaryDropDown"); List namelist = new List(); for (int i = 0; i < showname.Split(',').Length; i++) { string col = showname.Split(',')[i]; if (!string.IsNullOrEmpty(col)) { namelist.Add(col); } } List idlist = new List(); for (int i = 0; i < colnames.Split(',').Length; i++) { string col = colnames.Split(',')[i]; if (!string.IsNullOrEmpty(col)) { idlist.Add(col); } } var dt = StudentfileServices.Value.GetStudentExportList(configuretView, campusID, collegeID, yearID, standardID, learningformID, classmajorID, generalPurposeID, inSchoolStatusID, isPhotos, isDream, planningGraduateDate, LearnSystem, education, reportStatusID) .Select(x => new { x.ExamineeNum, x.UserName, x.SexName, BirthDate = (x.BirthDate.HasValue ? x.BirthDate.Value.ToString("yyyyMMdd") : ""), x.IDNumber, x.SchoolCode, x.SchoolName, x.StandardCode, x.StandardName,//其他学校通用专业名称 x.FacultymajorName,//(松山个性化)专业名称读取院系专业 LearnSystem = (x.LearnSystem.HasValue ? (x.LearnSystem.Value % 1 == 0 ? x.LearnSystem.Value.ToString("0") : x.LearnSystem.Value.ToString("0.0")) : ""), x.LearningformName, x.EducationName, EntranceDate = (x.EntranceDate.HasValue ? x.EntranceDate.Value.ToString("yyyyMMdd") : ""), GraduateDate = (x.GraduateDate.HasValue ? x.GraduateDate.Value.ToString("yyyyMMdd") : ""), x.GraduationResultName, x.GraduateCardNo, x.HeadMasterName, Territorial = (x.Territorial.HasValue ? x.Territorial.ToString() : ""), x.LoginID, x.PoliticsName, x.NationName, x.CampusName, x.CollegeName, x.ClassMajorCode, x.ClassMajorName, PlanningGraduateDate = (x.PlanningGraduateDate.HasValue ? x.PlanningGraduateDate.Value.ToString("yyyyMMdd") : ""), x.Remarks }).ToTable(namelist); string[] liststring = idlist.ToArray(); StudentfileServices.Value.WriteToDbf(dt, idlist); string filePath = Const.LOCAL_SETTING_UPLOAD_FILEPATH; string physicalPath = System.Web.HttpContext.Current.Server.MapPath(filePath); var filephysicalPath = (physicalPath.EndsWith("\\") ? physicalPath : physicalPath + "\\") + "StudentInfoExcel\\Info.dbf"; return File(filephysicalPath, "application/x-dbf", "学生信息(上报导出)" + DateTime.Now.ToString("yyyyMMdd") + ".dbf"); } /// /// Excel /// /// /// /// /// /// [HttpPost] public ActionResult InfoExcel(QueryParamsModel pararms, string selectedIDs, string colnames, string showname) { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); string WindowStr = Request.UrlReferrer.ToString(); int IndexofID = WindowStr.LastIndexOf("="); WindowStr = WindowStr.Remove(0, IndexofID + 1); var campusID = pararms.getExtraGuid("CampusDropdown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var classmajorID = pararms.getExtraGuid("ClassmajorDropdown"); var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown"); var learningformID = pararms.getExtraInt("LearningformDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("LearningformDictionaryDropDown"); var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown"); var inSchoolStatusID = pararms.getExtraInt("InSchoolStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("InSchoolStatusDictionaryDropDown"); var generalPurposeID = pararms.getExtraInt("GeneralPurposeDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("GeneralPurposeDictionaryDropDown"); var isPhotos = pararms.getExtraInt("YesOrNoStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatusDictionaryDropDown");//是否有照片 var isDream = pararms.getExtraInt("YesOrNoStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatus");//是否圆梦计划 var planningGraduateDate = pararms.getExtraString("PlanningGraduateDropDown"); var LearnSystem = pararms.getExtraString("DictionaryLearnSystem"); var education = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation"); var reportStatusID = pararms.getExtraInt("ReportStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ReportStatusDictionaryDropDown"); List namelist = new List(); for (int i = 0; i < showname.Split(',').Length; i++) { string col = showname.Split(',')[i]; if (!string.IsNullOrEmpty(col)) { namelist.Add(col); } } List idlist = new List(); for (int i = 0; i < colnames.Split(',').Length; i++) { string col = colnames.Split(',')[i]; if (!string.IsNullOrEmpty(col)) { idlist.Add(col); } } var dt = StudentfileServices.Value.GetStudentExportList(configuretView, campusID, collegeID, yearID, standardID, learningformID, classmajorID, generalPurposeID, inSchoolStatusID, isPhotos, isDream, planningGraduateDate, LearnSystem, education, reportStatusID) .Select(x => new { x.ExamineeNum, x.UserName, x.SexName, BirthDate = (x.BirthDate.HasValue ? x.BirthDate.Value.ToString("yyyyMMdd") : ""), x.IDNumber, x.SchoolCode, x.SchoolName, x.StandardCode, x.StandardName,//其他学校通用专业名称 x.FacultymajorName,//(松山个性化)专业名称读取院系专业 LearnSystem = (x.LearnSystem.HasValue ? (x.LearnSystem.Value % 1 == 0 ? x.LearnSystem.Value.ToString("0") : x.LearnSystem.Value.ToString("0.0")) : ""), x.LearningformName, x.EducationName, EntranceDate = (x.EntranceDate.HasValue ? x.EntranceDate.Value.ToString("yyyyMMdd") : ""), GraduateDate = (x.GraduateDate.HasValue ? x.GraduateDate.Value.ToString("yyyyMMdd") : ""), x.GraduationResultName, x.GraduateCardNo, x.HeadMasterName, Territorial = (x.Territorial.HasValue ? x.Territorial.ToString() : ""), x.LoginID, x.PoliticsName, x.NationName, x.CampusName, x.CollegeName, x.ClassMajorCode, x.ClassMajorName, PlanningGraduateDate = (x.PlanningGraduateDate.HasValue ? x.PlanningGraduateDate.Value.ToString("yyyyMMdd") : ""), x.Remarks }).ToTable(namelist); string[] liststring = idlist.ToArray(); neh.Export(dt, liststring, "学生信息(上报导出)" + DateTime.Now.ToString("yyyyMMdd")); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功。", url = Url.Content("~/Students/List").AddMenuParameter() }); } /// /// Excel导出 /// /// [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var UserIDs = Request.Form["UserIDs"]; var campusID = Request.Form["CampusDropdown"].ParseStrTo(); var collegeID = Request.Form["CollegeDropdown"].ParseStrTo(); var classmajorID = Request.Form["ClassmajorDropdown"].ParseStrTo(); var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo(); var learningformID = Request.Form["LearningformDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["LearningformDictionaryDropDown"].ParseStrTo(); var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo(); var inSchoolStatusID = Request.Form["InSchoolStatusDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["InSchoolStatusDictionaryDropDown"].ParseStrTo(); var generalPurposeID = Request.Form["GeneralPurposeDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["GeneralPurposeDictionaryDropDown"].ParseStrTo(); var isPhotos = Request.Form["YesOrNoStatusDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["YesOrNoStatusDictionaryDropDown"].ParseStrTo();//是否有照片 var isDream = Request.Form["YesOrNoStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["YesOrNoStatus"].ParseStrTo();//是否圆梦计划 var planningGraduateDate = Request.Form["PlanningGraduateDropDown"].ToString(); var LearnSystem = Request.Form["DictionaryLearnSystem"].ToString(); var education = Request.Form["DictionaryEducation"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo(); var reportStatusID = Request.Form["ReportStatusDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ReportStatusDictionaryDropDown"].ParseStrTo(); List UserIDsIDList = new List(); if (UserIDs != "") { UserIDsIDList = UserIDs.SplitIDString(); } else { UserIDsIDList = null; } var dt = StudentfileServices.Value.GetStudentViewList(configuretView, campusID, collegeID, yearID, standardID, learningformID, classmajorID, generalPurposeID, inSchoolStatusID, isPhotos, isDream, planningGraduateDate, LearnSystem, education, reportStatusID, UserIDsIDList) .Select(x => new { x.ExamineeNum, x.LoginID, x.UserName, x.SexName, BirthDate = (x.BirthDate.HasValue ? x.BirthDate.Value.ToString("yyyyMMdd") : ""), x.CertificatesTypeName, x.IDNumber, x.PoliticsName, x.NationName, x.StandardCode, x.StandardName, x.FacultymajorName, x.CampusName, x.CollegeName, x.ClassMajorCode, x.EducationName, x.LearningformName, LearnSystem = (x.LearnSystem.HasValue ? x.LearnSystem.Value.ToString("#.#") : ""), EntranceDate = (x.EntranceDate.HasValue ? x.EntranceDate.Value.ToString("yyyyMMdd") : ""), PlanningGraduateDate = (x.PlanningGraduateDate.HasValue ? x.PlanningGraduateDate.Value.ToString("yyyyMMdd") : ""), x.CardNo, x.InSchoolStatusName, x.StudentStatusName, x.ClassMajorName, x.Dormitory, x.GraduateCardNo, x.StudentCardNo, x.EntranceWayName, x.SchoolTypeName, x.CultureModelName, x.ExamineeTypeName, x.FeaturesName, x.TerritorialName, x.Area, x.Place, x.StudentTypeName, PhotoUrlNO = x.LoginID, x.Score, x.HealthyName, x.Email, x.QQ, x.Mobile, x.Telephone, x.ZipCode, x.HomeAddress, x.Recipient, x.Placebirth, x.UsedName, x.Specialty, x.Height, x.Weight, x.WorkUnit, x.IsDreamProjectName, x.Career, x.Remarks }).ToTable(); string[] liststring = { "教育部考生号","学号","姓名","性别","出生日期","证件类型","证件号码","政治面貌","民族" ,"专业代码","专业名称",RSL.Get("College")+"专业","分院(校)","系所函授站","班号","层次" ,"学习形式","学制","入学日期","预计毕业日期","银行卡号","在校状态","学籍状态" ,"班级名称","宿舍","毕结业证书编号","学籍卡编号","入学方式","办学类型","培养方式" ,"考生类别","考生特征","生源所属地","来源地区","籍贯","学生类别","照片编号","高考总分" ,"健康状态","电子邮箱","QQ","移动电话","固定电话","邮编","家庭地址","收件人","出生地","曾用名" ,"特长","身高(CM)","体重(KG)","工作单位","是否圆梦计划","在校经历","备注"}; neh.Export(dt, liststring, "学生信息"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功。", url = Url.Content("~/Students/List").AddMenuParameter() }); } [HttpPost] public ActionResult StudentCardReport(List userIDList) { //ExcelForPDF.Worksheet AsposeExcelHelper excel = new AsposeExcelHelper(); var pageList = new List(); var pictureItemList = new List(); List cellItems = new List(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); StudentsView studentView = new StudentsView(); List allDifferentDynamicViewList = DifferentDynamicServices.GetDifferentDynamicViewListNotDataRange(configuretView, null, null, null, null, null, null, null, null, null, null, null, 0, userIDList).ToList(); List allStudentEncourageViewList = StudentEncourageServices.GetStudentEncourageViewList(configuretView, null, null, null, null, null, null, null, null, null, null, null, null, null, userIDList).ToList(); foreach (var userID in userIDList) { studentView = StudentfileServices.Value.GetStudentfileView(userID); CellItem celltiem = new CellItem(); celltiem.Col = 1; celltiem.Row = 1; celltiem.Value = studentView.Name; cellItems.Add(celltiem); CellItem celltiem1 = new CellItem(); celltiem1.Col = 3; celltiem1.Row = 1; celltiem1.Value = studentView.SexName; cellItems.Add(celltiem1); CellItem celltiem2 = new CellItem(); celltiem2.Col = 5; celltiem2.Row = 1; celltiem2.Value = studentView.BirthDate == null ? "" : studentView.BirthDate.Value.ToShortDateString(); cellItems.Add(celltiem2); CellItem celltiem3 = new CellItem(); celltiem3.Col = 7; celltiem3.Row = 1; celltiem3.Value = studentView.IDNumber; cellItems.Add(celltiem3); CellItem celltiem4 = new CellItem(); celltiem4.Col = 10; celltiem4.Row = 1; celltiem4.Value = studentView.PoliticsName; cellItems.Add(celltiem4); CellItem celltiem5 = new CellItem(); celltiem5.Col = 1; celltiem5.Row = 2; celltiem5.Value = studentView.LoginID; cellItems.Add(celltiem5); CellItem celltiem6 = new CellItem(); celltiem6.Col = 4; celltiem6.Row = 2; celltiem6.Value = studentView.StandardName; cellItems.Add(celltiem6); CellItem celltiem7 = new CellItem(); celltiem7.Col = 7; celltiem7.Row = 2; celltiem7.Value = studentView.ClassMajorName; cellItems.Add(celltiem7); CellItem celltiem8 = new CellItem(); celltiem8.Col = 10; celltiem8.Row = 2; celltiem8.Value = studentView.NationName; cellItems.Add(celltiem8); CellItem celltiem9 = new CellItem(); celltiem9.Col = 1; celltiem9.Row = 3; celltiem9.Value = studentView.CollegeName; cellItems.Add(celltiem9); CellItem celltiem10 = new CellItem(); celltiem10.Col = 4; celltiem10.Row = 3; celltiem10.Value = studentView.Place; cellItems.Add(celltiem10); CellItem celltiem11 = new CellItem(); celltiem11.Col = 6; celltiem11.Row = 3; celltiem11.Value = studentView.LearningformName; cellItems.Add(celltiem11); CellItem celltiem12 = new CellItem(); celltiem12.Col = 8; celltiem12.Row = 3; celltiem12.Value = studentView.EducationName; cellItems.Add(celltiem12); CellItem celltiem13 = new CellItem(); celltiem13.Col = 10; celltiem13.Row = 3; celltiem13.Value = studentView.LearnSystem.ToString(); cellItems.Add(celltiem13); CellItem celltiem14 = new CellItem(); celltiem14.Col = 1; celltiem14.Row = 4; celltiem14.Value = studentView.ExamineeNum.ToString(); cellItems.Add(celltiem14); CellItem celltiem15 = new CellItem(); celltiem15.Col = 4; celltiem15.Row = 4; celltiem15.Value = studentView.EntranceDate == null ? "" : studentView.EntranceDate.Value.ToShortDateString(); cellItems.Add(celltiem15); CellItem celltiem16 = new CellItem(); celltiem16.Col = 6; celltiem16.Row = 4; celltiem16.Value = studentView.GraduateDate == null ? "": studentView.GraduateDate.Value.ToShortDateString(); cellItems.Add(celltiem16); CellItem celltiem17 = new CellItem(); celltiem17.Col = 8; celltiem17.Row = 4; celltiem17.Value = studentView.GraduateCardNo; cellItems.Add(celltiem17); CellItem celltiem18 = new CellItem(); celltiem18.Col = 10; celltiem18.Row = 4; celltiem18.Value = studentView.GraduationResultName; cellItems.Add(celltiem18); var DifferentDynamicViewList = allDifferentDynamicViewList.Where(x => x.UserID == userID).ToList(); string[][] diifferentDynamicvs1 = new string[][] { }; string[][] diifferentDynamicvs2 = new string[][] { }; string[][] diifferentDynamicvs3 = new string[][] { }; string[][] diifferentDynamicvs = DifferentDynamicViewList.Select((data, i) => new string[] { data.SchoolyearCode, data.DifferentDynamicTypeName, "", "", data.ReasonName, data.StudentStatusName, data.AfterClassmajorName, "", "", data.AfterStudentStatusName, data.EntityCreateTime == null ? "" : data.EntityCreateTime.Value.ToShortDateString() }).ToArray(); if (diifferentDynamicvs.Length >= 3) { diifferentDynamicvs1 = new string[][] { diifferentDynamicvs[0] }; diifferentDynamicvs2 = new string[][] { diifferentDynamicvs[1] }; diifferentDynamicvs3 = new string[][] { diifferentDynamicvs[2] }; } else if (diifferentDynamicvs.Length == 2) { diifferentDynamicvs1 = new string[][] { diifferentDynamicvs[0] }; diifferentDynamicvs2 = new string[][] { diifferentDynamicvs[1] }; } else if (diifferentDynamicvs.Length == 1) { diifferentDynamicvs1 = new string[][] { diifferentDynamicvs[0] }; } var StudentEncourageViewList = allStudentEncourageViewList.Where(x => x.UserID == userID).ToList(); string[][] studentEncouragevs1 = new string[][] { }; string[][] studentEncouragevs2 = new string[][] { }; string[][] studentEncouragevs3 = new string[][] { }; string[][] studentEncouragevs4 = new string[][] { }; string[][] studentEncouragevs5 = new string[][] { }; string[][] studentEncouragevs = StudentEncourageViewList.Select((data, i) => new string[] { data.SchoolyearCode, data.EncourageName, "", "", data.EncourageTypeName, data.EncourageLevelName, data.Unit, "", "", data.Amount.ToString(), data.EncourageDate == null ? "" : data.EncourageDate.Value.ToShortDateString() }).ToArray(); if (studentEncouragevs.Length >= 5) { studentEncouragevs1 = new string[][] { studentEncouragevs[0] }; studentEncouragevs2 = new string[][] { studentEncouragevs[1] }; studentEncouragevs3 = new string[][] { studentEncouragevs[2] }; studentEncouragevs4 = new string[][] { studentEncouragevs[3] }; studentEncouragevs5 = new string[][] { studentEncouragevs[4] }; } else if (studentEncouragevs.Length == 4) { studentEncouragevs1 = new string[][] { studentEncouragevs[0] }; studentEncouragevs2 = new string[][] { studentEncouragevs[1] }; studentEncouragevs3 = new string[][] { studentEncouragevs[2] }; studentEncouragevs4 = new string[][] { studentEncouragevs[3] }; } else if (studentEncouragevs.Length == 3) { studentEncouragevs1 = new string[][] { studentEncouragevs[0] }; studentEncouragevs2 = new string[][] { studentEncouragevs[1] }; studentEncouragevs3 = new string[][] { studentEncouragevs[2] }; } else if (studentEncouragevs.Length == 2) { studentEncouragevs1 = new string[][] { studentEncouragevs[0] }; studentEncouragevs2 = new string[][] { studentEncouragevs[1] }; } else if (studentEncouragevs.Length == 1) { studentEncouragevs1 = new string[][] { studentEncouragevs[0] }; } PictureItem picture = new PictureItem(); var urlstr = Server.MapPath(studentView.PhotoUrl); try { Bitmap b = new Bitmap(urlstr); Stream picstream = new MemoryStream(); b.Save(picstream, ImageFormat.Png); picture.Picture = picstream; picture.StartRow = 1; picture.EndRow = 5; picture.StartColumn = 11; picture.EndColumn = 12; pictureItemList.Add(picture); } catch { } pageList.Add(new PageItem { CellItemList = cellItems, ListItemList = new List{ new ListItem { StartRow = 6, StartColumn = 1, EndColumn = 11, Values = diifferentDynamicvs1 }, new ListItem { StartRow = 7, StartColumn = 1, EndColumn = 11, Values = diifferentDynamicvs2 }, new ListItem { StartRow = 8, StartColumn = 1, EndColumn = 11, Values = diifferentDynamicvs3 }, new ListItem { StartRow = 10, StartColumn = 1, EndColumn = 11, Values = studentEncouragevs1 }, new ListItem { StartRow = 11, StartColumn = 1, EndColumn = 11, Values = studentEncouragevs2 }, new ListItem { StartRow = 12, StartColumn = 1, EndColumn = 11, Values = studentEncouragevs3 }, new ListItem { StartRow = 13, StartColumn = 1, EndColumn = 11, Values = studentEncouragevs4 }, new ListItem { StartRow = 14, StartColumn = 1, EndColumn = 11, Values = studentEncouragevs5 } }, PictureItemList = pictureItemList }); } var newExcelName = Guid.NewGuid().ToString() + DateTime.Now.Ticks.ToString() + ".xlsx"; FileInfo file = new FileInfo(Server.MapPath("~/Content/TemplateFile" + Path.DirectorySeparatorChar + "studentCard.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"); } } }