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.DataCenterSynch; using Bowin.Common.Log; 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 IStudentSynchServices StudentSynchServices { get; set; } /// /// 学生信息页面 /// /// public ActionResult List() { return View(); } public ActionResult InfoExport(string selectedIDs) { ViewBag.selectedID = selectedIDs; return View(); } /// /// 列表查询 /// /// /// 在校状态 /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); //避开全选值 //var campusID = pararms.getExtraGuid("CampusDropdown"); var campusID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea"); 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.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea"); 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(); StudentfileServicesr.StudentType = (int)CF_STUDENTTYPE.DefaultType; 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; StudentfileServicesr.StudentType = (int)CF_STUDENTTYPE.DefaultType; } return View(StudentfileServicesr); } /// /// 编辑页面 /// /// [HttpPost] public ActionResult Edit(StudentsView studentfileView) { try { //获取用户 var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal; var accepts = new List { ".jpg" }; var postedFile = Request.Files["PhotoUrl"]; if (!string.IsNullOrEmpty(postedFile.FileName) && !accepts.Contains(Path.GetExtension(postedFile.FileName).ToLower())) { throw new Exception("只允许上传.jpg格式的文件。"); } if (!string.IsNullOrEmpty(postedFile.FileName) && (postedFile.ContentLength > (200 * 1024) || postedFile.ContentLength < (50 * 1024))) { throw new Exception("只允许上传50-200k大小的照片。"); } 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, title = "学生信息修改" }); } catch (Exception ex) { string UrlStr = Url.Action("Edit").AddMenuParameter(); if (studentfileView.UserID != null && studentfileView.UserID != Guid.Empty) { UrlStr += "&Userids=" + studentfileView.UserID + "&type=copyEdit"; } return RedirectToAction("MsgShowAndOpenAddUrl", "Common", new { title = "学生信息修改", WindowID = Request["WindowID"], msg = "保存失败!" + ex.Message, url = UrlStr }); } } public ActionResult StudentExperience() { return View(); } // //导出数据 // // Excel字段调整 2016年9月29日11:09:43 zhanghl [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var UserIDs = Request.Form["UserIDs"]; var campusID = Request.Form["ddlSchoolArea"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlSchoolArea"].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.StudentNo, x.UserName, x.SexName, BirthDate = (x.BirthDate.HasValue ? x.BirthDate.Value.ToString("yyyy-MM-dd") : ""), x.CertificatesTypeName, x.IDNumber, x.PoliticsName, x.NationName, x.StandardCode, x.StandardName, x.FacultymajorName, x.SchoolAreaName, 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("yyyy-MM-dd") : ""), PlanningGraduateDate = (x.PlanningGraduateDate.HasValue ? x.PlanningGraduateDate.Value.ToString("yyyy-MM-dd") : ""), 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() }); } // //学籍信息导出Excel dbf // // Excel字段调整 2016年9月29日11:09:43 zhanghl [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.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea"); 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, LearnSystem = (x.LearnSystem.HasValue ? x.LearnSystem.Value.ToString("0.0") : ""), x.LearningformName, x.EducationName, EntranceDate = (x.EntranceDate.HasValue ? x.EntranceDate.Value.ToString("yyyyMMdd") : ""), PlanningGraduateDate = (x.PlanningGraduateDate.HasValue ? x.PlanningGraduateDate.Value.ToString("yyyyMMdd") : ""), x.GraduationResultName, x.GraduateCardNo, x.HeadMasterName, x.TerritorialName, x.LoginID, x.PoliticsName, x.NationName, x.CampusName, x.CollegeName, x.ClassNumStr, x.ClassMajorCode, x.ClassMajorName, x.Remarks }).ToTable(namelist); string[] liststring = idlist.ToArray(); neh.Export(dt, liststring, "学籍信息"); return RedirectToAction("MsgShow", "Common", new { msg = "导出成功!", url = Url.Content("~/Students/List").AddMenuParameter() }); } // //学籍信息导出Excel dbf // // Excel字段调整 2016年9月29日11:09:43 zhanghl [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.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea"); 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, LearnSystem = (x.LearnSystem.HasValue ? x.LearnSystem.Value.ToString("0.0") : ""), x.LearningformName, x.EducationName, EntranceDate = (x.EntranceDate.HasValue ? x.EntranceDate.Value.ToString("yyyyMMdd") : ""), PlanningGraduateDate = (x.PlanningGraduateDate.HasValue ? x.PlanningGraduateDate.Value.ToString("yyyyMMdd") : ""), x.GraduationResultName, x.GraduateCardNo, x.HeadMasterName, x.TerritorialName, x.LoginID, x.PoliticsName, x.NationName, x.CampusName, x.CollegeName, x.ClassNumStr, x.ClassMajorCode, x.ClassMajorName, x.Remarks, }).ToTable(namelist); string[] liststring = idlist.ToArray(); StudentfileServices.Value.WriteToDbf(dt, idlist); var physicalPath = System.IO.Directory.GetCurrentDirectory() + "\\" + dt.TableName + ".dbf"; return File(physicalPath, "application/x-dbf", "学籍信息.dbf"); } [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.StudentDelete(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 + "!"); } } [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(string errorFile) { ViewBag.ErrorFile = errorFile; 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" }; foreach (var path in photoPaths) { string pathxiao = Path.GetExtension(path).ToLower(); if (acceptPicExtensions.Contains(pathxiao)) { listphotoPaths.Add(path); } } var errorDatatable = StudentfileServices.Value.PicImport(listphotoPaths); if (errorDatatable.Rows.Count > 0) { string filePath = Const.LOCAL_SETTING_UPLOAD_FILEPATH; var webFileName = filePath + "/" + Path.GetFileName("照片导入错误数据.xls"); var sourcePhysicalPath = Server.MapPath(webFileName); var excel = new NpoiExcelHelper(); excel.SaveInServer(errorDatatable, sourcePhysicalPath); var errorWebPath = webFileName.Substring(1,webFileName.Length - 1); return RedirectToAction("MsgShow", "Common", new { WindowID = "none", msg = "导入失败!", url = Url.Action("PicImport").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 = "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" }; 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("成功"); } /// /// 计算毕业日期 /// /// 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 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 ExportPictureType, string windowsssss) { try { string WindowStr = Request.UrlReferrer.ToString(); int IndexofID = WindowStr.LastIndexOf("="); WindowStr = WindowStr.Remove(0,IndexofID+1); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var campusID = Request.Form["ddlSchoolArea"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ddlSchoolArea"].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(); var selectedIDs = Request.Form["SelectedIDs"]; //WebClient conn = new WebClient(); ExportPictureType = "IDNumberToPicture"; 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 + x.MicroMsgNo + x.Mobile + 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("MsgShow", "Common", new { WindowID = Request["WindowID"], msg = "没有相片可导出!", url = Url.Content("~/Students/List").AddMenuParameter() }); } } catch (Exception ex) { return RedirectToAction("MsgShow", "Common", new { WindowID = Request["WindowID"], msg = ex.Message, url = Url.Content("~/Students/List").AddMenuParameter() }); //string mge = ex.Message; //return base.Json("导出失败,原因:" + mge + "!"); } } [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.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea"); 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 Synchr() { return View(); } [HttpPost] public ActionResult Synchr(Guid? collegeID, int? year, int? schoolAreaID, string selectedColumns) { List selectedColumnList = selectedColumns.Split(',').Where(x => !string.IsNullOrEmpty(x)).ToList(); try { StudentSynchServices.SynchrByCondition(collegeID, year, schoolAreaID, selectedColumnList); return Json(new ReturnMessage { IsSuccess = true, Message = "同步成功。" }); } catch (Exception ex) { string errorMessage = ex.Message; if (ex.InnerException != null) { errorMessage += ex.InnerException.Message; } return Json(new ReturnMessage() { IsSuccess = false, Message = "同步失败:" + errorMessage }); } } } }