StudentServices.cs 117 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Transactions;
  7. using Bowin.Common.Utility;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. using EMIS.ViewModel.CacheManage;
  11. using EMIS.ViewModel.StudentManage.StudentProfile;
  12. namespace EMIS.ExtensionLogic.ServiceLogic.StudentManage
  13. {
  14. public class StudentServices : EMIS.CommonLogic.StudentManage.StudentProfile.StudentServices
  15. {
  16. /// <summary>
  17. /// 编辑(新增、修改,业务主键:学号或考生号唯一)
  18. /// 注:学号总位数问题(广州美术)
  19. /// </summary>
  20. /// <param name="studentView"></param>
  21. /// <param name="photoUrl"></param>
  22. public override void StudentEdit(StudentView studentView, string photoUrl)
  23. {
  24. try
  25. {
  26. //查询相关Web.config配置
  27. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringMonth == null)
  28. {
  29. throw new Exception("预计毕业月(春季、上学期入学月)未配置,请检查。");
  30. }
  31. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringDay == null)
  32. {
  33. throw new Exception("预计毕业日(春季、上学期入学日)未配置,请检查。");
  34. }
  35. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnMonth == null)
  36. {
  37. throw new Exception("预计毕业月(秋季、下学期入学月)未配置,请检查。");
  38. }
  39. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnDay == null)
  40. {
  41. throw new Exception("预计毕业日(秋季、下学期入学日)未配置,请检查。");
  42. }
  43. if (EMIS.Utility.Const.LOCAL_SETTING_ENTRANCESEMESTERID == null)
  44. {
  45. throw new Exception("入学学期(春季、上学期、秋季、下学期)未配置,请检查。");
  46. }
  47. var studentNoTotal = EMIS.Utility.Const.LOCAL_SETTING_LOGINIDTOTAL;
  48. if (studentNoTotal == null)
  49. {
  50. throw new Exception("学号总位数未配置,请检查。");
  51. }
  52. if (!string.IsNullOrEmpty(studentView.StudentNo))
  53. {
  54. if (studentView.StudentNo.Trim().Length > Convert.ToInt32(studentNoTotal))
  55. {
  56. throw new Exception("输入的学号总位数有误,学号总位数应小于等于" + studentNoTotal + "位。");
  57. }
  58. }
  59. else
  60. {
  61. throw new Exception("学号不能为空,请输入学号。");
  62. }
  63. var userVerify = StudentDAL.Value.UserRepository.GetList(x => x.UserID != studentView.UserID && x.LoginID == studentView.StudentNo.Trim()).SingleOrDefault();
  64. if (userVerify == null)
  65. {
  66. var newStudentVerify = StudentDAL.Value.NewStudentRepository.GetList(x => x.AssignStatus == (int)CF_AssignStatus.Assigned
  67. && x.ExamineeNum != studentView.ExamineeNum && x.StudentNo == studentView.StudentNo.Trim()).SingleOrDefault();
  68. if (newStudentVerify != null)
  69. {
  70. throw new Exception("录取名单中已存在相同的学号(学号重复),请核查。");
  71. }
  72. if (!string.IsNullOrEmpty(studentView.ExamineeNum))
  73. {
  74. var examineeNumVerify = StudentDAL.Value.RecruitstudentsRepository.GetList(x => x.UserID != studentView.UserID
  75. && x.ExamineeNum == studentView.ExamineeNum.Trim()).SingleOrDefault();
  76. if (examineeNumVerify != null)
  77. {
  78. throw new Exception("已存在相同的考生号(考生号重复),请核查。");
  79. }
  80. }
  81. if (!string.IsNullOrEmpty(studentView.StudentCardNo))
  82. {
  83. var studentCardNoVerify = StudentDAL.Value.StudentRepository.GetList(x => x.UserID != studentView.UserID
  84. && x.StudentCardNo == studentView.StudentCardNo.Trim()).SingleOrDefault();
  85. if (studentCardNoVerify != null)
  86. {
  87. throw new Exception("已存在相同的学籍卡编号(学籍卡编号重复),请核查。");
  88. }
  89. }
  90. if (!string.IsNullOrEmpty(studentView.GraduateCardNo))
  91. {
  92. var graduateCardNoVerify = StudentDAL.Value.StudentRepository.GetList(x => x.UserID != studentView.UserID
  93. && x.GraduateCardNo == studentView.GraduateCardNo.Trim()).SingleOrDefault();
  94. if (graduateCardNoVerify != null)
  95. {
  96. throw new Exception("已存在相同的毕结业证书编号(毕结业证书编号重复),请核查。");
  97. }
  98. }
  99. if (!string.IsNullOrEmpty(studentView.ReplaceGraduateNo))
  100. {
  101. var replaceGraduateNoVerify = StudentDAL.Value.StudentRepository.GetList(x => x.UserID != studentView.UserID
  102. && x.ReplaceGraduateNo == studentView.ReplaceGraduateNo.Trim()).SingleOrDefault();
  103. if (replaceGraduateNoVerify != null)
  104. {
  105. throw new Exception("已存在相同的补证编号(补证编号重复),请核查。");
  106. }
  107. }
  108. var passwordParameter = StudentDAL.Value.ParameterRepository.GetSingle(x => x.ParameterTypeID == (int)ViewModel.CF_ParameterType.StudentInitPassword);
  109. var roleList = StudentDAL.Value.RoleRepository.GetList(x => x.TypeID == (int)SYS_RoleType.Student, (x => x.CF_StudentRole)).ToList();
  110. List<Sys_User> newUserInList = new List<Sys_User>();
  111. List<Sys_User> newUserUpList = new List<Sys_User>();
  112. List<CF_Student> newStudentInList = new List<CF_Student>();
  113. List<CF_Student> newStudentUpList = new List<CF_Student>();
  114. List<CF_StudentProfile> newStudentProfileInList = new List<CF_StudentProfile>();
  115. List<CF_StudentProfile> newStudentProfileUpList = new List<CF_StudentProfile>();
  116. List<CF_StudentContact> newStudentContactInList = new List<CF_StudentContact>();
  117. List<CF_StudentContact> newStudentContactUpList = new List<CF_StudentContact>();
  118. List<CF_StudentAccount> newStudentAccountInList = new List<CF_StudentAccount>();
  119. List<CF_StudentAccount> newStudentAccountUpList = new List<CF_StudentAccount>();
  120. List<CF_Recruitstudents> newRecruitstudentsInList = new List<CF_Recruitstudents>();
  121. List<CF_Recruitstudents> newRecruitstudentsUpList = new List<CF_Recruitstudents>();
  122. if (studentView.UserID != Guid.Empty)
  123. {
  124. //修改
  125. var student = StudentDAL.Value.StudentRepository.GetList(x => x.UserID == studentView.UserID,
  126. (x => x.CF_StudentProfile), (x => x.CF_StudentContact), (x => x.CF_StudentAccount),
  127. (x => x.CF_Recruitstudents), (x => x.Sys_User)).SingleOrDefault();
  128. if (student == null)
  129. {
  130. throw new Exception("数据有误,请核查。");
  131. }
  132. else
  133. {
  134. student.Sys_User.LoginID = studentView.StudentNo.Trim();
  135. student.Sys_User.Name = studentView.Name.Trim();
  136. this.SetModifyStatus(student.Sys_User);
  137. newUserUpList.Add(student.Sys_User);
  138. student.ClassmajorID = studentView.ClassmajorID;
  139. student.SexID = studentView.SexID;
  140. student.BirthDate = studentView.BirthDate;
  141. student.NationID = studentView.NationID;
  142. student.PoliticsID = studentView.PoliticsID;
  143. student.CertificatesType = studentView.CertificatesType;
  144. student.IDNumber = studentView.IDNumber;
  145. student.StudentType = studentView.StudentType;
  146. student.Sys_User.Sys_Role = new HashSet<Sys_Role>();
  147. roleList = roleList.Where(x => x.CF_StudentRole.StudentType == studentView.StudentType).ToList();
  148. if (roleList != null && roleList.Count > 0)
  149. {
  150. roleList.ForEach(x => student.Sys_User.Sys_Role.Add(x));
  151. }
  152. else
  153. {
  154. //对应角色为空时,默认为不分配用户角色
  155. }
  156. student.InSchoolStatusID = studentView.InSchoolStatusID;
  157. student.StudentStatus = studentView.StudentStatus;
  158. student.StudentCardNo = studentView.StudentCardNo;
  159. if (!string.IsNullOrEmpty(photoUrl))
  160. {
  161. student.PhotoUrl = photoUrl;
  162. }
  163. if (studentView.PlanningGraduateDate.HasValue)
  164. {
  165. student.PlanningGraduateDate = studentView.PlanningGraduateDate;
  166. }
  167. if (studentView.GraduateDate.HasValue)
  168. {
  169. student.GraduateDate = studentView.GraduateDate;
  170. }
  171. student.GraduateCardNo = studentView.GraduateCardNo;
  172. student.ReplaceGraduateNo = studentView.ReplaceGraduateNo;
  173. student.DegreeStatus = studentView.DegreeStatus;
  174. //if (!string.IsNullOrEmpty(studentView.GraduationPictureUrl))
  175. //{
  176. // student.GraduationPictureUrl = studentView.GraduationPictureUrl;
  177. //}
  178. student.Career = studentView.Career;
  179. //student.IsPhotoComparison = studentView.IsPhotoComparison;
  180. //student.IsProofread = studentView.IsProofread;
  181. student.Remark = studentView.Remark;
  182. this.SetModifyStatus(student);
  183. newStudentUpList.Add(student);
  184. if (student.CF_StudentProfile == null)
  185. {
  186. var studentProfile = new CF_StudentProfile();
  187. studentProfile.UserID = student.UserID;
  188. studentProfile.UsedName = studentView.UsedName;
  189. studentProfile.LiteracyLevelID = studentView.LiteracyLevelID;
  190. studentProfile.CultureModelID = studentView.CultureModelID;
  191. studentProfile.IsDreamProject = studentView.IsDreamProject;
  192. studentProfile.Country = studentView.Country;
  193. studentProfile.Place = studentView.Place;
  194. studentProfile.BornPlace = studentView.BornPlace;
  195. studentProfile.HealthStateID = studentView.HealthStateID;
  196. studentProfile.BloodGroup = studentView.BloodGroup;
  197. studentProfile.Specialty = studentView.Specialty;
  198. studentProfile.Height = studentView.Height;
  199. studentProfile.Weight = studentView.Weight;
  200. studentProfile.DirectorName = studentView.DirectorName;
  201. this.SetNewStatus(studentProfile);
  202. newStudentProfileInList.Add(studentProfile);
  203. }
  204. else
  205. {
  206. student.CF_StudentProfile.UsedName = studentView.UsedName;
  207. student.CF_StudentProfile.LiteracyLevelID = studentView.LiteracyLevelID;
  208. student.CF_StudentProfile.CultureModelID = studentView.CultureModelID;
  209. student.CF_StudentProfile.IsDreamProject = studentView.IsDreamProject;
  210. student.CF_StudentProfile.Country = studentView.Country;
  211. student.CF_StudentProfile.Place = studentView.Place;
  212. student.CF_StudentProfile.BornPlace = studentView.BornPlace;
  213. student.CF_StudentProfile.HealthStateID = studentView.HealthStateID;
  214. student.CF_StudentProfile.BloodGroup = studentView.BloodGroup;
  215. student.CF_StudentProfile.Specialty = studentView.Specialty;
  216. student.CF_StudentProfile.Height = studentView.Height;
  217. student.CF_StudentProfile.Weight = studentView.Weight;
  218. student.CF_StudentProfile.DirectorName = studentView.DirectorName;
  219. this.SetModifyStatus(student.CF_StudentProfile);
  220. newStudentProfileUpList.Add(student.CF_StudentProfile);
  221. }
  222. if (student.CF_StudentContact == null)
  223. {
  224. var studentContact = new CF_StudentContact();
  225. studentContact.UserID = student.UserID;
  226. studentContact.Email = studentView.Email;
  227. studentContact.Telephone = studentView.Email;
  228. studentContact.Mobile = studentView.Email;
  229. studentContact.ZIPCode = studentView.ZIPCode;
  230. studentContact.WeChatNum = studentView.WeChatNum;
  231. studentContact.QQ = studentView.QQ;
  232. studentContact.HomeAddress = studentView.HomeAddress;
  233. studentContact.WorkUnit = studentView.WorkUnit;
  234. studentContact.Address = studentView.Address;
  235. studentContact.Recipient = studentView.Recipient;
  236. studentContact.Dormitory = studentView.Dormitory;
  237. this.SetNewStatus(studentContact);
  238. newStudentContactInList.Add(studentContact);
  239. }
  240. else
  241. {
  242. student.CF_StudentContact.Email = studentView.Email;
  243. student.CF_StudentContact.Telephone = studentView.Telephone;
  244. student.CF_StudentContact.Mobile = studentView.Mobile;
  245. student.CF_StudentContact.ZIPCode = studentView.ZIPCode;
  246. student.CF_StudentContact.WeChatNum = studentView.WeChatNum;
  247. student.CF_StudentContact.QQ = studentView.QQ;
  248. student.CF_StudentContact.HomeAddress = studentView.HomeAddress;
  249. student.CF_StudentContact.WorkUnit = studentView.WorkUnit;
  250. student.CF_StudentContact.Address = studentView.Address;
  251. student.CF_StudentContact.Recipient = studentView.Recipient;
  252. student.CF_StudentContact.Dormitory = studentView.Dormitory;
  253. this.SetModifyStatus(student.CF_StudentContact);
  254. newStudentContactUpList.Add(student.CF_StudentContact);
  255. }
  256. if (student.CF_StudentAccount == null)
  257. {
  258. var studentAccount = new CF_StudentAccount();
  259. studentAccount.UserID = student.UserID;
  260. studentAccount.BankName = studentView.BankName;
  261. studentAccount.CardNo = studentView.CardNo;
  262. this.SetNewStatus(studentAccount);
  263. newStudentAccountInList.Add(studentAccount);
  264. }
  265. else
  266. {
  267. student.CF_StudentAccount.BankName = studentView.BankName;
  268. student.CF_StudentAccount.CardNo = studentView.CardNo;
  269. this.SetModifyStatus(student.CF_StudentAccount);
  270. newStudentAccountUpList.Add(student.CF_StudentAccount);
  271. }
  272. if (student.CF_Recruitstudents == null)
  273. {
  274. var recruitstudents = new CF_Recruitstudents();
  275. recruitstudents.UserID = student.UserID;
  276. recruitstudents.ExamineeNum = studentView.ExamineeNum;
  277. recruitstudents.AdmissionTicketNo = studentView.AdmissionTicketNo;
  278. recruitstudents.ExamineeType = studentView.ExamineeType;
  279. recruitstudents.EnteringSchoolYearID = studentView.StartSchoolyearID;
  280. recruitstudents.EntranceDate = studentView.EntranceDate;
  281. recruitstudents.Score = studentView.Score;
  282. recruitstudents.EntranceWayID = studentView.EntranceWayID;
  283. recruitstudents.FeaturesID = studentView.FeaturesID;
  284. recruitstudents.TerritorialID = studentView.TerritorialID;
  285. recruitstudents.Area = studentView.Area;
  286. //if (!string.IsNullOrEmpty(studentView.RecruitPictureUrl))
  287. //{
  288. // recruitstudents.RecruitPictureUrl = studentView.RecruitPictureUrl;
  289. //}
  290. this.SetNewStatus(recruitstudents);
  291. newRecruitstudentsInList.Add(recruitstudents);
  292. }
  293. else
  294. {
  295. student.CF_Recruitstudents.ExamineeNum = studentView.ExamineeNum;
  296. student.CF_Recruitstudents.AdmissionTicketNo = studentView.AdmissionTicketNo;
  297. student.CF_Recruitstudents.ExamineeType = studentView.ExamineeType;
  298. student.CF_Recruitstudents.EnteringSchoolYearID = studentView.StartSchoolyearID;
  299. student.CF_Recruitstudents.EntranceDate = studentView.EntranceDate;
  300. student.CF_Recruitstudents.Score = studentView.Score;
  301. student.CF_Recruitstudents.EntranceWayID = studentView.EntranceWayID;
  302. student.CF_Recruitstudents.FeaturesID = studentView.FeaturesID;
  303. student.CF_Recruitstudents.TerritorialID = studentView.TerritorialID;
  304. student.CF_Recruitstudents.Area = studentView.Area;
  305. //if (!string.IsNullOrEmpty(studentView.RecruitPictureUrl))
  306. //{
  307. // student.CF_Recruitstudents.RecruitPictureUrl = studentView.RecruitPictureUrl;
  308. //}
  309. this.SetModifyStatus(student.CF_Recruitstudents);
  310. newRecruitstudentsUpList.Add(student.CF_Recruitstudents);
  311. }
  312. }
  313. }
  314. else
  315. {
  316. //新增
  317. var newUser = new Sys_User();
  318. newUser.UserID = Guid.NewGuid();
  319. newUser.LoginID = studentView.StudentNo.Trim();
  320. newUser.Name = studentView.Name.Trim();
  321. if (passwordParameter == null)
  322. {
  323. newUser.Password = ("A" + studentView.StudentNo.Trim()).MD5();
  324. }
  325. else
  326. {
  327. if (passwordParameter.Value != null)
  328. {
  329. newUser.Password = passwordParameter.Value;
  330. }
  331. else
  332. {
  333. newUser.Password = ("A" + studentView.StudentNo.Trim()).MD5();
  334. }
  335. }
  336. this.SetNewStatus(newUser, (int)SYS_STATUS.USABLE);
  337. newUserInList.Add(newUser);
  338. newUser.Sys_Role = new HashSet<Sys_Role>();
  339. roleList = roleList.Where(x => x.CF_StudentRole.StudentType == studentView.StudentType).ToList();
  340. if (roleList != null && roleList.Count > 0)
  341. {
  342. roleList.ForEach(x => newUser.Sys_Role.Add(x));
  343. }
  344. else
  345. {
  346. //对应角色为空时,默认为不分配用户角色
  347. }
  348. var newStudent = new CF_Student();
  349. newStudent.UserID = newUser.UserID;
  350. newStudent.ClassmajorID = studentView.ClassmajorID;
  351. newStudent.SexID = studentView.SexID;
  352. newStudent.BirthDate = studentView.BirthDate;
  353. newStudent.NationID = studentView.NationID;
  354. newStudent.PoliticsID = studentView.PoliticsID;
  355. newStudent.CertificatesType = studentView.CertificatesType;
  356. newStudent.IDNumber = studentView.IDNumber;
  357. newStudent.StudentType = studentView.StudentType;
  358. newStudent.InSchoolStatusID = studentView.InSchoolStatusID;
  359. newStudent.StudentStatus = studentView.StudentStatus;
  360. newStudent.StudentCardNo = studentView.StudentCardNo;
  361. if (!string.IsNullOrEmpty(photoUrl))
  362. {
  363. newStudent.PhotoUrl = photoUrl;
  364. }
  365. newStudent.PlanningGraduateDate = this.GetClassmajorPlanningGraduateDate(studentView.ClassmajorID);
  366. newStudent.GraduateDate = this.GetClassmajorGraduateDate(studentView.ClassmajorID);
  367. newStudent.GraduateCardNo = studentView.GraduateCardNo;
  368. newStudent.ReplaceGraduateNo = studentView.ReplaceGraduateNo;
  369. newStudent.DegreeStatus = studentView.DegreeStatus;
  370. //if (!string.IsNullOrEmpty(studentView.GraduationPictureUrl))
  371. //{
  372. // newStudent.GraduationPictureUrl = studentView.GraduationPictureUrl;
  373. //}
  374. newStudent.Career = studentView.Career;
  375. //newStudent.IsPhotoComparison = studentView.IsPhotoComparison;
  376. //newStudent.IsProofread = studentView.IsProofread;
  377. newStudent.Remark = studentView.Remark;
  378. this.SetNewStatus(newStudent);
  379. newStudentInList.Add(newStudent);
  380. var newStudentProfile = new CF_StudentProfile();
  381. newStudentProfile.UserID = newStudent.UserID;
  382. newStudentProfile.UsedName = studentView.UsedName;
  383. newStudentProfile.LiteracyLevelID = studentView.LiteracyLevelID;
  384. newStudentProfile.CultureModelID = studentView.CultureModelID;
  385. newStudentProfile.IsDreamProject = studentView.IsDreamProject;
  386. newStudentProfile.Country = studentView.Country;
  387. newStudentProfile.Place = studentView.Place;
  388. newStudentProfile.BornPlace = studentView.BornPlace;
  389. newStudentProfile.HealthStateID = studentView.HealthStateID;
  390. newStudentProfile.BloodGroup = studentView.BloodGroup;
  391. newStudentProfile.Specialty = studentView.Specialty;
  392. newStudentProfile.Height = studentView.Height;
  393. newStudentProfile.Weight = studentView.Weight;
  394. newStudentProfile.DirectorName = studentView.DirectorName;
  395. this.SetNewStatus(newStudentProfile);
  396. newStudentProfileInList.Add(newStudentProfile);
  397. var newStudentContact = new CF_StudentContact();
  398. newStudentContact.UserID = newStudent.UserID;
  399. newStudentContact.Email = studentView.Email;
  400. newStudentContact.Telephone = studentView.Telephone;
  401. newStudentContact.Mobile = studentView.Mobile;
  402. newStudentContact.ZIPCode = studentView.ZIPCode;
  403. newStudentContact.WeChatNum = studentView.WeChatNum;
  404. newStudentContact.QQ = studentView.QQ;
  405. newStudentContact.HomeAddress = studentView.HomeAddress;
  406. newStudentContact.WorkUnit = studentView.WorkUnit;
  407. newStudentContact.Address = studentView.Address;
  408. newStudentContact.Recipient = studentView.Recipient;
  409. newStudentContact.Dormitory = studentView.Dormitory;
  410. this.SetNewStatus(newStudentContact);
  411. newStudentContactInList.Add(newStudentContact);
  412. var newStudentAccount = new CF_StudentAccount();
  413. newStudentAccount.UserID = newStudent.UserID;
  414. newStudentAccount.CardNo = studentView.CardNo;
  415. newStudentAccount.BankName = studentView.BankName;
  416. this.SetNewStatus(newStudentAccount);
  417. newStudentAccountInList.Add(newStudentAccount);
  418. var newRecruitstudents = new CF_Recruitstudents();
  419. newRecruitstudents.UserID = newStudent.UserID;
  420. newRecruitstudents.ExamineeNum = studentView.ExamineeNum;
  421. newRecruitstudents.AdmissionTicketNo = studentView.AdmissionTicketNo;
  422. newRecruitstudents.ExamineeType = studentView.ExamineeType;
  423. newRecruitstudents.EnteringSchoolYearID = studentView.StartSchoolyearID;
  424. newRecruitstudents.EntranceDate = studentView.EntranceDate;
  425. newRecruitstudents.Score = studentView.Score;
  426. newRecruitstudents.EntranceWayID = studentView.EntranceWayID;
  427. newRecruitstudents.FeaturesID = studentView.FeaturesID;
  428. newRecruitstudents.TerritorialID = studentView.TerritorialID;
  429. newRecruitstudents.Area = studentView.Area;
  430. //if (!string.IsNullOrEmpty(studentView.RecruitPictureUrl))
  431. //{
  432. // newRecruitstudents.RecruitPictureUrl = studentView.RecruitPictureUrl;
  433. //}
  434. this.SetNewStatus(newRecruitstudents);
  435. newRecruitstudentsInList.Add(newRecruitstudents);
  436. }
  437. using (TransactionScope ts = new TransactionScope())
  438. {
  439. UnitOfWork.BulkInsert<Sys_User>(newUserInList);
  440. UnitOfWork.BulkInsert(newUserInList, (x => x.Sys_Role));
  441. UnitOfWork.BulkInsert<CF_Student>(newStudentInList);
  442. UnitOfWork.BulkInsert<CF_StudentProfile>(newStudentProfileInList);
  443. UnitOfWork.BulkInsert<CF_StudentContact>(newStudentContactInList);
  444. UnitOfWork.BulkInsert<CF_StudentAccount>(newStudentAccountInList);
  445. UnitOfWork.BulkInsert<CF_Recruitstudents>(newRecruitstudentsInList);
  446. if (newUserUpList != null && newUserUpList.Count() > 0)
  447. {
  448. UnitOfWork.BatchUpdate(newUserUpList);
  449. UnitOfWork.Delete(newUserUpList, (x => x.Sys_Role));
  450. UnitOfWork.BulkInsert(newUserUpList, (x => x.Sys_Role));
  451. }
  452. if (newStudentUpList != null && newStudentUpList.Count() > 0)
  453. {
  454. UnitOfWork.BatchUpdate(newStudentUpList);
  455. }
  456. if (newStudentProfileUpList != null && newStudentProfileUpList.Count() > 0)
  457. {
  458. UnitOfWork.BatchUpdate(newStudentProfileUpList);
  459. }
  460. if (newStudentContactUpList != null && newStudentContactUpList.Count() > 0)
  461. {
  462. UnitOfWork.BatchUpdate(newStudentContactUpList);
  463. }
  464. if (newStudentAccountUpList != null && newStudentAccountUpList.Count() > 0)
  465. {
  466. UnitOfWork.BatchUpdate(newStudentAccountUpList);
  467. }
  468. if (newRecruitstudentsUpList != null && newRecruitstudentsUpList.Count() > 0)
  469. {
  470. UnitOfWork.BatchUpdate(newRecruitstudentsUpList);
  471. }
  472. ts.Complete();
  473. }
  474. }
  475. else
  476. {
  477. var studentVerify = StudentDAL.Value.StudentRepository.GetList(x => x.UserID != studentView.UserID,
  478. (x => x.Sys_User)).Where(x => x.Sys_User.LoginID == studentView.StudentNo.Trim()).SingleOrDefault();
  479. if (studentVerify != null)
  480. {
  481. throw new Exception("已存在相同的学号(学号重复),请核查。");
  482. }
  483. else
  484. {
  485. var staffVerify = StudentDAL.Value.StaffRepository.GetList(x => x.UserID != studentView.UserID,
  486. (x => x.Sys_User)).Where(x => x.Sys_User.LoginID == studentView.StudentNo.Trim()).SingleOrDefault();
  487. if (staffVerify != null)
  488. {
  489. throw new Exception("教师信息中已存在相同的用户(用户名重复),请核查。");
  490. }
  491. else
  492. {
  493. throw new Exception("用户信息中已存在相同的用户(用户名重复),请核查。");
  494. }
  495. }
  496. }
  497. }
  498. catch (Exception ex)
  499. {
  500. throw new Exception(ex.Message);
  501. }
  502. }
  503. /// <summary>
  504. /// 学生信息Excel导入
  505. /// 注:学号总位数问题(广州美术)
  506. /// </summary>
  507. /// <param name="cellheader"></param>
  508. /// <param name="inCount"></param>
  509. /// <param name="upCount"></param>
  510. /// <param name="errdataList"></param>
  511. /// <param name="errCount"></param>
  512. /// <param name="sourcePhysicalPath"></param>
  513. public override void StudentImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount, out List<StudentView> errdataList, out int? errCount, string sourcePhysicalPath)
  514. {
  515. try
  516. {
  517. //查询相关Web.config配置
  518. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringMonth == null)
  519. {
  520. throw new Exception("预计毕业月(春季、上学期入学月)未配置,请检查。");
  521. }
  522. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringDay == null)
  523. {
  524. throw new Exception("预计毕业日(春季、上学期入学日)未配置,请检查。");
  525. }
  526. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnMonth == null)
  527. {
  528. throw new Exception("预计毕业月(秋季、下学期入学月)未配置,请检查。");
  529. }
  530. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnDay == null)
  531. {
  532. throw new Exception("预计毕业日(秋季、下学期入学日)未配置,请检查。");
  533. }
  534. if (EMIS.Utility.Const.LOCAL_SETTING_ENTRANCESEMESTERID == null)
  535. {
  536. throw new Exception("入学学期(春季、上学期、秋季、下学期)未配置,请检查。");
  537. }
  538. var studentNoTotal = EMIS.Utility.Const.LOCAL_SETTING_LOGINIDTOTAL;
  539. if (studentNoTotal == null)
  540. {
  541. throw new Exception("学号总位数未配置,请检查。");
  542. }
  543. StringBuilder errorMsg = new StringBuilder(); // 错误信息
  544. List<StudentView> errList = new List<StudentView>();
  545. // 1.1解析文件,存放到一个List集合里
  546. cellheader.Remove("ErrorMessage");//移除“未导入原因”列(ErrorMessage)
  547. List<StudentView> enlist = NpoiExcelHelper.ExcelToEntityList<StudentView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
  548. cellheader.Add("ErrorMessage", "未导入原因");
  549. //对List集合进行有效性校验
  550. if (enlist.Count() <= 0)
  551. {
  552. throw new Exception("Excel文件数据为空,请检查。");
  553. }
  554. Regex reg = null; //正则表达式
  555. DateTime result; //用于返回判断日期字段格式
  556. inCount = 0; //导入个数
  557. upCount = 0; //更新个数
  558. errCount = 0; //失败个数
  559. string errorMsgStr = ""; //错误信息
  560. List<Sys_User> newUserInList = new List<Sys_User>();
  561. List<Sys_User> newUserUpList = new List<Sys_User>();
  562. List<CF_Student> newStudentInList = new List<CF_Student>();
  563. List<CF_Student> newStudentUpList = new List<CF_Student>();
  564. List<CF_StudentProfile> newStudentProfileInList = new List<CF_StudentProfile>();
  565. List<CF_StudentProfile> newStudentProfileUpList = new List<CF_StudentProfile>();
  566. List<CF_StudentContact> newStudentContactInList = new List<CF_StudentContact>();
  567. List<CF_StudentContact> newStudentContactUpList = new List<CF_StudentContact>();
  568. List<CF_StudentAccount> newStudentAccountInList = new List<CF_StudentAccount>();
  569. List<CF_StudentAccount> newStudentAccountUpList = new List<CF_StudentAccount>();
  570. List<CF_Recruitstudents> newRecruitstudentsInList = new List<CF_Recruitstudents>();
  571. List<CF_Recruitstudents> newRecruitstudentsUpList = new List<CF_Recruitstudents>();
  572. var passwordParameter = StudentDAL.Value.ParameterRepository.GetSingle(x => x.ParameterTypeID == (int)ViewModel.CF_ParameterType.StudentInitPassword);
  573. var roleList = StudentDAL.Value.RoleRepository.GetList(x => x.TypeID == (int)SYS_RoleType.Student, (x => x.CF_StudentRole)).ToList();
  574. //将循环中相关数据库查询统一查询出来进行匹配(尽量避免在循环中进行数据库查询)
  575. //性别
  576. var sexList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Sex).ToList();
  577. //民族
  578. var nationList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Nation).ToList();
  579. //政治面貌
  580. var politicsList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Politics).ToList();
  581. //学生类别
  582. var studentTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_STUDENTTYPE).ToList();
  583. //证件类型
  584. var certificatesTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CertificatesType).ToList();
  585. //在校状态
  586. var inschoolStatusList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_InschoolStatus).ToList();
  587. //学籍状态
  588. var studentStatusList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_StudentStatus).ToList();
  589. //文化程度
  590. var literacyLevelList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_LiteracyLevel).ToList();
  591. //培养方式
  592. var cultureModelList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CULTUREMODEL).ToList();
  593. //考生类别
  594. var examineeTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_EXAMINEETYPE).ToList();
  595. //入学方式
  596. var entranceWayList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_EntranceWay).ToList();
  597. //考生特征
  598. var featuresList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Features).ToList();
  599. //生源所属地
  600. var territorialList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Province).ToList();
  601. //健康状况
  602. var healthStateList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_HealthState).ToList();
  603. //血型
  604. var bloodGroupList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_BLOODGROUP).ToList();
  605. //是否
  606. var generalPurposeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_GeneralPurpose).ToList();
  607. //有无
  608. var generalExistList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_GeneralExist).ToList();
  609. //班级编号
  610. var classmajorNoList = enlist.Where(x => !string.IsNullOrEmpty(x.ClassmajorNo)).Select(x => x.ClassmajorNo.Trim()).ToList();
  611. //对比后的newClassmajorList
  612. var newClassmajorList = StudentDAL.Value.ClassmajorRepository.GetList(x => classmajorNoList.Contains(x.No)).ToList();
  613. //学籍卡编号
  614. var studentCardNoList = enlist.Where(x => !string.IsNullOrEmpty(x.StudentCardNo)).Select(x => x.StudentCardNo.Trim()).ToList();
  615. //对比后的newStudentCardNoList
  616. var newStudentCardNoList = StudentDAL.Value.StudentRepository.GetList(x => studentCardNoList.Contains(x.StudentCardNo)).ToList();
  617. //毕结业证书编号
  618. var graduateCardNoList = enlist.Where(x => !string.IsNullOrEmpty(x.GraduateCardNo)).Select(x => x.GraduateCardNo.Trim()).ToList();
  619. //对比后的newGraduateCardNoList
  620. var newGraduateCardNoList = StudentDAL.Value.StudentRepository.GetList(x => graduateCardNoList.Contains(x.GraduateCardNo)).ToList();
  621. //考生号
  622. var examineeNumList = enlist.Where(x => !string.IsNullOrEmpty(x.ExamineeNum)).Select(x => x.ExamineeNum.Trim()).ToList();
  623. //对比后的newExamineeNumList
  624. var newExamineeNumList = StudentDAL.Value.RecruitstudentsRepository.GetList(x => examineeNumList.Contains(x.ExamineeNum)).ToList();
  625. //学号
  626. var studentNoList = enlist.Where(x => !string.IsNullOrEmpty(x.StudentNo)).Select(x => x.StudentNo.Trim()).ToList();
  627. //对比后的newNewStuList
  628. var newNewStuList = StudentDAL.Value.NewStudentRepository.GetList(x => x.AssignStatus == (int)CF_AssignStatus.Assigned).Where(x => studentNoList.Contains(x.StudentNo)).ToList();
  629. //对比后的newStudentList
  630. var newStudentList = StudentDAL.Value.StudentRepository.GetList(x => studentNoList.Contains(x.Sys_User.LoginID),
  631. (x => x.CF_StudentProfile), (x => x.CF_StudentContact), (x => x.CF_StudentAccount),
  632. (x => x.CF_Recruitstudents), (x => x.Sys_User)).ToList();
  633. //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等)
  634. for (int i = 0; i < enlist.Count; i++)
  635. {
  636. StudentView en = enlist[i]; //Excel表数据视图
  637. var newUser = new Sys_User();
  638. var newStudent = new CF_Student();
  639. var newStudentProfile = new CF_StudentProfile();
  640. var newStudentContact = new CF_StudentContact();
  641. var newStudentAccount = new CF_StudentAccount();
  642. var newRecruitstudents = new CF_Recruitstudents();
  643. //考生号
  644. if (string.IsNullOrWhiteSpace(en.ExamineeNum))
  645. {
  646. errCount++;
  647. errorMsgStr = "考生号不能为空";
  648. en.ErrorMessage = errorMsgStr;
  649. errList.Add(en);
  650. errorMsg.AppendLine(errorMsgStr);
  651. continue;
  652. }
  653. else
  654. {
  655. reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
  656. if (!reg.IsMatch(en.ExamineeNum.Trim()))
  657. {
  658. errCount++;
  659. errorMsgStr = "考生号格式不正确,请检查(数字或英文字母)";
  660. en.ErrorMessage = errorMsgStr;
  661. errList.Add(en);
  662. errorMsg.AppendLine(errorMsgStr);
  663. continue;
  664. }
  665. else
  666. {
  667. newRecruitstudents.ExamineeNum = en.ExamineeNum.Trim();
  668. }
  669. }
  670. //准考证号
  671. if (string.IsNullOrWhiteSpace(en.AdmissionTicketNo))
  672. {
  673. //暂不考虑
  674. }
  675. else
  676. {
  677. reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
  678. if (!reg.IsMatch(en.AdmissionTicketNo.Trim()))
  679. {
  680. errCount++;
  681. errorMsgStr = "准考证号格式不正确,请检查(数字或英文字母)";
  682. en.ErrorMessage = errorMsgStr;
  683. errList.Add(en);
  684. errorMsg.AppendLine(errorMsgStr);
  685. continue;
  686. }
  687. else
  688. {
  689. newRecruitstudents.AdmissionTicketNo = en.AdmissionTicketNo.Trim();
  690. }
  691. }
  692. //学号
  693. if (string.IsNullOrWhiteSpace(en.StudentNo))
  694. {
  695. errCount++;
  696. errorMsgStr = "学号不能为空";
  697. en.ErrorMessage = errorMsgStr;
  698. errList.Add(en);
  699. errorMsg.AppendLine(errorMsgStr);
  700. continue;
  701. }
  702. else
  703. {
  704. reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
  705. if (!reg.IsMatch(en.StudentNo.Trim()))
  706. {
  707. errCount++;
  708. errorMsgStr = "学号格式不正确,请检查(数字或英文字母)";
  709. en.ErrorMessage = errorMsgStr;
  710. errList.Add(en);
  711. errorMsg.AppendLine(errorMsgStr);
  712. continue;
  713. }
  714. else
  715. {
  716. if (en.StudentNo.Trim().Length > Convert.ToInt32(studentNoTotal))
  717. {
  718. errCount++;
  719. errorMsgStr = "学号总位数有误,学号总位数应小于等于" + studentNoTotal + "位。";
  720. en.ErrorMessage = errorMsgStr;
  721. errList.Add(en);
  722. errorMsg.AppendLine(errorMsgStr);
  723. continue;
  724. }
  725. else
  726. {
  727. newUser.LoginID = en.StudentNo.Trim();
  728. }
  729. }
  730. }
  731. //姓名
  732. if (string.IsNullOrWhiteSpace(en.Name))
  733. {
  734. errCount++;
  735. errorMsgStr = "姓名不能为空";
  736. en.ErrorMessage = errorMsgStr;
  737. errList.Add(en);
  738. errorMsg.AppendLine(errorMsgStr);
  739. continue;
  740. }
  741. else
  742. {
  743. newUser.Name = en.Name.Trim();
  744. }
  745. //曾用名
  746. if (string.IsNullOrWhiteSpace(en.UsedName))
  747. {
  748. //暂不考虑
  749. }
  750. else
  751. {
  752. newStudentProfile.UsedName = en.UsedName.Trim();
  753. }
  754. //性别
  755. if (string.IsNullOrWhiteSpace(en.SexStr))
  756. {
  757. errCount++;
  758. errorMsgStr = "性别不能为空";
  759. en.ErrorMessage = errorMsgStr;
  760. errList.Add(en);
  761. errorMsg.AppendLine(errorMsgStr);
  762. continue;
  763. }
  764. else
  765. {
  766. var sex = sexList.Where(x => x.Name == en.SexStr.Trim()).SingleOrDefault();
  767. if (sex == null)
  768. {
  769. errCount++;
  770. errorMsgStr = "性别不存在,请检查";
  771. en.ErrorMessage = errorMsgStr;
  772. errList.Add(en);
  773. errorMsg.AppendLine(errorMsgStr);
  774. continue;
  775. }
  776. else
  777. {
  778. newStudent.SexID = sex.Value;
  779. }
  780. }
  781. //出生日期
  782. if (string.IsNullOrWhiteSpace(en.BirthDateStr))
  783. {
  784. errCount++;
  785. errorMsgStr = "出生日期不能为空";
  786. en.ErrorMessage = errorMsgStr;
  787. errList.Add(en);
  788. errorMsg.AppendLine(errorMsgStr);
  789. continue;
  790. }
  791. else
  792. {
  793. //reg = new Regex(@"(\d{4})-(\d{1,2})-(\d{1,2})"); //日期正则表达式,2017-12-28
  794. if (!DateTime.TryParse(en.BirthDateStr, out result))
  795. {
  796. errCount++;
  797. errorMsgStr = "出生日期格式不正确,请检查";
  798. en.ErrorMessage = errorMsgStr;
  799. errList.Add(en);
  800. errorMsg.AppendLine(errorMsgStr);
  801. continue;
  802. }
  803. else
  804. {
  805. newStudent.BirthDate = Convert.ToDateTime(en.BirthDateStr);
  806. }
  807. }
  808. //民族
  809. if (string.IsNullOrWhiteSpace(en.NationStr))
  810. {
  811. errCount++;
  812. errorMsgStr = "民族不能为空";
  813. en.ErrorMessage = errorMsgStr;
  814. errList.Add(en);
  815. errorMsg.AppendLine(errorMsgStr);
  816. continue;
  817. }
  818. else
  819. {
  820. var nation = nationList.Where(x => x.Name == en.NationStr.Trim()).SingleOrDefault();
  821. if (nation == null)
  822. {
  823. errCount++;
  824. errorMsgStr = "民族不存在,请检查";
  825. en.ErrorMessage = errorMsgStr;
  826. errList.Add(en);
  827. errorMsg.AppendLine(errorMsgStr);
  828. continue;
  829. }
  830. else
  831. {
  832. newStudent.NationID = nation.Value;
  833. }
  834. }
  835. //政治面貌
  836. if (string.IsNullOrWhiteSpace(en.PoliticsStr))
  837. {
  838. errCount++;
  839. errorMsgStr = "政治面貌不能为空";
  840. en.ErrorMessage = errorMsgStr;
  841. errList.Add(en);
  842. errorMsg.AppendLine(errorMsgStr);
  843. continue;
  844. }
  845. else
  846. {
  847. var politics = politicsList.Where(x => x.Name == en.PoliticsStr.Trim()).SingleOrDefault();
  848. if (politics == null)
  849. {
  850. errCount++;
  851. errorMsgStr = "政治面貌不存在,请检查";
  852. en.ErrorMessage = errorMsgStr;
  853. errList.Add(en);
  854. errorMsg.AppendLine(errorMsgStr);
  855. continue;
  856. }
  857. else
  858. {
  859. newStudent.PoliticsID = politics.Value;
  860. }
  861. }
  862. //学生类别
  863. if (string.IsNullOrWhiteSpace(en.StudentTypeStr))
  864. {
  865. newStudent.StudentType = (int)CF_STUDENTTYPE.DefaultType;
  866. }
  867. else
  868. {
  869. var studentType = studentTypeList.Where(x => x.Name == en.StudentTypeStr.Trim()).SingleOrDefault();
  870. if (studentType == null)
  871. {
  872. errCount++;
  873. errorMsgStr = "学生类别不存在,请检查";
  874. en.ErrorMessage = errorMsgStr;
  875. errList.Add(en);
  876. errorMsg.AppendLine(errorMsgStr);
  877. continue;
  878. }
  879. else
  880. {
  881. newStudent.StudentType = studentType.Value;
  882. }
  883. }
  884. //证件类型
  885. if (string.IsNullOrWhiteSpace(en.CertificatesTypeStr))
  886. {
  887. //默认为身份证
  888. newStudent.CertificatesType = (int)CF_CertificatesType.IdCrad;
  889. }
  890. else
  891. {
  892. var certificatesType = certificatesTypeList.Where(x => x.Name == en.CertificatesTypeStr.Trim()).SingleOrDefault();
  893. if (certificatesType == null)
  894. {
  895. errCount++;
  896. errorMsgStr = "证件类型不存在,请检查";
  897. en.ErrorMessage = errorMsgStr;
  898. errList.Add(en);
  899. errorMsg.AppendLine(errorMsgStr);
  900. continue;
  901. }
  902. else
  903. {
  904. newStudent.CertificatesType = certificatesType.Value;
  905. }
  906. }
  907. //证件号码
  908. if (string.IsNullOrWhiteSpace(en.IDNumber))
  909. {
  910. errCount++;
  911. errorMsgStr = "证件号码不能为空";
  912. en.ErrorMessage = errorMsgStr;
  913. errList.Add(en);
  914. errorMsg.AppendLine(errorMsgStr);
  915. continue;
  916. }
  917. else
  918. {
  919. //reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
  920. //if (!reg.IsMatch(en.IDNumber.Trim()))
  921. //{
  922. // errCount++;
  923. // errorMsgStr = "证件号码格式不正确,请检查(数字或英文字母)";
  924. // en.ErrorMessage = errorMsgStr;
  925. // errList.Add(en);
  926. // errorMsg.AppendLine(errorMsgStr);
  927. // continue;
  928. //}
  929. //else
  930. //{
  931. // newStudent.IDNumber = en.IDNumber.Trim();
  932. //}
  933. newStudent.IDNumber = en.IDNumber.Trim();
  934. }
  935. //在校状态
  936. if (string.IsNullOrWhiteSpace(en.InSchoolStatusStr))
  937. {
  938. errCount++;
  939. errorMsgStr = "在校状态不能为空";
  940. en.ErrorMessage = errorMsgStr;
  941. errList.Add(en);
  942. errorMsg.AppendLine(errorMsgStr);
  943. continue;
  944. }
  945. else
  946. {
  947. var inSchoolStatus = inschoolStatusList.Where(x => x.Name == en.InSchoolStatusStr.Trim()).SingleOrDefault();
  948. if (inSchoolStatus == null)
  949. {
  950. errCount++;
  951. errorMsgStr = "在校状态不存在,请检查";
  952. en.ErrorMessage = errorMsgStr;
  953. errList.Add(en);
  954. errorMsg.AppendLine(errorMsgStr);
  955. continue;
  956. }
  957. else
  958. {
  959. newStudent.InSchoolStatusID = inSchoolStatus.Value;
  960. }
  961. }
  962. //学籍状态
  963. if (string.IsNullOrWhiteSpace(en.StudentStatusStr))
  964. {
  965. errCount++;
  966. errorMsgStr = "学籍状态不能为空";
  967. en.ErrorMessage = errorMsgStr;
  968. errList.Add(en);
  969. errorMsg.AppendLine(errorMsgStr);
  970. continue;
  971. }
  972. else
  973. {
  974. var studentStatus = studentStatusList.Where(x => x.Name == en.StudentStatusStr.Trim()).SingleOrDefault();
  975. if (studentStatus == null)
  976. {
  977. errCount++;
  978. errorMsgStr = "学籍状态不存在,请检查";
  979. en.ErrorMessage = errorMsgStr;
  980. errList.Add(en);
  981. errorMsg.AppendLine(errorMsgStr);
  982. continue;
  983. }
  984. else
  985. {
  986. newStudent.StudentStatus = studentStatus.Value;
  987. }
  988. }
  989. //班级编号
  990. if (string.IsNullOrWhiteSpace(en.ClassmajorNo))
  991. {
  992. errCount++;
  993. errorMsgStr = "班级编号不能为空";
  994. en.ErrorMessage = errorMsgStr;
  995. errList.Add(en);
  996. errorMsg.AppendLine(errorMsgStr);
  997. continue;
  998. }
  999. else
  1000. {
  1001. var classmajor = newClassmajorList.Where(x => x.No == en.ClassmajorNo.Trim()).SingleOrDefault();
  1002. if (classmajor == null)
  1003. {
  1004. errCount++;
  1005. errorMsgStr = "班级编号不存在,请检查";
  1006. en.ErrorMessage = errorMsgStr;
  1007. errList.Add(en);
  1008. errorMsg.AppendLine(errorMsgStr);
  1009. continue;
  1010. }
  1011. else
  1012. {
  1013. //判断班级编号与班级名称(以班级编号为准)
  1014. if (string.IsNullOrWhiteSpace(en.ClassmajorName))
  1015. {
  1016. //暂不考虑
  1017. }
  1018. else
  1019. {
  1020. //班级编号与班级名称不对应
  1021. if (classmajor.Name.Trim() != en.ClassmajorName.Trim())
  1022. {
  1023. errCount++;
  1024. errorMsgStr = "班级编号与班级名称不对应(以班级编号为准),请检查";
  1025. en.ErrorMessage = errorMsgStr;
  1026. errList.Add(en);
  1027. errorMsg.AppendLine(errorMsgStr);
  1028. continue;
  1029. }
  1030. }
  1031. newStudent.ClassmajorID = classmajor.ClassmajorID;
  1032. newStudent.PlanningGraduateDate = this.GetClassmajorPlanningGraduateDate(classmajor.ClassmajorID);
  1033. newStudent.GraduateDate = this.GetClassmajorGraduateDate(classmajor.ClassmajorID);
  1034. }
  1035. }
  1036. //班级名称
  1037. if (string.IsNullOrWhiteSpace(en.ClassmajorName))
  1038. {
  1039. //暂不考虑
  1040. }
  1041. else
  1042. {
  1043. //暂不考虑
  1044. }
  1045. //文化程度
  1046. if (string.IsNullOrWhiteSpace(en.LiteracyLevelStr))
  1047. {
  1048. //暂不考虑
  1049. }
  1050. else
  1051. {
  1052. var literacyLevel = literacyLevelList.Where(x => x.Name == en.LiteracyLevelStr.Trim()).SingleOrDefault();
  1053. if (literacyLevel == null)
  1054. {
  1055. errCount++;
  1056. errorMsgStr = "文化程度不存在,请检查";
  1057. en.ErrorMessage = errorMsgStr;
  1058. errList.Add(en);
  1059. errorMsg.AppendLine(errorMsgStr);
  1060. continue;
  1061. }
  1062. else
  1063. {
  1064. newStudentProfile.LiteracyLevelID = literacyLevel.Value;
  1065. }
  1066. }
  1067. //培养方式
  1068. if (string.IsNullOrWhiteSpace(en.CultureModelStr))
  1069. {
  1070. //暂不考虑
  1071. }
  1072. else
  1073. {
  1074. var cultureModel = cultureModelList.Where(x => x.Name == en.CultureModelStr.Trim()).SingleOrDefault();
  1075. if (cultureModel == null)
  1076. {
  1077. errCount++;
  1078. errorMsgStr = "培养方式不存在,请检查";
  1079. en.ErrorMessage = errorMsgStr;
  1080. errList.Add(en);
  1081. errorMsg.AppendLine(errorMsgStr);
  1082. continue;
  1083. }
  1084. else
  1085. {
  1086. newStudentProfile.CultureModelID = cultureModel.Value;
  1087. }
  1088. }
  1089. //考生类别
  1090. if (string.IsNullOrWhiteSpace(en.ExamineeTypeStr))
  1091. {
  1092. //暂不考虑
  1093. }
  1094. else
  1095. {
  1096. var examineeType = examineeTypeList.Where(x => x.Name == en.ExamineeTypeStr.Trim()).SingleOrDefault();
  1097. if (examineeType == null)
  1098. {
  1099. errCount++;
  1100. errorMsgStr = "考生类别不存在,请检查";
  1101. en.ErrorMessage = errorMsgStr;
  1102. errList.Add(en);
  1103. errorMsg.AppendLine(errorMsgStr);
  1104. continue;
  1105. }
  1106. else
  1107. {
  1108. newRecruitstudents.ExamineeType = examineeType.Value;
  1109. }
  1110. }
  1111. //入学日期
  1112. if (string.IsNullOrWhiteSpace(en.EntranceDateStr))
  1113. {
  1114. //暂不考虑
  1115. }
  1116. else
  1117. {
  1118. if (!DateTime.TryParse(en.EntranceDateStr, out result))
  1119. {
  1120. errCount++;
  1121. errorMsgStr = "入学日期格式不正确,请检查";
  1122. en.ErrorMessage = errorMsgStr;
  1123. errList.Add(en);
  1124. errorMsg.AppendLine(errorMsgStr);
  1125. continue;
  1126. }
  1127. else
  1128. {
  1129. newRecruitstudents.EntranceDate = Convert.ToDateTime(en.EntranceDateStr);
  1130. }
  1131. }
  1132. //总分
  1133. if (string.IsNullOrWhiteSpace(en.ScoreStr))
  1134. {
  1135. //暂不考虑
  1136. }
  1137. else
  1138. {
  1139. reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$"); //数字正则表达式
  1140. if (!reg.IsMatch(en.ScoreStr))
  1141. {
  1142. errCount++;
  1143. errorMsgStr = "总分格式不正确,请检查";
  1144. en.ErrorMessage = errorMsgStr;
  1145. errList.Add(en);
  1146. errorMsg.AppendLine(errorMsgStr);
  1147. continue;
  1148. }
  1149. else
  1150. {
  1151. newRecruitstudents.Score = Convert.ToDecimal(en.ScoreStr);
  1152. }
  1153. }
  1154. //入学方式
  1155. if (string.IsNullOrWhiteSpace(en.EntranceWayStr))
  1156. {
  1157. //暂不考虑
  1158. }
  1159. else
  1160. {
  1161. var entranceWay = entranceWayList.Where(x => x.Name == en.EntranceWayStr.Trim()).SingleOrDefault();
  1162. if (entranceWay == null)
  1163. {
  1164. errCount++;
  1165. errorMsgStr = "入学方式不存在,请检查";
  1166. en.ErrorMessage = errorMsgStr;
  1167. errList.Add(en);
  1168. errorMsg.AppendLine(errorMsgStr);
  1169. continue;
  1170. }
  1171. else
  1172. {
  1173. newRecruitstudents.EntranceWayID = entranceWay.Value;
  1174. }
  1175. }
  1176. //考生特征
  1177. if (string.IsNullOrWhiteSpace(en.FeaturesStr))
  1178. {
  1179. //暂不考虑
  1180. }
  1181. else
  1182. {
  1183. var features = featuresList.Where(x => x.Name == en.FeaturesStr.Trim()).SingleOrDefault();
  1184. if (features == null)
  1185. {
  1186. errCount++;
  1187. errorMsgStr = "考生特征不存在,请检查";
  1188. en.ErrorMessage = errorMsgStr;
  1189. errList.Add(en);
  1190. errorMsg.AppendLine(errorMsgStr);
  1191. continue;
  1192. }
  1193. else
  1194. {
  1195. newRecruitstudents.FeaturesID = features.Value;
  1196. }
  1197. }
  1198. //生源所属地
  1199. if (string.IsNullOrWhiteSpace(en.TerritorialStr))
  1200. {
  1201. //暂不考虑
  1202. }
  1203. else
  1204. {
  1205. var territorial = territorialList.Where(x => x.Name == en.TerritorialStr.Trim()).SingleOrDefault();
  1206. if (territorial == null)
  1207. {
  1208. errCount++;
  1209. errorMsgStr = "生源所属地不存在,请检查";
  1210. en.ErrorMessage = errorMsgStr;
  1211. errList.Add(en);
  1212. errorMsg.AppendLine(errorMsgStr);
  1213. continue;
  1214. }
  1215. else
  1216. {
  1217. newRecruitstudents.TerritorialID = territorial.Value;
  1218. }
  1219. }
  1220. //来源地区
  1221. if (string.IsNullOrWhiteSpace(en.Area))
  1222. {
  1223. //暂不考虑
  1224. }
  1225. else
  1226. {
  1227. newRecruitstudents.Area = en.Area.Trim();
  1228. }
  1229. //国籍
  1230. if (string.IsNullOrWhiteSpace(en.Country))
  1231. {
  1232. //暂不考虑
  1233. }
  1234. else
  1235. {
  1236. newStudentProfile.Country = en.Country.Trim();
  1237. }
  1238. //籍贯
  1239. if (string.IsNullOrWhiteSpace(en.Place))
  1240. {
  1241. //暂不考虑
  1242. }
  1243. else
  1244. {
  1245. newStudentProfile.Place = en.Place.Trim();
  1246. }
  1247. //出生地
  1248. if (string.IsNullOrWhiteSpace(en.BornPlace))
  1249. {
  1250. //暂不考虑
  1251. }
  1252. else
  1253. {
  1254. newStudentProfile.BornPlace = en.BornPlace.Trim();
  1255. }
  1256. //电子邮箱
  1257. if (string.IsNullOrWhiteSpace(en.Email))
  1258. {
  1259. //暂不考虑
  1260. }
  1261. else
  1262. {
  1263. reg = new Regex(@"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"); //正则表达式
  1264. if (!reg.IsMatch(en.Email.Trim()))
  1265. {
  1266. errCount++;
  1267. errorMsgStr = "电子邮箱格式不正确,请检查";
  1268. en.ErrorMessage = errorMsgStr;
  1269. errList.Add(en);
  1270. errorMsg.AppendLine(errorMsgStr);
  1271. continue;
  1272. }
  1273. else
  1274. {
  1275. newStudentContact.Email = en.Email.Trim();
  1276. }
  1277. }
  1278. //移动电话
  1279. if (string.IsNullOrWhiteSpace(en.Mobile))
  1280. {
  1281. //暂不考虑
  1282. }
  1283. else
  1284. {
  1285. newStudentContact.Mobile = en.Mobile.Trim();
  1286. }
  1287. //家庭电话
  1288. if (string.IsNullOrWhiteSpace(en.Telephone))
  1289. {
  1290. //暂不考虑
  1291. }
  1292. else
  1293. {
  1294. newStudentContact.Telephone = en.Telephone.Trim();
  1295. }
  1296. //邮政编码
  1297. if (string.IsNullOrWhiteSpace(en.ZIPCode))
  1298. {
  1299. //暂不考虑
  1300. }
  1301. else
  1302. {
  1303. reg = new Regex(@"[1-9]\d{5}(?!\d)"); //正则表达式
  1304. if (!reg.IsMatch(en.ZIPCode.Trim()))
  1305. {
  1306. errCount++;
  1307. errorMsgStr = "邮政编码格式不正确,请检查";
  1308. en.ErrorMessage = errorMsgStr;
  1309. errList.Add(en);
  1310. errorMsg.AppendLine(errorMsgStr);
  1311. continue;
  1312. }
  1313. else
  1314. {
  1315. newStudentContact.ZIPCode = en.ZIPCode.Trim();
  1316. }
  1317. }
  1318. //健康状况
  1319. if (string.IsNullOrWhiteSpace(en.HealthStateStr))
  1320. {
  1321. newStudentProfile.HealthStateID = (int)CF_HealthState.Healthy;
  1322. }
  1323. else
  1324. {
  1325. var healthState = healthStateList.Where(x => x.Name == en.HealthStateStr.Trim()).SingleOrDefault();
  1326. if (healthState == null)
  1327. {
  1328. errCount++;
  1329. errorMsgStr = "健康状况不存在,请检查";
  1330. en.ErrorMessage = errorMsgStr;
  1331. errList.Add(en);
  1332. errorMsg.AppendLine(errorMsgStr);
  1333. continue;
  1334. }
  1335. else
  1336. {
  1337. newStudentProfile.HealthStateID = healthState.Value;
  1338. }
  1339. }
  1340. //血型
  1341. if (string.IsNullOrWhiteSpace(en.BloodGroupStr))
  1342. {
  1343. //暂不考虑
  1344. }
  1345. else
  1346. {
  1347. var bloodGroup = bloodGroupList.Where(x => x.Name == en.BloodGroupStr.Trim()).SingleOrDefault();
  1348. if (bloodGroup == null)
  1349. {
  1350. errCount++;
  1351. errorMsgStr = "血型不存在,请检查";
  1352. en.ErrorMessage = errorMsgStr;
  1353. errList.Add(en);
  1354. errorMsg.AppendLine(errorMsgStr);
  1355. continue;
  1356. }
  1357. else
  1358. {
  1359. newStudentProfile.BloodGroup = bloodGroup.Value;
  1360. }
  1361. }
  1362. //特长
  1363. if (string.IsNullOrWhiteSpace(en.Specialty))
  1364. {
  1365. //暂不考虑
  1366. }
  1367. else
  1368. {
  1369. newStudentProfile.Specialty = en.Specialty.Trim();
  1370. }
  1371. //身高(cm)
  1372. if (string.IsNullOrWhiteSpace(en.Height))
  1373. {
  1374. //暂不考虑
  1375. }
  1376. else
  1377. {
  1378. reg = new Regex(@"^\d+(\.\d+)?$"); //正则表达式
  1379. if (!reg.IsMatch(en.Height.Trim()))
  1380. {
  1381. errCount++;
  1382. errorMsgStr = "身高(cm)格式不正确,请检查";
  1383. en.ErrorMessage = errorMsgStr;
  1384. errList.Add(en);
  1385. errorMsg.AppendLine(errorMsgStr);
  1386. continue;
  1387. }
  1388. else
  1389. {
  1390. newStudentProfile.Height = en.Height.Trim();
  1391. }
  1392. }
  1393. //体重(kg)
  1394. if (string.IsNullOrWhiteSpace(en.Weight))
  1395. {
  1396. //暂不考虑
  1397. }
  1398. else
  1399. {
  1400. reg = new Regex(@"^\d+(\.\d+)?$"); //正则表达式
  1401. if (!reg.IsMatch(en.Weight.Trim()))
  1402. {
  1403. errCount++;
  1404. errorMsgStr = "体重(cm)格式不正确,请检查";
  1405. en.ErrorMessage = errorMsgStr;
  1406. errList.Add(en);
  1407. errorMsg.AppendLine(errorMsgStr);
  1408. continue;
  1409. }
  1410. else
  1411. {
  1412. newStudentProfile.Weight = en.Weight.Trim();
  1413. }
  1414. }
  1415. //微信号
  1416. if (string.IsNullOrWhiteSpace(en.WeChatNum))
  1417. {
  1418. //暂不考虑
  1419. }
  1420. else
  1421. {
  1422. newStudentContact.WeChatNum = en.WeChatNum.Trim();
  1423. }
  1424. //QQ
  1425. if (string.IsNullOrWhiteSpace(en.QQ))
  1426. {
  1427. //暂不考虑
  1428. }
  1429. else
  1430. {
  1431. reg = new Regex(@"[1-9][0-9]{4,}"); //正则表达式
  1432. if (!reg.IsMatch(en.QQ.Trim()))
  1433. {
  1434. errCount++;
  1435. errorMsgStr = "QQ格式不正确,请检查";
  1436. en.ErrorMessage = errorMsgStr;
  1437. errList.Add(en);
  1438. errorMsg.AppendLine(errorMsgStr);
  1439. continue;
  1440. }
  1441. else
  1442. {
  1443. newStudentContact.QQ = en.QQ.Trim();
  1444. }
  1445. }
  1446. //家庭住址
  1447. if (string.IsNullOrWhiteSpace(en.HomeAddress))
  1448. {
  1449. //暂不考虑
  1450. }
  1451. else
  1452. {
  1453. newStudentContact.HomeAddress = en.HomeAddress.Trim();
  1454. }
  1455. //工作单位
  1456. if (string.IsNullOrWhiteSpace(en.WorkUnit))
  1457. {
  1458. //暂不考虑
  1459. }
  1460. else
  1461. {
  1462. newStudentContact.WorkUnit = en.WorkUnit.Trim();
  1463. }
  1464. //通信地址
  1465. if (string.IsNullOrWhiteSpace(en.Address))
  1466. {
  1467. //暂不考虑
  1468. }
  1469. else
  1470. {
  1471. newStudentContact.Address = en.Address.Trim();
  1472. }
  1473. //宿舍地址
  1474. if (string.IsNullOrWhiteSpace(en.Dormitory))
  1475. {
  1476. //暂不考虑
  1477. }
  1478. else
  1479. {
  1480. newStudentContact.Dormitory = en.Dormitory.Trim();
  1481. }
  1482. //收件人
  1483. if (string.IsNullOrWhiteSpace(en.Recipient))
  1484. {
  1485. //暂不考虑
  1486. }
  1487. else
  1488. {
  1489. newStudentContact.Recipient = en.Recipient.Trim();
  1490. }
  1491. //圆梦计划
  1492. if (string.IsNullOrWhiteSpace(en.IsDreamProjectStr))
  1493. {
  1494. newStudentProfile.IsDreamProject = false;
  1495. }
  1496. else
  1497. {
  1498. var isDreamProject = generalPurposeList.Where(x => x.Name == en.IsDreamProjectStr.Trim()).SingleOrDefault();
  1499. if (isDreamProject == null)
  1500. {
  1501. errCount++;
  1502. errorMsgStr = "是否圆梦计划不存在,请检查";
  1503. en.ErrorMessage = errorMsgStr;
  1504. errList.Add(en);
  1505. errorMsg.AppendLine(errorMsgStr);
  1506. continue;
  1507. }
  1508. else
  1509. {
  1510. newStudentProfile.IsDreamProject = isDreamProject.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
  1511. }
  1512. }
  1513. //导师姓名
  1514. if (string.IsNullOrWhiteSpace(en.DirectorName))
  1515. {
  1516. //暂不考虑
  1517. }
  1518. else
  1519. {
  1520. newStudentProfile.DirectorName = en.DirectorName.Trim();
  1521. }
  1522. //开户银行
  1523. if (string.IsNullOrWhiteSpace(en.BankName))
  1524. {
  1525. //暂不考虑
  1526. }
  1527. else
  1528. {
  1529. newStudentAccount.BankName = en.BankName.Trim();
  1530. }
  1531. //银行卡号
  1532. if (string.IsNullOrWhiteSpace(en.CardNo))
  1533. {
  1534. //暂不考虑
  1535. }
  1536. else
  1537. {
  1538. reg = new Regex(@"^[0-9]*$"); //正则表达式
  1539. if (!reg.IsMatch(en.CardNo.Trim()))
  1540. {
  1541. errCount++;
  1542. errorMsgStr = "银行卡号格式不正确,请检查";
  1543. en.ErrorMessage = errorMsgStr;
  1544. errList.Add(en);
  1545. errorMsg.AppendLine(errorMsgStr);
  1546. continue;
  1547. }
  1548. else
  1549. {
  1550. newStudentAccount.CardNo = en.CardNo.Trim();
  1551. }
  1552. }
  1553. //学籍卡编号
  1554. if (string.IsNullOrWhiteSpace(en.StudentCardNo))
  1555. {
  1556. //暂不考虑
  1557. }
  1558. else
  1559. {
  1560. reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式
  1561. if (!reg.IsMatch(en.StudentCardNo.Trim()))
  1562. {
  1563. errCount++;
  1564. errorMsgStr = "学籍卡编号格式不正确,请检查";
  1565. en.ErrorMessage = errorMsgStr;
  1566. errList.Add(en);
  1567. errorMsg.AppendLine(errorMsgStr);
  1568. continue;
  1569. }
  1570. else
  1571. {
  1572. newStudent.StudentCardNo = en.StudentCardNo.Trim();
  1573. }
  1574. }
  1575. //毕结业证书编号
  1576. if (string.IsNullOrWhiteSpace(en.GraduateCardNo))
  1577. {
  1578. //暂不考虑
  1579. }
  1580. else
  1581. {
  1582. reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式
  1583. if (!reg.IsMatch(en.GraduateCardNo.Trim()))
  1584. {
  1585. errCount++;
  1586. errorMsgStr = "毕结业证书编号格式不正确,请检查";
  1587. en.ErrorMessage = errorMsgStr;
  1588. errList.Add(en);
  1589. errorMsg.AppendLine(errorMsgStr);
  1590. continue;
  1591. }
  1592. else
  1593. {
  1594. newStudent.GraduateCardNo = en.GraduateCardNo.Trim();
  1595. }
  1596. }
  1597. //学位有无
  1598. if (string.IsNullOrWhiteSpace(en.DegreeStatusStr))
  1599. {
  1600. newStudent.DegreeStatus = false;
  1601. }
  1602. else
  1603. {
  1604. var degreeStatus = generalExistList.Where(x => x.Name == en.DegreeStatusStr.Trim()).SingleOrDefault();
  1605. if (degreeStatus == null)
  1606. {
  1607. errCount++;
  1608. errorMsgStr = "学位有无不存在,请检查";
  1609. en.ErrorMessage = errorMsgStr;
  1610. errList.Add(en);
  1611. errorMsg.AppendLine(errorMsgStr);
  1612. continue;
  1613. }
  1614. else
  1615. {
  1616. newStudent.DegreeStatus = degreeStatus.Value == (int)CF_GeneralExist.Have ? true : false;
  1617. }
  1618. }
  1619. //在校经历
  1620. if (string.IsNullOrWhiteSpace(en.Career))
  1621. {
  1622. //暂不考虑
  1623. }
  1624. else
  1625. {
  1626. newStudent.Career = en.Career.Trim();
  1627. }
  1628. //备注
  1629. if (string.IsNullOrWhiteSpace(en.Remark))
  1630. {
  1631. //暂不考虑
  1632. }
  1633. else
  1634. {
  1635. newStudent.Remark = en.Remark.Trim();
  1636. }
  1637. ////Excel表重复性验证(注:当数据表中没有此记录,但是Excel中有重复数据时的去掉)
  1638. //for (int j = i + 1; j < enlist.Count; j++)
  1639. //{
  1640. // StudentView enA = enlist[j];
  1641. // //根据Excel表中的业务主键进行去重(学号或考生号唯一)
  1642. // if (en.StudentNo == enA.StudentNo || en.ExamineeNum == enA.ExamineeNum)
  1643. // {
  1644. // //用于标识Excel表中的重复记录(由于是批量进行插入数据表)
  1645. // }
  1646. //}
  1647. //数据表重复性验证(学号或考生号唯一)
  1648. var userVerify = newStudentList.Select(x => x.Sys_User).Where(x => x.LoginID == newUser.LoginID).SingleOrDefault();
  1649. if (userVerify == null)
  1650. {
  1651. var newNewStuVerify = newNewStuList.Where(x => x.ExamineeNum != newRecruitstudents.ExamineeNum
  1652. && x.StudentNo == newUser.LoginID).SingleOrDefault();
  1653. if (newNewStuVerify != null)
  1654. {
  1655. errCount++;
  1656. errorMsgStr = "学号重复(录取名单中学号重复),请核查";
  1657. en.ErrorMessage = errorMsgStr;
  1658. errList.Add(en);
  1659. errorMsg.AppendLine(errorMsgStr);
  1660. continue;
  1661. }
  1662. if (!newRecruitstudentsUpList.Any(x => x.ExamineeNum == newRecruitstudents.ExamineeNum))
  1663. {
  1664. if (!newRecruitstudentsInList.Any(x => x.ExamineeNum == newRecruitstudents.ExamineeNum))
  1665. {
  1666. var newExamineeNumVerify = newExamineeNumList.Where(x => x.ExamineeNum == newRecruitstudents.ExamineeNum).SingleOrDefault();
  1667. if (newExamineeNumVerify != null)
  1668. {
  1669. errCount++;
  1670. errorMsgStr = "考生号重复,请核查";
  1671. en.ErrorMessage = errorMsgStr;
  1672. errList.Add(en);
  1673. errorMsg.AppendLine(errorMsgStr);
  1674. continue;
  1675. }
  1676. }
  1677. else
  1678. {
  1679. errCount++;
  1680. errorMsgStr = "考生号重复(Excel中),请检查";
  1681. en.ErrorMessage = errorMsgStr;
  1682. errList.Add(en);
  1683. errorMsg.AppendLine(errorMsgStr);
  1684. continue;
  1685. }
  1686. }
  1687. else
  1688. {
  1689. errCount++;
  1690. errorMsgStr = "考生号重复(Excel中),请检查";
  1691. en.ErrorMessage = errorMsgStr;
  1692. errList.Add(en);
  1693. errorMsg.AppendLine(errorMsgStr);
  1694. continue;
  1695. }
  1696. if (!string.IsNullOrEmpty(newStudent.StudentCardNo))
  1697. {
  1698. if (!newStudentUpList.Any(x => x.StudentCardNo == newStudent.StudentCardNo))
  1699. {
  1700. if (!newStudentInList.Any(x => x.StudentCardNo == newStudent.StudentCardNo))
  1701. {
  1702. var newStudentCardNoVerify = newStudentCardNoList.Where(x => x.StudentCardNo == newStudent.StudentCardNo).SingleOrDefault();
  1703. if (newStudentCardNoVerify != null)
  1704. {
  1705. errCount++;
  1706. errorMsgStr = "学籍卡编号重复,请核查";
  1707. en.ErrorMessage = errorMsgStr;
  1708. errList.Add(en);
  1709. errorMsg.AppendLine(errorMsgStr);
  1710. continue;
  1711. }
  1712. }
  1713. else
  1714. {
  1715. errCount++;
  1716. errorMsgStr = "学籍卡编号重复(Excel中),请检查";
  1717. en.ErrorMessage = errorMsgStr;
  1718. errList.Add(en);
  1719. errorMsg.AppendLine(errorMsgStr);
  1720. continue;
  1721. }
  1722. }
  1723. else
  1724. {
  1725. errCount++;
  1726. errorMsgStr = "学籍卡编号重复(Excel中),请检查";
  1727. en.ErrorMessage = errorMsgStr;
  1728. errList.Add(en);
  1729. errorMsg.AppendLine(errorMsgStr);
  1730. continue;
  1731. }
  1732. }
  1733. if (!string.IsNullOrEmpty(newStudent.GraduateCardNo))
  1734. {
  1735. if (!newStudentUpList.Any(x => x.GraduateCardNo == newStudent.GraduateCardNo))
  1736. {
  1737. if (!newStudentInList.Any(x => x.GraduateCardNo == newStudent.GraduateCardNo))
  1738. {
  1739. var newGraduateCardNoVerify = newGraduateCardNoList.Where(x => x.GraduateCardNo == newStudent.GraduateCardNo).SingleOrDefault();
  1740. if (newGraduateCardNoVerify != null)
  1741. {
  1742. errCount++;
  1743. errorMsgStr = "毕结业证书编号重复,请核查";
  1744. en.ErrorMessage = errorMsgStr;
  1745. errList.Add(en);
  1746. errorMsg.AppendLine(errorMsgStr);
  1747. continue;
  1748. }
  1749. }
  1750. else
  1751. {
  1752. errCount++;
  1753. errorMsgStr = "毕结业证书编号重复(Excel中),请检查";
  1754. en.ErrorMessage = errorMsgStr;
  1755. errList.Add(en);
  1756. errorMsg.AppendLine(errorMsgStr);
  1757. continue;
  1758. }
  1759. }
  1760. else
  1761. {
  1762. errCount++;
  1763. errorMsgStr = "毕结业证书编号重复(Excel中),请检查";
  1764. en.ErrorMessage = errorMsgStr;
  1765. errList.Add(en);
  1766. errorMsg.AppendLine(errorMsgStr);
  1767. continue;
  1768. }
  1769. }
  1770. //新增
  1771. if (!newUserInList.Any(x => x.LoginID == newUser.LoginID))
  1772. {
  1773. newUser.UserID = Guid.NewGuid();
  1774. if (passwordParameter == null)
  1775. {
  1776. newUser.Password = ("A" + newUser.LoginID.Trim()).MD5();
  1777. }
  1778. else
  1779. {
  1780. if (passwordParameter.Value != null)
  1781. {
  1782. newUser.Password = passwordParameter.Value;
  1783. }
  1784. else
  1785. {
  1786. newUser.Password = ("A" + newUser.LoginID.Trim()).MD5();
  1787. }
  1788. }
  1789. this.SetNewStatus(newUser, (int)SYS_STATUS.USABLE);
  1790. newUserInList.Add(newUser);
  1791. newUser.Sys_Role = new HashSet<Sys_Role>();
  1792. roleList = roleList.Where(x => x.CF_StudentRole.StudentType == newStudent.StudentType).ToList();
  1793. if (roleList != null && roleList.Count > 0)
  1794. {
  1795. roleList.ForEach(x => newUser.Sys_Role.Add(x));
  1796. }
  1797. else
  1798. {
  1799. //对应角色为空时,默认为不分配用户角色
  1800. }
  1801. newStudent.UserID = newUser.UserID;
  1802. newStudent.IsPhotoComparison = false;
  1803. newStudent.IsProofread = false;
  1804. this.SetNewStatus(newStudent);
  1805. newStudentInList.Add(newStudent);
  1806. newStudentProfile.UserID = newStudent.UserID;
  1807. this.SetNewStatus(newStudentProfile);
  1808. newStudentProfileInList.Add(newStudentProfile);
  1809. newStudentContact.UserID = newStudent.UserID;
  1810. this.SetNewStatus(newStudentContact);
  1811. newStudentContactInList.Add(newStudentContact);
  1812. newStudentAccount.UserID = newStudent.UserID;
  1813. this.SetNewStatus(newStudentAccount);
  1814. newStudentAccountInList.Add(newStudentAccount);
  1815. newRecruitstudents.UserID = newStudent.UserID;
  1816. this.SetNewStatus(newRecruitstudents);
  1817. newRecruitstudentsInList.Add(newRecruitstudents);
  1818. inCount++;
  1819. }
  1820. else
  1821. {
  1822. //Excel表重复性验证
  1823. //(注:当数据表中没有此记录,但是Excel中有重复数据,可在此处进行抛出到失败数据文件中)
  1824. errCount++;
  1825. errorMsgStr = "学号重复(Excel中),请检查";
  1826. en.ErrorMessage = errorMsgStr;
  1827. errList.Add(en);
  1828. errorMsg.AppendLine(errorMsgStr);
  1829. continue;
  1830. }
  1831. }
  1832. else
  1833. {
  1834. //更新(判断Excel有重复时,以最后一条记录更新为准)
  1835. var studentVerify = newStudentList.Where(x => x.UserID == userVerify.UserID).SingleOrDefault();
  1836. if (studentVerify == null)
  1837. {
  1838. errCount++;
  1839. errorMsgStr = "学号冲突(与其它帐号冲突),请检查";
  1840. en.ErrorMessage = errorMsgStr;
  1841. errList.Add(en);
  1842. errorMsg.AppendLine(errorMsgStr);
  1843. continue;
  1844. }
  1845. else
  1846. {
  1847. var newNewStuVerify = newNewStuList.Where(x => x.ExamineeNum != newRecruitstudents.ExamineeNum
  1848. && x.StudentNo == newUser.LoginID).SingleOrDefault();
  1849. if (newNewStuVerify != null)
  1850. {
  1851. errCount++;
  1852. errorMsgStr = "学号重复(录取名单中学号重复),请核查";
  1853. en.ErrorMessage = errorMsgStr;
  1854. errList.Add(en);
  1855. errorMsg.AppendLine(errorMsgStr);
  1856. continue;
  1857. }
  1858. if (!newRecruitstudentsInList.Any(x => x.ExamineeNum == newRecruitstudents.ExamineeNum))
  1859. {
  1860. if (!newRecruitstudentsUpList.Any(x => x.ExamineeNum == newRecruitstudents.ExamineeNum))
  1861. {
  1862. var newExamineeNumVerify = newExamineeNumList.Where(x => x.UserID != userVerify.UserID
  1863. && x.ExamineeNum == newRecruitstudents.ExamineeNum).ToList();
  1864. if (newExamineeNumVerify != null && newExamineeNumVerify.Count() > 0)
  1865. {
  1866. errCount++;
  1867. errorMsgStr = "考生号已存在(与其它学生冲突),请检查";
  1868. en.ErrorMessage = errorMsgStr;
  1869. errList.Add(en);
  1870. errorMsg.AppendLine(errorMsgStr);
  1871. continue;
  1872. }
  1873. }
  1874. else
  1875. {
  1876. errCount++;
  1877. errorMsgStr = "考生号重复(Excel中),请检查";
  1878. en.ErrorMessage = errorMsgStr;
  1879. errList.Add(en);
  1880. errorMsg.AppendLine(errorMsgStr);
  1881. continue;
  1882. }
  1883. }
  1884. else
  1885. {
  1886. errCount++;
  1887. errorMsgStr = "考生号重复(Excel中),请检查";
  1888. en.ErrorMessage = errorMsgStr;
  1889. errList.Add(en);
  1890. errorMsg.AppendLine(errorMsgStr);
  1891. continue;
  1892. }
  1893. if (!string.IsNullOrEmpty(newStudent.StudentCardNo))
  1894. {
  1895. if (!newStudentInList.Any(x => x.StudentCardNo == newStudent.StudentCardNo))
  1896. {
  1897. if (!newStudentUpList.Any(x => x.StudentCardNo == newStudent.StudentCardNo))
  1898. {
  1899. var newStudentCardNoVerify = newStudentCardNoList.Where(x => x.UserID != userVerify.UserID
  1900. && x.StudentCardNo == newStudent.StudentCardNo).ToList();
  1901. if (newStudentCardNoVerify != null && newStudentCardNoVerify.Count() > 0)
  1902. {
  1903. errCount++;
  1904. errorMsgStr = "学籍卡编号已存在(与其它学生冲突),请检查";
  1905. en.ErrorMessage = errorMsgStr;
  1906. errList.Add(en);
  1907. errorMsg.AppendLine(errorMsgStr);
  1908. continue;
  1909. }
  1910. }
  1911. else
  1912. {
  1913. errCount++;
  1914. errorMsgStr = "学籍卡编号重复(Excel中),请检查";
  1915. en.ErrorMessage = errorMsgStr;
  1916. errList.Add(en);
  1917. errorMsg.AppendLine(errorMsgStr);
  1918. continue;
  1919. }
  1920. }
  1921. else
  1922. {
  1923. errCount++;
  1924. errorMsgStr = "学籍卡编号重复(Excel中),请检查";
  1925. en.ErrorMessage = errorMsgStr;
  1926. errList.Add(en);
  1927. errorMsg.AppendLine(errorMsgStr);
  1928. continue;
  1929. }
  1930. }
  1931. if (!string.IsNullOrEmpty(newStudent.GraduateCardNo))
  1932. {
  1933. if (!newStudentInList.Any(x => x.GraduateCardNo == newStudent.GraduateCardNo))
  1934. {
  1935. if (!newStudentUpList.Any(x => x.GraduateCardNo == newStudent.GraduateCardNo))
  1936. {
  1937. var newGraduateCardNoVerify = newGraduateCardNoList.Where(x => x.UserID != userVerify.UserID
  1938. && x.GraduateCardNo == newStudent.GraduateCardNo).ToList();
  1939. if (newGraduateCardNoVerify != null && newGraduateCardNoVerify.Count() > 0)
  1940. {
  1941. errCount++;
  1942. errorMsgStr = "毕结业证书编号已存在(与其它学生冲突),请检查";
  1943. en.ErrorMessage = errorMsgStr;
  1944. errList.Add(en);
  1945. errorMsg.AppendLine(errorMsgStr);
  1946. continue;
  1947. }
  1948. }
  1949. else
  1950. {
  1951. errCount++;
  1952. errorMsgStr = "毕结业证书编号重复(Excel中),请检查";
  1953. en.ErrorMessage = errorMsgStr;
  1954. errList.Add(en);
  1955. errorMsg.AppendLine(errorMsgStr);
  1956. continue;
  1957. }
  1958. }
  1959. else
  1960. {
  1961. errCount++;
  1962. errorMsgStr = "毕结业证书编号重复(Excel中),请检查";
  1963. en.ErrorMessage = errorMsgStr;
  1964. errList.Add(en);
  1965. errorMsg.AppendLine(errorMsgStr);
  1966. continue;
  1967. }
  1968. }
  1969. studentVerify.Sys_User.LoginID = newUser.LoginID.Trim();
  1970. studentVerify.Sys_User.Name = newUser.Name.Trim();
  1971. this.SetModifyStatus(studentVerify.Sys_User);
  1972. newUserUpList.Add(studentVerify.Sys_User);
  1973. studentVerify.SexID = newStudent.SexID;
  1974. studentVerify.BirthDate = newStudent.BirthDate;
  1975. studentVerify.NationID = newStudent.NationID;
  1976. studentVerify.PoliticsID = newStudent.PoliticsID;
  1977. studentVerify.CertificatesType = newStudent.CertificatesType;
  1978. studentVerify.IDNumber = newStudent.IDNumber;
  1979. studentVerify.StudentType = newStudent.StudentType;
  1980. studentVerify.Sys_User.Sys_Role = new HashSet<Sys_Role>();
  1981. roleList = roleList.Where(x => x.CF_StudentRole.StudentType == newStudent.StudentType).ToList();
  1982. if (roleList != null && roleList.Count > 0)
  1983. {
  1984. roleList.ForEach(x => studentVerify.Sys_User.Sys_Role.Add(x));
  1985. }
  1986. else
  1987. {
  1988. //对应角色为空时,默认为不分配用户角色
  1989. }
  1990. studentVerify.StudentCardNo = newStudent.StudentCardNo;
  1991. studentVerify.GraduateCardNo = newStudent.GraduateCardNo;
  1992. studentVerify.DegreeStatus = newStudent.DegreeStatus;
  1993. studentVerify.Career = newStudent.Career;
  1994. studentVerify.Remark = newStudent.Remark;
  1995. this.SetModifyStatus(studentVerify);
  1996. newStudentUpList.Add(studentVerify);
  1997. if (studentVerify.CF_StudentProfile == null)
  1998. {
  1999. var studentProfile = new CF_StudentProfile();
  2000. studentProfile.UserID = studentVerify.UserID;
  2001. studentProfile.UsedName = newStudentProfile.UsedName;
  2002. studentProfile.LiteracyLevelID = newStudentProfile.LiteracyLevelID;
  2003. studentProfile.CultureModelID = newStudentProfile.CultureModelID;
  2004. studentProfile.IsDreamProject = newStudentProfile.IsDreamProject;
  2005. studentProfile.Country = newStudentProfile.Country;
  2006. studentProfile.Place = newStudentProfile.Place;
  2007. studentProfile.BornPlace = newStudentProfile.BornPlace;
  2008. studentProfile.HealthStateID = newStudentProfile.HealthStateID;
  2009. studentProfile.BloodGroup = newStudentProfile.BloodGroup;
  2010. studentProfile.Specialty = newStudentProfile.Specialty;
  2011. studentProfile.Height = newStudentProfile.Height;
  2012. studentProfile.Weight = newStudentProfile.Weight;
  2013. studentProfile.DirectorName = newStudentProfile.DirectorName;
  2014. this.SetNewStatus(studentProfile);
  2015. newStudentProfileInList.Add(studentProfile);
  2016. }
  2017. else
  2018. {
  2019. studentVerify.CF_StudentProfile.UsedName = newStudentProfile.UsedName;
  2020. studentVerify.CF_StudentProfile.LiteracyLevelID = newStudentProfile.LiteracyLevelID;
  2021. studentVerify.CF_StudentProfile.CultureModelID = newStudentProfile.CultureModelID;
  2022. studentVerify.CF_StudentProfile.IsDreamProject = newStudentProfile.IsDreamProject;
  2023. studentVerify.CF_StudentProfile.Country = newStudentProfile.Country;
  2024. studentVerify.CF_StudentProfile.Place = newStudentProfile.Place;
  2025. studentVerify.CF_StudentProfile.BornPlace = newStudentProfile.BornPlace;
  2026. studentVerify.CF_StudentProfile.HealthStateID = newStudentProfile.HealthStateID;
  2027. studentVerify.CF_StudentProfile.BloodGroup = newStudentProfile.BloodGroup;
  2028. studentVerify.CF_StudentProfile.Specialty = newStudentProfile.Specialty;
  2029. studentVerify.CF_StudentProfile.Height = newStudentProfile.Height;
  2030. studentVerify.CF_StudentProfile.Weight = newStudentProfile.Weight;
  2031. studentVerify.CF_StudentProfile.DirectorName = newStudentProfile.DirectorName;
  2032. this.SetModifyStatus(studentVerify.CF_StudentProfile);
  2033. newStudentProfileUpList.Add(studentVerify.CF_StudentProfile);
  2034. }
  2035. if (studentVerify.CF_StudentContact == null)
  2036. {
  2037. var studentContact = new CF_StudentContact();
  2038. studentContact.UserID = studentVerify.UserID;
  2039. studentContact.Email = newStudentContact.Email;
  2040. studentContact.Telephone = newStudentContact.Email;
  2041. studentContact.Mobile = newStudentContact.Email;
  2042. studentContact.ZIPCode = newStudentContact.ZIPCode;
  2043. studentContact.WeChatNum = newStudentContact.WeChatNum;
  2044. studentContact.QQ = newStudentContact.QQ;
  2045. studentContact.HomeAddress = newStudentContact.HomeAddress;
  2046. studentContact.WorkUnit = newStudentContact.WorkUnit;
  2047. studentContact.Address = newStudentContact.Address;
  2048. studentContact.Recipient = newStudentContact.Recipient;
  2049. studentContact.Dormitory = newStudentContact.Dormitory;
  2050. this.SetNewStatus(studentContact);
  2051. newStudentContactInList.Add(studentContact);
  2052. }
  2053. else
  2054. {
  2055. studentVerify.CF_StudentContact.Email = newStudentContact.Email;
  2056. studentVerify.CF_StudentContact.Telephone = newStudentContact.Telephone;
  2057. studentVerify.CF_StudentContact.Mobile = newStudentContact.Mobile;
  2058. studentVerify.CF_StudentContact.ZIPCode = newStudentContact.ZIPCode;
  2059. studentVerify.CF_StudentContact.WeChatNum = newStudentContact.WeChatNum;
  2060. studentVerify.CF_StudentContact.QQ = newStudentContact.QQ;
  2061. studentVerify.CF_StudentContact.HomeAddress = newStudentContact.HomeAddress;
  2062. studentVerify.CF_StudentContact.WorkUnit = newStudentContact.WorkUnit;
  2063. studentVerify.CF_StudentContact.Address = newStudentContact.Address;
  2064. studentVerify.CF_StudentContact.Recipient = newStudentContact.Recipient;
  2065. studentVerify.CF_StudentContact.Dormitory = newStudentContact.Dormitory;
  2066. this.SetModifyStatus(studentVerify.CF_StudentContact);
  2067. newStudentContactUpList.Add(studentVerify.CF_StudentContact);
  2068. }
  2069. if (studentVerify.CF_StudentAccount == null)
  2070. {
  2071. var studentAccount = new CF_StudentAccount();
  2072. studentAccount.UserID = studentVerify.UserID;
  2073. studentAccount.BankName = newStudentAccount.BankName;
  2074. studentAccount.CardNo = newStudentAccount.CardNo;
  2075. this.SetNewStatus(studentAccount);
  2076. newStudentAccountInList.Add(studentAccount);
  2077. }
  2078. else
  2079. {
  2080. studentVerify.CF_StudentAccount.BankName = newStudentAccount.BankName;
  2081. studentVerify.CF_StudentAccount.CardNo = newStudentAccount.CardNo;
  2082. this.SetModifyStatus(studentVerify.CF_StudentAccount);
  2083. newStudentAccountUpList.Add(studentVerify.CF_StudentAccount);
  2084. }
  2085. if (studentVerify.CF_Recruitstudents == null)
  2086. {
  2087. var recruitstudents = new CF_Recruitstudents();
  2088. recruitstudents.UserID = studentVerify.UserID;
  2089. recruitstudents.ExamineeNum = newRecruitstudents.ExamineeNum;
  2090. recruitstudents.AdmissionTicketNo = newRecruitstudents.AdmissionTicketNo;
  2091. recruitstudents.ExamineeType = newRecruitstudents.ExamineeType;
  2092. recruitstudents.EntranceDate = newRecruitstudents.EntranceDate;
  2093. recruitstudents.Score = newRecruitstudents.Score;
  2094. recruitstudents.EntranceWayID = newRecruitstudents.EntranceWayID;
  2095. recruitstudents.FeaturesID = newRecruitstudents.FeaturesID;
  2096. recruitstudents.TerritorialID = newRecruitstudents.TerritorialID;
  2097. recruitstudents.Area = newRecruitstudents.Area;
  2098. this.SetNewStatus(recruitstudents);
  2099. newRecruitstudentsInList.Add(recruitstudents);
  2100. }
  2101. else
  2102. {
  2103. studentVerify.CF_Recruitstudents.ExamineeNum = newRecruitstudents.ExamineeNum;
  2104. studentVerify.CF_Recruitstudents.AdmissionTicketNo = newRecruitstudents.AdmissionTicketNo;
  2105. studentVerify.CF_Recruitstudents.ExamineeType = newRecruitstudents.ExamineeType;
  2106. studentVerify.CF_Recruitstudents.EntranceDate = newRecruitstudents.EntranceDate;
  2107. studentVerify.CF_Recruitstudents.Score = newRecruitstudents.Score;
  2108. studentVerify.CF_Recruitstudents.EntranceWayID = newRecruitstudents.EntranceWayID;
  2109. studentVerify.CF_Recruitstudents.FeaturesID = newRecruitstudents.FeaturesID;
  2110. studentVerify.CF_Recruitstudents.TerritorialID = newRecruitstudents.TerritorialID;
  2111. studentVerify.CF_Recruitstudents.Area = newRecruitstudents.Area;
  2112. this.SetModifyStatus(studentVerify.CF_Recruitstudents);
  2113. newRecruitstudentsUpList.Add(studentVerify.CF_Recruitstudents);
  2114. }
  2115. upCount++;
  2116. }
  2117. }
  2118. }
  2119. TransactionOptions transactionOption = new TransactionOptions();
  2120. transactionOption.IsolationLevel = System.Transactions.IsolationLevel.Serializable;
  2121. transactionOption.Timeout = new TimeSpan(0, 3, 0);
  2122. using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, transactionOption))
  2123. {
  2124. UnitOfWork.BulkInsert<Sys_User>(newUserInList);
  2125. UnitOfWork.BulkInsert(newUserInList, (x => x.Sys_Role));
  2126. UnitOfWork.BulkInsert<CF_Student>(newStudentInList);
  2127. UnitOfWork.BulkInsert<CF_StudentProfile>(newStudentProfileInList);
  2128. UnitOfWork.BulkInsert<CF_StudentContact>(newStudentContactInList);
  2129. UnitOfWork.BulkInsert<CF_StudentAccount>(newStudentAccountInList);
  2130. UnitOfWork.BulkInsert<CF_Recruitstudents>(newRecruitstudentsInList);
  2131. if (newUserUpList != null && newUserUpList.Count() > 0)
  2132. {
  2133. UnitOfWork.BatchUpdate(newUserUpList);
  2134. }
  2135. if (newStudentUpList != null && newStudentUpList.Count() > 0)
  2136. {
  2137. UnitOfWork.BatchUpdate(newStudentUpList);
  2138. }
  2139. if (newStudentProfileUpList != null && newStudentProfileUpList.Count() > 0)
  2140. {
  2141. UnitOfWork.BatchUpdate(newStudentProfileUpList);
  2142. }
  2143. if (newStudentContactUpList != null && newStudentContactUpList.Count() > 0)
  2144. {
  2145. UnitOfWork.BatchUpdate(newStudentContactUpList);
  2146. }
  2147. if (newStudentAccountUpList != null && newStudentAccountUpList.Count() > 0)
  2148. {
  2149. UnitOfWork.BatchUpdate(newStudentAccountUpList);
  2150. }
  2151. if (newRecruitstudentsUpList != null && newRecruitstudentsUpList.Count() > 0)
  2152. {
  2153. UnitOfWork.BatchUpdate(newRecruitstudentsUpList);
  2154. }
  2155. ts.Complete();
  2156. }
  2157. errdataList = errList.Distinct().ToList(); //错误列表List
  2158. }
  2159. catch (Exception)
  2160. {
  2161. throw;
  2162. }
  2163. }
  2164. }
  2165. }