1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474 |
- 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<IStudentsServices> StudentfileServices { get; set; }
- public Lazy<IUserServices> userServices { get; set; }
- public Lazy<ISchoolYearServices> 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; }
- /// <summary>
- /// 学生信息页面
- /// </summary>
- /// <returns></returns>
- public ActionResult List()
- {
- return View();
- }
- /// <summary>
- /// 列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <param name="inSchoolStatus">在校状态</param>
- /// <returns></returns>
- [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));
- }
- /// <summary>
- /// 学生信息页面
- /// </summary>
- /// <returns></returns>
- public ActionResult GdssList()
- {
- return View();
- }
- /// <summary>
- /// 列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <param name="inSchoolStatus">在校状态</param>
- /// <returns></returns>
- [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));
- }
- /// <summary>
- /// 查询学生信息
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [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));
- }
- //<summary>
- //编辑页面
- //</summary>
- //<returns></returns>
- [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);
- }
- /// <summary>
- /// 编辑页面
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Edit(StudentsView studentfileView)
- {
- try
- {
- //获取用户
- var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
- var accepts = new List<string> { ".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
- });
- }
- }
- //<summary>
- //编辑页面
- //</summary>
- //<returns></returns>
- [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导出
- /// <summary>
- /// 导出数据
- /// </summary>
- /// <returns></returns>
- //[HttpPost]
- //public ActionResult Excel()
- //{
- // NpoiExcelHelper neh = new NpoiExcelHelper();
- // ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- // var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
- // var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
- // var classmajorID = Request.Form["ClassmajorDropdown"].ParseStrTo<Guid>();
- // var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
- // var learningformID = Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>();
- // var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
- // var inSchoolStatusID = Request.Form["InSchoolStatusDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["InSchoolStatusDictionaryDropDown"].ParseStrTo<int>();
- // var generalPurposeID = Request.Form["GeneralPurposeDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["GeneralPurposeDictionaryDropDown"].ParseStrTo<int>();
- // 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<StudentExperienceView>("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<StudentFamilyView>("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<string> listphotoPaths = new List<string>();
- 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<string> listphotoPaths = new List<string>();
- 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"]
- });
- }
- }
- /// <summary>
- /// 添加更新前验证
- /// </summary>
- /// <param name="universityID"></param>
- /// <param name="code"></param>
- /// <returns></returns>
- [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("成功");
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="facultymajorView"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Delete(string userIDs)
- {
- try
- {
- List<Guid> list = new List<Guid>();
- 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 + "!");
- }
- }
- /// <summary>
- /// 计算毕业日期
- /// </summary>
- /// <returns></returns>
- 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);
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="LoginID"></param>
- /// <returns></returns>
- 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<StudentsView> studentList = new List<StudentsView>();
- 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<int, DateTime?> 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));
- }
- /// <summary>
- /// 列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <param name="inSchoolStatus">在校状态</param>
- /// <returns></returns>
- [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));
- }
- /// <summary>
- /// 上报导出
- /// </summary>
- /// <param name="selectedIDs"></param>
- /// <returns></returns>
- public ActionResult InfoExport(string selectedIDs)
- {
- ViewBag.selectedID = selectedIDs;
- return View();
- }
- /// <summary>
- /// dbf
- /// </summary>
- /// <param name="pararms"></param>
- /// <param name="selectedIDs"></param>
- /// <param name="colnames"></param>
- /// <param name="showname"></param>
- /// <returns></returns>
- [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<string> namelist = new List<string>();
- for (int i = 0; i < showname.Split(',').Length; i++)
- {
- string col = showname.Split(',')[i];
- if (!string.IsNullOrEmpty(col))
- {
- namelist.Add(col);
- }
- }
- List<string> idlist = new List<string>();
- 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");
- }
- /// <summary>
- /// Excel
- /// </summary>
- /// <param name="pararms"></param>
- /// <param name="selectedIDs"></param>
- /// <param name="colnames"></param>
- /// <param name="showname"></param>
- /// <returns></returns>
- [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<string> namelist = new List<string>();
- for (int i = 0; i < showname.Split(',').Length; i++)
- {
- string col = showname.Split(',')[i];
- if (!string.IsNullOrEmpty(col))
- {
- namelist.Add(col);
- }
- }
- List<string> idlist = new List<string>();
- 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()
- });
- }
- /// <summary>
- /// Excel导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var UserIDs = Request.Form["UserIDs"];
- var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
- var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
- var classmajorID = Request.Form["ClassmajorDropdown"].ParseStrTo<Guid>();
- var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
- var learningformID = Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>();
- var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
- var inSchoolStatusID = Request.Form["InSchoolStatusDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["InSchoolStatusDictionaryDropDown"].ParseStrTo<int>();
- var generalPurposeID = Request.Form["GeneralPurposeDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["GeneralPurposeDictionaryDropDown"].ParseStrTo<int>();
- var isPhotos = Request.Form["YesOrNoStatusDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["YesOrNoStatusDictionaryDropDown"].ParseStrTo<int>();//是否有照片
- var isDream = Request.Form["YesOrNoStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["YesOrNoStatus"].ParseStrTo<int>();//是否圆梦计划
- var planningGraduateDate = Request.Form["PlanningGraduateDropDown"].ToString();
- var LearnSystem = Request.Form["DictionaryLearnSystem"].ToString();
- var education = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
- var reportStatusID = Request.Form["ReportStatusDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ReportStatusDictionaryDropDown"].ParseStrTo<int>();
- List<Guid?> UserIDsIDList = new List<Guid?>();
- 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<Guid?> userIDList)
- {
- //ExcelForPDF.Worksheet
- AsposeExcelHelper excel = new AsposeExcelHelper();
- var pageList = new List<PageItem>();
- var pictureItemList = new List<PictureItem>();
- List<CellItem> cellItems = new List<CellItem>();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- StudentsView studentView = new StudentsView();
- List<DifferentDynamicView> allDifferentDynamicViewList = DifferentDynamicServices.GetDifferentDynamicViewListNotDataRange(configuretView, null, null, null, null, null, null, null, null, null, null, null, 0, userIDList).ToList();
- List<StudentEncourageView> 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<ListItem>{
- 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");
- }
- }
- }
|