123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479 |
- 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 cellTitle= new CellItem();
- cellTitle.Col = 0;
- cellTitle.Row = 0;
- cellTitle.Value = EMIS.Utility.RSL.Get("UniversityName") + "学籍卡";
- cellItems.Add(cellTitle);
- 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");
- }
- }
- }
|