StudentsServices.cs 110 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Bowin.Common;
  6. using Bowin.Common.Linq;
  7. using Bowin.Common.Linq.Entity;
  8. using EMIS.DataLogic.Repositories;
  9. using System.Linq.Expressions;
  10. using EMIS.Entities;
  11. using EMIS.DataLogic.SystemDAL;
  12. using EMIS.ViewModel.Students;
  13. using EMIS.ViewModel.SystemView;
  14. using EMIS.Utility;
  15. using EMIS.DataLogic.Common.AdministrativeOrgan;
  16. using EMIS.DataLogic.Common.Students;
  17. using EMIS.ViewModel;
  18. using System.Data;
  19. using EMIS.ViewModel.Cache;
  20. using System.IO;
  21. using System.Text.RegularExpressions;
  22. using Bowin.Common.Utility;
  23. using Bowin.Common.DataTime;
  24. using System.Globalization;
  25. using EMIS.CommonLogic.CalendarManage;
  26. using EMIS.Utility.FormValidate;
  27. using System.Web;
  28. using System.Transactions;
  29. using EMIS.DataLogic;
  30. using System.Data.OleDb;
  31. using EMIS.DataLogic.ExaminationApply;
  32. namespace EMIS.CommonLogic.Students
  33. {
  34. public class StudentsServices : BaseServices, IStudentsServices
  35. {
  36. public Lazy<StudentsDAL> StudentsDAL { get; set; }
  37. public Lazy<RoleDAL> RoleDAL { get; set; }
  38. public Lazy<InSchoolSettingRepository> InSchoolSettingRepository { get; set; }
  39. public Lazy<StudentProfileRepository> StudentProfileRepository { get; set; }
  40. public Lazy<StudentContactRepository> StudentContactRepository { get; set; }
  41. public Lazy<UserRepository> UserRepository { get; set; }
  42. public Lazy<RecruitstudentsRepository> RecruitstudentsRepository { get; set; }
  43. public Lazy<StudentAccountRepository> StudentAccountRepository { get; set; }
  44. public Lazy<ClassmajorRepository> ClassmajorRepository { get; set; }
  45. public Lazy<SchoolyearRepository> SchoolyearRepository { get; set; }
  46. public Lazy<ISchoolYearServices> SchoolYearServices { get; set; }
  47. public ParameterDAL ParameterDAL { get; set; }
  48. public InSchoolStatusSettingDAL InSchoolStatusSettingDAL { get; set; }
  49. public DataRangeDAL DataRangeDAL { get; set; }
  50. public ExaminationSubjectDAL ExaminationSubjectDAL { get; set; }
  51. public AnnouncementDAL AnnouncementDAL { get; set; }
  52. /// <summary>
  53. /// 查询列表
  54. /// </summary>
  55. /// <param name="configuretView"></param>
  56. /// <param name="campusID">校区ID</param>
  57. /// <param name="collegeID">院系所ID</param>
  58. /// <param name="educationID">培养层次ID</param>
  59. /// <param name="years">学年</param>
  60. /// <param name="standardID">招生专业ID</param>
  61. /// <param name="learnFormID">学习形式ID</param>
  62. /// <param name="classMajorID">班级ID</param>
  63. /// <param name="Shoolstatu">在校状态ID</param>
  64. /// <param name="isPhotos">是否有照片</param>
  65. /// <param name="graduationtmentDropdown">是否毕业学生</param>
  66. /// <param name="pageIndex"></param>
  67. /// <param name="pageSize"></param>
  68. /// <returns></returns>
  69. public Bowin.Common.Linq.Entity.IGridResultSet<StudentsView> GetStudentUserViewList(ViewModel.ConfiguretView configuretView,
  70. int? campusID, Guid? collegeID, int? years, int? standardID, int? learningformID, Guid? classmajorID, int? IsGraduation, int? inSchoolStatusID, int? isPhotos, int? isDream, string planningGraduateDate, string LearnSystem,int? education,int? reportStatusID, int pageIndex, int pageSize)
  71. {
  72. Expression<Func<CF_Student, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  73. Expression<Func<CF_Classmajor, bool>> classexp = (x => true);
  74. Expression<Func<CF_Grademajor, bool>> gradeexp = (x => true);
  75. if (isPhotos.HasValue)
  76. {
  77. if (isPhotos.Value == (int)CF_GeneralPurpose.IsYes)
  78. {
  79. exp = exp.And(x => x.PhotoUrl != null);
  80. }
  81. else
  82. {
  83. exp = exp.And(x => x.PhotoUrl == null);
  84. }
  85. }
  86. if (campusID.HasValue)
  87. gradeexp = gradeexp.And(x => x.SchoolAreaID == campusID);
  88. if (collegeID.HasValue)
  89. gradeexp = gradeexp.And(x => x.CF_Facultymajor.CollegeID == collegeID);
  90. if (years.HasValue)
  91. gradeexp = gradeexp.And(x => x.SchoolyearID == years);
  92. if (standardID.HasValue)
  93. gradeexp = gradeexp.And(x => x.CF_Facultymajor.StandardID == standardID);
  94. if (learningformID.HasValue)
  95. gradeexp = gradeexp.And(x => x.CF_Facultymajor.LearningformID == learningformID);
  96. if (classmajorID.HasValue)
  97. exp = exp.And(x => x.ClassmajorID == classmajorID);
  98. if (inSchoolStatusID.HasValue)
  99. exp = exp.And(x => x.InSchoolStatusID == inSchoolStatusID);
  100. if (IsGraduation.HasValue)
  101. {
  102. if (IsGraduation != (int)EMIS.ViewModel.CF_GeneralPurpose.IsYes)
  103. exp = exp.And(x => x.StudentStatus != (int)EMIS.ViewModel.CF_STUDENTSTATUS.Graduation);
  104. else
  105. exp = exp.And(x => x.StudentStatus == (int)EMIS.ViewModel.CF_STUDENTSTATUS.Graduation);
  106. }
  107. if(isDream.HasValue){
  108. if(isDream.Value==(int)CF_GeneralPurpose.IsYes){
  109. exp = exp.And(x => x.IsDreamProject != null);
  110. }
  111. else
  112. {
  113. exp=exp.And(x=>x.IsDreamProject==null);
  114. }
  115. }
  116. if (planningGraduateDate != "" && !String.IsNullOrEmpty(planningGraduateDate) && planningGraduateDate != "-1")
  117. {
  118. //DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
  119. //dtFormat.ShortDatePattern = "yyyyMMdd";
  120. DateTime date = DateTime.ParseExact(planningGraduateDate, "yyyyMMdd", CultureInfo.CurrentCulture);
  121. //string datestr = date.ToString("u");
  122. //dtFormat.ShortDatePattern = "yyyy-MM-dd";
  123. //dtFormat.DateSeparator = "-";
  124. //DateTime dates = Convert.ToDateTime(datestr, dtFormat);
  125. exp = exp.And(x => DateTime.Compare((DateTime)x.PlanningGraduateDate, date) == 0);
  126. }
  127. if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
  128. {
  129. var LearnSystems = Convert.ToDecimal(LearnSystem);
  130. exp = exp.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
  131. }
  132. if (education.HasValue)
  133. {
  134. exp = exp.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value);
  135. }
  136. var query = StudentsDAL.Value.GetStudentQueryable(exp, classexp, gradeexp);
  137. if (reportStatusID.HasValue)
  138. {
  139. query = query.Where(x => x.ReportStatusID == reportStatusID);
  140. }
  141. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  142. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  143. return this.GetQueryByAssistant(query, (x => x.ClassMajorID), this.GetQueryByDataRangeByCollege(query)).OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  144. .ThenBy(x => x.ClassMajorCode).ThenBy(x => x.LoginID).ToGridResultSet<StudentsView>(pageIndex, pageSize);
  145. }
  146. public IList<StudentsView> GetStudentViewList(ViewModel.ConfiguretView configuretView,
  147. int? campusID, Guid? collegeID, int? years, int? standardID, int? learningformID, Guid? classmajorID, int? IsGraduation, int? inSchoolStatusID, int? isPhotos, int? isDream, string planningGraduateDate, string LearnSystem, int? education, int? reportStatusID, List<Guid?> UserIDsIDList)
  148. {
  149. Expression<Func<CF_Student, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  150. Expression<Func<CF_Classmajor, bool>> classexp = (x => true);
  151. Expression<Func<CF_Grademajor, bool>> gradeexp = (x => true);
  152. if (UserIDsIDList != null)
  153. {
  154. exp = exp.And(x => UserIDsIDList.Contains(x.UserID));
  155. }
  156. else
  157. {
  158. if (isPhotos.HasValue)
  159. {
  160. if (isPhotos.Value == (int)CF_GeneralPurpose.IsYes)
  161. {
  162. exp = exp.And(x => x.PhotoUrl != null);
  163. }
  164. else
  165. {
  166. exp = exp.And(x => x.PhotoUrl == null);
  167. }
  168. }
  169. if (campusID.HasValue)
  170. gradeexp = gradeexp.And(x => x.SchoolAreaID == campusID);
  171. if (collegeID.HasValue)
  172. gradeexp = gradeexp.And(x => x.CF_Facultymajor.CollegeID == collegeID);
  173. if (years.HasValue)
  174. gradeexp = gradeexp.And(x => x.SchoolyearID == years);
  175. if (standardID.HasValue)
  176. gradeexp = gradeexp.And(x => x.CF_Facultymajor.StandardID == standardID);
  177. if (learningformID.HasValue)
  178. gradeexp = gradeexp.And(x => x.CF_Facultymajor.LearningformID == learningformID);
  179. if (classmajorID.HasValue)
  180. exp = exp.And(x => x.ClassmajorID == classmajorID);
  181. if (inSchoolStatusID.HasValue)
  182. exp = exp.And(x => x.InSchoolStatusID == inSchoolStatusID);
  183. if (IsGraduation.HasValue)
  184. {
  185. if (IsGraduation != (int)EMIS.ViewModel.CF_STUDENTSTATUS.Graduation)
  186. exp = exp.And(x => x.StudentStatus != (int)EMIS.ViewModel.CF_STUDENTSTATUS.Graduation);
  187. else
  188. exp = exp.And(x => x.StudentStatus == (int)EMIS.ViewModel.CF_STUDENTSTATUS.Graduation);
  189. }
  190. if (isDream.HasValue)
  191. {
  192. if (isDream.Value == (int)CF_GeneralPurpose.IsYes)
  193. {
  194. exp = exp.And(x => x.IsDreamProject != null);
  195. }
  196. else
  197. {
  198. exp = exp.And(x => x.IsDreamProject == null);
  199. }
  200. }
  201. if (planningGraduateDate != "" && !String.IsNullOrEmpty(planningGraduateDate) && planningGraduateDate != "-1")
  202. {
  203. //DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
  204. //dtFormat.ShortDatePattern = "yyyyMMdd";
  205. DateTime date = DateTime.ParseExact(planningGraduateDate, "yyyyMMdd", CultureInfo.CurrentCulture);
  206. //string datestr = date.ToString("u");
  207. //dtFormat.ShortDatePattern = "yyyy-MM-dd";
  208. //dtFormat.DateSeparator = "-";
  209. //DateTime dates = Convert.ToDateTime(datestr, dtFormat);
  210. exp = exp.And(x => DateTime.Compare((DateTime)x.PlanningGraduateDate, date) == 0);
  211. }
  212. if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
  213. {
  214. var LearnSystems = Convert.ToDecimal(LearnSystem);
  215. exp = exp.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
  216. }
  217. if (education.HasValue)
  218. {
  219. exp = exp.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value);
  220. }
  221. }
  222. var query = StudentsDAL.Value.GetStudentQueryable(exp, classexp, gradeexp);
  223. if (reportStatusID.HasValue)
  224. {
  225. query = query.Where(x => x.ReportStatusID == reportStatusID);
  226. }
  227. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  228. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  229. return this.GetQueryByAssistant(query, (x => x.ClassMajorID), this.GetQueryByDataRangeByCollege(query)).OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  230. .ThenBy(x => x.ClassMajorCode).ThenBy(x => x.LoginID).ToList();
  231. }
  232. /// <summary>
  233. /// 导出excel和dbf
  234. /// </summary>
  235. /// <param name="configuretView"></param>
  236. /// <param name="campusID"></param>
  237. /// <param name="collegeID"></param>
  238. /// <param name="years"></param>
  239. /// <param name="standardID"></param>
  240. /// <param name="learningformID"></param>
  241. /// <param name="classmajorID"></param>
  242. /// <param name="IsGraduation"></param>
  243. /// <param name="inSchoolStatusID"></param>
  244. /// <param name="isPhotos"></param>
  245. /// <param name="isDream"></param>
  246. /// <param name="planningGraduateDate"></param>
  247. /// <param name="LearnSystem"></param>
  248. /// <param name="education"></param>
  249. /// <param name="reportStatusID"></param>
  250. /// <returns></returns>
  251. public IList<StudentsView> GetStudentExportList(ViewModel.ConfiguretView configuretView,
  252. int? campusID, Guid? collegeID, int? years, int? standardID, int? learningformID, Guid? classmajorID, int? IsGraduation, int? inSchoolStatusID, int? isPhotos, int? isDream, string planningGraduateDate, string LearnSystem, int? education, int? reportStatusID)
  253. {
  254. Expression<Func<CF_Student, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  255. Expression<Func<CF_Classmajor, bool>> classexp = (x => true);
  256. Expression<Func<CF_Grademajor, bool>> gradeexp = (x => true);
  257. if (isPhotos.HasValue)
  258. {
  259. if (isPhotos.Value == (int)CF_GeneralPurpose.IsYes)
  260. {
  261. exp = exp.And(x => x.PhotoUrl != null);
  262. }
  263. else
  264. {
  265. exp = exp.And(x => x.PhotoUrl == null);
  266. }
  267. }
  268. if (campusID.HasValue)
  269. gradeexp = gradeexp.And(x => x.SchoolAreaID == campusID);
  270. if (collegeID.HasValue)
  271. gradeexp = gradeexp.And(x => x.CF_Facultymajor.CollegeID == collegeID);
  272. if (years.HasValue)
  273. gradeexp = gradeexp.And(x => x.SchoolyearID == years);
  274. if (standardID.HasValue)
  275. gradeexp = gradeexp.And(x => x.CF_Facultymajor.StandardID == standardID);
  276. if (learningformID.HasValue)
  277. gradeexp = gradeexp.And(x => x.CF_Facultymajor.LearningformID == learningformID);
  278. if (classmajorID.HasValue)
  279. exp = exp.And(x => x.ClassmajorID == classmajorID);
  280. if (inSchoolStatusID.HasValue)
  281. exp = exp.And(x => x.InSchoolStatusID == inSchoolStatusID);
  282. if (IsGraduation.HasValue)
  283. {
  284. if (IsGraduation != (int)EMIS.ViewModel.CF_STUDENTSTATUS.Graduation)
  285. exp = exp.And(x => x.StudentStatus != (int)EMIS.ViewModel.CF_STUDENTSTATUS.Graduation);
  286. else
  287. exp = exp.And(x => x.StudentStatus == (int)EMIS.ViewModel.CF_STUDENTSTATUS.Graduation);
  288. }
  289. if (isDream.HasValue)
  290. {
  291. if (isDream.Value == (int)CF_GeneralPurpose.IsYes)
  292. {
  293. exp = exp.And(x => x.IsDreamProject != null);
  294. }
  295. else
  296. {
  297. exp = exp.And(x => x.IsDreamProject == null);
  298. }
  299. }
  300. if (planningGraduateDate != "" && !String.IsNullOrEmpty(planningGraduateDate) && planningGraduateDate != "-1")
  301. {
  302. //DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
  303. //dtFormat.ShortDatePattern = "yyyyMMdd";
  304. DateTime date = DateTime.ParseExact(planningGraduateDate, "yyyyMMdd", CultureInfo.CurrentCulture);
  305. //string datestr = date.ToString("u");
  306. //dtFormat.ShortDatePattern = "yyyy-MM-dd";
  307. //dtFormat.DateSeparator = "-";
  308. //DateTime dates = Convert.ToDateTime(datestr, dtFormat);
  309. exp = exp.And(x => DateTime.Compare((DateTime)x.PlanningGraduateDate, date) == 0);
  310. }
  311. if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1")
  312. {
  313. var LearnSystems = Convert.ToDecimal(LearnSystem);
  314. exp = exp.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems);
  315. }
  316. if (education.HasValue)
  317. {
  318. exp = exp.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value);
  319. }
  320. var query = StudentsDAL.Value.GetStudentForExcel(exp, classexp, gradeexp);
  321. if (reportStatusID.HasValue)
  322. {
  323. query = query.Where(x => x.ReportStatusID == reportStatusID);
  324. }
  325. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  326. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  327. return this.GetQueryByAssistant(query, (x => x.ClassMajorID), this.GetQueryByDataRangeByCollege(query)).OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  328. .ThenBy(x => x.ClassMajorCode).ThenBy(x => x.LoginID).ToList();
  329. }
  330. /// <summary>
  331. /// 将数据表写入到DBF文件中
  332. /// </summary>
  333. /// <param name="dt"></param>
  334. public void WriteToDbf(DataTable dt, List<string> colList)
  335. {
  336. //连接字符串
  337. string sConn =
  338. "Provider=Microsoft.Jet.OLEDB.4.0; " +
  339. "Data Source=" + System.IO.Directory.GetCurrentDirectory() + "; " +
  340. "Extended Properties=dBASE IV;";
  341. OleDbConnection conn = new OleDbConnection(sConn);
  342. conn.Open();
  343. try
  344. {
  345. //如果存在同名文件则先删除
  346. if (File.Exists(dt.TableName + ".dbf"))
  347. {
  348. File.Delete(dt.TableName + ".dbf");
  349. }
  350. OleDbCommand cmd;
  351. //建立新表
  352. StringBuilder sbCreate = new StringBuilder();
  353. sbCreate.Append("CREATE TABLE " + dt.TableName + ".dbf (");
  354. for (int i = 0; i < colList.Count; i++)
  355. {
  356. sbCreate.Append(colList[i]);
  357. sbCreate.Append(" char(25)");
  358. if (i != colList.Count - 1)
  359. {
  360. sbCreate.Append(", ");
  361. }
  362. else
  363. {
  364. sbCreate.Append(')');
  365. }
  366. }
  367. cmd = new OleDbCommand(sbCreate.ToString(), conn);
  368. cmd.ExecuteNonQuery();
  369. //插入各行
  370. StringBuilder sbInsert = new StringBuilder();
  371. foreach (DataRow dr in dt.Rows)
  372. {
  373. sbInsert.Clear();
  374. sbInsert.Append("INSERT INTO " + dt.TableName + ".dbf (");
  375. for (int i = 0; i < colList.Count; i++)
  376. {
  377. sbInsert.Append(colList[i]);
  378. if (i != colList.Count - 1)
  379. {
  380. sbInsert.Append(", ");
  381. }
  382. }
  383. sbInsert.Append(") VALUES (");
  384. for (int i = 0; i < dt.Columns.Count; i++)
  385. {
  386. sbInsert.Append("'" + dr[i].ToString() + "'");
  387. if (i != dt.Columns.Count - 1)
  388. {
  389. sbInsert.Append(", ");
  390. }
  391. }
  392. sbInsert.Append(')');
  393. cmd = new OleDbCommand(sbInsert.ToString(), conn);
  394. cmd.ExecuteNonQuery();
  395. }
  396. }
  397. catch (Exception ex)
  398. {
  399. throw ex;
  400. }
  401. conn.Close();
  402. //var physicalPath = System.IO.Directory.GetCurrentDirectory() + "\\" + dt.TableName + ".dbf";
  403. //FileInfo finfo = new FileInfo(physicalPath);
  404. //return finfo;
  405. }
  406. public IList<StudentsView> GetStudentViewListByIDList(IList<Guid?> studentUserIDList)
  407. {
  408. return StudentsDAL.Value.GetStudentQueryable(x => studentUserIDList.Contains(x.UserID)).ToList();
  409. }
  410. /// <summary>
  411. /// 获取可进行异动申请的学生。
  412. /// </summary>
  413. /// <returns></returns>
  414. public IGridResultSet<StudentsView> GetAbleDifferentDynamicApplyStudentList(ConfiguretView configuretView, int pageIndex, int pageSize)
  415. {
  416. Expression<Func<CF_Student, bool>> filter = w => w.RecordStatus > (int)SYS_STATUS.UNUSABLE;
  417. //为何和学籍状态有关?
  418. //var studentStatus = new[]
  419. //{
  420. // (int?)CF_STUDENTSTATUS.Whodid,
  421. // (int?)CF_STUDENTSTATUS.Thegraduation,
  422. // (int?)CF_STUDENTSTATUS.Graduation
  423. //};
  424. //filter = filter.And(w => !studentStatus.Contains(w.StudentStatus));
  425. //2016年10月13日14:53:40
  426. //PS:异动申请,新增异动的时候,这个异动权限要放开。现在只有在校生能学籍异动,非在校生也能异动才行。【相当于权限放开,可以添加任何在校状态的学生】
  427. // var inSchoolStatusIDs = InSchoolSettingRepository.Value.GetList(w => w.IsSelected == true).Select(s => s.InSchoolStatusID).ToArray();
  428. //filter = filter.And(w => inSchoolStatusIDs.Contains(w.InSchoolStatusID));
  429. var query = StudentsDAL.Value.GetStudentQueryable(filter);
  430. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  431. {
  432. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  433. }
  434. query = this.GetQueryByAssistant(query, (x => x.ClassMajorID), this.GetQueryByDataRangeByCollege(query)).OrderByDescending(x => x.LoginID);
  435. return query.ToGridResultSet(pageIndex, pageSize);
  436. }
  437. /// <summary>
  438. /// 查询用户ID
  439. /// </summary>
  440. /// <param name="userId"></param>
  441. /// <returns></returns>
  442. public StudentsView GetStudentfileView(Guid? userId)
  443. {
  444. //查询条件
  445. var query = StudentsDAL.Value.GetStudentQueryable(x => x.UserID == userId);
  446. //if (userId.HasValue)
  447. // query = query.Where(x => x.UserID == userId);
  448. return query.FirstOrDefault();
  449. }
  450. /// <summary>
  451. /// 添加
  452. /// </summary>
  453. /// <param name="studentfileView"></param>
  454. public void Save(StudentsView studentfileView)
  455. {
  456. BaseStudentView tempView = StudentsDAL.Value.GetBaseStudentViewQueryable(x => x.Sys_User.UserID == studentfileView.UserID).FirstOrDefault();
  457. var parameter = ParameterDAL.ParameterRepository.GetSingle(x => x.ParameterTypeID == (int)ViewModel.CF_ParameterType.StudentInitPassword);
  458. var roleList = RoleDAL.Value.RoleRepository.GetList(x => x.TypeID == (int)SYS_RoleType.Student && x.CF_StudentRole.StudentType == studentfileView.StudentType,(x=>x.CF_StudentRole)).ToList();
  459. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringMonth == null)
  460. throw new Exception("请先设置配置文件的预计毕业月份(春季入学)。");
  461. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringDay == null)
  462. throw new Exception("请先设置配置文件的预计毕业日期(春季入学)。");
  463. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnMonth == null)
  464. throw new Exception("请先设置配置文件的预计毕业月份(秋季入学)。");
  465. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnDay == null)
  466. throw new Exception("请先设置配置文件的预计毕业日期(秋季入学)。");
  467. if (studentfileView.GradeMajorID==null)
  468. {
  469. var GradeMajorID=ClassmajorRepository.Value.Entities.Where(x => x.ClassmajorID == (Guid)studentfileView.ClassMajorID).Select(w => w.GrademajorID).FirstOrDefault();
  470. studentfileView.GradeMajorID = (Guid)GradeMajorID;
  471. }
  472. //studentfileView.PlanningGraduateDate = Convert.ToDateTime(GetPlanningGraduate((Guid)studentfileView.GradeMajorID));
  473. SaveOrUpdateInternal(studentfileView, tempView, parameter, roleList);
  474. this.UnitOfWork.Commit();
  475. }
  476. public void StudentDelete(List<Guid> userIDs)
  477. {
  478. try
  479. {
  480. var registrationList = ExaminationSubjectDAL.examinationRegistrationRepository.GetList(x => userIDs.Contains(x.UserID.Value)).ToList();
  481. if (registrationList != null && registrationList.Count() > 0)
  482. {
  483. throw new Exception("要删除的学生中存在已报名的数据,无法删除");
  484. }
  485. else
  486. {
  487. //List<Guid> dbuserID = new List<Guid>();
  488. using (TransactionScope ts = new TransactionScope())
  489. {
  490. var announcementList = AnnouncementDAL.AnnouncementRepository.GetList(x => x.Sys_User.Any(y => userIDs.Contains(y.UserID)), (x => x.Sys_Role), (x => x.Sys_User)).ToList();
  491. announcementList.ForEach(x => {
  492. x.Sys_User.RemoveWhere(y => userIDs.Contains(y.UserID));
  493. });
  494. UnitOfWork.Commit();
  495. //UnitOfWork.BatchUpdate
  496. UnitOfWork.Remove<CF_StudentContact>(x => userIDs.Contains(x.UserID));
  497. UnitOfWork.Remove<CF_StudentAccount>(x => userIDs.Contains(x.UserID));
  498. UnitOfWork.Remove<CF_Recruitstudents>(x => userIDs.Contains(x.UserID));
  499. UnitOfWork.Remove<CF_StudentProfile>(x => userIDs.Contains(x.UserID));
  500. UnitOfWork.Remove<CF_Student>(x => userIDs.Contains(x.UserID));
  501. var userList = this.UserRepository.Value.GetList(x => userIDs.Contains(x.UserID), (x => x.Sys_Role)).ToList();
  502. userList.ForEach(x => x.Sys_Role = new HashSet<Sys_Role>());
  503. UnitOfWork.Remove<Sys_User>(x => userIDs.Contains(x.UserID));
  504. UnitOfWork.Commit();
  505. ts.Complete();
  506. }
  507. }
  508. }
  509. catch (Exception)
  510. {
  511. throw;
  512. }
  513. }
  514. /// <summary>
  515. /// 获取信息
  516. /// </summary>
  517. /// <param name="userID">用户ID</param>
  518. /// <returns></returns>
  519. public Entities.Sys_User GetUser(Guid? userID)
  520. {
  521. //查询条件
  522. Expression<Func<Sys_User, bool>> expression = x => x.UserID == userID;
  523. return UserRepository.Value.GetSingle(expression, (x => x.Sys_Role));
  524. }
  525. /// <summary>
  526. /// 获取学生扩展表信息
  527. /// </summary>
  528. /// <param name="userID">用户ID</param>
  529. /// <returns></returns>
  530. public Entities.CF_StudentProfile GetProfile(Guid? userID)
  531. {
  532. //查询条件
  533. Expression<Func<CF_StudentProfile, bool>> expression = x => x.UserID == userID;
  534. return StudentProfileRepository.Value.GetSingle(expression);
  535. }
  536. /// <summary>
  537. /// 获取学生信息
  538. /// </summary>
  539. /// <param name="userID">用户ID</param>
  540. /// <returns></returns>
  541. public Entities.CF_Student GetStudent(Guid? userID)
  542. {
  543. //查询条件
  544. Expression<Func<CF_Student, bool>> expression = x => x.UserID == userID;
  545. return StudentsDAL.Value.StudentRepository.GetSingle(expression);
  546. }
  547. /// <summary>
  548. /// 高考招生表
  549. /// </summary>
  550. /// <param name="userID">用户ID</param>
  551. /// <returns></returns>
  552. public Entities.CF_Recruitstudents GetRecruit(Guid? userID)
  553. {
  554. //查询条件
  555. Expression<Func<CF_Recruitstudents, bool>> expression = x => x.UserID == userID;
  556. return RecruitstudentsRepository.Value.GetSingle(expression);
  557. }
  558. /// <summary>
  559. /// 学生缴费表
  560. /// </summary>
  561. /// <param name="userID">用户ID</param>
  562. /// <returns></returns>
  563. public Entities.CF_StudentAccount GetAccount(Guid? userID)
  564. {
  565. //查询条件
  566. Expression<Func<CF_StudentAccount, bool>> expression = x => x.UserID == userID;
  567. return StudentAccountRepository.Value.GetSingle(expression);
  568. }
  569. /// <summary>
  570. /// 学生联系表
  571. /// </summary>
  572. /// <param name="userID">用户ID</param>
  573. /// <returns></returns>
  574. public Entities.CF_StudentContact GetContact(Guid? userID)
  575. {
  576. //查询条件
  577. Expression<Func<CF_StudentContact, bool>> expression = x => x.UserID == userID;
  578. return StudentContactRepository.Value.GetSingle(expression);
  579. }
  580. /// <summary>
  581. /// 获取学生表列表信息
  582. /// </summary>
  583. /// <returns></returns>
  584. public Entities.CF_Student GetStudenter(Guid? userID)
  585. {
  586. //查询条件
  587. Expression<Func<CF_Student, bool>> expression = x => x.UserID == userID;
  588. return StudentsDAL.Value.StudentRepository.GetSingle(expression);
  589. }
  590. public CF_Student GetReplaceGraduateNo(string ReplaceGraduateNo,Guid? userID)
  591. {
  592. //查询条件
  593. Expression<Func<CF_Student, bool>> expression = x => x.ReplaceGraduateNo == ReplaceGraduateNo;
  594. expression=expression.And(x => x.UserID != userID);
  595. return StudentsDAL.Value.StudentRepository.GetSingle(expression);
  596. }
  597. public Entities.Sys_User GetUserByLoginID(Guid userid)
  598. {
  599. Expression<Func<Sys_User, bool>> user = p => p.UserID == userid;
  600. return UserRepository.Value.GetSingle(user);
  601. }
  602. private void SaveOrUpdate(params StudentsView[] studentsViews)
  603. {
  604. var IDNumberList = studentsViews.Select(x => x.IDNumber.Trim().ToLower().Replace(")", ")").Replace("(", "(")).ToList();
  605. var existsStudentViewList = StudentsDAL.Value.StudentRepository.GetList(x => IDNumberList.Contains(x.IDNumber.Trim().ToLower().Replace(")", ")").Replace("(", "(")) || IDNumberList.Contains(x.Sys_User.LoginID.Trim().ToLower().Replace(")", ")").Replace("(", "(")),
  606. (x => x.Sys_User.Sys_Role),
  607. (x => x.CF_StudentProfile),
  608. (x => x.CF_StudentContact),
  609. (x => x.CF_StudentAccount),
  610. (x => x.CF_Recruitstudents)).ToList();
  611. var existsStudentList = existsStudentViewList.Select(x=>x.IDNumber.Trim().ToLower().Replace(")", ")").Replace("(", "(")).ToList();
  612. var addStudentsViews = studentsViews.Where(x => !existsStudentList.Contains(x.IDNumber.Trim().ToLower().Replace(")", ")").Replace("(", "("))).ToList();
  613. var parameter = ParameterDAL.ParameterRepository.GetSingle(x => x.ParameterTypeID == (int)ViewModel.CF_ParameterType.StudentInitPassword);
  614. var roleList = RoleDAL.Value.RoleRepository.GetList(x => x.TypeID == (int)SYS_RoleType.Student, (x => x.CF_StudentRole)).ToList();
  615. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringMonth == null)
  616. throw new Exception("请先设置配置文件的预计毕业月份(春季入学)。");
  617. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringDay == null)
  618. throw new Exception("请先设置配置文件的预计毕业日期(春季入学)。");
  619. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnMonth == null)
  620. throw new Exception("请先设置配置文件的预计毕业月份(秋季入学)。");
  621. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnDay == null)
  622. throw new Exception("请先设置配置文件的预计毕业日期(秋季入学)。");
  623. SaveInternalForImport(addStudentsViews, null, parameter, roleList);
  624. UnitOfWork.Delete(existsStudentViewList.Select(x => x.Sys_User).ToList(), (x => x.Sys_Role));
  625. foreach (var item in studentsViews)
  626. {
  627. var student = existsStudentViewList.FirstOrDefault(x => x.IDNumber == item.IDNumber);
  628. if (student != null)
  629. {
  630. UpdateInternalForImport(item, student, parameter, roleList);
  631. student.Sys_User.LoginID = item.IDNumber;
  632. }
  633. }
  634. UnitOfWork.BatchUpdate(existsStudentViewList.Select(x => x.Sys_User).ToList());
  635. UnitOfWork.BatchUpdate(existsStudentViewList);
  636. UnitOfWork.BatchUpdate(existsStudentViewList.Select(x => x.CF_StudentProfile).ToList());
  637. UnitOfWork.BatchUpdate(existsStudentViewList.Select(x => x.CF_StudentContact).ToList());
  638. UnitOfWork.BatchUpdate(existsStudentViewList.Select(x => x.CF_StudentAccount).ToList());
  639. UnitOfWork.BatchUpdate(existsStudentViewList.Select(x => x.CF_Recruitstudents).ToList());
  640. UnitOfWork.BulkInsert(existsStudentViewList.Select(x => x.Sys_User).ToList(), (x => x.Sys_Role));
  641. //UnitOfWork.Commit();
  642. }
  643. public DataTable Import(DataTable dataSource)
  644. {
  645. var errorSource = dataSource.Clone();
  646. errorSource.Columns.Add("错误信息");
  647. //添加错误并且排除必填字段为空的记录行
  648. var errorList = AddErrorAndExceptEmptyDataRow(dataSource);
  649. //添加错误并且排除重复的记录行
  650. errorList.AddRange(AddErrorAndExceptRepetitiveDataRow(dataSource));
  651. //现改为可重复导入学生,并以学号关键字修改学生相关信息表,因此注释掉排除重复学号方法:邓智荣
  652. //添加错误并且排除已存在的记录
  653. //AddErrorAndExceptExistingDataRow(dataSource, errorSource);
  654. var views = MapToStudentsView(dataSource, errorList);
  655. errorList.ForEach(x =>
  656. AddError(errorSource, x.Row, x.Error)
  657. );
  658. if (errorSource.Rows.Count == 0)
  659. {
  660. SaveOrUpdate(views);
  661. }
  662. return errorSource;
  663. }
  664. public void GraduationPicImport(IList<string> photoPaths)
  665. {
  666. var map = photoPaths
  667. .Select(s => new
  668. {
  669. IDNum = Path.GetFileNameWithoutExtension(s).Trim(),
  670. PhotoPath = s,
  671. })
  672. .ToArray();
  673. var idNums = map.Select(s => s.IDNum).Distinct().ToArray();
  674. var studentList = StudentsDAL.Value.StudentRepository.GetList(w => idNums.Contains(w.IDNumber), (x => x.CF_StudentProfile)).ToList();
  675. foreach (var idNum in idNums)
  676. {
  677. var student = studentList.FirstOrDefault(w => w.IDNumber == idNum);
  678. if (student == null)
  679. {
  680. throw new Exception("导入照片中存在无法匹对信息,请检查文件名是否正确。");
  681. }
  682. }
  683. foreach (var m in map)
  684. {
  685. var student = studentList.FirstOrDefault(w => w.IDNumber == m.IDNum);
  686. if (student != null)
  687. {
  688. student.CF_StudentProfile.GraduationPictureUrl = m.PhotoPath;
  689. }
  690. }
  691. UnitOfWork.Commit();
  692. }
  693. public virtual void PicImport(IList<string> photoPaths)
  694. {
  695. var map = photoPaths
  696. .Select(s => new
  697. {
  698. IDNumber = Path.GetFileNameWithoutExtension(s).Trim(),
  699. PhotoPath = s,
  700. })
  701. .ToArray();
  702. var IDNumbers = map.Select(s => s.IDNumber).Distinct().ToArray();
  703. var userIDList = StudentsDAL.Value.StudentRepository.Entities.Where(x => IDNumbers.Contains(x.IDNumber)).Select(x => x.UserID).ToList();
  704. var users = UserRepository.Value.GetList(w => userIDList.Contains(w.UserID), i => i.CF_Student).ToList();
  705. var idList = new List<string>();
  706. foreach (var idNumber in IDNumbers)
  707. {
  708. var user = users.FirstOrDefault(w => w.CF_Student.IDNumber.Equals(idNumber, StringComparison.OrdinalIgnoreCase));
  709. if (user == null)
  710. {
  711. idList.Add(idNumber);
  712. }
  713. }
  714. if (idList.Count() > 0)
  715. {
  716. string idstr = "";
  717. for (int i = 0; i < (idList.Count() > 5 ? 5 : idList.Count()); i++)
  718. {
  719. idstr += idList[i] + ",";
  720. }
  721. throw new Exception("导入照片中存在无法匹对信息,照片名字为:" + idstr.Remove(idstr.Length - 1) + "...,请检查系统是否存在对应学生。");
  722. }
  723. foreach (var m in map)
  724. {
  725. var user = users.FirstOrDefault(w => w.CF_Student.IDNumber.Equals(m.IDNumber, StringComparison.InvariantCultureIgnoreCase));
  726. if (user != null)
  727. {
  728. user.CF_Student.PhotoUrl = m.PhotoPath;
  729. }
  730. }
  731. UnitOfWork.Commit();
  732. }
  733. private StudentsView[] MapToStudentsView(DataTable dataSource, List<ImportErrorRowView> errorList)
  734. {
  735. var views = new List<StudentsView>();
  736. var classNames = dataSource.AsEnumerable().Select(s => s.Field<string>("班级名称").Trim()).Distinct().ToArray();
  737. var classes = ClassmajorRepository.Value.GetList(w => classNames.Contains(w.Name.Trim()), i => i.CF_Grademajor.CF_Schoolyear).ToArray();
  738. var schoolYearCodes = dataSource.AsEnumerable().Select(s => s.Field<string>("入学学年学期").Trim()).Distinct().ToArray();
  739. var schoolYears = SchoolyearRepository.Value.GetList(w => schoolYearCodes.Contains(w.Code.Trim())).ToArray();
  740. var dictionarySex = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Sex);
  741. var dictionaryCertificatesType = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CertificatesType);
  742. var dictionaryStudentStatus = IdNameExt.GetDictionaryItem(DictionaryItem.CF_STUDENTSTATUS);
  743. var dictionaryInschoolStatus = IdNameExt.GetDictionaryItem(DictionaryItem.CF_InschoolStatus);
  744. var dictionaryStudentType = IdNameExt.GetDictionaryItem(DictionaryItem.CF_STUDENTTYPE);
  745. var dictionaryCultureModel = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CULTUREMODEL);
  746. var dictionaryExamineeType = IdNameExt.GetDictionaryItem(DictionaryItem.CF_EXAMINEETYPE);
  747. var dictionaryEntranceWay = IdNameExt.GetDictionaryItem(DictionaryItem.CF_EntranceWay);
  748. var dictionaryFeatures = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Features);
  749. var dictionaryTerritorial = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Province);
  750. var dictionaryNation = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Nation);
  751. var dictionaryHealthy = IdNameExt.GetDictionaryItem(DictionaryItem.CF_HealthState);
  752. var dictionaryBloodGroup = IdNameExt.GetDictionaryItem(DictionaryItem.CF_BLOODGROUP);
  753. var dictionaryPolitics = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Politics);
  754. var dictionaryIsDreamProject = IdNameExt.GetDictionaryItem(DictionaryItem.CF_YesOrNoStatus);
  755. DataTimeHelper dth = new DataTimeHelper();
  756. string temp;
  757. string isDreamProject;
  758. foreach (DataRow dr in dataSource.Rows)
  759. {
  760. List<string> errorMessageList = new List<string>();
  761. var view = new StudentsView();
  762. view.LoginID = (dr.Field<string>("学号") ?? "").Trim();
  763. view.UserName = (dr.Field<string>("姓名") ?? "").Trim();
  764. view.Career = (dr.Field<string>("在校经历") ?? "").Trim();
  765. #region 性别
  766. var sexField = dr.Field<string>("性别");
  767. if (!string.IsNullOrEmpty(sexField))
  768. {
  769. var sex = dictionarySex.SingleOrDefault(w => w.Name.Trim() == sexField.Trim());
  770. if (sex == null)
  771. {
  772. errorMessageList.Add("性别数据格式不正确");
  773. //AddError(errorSource, dr, "性别数据格式不正确");
  774. //continue;
  775. }
  776. else
  777. {
  778. view.Sex = sex.Value;
  779. }
  780. }
  781. #endregion
  782. #region 是否是圆梦计划
  783. isDreamProject = (dr.Field<string>("是否是圆梦计划")??"").Trim();
  784. if (!string.IsNullOrEmpty(isDreamProject))
  785. {
  786. var IsDreamProject = dictionaryIsDreamProject.SingleOrDefault(w => w.Name.Trim() == isDreamProject);
  787. if (IsDreamProject == null)
  788. {
  789. errorMessageList.Add("是否是圆梦计划数据格式不正确");
  790. //AddError(errorSource, dr, "是否是圆梦计划数据格式不正确");
  791. //continue;
  792. }
  793. else
  794. {
  795. view.IsDreamProject = IsDreamProject.Value == 0 ? false : true;
  796. }
  797. }
  798. #endregion
  799. #region 证件类型
  800. var certificatesTypeField = dr.Field<string>("证件类型");
  801. if (!string.IsNullOrEmpty(certificatesTypeField))
  802. {
  803. var certificatesType = dictionaryCertificatesType.SingleOrDefault(w => w.Name.Trim() == certificatesTypeField.Trim());
  804. if (certificatesType == null)
  805. {
  806. errorMessageList.Add("证件类型数据格式不正确");
  807. //AddError(errorSource, dr, "证件类型数据格式不正确");
  808. //continue;
  809. }
  810. else
  811. {
  812. view.CertificatesType = certificatesType.Value;
  813. }
  814. }
  815. #endregion
  816. view.IDNumber = (dr.Field<string>("证件号码") ?? "").Trim();
  817. #region 班级名称
  818. var classField = dr.Field<string>("班级名称");
  819. if (!string.IsNullOrEmpty(classField))
  820. {
  821. var @class = classes.SingleOrDefault(w => w.Name.Trim() == classField.Trim());
  822. if (@class == null)
  823. {
  824. errorMessageList.Add("班级名称不存在");
  825. //AddError(errorSource, dr, "班级名称不存在");
  826. //continue;
  827. }
  828. else
  829. {
  830. view.ClassMajorID = @class.ClassmajorID;
  831. //view.PlanningGraduateDate = PlanningGraduateDateHelper.GetPlanningGraduateDate(@class.CF_Grademajor.CF_Schoolyear.FirstWeek);
  832. //string PlanningGraduateDate = GetPlanningGraduate(@class.CF_Grademajor.GrademajorID);
  833. //view.PlanningGraduateDate = GetPlanningGraduate(@class.CF_Grademajor.GrademajorID);//设置预计毕业时间
  834. }
  835. }
  836. #endregion
  837. #region 学籍状态
  838. var studentStatusField = dr.Field<string>("学籍状态");
  839. if (!string.IsNullOrEmpty(studentStatusField))
  840. {
  841. var studentStatus = dictionaryStudentStatus.SingleOrDefault(w => w.Name.Trim() == studentStatusField.Trim());
  842. if (studentStatus == null)
  843. {
  844. errorMessageList.Add("学籍状态数据格式不正确");
  845. //AddError(errorSource, dr, "学籍状态数据格式不正确");
  846. //continue;
  847. }
  848. else
  849. {
  850. view.StudentStatus = studentStatus.Value;
  851. }
  852. }
  853. #endregion
  854. #region 在校状态
  855. var inschoolStatusField = dr.Field<string>("在校状态");
  856. if (!string.IsNullOrEmpty(inschoolStatusField))
  857. {
  858. var inschoolStatus = dictionaryInschoolStatus.SingleOrDefault(w => w.Name.Trim() == inschoolStatusField.Trim());
  859. if (inschoolStatus == null)
  860. {
  861. errorMessageList.Add("在校状态数据格式不正确");
  862. //AddError(errorSource, dr, "在校状态数据格式不正确");
  863. //continue;
  864. }
  865. else
  866. {
  867. view.InSchoolStatusID = inschoolStatus.Value;
  868. }
  869. }
  870. #endregion
  871. #region 入学学年学期
  872. var schoolYearField = dr.Field<string>("入学学年学期");
  873. if (!string.IsNullOrEmpty(schoolYearField))
  874. {
  875. var schoolYear = schoolYears.SingleOrDefault(w => w.Code.Trim() == schoolYearField.Trim());
  876. if (schoolYear == null)
  877. {
  878. errorMessageList.Add("入学学年学期不存在");
  879. //AddError(errorSource, dr, "入学学年学期不存在");
  880. //continue;
  881. }
  882. else
  883. {
  884. view.EnteringSchoolYearID = schoolYear.SchoolyearID;
  885. }
  886. }
  887. #endregion
  888. #region 学生类别
  889. temp = (dr.Field<string>("学生类别") ?? "").Trim();
  890. if (!string.IsNullOrEmpty(temp))
  891. {
  892. var ent = dictionaryStudentType.SingleOrDefault(w => w.Name.Trim() == temp);
  893. if (ent == null)
  894. {
  895. errorMessageList.Add("学生类别不存在");
  896. //AddError(errorSource, dr, "学生类别不存在");
  897. //continue;
  898. }
  899. else
  900. {
  901. view.StudentType = ent.Value;
  902. }
  903. }
  904. #endregion
  905. #region 培养方式
  906. temp = (dr.Field<string>("培养方式") ?? "").Trim();
  907. if (!string.IsNullOrEmpty(temp))
  908. {
  909. var ent = dictionaryCultureModel.SingleOrDefault(w => w.Name.Trim() == temp);
  910. if (ent == null)
  911. {
  912. errorMessageList.Add("培养方式不存在");
  913. //AddError(errorSource, dr, "培养方式不存在");
  914. //continue;
  915. }
  916. else
  917. {
  918. view.CultureModel = ent.Value;
  919. }
  920. }
  921. #endregion
  922. view.StudentCardNo = (dr.Field<string>("学号") ?? "").Trim();//岭南报名系统学号存在学籍卡号字段
  923. //(dr.Field<string>("学籍卡编号") ?? "").Trim();
  924. view.GraduateCardNo = (dr.Field<string>("毕结业证书编号") ?? "").Trim();
  925. view.ExamineeNum = (dr.Field<string>("教育部考生号") ?? "").Trim();
  926. #region 考生类别
  927. temp = (dr.Field<string>("考生类别") ?? "").Trim();
  928. if (!string.IsNullOrEmpty(temp))
  929. {
  930. var ent = dictionaryExamineeType.SingleOrDefault(w => w.Name.Trim() == temp);
  931. if (ent == null)
  932. {
  933. errorMessageList.Add("考生类别不存在");
  934. //AddError(errorSource, dr, "考生类别不存在");
  935. //continue;
  936. }
  937. else
  938. {
  939. view.ExamineeType = ent.Value;
  940. }
  941. }
  942. #endregion
  943. #region 入学日期
  944. temp = (dr.Field<string>("入学日期") ?? "").Trim();
  945. if (!string.IsNullOrEmpty(temp))
  946. {
  947. DateTime dt;
  948. if (!DateTime.TryParseExact(temp, "yyyyMMdd", null, 0, out dt))
  949. {
  950. if (!DateTime.TryParse(temp, out dt))
  951. {
  952. errorMessageList.Add("入学日期数据格式不正确");
  953. //AddError(errorSource, dr, "入学日期数据格式不正确");
  954. //continue;
  955. }
  956. else
  957. {
  958. view.EntranceDate = dt;
  959. }
  960. }
  961. else
  962. {
  963. view.EntranceDate = dt;
  964. }
  965. }
  966. #endregion
  967. #region 入学方式
  968. temp = (dr.Field<string>("入学方式") ?? "").Trim();
  969. if (!string.IsNullOrEmpty(temp))
  970. {
  971. var ent = dictionaryEntranceWay.SingleOrDefault(w => w.Name.Trim() == temp);
  972. if (ent == null)
  973. {
  974. errorMessageList.Add("入学方式不存在");
  975. //AddError(errorSource, dr, "入学方式不存在");
  976. //continue;
  977. }
  978. else
  979. {
  980. view.EntranceWay = ent.Value;
  981. }
  982. }
  983. #endregion
  984. view.Placebirth = (dr.Field<string>("出生地") ?? "").Trim();
  985. #region 考生特征
  986. temp = (dr.Field<string>("考生特征") ?? "").Trim();
  987. if (!string.IsNullOrEmpty(temp))
  988. {
  989. var ent = dictionaryFeatures.SingleOrDefault(w => w.Name.Trim() == temp);
  990. if (ent == null)
  991. {
  992. errorMessageList.Add("考生特征不存在");
  993. //AddError(errorSource, dr, "考生特征不存在");
  994. //continue;
  995. }
  996. else
  997. {
  998. view.Features = ent.Value;
  999. }
  1000. }
  1001. #endregion
  1002. #region 高考总分
  1003. temp = (dr.Field<string>("高考总分") ?? "").Trim();
  1004. if (!string.IsNullOrEmpty(temp))
  1005. {
  1006. decimal d;
  1007. if (!decimal.TryParse(temp, out d))
  1008. {
  1009. errorMessageList.Add("高考总分数据格式不正确");
  1010. //AddError(errorSource, dr, "高考总分数据格式不正确");
  1011. //continue;
  1012. }
  1013. else
  1014. {
  1015. view.Score = d;
  1016. }
  1017. }
  1018. #endregion
  1019. #region 生源所属地
  1020. temp = (dr.Field<string>("生源所属地") ?? "").Trim();
  1021. if (!string.IsNullOrEmpty(temp))
  1022. {
  1023. var ent = dictionaryTerritorial.SingleOrDefault(w => w.Name.Trim() == temp);
  1024. if (ent == null)
  1025. {
  1026. errorMessageList.Add("生源所属地不存在");
  1027. //AddError(errorSource, dr, "生源所属地不存在");
  1028. //continue;
  1029. }
  1030. else
  1031. {
  1032. view.Territorial = ent.Value;
  1033. }
  1034. }
  1035. #endregion
  1036. view.Area = (dr.Field<string>("来源地区") ?? "").Trim();
  1037. view.UsedName = (dr.Field<string>("曾用名") ?? "").Trim();
  1038. view.DirectorName = (dr.Field<string>("导师姓名") ?? "").Trim();
  1039. #region 出生日期
  1040. temp = (dr.Field<string>("出生日期") ?? "").Trim();
  1041. if (!string.IsNullOrEmpty(temp))
  1042. {
  1043. DateTime dt;
  1044. if (!DateTime.TryParseExact(temp, "yyyyMMdd", null, 0, out dt))
  1045. {
  1046. if (!DateTime.TryParse(temp, out dt))
  1047. {
  1048. errorMessageList.Add("出生日期数据格式不正确");
  1049. //AddError(errorSource, dr, "出生日期数据格式不正确");
  1050. //continue;
  1051. }
  1052. else
  1053. {
  1054. view.BirthDate = dt;
  1055. }
  1056. }
  1057. else
  1058. {
  1059. view.BirthDate = dt;
  1060. }
  1061. }
  1062. #endregion
  1063. view.Country = (dr.Field<string>("国籍") ?? "").Trim();
  1064. // view.Politics = (dr.Field<string>("政治面貌") ?? "").Trim();
  1065. #region 政治面貌
  1066. temp = (dr.Field<string>("政治面貌") ?? "").Trim();
  1067. if (!string.IsNullOrEmpty(temp))
  1068. {
  1069. var politics = dictionaryPolitics.SingleOrDefault(w => w.Name.Trim() == temp);
  1070. if (politics == null)
  1071. {
  1072. errorMessageList.Add("政治面貌不存在");
  1073. //AddError(errorSource, dr, "政治面貌不存在");
  1074. //continue;
  1075. }
  1076. else
  1077. {
  1078. view.Politics = politics.Value;
  1079. }
  1080. }
  1081. #endregion
  1082. #region 民族
  1083. temp = (dr.Field<string>("民族") ?? "").Trim();
  1084. if (!string.IsNullOrEmpty(temp))
  1085. {
  1086. var ent = dictionaryNation.SingleOrDefault(w => w.Name.Trim() == temp);
  1087. if (ent == null)
  1088. {
  1089. errorMessageList.Add("民族不存在");
  1090. //AddError(errorSource, dr, "民族不存在");
  1091. //continue;
  1092. }
  1093. else
  1094. {
  1095. view.Nation = ent.Value;
  1096. }
  1097. }
  1098. #endregion
  1099. view.Place = (dr.Field<string>("籍贯") ?? "").Trim();
  1100. #region 健康状态
  1101. temp = (dr.Field<string>("健康状态") ?? "").Trim();
  1102. if (!string.IsNullOrEmpty(temp))
  1103. {
  1104. var ent = dictionaryHealthy.SingleOrDefault(w => w.Name.Trim() == temp);
  1105. if (ent == null)
  1106. {
  1107. errorMessageList.Add("健康状态不存在");
  1108. //AddError(errorSource, dr, "健康状态不存在");
  1109. //continue;
  1110. }
  1111. else
  1112. {
  1113. view.Healthy = ent.Value;
  1114. }
  1115. }
  1116. #endregion
  1117. #region 血型
  1118. temp = (dr.Field<string>("血型") ?? "").Trim();
  1119. if (!string.IsNullOrEmpty(temp))
  1120. {
  1121. var ent = dictionaryBloodGroup.SingleOrDefault(w => w.Name.Trim() == temp);
  1122. if (ent == null)
  1123. {
  1124. errorMessageList.Add("血型不存在");
  1125. //AddError(errorSource, dr, "血型不存在");
  1126. //continue;
  1127. }
  1128. else
  1129. {
  1130. view.BloodGroup = ent.Value;
  1131. }
  1132. }
  1133. #endregion
  1134. view.Specialty = (dr.Field<string>("特长") ?? "").Trim();
  1135. view.Height = (dr.Field<string>("身高") ?? "").Trim();
  1136. view.Weight = (dr.Field<string>("体重") ?? "").Trim();
  1137. view.Remarks = (dr.Field<string>("备注") ?? "").Trim();
  1138. view.CardNo = (dr.Field<string>("银行卡号") ?? "").Trim();
  1139. view.BankName = (dr.Field<string>("开户银行") ?? "").Trim();
  1140. view.Email = (dr.Field<string>("电子邮件") ?? "").Trim();
  1141. view.QQ = (dr.Field<string>("QQ") ?? "").Trim();
  1142. view.Mobile = (dr.Field<string>("移动电话") ?? "").Trim();
  1143. view.Telephone = (dr.Field<string>("固定电话") ?? "").Trim();
  1144. view.MicroMsgNo = (dr.Field<string>("微信号") ?? "").Trim();
  1145. view.ZipCode = (dr.Field<string>("邮编") ?? "").Trim();
  1146. view.Address = (dr.Field<string>("通信地址") ?? "").Trim();
  1147. view.WorkUnit = (dr.Field<string>("工作单位") ?? "").Trim();
  1148. view.HomeAddress = (dr.Field<string>("家庭地址") ?? "").Trim();
  1149. view.Recipient = (dr.Field<string>("收件人") ?? "").Trim();
  1150. view.Dormitory = (dr.Field<string>("宿舍编号") ?? "").Trim();
  1151. if (errorMessageList.Count > 0)
  1152. {
  1153. if (errorList.Any(x => x.Row == dr))
  1154. {
  1155. var errorRow = errorList.First(x => x.Row == dr);
  1156. errorRow.Error += "," + string.Join(",", errorMessageList);
  1157. }
  1158. else
  1159. {
  1160. errorList.Add(new ImportErrorRowView { Row = dr, Error = string.Join(",", errorMessageList) });
  1161. }
  1162. }
  1163. else if (!errorList.Any(x => x.Row == dr))
  1164. {
  1165. views.Add(view);
  1166. }
  1167. }
  1168. return views.ToArray();
  1169. }
  1170. private List<ImportErrorRowView> AddErrorAndExceptEmptyDataRow(DataTable dataSource)
  1171. {
  1172. var dic = new Dictionary<string, string>
  1173. {
  1174. {"学号","学号不能为空"},
  1175. {"姓名","姓名不能为空"},
  1176. {"性别","性别不能为空"},
  1177. {"证件类型","证件类型不能为空"},
  1178. {"证件号码","证件号码不能为空"},
  1179. {"班级名称","班级名称不能为空"},
  1180. {"学籍状态","学籍状态不能为空"},
  1181. {"在校状态","在校状态不能为空"},
  1182. {"入学学年学期","入学学年学期不能为空"},
  1183. };
  1184. var errorRowList = (from ds in dataSource.AsEnumerable()
  1185. from pair in dic
  1186. where string.IsNullOrEmpty(ds.Field<string>(pair.Key))
  1187. group pair by ds into g
  1188. select new ImportErrorRowView { Row = g.Key, Error = string.Join(",", g.Select(x => x.Value)) })
  1189. .ToList();
  1190. //foreach (var errorRow in errorRowList)
  1191. //{
  1192. // AddError(errorSource, errorRow.Row, errorRow.Error);
  1193. // dataSource.Rows.Remove(errorRow.Row);
  1194. //}
  1195. return errorRowList;
  1196. //foreach (var pair in dic)
  1197. //{
  1198. // var query = dataSource.AsEnumerable().Where(w => string.IsNullOrEmpty(w.Field<string>(pair.Key))).ToArray();
  1199. // foreach (var dr in query)
  1200. // {
  1201. // AddError(errorSource, dr, pair.Value);
  1202. // dataSource.Rows.Remove(dr);
  1203. // }
  1204. //}
  1205. }
  1206. private List<ImportErrorRowView> AddErrorAndExceptExistingDataRow(DataTable dataSource)
  1207. {
  1208. var loginIDs = dataSource.AsEnumerable().Select(s => s.Field<string>("学号")).ToArray();
  1209. var hasLoginIds = UserRepository.Value.GetList(w => loginIDs.Contains(w.LoginID)).Select(s => s.LoginID).ToArray();
  1210. var query = dataSource.AsEnumerable().Where(w => hasLoginIds.Contains(w.Field<string>("学号")))
  1211. .Select(x => new ImportErrorRowView { Row = x, Error = "该学号已存在" }).ToList();
  1212. return query;
  1213. //foreach (var dr in query)
  1214. //{
  1215. // AddError(errorSource, dr, "该学号已存在");
  1216. // dataSource.Rows.Remove(dr);
  1217. //}
  1218. }
  1219. private List<ImportErrorRowView> AddErrorAndExceptRepetitiveDataRow(DataTable dataSource)
  1220. {
  1221. var query = dataSource.AsEnumerable()
  1222. .GroupBy(key => key.Field<string>("学号").ToLower().Replace(")", ")").Replace("(", "("))
  1223. .Where(w => w.Count() > 1 && !string.IsNullOrEmpty(w.Key))
  1224. .SelectMany(s => s)
  1225. .Select(x => new ImportErrorRowView { Row = x, Error = "学号重复" }).ToList();
  1226. var idNumber = dataSource.AsEnumerable()
  1227. .GroupBy(key => key.Field<string>("证件号码").ToLower().Replace(")", ")").Replace("(", "("))
  1228. .Where(w => w.Count() > 1 && !string.IsNullOrEmpty(w.Key))
  1229. .SelectMany(s => s)
  1230. .Select(x => new ImportErrorRowView { Row = x, Error = "证件号码重复" }).ToList();
  1231. //foreach (var dr in query)
  1232. //{
  1233. // AddError(errorSource, dr, "学号重复");
  1234. // dataSource.Rows.Remove(dr);
  1235. //}
  1236. if (query.Count > 0)
  1237. {
  1238. return query;
  1239. }
  1240. if (idNumber.Count > 0)
  1241. {
  1242. return idNumber;
  1243. }
  1244. return query;
  1245. }
  1246. private void AddError(DataTable dtError, DataRow dataRow, string message)
  1247. {
  1248. var dr = dtError.NewRow();
  1249. if (dataRow != null)
  1250. {
  1251. dr.ItemArray = dataRow.ItemArray;
  1252. }
  1253. dr["错误信息"] = message;
  1254. dtError.Rows.Add(dr);
  1255. }
  1256. private void SaveOrUpdateInternal(StudentsView studentfileView, BaseStudentView tempView, CF_Parameter parameter,
  1257. IList<Sys_Role> roleList)
  1258. {
  1259. Sys_User user;
  1260. CF_Student student; //获取学生信息
  1261. CF_StudentProfile studentProfile;
  1262. CF_StudentContact studentContact;
  1263. CF_StudentAccount studentAccount;
  1264. CF_Recruitstudents recruitstudents;
  1265. List<Guid> StudentID = new List<Guid>();
  1266. //以导入信息中的学号查找学生,当没有该学生时新增,否则修改学生信息
  1267. if (tempView == null) //studentfileView.UserID == Guid.Empty
  1268. {
  1269. if (!string.IsNullOrEmpty(studentfileView.IDNumber) && StudentsDAL.Value.StudentRepository.Entities.Any(x => x.IDNumber == studentfileView.IDNumber))
  1270. {
  1271. throw new Exception("已存在相同证件号码的学生");
  1272. }
  1273. if (!string.IsNullOrEmpty(studentfileView.StudentNo) && StudentsDAL.Value.StudentRepository.Entities.Any(x => x.StudentCardNo == studentfileView.StudentNo))
  1274. {
  1275. throw new Exception("已存在相同学号的学生");
  1276. }
  1277. user = new Sys_User();
  1278. user.UserID = Guid.NewGuid();
  1279. StudentID.Add(user.UserID);
  1280. if (parameter == null)
  1281. {
  1282. //密码默认为6个8
  1283. user.Password = ("888888").MD5();
  1284. }
  1285. else
  1286. {
  1287. if (parameter.Value != null)
  1288. {
  1289. user.Password = parameter.Value;
  1290. }
  1291. else
  1292. {
  1293. //密码默认为6个8
  1294. user.Password = ("888888").MD5();
  1295. }
  1296. }
  1297. user.CreateTime = DateTime.Now;
  1298. UnitOfWork.Add(user);
  1299. SetNewStatus(user);
  1300. //添加学生表
  1301. student = new CF_Student();
  1302. student.UserID = user.UserID;
  1303. student.CreateTime = DateTime.Now;
  1304. UnitOfWork.Add(student);
  1305. SetNewStatus(student);
  1306. //学生扩展信息表
  1307. studentProfile = new CF_StudentProfile();
  1308. studentProfile.UserID = student.UserID;
  1309. studentProfile.CreateTime = DateTime.Now;
  1310. UnitOfWork.Add(studentProfile);
  1311. SetNewStatus(studentProfile);
  1312. studentContact = new CF_StudentContact();
  1313. studentContact.UserID = student.UserID;
  1314. studentContact.CreateTime = DateTime.Now;
  1315. UnitOfWork.Add(studentContact);
  1316. SetNewStatus(studentContact);
  1317. studentAccount = new CF_StudentAccount();
  1318. studentAccount.UserID = student.UserID;
  1319. studentAccount.CreateTime = DateTime.Now;
  1320. UnitOfWork.Add(studentAccount);
  1321. SetNewStatus(studentAccount);
  1322. recruitstudents = new CF_Recruitstudents();
  1323. recruitstudents.UserID = student.UserID;
  1324. recruitstudents.CreateTime = DateTime.Now;
  1325. UnitOfWork.Add(recruitstudents);
  1326. SetNewStatus(recruitstudents);
  1327. }
  1328. else
  1329. {
  1330. user = GetUser(tempView.UserID); //studentfileView.UserID
  1331. SetModifyStatus(user);
  1332. student = GetStudent(tempView.UserID); //studentfileView.UserID
  1333. SetModifyStatus(student);
  1334. studentProfile = GetProfile(tempView.UserID); //studentfileView.UserID
  1335. SetModifyStatus(studentProfile);
  1336. studentContact = GetContact(tempView.UserID); //studentfileView.UserID
  1337. SetModifyStatus(studentContact);
  1338. studentAccount = GetAccount(tempView.UserID); //studentfileView.UserID
  1339. SetModifyStatus(studentAccount);
  1340. recruitstudents = GetRecruit(tempView.UserID); //studentfileView.UserID
  1341. SetModifyStatus(recruitstudents);
  1342. }
  1343. user.LoginID = studentfileView.IDNumber;//岭南登录号用身份证号
  1344. if (!string.IsNullOrEmpty(studentfileView.UserName))
  1345. user.Name = studentfileView.UserName;
  1346. if (studentfileView.ClassMajorID != null)
  1347. student.ClassmajorID = studentfileView.ClassMajorID;
  1348. if (studentfileView.Sex != null)
  1349. student.Sex = (int)studentfileView.Sex;
  1350. if (studentfileView.CertificatesType != null)
  1351. student.CertificatesType = studentfileView.CertificatesType;
  1352. if (!string.IsNullOrEmpty(studentfileView.IDNumber))
  1353. student.IDNumber = studentfileView.IDNumber;
  1354. if (studentfileView.IsDreamProject)
  1355. student.IsDreamProject = studentfileView.IsDreamProject;
  1356. student.Career = studentfileView.Career;
  1357. if (!string.IsNullOrEmpty(studentfileView.PhotoUrl))
  1358. {
  1359. student.PhotoUrl = studentfileView.PhotoUrl;
  1360. }
  1361. student.PlanningGraduateDate = studentfileView.PlanningGraduateDate ?? studentfileView.PlanningGraduateDateStr;
  1362. //if (student.PlanningGraduateDate == null)
  1363. //{
  1364. // var GradeMajorID = ClassmajorRepository.Value.Entities.Where(x => x.ClassmajorID == studentfileView.ClassMajorID).FirstOrDefault().GrademajorID;
  1365. // student.PlanningGraduateDate = Convert.ToDateTime(GetPlanningGraduate(GradeMajorID.Value));
  1366. //}
  1367. student.StudentCardNo = studentfileView.StudentNo;
  1368. //毕、结业证书编号
  1369. student.GraduateCardNo = studentfileView.GraduateCardNo;
  1370. student.CultureModel = studentfileView.CultureModel;
  1371. if (studentfileView.StudentType != null)
  1372. student.StudentType = studentfileView.StudentType;
  1373. if (studentfileView.StudentStatus != null)
  1374. student.StudentStatus = studentfileView.StudentStatus;
  1375. if (studentfileView.InSchoolStatusID != null)
  1376. student.InSchoolStatusID = studentfileView.InSchoolStatusID;
  1377. if (studentfileView.ReplaceGraduateNo != null)
  1378. student.ReplaceGraduateNo = studentfileView.ReplaceGraduateNo;
  1379. user.Sys_Role = new HashSet<Sys_Role>();
  1380. roleList = roleList.Where(x => x.CF_StudentRole.StudentType == student.StudentType).ToList();
  1381. roleList.ForEach(x => user.Sys_Role.Add(x));
  1382. if (!string.IsNullOrEmpty(studentfileView.GraduationPictureUrl))
  1383. {
  1384. studentProfile.GraduationPictureUrl = studentfileView.GraduationPictureUrl;
  1385. }
  1386. studentProfile.UsedName = studentfileView.UsedName;
  1387. studentProfile.DirectorName = studentfileView.DirectorName;
  1388. studentProfile.BirthDate = studentfileView.BirthDate;
  1389. studentProfile.Country = studentfileView.Country;
  1390. if (studentfileView.Politics != null)
  1391. studentProfile.Politics = studentfileView.Politics;
  1392. studentProfile.Nation = studentfileView.Nation;
  1393. studentProfile.Place = studentfileView.Place;
  1394. studentProfile.Healthy = studentfileView.Healthy;
  1395. studentProfile.BloodGroup = studentfileView.BloodGroup;
  1396. //studentProfile.BornPlace = studentfileView.BornPlace;
  1397. studentProfile.Specialty = studentfileView.Specialty;
  1398. studentProfile.Height = studentfileView.Height;
  1399. studentProfile.Weight = studentfileView.Weight;
  1400. studentProfile.Remarks = studentfileView.Remarks;
  1401. studentContact.Email = studentfileView.Email;
  1402. studentContact.QQ = studentfileView.QQ;
  1403. studentContact.Mobile = studentfileView.Mobile;
  1404. studentContact.Telephone = studentfileView.Telephone;
  1405. studentContact.MicroMsgNo = studentfileView.MicroMsgNo;
  1406. studentContact.Zipcode = studentfileView.ZipCode;
  1407. studentContact.Address = studentfileView.Address;
  1408. studentContact.WorkUnit = studentfileView.WorkUnit;
  1409. studentContact.HomeAddress = studentfileView.HomeAddress;
  1410. studentContact.Recipient = studentfileView.Recipient;
  1411. studentContact.Dormitory = studentfileView.Dormitory;
  1412. studentAccount.CardNo = studentfileView.CardNo;
  1413. studentAccount.BankName = studentfileView.BankName;
  1414. recruitstudents.EntranceDate = studentfileView.EntranceDate;
  1415. recruitstudents.EntranceWay = studentfileView.EntranceWay;
  1416. recruitstudents.ExamineeNum = studentfileView.ExamineeNum;
  1417. recruitstudents.PlaceBirth = studentfileView.Placebirth;
  1418. recruitstudents.ExamineeType = studentfileView.ExamineeType;
  1419. recruitstudents.Features = studentfileView.Features;
  1420. recruitstudents.Score = studentfileView.Score;
  1421. recruitstudents.Territorial = studentfileView.Territorial;
  1422. recruitstudents.Area = studentfileView.Area;
  1423. recruitstudents.EnteringSchoolYearID = studentfileView.EnteringSchoolYearID;
  1424. UnitOfWork.Commit();
  1425. }
  1426. /// <summary>
  1427. /// 导入更新
  1428. /// </summary>
  1429. /// <param name="studentfileView"></param>
  1430. /// <param name="student"></param>
  1431. /// <param name="parameter"></param>
  1432. /// <param name="roleList"></param>
  1433. private void UpdateInternalForImport(StudentsView studentfileView, CF_Student student, CF_Parameter parameter,
  1434. IList<Sys_Role> roleList)
  1435. {
  1436. SetModifyStatus(student.Sys_User);
  1437. SetModifyStatus(student);
  1438. SetModifyStatus(student.CF_StudentProfile);
  1439. SetModifyStatus(student.CF_StudentContact);
  1440. SetModifyStatus(student.CF_StudentAccount);
  1441. SetModifyStatus(student.CF_Recruitstudents);
  1442. student.Sys_User.LoginID = studentfileView.IDNumber;//岭南LoginID为证件号码
  1443. if (!string.IsNullOrEmpty(studentfileView.UserName))
  1444. student.Sys_User.Name = studentfileView.UserName;
  1445. if (studentfileView.ClassMajorID != null)
  1446. student.ClassmajorID = student.ClassmajorID;
  1447. if (studentfileView.Sex != null)
  1448. student.Sex = (int)studentfileView.Sex;
  1449. if (studentfileView.CertificatesType != null)
  1450. student.CertificatesType = studentfileView.CertificatesType;
  1451. if (!string.IsNullOrEmpty(studentfileView.IDNumber))
  1452. student.IDNumber = studentfileView.IDNumber;
  1453. if (studentfileView.IsDreamProject)
  1454. student.IsDreamProject = studentfileView.IsDreamProject;
  1455. if (!string.IsNullOrEmpty(studentfileView.Career))
  1456. student.Career = studentfileView.Career;
  1457. if (!string.IsNullOrEmpty(studentfileView.PhotoUrl))
  1458. {
  1459. student.PhotoUrl = studentfileView.PhotoUrl;
  1460. }
  1461. student.PlanningGraduateDate = studentfileView.PlanningGraduateDate ?? studentfileView.PlanningGraduateDateStr;
  1462. //if (student.PlanningGraduateDate == null)
  1463. //{
  1464. // var GradeMajorID = ClassmajorRepository.Value.Entities.Where(x => x.ClassmajorID == studentfileView.ClassMajorID).FirstOrDefault().GrademajorID;
  1465. // student.PlanningGraduateDate = Convert.ToDateTime(GetPlanningGraduate(GradeMajorID.Value));
  1466. //}
  1467. if (!string.IsNullOrEmpty(studentfileView.StudentCardNo))
  1468. student.StudentCardNo = studentfileView.StudentCardNo;
  1469. //毕、结业证书编号
  1470. if (!string.IsNullOrEmpty(studentfileView.GraduateCardNo))
  1471. student.GraduateCardNo = studentfileView.GraduateCardNo;
  1472. if (studentfileView.CultureModel != null)
  1473. student.CultureModel = studentfileView.CultureModel;
  1474. if (studentfileView.StudentType != null)
  1475. student.StudentType = studentfileView.StudentType;
  1476. if (studentfileView.StudentStatus != null)
  1477. student.StudentStatus = studentfileView.StudentStatus;
  1478. if (studentfileView.InSchoolStatusID != null)
  1479. student.InSchoolStatusID = studentfileView.InSchoolStatusID;
  1480. student.Sys_User.Sys_Role = new HashSet<Sys_Role>();
  1481. roleList = roleList.Where(x => x.CF_StudentRole.StudentType == student.StudentType).ToList();
  1482. roleList.ForEach(x => student.Sys_User.Sys_Role.Add(x));
  1483. if (!string.IsNullOrEmpty(studentfileView.GraduationPictureUrl))
  1484. {
  1485. student.CF_StudentProfile.GraduationPictureUrl = studentfileView.GraduationPictureUrl;
  1486. }
  1487. if (!string.IsNullOrEmpty(studentfileView.UsedName))
  1488. student.CF_StudentProfile.UsedName = studentfileView.UsedName;
  1489. if (!string.IsNullOrEmpty(studentfileView.DirectorName))
  1490. student.CF_StudentProfile.DirectorName = studentfileView.DirectorName;
  1491. if (studentfileView.BirthDate != null)
  1492. student.CF_StudentProfile.BirthDate = studentfileView.BirthDate;
  1493. if (!string.IsNullOrEmpty(studentfileView.Country))
  1494. student.CF_StudentProfile.Country = studentfileView.Country;
  1495. if (studentfileView.Politics != null)
  1496. student.CF_StudentProfile.Politics = studentfileView.Politics;
  1497. if (studentfileView.Nation != null)
  1498. student.CF_StudentProfile.Nation = studentfileView.Nation;
  1499. if (!string.IsNullOrEmpty(studentfileView.Place))
  1500. student.CF_StudentProfile.Place = studentfileView.Place;
  1501. if (studentfileView.Healthy != null)
  1502. student.CF_StudentProfile.Healthy = studentfileView.Healthy;
  1503. if (studentfileView.BloodGroup != null)
  1504. student.CF_StudentProfile.BloodGroup = studentfileView.BloodGroup;
  1505. //studentProfile.BornPlace = studentfileView.BornPlace;
  1506. if (!string.IsNullOrEmpty(studentfileView.Specialty))
  1507. student.CF_StudentProfile.Specialty = studentfileView.Specialty;
  1508. if (!string.IsNullOrEmpty(studentfileView.Height))
  1509. student.CF_StudentProfile.Height = studentfileView.Height;
  1510. if (!string.IsNullOrEmpty(studentfileView.Weight))
  1511. student.CF_StudentProfile.Weight = studentfileView.Weight;
  1512. if (!string.IsNullOrEmpty(studentfileView.Remarks))
  1513. student.CF_StudentProfile.Remarks = studentfileView.Remarks;
  1514. if (!string.IsNullOrEmpty(studentfileView.Email))
  1515. student.CF_StudentContact.Email = studentfileView.Email;
  1516. if (!string.IsNullOrEmpty(studentfileView.QQ))
  1517. student.CF_StudentContact.QQ = studentfileView.QQ;
  1518. if (!string.IsNullOrEmpty(studentfileView.Mobile))
  1519. student.CF_StudentContact.Mobile = studentfileView.Mobile;
  1520. if (!string.IsNullOrEmpty(studentfileView.Telephone))
  1521. student.CF_StudentContact.Telephone = studentfileView.Telephone;
  1522. if (!string.IsNullOrEmpty(studentfileView.MicroMsgNo))
  1523. student.CF_StudentContact.MicroMsgNo = studentfileView.MicroMsgNo;
  1524. if (!string.IsNullOrEmpty(studentfileView.ZipCode))
  1525. student.CF_StudentContact.Zipcode = studentfileView.ZipCode;
  1526. if (!string.IsNullOrEmpty(studentfileView.Address))
  1527. student.CF_StudentContact.Address = studentfileView.Address;
  1528. if (!string.IsNullOrEmpty(studentfileView.WorkUnit))
  1529. student.CF_StudentContact.WorkUnit = studentfileView.WorkUnit;
  1530. if (!string.IsNullOrEmpty(studentfileView.HomeAddress))
  1531. student.CF_StudentContact.HomeAddress = studentfileView.HomeAddress;
  1532. if (!string.IsNullOrEmpty(studentfileView.Recipient))
  1533. student.CF_StudentContact.Recipient = studentfileView.Recipient;
  1534. if (!string.IsNullOrEmpty(studentfileView.Dormitory))
  1535. student.CF_StudentContact.Dormitory = studentfileView.Dormitory;
  1536. if (!string.IsNullOrEmpty(studentfileView.CardNo))
  1537. student.CF_StudentAccount.CardNo = studentfileView.CardNo;
  1538. if (!string.IsNullOrEmpty(studentfileView.BankName))
  1539. student.CF_StudentAccount.BankName = studentfileView.BankName;
  1540. if (studentfileView.EntranceDate != null)
  1541. student.CF_Recruitstudents.EntranceDate = studentfileView.EntranceDate;
  1542. if (studentfileView.EntranceWay != null)
  1543. student.CF_Recruitstudents.EntranceWay = studentfileView.EntranceWay;
  1544. if (!string.IsNullOrEmpty(studentfileView.ExamineeNum))
  1545. student.CF_Recruitstudents.ExamineeNum = studentfileView.ExamineeNum;
  1546. if (!string.IsNullOrEmpty(studentfileView.Placebirth))
  1547. student.CF_Recruitstudents.PlaceBirth = studentfileView.Placebirth;
  1548. if (studentfileView.ExamineeType != null)
  1549. student.CF_Recruitstudents.ExamineeType = studentfileView.ExamineeType;
  1550. if (studentfileView.Features != null)
  1551. student.CF_Recruitstudents.Features = studentfileView.Features;
  1552. if (studentfileView.Score != null)
  1553. student.CF_Recruitstudents.Score = studentfileView.Score;
  1554. if (studentfileView.Territorial != null)
  1555. student.CF_Recruitstudents.Territorial = studentfileView.Territorial;
  1556. if (!string.IsNullOrEmpty(studentfileView.Area))
  1557. student.CF_Recruitstudents.Area = studentfileView.Area;
  1558. if (studentfileView.EnteringSchoolYearID != null)
  1559. student.CF_Recruitstudents.EnteringSchoolYearID = studentfileView.EnteringSchoolYearID;
  1560. }
  1561. /// <summary>
  1562. /// 导入新增
  1563. /// </summary>
  1564. /// <param name="studentfileView"></param>
  1565. /// <param name="tempView"></param>
  1566. /// <param name="parameter"></param>
  1567. /// <param name="roleList"></param>
  1568. private void SaveInternalForImport(List<StudentsView> studentfileView, BaseStudentView tempView, CF_Parameter parameter,
  1569. IList<Sys_Role> roleList)
  1570. {
  1571. List<Guid> StudentID=new List<Guid>();
  1572. List<Sys_User> userList=new List<Sys_User>();
  1573. List<CF_Student> studentList=new List<CF_Student>(); //获取学生信息
  1574. List<CF_StudentProfile> studentProfileList = new List<CF_StudentProfile>();
  1575. List<CF_StudentContact> studentContactList= new List<CF_StudentContact>();
  1576. List<CF_StudentAccount> studentAccountList =new List<CF_StudentAccount>();
  1577. List<CF_Recruitstudents> recruitstudentsList = new List<CF_Recruitstudents>();
  1578. for (int i = 0; i < studentfileView.Count(); i++)
  1579. {
  1580. var pwd="";
  1581. if (parameter == null)
  1582. {
  1583. pwd = ("888888").MD5();
  1584. }
  1585. else
  1586. {
  1587. if (parameter.Value != null)
  1588. {
  1589. pwd = parameter.Value;
  1590. }
  1591. else
  1592. {
  1593. pwd = ("888888").MD5();
  1594. }
  1595. }
  1596. Sys_User user=new Sys_User();
  1597. int? tpye=null;
  1598. user.LoginID=studentfileView[i].IDNumber;//岭南LoginID为证件号码
  1599. if (!string.IsNullOrEmpty(studentfileView[i].UserName))
  1600. user.Name = studentfileView[i].UserName;
  1601. if (studentfileView[i].StudentType != null)
  1602. tpye= studentfileView[i].StudentType;
  1603. user.Sys_Role = new HashSet<Sys_Role>();
  1604. roleList = roleList.Where(x => x.CF_StudentRole.StudentType == tpye).ToList();
  1605. roleList.ForEach(x => user.Sys_Role.Add(x));
  1606. userList.Add(new Sys_User
  1607. {
  1608. UserID = Guid.NewGuid(),
  1609. Password = pwd,
  1610. CreateTime=DateTime.Now,
  1611. LoginID = user.LoginID,
  1612. Name = user.Name,
  1613. RecordStatus=(int)SYS_STATUS.USABLE,
  1614. Sys_Role=user.Sys_Role
  1615. });
  1616. StudentID.Add(userList[i].UserID);
  1617. CF_Student students =new CF_Student();
  1618. students.UserID=userList[i].UserID;
  1619. if (studentfileView[i].ClassMajorID != null)
  1620. students.ClassmajorID = studentfileView[i].ClassMajorID;
  1621. if (studentfileView[i].Sex != null)
  1622. students.Sex = (int)studentfileView[i].Sex;
  1623. if (studentfileView[i].CertificatesType != null)
  1624. students.CertificatesType = studentfileView[i].CertificatesType;
  1625. if (!string.IsNullOrEmpty(studentfileView[i].IDNumber))
  1626. students.IDNumber = studentfileView[i].IDNumber;
  1627. if (studentfileView[i].IsDreamProject)
  1628. students.IsDreamProject = studentfileView[i].IsDreamProject;
  1629. if (!string.IsNullOrEmpty(studentfileView[i].Career))
  1630. students.Career = studentfileView[i].Career;
  1631. if (!string.IsNullOrEmpty(studentfileView[i].PhotoUrl))
  1632. {
  1633. students.PhotoUrl = studentfileView[i].PhotoUrl;
  1634. }
  1635. students.PlanningGraduateDate = studentfileView[i].PlanningGraduateDate ?? studentfileView[i].PlanningGraduateDateStr;
  1636. //if (students.PlanningGraduateDate == null)
  1637. //{
  1638. // var GradeMajorID = ClassmajorRepository.Value.Entities.Where(x => x.ClassmajorID == studentfileView[i].ClassMajorID).FirstOrDefault().GrademajorID;
  1639. // students.PlanningGraduateDate = Convert.ToDateTime(GetPlanningGraduate(GradeMajorID.Value));
  1640. //}
  1641. if (!string.IsNullOrEmpty(studentfileView[i].StudentCardNo))
  1642. students.StudentCardNo = studentfileView[i].StudentCardNo;
  1643. //毕、结业证书编号
  1644. if (!string.IsNullOrEmpty(studentfileView[i].GraduateCardNo))
  1645. students.GraduateCardNo = studentfileView[i].GraduateCardNo;
  1646. if (studentfileView[i].CultureModel != null)
  1647. students.CultureModel = studentfileView[i].CultureModel;
  1648. if (studentfileView[i].StudentType != null)
  1649. students.StudentType = studentfileView[i].StudentType;
  1650. if (studentfileView[i].StudentStatus != null)
  1651. students.StudentStatus = studentfileView[i].StudentStatus;
  1652. if (studentfileView[i].InSchoolStatusID != null)
  1653. students.InSchoolStatusID = studentfileView[i].InSchoolStatusID;
  1654. studentList.Add(new CF_Student
  1655. {
  1656. UserID = students.UserID,
  1657. ClassmajorID = students.ClassmajorID,
  1658. Sex = students.Sex,
  1659. CertificatesType = students.CertificatesType,
  1660. IDNumber = students.IDNumber,
  1661. IsDreamProject = students.IsDreamProject,
  1662. Career = students.Career,
  1663. PhotoUrl = students.PhotoUrl,
  1664. PlanningGraduateDate = students.PlanningGraduateDate,
  1665. StudentCardNo = students.StudentCardNo,
  1666. GraduateCardNo = students.GraduateCardNo,
  1667. CultureModel = students.CultureModel,
  1668. StudentType = students.StudentType,
  1669. StudentStatus = students.StudentStatus,
  1670. InSchoolStatusID = students.InSchoolStatusID,
  1671. CreateTime = DateTime.Now,
  1672. RecordStatus = (int)SYS_STATUS.USABLE
  1673. });
  1674. CF_StudentProfile studentProfile = new CF_StudentProfile();
  1675. if (!string.IsNullOrEmpty(studentfileView[i].GraduationPictureUrl))
  1676. {
  1677. studentProfile.GraduationPictureUrl = studentfileView[i].GraduationPictureUrl;
  1678. }
  1679. if (!string.IsNullOrEmpty(studentfileView[i].UsedName))
  1680. studentProfile.UsedName = studentfileView[i].UsedName;
  1681. if (!string.IsNullOrEmpty(studentfileView[i].DirectorName))
  1682. studentProfile.DirectorName = studentfileView[i].DirectorName;
  1683. if (studentfileView[i].BirthDate != null)
  1684. studentProfile.BirthDate = studentfileView[i].BirthDate;
  1685. if (!string.IsNullOrEmpty(studentfileView[i].Country))
  1686. studentProfile.Country = studentfileView[i].Country;
  1687. if (studentfileView[i].Politics != null)
  1688. studentProfile.Politics = studentfileView[i].Politics;
  1689. if (studentfileView[i].Nation != null)
  1690. studentProfile.Nation = studentfileView[i].Nation;
  1691. if (!string.IsNullOrEmpty(studentfileView[i].Place))
  1692. studentProfile.Place = studentfileView[i].Place;
  1693. if (studentfileView[i].Healthy != null)
  1694. studentProfile.Healthy = studentfileView[i].Healthy;
  1695. if (studentfileView[i].BloodGroup != null)
  1696. studentProfile.BloodGroup = studentfileView[i].BloodGroup;
  1697. //studentProfile.BornPlace = studentfileView.BornPlace;
  1698. if (!string.IsNullOrEmpty(studentfileView[i].Specialty))
  1699. studentProfile.Specialty = studentfileView[i].Specialty;
  1700. if (!string.IsNullOrEmpty(studentfileView[i].Height))
  1701. studentProfile.Height = studentfileView[i].Height;
  1702. if (!string.IsNullOrEmpty(studentfileView[i].Weight))
  1703. studentProfile.Weight = studentfileView[i].Weight;
  1704. if (!string.IsNullOrEmpty(studentfileView[i].Remarks))
  1705. studentProfile.Remarks = studentfileView[i].Remarks;
  1706. studentProfileList.Add(new CF_StudentProfile
  1707. {
  1708. UserID = students.UserID,
  1709. UsedName = studentProfile.UsedName,
  1710. GraduationPictureUrl=studentProfile.GraduationPictureUrl,
  1711. DirectorName=studentProfile.DirectorName,
  1712. BirthDate=studentProfile.BirthDate,
  1713. Country=studentProfile.Country,
  1714. Politics=studentProfile.Politics,
  1715. Nation=studentProfile.Nation,
  1716. Place=studentProfile.Place,
  1717. Healthy=studentProfile.Healthy,
  1718. BloodGroup=studentProfile.BloodGroup,
  1719. Specialty=studentProfile.Specialty,
  1720. Height=studentProfile.Height,
  1721. Weight=studentProfile.Weight,
  1722. Remarks = studentProfile.Remarks,
  1723. CreateTime = DateTime.Now,
  1724. RecordStatus = (int)SYS_STATUS.USABLE
  1725. });
  1726. CF_StudentContact studentContact = new CF_StudentContact();
  1727. if (!string.IsNullOrEmpty(studentfileView[i].Email))
  1728. studentContact.Email = studentfileView[i].Email;
  1729. if (!string.IsNullOrEmpty(studentfileView[i].QQ))
  1730. studentContact.QQ = studentfileView[i].QQ;
  1731. if (!string.IsNullOrEmpty(studentfileView[i].Mobile))
  1732. studentContact.Mobile = studentfileView[i].Mobile;
  1733. if (!string.IsNullOrEmpty(studentfileView[i].Telephone))
  1734. studentContact.Telephone = studentfileView[i].Telephone;
  1735. if (!string.IsNullOrEmpty(studentfileView[i].MicroMsgNo))
  1736. studentContact.MicroMsgNo = studentfileView[i].MicroMsgNo;
  1737. if (!string.IsNullOrEmpty(studentfileView[i].ZipCode))
  1738. studentContact.Zipcode = studentfileView[i].ZipCode;
  1739. if (!string.IsNullOrEmpty(studentfileView[i].Address))
  1740. studentContact.Address = studentfileView[i].Address;
  1741. if (!string.IsNullOrEmpty(studentfileView[i].WorkUnit))
  1742. studentContact.WorkUnit = studentfileView[i].WorkUnit;
  1743. if (!string.IsNullOrEmpty(studentfileView[i].HomeAddress))
  1744. studentContact.HomeAddress = studentfileView[i].HomeAddress;
  1745. if (!string.IsNullOrEmpty(studentfileView[i].Recipient))
  1746. studentContact.Recipient = studentfileView[i].Recipient;
  1747. if (!string.IsNullOrEmpty(studentfileView[i].Dormitory))
  1748. studentContact.Dormitory = studentfileView[i].Dormitory;
  1749. studentContactList.Add(new CF_StudentContact
  1750. {
  1751. UserID = students.UserID,
  1752. Email=studentContact.Email,
  1753. QQ=studentContact.QQ,
  1754. Mobile=studentContact.Mobile,
  1755. Telephone=studentContact.Telephone,
  1756. MicroMsgNo=studentContact.MicroMsgNo,
  1757. Zipcode=studentContact.Zipcode,
  1758. Address=studentContact.Address,
  1759. WorkUnit=studentContact.WorkUnit,
  1760. HomeAddress=studentContact.HomeAddress,
  1761. Recipient=studentContact.Recipient,
  1762. Dormitory=studentContact.Dormitory,
  1763. CreateTime = DateTime.Now,
  1764. RecordStatus = (int)SYS_STATUS.USABLE
  1765. });
  1766. CF_StudentAccount studentAccount=new CF_StudentAccount();
  1767. if (!string.IsNullOrEmpty(studentfileView[i].CardNo))
  1768. studentAccount.CardNo = studentfileView[i].CardNo;
  1769. if (!string.IsNullOrEmpty(studentfileView[i].BankName))
  1770. studentAccount.BankName = studentfileView[i].BankName;
  1771. studentAccountList.Add(new CF_StudentAccount
  1772. {
  1773. UserID = students.UserID,
  1774. CardNo=studentAccount.CardNo,
  1775. BankName=studentAccount.BankName,
  1776. CreateTime = DateTime.Now,
  1777. RecordStatus = (int)SYS_STATUS.USABLE
  1778. });
  1779. CF_Recruitstudents recruitstudents = new CF_Recruitstudents();
  1780. if (studentfileView[i].EntranceDate != null)
  1781. recruitstudents.EntranceDate = studentfileView[i].EntranceDate;
  1782. if (studentfileView[i].EntranceWay != null)
  1783. recruitstudents.EntranceWay = studentfileView[i].EntranceWay;
  1784. if (!string.IsNullOrEmpty(studentfileView[i].ExamineeNum))
  1785. recruitstudents.ExamineeNum = studentfileView[i].ExamineeNum;
  1786. if (!string.IsNullOrEmpty(studentfileView[i].Placebirth))
  1787. recruitstudents.PlaceBirth = studentfileView[i].Placebirth;
  1788. if (studentfileView[i].ExamineeType != null)
  1789. recruitstudents.ExamineeType = studentfileView[i].ExamineeType;
  1790. if (studentfileView[i].Features != null)
  1791. recruitstudents.Features = studentfileView[i].Features;
  1792. if (studentfileView[i].Score != null)
  1793. recruitstudents.Score = studentfileView[i].Score;
  1794. if (studentfileView[i].Territorial != null)
  1795. recruitstudents.Territorial = studentfileView[i].Territorial;
  1796. if (!string.IsNullOrEmpty(studentfileView[i].Area))
  1797. recruitstudents.Area = studentfileView[i].Area;
  1798. if (studentfileView[i].EnteringSchoolYearID != null)
  1799. recruitstudents.EnteringSchoolYearID = studentfileView[i].EnteringSchoolYearID;
  1800. recruitstudentsList.Add(new CF_Recruitstudents
  1801. {
  1802. UserID = students.UserID,
  1803. EntranceDate=recruitstudents.EntranceDate,
  1804. EntranceWay=recruitstudents.EntranceWay,
  1805. ExamineeNum=recruitstudents.ExamineeNum,
  1806. PlaceBirth=recruitstudents.PlaceBirth,
  1807. ExamineeType=recruitstudents.ExamineeType,
  1808. Features=recruitstudents.Features,
  1809. Score=recruitstudents.Score,
  1810. Territorial=recruitstudents.Territorial,
  1811. Area=recruitstudents.Area,
  1812. EnteringSchoolYearID=recruitstudents.EnteringSchoolYearID,
  1813. CreateTime = DateTime.Now,
  1814. RecordStatus = (int)SYS_STATUS.USABLE
  1815. });
  1816. }
  1817. UnitOfWork.BulkInsert(userList);
  1818. UnitOfWork.BulkInsert(userList, (x => x.Sys_Role));
  1819. UnitOfWork.BulkInsert(studentList);
  1820. UnitOfWork.BulkInsert(studentProfileList);
  1821. UnitOfWork.BulkInsert(studentContactList);
  1822. UnitOfWork.BulkInsert(studentAccountList);
  1823. UnitOfWork.BulkInsert(recruitstudentsList);
  1824. }
  1825. public IGridResultSet<BaseStudentView> GetBaseStudentView(ViewModel.ConfiguretView configuretView, Guid? collegeID, Guid? grademajorID, Guid? classmajorID, Guid? userID, int pageIndex, int pageSize)
  1826. {
  1827. Expression<Func<CF_Student, bool>> filter = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1828. if (collegeID.HasValue)
  1829. filter = filter.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  1830. if (grademajorID.HasValue)
  1831. filter = filter.And(x => x.CF_Classmajor.GrademajorID == grademajorID);
  1832. if (classmajorID.HasValue)
  1833. filter = filter.And(x => x.ClassmajorID == classmajorID);
  1834. if (userID.HasValue)
  1835. {
  1836. filter = filter.And(x => x.UserID == userID);
  1837. }
  1838. var query = StudentsDAL.Value.GetBaseStudentViewQueryable(filter);
  1839. //查询条件
  1840. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  1841. {
  1842. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  1843. }
  1844. return query
  1845. .OrderByDescending(x => x.LoginID.Length).ThenBy(x => x.LoginID)
  1846. .ThenBy(x => x.ClassmajorCode.Length).ThenBy(x => x.ClassmajorCode)
  1847. .ToGridResultSet<BaseStudentView>(pageIndex, pageSize);
  1848. }
  1849. public DateTime? ReckonPlanningGraduateDate(Guid GrademajorID)
  1850. {
  1851. //由于LINQ不识别方法的系统的时间 ToDateTime(系统,字符串)的方法、将计算时间移至外围
  1852. StudentsView studentsEntity = StudentsDAL.Value.GetPlanningGraduateDate(GrademajorID);
  1853. return studentsEntity.PlanningGraduateDate.Value.AddDays(studentsEntity.WeeksNum);
  1854. }
  1855. //private DateTime GetPlanningGraduate(DateTime firstWeek)
  1856. //{
  1857. // if (firstWeek.Month >= 1 && firstWeek.Month <= 6)
  1858. // {
  1859. // return new DateTime(firstWeek.Year, 6, 30);
  1860. // }
  1861. // else
  1862. // {
  1863. // return new DateTime((firstWeek.Year + 1), 1, 31);
  1864. // }
  1865. //}
  1866. public string GetPlanningGraduate(Guid GrademajorID)
  1867. {
  1868. var graduationSchoolyear = this.SchoolyearRepository.Value.GetSingle(x => x.CF_Grademajor.Any(w => w.GrademajorID == GrademajorID));
  1869. if (graduationSchoolyear != null)
  1870. {
  1871. var date = PlanningGraduateDateHelper.GetPlanningGraduateDate(graduationSchoolyear.FirstWeek);
  1872. return date.ToString("yyyy-MM-dd");
  1873. }
  1874. else
  1875. {
  1876. return null;
  1877. }
  1878. //return GetPlanningGraduate(graduationSchoolyear.FirstWeek).ToString("yyyy-MM-dd");
  1879. //StudentsView studentsEntity = StudentsDAL.Value.GetPlanningGraduate(GrademajorID);
  1880. //int PlanningGraduate = (int)studentsEntity.Years;
  1881. //try
  1882. //{
  1883. // string SetPlanningGraduate;
  1884. // if (studentsEntity.PlanningGraduateSchoolCode == (int)EMIS.ViewModel.CF_Schoolcode.Spring)
  1885. // {
  1886. // SetPlanningGraduate = studentsEntity.PlanningGraduateYear.ToString() + "-06-30";
  1887. // }
  1888. // else if (studentsEntity.PlanningGraduateSchoolCode == (int)EMIS.ViewModel.CF_Schoolcode.Autumn)
  1889. // { //因秋季是跨年,毕业年份需要+1年
  1890. // SetPlanningGraduate = (studentsEntity.PlanningGraduateYear + 1).ToString() + "-01-31";
  1891. // }
  1892. // else
  1893. // throw new Exception("学期设置有问题,请核查");
  1894. // return SetPlanningGraduate;
  1895. //}
  1896. //catch
  1897. //{
  1898. // return "";
  1899. //}
  1900. //预计毕业时间,原来逻辑有问题,默认值为2016-01-31+30个月也就是2018-07-31,当学制不为3或2.5时,返回2018-07-31+学制年数:邓智荣
  1901. //DateTime SetPlanningGraduate = Convert.ToDateTime("2016-01-31").AddMonths(30);
  1902. //DateTime SetPlanningGraduate = Convert.ToDateTime(PlanningGraduate.ToString() + "-06-30");
  1903. //if (studentsEntity.LearnSystem == 3)
  1904. //{
  1905. // SetPlanningGraduate = Convert.ToDateTime(PlanningGraduate + "-06-30");
  1906. // // SetPlanningGraduate.AddYears((int)studentsEntity.LearnSystem);
  1907. //}
  1908. //if (studentsEntity.LearnSystem == (Decimal)2.5)
  1909. //{
  1910. // SetPlanningGraduate = Convert.ToDateTime(PlanningGraduate + "-01-31");
  1911. // // SetPlanningGraduate.AddMonths((int)studentsEntity.LearnSystem * 12);
  1912. //}
  1913. ////原逻辑只有学制2.5和3的判断,现加上2和4
  1914. //if (studentsEntity.LearnSystem == 2 || studentsEntity.LearnSystem == 4)
  1915. //{
  1916. // SetPlanningGraduate = Convert.ToDateTime(PlanningGraduate + "-06-30");
  1917. //}
  1918. //if (Convert.ToInt32(studentsEntity.LearnSystem) == studentsEntity.LearnSystem)
  1919. //{ //2、3或4年制
  1920. // SetPlanningGraduate = Convert.ToDateTime(PlanningGraduate + "-06-30");
  1921. //}
  1922. //else
  1923. //{ //2.5或3.5年制
  1924. // SetPlanningGraduate = Convert.ToDateTime(PlanningGraduate + "-01-31");
  1925. //}
  1926. //return SetPlanningGraduate.AddYears((int)studentsEntity.LearnSystem);//2.5 转int 2
  1927. }
  1928. public IGridResultSet<StudentsView> GetPlanningGraduateList()
  1929. {
  1930. Dictionary<int, DateTime?> diction = new Dictionary<int, DateTime?>();
  1931. //int key = 0;
  1932. var query = StudentsDAL.Value.GetPlanningGraduateDictionary().Where(x => x.PlanningGraduateDate != null);
  1933. List<DateTime?> list = query.Select(x => x.PlanningGraduateDate).OrderBy(x => x.Value).ToList();
  1934. List<StudentsView> stulist = query.OrderBy(x => x.PlanningGraduateDate).ToList();
  1935. List<string> datestr = new List<string>();
  1936. for (int i = 0; i < stulist.Count; i++)
  1937. {
  1938. stulist[i].PlanningGraduateStr = list[i].Value.ToString("yyyyMMdd");
  1939. }
  1940. //List<string> dictionList = query.Select(x => x.PlanningGraduateStr).ToList();
  1941. //foreach(DateTime date in dictionList)
  1942. //{
  1943. // diction.Add(key, date);
  1944. // key++;
  1945. //}
  1946. return stulist.AsQueryable().ToGridResultSet<StudentsView>();
  1947. }
  1948. public void ClearPhotoUrl(IList<Guid> studentIDList)
  1949. {
  1950. this.UnitOfWork.Update<CF_Student>((x => new CF_Student { PhotoUrl = null }), (x => studentIDList.Contains(x.UserID)));
  1951. }
  1952. public virtual int? GetDefaultLearnformForList()
  1953. {
  1954. return null;
  1955. }
  1956. public StudentsView GetStudentViewByLoginID(string loginID){
  1957. var student = StudentsDAL.Value.GetStudentQueryable(x => x.Sys_User.LoginID == loginID).FirstOrDefault();
  1958. return student;
  1959. }
  1960. public StudentsView GetStudentViewByIDNum(string idNum)
  1961. {
  1962. var student = StudentsDAL.Value.GetStudentQueryable(x => x.IDNumber == idNum).FirstOrDefault();
  1963. return student;
  1964. }
  1965. public int GetDataRange()
  1966. {
  1967. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  1968. var curUserID = curUser.UserID;
  1969. if (curUser.IsStudent)
  1970. {
  1971. return 6;
  1972. }
  1973. var menuNo = HttpHelper.GetMenuNo();
  1974. if (string.IsNullOrEmpty(menuNo))
  1975. {
  1976. menuNo = HttpContext.Current.Request.UrlReferrer.GetQueryStringByPath("FromMNU");
  1977. }
  1978. SYS_DataRange dataRange = DataRangeDAL.GetRoleDataRange(curUser.RoleID, menuNo);
  1979. switch (dataRange)
  1980. {
  1981. case SYS_DataRange.All:
  1982. default:
  1983. return (int)SYS_DataRange.All;
  1984. case SYS_DataRange.Campus:
  1985. return (int)SYS_DataRange.Campus;
  1986. case SYS_DataRange.College:
  1987. return (int)SYS_DataRange.College;
  1988. case SYS_DataRange.Department:
  1989. return (int)SYS_DataRange.Department;
  1990. case SYS_DataRange.Teacher:
  1991. return (int)SYS_DataRange.Teacher;
  1992. case SYS_DataRange.Assistant:
  1993. return (int)SYS_DataRange.Assistant;
  1994. }
  1995. }
  1996. public IGridResultSet<BaseStudentView> GetStudentOnlyInSchool(ConfiguretView configuretView, int pageIndex, int pageSize)
  1997. {
  1998. Expression<Func<CF_Student, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.InSchoolStatusID == (int)CF_InschoolStatus.InSchool);
  1999. Expression<Func<CF_Classmajor, bool>> classexp = (x => true);
  2000. Expression<Func<CF_Grademajor, bool>> gradeexp = (x => true);
  2001. var query = StudentsDAL.Value.GetInSchoolStudentViewQueryable(exp);
  2002. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  2003. {
  2004. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  2005. }
  2006. return query.OrderBy(x => x.ClassmajorCode.Length).ThenBy(x => x.ClassmajorCode).ThenBy(x => x.LoginID).ToGridResultSet<BaseStudentView>(pageIndex, pageSize);
  2007. }
  2008. /// <summary>
  2009. /// 查询列表
  2010. /// </summary>
  2011. /// <param name="configuretView"></param>
  2012. /// <param name="campusID">校区ID</param>
  2013. /// <param name="collegeID">院系所ID</param>
  2014. /// <param name="educationID">培养层次ID</param>
  2015. /// <param name="years">学年</param>
  2016. /// <param name="standardID">招生专业ID</param>
  2017. /// <param name="learnFormID">学习形式ID</param>
  2018. /// <param name="classMajorID">班级ID</param>
  2019. /// <param name="Shoolstatu">在校状态ID</param>
  2020. /// <param name="isPhotos">是否有照片</param>
  2021. /// <param name="graduationtmentDropdown">是否毕业学生</param>
  2022. /// <param name="pageIndex"></param>
  2023. /// <param name="pageSize"></param>
  2024. /// <returns></returns>
  2025. public IGridResultSet<StudentsView> GetStudentUserViewList(ConfiguretView configuretView,
  2026. int? campusID, Guid? collegeID, int? education, int? years, int? standardID, int? learningformID, int? classNum, int? studentStatusID, bool? isPhotos,
  2027. bool? isOnlyGraduation, bool? isPreviousNotGraduated, int pageIndex, int pageSize)
  2028. {
  2029. var currentSchoolyear = SchoolYearServices.Value.GetCurrentSchoolYear();
  2030. var inschoolStatusList = InSchoolSettingRepository.Value.GetList(x => x.IsSelected == true)
  2031. .Select(x => x.InSchoolStatusID).Distinct().ToList();
  2032. Expression<Func<CF_Student, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && inschoolStatusList.Contains(x.InSchoolStatusID));
  2033. Expression<Func<CF_Classmajor, bool>> classexp = (x => true);
  2034. Expression<Func<CF_Grademajor, bool>> gradeexp = (x => true);
  2035. if (campusID.HasValue)
  2036. {
  2037. gradeexp = gradeexp.And(x => x.SchoolAreaID == campusID);
  2038. }
  2039. if (collegeID.HasValue)
  2040. {
  2041. gradeexp = gradeexp.And(x => x.CF_Facultymajor.CollegeID == collegeID);
  2042. }
  2043. if (education.HasValue)
  2044. {
  2045. gradeexp = gradeexp.And(x => x.CF_Facultymajor.EducationID == education.Value);
  2046. }
  2047. if (years.HasValue)
  2048. {
  2049. gradeexp = gradeexp.And(x => x.SchoolyearID == years);
  2050. }
  2051. if (standardID.HasValue)
  2052. {
  2053. gradeexp = gradeexp.And(x => x.CF_Facultymajor.StandardID == standardID);
  2054. }
  2055. if (learningformID.HasValue)
  2056. {
  2057. gradeexp = gradeexp.And(x => x.CF_Facultymajor.LearningformID == learningformID);
  2058. }
  2059. if (classNum.HasValue)
  2060. {
  2061. classexp = classexp.And(x => x.ClassNum == classNum);
  2062. }
  2063. if (studentStatusID.HasValue)
  2064. {
  2065. exp = exp.And(x => x.StudentStatus == studentStatusID);
  2066. }
  2067. if (isPhotos.HasValue)
  2068. {
  2069. if (isPhotos.Value)
  2070. {
  2071. exp = exp.And(x => x.PhotoUrl != null);
  2072. }
  2073. else
  2074. {
  2075. exp = exp.And(x => x.PhotoUrl == null);
  2076. }
  2077. }
  2078. if (isOnlyGraduation == true)
  2079. {
  2080. gradeexp = gradeexp.And(x => x.GraduatingSemesterID == currentSchoolyear.SchoolYearID);
  2081. }
  2082. if (isPreviousNotGraduated == true)
  2083. {
  2084. gradeexp = gradeexp.And(x => x.CF_Schoolyear.Value < currentSchoolyear.Value);
  2085. exp = exp.And(x => x.StudentStatus == (int)CF_STUDENTSTATUS.Complete && x.InSchoolStatusID == (int)CF_InschoolStatus.Complete);
  2086. }
  2087. var query = StudentsDAL.Value.GetStudentQueryable(exp, classexp, gradeexp);
  2088. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  2089. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  2090. return this.GetQueryByAssistant(query, (x => x.ClassMajorID), this.GetQueryByDataRangeByCollege(query)).OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  2091. .ThenBy(x => x.ClassMajorCode).ThenBy(x => x.LoginID).ToGridResultSet<StudentsView>(pageIndex, pageSize);
  2092. }
  2093. public RegistView GetRegistViewByUserID(Guid userID)
  2094. {
  2095. var registView = StudentsDAL.Value.GetRegustViewQueryable(x => x.UserID == userID).FirstOrDefault();
  2096. return registView;
  2097. }
  2098. public bool CheckNecessary(Guid userID)
  2099. {
  2100. var registView = this.GetRegistViewByUserID(userID);
  2101. if (registView == null)
  2102. {
  2103. return false;
  2104. }
  2105. if (string.IsNullOrEmpty(registView.LoginID))
  2106. {
  2107. return false;
  2108. }
  2109. if (!registView.CertificatesType.HasValue)
  2110. {
  2111. return false;
  2112. }
  2113. if (string.IsNullOrEmpty(registView.UserName))
  2114. {
  2115. return false;
  2116. }
  2117. if (string.IsNullOrEmpty(registView.Mobile))
  2118. {
  2119. return false;
  2120. }
  2121. if (string.IsNullOrEmpty(registView.Email))
  2122. {
  2123. return false;
  2124. }
  2125. if (string.IsNullOrEmpty(registView.PhotoUrl))
  2126. {
  2127. return false;
  2128. }
  2129. if (!registView.Sex.HasValue)
  2130. {
  2131. return false;
  2132. }
  2133. if (!registView.BirthDate.HasValue)
  2134. {
  2135. return false;
  2136. }
  2137. return true;
  2138. }
  2139. }
  2140. }