StudentsController.cs 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474
  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.StudentManage.StudentProfile;
  24. using EMIS.ViewModel.StudentManage.StudentProfile;
  25. using EMIS.ViewModel.DifferentDynamic;
  26. using System.Drawing;
  27. using System.Drawing.Imaging;
  28. namespace EMIS.Web.Controllers.Students
  29. {
  30. [Authorization]
  31. public class StudentsController : Controller
  32. {
  33. public Lazy<IStudentsServices> StudentfileServices { get; set; }
  34. public Lazy<IUserServices> userServices { get; set; }
  35. public Lazy<ISchoolYearServices> schoolYearServices { get; set; }
  36. public IStudentExperienceServices StudentExperienceServices { get; set; }
  37. public IStudentFamilyServices StudentFamilyServices { get; set; }
  38. public IDifferentDynamicServices differentDynamicServices { get; set; }
  39. public IDifferentDynamicServices DifferentDynamicServices { get; set; }
  40. public IStudentEncourageServices StudentEncourageServices { get; set; }
  41. /// <summary>
  42. /// 学生信息页面
  43. /// </summary>
  44. /// <returns></returns>
  45. public ActionResult List()
  46. {
  47. return View();
  48. }
  49. /// <summary>
  50. /// 列表查询
  51. /// </summary>
  52. /// <param name="pararms"></param>
  53. /// <param name="inSchoolStatus">在校状态</param>
  54. /// <returns></returns>
  55. [HttpPost]
  56. public ActionResult List(QueryParamsModel pararms)
  57. {
  58. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  59. //避开全选值
  60. var campusID = pararms.getExtraGuid("CampusDropdown");
  61. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  62. var classmajorID = pararms.getExtraGuid("ClassmajorDropdown");
  63. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  64. var learningformID = pararms.getExtraInt("LearningformDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("LearningformDictionaryDropDown");
  65. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  66. var inSchoolStatusID = pararms.getExtraInt("InSchoolStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("InSchoolStatusDictionaryDropDown");
  67. var generalPurposeID = pararms.getExtraInt("GeneralPurposeDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("GeneralPurposeDictionaryDropDown");
  68. var isPhotos = pararms.getExtraInt("YesOrNoStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatusDictionaryDropDown");//是否有照片
  69. var isDream = pararms.getExtraInt("YesOrNoStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatus");//是否圆梦计划
  70. var planningGraduateDate = pararms.getExtraString("PlanningGraduateDropDown");
  71. var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
  72. var education = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  73. var reportStatusID = pararms.getExtraInt("ReportStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ReportStatusDictionaryDropDown");
  74. //DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
  75. //dtFormat.ShortDatePattern = "yyyyMMdd";
  76. //var planningGraduateDate;
  77. //if (str != "" && !str.Equals(""))
  78. //{
  79. // planningGraduateDate = Convert.ToDateTime(str, dtFormat); //== DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatus");
  80. //}
  81. return base.Json(StudentfileServices.Value.GetStudentUserViewList(configuretView, campusID, collegeID, yearID, standardID,
  82. learningformID, classmajorID, generalPurposeID, inSchoolStatusID, isPhotos, isDream, planningGraduateDate, LearnSystem, education, reportStatusID, (int)pararms.page, (int)pararms.rows));
  83. }
  84. /// <summary>
  85. /// 学生信息页面
  86. /// </summary>
  87. /// <returns></returns>
  88. public ActionResult GdssList()
  89. {
  90. return View();
  91. }
  92. /// <summary>
  93. /// 列表查询
  94. /// </summary>
  95. /// <param name="pararms"></param>
  96. /// <param name="inSchoolStatus">在校状态</param>
  97. /// <returns></returns>
  98. [HttpPost]
  99. public ActionResult GdssList(QueryParamsModel pararms)
  100. {
  101. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  102. //避开全选值
  103. var campusID = pararms.getExtraGuid("CampusDropdown");
  104. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  105. var classmajorID = pararms.getExtraGuid("ClassmajorDropdown");
  106. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  107. var learningformID = pararms.getExtraInt("LearningformDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("LearningformDictionaryDropDown");
  108. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  109. var inSchoolStatusID = pararms.getExtraInt("InSchoolStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("InSchoolStatusDictionaryDropDown");
  110. var generalPurposeID = pararms.getExtraInt("GeneralPurposeDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("GeneralPurposeDictionaryDropDown");
  111. var isPhotos = pararms.getExtraInt("YesOrNoStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatusDictionaryDropDown");//是否有照片
  112. var isDream = pararms.getExtraInt("YesOrNoStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatus");//是否圆梦计划
  113. var planningGraduateDate = pararms.getExtraString("PlanningGraduateDropDown");
  114. var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
  115. var education = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  116. var reportStatusID = pararms.getExtraInt("ReportStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ReportStatusDictionaryDropDown");
  117. //DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
  118. //dtFormat.ShortDatePattern = "yyyyMMdd";
  119. //var planningGraduateDate;
  120. //if (str != "" && !str.Equals(""))
  121. //{
  122. // planningGraduateDate = Convert.ToDateTime(str, dtFormat); //== DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatus");
  123. //}
  124. return base.Json(StudentfileServices.Value.GetStudentUserViewList(configuretView, campusID, collegeID, yearID, standardID,
  125. learningformID, classmajorID, generalPurposeID, inSchoolStatusID, isPhotos, isDream, planningGraduateDate, LearnSystem, education, reportStatusID, (int)pararms.page, (int)pararms.rows));
  126. }
  127. /// <summary>
  128. /// 查询学生信息
  129. /// </summary>
  130. /// <param name="pararms"></param>
  131. /// <returns></returns>
  132. [HttpPost]
  133. public ActionResult BaseStudentViewList(QueryParamsModel pararms)
  134. {
  135. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  136. var collegeID = pararms.getExtraGuid("CollegeComboGrid");
  137. var grademajorID = pararms.getExtraGuid("GrademajorComboGrid");
  138. var classmajorID = pararms.getExtraGuid("ClassmajorComboGrid");
  139. var userID = pararms.getExtraGuid("StudentComboGrid");
  140. //var inSchool = Request.Form["InSchool"];
  141. return Json(StudentfileServices.Value.GetBaseStudentView(configuretView, collegeID, grademajorID, classmajorID, userID, (int)pararms.page, (int)pararms.rows));
  142. }
  143. //<summary>
  144. //编辑页面
  145. //</summary>
  146. //<returns></returns>
  147. [HttpGet]
  148. public ActionResult Edit(Guid? Userids,string type)
  149. {
  150. StudentsView StudentfileServicesr = new StudentsView();
  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. }
  171. return View(StudentfileServicesr);
  172. }
  173. /// <summary>
  174. /// 编辑页面
  175. /// </summary>
  176. /// <returns></returns>
  177. [HttpPost]
  178. public ActionResult Edit(StudentsView studentfileView)
  179. {
  180. try
  181. {
  182. //获取用户
  183. var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal;
  184. var accepts = new List<string> { ".jpg", ".jpeg", ".png", ".bmp" };
  185. var postedFile = Request.Files["PhotoUrl"];
  186. if (!string.IsNullOrEmpty(postedFile.FileName) && !accepts.Contains(Path.GetExtension(postedFile.FileName).ToLower()))
  187. {
  188. throw new Exception("只允许上传.jpg、.jpeg、.png、.bmp格式的文件。");
  189. }
  190. string photoUrl = FileUploadHelper.UploadFile(postedFile);
  191. if (photoUrl != null)
  192. {
  193. studentfileView.PhotoUrl = photoUrl;
  194. }
  195. this.StudentfileServices.Value.Save(studentfileView);
  196. string UrlStr = Url.Action("Edit").AddMenuParameter() + "&Userids=" + studentfileView.UserID;
  197. if (studentfileView.UserID != null && studentfileView.UserID != Guid.Empty)
  198. {
  199. UrlStr = Url.Action("Edit").AddMenuParameter() + "&Userids=" + studentfileView.UserID + "&type=copyEdit";
  200. }
  201. return RedirectToAction("MsgShowAndOpenAddUrl", "Common", new
  202. {
  203. WindowID = Request["WindowID"],
  204. msg = "保存成功!",
  205. url = UrlStr
  206. });
  207. }
  208. catch (Exception ex)
  209. {
  210. string UrlStr = Url.Action("Edit").AddMenuParameter() + "&Userids=" + studentfileView.UserID;
  211. if (studentfileView.UserID != null && studentfileView.UserID != Guid.Empty)
  212. {
  213. UrlStr = Url.Action("Edit").AddMenuParameter() + "&Userids=" + studentfileView.UserID + "&type=copyEdit";
  214. }
  215. return RedirectToAction("MsgShowAndOpenAddUrl", "Common", new
  216. {
  217. WindowID = Request["WindowID"],
  218. msg = "保存失败!" + ex.Message,
  219. url = UrlStr
  220. });
  221. }
  222. }
  223. //<summary>
  224. //编辑页面
  225. //</summary>
  226. //<returns></returns>
  227. [HttpGet]
  228. public ActionResult EditForGD(Guid? userIds, string type)
  229. {
  230. StudentsView StudentfileServicesr = new StudentsView();
  231. if (userIds != null && userIds != Guid.Empty)
  232. StudentfileServicesr = StudentfileServices.Value.GetStudentfileView((Guid)userIds);
  233. //设置预计毕业学期 方案二
  234. if (StudentfileServicesr.GradeMajorID.HasValue)
  235. {
  236. string GetPlanningGraduate = StudentfileServices.Value.GetPlanningGraduate((Guid)StudentfileServicesr.GradeMajorID);
  237. if (GetPlanningGraduate != "")
  238. {
  239. StudentfileServicesr.PlanningGraduateDate = Convert.ToDateTime(GetPlanningGraduate);
  240. StudentfileServicesr.PlanningGraduateDateStr = Convert.ToDateTime(GetPlanningGraduate);
  241. }
  242. }
  243. return View(StudentfileServicesr);
  244. }
  245. #region TODO:原学生信息Excel导出
  246. /// <summary>
  247. /// 导出数据
  248. /// </summary>
  249. /// <returns></returns>
  250. //[HttpPost]
  251. //public ActionResult Excel()
  252. //{
  253. // NpoiExcelHelper neh = new NpoiExcelHelper();
  254. // ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  255. // var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  256. // var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  257. // var classmajorID = Request.Form["ClassmajorDropdown"].ParseStrTo<Guid>();
  258. // var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
  259. // var learningformID = Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>();
  260. // var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
  261. // var inSchoolStatusID = Request.Form["InSchoolStatusDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["InSchoolStatusDictionaryDropDown"].ParseStrTo<int>();
  262. // var generalPurposeID = Request.Form["GeneralPurposeDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["GeneralPurposeDictionaryDropDown"].ParseStrTo<int>();
  263. // var dt = StudentfileServices.Value.GetStudentViewList(configuretView, campusID, collegeID, yearID, standardID,
  264. // learningformID, classmajorID, generalPurposeID, inSchoolStatusID)
  265. // .Select(x => new
  266. // {
  267. // x.LoginID,
  268. // x.UserName,
  269. // x.SexName,
  270. // x.PhotoUrl,
  271. // Certificatestypename = x.CertificatesTypeName,
  272. // x.IDNumber,
  273. // Studentcardno = x.StudentCardNo,
  274. // PlanningGraduateDate = x.PlanningGraduateDate.ToStringEx(MsgConsts.dateFormat),
  275. // CultureModelname = x.CultureModelName,
  276. // Studenttypename = x.StudentTypeName,
  277. // x.InSchoolStatusName,
  278. // ClassmajorName = x.ClassMajorName,
  279. // x.ExamineeNum,
  280. // ExamineeTypename = x.ExamineeTypeName,
  281. // EntranceDate = x.EntranceDate.ToStringEx(MsgConsts.dateFormat),
  282. // EntranceWayname = x.EntranceWayName,
  283. // x.Placebirth,
  284. // Featuresname = x.FeaturesName,
  285. // x.Score,
  286. // x.TerritorialName,
  287. // x.Area,
  288. // x.UsedName,
  289. // x.DirectorName,
  290. // BirthDate = x.BirthDate.ToStringEx(MsgConsts.dateFormat),
  291. // x.Country,
  292. // x.Politics,
  293. // Nationname = x.NationName,
  294. // x.Place,
  295. // Healthyname = x.HealthyName,
  296. // BloodGroupname = x.BloodGroupName,
  297. // x.Specialty,
  298. // x.Height,
  299. // x.Weight,
  300. // x.Email,
  301. // x.QQ,
  302. // x.Mobile,
  303. // x.Telephone,
  304. // x.MicroMsgNo,
  305. // Zipcode = x.ZipCode,
  306. // x.Address,
  307. // x.WorkUnit,
  308. // x.HomeAddress,
  309. // x.Recipient,
  310. // x.Dormitory,
  311. // x.Remarks
  312. // }).ToTable();
  313. // string[] liststring = { "学号", "姓名", "性别", "图片路径", "证件类型", "证件号码", "学籍卡编号", "预毕业日期", "培养方式",
  314. // "学生类别", "在校状态", "班级名称", "教育部考生号", "考生类别", "入学日期", "入学方式", "出生地", "考生特征",
  315. // "分数", "生源所属地", "来源地区", "曾用名", "导师姓名", "出生日期", "国籍", "政治面貌", "民族", "籍贯", "健康状态",
  316. // "血型", "特长", "身高", "体重", "电子邮箱", "QQ", "移动电话", "固定电话", "微信号", "邮编", "通信地址",
  317. // "工作单位", "家庭地址", "收件人", "宿舍编号", "备注"};
  318. // neh.Export(dt, liststring, "学生信息");
  319. // return RedirectToAction("MsgShow", "Common", new
  320. // {
  321. // msg = "导出成功!",
  322. // url = Url.Content("~/Students/List").AddMenuParameter()
  323. // });
  324. //}
  325. #endregion
  326. public ActionResult StudentExperience()
  327. {
  328. return View();
  329. }
  330. [HttpPost]
  331. public ActionResult StudentExperienceList(QueryParamsModel pararms)
  332. {
  333. return Json(StudentExperienceServices.GetTopStudentExperienceGridView(EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID, 5, pararms.page, pararms.rows));
  334. }
  335. [HttpPost]
  336. public ActionResult SaveStudentExperience()
  337. {
  338. var userID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID;
  339. var studentExperienceList = DataGrid.GetTableData<StudentExperienceView>("dgStudentExperienceList");
  340. try
  341. {
  342. this.StudentExperienceServices.Save(userID, studentExperienceList);
  343. return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" });
  344. }
  345. catch (Exception ex)
  346. {
  347. return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message });
  348. }
  349. }
  350. public ActionResult StudentFamily()
  351. {
  352. return View();
  353. }
  354. [HttpPost]
  355. public ActionResult StudentFamilyList(QueryParamsModel pararms)
  356. {
  357. return Json(StudentFamilyServices.GetTopStudentFamilyGridView(EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID, 4, pararms.page, pararms.rows));
  358. }
  359. [HttpPost]
  360. public ActionResult SaveStudentFamily()
  361. {
  362. var userID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID;
  363. var studentFamilyList = DataGrid.GetTableData<StudentFamilyView>("dgStudentFamilyList");
  364. try
  365. {
  366. this.StudentFamilyServices.Save(userID, studentFamilyList);
  367. return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" });
  368. }
  369. catch (Exception ex)
  370. {
  371. return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message });
  372. }
  373. }
  374. [HttpGet]
  375. public ActionResult Import(string errorFile)
  376. {
  377. ViewBag.ErrorFile = errorFile;
  378. return View();
  379. }
  380. [HttpPost]
  381. public ActionResult Import(HttpPostedFileBase file)
  382. {
  383. try
  384. {
  385. var accept = new[] { ".xls" };
  386. var p = Path.GetExtension(file.FileName);
  387. if (!accept.Contains(p))
  388. {
  389. throw new Exception("只允许上传xls格式的Excel文件!");
  390. }
  391. string sourceWebPath = FileUploadHelper.UploadFile(file);
  392. var sourcePhysicalPath = Server.MapPath(sourceWebPath);
  393. var excel = new NpoiExcelHelper();
  394. var dataSource = excel.ImpotColumns(sourcePhysicalPath);
  395. System.IO.File.Delete(sourcePhysicalPath);
  396. var errorSource = StudentfileServices.Value.Import(dataSource);
  397. var errorCount = errorSource.Rows.Count;
  398. if (errorCount > 0)
  399. {
  400. var errorPhysicalPath = sourcePhysicalPath;
  401. excel.SaveInServer(errorSource, errorPhysicalPath);
  402. var errorWebPath = sourceWebPath;
  403. return RedirectToAction("MsgShow", "Common", new
  404. {
  405. WindowID = "none",
  406. msg = "导入失败!",
  407. url = Url.Action("Import").AddMenuParameter() + "&errorFile=" + errorWebPath + "&WindowID=" + Request["WindowID"]
  408. });
  409. }
  410. else
  411. {
  412. return RedirectToAction("MsgShow", "Common", new
  413. {
  414. WindowID = Request["WindowID"],
  415. msg = "导入成功!",
  416. url = Url.Action("List").AddMenuParameter()
  417. });
  418. }
  419. }
  420. catch (Exception ex)
  421. {
  422. return RedirectToAction("MsgShow", "Common", new
  423. {
  424. WindowID = Request["WindowID"],
  425. msg = "导入发生错误!" + ex.Message,
  426. url = Url.Action("List").AddMenuParameter()
  427. });
  428. }
  429. }
  430. [HttpGet]
  431. public ActionResult PicImport()
  432. {
  433. return View();
  434. }
  435. [HttpPost]
  436. public ActionResult PicImport(HttpPostedFileBase file)
  437. {
  438. try
  439. {
  440. if (file.ContentLength <= 0)
  441. {
  442. throw new Exception("请选择上传文件!");
  443. }
  444. var acceptFileExtensions = new[] { ".zip", ".rar" };
  445. var p = Path.GetExtension(file.FileName);
  446. if (!acceptFileExtensions.Contains(p))
  447. {
  448. throw new Exception("只允许上传zip或rar格式的压缩包!");
  449. }
  450. var photoPaths = FileUploadHelper.UploadFileAndExtractFile(file);
  451. if (photoPaths.Count <= 0)
  452. {
  453. throw new Exception("压缩包中没有文件!");
  454. }
  455. List<string> listphotoPaths = new List<string>();
  456. var acceptPicExtensions = new[] { ".jpg", ".jpeg", ".png", ".bmp" };
  457. foreach (var path in photoPaths)
  458. {
  459. string pathxiao = Path.GetExtension(path).ToLower();
  460. if (acceptPicExtensions.Contains(pathxiao))
  461. {
  462. listphotoPaths.Add(path);
  463. }
  464. //{
  465. // throw new Exception("压缩包中含有不支持的图片格式!");
  466. //}
  467. //if (!acceptPicExtensions.Contains(Path.GetExtension(path)))
  468. //{
  469. // throw new Exception("压缩包中含有不支持的图片格式!");
  470. //}
  471. }
  472. StudentfileServices.Value.PicImport(listphotoPaths);
  473. return RedirectToAction("MsgShow", "Common", new
  474. {
  475. WindowID = Request["WindowID"],
  476. msg = "导入照片成功!",
  477. url = Url.Action("List").AddMenuParameter()
  478. });
  479. }
  480. catch (Exception ex)
  481. {
  482. return RedirectToAction("MsgShow", "Common", new
  483. {
  484. WindowID = "none",
  485. msg = "导入照片失败!" + ex.Message,
  486. url = Url.Action("PicImport").AddMenuParameter() + "&WindowID=" + Request["WindowID"]
  487. });
  488. }
  489. }
  490. [HttpGet]
  491. public ActionResult GraduatePicImport()
  492. {
  493. return View();
  494. }
  495. [HttpPost]
  496. public ActionResult GraduationPicImport(HttpPostedFileBase file)
  497. {
  498. try
  499. {
  500. if (file.ContentLength <= 0)
  501. {
  502. throw new Exception("请选择上传文件!");
  503. }
  504. var acceptFileExtensions = new[] { ".zip", ".rar" };
  505. var p = Path.GetExtension(file.FileName);
  506. if (!acceptFileExtensions.Contains(p))
  507. {
  508. throw new Exception("只允许上传zip或rar格式的压缩包!");
  509. }
  510. var photoPaths = FileUploadHelper.UploadFileAndExtractFile(file);
  511. if (photoPaths.Count <= 0)
  512. {
  513. throw new Exception("压缩包中没有文件!");
  514. }
  515. List<string> listphotoPaths = new List<string>();
  516. var acceptPicExtensions = new[] { ".jpg", ".jpeg", ".png", ".bmp" };
  517. foreach (var path in photoPaths)
  518. {
  519. string pathxiao = Path.GetExtension(path).ToLower();
  520. if (acceptPicExtensions.Contains(pathxiao))
  521. {
  522. listphotoPaths.Add(path);
  523. }
  524. }
  525. StudentfileServices.Value.GraduationPicImport(listphotoPaths);
  526. return RedirectToAction("MsgShow", "Common", new
  527. {
  528. WindowID = Request["WindowID"],
  529. msg = "导入学历照片成功!",
  530. url = Url.Action("List").AddMenuParameter()
  531. });
  532. }
  533. catch (Exception ex)
  534. {
  535. return RedirectToAction("MsgShow", "Common", new
  536. {
  537. WindowID = "none",
  538. msg = "导入学历照片失败!" + ex.Message,
  539. url = Url.Action("GraduatePicImport").AddMenuParameter() + "&WindowID=" + Request["WindowID"]
  540. });
  541. }
  542. }
  543. /// <summary>
  544. /// 添加更新前验证
  545. /// </summary>
  546. /// <param name="universityID"></param>
  547. /// <param name="code"></param>
  548. /// <returns></returns>
  549. [HttpPost]
  550. public ActionResult Verification(Guid? Userid, string Code, string ReplaceGraduateNo)
  551. {
  552. Sys_User userNo = null;
  553. Sys_User userInfo = null;
  554. if (!string.IsNullOrEmpty(Code))
  555. {
  556. userNo = userServices.Value.GetUserByLoginID(Code.Trim());
  557. if (!string.IsNullOrEmpty(Code) && Userid != Guid.Empty)
  558. {
  559. if (!string.IsNullOrEmpty(ReplaceGraduateNo))
  560. {
  561. var isexistReplaceGraduateNo = StudentfileServices.Value.GetReplaceGraduateNo(ReplaceGraduateNo,Userid);
  562. if (isexistReplaceGraduateNo != null)
  563. {
  564. return base.Json("保存失败,补证号已经存在,请重新输入。");
  565. }
  566. }
  567. userInfo = StudentfileServices.Value.GetStudenter(Userid).Sys_User;
  568. if (userNo == userInfo)
  569. {
  570. return base.Json("成功");
  571. }
  572. else
  573. {
  574. if (userNo != null)
  575. {
  576. return base.Json("保存失败,学生号已经存在,请重新输入!");
  577. }
  578. }
  579. }
  580. else
  581. {
  582. if (userNo != null)
  583. {
  584. return base.Json("保存失败,学生号已经存在,请重新输入!");
  585. }
  586. }
  587. }
  588. if (Userid.HasValue && Userid != Guid.Empty)
  589. {
  590. userInfo = StudentfileServices.Value.GetStudenter(Userid).Sys_User;
  591. if (userInfo == null)
  592. {
  593. return base.Json("保存失败,未能找到相对应的数据!");
  594. }
  595. }
  596. return base.Json("成功");
  597. }
  598. /// <summary>
  599. /// 删除
  600. /// </summary>
  601. /// <param name="facultymajorView"></param>
  602. /// <returns></returns>
  603. [HttpPost]
  604. public ActionResult Delete(string userIDs)
  605. {
  606. try
  607. {
  608. List<Guid> list = new List<Guid>();
  609. for (int i = 0; i < userIDs.Split(',').Length; i++)
  610. {
  611. string id = userIDs.Split(',')[i];
  612. if (!string.IsNullOrEmpty(id))
  613. {
  614. Guid userID = new Guid(id);
  615. list.Add(userID);
  616. }
  617. }
  618. StudentfileServices.Value.UserDelete(list);
  619. return base.Json("删除成功!");
  620. }
  621. catch (Exception ex)
  622. {
  623. string mge = ex.Message;
  624. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  625. if (num != null)
  626. {
  627. if (num.Number == 547)
  628. mge = "请先删除所有关联的数据,学期注册,任务管理,学生成绩等";
  629. }
  630. return base.Json("删除失败,原因:" + mge + "!");
  631. }
  632. }
  633. /// <summary>
  634. /// 计算毕业日期
  635. /// </summary>
  636. /// <returns></returns>
  637. public ActionResult GetPlanningGraduateDate(Guid? GradeMajorID)
  638. {
  639. string planningGraduateDate = string.Empty;
  640. //var schoolyear = schoolYearServices.Value.GetSchoolYear(schoolYearID);
  641. //if (schoolyear != null)
  642. //{
  643. // DateTime dtime = PlanningGraduateDateHelper.GetPlanningGraduateDate(schoolyear);
  644. // planningGraduateDate = dtime.ToString("yyyy-MM-dd");
  645. //}
  646. //if (GradeMajorID.HasValue)
  647. //{
  648. // planningGraduateDate = StudentfileServices.Value.ReckonPlanningGraduateDate((Guid)GradeMajorID).Value.ToString("yyyy-MM-dd") + "";
  649. //}
  650. if (GradeMajorID.HasValue)
  651. {
  652. string PlanningGraduate = StudentfileServices.Value.GetPlanningGraduate((Guid)GradeMajorID);
  653. //planningGraduateDate = StudentfileServices.Value.GetPlanningGraduate((Guid)GradeMajorID).Value.ToString("yyyy-MM-dd") + "";
  654. }
  655. return base.Json(planningGraduateDate);
  656. }
  657. /// <summary>
  658. ///
  659. /// </summary>
  660. /// <param name="LoginID"></param>
  661. /// <returns></returns>
  662. public ActionResult ClassStudentReport(string LoginID)
  663. {
  664. int? status = differentDynamicServices.GetCorrectEndStatus();
  665. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  666. var dataRange= StudentfileServices.Value.GetDataRange();
  667. ViewBag.DataRange = dataRange;
  668. ViewBag.UserID = curUser.UserID.ToString();
  669. ViewBag.Status = status;
  670. return View();
  671. }
  672. public ActionResult StudentProofReport(string LoginID)
  673. {
  674. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  675. var dataRange = StudentfileServices.Value.GetDataRange();
  676. ViewBag.DataRange = dataRange;
  677. ViewBag.UserID = curUser.UserID.ToString();
  678. return View();
  679. }
  680. [HttpGet]
  681. public ActionResult ExportPictures(string selectedIDs)
  682. {
  683. ViewBag.selectedID = selectedIDs;
  684. return View();
  685. }
  686. [HttpPost]
  687. public ActionResult ExportPictures(QueryParamsModel pararms, string selectedIDs, string ExportPictureType, string windowsssss)
  688. {
  689. try
  690. {
  691. string WindowStr = Request.UrlReferrer.ToString();
  692. int IndexofID = WindowStr.LastIndexOf("=");
  693. WindowStr = WindowStr.Remove(0,IndexofID+1);
  694. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  695. var campusID = pararms.getExtraGuid("CampusDropdown");
  696. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  697. var classmajorID = pararms.getExtraGuid("ClassmajorDropdown");
  698. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  699. var learningformID = pararms.getExtraInt("LearningformDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("LearningformDictionaryDropDown");
  700. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  701. var inSchoolStatusID = pararms.getExtraInt("InSchoolStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("InSchoolStatusDictionaryDropDown");
  702. var generalPurposeID = pararms.getExtraInt("GeneralPurposeDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("GeneralPurposeDictionaryDropDown");
  703. var isPhotos = pararms.getExtraInt("YesOrNoStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatusDictionaryDropDown");//是否有照片
  704. var isDream = pararms.getExtraInt("YesOrNoStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatus");//是否圆梦计划
  705. var planningGraduateDate = pararms.getExtraString("PlanningGraduateDropDown");
  706. var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
  707. var education = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  708. var reportStatusID = pararms.getExtraInt("ReportStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ReportStatusDictionaryDropDown");
  709. //WebClient conn = new WebClient();
  710. List<StudentsView> studentList = new List<StudentsView>();
  711. if (!string.IsNullOrEmpty(selectedIDs))
  712. {
  713. var selectedIDList = selectedIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  714. studentList = this.StudentfileServices.Value.GetStudentViewListByIDList(selectedIDList).ToList();
  715. }
  716. else
  717. {
  718. studentList = this.StudentfileServices.Value.GetStudentViewList(configuretView, campusID, collegeID, yearID, standardID,
  719. learningformID, classmajorID, generalPurposeID, inSchoolStatusID, isPhotos, isDream, planningGraduateDate, LearnSystem, education, reportStatusID,null).ToList();
  720. }
  721. var remoteFileList = studentList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x =>
  722. new EMIS.Utility.FileUploadHelper.RemoteFileInfo
  723. {
  724. FileName = x.LoginID + Path.GetExtension(x.PhotoUrl.Trim()),
  725. RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : Url.Content(x.PhotoUrl.Trim()))
  726. }).ToList();
  727. if (ExportPictureType == "IDNumberToPicture")
  728. {
  729. remoteFileList = studentList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x =>
  730. new EMIS.Utility.FileUploadHelper.RemoteFileInfo
  731. {
  732. FileName = x.IDNumber + Path.GetExtension(x.PhotoUrl.Trim()),
  733. RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : Url.Content(x.PhotoUrl.Trim()))
  734. }).ToList();
  735. }
  736. if (ExportPictureType == "ExamineeNumToPicture")
  737. {
  738. remoteFileList = studentList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x =>
  739. new EMIS.Utility.FileUploadHelper.RemoteFileInfo
  740. {
  741. FileName = x.ExamineeNum + Path.GetExtension(x.PhotoUrl.Trim()),
  742. RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : Url.Content(x.PhotoUrl.Trim()))
  743. }).ToList();
  744. }
  745. if (ExportPictureType == "LoginIDandUserNameToPicture")
  746. {
  747. remoteFileList = studentList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x =>
  748. new EMIS.Utility.FileUploadHelper.RemoteFileInfo
  749. {
  750. FileName = x.LoginID + x.UserName + Path.GetExtension(x.PhotoUrl.Trim()),
  751. RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : Url.Content(x.PhotoUrl.Trim()))
  752. }).ToList();
  753. }
  754. if (remoteFileList.Count > 0)
  755. {
  756. var zipFileStream = FileUploadHelper.DownLoadFiles(Guid.NewGuid().ToString(), "学生照片", remoteFileList);
  757. return File(zipFileStream, System.Net.Mime.MediaTypeNames.Application.Zip, "学生照片.zip");
  758. }
  759. else
  760. {
  761. return RedirectToAction("MsgShowAndOpen", "Common", new
  762. {
  763. WindowID = WindowStr,
  764. msg = "没有照片可导出!",
  765. });
  766. }
  767. }
  768. catch (Exception ex)
  769. {
  770. string mge = ex.Message;
  771. return base.Json("导出失败,原因:" + mge + "!");
  772. }
  773. }
  774. [HttpPost]
  775. public ActionResult PlanningGraduateList()
  776. {
  777. //Dictionary<int, DateTime?> PlanningGraduateList = StudentfileServices.Value.GetPlanningGraduateList();
  778. return Json(StudentfileServices.Value.GetPlanningGraduateList());
  779. }
  780. [HttpPost]
  781. public ActionResult GetDataRange()
  782. {
  783. return Json(StudentfileServices.Value.GetDataRange());
  784. }
  785. [HttpPost]
  786. public ActionResult StudentOnlyInSchool(QueryParamsModel pararms)
  787. {
  788. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  789. return base.Json(StudentfileServices.Value.GetStudentOnlyInSchool(configuretView, (int)pararms.page, (int)pararms.rows));
  790. }
  791. /// <summary>
  792. /// 列表查询
  793. /// </summary>
  794. /// <param name="pararms"></param>
  795. /// <param name="inSchoolStatus">在校状态</param>
  796. /// <returns></returns>
  797. [HttpPost]
  798. public ActionResult BatchSelectList(QueryParamsModel pararms)
  799. {
  800. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  801. //避开全选值
  802. var campusID = pararms.getExtraGuid("cbgCampus");
  803. var collegeID = pararms.getExtraGuid("cbgCollege");
  804. var education = pararms.getExtraInt("ddlEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlEducation");
  805. var yearID = pararms.getExtraInt("ddlYear") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlYear");
  806. var standardID = pararms.getExtraInt("cbgStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("cbgStandard");
  807. var learningformID = pararms.getExtraInt("ddlLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlLearningform");
  808. var classNum = pararms.getExtraInt("ddlClassNum") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlClassNum");
  809. var studentStatusID = pararms.getExtraInt("ddlStudentStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ddlStudentStatus");
  810. var isPhotos = pararms.getExtraInt("ddlHasPhoto") == DropdownList.SELECT_ALL ? null : (bool?)(pararms.getExtraInt("ddlHasPhoto") == (int)CF_YesOrNoStatus.Yes);//是否有照片
  811. var isOnlyGraduation = pararms.getExtraBool("chkOnlyGraduation");
  812. var isPreviousNotGraduated = pararms.getExtraBool("chkPreviousNotGraduated");
  813. return base.Json(StudentfileServices.Value.GetStudentUserViewList(configuretView, campusID, collegeID, education, yearID, standardID,
  814. learningformID, classNum, studentStatusID, isPhotos, isOnlyGraduation, isPreviousNotGraduated, (int)pararms.page, (int)pararms.rows));
  815. }
  816. /// <summary>
  817. /// 上报导出
  818. /// </summary>
  819. /// <param name="selectedIDs"></param>
  820. /// <returns></returns>
  821. public ActionResult InfoExport(string selectedIDs)
  822. {
  823. ViewBag.selectedID = selectedIDs;
  824. return View();
  825. }
  826. /// <summary>
  827. /// dbf
  828. /// </summary>
  829. /// <param name="pararms"></param>
  830. /// <param name="selectedIDs"></param>
  831. /// <param name="colnames"></param>
  832. /// <param name="showname"></param>
  833. /// <returns></returns>
  834. [HttpPost]
  835. public ActionResult DbfExport(QueryParamsModel pararms, string selectedIDs, string colnames, string showname)
  836. {
  837. NpoiExcelHelper neh = new NpoiExcelHelper();
  838. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  839. string WindowStr = Request.UrlReferrer.ToString();
  840. int IndexofID = WindowStr.LastIndexOf("=");
  841. WindowStr = WindowStr.Remove(0, IndexofID + 1);
  842. var campusID = pararms.getExtraGuid("CampusDropdown");
  843. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  844. var classmajorID = pararms.getExtraGuid("ClassmajorDropdown");
  845. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  846. var learningformID = pararms.getExtraInt("LearningformDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("LearningformDictionaryDropDown");
  847. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  848. var inSchoolStatusID = pararms.getExtraInt("InSchoolStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("InSchoolStatusDictionaryDropDown");
  849. var generalPurposeID = pararms.getExtraInt("GeneralPurposeDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("GeneralPurposeDictionaryDropDown");
  850. var isPhotos = pararms.getExtraInt("YesOrNoStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatusDictionaryDropDown");//是否有照片
  851. var isDream = pararms.getExtraInt("YesOrNoStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatus");//是否圆梦计划
  852. var planningGraduateDate = pararms.getExtraString("PlanningGraduateDropDown");
  853. var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
  854. var education = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  855. var reportStatusID = pararms.getExtraInt("ReportStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ReportStatusDictionaryDropDown");
  856. List<string> namelist = new List<string>();
  857. for (int i = 0; i < showname.Split(',').Length; i++)
  858. {
  859. string col = showname.Split(',')[i];
  860. if (!string.IsNullOrEmpty(col))
  861. {
  862. namelist.Add(col);
  863. }
  864. }
  865. List<string> idlist = new List<string>();
  866. for (int i = 0; i < colnames.Split(',').Length; i++)
  867. {
  868. string col = colnames.Split(',')[i];
  869. if (!string.IsNullOrEmpty(col))
  870. {
  871. idlist.Add(col);
  872. }
  873. }
  874. var dt = StudentfileServices.Value.GetStudentExportList(configuretView, campusID, collegeID, yearID, standardID,
  875. learningformID, classmajorID, generalPurposeID, inSchoolStatusID, isPhotos, isDream, planningGraduateDate, LearnSystem, education, reportStatusID)
  876. .Select(x => new
  877. {
  878. x.ExamineeNum,
  879. x.UserName,
  880. x.SexName,
  881. BirthDate = (x.BirthDate.HasValue ? x.BirthDate.Value.ToString("yyyyMMdd") : ""),
  882. x.IDNumber,
  883. x.SchoolCode,
  884. x.SchoolName,
  885. x.StandardCode,
  886. x.StandardName,//其他学校通用专业名称
  887. x.FacultymajorName,//(松山个性化)专业名称读取院系专业
  888. LearnSystem = (x.LearnSystem.HasValue ? (x.LearnSystem.Value % 1 == 0 ? x.LearnSystem.Value.ToString("0") : x.LearnSystem.Value.ToString("0.0")) : ""),
  889. x.LearningformName,
  890. x.EducationName,
  891. EntranceDate = (x.EntranceDate.HasValue ? x.EntranceDate.Value.ToString("yyyyMMdd") : ""),
  892. GraduateDate = (x.GraduateDate.HasValue ? x.GraduateDate.Value.ToString("yyyyMMdd") : ""),
  893. x.GraduationResultName,
  894. x.GraduateCardNo,
  895. x.HeadMasterName,
  896. Territorial = (x.Territorial.HasValue ? x.Territorial.ToString() : ""),
  897. x.LoginID,
  898. x.PoliticsName,
  899. x.NationName,
  900. x.CampusName,
  901. x.CollegeName,
  902. x.ClassMajorCode,
  903. x.ClassMajorName,
  904. PlanningGraduateDate = (x.PlanningGraduateDate.HasValue ? x.PlanningGraduateDate.Value.ToString("yyyyMMdd") : ""),
  905. x.Remarks
  906. }).ToTable(namelist);
  907. string[] liststring = idlist.ToArray();
  908. StudentfileServices.Value.WriteToDbf(dt, idlist);
  909. string filePath = Const.LOCAL_SETTING_UPLOAD_FILEPATH;
  910. string physicalPath = System.Web.HttpContext.Current.Server.MapPath(filePath);
  911. var filephysicalPath = (physicalPath.EndsWith("\\") ? physicalPath : physicalPath + "\\") + "StudentInfoExcel\\Info.dbf";
  912. return File(filephysicalPath, "application/x-dbf", "学生信息(上报导出)" + DateTime.Now.ToString("yyyyMMdd") + ".dbf");
  913. }
  914. /// <summary>
  915. /// Excel
  916. /// </summary>
  917. /// <param name="pararms"></param>
  918. /// <param name="selectedIDs"></param>
  919. /// <param name="colnames"></param>
  920. /// <param name="showname"></param>
  921. /// <returns></returns>
  922. [HttpPost]
  923. public ActionResult InfoExcel(QueryParamsModel pararms, string selectedIDs, string colnames, string showname)
  924. {
  925. NpoiExcelHelper neh = new NpoiExcelHelper();
  926. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  927. string WindowStr = Request.UrlReferrer.ToString();
  928. int IndexofID = WindowStr.LastIndexOf("=");
  929. WindowStr = WindowStr.Remove(0, IndexofID + 1);
  930. var campusID = pararms.getExtraGuid("CampusDropdown");
  931. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  932. var classmajorID = pararms.getExtraGuid("ClassmajorDropdown");
  933. var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown");
  934. var learningformID = pararms.getExtraInt("LearningformDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("LearningformDictionaryDropDown");
  935. var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown");
  936. var inSchoolStatusID = pararms.getExtraInt("InSchoolStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("InSchoolStatusDictionaryDropDown");
  937. var generalPurposeID = pararms.getExtraInt("GeneralPurposeDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("GeneralPurposeDictionaryDropDown");
  938. var isPhotos = pararms.getExtraInt("YesOrNoStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatusDictionaryDropDown");//是否有照片
  939. var isDream = pararms.getExtraInt("YesOrNoStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("YesOrNoStatus");//是否圆梦计划
  940. var planningGraduateDate = pararms.getExtraString("PlanningGraduateDropDown");
  941. var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
  942. var education = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  943. var reportStatusID = pararms.getExtraInt("ReportStatusDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ReportStatusDictionaryDropDown");
  944. List<string> namelist = new List<string>();
  945. for (int i = 0; i < showname.Split(',').Length; i++)
  946. {
  947. string col = showname.Split(',')[i];
  948. if (!string.IsNullOrEmpty(col))
  949. {
  950. namelist.Add(col);
  951. }
  952. }
  953. List<string> idlist = new List<string>();
  954. for (int i = 0; i < colnames.Split(',').Length; i++)
  955. {
  956. string col = colnames.Split(',')[i];
  957. if (!string.IsNullOrEmpty(col))
  958. {
  959. idlist.Add(col);
  960. }
  961. }
  962. var dt = StudentfileServices.Value.GetStudentExportList(configuretView, campusID, collegeID, yearID, standardID,
  963. learningformID, classmajorID, generalPurposeID, inSchoolStatusID, isPhotos, isDream, planningGraduateDate, LearnSystem, education, reportStatusID)
  964. .Select(x => new
  965. {
  966. x.ExamineeNum,
  967. x.UserName,
  968. x.SexName,
  969. BirthDate = (x.BirthDate.HasValue ? x.BirthDate.Value.ToString("yyyyMMdd") : ""),
  970. x.IDNumber,
  971. x.SchoolCode,
  972. x.SchoolName,
  973. x.StandardCode,
  974. x.StandardName,//其他学校通用专业名称
  975. x.FacultymajorName,//(松山个性化)专业名称读取院系专业
  976. LearnSystem = (x.LearnSystem.HasValue ? (x.LearnSystem.Value % 1 == 0 ? x.LearnSystem.Value.ToString("0") : x.LearnSystem.Value.ToString("0.0")) : ""),
  977. x.LearningformName,
  978. x.EducationName,
  979. EntranceDate = (x.EntranceDate.HasValue ? x.EntranceDate.Value.ToString("yyyyMMdd") : ""),
  980. GraduateDate = (x.GraduateDate.HasValue ? x.GraduateDate.Value.ToString("yyyyMMdd") : ""),
  981. x.GraduationResultName,
  982. x.GraduateCardNo,
  983. x.HeadMasterName,
  984. Territorial = (x.Territorial.HasValue ? x.Territorial.ToString() : ""),
  985. x.LoginID,
  986. x.PoliticsName,
  987. x.NationName,
  988. x.CampusName,
  989. x.CollegeName,
  990. x.ClassMajorCode,
  991. x.ClassMajorName,
  992. PlanningGraduateDate = (x.PlanningGraduateDate.HasValue ? x.PlanningGraduateDate.Value.ToString("yyyyMMdd") : ""),
  993. x.Remarks
  994. }).ToTable(namelist);
  995. string[] liststring = idlist.ToArray();
  996. neh.Export(dt, liststring, "学生信息(上报导出)" + DateTime.Now.ToString("yyyyMMdd"));
  997. return RedirectToAction("MsgShow", "Common", new
  998. {
  999. msg = "导出成功。",
  1000. url = Url.Content("~/Students/List").AddMenuParameter()
  1001. });
  1002. }
  1003. /// <summary>
  1004. /// Excel导出
  1005. /// </summary>
  1006. /// <returns></returns>
  1007. [HttpPost]
  1008. public ActionResult Excel()
  1009. {
  1010. NpoiExcelHelper neh = new NpoiExcelHelper();
  1011. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  1012. var UserIDs = Request.Form["UserIDs"];
  1013. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  1014. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  1015. var classmajorID = Request.Form["ClassmajorDropdown"].ParseStrTo<Guid>();
  1016. var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo<int>();
  1017. var learningformID = Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["LearningformDictionaryDropDown"].ParseStrTo<int>();
  1018. var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo<int>();
  1019. var inSchoolStatusID = Request.Form["InSchoolStatusDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["InSchoolStatusDictionaryDropDown"].ParseStrTo<int>();
  1020. var generalPurposeID = Request.Form["GeneralPurposeDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["GeneralPurposeDictionaryDropDown"].ParseStrTo<int>();
  1021. var isPhotos = Request.Form["YesOrNoStatusDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["YesOrNoStatusDictionaryDropDown"].ParseStrTo<int>();//是否有照片
  1022. var isDream = Request.Form["YesOrNoStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["YesOrNoStatus"].ParseStrTo<int>();//是否圆梦计划
  1023. var planningGraduateDate = Request.Form["PlanningGraduateDropDown"].ToString();
  1024. var LearnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  1025. var education = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  1026. var reportStatusID = Request.Form["ReportStatusDictionaryDropDown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["ReportStatusDictionaryDropDown"].ParseStrTo<int>();
  1027. List<Guid?> UserIDsIDList = new List<Guid?>();
  1028. if (UserIDs != "")
  1029. {
  1030. UserIDsIDList = UserIDs.SplitIDString();
  1031. }
  1032. else
  1033. {
  1034. UserIDsIDList = null;
  1035. }
  1036. var dt = StudentfileServices.Value.GetStudentViewList(configuretView, campusID, collegeID, yearID, standardID,
  1037. learningformID, classmajorID, generalPurposeID, inSchoolStatusID, isPhotos, isDream, planningGraduateDate,
  1038. LearnSystem, education, reportStatusID, UserIDsIDList)
  1039. .Select(x => new
  1040. {
  1041. x.ExamineeNum,
  1042. x.LoginID,
  1043. x.UserName,
  1044. x.SexName,
  1045. BirthDate = (x.BirthDate.HasValue ? x.BirthDate.Value.ToString("yyyyMMdd") : ""),
  1046. x.CertificatesTypeName,
  1047. x.IDNumber,
  1048. x.PoliticsName,
  1049. x.NationName,
  1050. x.StandardCode,
  1051. x.StandardName,
  1052. x.FacultymajorName,
  1053. x.CampusName,
  1054. x.CollegeName,
  1055. x.ClassMajorCode,
  1056. x.EducationName,
  1057. x.LearningformName,
  1058. LearnSystem = (x.LearnSystem.HasValue ? x.LearnSystem.Value.ToString("#.#") : ""),
  1059. EntranceDate = (x.EntranceDate.HasValue ? x.EntranceDate.Value.ToString("yyyyMMdd") : ""),
  1060. PlanningGraduateDate = (x.PlanningGraduateDate.HasValue ? x.PlanningGraduateDate.Value.ToString("yyyyMMdd") : ""),
  1061. x.CardNo,
  1062. x.InSchoolStatusName,
  1063. x.StudentStatusName,
  1064. x.ClassMajorName,
  1065. x.Dormitory,
  1066. x.GraduateCardNo,
  1067. x.StudentCardNo,
  1068. x.EntranceWayName,
  1069. x.SchoolTypeName,
  1070. x.CultureModelName,
  1071. x.ExamineeTypeName,
  1072. x.FeaturesName,
  1073. x.TerritorialName,
  1074. x.Area,
  1075. x.Place,
  1076. x.StudentTypeName,
  1077. PhotoUrlNO = x.LoginID,
  1078. x.Score,
  1079. x.HealthyName,
  1080. x.Email,
  1081. x.QQ,
  1082. x.Mobile,
  1083. x.Telephone,
  1084. x.ZipCode,
  1085. x.HomeAddress,
  1086. x.Recipient,
  1087. x.Placebirth,
  1088. x.UsedName,
  1089. x.Specialty,
  1090. x.Height,
  1091. x.Weight,
  1092. x.WorkUnit,
  1093. x.IsDreamProjectName,
  1094. x.Career,
  1095. x.Remarks
  1096. }).ToTable();
  1097. string[] liststring = {
  1098. "教育部考生号","学号","姓名","性别","出生日期","证件类型","证件号码","政治面貌","民族"
  1099. ,"专业代码","专业名称",RSL.Get("College")+"专业","分院(校)","系所函授站","班号","层次"
  1100. ,"学习形式","学制","入学日期","预计毕业日期","银行卡号","在校状态","学籍状态"
  1101. ,"班级名称","宿舍","毕结业证书编号","学籍卡编号","入学方式","办学类型","培养方式"
  1102. ,"考生类别","考生特征","生源所属地","来源地区","籍贯","学生类别","照片编号","高考总分"
  1103. ,"健康状态","电子邮箱","QQ","移动电话","固定电话","邮编","家庭地址","收件人","出生地","曾用名"
  1104. ,"特长","身高(CM)","体重(KG)","工作单位","是否圆梦计划","在校经历","备注"};
  1105. neh.Export(dt, liststring, "学生信息");
  1106. return RedirectToAction("MsgShow", "Common", new
  1107. {
  1108. msg = "导出成功。",
  1109. url = Url.Content("~/Students/List").AddMenuParameter()
  1110. });
  1111. }
  1112. [HttpPost]
  1113. public ActionResult StudentCardReport(List<Guid?> userIDList)
  1114. {
  1115. //ExcelForPDF.Worksheet
  1116. AsposeExcelHelper excel = new AsposeExcelHelper();
  1117. var pageList = new List<PageItem>();
  1118. var pictureItemList = new List<PictureItem>();
  1119. List<CellItem> cellItems = new List<CellItem>();
  1120. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  1121. StudentsView studentView = new StudentsView();
  1122. List<DifferentDynamicView> allDifferentDynamicViewList = DifferentDynamicServices.GetDifferentDynamicViewListNotDataRange(configuretView, null, null, null, null, null, null, null, null, null, null, null, 0, userIDList).ToList();
  1123. List<StudentEncourageView> allStudentEncourageViewList = StudentEncourageServices.GetStudentEncourageViewList(configuretView, null, null, null, null, null, null, null, null, null, null, null, null, null, userIDList).ToList();
  1124. foreach (var userID in userIDList)
  1125. {
  1126. studentView = StudentfileServices.Value.GetStudentfileView(userID);
  1127. CellItem celltiem = new CellItem();
  1128. celltiem.Col = 1;
  1129. celltiem.Row = 1;
  1130. celltiem.Value = studentView.Name;
  1131. cellItems.Add(celltiem);
  1132. CellItem celltiem1 = new CellItem();
  1133. celltiem1.Col = 3;
  1134. celltiem1.Row = 1;
  1135. celltiem1.Value = studentView.SexName;
  1136. cellItems.Add(celltiem1);
  1137. CellItem celltiem2 = new CellItem();
  1138. celltiem2.Col = 5;
  1139. celltiem2.Row = 1;
  1140. celltiem2.Value = studentView.BirthDate == null ? "" : studentView.BirthDate.Value.ToShortDateString();
  1141. cellItems.Add(celltiem2);
  1142. CellItem celltiem3 = new CellItem();
  1143. celltiem3.Col = 7;
  1144. celltiem3.Row = 1;
  1145. celltiem3.Value = studentView.IDNumber;
  1146. cellItems.Add(celltiem3);
  1147. CellItem celltiem4 = new CellItem();
  1148. celltiem4.Col = 10;
  1149. celltiem4.Row = 1;
  1150. celltiem4.Value = studentView.PoliticsName;
  1151. cellItems.Add(celltiem4);
  1152. CellItem celltiem5 = new CellItem();
  1153. celltiem5.Col = 1;
  1154. celltiem5.Row = 2;
  1155. celltiem5.Value = studentView.LoginID;
  1156. cellItems.Add(celltiem5);
  1157. CellItem celltiem6 = new CellItem();
  1158. celltiem6.Col = 4;
  1159. celltiem6.Row = 2;
  1160. celltiem6.Value = studentView.StandardName;
  1161. cellItems.Add(celltiem6);
  1162. CellItem celltiem7 = new CellItem();
  1163. celltiem7.Col = 7;
  1164. celltiem7.Row = 2;
  1165. celltiem7.Value = studentView.ClassMajorName;
  1166. cellItems.Add(celltiem7);
  1167. CellItem celltiem8 = new CellItem();
  1168. celltiem8.Col = 10;
  1169. celltiem8.Row = 2;
  1170. celltiem8.Value = studentView.NationName;
  1171. cellItems.Add(celltiem8);
  1172. CellItem celltiem9 = new CellItem();
  1173. celltiem9.Col = 1;
  1174. celltiem9.Row = 3;
  1175. celltiem9.Value = studentView.CollegeName;
  1176. cellItems.Add(celltiem9);
  1177. CellItem celltiem10 = new CellItem();
  1178. celltiem10.Col = 4;
  1179. celltiem10.Row = 3;
  1180. celltiem10.Value = studentView.Place;
  1181. cellItems.Add(celltiem10);
  1182. CellItem celltiem11 = new CellItem();
  1183. celltiem11.Col = 6;
  1184. celltiem11.Row = 3;
  1185. celltiem11.Value = studentView.LearningformName;
  1186. cellItems.Add(celltiem11);
  1187. CellItem celltiem12 = new CellItem();
  1188. celltiem12.Col = 8;
  1189. celltiem12.Row = 3;
  1190. celltiem12.Value = studentView.EducationName;
  1191. cellItems.Add(celltiem12);
  1192. CellItem celltiem13 = new CellItem();
  1193. celltiem13.Col = 10;
  1194. celltiem13.Row = 3;
  1195. celltiem13.Value = studentView.LearnSystem.ToString();
  1196. cellItems.Add(celltiem13);
  1197. CellItem celltiem14 = new CellItem();
  1198. celltiem14.Col = 1;
  1199. celltiem14.Row = 4;
  1200. celltiem14.Value = studentView.ExamineeNum.ToString();
  1201. cellItems.Add(celltiem14);
  1202. CellItem celltiem15 = new CellItem();
  1203. celltiem15.Col = 4;
  1204. celltiem15.Row = 4;
  1205. celltiem15.Value = studentView.EntranceDate == null ? "" : studentView.EntranceDate.Value.ToShortDateString();
  1206. cellItems.Add(celltiem15);
  1207. CellItem celltiem16 = new CellItem();
  1208. celltiem16.Col = 6;
  1209. celltiem16.Row = 4;
  1210. celltiem16.Value = studentView.GraduateDate == null ? "": studentView.GraduateDate.Value.ToShortDateString();
  1211. cellItems.Add(celltiem16);
  1212. CellItem celltiem17 = new CellItem();
  1213. celltiem17.Col = 8;
  1214. celltiem17.Row = 4;
  1215. celltiem17.Value = studentView.GraduateCardNo;
  1216. cellItems.Add(celltiem17);
  1217. CellItem celltiem18 = new CellItem();
  1218. celltiem18.Col = 10;
  1219. celltiem18.Row = 4;
  1220. celltiem18.Value = studentView.GraduationResultName;
  1221. cellItems.Add(celltiem18);
  1222. var DifferentDynamicViewList = allDifferentDynamicViewList.Where(x => x.UserID == userID).ToList();
  1223. string[][] diifferentDynamicvs1 = new string[][] { };
  1224. string[][] diifferentDynamicvs2 = new string[][] { };
  1225. string[][] diifferentDynamicvs3 = new string[][] { };
  1226. string[][] diifferentDynamicvs = DifferentDynamicViewList.Select((data, i) => new string[]
  1227. {
  1228. data.SchoolyearCode,
  1229. data.DifferentDynamicTypeName,
  1230. "",
  1231. "",
  1232. data.ReasonName,
  1233. data.StudentStatusName,
  1234. data.AfterClassmajorName,
  1235. "",
  1236. "",
  1237. data.AfterStudentStatusName,
  1238. data.EntityCreateTime == null ? "" : data.EntityCreateTime.Value.ToShortDateString()
  1239. }).ToArray();
  1240. if (diifferentDynamicvs.Length >= 3)
  1241. {
  1242. diifferentDynamicvs1 = new string[][] { diifferentDynamicvs[0] };
  1243. diifferentDynamicvs2 = new string[][] { diifferentDynamicvs[1] };
  1244. diifferentDynamicvs3 = new string[][] { diifferentDynamicvs[2] };
  1245. }
  1246. else if (diifferentDynamicvs.Length == 2)
  1247. {
  1248. diifferentDynamicvs1 = new string[][] { diifferentDynamicvs[0] };
  1249. diifferentDynamicvs2 = new string[][] { diifferentDynamicvs[1] };
  1250. }
  1251. else if (diifferentDynamicvs.Length == 1)
  1252. {
  1253. diifferentDynamicvs1 = new string[][] { diifferentDynamicvs[0] };
  1254. }
  1255. var StudentEncourageViewList = allStudentEncourageViewList.Where(x => x.UserID == userID).ToList();
  1256. string[][] studentEncouragevs1 = new string[][] { };
  1257. string[][] studentEncouragevs2 = new string[][] { };
  1258. string[][] studentEncouragevs3 = new string[][] { };
  1259. string[][] studentEncouragevs4 = new string[][] { };
  1260. string[][] studentEncouragevs5 = new string[][] { };
  1261. string[][] studentEncouragevs = StudentEncourageViewList.Select((data, i) => new string[]
  1262. {
  1263. data.SchoolyearCode,
  1264. data.EncourageName,
  1265. "",
  1266. "",
  1267. data.EncourageTypeName,
  1268. data.EncourageLevelName,
  1269. data.Unit,
  1270. "",
  1271. "",
  1272. data.Amount.ToString(),
  1273. data.EncourageDate == null ? "" : data.EncourageDate.Value.ToShortDateString()
  1274. }).ToArray();
  1275. if (studentEncouragevs.Length >= 5)
  1276. {
  1277. studentEncouragevs1 = new string[][] { studentEncouragevs[0] };
  1278. studentEncouragevs2 = new string[][] { studentEncouragevs[1] };
  1279. studentEncouragevs3 = new string[][] { studentEncouragevs[2] };
  1280. studentEncouragevs4 = new string[][] { studentEncouragevs[3] };
  1281. studentEncouragevs5 = new string[][] { studentEncouragevs[4] };
  1282. }
  1283. else if (studentEncouragevs.Length == 4)
  1284. {
  1285. studentEncouragevs1 = new string[][] { studentEncouragevs[0] };
  1286. studentEncouragevs2 = new string[][] { studentEncouragevs[1] };
  1287. studentEncouragevs3 = new string[][] { studentEncouragevs[2] };
  1288. studentEncouragevs4 = new string[][] { studentEncouragevs[3] };
  1289. }
  1290. else if (studentEncouragevs.Length == 3)
  1291. {
  1292. studentEncouragevs1 = new string[][] { studentEncouragevs[0] };
  1293. studentEncouragevs2 = new string[][] { studentEncouragevs[1] };
  1294. studentEncouragevs3 = new string[][] { studentEncouragevs[2] };
  1295. }
  1296. else if (studentEncouragevs.Length == 2)
  1297. {
  1298. studentEncouragevs1 = new string[][] { studentEncouragevs[0] };
  1299. studentEncouragevs2 = new string[][] { studentEncouragevs[1] };
  1300. }
  1301. else if (studentEncouragevs.Length == 1)
  1302. {
  1303. studentEncouragevs1 = new string[][] { studentEncouragevs[0] };
  1304. }
  1305. PictureItem picture = new PictureItem();
  1306. var urlstr = Server.MapPath(studentView.PhotoUrl);
  1307. try
  1308. {
  1309. Bitmap b = new Bitmap(urlstr);
  1310. Stream picstream = new MemoryStream();
  1311. b.Save(picstream, ImageFormat.Png);
  1312. picture.Picture = picstream;
  1313. picture.StartRow = 1;
  1314. picture.EndRow = 5;
  1315. picture.StartColumn = 11;
  1316. picture.EndColumn = 12;
  1317. pictureItemList.Add(picture);
  1318. }
  1319. catch {
  1320. }
  1321. pageList.Add(new PageItem
  1322. {
  1323. CellItemList = cellItems,
  1324. ListItemList = new List<ListItem>{
  1325. new ListItem { StartRow = 6, StartColumn = 1, EndColumn = 11, Values = diifferentDynamicvs1 },
  1326. new ListItem { StartRow = 7, StartColumn = 1, EndColumn = 11, Values = diifferentDynamicvs2 },
  1327. new ListItem { StartRow = 8, StartColumn = 1, EndColumn = 11, Values = diifferentDynamicvs3 },
  1328. new ListItem { StartRow = 10, StartColumn = 1, EndColumn = 11, Values = studentEncouragevs1 },
  1329. new ListItem { StartRow = 11, StartColumn = 1, EndColumn = 11, Values = studentEncouragevs2 },
  1330. new ListItem { StartRow = 12, StartColumn = 1, EndColumn = 11, Values = studentEncouragevs3 },
  1331. new ListItem { StartRow = 13, StartColumn = 1, EndColumn = 11, Values = studentEncouragevs4 },
  1332. new ListItem { StartRow = 14, StartColumn = 1, EndColumn = 11, Values = studentEncouragevs5 }
  1333. },
  1334. PictureItemList = pictureItemList
  1335. });
  1336. }
  1337. var newExcelName = Guid.NewGuid().ToString() + DateTime.Now.Ticks.ToString() + ".xlsx";
  1338. FileInfo file = new FileInfo(Server.MapPath("~/Content/TemplateFile" + Path.DirectorySeparatorChar + "studentCard.xlsx"));
  1339. file.CopyTo(Server.MapPath("~/Content/TemplateFile" + Path.DirectorySeparatorChar + newExcelName));
  1340. FileInfo newfile = new FileInfo(Server.MapPath("~/Content/TemplateFile" + Path.DirectorySeparatorChar + newExcelName));
  1341. var stream = new FileStream(Server.MapPath("~/Content/TemplateFile" + Path.DirectorySeparatorChar + newExcelName), FileMode.Open);
  1342. var excelNewStream = excel.ExportToTemplate(stream, pageList);
  1343. var fileName = ExcelToPDF.ExportToFile(excelNewStream, Const.LOCAL_SETTING_UPLOAD_FILEPATH);
  1344. var url = HttpContext.Request.Url.Scheme + "://" + HttpContext.Request.Url.Host + ":" + HttpContext.Request.Url.Port + Url.Content("~/").TrimEnd('/');
  1345. //var host = HttpContext.Request.Url;
  1346. var fileUrl = url + fileName.Substring(1, fileName.Length - 1);
  1347. stream.Close();
  1348. newfile.Delete();
  1349. return Json(new ReturnMessage()
  1350. {
  1351. IsSuccess = true,
  1352. Message = fileUrl,
  1353. });
  1354. //File(Server.MapPath(fileName), "application/x-pdf", "测试" + DateTime.Now.ToString("yyyyMMdd") + ".pdf");
  1355. }
  1356. }
  1357. }