StudentsController.cs 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.Mvc;
  7. using Bowin.Common;
  8. using Bowin.Common.Data;
  9. using Bowin.Common.Exceptions;
  10. using Bowin.Common.Utility;
  11. using Bowin.Web.Controls.Mvc;
  12. using EMIS.CommonLogic.CalendarManage;
  13. using EMIS.CommonLogic.Students;
  14. using EMIS.CommonLogic.SystemServices;
  15. using EMIS.Entities;
  16. using EMIS.Utility;
  17. using EMIS.ViewModel;
  18. using EMIS.ViewModel.Students;
  19. using EMIS.Web.Controls;
  20. using System.Net;
  21. using System.Globalization;
  22. using Newtonsoft.Json;
  23. using EMIS.CommonLogic.DataCenterSynch;
  24. using Bowin.Common.Log;
  25. namespace EMIS.Web.Controllers.Students
  26. {
  27. [Authorization]
  28. public class StudentsController : Controller
  29. {
  30. public Lazy<IStudentsServices> StudentfileServices { get; set; }
  31. public Lazy<IUserServices> userServices { get; set; }
  32. public Lazy<ISchoolYearServices> schoolYearServices { get; set; }
  33. public IStudentSynchServices StudentSynchServices { get; set; }
  34. /// <summary>
  35. /// 学生信息页面
  36. /// </summary>
  37. /// <returns></returns>
  38. public ActionResult List()
  39. {
  40. return View();
  41. }
  42. public ActionResult InfoExport(string selectedIDs)
  43. {
  44. ViewBag.selectedID = selectedIDs;
  45. return View();
  46. }
  47. /// <summary>
  48. /// 列表查询
  49. /// </summary>
  50. /// <param name="pararms"></param>
  51. /// <param name="inSchoolStatus">在校状态</param>
  52. /// <returns></returns>
  53. [HttpPost]
  54. public ActionResult List(QueryParamsModel pararms)
  55. {
  56. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  57. //避开全选值
  58. //var campusID = pararms.getExtraGuid("CampusDropdown");
  59. var campusID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea");
  60. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  61. var classmajorID = pararms.getExtraGuid("ClassmajorDropdown");
  62. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  63. var learningformID = pararms.getExtraInt("LearningformDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("LearningformDictionaryDropDown");
  64. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  65. var inSchoolStatusID = pararms.getExtraInt("InSchoolStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("InSchoolStatusDictionaryDropDown");
  66. var generalPurposeID = pararms.getExtraInt("GeneralPurposeDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("GeneralPurposeDictionaryDropDown");
  67. var isPhotos = pararms.getExtraInt("YesOrNoStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatusDictionaryDropDown");//是否有照片
  68. var isDream = pararms.getExtraInt("YesOrNoStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatus");//是否圆梦计划
  69. var planningGraduateDate = pararms.getExtraString("PlanningGraduateDropDown");
  70. var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
  71. var education = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  72. var reportStatusID = pararms.getExtraInt("ReportStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ReportStatusDictionaryDropDown");
  73. //DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
  74. //dtFormat.ShortDatePattern = "yyyyMMdd";
  75. //var planningGraduateDate;
  76. //if (str != "" && !str.Equals(""))
  77. //{
  78. // planningGraduateDate = Convert.ToDateTime(str, dtFormat); //== DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatus");
  79. //}
  80. return base.Json(StudentfileServices.Value.GetStudentUserViewList(configuretView, campusID, collegeID, yearID, standardID,
  81. learningformID, classmajorID, generalPurposeID, inSchoolStatusID, isPhotos, isDream, planningGraduateDate, LearnSystem, education, reportStatusID, (int)pararms.page, (int)pararms.rows));
  82. }
  83. /// <summary>
  84. /// 学生信息页面
  85. /// </summary>
  86. /// <returns></returns>
  87. public ActionResult GdssList()
  88. {
  89. return View();
  90. }
  91. /// <summary>
  92. /// 列表查询
  93. /// </summary>
  94. /// <param name="pararms"></param>
  95. /// <param name="inSchoolStatus">在校状态</param>
  96. /// <returns></returns>
  97. [HttpPost]
  98. public ActionResult GdssList(QueryParamsModel pararms)
  99. {
  100. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  101. //避开全选值
  102. var campusID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea");
  103. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  104. var classmajorID = pararms.getExtraGuid("ClassmajorDropdown");
  105. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  106. var learningformID = pararms.getExtraInt("LearningformDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("LearningformDictionaryDropDown");
  107. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  108. var inSchoolStatusID = pararms.getExtraInt("InSchoolStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("InSchoolStatusDictionaryDropDown");
  109. var generalPurposeID = pararms.getExtraInt("GeneralPurposeDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("GeneralPurposeDictionaryDropDown");
  110. var isPhotos = pararms.getExtraInt("YesOrNoStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatusDictionaryDropDown");//是否有照片
  111. var isDream = pararms.getExtraInt("YesOrNoStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatus");//是否圆梦计划
  112. var planningGraduateDate = pararms.getExtraString("PlanningGraduateDropDown");
  113. var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
  114. var education = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  115. var reportStatusID = pararms.getExtraInt("ReportStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ReportStatusDictionaryDropDown");
  116. //DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
  117. //dtFormat.ShortDatePattern = "yyyyMMdd";
  118. //var planningGraduateDate;
  119. //if (str != "" && !str.Equals(""))
  120. //{
  121. // planningGraduateDate = Convert.ToDateTime(str, dtFormat); //== DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatus");
  122. //}
  123. return base.Json(StudentfileServices.Value.GetStudentUserViewList(configuretView, campusID, collegeID, yearID, standardID,
  124. learningformID, classmajorID, generalPurposeID, inSchoolStatusID, isPhotos, isDream, planningGraduateDate, LearnSystem, education, reportStatusID, (int)pararms.page, (int)pararms.rows));
  125. }
  126. /// <summary>
  127. /// 查询学生信息
  128. /// </summary>
  129. /// <param name="pararms"></param>
  130. /// <returns></returns>
  131. [HttpPost]
  132. public ActionResult BaseStudentViewList(QueryParamsModel pararms)
  133. {
  134. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  135. var collegeID = pararms.getExtraGuid("CollegeComboGrid");
  136. var grademajorID = pararms.getExtraGuid("GrademajorComboGrid");
  137. var classmajorID = pararms.getExtraGuid("ClassmajorComboGrid");
  138. var userID = pararms.getExtraGuid("StudentComboGrid");
  139. //var inSchool = Request.Form["InSchool"];
  140. return Json(StudentfileServices.Value.GetBaseStudentView(configuretView, collegeID, grademajorID, classmajorID, userID, (int)pararms.page, (int)pararms.rows));
  141. }
  142. //<summary>
  143. //编辑页面
  144. //</summary>
  145. //<returns></returns>
  146. [HttpGet]
  147. public ActionResult Edit(Guid? Userids,string type)
  148. {
  149. StudentsView StudentfileServicesr = new StudentsView();
  150. StudentfileServicesr.StudentType = (int)CF_STUDENTTYPE.DefaultType;
  151. if (Userids != null && Userids != Guid.Empty)
  152. StudentfileServicesr = StudentfileServices.Value.GetStudentfileView((Guid)Userids);
  153. //设置预计毕业学期 方案二
  154. if (StudentfileServicesr.GradeMajorID.HasValue)
  155. {
  156. //string GetPlanningGraduate = StudentfileServices.Value.GetPlanningGraduate((Guid)StudentfileServicesr.GradeMajorID);
  157. //if (GetPlanningGraduate != "")
  158. //{
  159. // StudentfileServicesr.PlanningGraduateDate = Convert.ToDateTime(GetPlanningGraduate);
  160. // StudentfileServicesr.PlanningGraduateDateStr = Convert.ToDateTime(GetPlanningGraduate);
  161. //}
  162. }
  163. if (type == "copyAdd" && Userids!=null)
  164. {
  165. StudentfileServicesr.UserID = Guid.Empty;
  166. StudentfileServicesr.LoginID = null;
  167. StudentfileServicesr.IDNumber = null;
  168. StudentfileServicesr.UserName = null;
  169. StudentfileServicesr.PhotoUrl = null;
  170. StudentfileServicesr.StudentType = (int)CF_STUDENTTYPE.DefaultType;
  171. }
  172. return View(StudentfileServicesr);
  173. }
  174. /// <summary>
  175. /// 编辑页面
  176. /// </summary>
  177. /// <returns></returns>
  178. [HttpPost]
  179. public ActionResult Edit(StudentsView studentfileView)
  180. {
  181. try
  182. {
  183. //获取用户
  184. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  185. var accepts = new List<string> { ".jpg" };
  186. var postedFile = Request.Files["PhotoUrl"];
  187. if (!string.IsNullOrEmpty(postedFile.FileName) && !accepts.Contains(Path.GetExtension(postedFile.FileName).ToLower()))
  188. {
  189. throw new Exception("只允许上传.jpg格式的文件。");
  190. }
  191. if (!string.IsNullOrEmpty(postedFile.FileName) && (postedFile.ContentLength > (200 * 1024) || postedFile.ContentLength < (50 * 1024)))
  192. {
  193. throw new Exception("只允许上传50-200k大小的照片。");
  194. }
  195. string photoUrl = FileUploadHelper.UploadFile(postedFile);
  196. if (photoUrl != null)
  197. {
  198. studentfileView.PhotoUrl = photoUrl;
  199. }
  200. this.StudentfileServices.Value.Save(studentfileView);
  201. string UrlStr = Url.Action("Edit").AddMenuParameter() + "&Userids=" + studentfileView.UserID;
  202. if (studentfileView.UserID != null && studentfileView.UserID != Guid.Empty)
  203. {
  204. UrlStr = Url.Action("Edit").AddMenuParameter() + "&Userids=" + studentfileView.UserID + "&type=copyEdit";
  205. }
  206. return RedirectToAction("MsgShowAndOpenAddUrl", "Common", new
  207. {
  208. WindowID = Request["WindowID"],
  209. msg = "保存成功!",
  210. url = UrlStr,
  211. title = "学生信息修改"
  212. });
  213. }
  214. catch (Exception ex)
  215. {
  216. string UrlStr = Url.Action("Edit").AddMenuParameter();
  217. if (studentfileView.UserID != null && studentfileView.UserID != Guid.Empty)
  218. {
  219. UrlStr += "&Userids=" + studentfileView.UserID + "&type=copyEdit";
  220. }
  221. return RedirectToAction("MsgShowAndOpenAddUrl", "Common", new
  222. {
  223. title = "学生信息修改",
  224. WindowID = Request["WindowID"],
  225. msg = "保存失败!" + ex.Message,
  226. url = UrlStr
  227. });
  228. }
  229. }
  230. public ActionResult StudentExperience()
  231. {
  232. return View();
  233. }
  234. //<summary>
  235. //导出数据
  236. //</summary>
  237. //<returns></returns> Excel字段调整 2016年9月29日11:09:43 zhanghl
  238. [HttpPost]
  239. public ActionResult Excel()
  240. {
  241. NpoiExcelHelper neh = new NpoiExcelHelper();
  242. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  243. var UserIDs = Request.Form["UserIDs"];
  244. var campusID = Request.Form["ddlSchoolArea"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlSchoolArea"].ParseStrTo<int>();
  245. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  246. var classmajorID = Request.Form["ClassmajorDropdown"].ParseStrTo<Guid>();
  247. var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
  248. var learningformID = Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>();
  249. var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
  250. var inSchoolStatusID = Request.Form["InSchoolStatusDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["InSchoolStatusDictionaryDropDown"].ParseStrTo<int>();
  251. var generalPurposeID = Request.Form["GeneralPurposeDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["GeneralPurposeDictionaryDropDown"].ParseStrTo<int>();
  252. var isPhotos = Request.Form["YesOrNoStatusDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["YesOrNoStatusDictionaryDropDown"].ParseStrTo<int>();//是否有照片
  253. var isDream = Request.Form["YesOrNoStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["YesOrNoStatus"].ParseStrTo<int>();//是否圆梦计划
  254. var planningGraduateDate = "";
  255. //Request.Form["PlanningGraduateDropDown"].ToString();
  256. var LearnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  257. var education = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  258. var reportStatusID = Request.Form["ReportStatusDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ReportStatusDictionaryDropDown"].ParseStrTo<int>();
  259. List<Guid?> UserIDsIDList = new List<Guid?>();
  260. if (UserIDs != "")
  261. {
  262. UserIDsIDList = UserIDs.SplitIDString();
  263. }
  264. else
  265. {
  266. UserIDsIDList = null;
  267. }
  268. var dt = StudentfileServices.Value.GetStudentViewList(configuretView, campusID, collegeID, yearID, standardID,
  269. learningformID, classmajorID, generalPurposeID, inSchoolStatusID, isPhotos, isDream, planningGraduateDate, LearnSystem, education, reportStatusID, UserIDsIDList)
  270. .Select(x => new
  271. {
  272. x.ExamineeNum,
  273. x.StudentNo,
  274. x.UserName,
  275. x.SexName,
  276. BirthDate = (x.BirthDate.HasValue ? x.BirthDate.Value.ToString("yyyy-MM-dd") : ""),
  277. x.CertificatesTypeName,
  278. x.IDNumber,
  279. x.PoliticsName,
  280. x.NationName,
  281. x.StandardCode,
  282. x.StandardName,
  283. x.FacultymajorName,
  284. x.SchoolAreaName,
  285. x.CampusName,
  286. x.CollegeName,
  287. x.ClassMajorCode,
  288. x.EducationName,
  289. x.LearningformName,
  290. LearnSystem = (x.LearnSystem.HasValue ? x.LearnSystem.Value.ToString("#.#") : ""),
  291. EntranceDate = (x.EntranceDate.HasValue ? x.EntranceDate.Value.ToString("yyyy-MM-dd") : ""),
  292. PlanningGraduateDate = (x.PlanningGraduateDate.HasValue ? x.PlanningGraduateDate.Value.ToString("yyyy-MM-dd") : ""),
  293. x.CardNo,
  294. x.InSchoolStatusName,
  295. x.StudentStatusName,
  296. x.ClassMajorName,
  297. x.Dormitory,
  298. x.GraduateCardNo,
  299. x.StudentCardNo,
  300. x.EntranceWayName,
  301. x.SchoolTypeName,
  302. x.CultureModelName,
  303. x.ExamineeTypeName,
  304. x.FeaturesName,
  305. x.TerritorialName,
  306. x.Area,
  307. x.Place,
  308. x.StudentTypeName,
  309. PhotoUrlNO = x.LoginID,
  310. x.Score,
  311. x.HealthyName,
  312. x.Email,
  313. x.QQ,
  314. x.Mobile,
  315. x.Telephone,
  316. x.ZipCode,
  317. x.HomeAddress,
  318. x.Recipient,
  319. x.Placebirth,
  320. x.UsedName,
  321. x.Specialty,
  322. x.Height,
  323. x.Weight,
  324. x.WorkUnit,
  325. x.IsDreamProjectName,
  326. x.Career,
  327. x.Remarks
  328. }).ToTable();
  329. string[] liststring = {
  330. "教育部考生号","学号","姓名","性别","出生日期","证件类型","证件号码","政治面貌","民族"
  331. ,"专业代码","专业名称",RSL.Get("College")+"专业","校区","分院(校)","系所函授站","班号","层次"
  332. ,"学习形式","学制","入学日期","预计毕业日期","银行卡号","在校状态","学籍状态"
  333. ,"班级名称","宿舍","毕结业证书编号","学籍卡编号","入学方式","办学类型","培养方式"
  334. ,"考生类别","考生特征","生源所属地","来源地区","籍贯","学生类别","相片编号","高考总分"
  335. ,"健康状态","电子邮箱","QQ","移动电话","固定电话","邮编","家庭地址","收件人","出生地","曾用名"
  336. ,"特长","身高(CM)","体重(KG)","工作单位","是否圆梦计划","在校经历","备注"};
  337. neh.Export(dt, liststring, "学生信息");
  338. return RedirectToAction("MsgShow", "Common", new
  339. {
  340. msg = "导出成功!",
  341. url = Url.Content("~/Students/List").AddMenuParameter()
  342. });
  343. }
  344. //<summary>
  345. //学籍信息导出Excel dbf
  346. //</summary>
  347. //<returns></returns> Excel字段调整 2016年9月29日11:09:43 zhanghl
  348. [HttpPost]
  349. public ActionResult InfoExcel(QueryParamsModel pararms, string selectedIDs, string colnames, string showname)
  350. {
  351. NpoiExcelHelper neh = new NpoiExcelHelper();
  352. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  353. string WindowStr = Request.UrlReferrer.ToString();
  354. int IndexofID = WindowStr.LastIndexOf("=");
  355. WindowStr = WindowStr.Remove(0, IndexofID + 1);
  356. var campusID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea");
  357. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  358. var classmajorID = pararms.getExtraGuid("ClassmajorDropdown");
  359. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  360. var learningformID = pararms.getExtraInt("LearningformDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("LearningformDictionaryDropDown");
  361. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  362. var inSchoolStatusID = pararms.getExtraInt("InSchoolStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("InSchoolStatusDictionaryDropDown");
  363. var generalPurposeID = pararms.getExtraInt("GeneralPurposeDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("GeneralPurposeDictionaryDropDown");
  364. var isPhotos = pararms.getExtraInt("YesOrNoStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatusDictionaryDropDown");//是否有照片
  365. var isDream = pararms.getExtraInt("YesOrNoStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatus");//是否圆梦计划
  366. var planningGraduateDate = pararms.getExtraString("PlanningGraduateDropDown");
  367. var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
  368. var education = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  369. var reportStatusID = pararms.getExtraInt("ReportStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ReportStatusDictionaryDropDown");
  370. List<string> namelist = new List<string>();
  371. for (int i = 0; i < showname.Split(',').Length; i++)
  372. {
  373. string col = showname.Split(',')[i];
  374. if (!string.IsNullOrEmpty(col))
  375. {
  376. namelist.Add(col);
  377. }
  378. }
  379. List<string> idlist = new List<string>();
  380. for (int i = 0; i < colnames.Split(',').Length; i++)
  381. {
  382. string col = colnames.Split(',')[i];
  383. if (!string.IsNullOrEmpty(col))
  384. {
  385. idlist.Add(col);
  386. }
  387. }
  388. var dt = StudentfileServices.Value.GetStudentExportList(configuretView, campusID, collegeID, yearID, standardID,
  389. learningformID, classmajorID, generalPurposeID, inSchoolStatusID, isPhotos, isDream, planningGraduateDate, LearnSystem, education, reportStatusID)
  390. .Select(x => new
  391. {
  392. x.ExamineeNum,
  393. x.UserName,
  394. x.SexName,
  395. BirthDate = (x.BirthDate.HasValue ? x.BirthDate.Value.ToString("yyyyMMdd") : ""),
  396. x.IDNumber,
  397. x.SchoolCode,
  398. x.SchoolName,
  399. x.StandardCode,
  400. x.StandardName,
  401. LearnSystem = (x.LearnSystem.HasValue ? x.LearnSystem.Value.ToString("0.0") : ""),
  402. x.LearningformName,
  403. x.EducationName,
  404. EntranceDate = (x.EntranceDate.HasValue ? x.EntranceDate.Value.ToString("yyyyMMdd") : ""),
  405. PlanningGraduateDate = (x.PlanningGraduateDate.HasValue ? x.PlanningGraduateDate.Value.ToString("yyyyMMdd") : ""),
  406. x.GraduationResultName,
  407. x.GraduateCardNo,
  408. x.HeadMasterName,
  409. x.TerritorialName,
  410. x.LoginID,
  411. x.PoliticsName,
  412. x.NationName,
  413. x.CampusName,
  414. x.CollegeName,
  415. x.ClassNumStr,
  416. x.ClassMajorCode,
  417. x.ClassMajorName,
  418. x.Remarks
  419. }).ToTable(namelist);
  420. string[] liststring = idlist.ToArray();
  421. neh.Export(dt, liststring, "学籍信息");
  422. return RedirectToAction("MsgShow", "Common", new
  423. {
  424. msg = "导出成功!",
  425. url = Url.Content("~/Students/List").AddMenuParameter()
  426. });
  427. }
  428. //<summary>
  429. //学籍信息导出Excel dbf
  430. //</summary>
  431. //<returns></returns> Excel字段调整 2016年9月29日11:09:43 zhanghl
  432. [HttpPost]
  433. public ActionResult DbfExport(QueryParamsModel pararms, string selectedIDs, string colnames, string showname)
  434. {
  435. NpoiExcelHelper neh = new NpoiExcelHelper();
  436. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  437. string WindowStr = Request.UrlReferrer.ToString();
  438. int IndexofID = WindowStr.LastIndexOf("=");
  439. WindowStr = WindowStr.Remove(0, IndexofID + 1);
  440. var campusID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea");
  441. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  442. var classmajorID = pararms.getExtraGuid("ClassmajorDropdown");
  443. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  444. var learningformID = pararms.getExtraInt("LearningformDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("LearningformDictionaryDropDown");
  445. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  446. var inSchoolStatusID = pararms.getExtraInt("InSchoolStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("InSchoolStatusDictionaryDropDown");
  447. var generalPurposeID = pararms.getExtraInt("GeneralPurposeDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("GeneralPurposeDictionaryDropDown");
  448. var isPhotos = pararms.getExtraInt("YesOrNoStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatusDictionaryDropDown");//是否有照片
  449. var isDream = pararms.getExtraInt("YesOrNoStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatus");//是否圆梦计划
  450. var planningGraduateDate = pararms.getExtraString("PlanningGraduateDropDown");
  451. var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
  452. var education = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  453. var reportStatusID = pararms.getExtraInt("ReportStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ReportStatusDictionaryDropDown");
  454. List<string> namelist = new List<string>();
  455. for (int i = 0; i < showname.Split(',').Length; i++)
  456. {
  457. string col = showname.Split(',')[i];
  458. if (!string.IsNullOrEmpty(col))
  459. {
  460. namelist.Add(col);
  461. }
  462. }
  463. List<string> idlist = new List<string>();
  464. for (int i = 0; i < colnames.Split(',').Length; i++)
  465. {
  466. string col = colnames.Split(',')[i];
  467. if (!string.IsNullOrEmpty(col))
  468. {
  469. idlist.Add(col);
  470. }
  471. }
  472. var dt = StudentfileServices.Value.GetStudentExportList(configuretView, campusID, collegeID, yearID, standardID,
  473. learningformID, classmajorID, generalPurposeID, inSchoolStatusID, isPhotos, isDream, planningGraduateDate, LearnSystem, education, reportStatusID)
  474. .Select(x => new
  475. {
  476. x.ExamineeNum,
  477. x.UserName,
  478. x.SexName,
  479. BirthDate = (x.BirthDate.HasValue ? x.BirthDate.Value.ToString("yyyyMMdd") : ""),
  480. x.IDNumber,
  481. x.SchoolCode,
  482. x.SchoolName,
  483. x.StandardCode,
  484. x.StandardName,
  485. LearnSystem = (x.LearnSystem.HasValue ? x.LearnSystem.Value.ToString("0.0") : ""),
  486. x.LearningformName,
  487. x.EducationName,
  488. EntranceDate = (x.EntranceDate.HasValue ? x.EntranceDate.Value.ToString("yyyyMMdd") : ""),
  489. PlanningGraduateDate = (x.PlanningGraduateDate.HasValue ? x.PlanningGraduateDate.Value.ToString("yyyyMMdd") : ""),
  490. x.GraduationResultName,
  491. x.GraduateCardNo,
  492. x.HeadMasterName,
  493. x.TerritorialName,
  494. x.LoginID,
  495. x.PoliticsName,
  496. x.NationName,
  497. x.CampusName,
  498. x.CollegeName,
  499. x.ClassNumStr,
  500. x.ClassMajorCode,
  501. x.ClassMajorName,
  502. x.Remarks,
  503. }).ToTable(namelist);
  504. string[] liststring = idlist.ToArray();
  505. StudentfileServices.Value.WriteToDbf(dt, idlist);
  506. var physicalPath = System.IO.Directory.GetCurrentDirectory() + "\\" + dt.TableName + ".dbf";
  507. return File(physicalPath, "application/x-dbf", "学籍信息.dbf");
  508. }
  509. [HttpPost]
  510. public ActionResult Delete(string userIDs)
  511. {
  512. try
  513. {
  514. List<Guid> list = new List<Guid>();
  515. for (int i = 0; i < userIDs.Split(',').Length; i++)
  516. {
  517. string id = userIDs.Split(',')[i];
  518. if (!string.IsNullOrEmpty(id))
  519. {
  520. Guid userID = new Guid(id);
  521. list.Add(userID);
  522. }
  523. }
  524. StudentfileServices.Value.StudentDelete(list);
  525. return base.Json("删除成功!");
  526. }
  527. catch (Exception ex)
  528. {
  529. string mge = ex.Message;
  530. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  531. if (num != null)
  532. {
  533. if (num.Number == 547)
  534. mge = "请先删除所有关联的数据,学期注册,任务管理,学生成绩等";
  535. }
  536. return base.Json("删除失败,原因:" + mge + "!");
  537. }
  538. }
  539. [HttpGet]
  540. public ActionResult Import(string errorFile)
  541. {
  542. ViewBag.ErrorFile = errorFile;
  543. return View();
  544. }
  545. [HttpPost]
  546. public ActionResult Import(HttpPostedFileBase file)
  547. {
  548. try
  549. {
  550. var accept = new[] { ".xls" };
  551. var p = Path.GetExtension(file.FileName);
  552. if (!accept.Contains(p))
  553. {
  554. throw new Exception("只允许上传xls格式的Excel文件!");
  555. }
  556. string sourceWebPath = FileUploadHelper.UploadFile(file);
  557. var sourcePhysicalPath = Server.MapPath(sourceWebPath);
  558. var excel = new NpoiExcelHelper();
  559. var dataSource = excel.ImpotColumns(sourcePhysicalPath);
  560. System.IO.File.Delete(sourcePhysicalPath);
  561. var errorSource = StudentfileServices.Value.Import(dataSource);
  562. var errorCount = errorSource.Rows.Count;
  563. if (errorCount > 0)
  564. {
  565. var errorPhysicalPath = sourcePhysicalPath;
  566. excel.SaveInServer(errorSource, errorPhysicalPath);
  567. var errorWebPath = sourceWebPath;
  568. return RedirectToAction("MsgShow", "Common", new
  569. {
  570. WindowID = "none",
  571. msg = "导入失败!",
  572. url = Url.Action("Import").AddMenuParameter() + "&errorFile=" + errorWebPath + "&WindowID=" + Request["WindowID"]
  573. });
  574. }
  575. else
  576. {
  577. return RedirectToAction("MsgShow", "Common", new
  578. {
  579. WindowID = Request["WindowID"],
  580. msg = "导入成功!",
  581. url = Url.Action("List").AddMenuParameter()
  582. });
  583. }
  584. }
  585. catch (Exception ex)
  586. {
  587. return RedirectToAction("MsgShow", "Common", new
  588. {
  589. WindowID = Request["WindowID"],
  590. msg = "导入发生错误!" + ex.Message,
  591. url = Url.Action("List").AddMenuParameter()
  592. });
  593. }
  594. }
  595. [HttpGet]
  596. public ActionResult PicImport(string errorFile)
  597. {
  598. ViewBag.ErrorFile = errorFile;
  599. return View();
  600. }
  601. [HttpPost]
  602. public ActionResult PicImport(HttpPostedFileBase file)
  603. {
  604. try
  605. {
  606. if (file.ContentLength <= 0)
  607. {
  608. throw new Exception("请选择上传文件!");
  609. }
  610. var acceptFileExtensions = new[] { ".zip", ".rar" };
  611. var p = Path.GetExtension(file.FileName);
  612. if (!acceptFileExtensions.Contains(p))
  613. {
  614. throw new Exception("只允许上传zip或rar格式的压缩包!");
  615. }
  616. var photoPaths = FileUploadHelper.UploadFileAndExtractFile(file);
  617. if (photoPaths.Count <= 0)
  618. {
  619. throw new Exception("压缩包中没有文件!");
  620. }
  621. List<string> listphotoPaths = new List<string>();
  622. var acceptPicExtensions = new[] { ".jpg" };
  623. foreach (var path in photoPaths)
  624. {
  625. string pathxiao = Path.GetExtension(path).ToLower();
  626. if (acceptPicExtensions.Contains(pathxiao))
  627. {
  628. listphotoPaths.Add(path);
  629. }
  630. }
  631. var errorDatatable = StudentfileServices.Value.PicImport(listphotoPaths);
  632. if (errorDatatable.Rows.Count > 0)
  633. {
  634. string filePath = Const.LOCAL_SETTING_UPLOAD_FILEPATH;
  635. var webFileName = filePath + "/" + Path.GetFileName("照片导入错误数据.xls");
  636. var sourcePhysicalPath = Server.MapPath(webFileName);
  637. var excel = new NpoiExcelHelper();
  638. excel.SaveInServer(errorDatatable, sourcePhysicalPath);
  639. var errorWebPath = webFileName.Substring(1,webFileName.Length - 1);
  640. return RedirectToAction("MsgShow", "Common", new
  641. {
  642. WindowID = "none",
  643. msg = "导入失败!",
  644. url = Url.Action("PicImport").AddMenuParameter() + "&errorFile=" + errorWebPath + "&WindowID=" + Request["WindowID"]
  645. });
  646. }
  647. else
  648. {
  649. return RedirectToAction("MsgShow", "Common", new
  650. {
  651. WindowID = Request["WindowID"],
  652. msg = "导入照片成功!",
  653. url = Url.Action("List").AddMenuParameter()
  654. });
  655. }
  656. }
  657. catch (Exception ex)
  658. {
  659. return RedirectToAction("MsgShow", "Common", new
  660. {
  661. WindowID = "none",
  662. msg = "导入照片失败!" + ex.Message,
  663. url = Url.Action("PicImport").AddMenuParameter() + "&WindowID=" + Request["WindowID"]
  664. });
  665. }
  666. }
  667. [HttpGet]
  668. public ActionResult GraduatePicImport()
  669. {
  670. return View();
  671. }
  672. [HttpPost]
  673. public ActionResult GraduationPicImport(HttpPostedFileBase file)
  674. {
  675. try
  676. {
  677. if (file.ContentLength <= 0)
  678. {
  679. throw new Exception("请选择上传文件!");
  680. }
  681. var acceptFileExtensions = new[] { ".zip", ".rar" };
  682. var p = Path.GetExtension(file.FileName);
  683. if (!acceptFileExtensions.Contains(p))
  684. {
  685. throw new Exception("只允许上传zip或rar格式的压缩包!");
  686. }
  687. var photoPaths = FileUploadHelper.UploadFileAndExtractFile(file);
  688. if (photoPaths.Count <= 0)
  689. {
  690. throw new Exception("压缩包中没有文件!");
  691. }
  692. List<string> listphotoPaths = new List<string>();
  693. var acceptPicExtensions = new[] { ".jpg" };
  694. foreach (var path in photoPaths)
  695. {
  696. string pathxiao = Path.GetExtension(path).ToLower();
  697. if (acceptPicExtensions.Contains(pathxiao))
  698. {
  699. listphotoPaths.Add(path);
  700. }
  701. }
  702. StudentfileServices.Value.GraduationPicImport(listphotoPaths);
  703. return RedirectToAction("MsgShow", "Common", new
  704. {
  705. WindowID = Request["WindowID"],
  706. msg = "导入毕业相片成功!",
  707. url = Url.Action("List").AddMenuParameter()
  708. });
  709. }
  710. catch (Exception ex)
  711. {
  712. return RedirectToAction("MsgShow", "Common", new
  713. {
  714. WindowID = "none",
  715. msg = "导入毕业相片失败!" + ex.Message,
  716. url = Url.Action("GraduatePicImport").AddMenuParameter() + "&WindowID=" + Request["WindowID"]
  717. });
  718. }
  719. }
  720. /// <summary>
  721. /// 添加更新前验证
  722. /// </summary>
  723. /// <param name="universityID"></param>
  724. /// <param name="code"></param>
  725. /// <returns></returns>
  726. [HttpPost]
  727. public ActionResult Verification(Guid? Userid, string Code, string ReplaceGraduateNo)
  728. {
  729. Sys_User userNo = null;
  730. Sys_User userInfo = null;
  731. if (!string.IsNullOrEmpty(Code))
  732. {
  733. userNo = userServices.Value.GetUserByLoginID(Code.Trim());
  734. if (!string.IsNullOrEmpty(Code) && Userid != Guid.Empty)
  735. {
  736. if (!string.IsNullOrEmpty(ReplaceGraduateNo))
  737. {
  738. var isexistReplaceGraduateNo = StudentfileServices.Value.GetReplaceGraduateNo(ReplaceGraduateNo,Userid);
  739. if (isexistReplaceGraduateNo != null)
  740. {
  741. return base.Json("保存失败,补证号已经存在,请重新输入。");
  742. }
  743. }
  744. userInfo = StudentfileServices.Value.GetStudenter(Userid).Sys_User;
  745. if (userNo == userInfo)
  746. {
  747. return base.Json("成功");
  748. }
  749. else
  750. {
  751. if (userNo != null)
  752. {
  753. return base.Json("保存失败,学生号已经存在,请重新输入!");
  754. }
  755. }
  756. }
  757. else
  758. {
  759. if (userNo != null)
  760. {
  761. return base.Json("保存失败,学生号已经存在,请重新输入!");
  762. }
  763. }
  764. }
  765. if (Userid.HasValue && Userid != Guid.Empty)
  766. {
  767. userInfo = StudentfileServices.Value.GetStudenter(Userid).Sys_User;
  768. if (userInfo == null)
  769. {
  770. return base.Json("保存失败,未能找到相对应的数据!");
  771. }
  772. }
  773. return base.Json("成功");
  774. }
  775. /// <summary>
  776. /// 计算毕业日期
  777. /// </summary>
  778. /// <returns></returns>
  779. public ActionResult GetPlanningGraduateDate(Guid? GradeMajorID)
  780. {
  781. string planningGraduateDate = string.Empty;
  782. //var schoolyear = schoolYearServices.Value.GetSchoolYear(schoolYearID);
  783. //if (schoolyear != null)
  784. //{
  785. // DateTime dtime = PlanningGraduateDateHelper.GetPlanningGraduateDate(schoolyear);
  786. // planningGraduateDate = dtime.ToString("yyyy-MM-dd");
  787. //}
  788. //if (GradeMajorID.HasValue)
  789. //{
  790. // planningGraduateDate = StudentfileServices.Value.ReckonPlanningGraduateDate((Guid)GradeMajorID).Value.ToString("yyyy-MM-dd") + "";
  791. //}
  792. if (GradeMajorID.HasValue)
  793. {
  794. string PlanningGraduate = StudentfileServices.Value.GetPlanningGraduate((Guid)GradeMajorID);
  795. //planningGraduateDate = StudentfileServices.Value.GetPlanningGraduate((Guid)GradeMajorID).Value.ToString("yyyy-MM-dd") + "";
  796. }
  797. return base.Json(planningGraduateDate);
  798. }
  799. public ActionResult StudentProofReport(string LoginID)
  800. {
  801. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  802. var dataRange = StudentfileServices.Value.GetDataRange();
  803. ViewBag.DataRange = dataRange;
  804. ViewBag.UserID = curUser.UserID.ToString();
  805. return View();
  806. }
  807. [HttpGet]
  808. public ActionResult ExportPictures(string selectedIDs)
  809. {
  810. ViewBag.selectedID = selectedIDs;
  811. return View();
  812. }
  813. [HttpPost]
  814. public ActionResult ExportPictures(QueryParamsModel pararms, string ExportPictureType, string windowsssss)
  815. {
  816. try
  817. {
  818. string WindowStr = Request.UrlReferrer.ToString();
  819. int IndexofID = WindowStr.LastIndexOf("=");
  820. WindowStr = WindowStr.Remove(0,IndexofID+1);
  821. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  822. var campusID = Request.Form["ddlSchoolArea"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ddlSchoolArea"].ParseStrTo<int>();
  823. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  824. var classmajorID = Request.Form["ClassmajorDropdown"].ParseStrTo<Guid>();
  825. var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
  826. var learningformID = Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>();
  827. var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
  828. var inSchoolStatusID = Request.Form["InSchoolStatusDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["InSchoolStatusDictionaryDropDown"].ParseStrTo<int>();
  829. var generalPurposeID = Request.Form["GeneralPurposeDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["GeneralPurposeDictionaryDropDown"].ParseStrTo<int>();
  830. var isPhotos = Request.Form["YesOrNoStatusDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["YesOrNoStatusDictionaryDropDown"].ParseStrTo<int>();//是否有照片
  831. var isDream = Request.Form["YesOrNoStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["YesOrNoStatus"].ParseStrTo<int>();//是否圆梦计划
  832. var planningGraduateDate = "";
  833. //Request.Form["PlanningGraduateDropDown"].ToString();
  834. var LearnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  835. var education = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  836. var reportStatusID = Request.Form["ReportStatusDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ReportStatusDictionaryDropDown"].ParseStrTo<int>();
  837. var selectedIDs = Request.Form["SelectedIDs"];
  838. //WebClient conn = new WebClient();
  839. ExportPictureType = "IDNumberToPicture";
  840. List<StudentsView> studentList = new List<StudentsView>();
  841. if (!string.IsNullOrEmpty(selectedIDs))
  842. {
  843. var selectedIDList = selectedIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  844. studentList = this.StudentfileServices.Value.GetStudentViewListByIDList(selectedIDList).ToList();
  845. }
  846. else
  847. {
  848. studentList = this.StudentfileServices.Value.GetStudentViewList(configuretView, campusID, collegeID, yearID, standardID,
  849. learningformID, classmajorID, generalPurposeID, inSchoolStatusID, isPhotos, isDream, planningGraduateDate, LearnSystem, education, reportStatusID,null).ToList();
  850. }
  851. var remoteFileList = studentList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x =>
  852. new EMIS.Utility.FileUploadHelper.RemoteFileInfo
  853. {
  854. FileName = x.LoginID + Path.GetExtension(x.PhotoUrl.Trim()),
  855. RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : Url.Content(x.PhotoUrl.Trim()))
  856. }).ToList();
  857. if (ExportPictureType == "IDNumberToPicture")
  858. {
  859. remoteFileList = studentList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x =>
  860. new EMIS.Utility.FileUploadHelper.RemoteFileInfo
  861. {
  862. FileName = x.IDNumber + Path.GetExtension(x.PhotoUrl.Trim()),
  863. RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : Url.Content(x.PhotoUrl.Trim()))
  864. }).ToList();
  865. }
  866. if (ExportPictureType == "ExamineeNumToPicture")
  867. {
  868. remoteFileList = studentList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x =>
  869. new EMIS.Utility.FileUploadHelper.RemoteFileInfo
  870. {
  871. FileName = x.ExamineeNum + Path.GetExtension(x.PhotoUrl.Trim()),
  872. RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : Url.Content(x.PhotoUrl.Trim()))
  873. }).ToList();
  874. }
  875. if (ExportPictureType == "LoginIDandUserNameToPicture")
  876. {
  877. remoteFileList = studentList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x =>
  878. new EMIS.Utility.FileUploadHelper.RemoteFileInfo
  879. {
  880. FileName = x.LoginID + x.UserName + x.MicroMsgNo + x.Mobile + Path.GetExtension(x.PhotoUrl.Trim()),
  881. RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : Url.Content(x.PhotoUrl.Trim()))
  882. }).ToList();
  883. }
  884. if (remoteFileList.Count > 0)
  885. {
  886. var zipFileStream = FileUploadHelper.DownLoadFiles(Guid.NewGuid().ToString(), "学生相片", remoteFileList);
  887. return File(zipFileStream, System.Net.Mime.MediaTypeNames.Application.Zip, "学生相片.zip");
  888. }
  889. else
  890. {
  891. return RedirectToAction("MsgShow", "Common", new
  892. {
  893. WindowID = Request["WindowID"],
  894. msg = "没有相片可导出!",
  895. url = Url.Content("~/Students/List").AddMenuParameter()
  896. });
  897. }
  898. }
  899. catch (Exception ex)
  900. {
  901. return RedirectToAction("MsgShow", "Common", new
  902. {
  903. WindowID = Request["WindowID"],
  904. msg = ex.Message,
  905. url = Url.Content("~/Students/List").AddMenuParameter()
  906. });
  907. //string mge = ex.Message;
  908. //return base.Json("导出失败,原因:" + mge + "!");
  909. }
  910. }
  911. [HttpPost]
  912. public ActionResult GetDataRange()
  913. {
  914. return Json(StudentfileServices.Value.GetDataRange());
  915. }
  916. [HttpPost]
  917. public ActionResult StudentOnlyInSchool(QueryParamsModel pararms)
  918. {
  919. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  920. return base.Json(StudentfileServices.Value.GetStudentOnlyInSchool(configuretView, (int)pararms.page, (int)pararms.rows));
  921. }
  922. /// <summary>
  923. /// 列表查询
  924. /// </summary>
  925. /// <param name="pararms"></param>
  926. /// <param name="inSchoolStatus">在校状态</param>
  927. /// <returns></returns>
  928. [HttpPost]
  929. public ActionResult BatchSelectList(QueryParamsModel pararms)
  930. {
  931. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  932. //避开全选值
  933. var campusID = pararms.getExtraInt("ddlSchoolArea") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlSchoolArea");
  934. var collegeID = pararms.getExtraGuid("cbgCollege");
  935. var education = pararms.getExtraInt("ddlEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlEducation");
  936. var yearID = pararms.getExtraInt("ddlYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear");
  937. var standardID = pararms.getExtraInt("cbgStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("cbgStandard");
  938. var learningformID = pararms.getExtraInt("ddlLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlLearningform");
  939. var classNum = pararms.getExtraInt("ddlClassNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlClassNum");
  940. var studentStatusID = pararms.getExtraInt("ddlStudentStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlStudentStatus");
  941. var isPhotos = pararms.getExtraInt("ddlHasPhoto") == DropdownList.SELECT_ALL ? null : (bool?)(pararms.getExtraInt("ddlHasPhoto") == (int)CF_YesOrNoStatus.Yes);//是否有照片
  942. var isOnlyGraduation = pararms.getExtraBool("chkOnlyGraduation");
  943. var isPreviousNotGraduated = pararms.getExtraBool("chkPreviousNotGraduated");
  944. return base.Json(StudentfileServices.Value.GetStudentUserViewList(configuretView, campusID, collegeID, education, yearID, standardID,
  945. learningformID, classNum, studentStatusID, isPhotos, isOnlyGraduation, isPreviousNotGraduated, (int)pararms.page, (int)pararms.rows));
  946. }
  947. public ActionResult Synchr()
  948. {
  949. return View();
  950. }
  951. [HttpPost]
  952. public ActionResult Synchr(Guid? collegeID, int? year, int? schoolAreaID, string selectedColumns)
  953. {
  954. List<string> selectedColumnList = selectedColumns.Split(',').Where(x => !string.IsNullOrEmpty(x)).ToList();
  955. try
  956. {
  957. StudentSynchServices.SynchrByCondition(collegeID, year, schoolAreaID, selectedColumnList);
  958. return Json(new ReturnMessage { IsSuccess = true, Message = "同步成功。" });
  959. }
  960. catch (Exception ex)
  961. {
  962. string errorMessage = ex.Message;
  963. if (ex.InnerException != null)
  964. {
  965. errorMessage += ex.InnerException.Message;
  966. }
  967. return Json(new ReturnMessage()
  968. {
  969. IsSuccess = false,
  970. Message = "同步失败:" + errorMessage
  971. });
  972. }
  973. }
  974. }
  975. }