StudentsServices.cs 111 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350
  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 DataTable PicImport(IList<string> photoPaths)
  694. {
  695. //var errorWebPath = "";
  696. var dt = new DataTable();
  697. var map = photoPaths
  698. .Select(s => new
  699. {
  700. IDNumber = Path.GetFileNameWithoutExtension(s).Trim(),
  701. PhotoPath = s,
  702. })
  703. .ToArray();
  704. var IDNumbers = map.Select(s => s.IDNumber).Distinct().ToArray();
  705. var userIDList = StudentsDAL.Value.StudentRepository.Entities.Where(x => IDNumbers.Contains(x.IDNumber)).Select(x => x.UserID).ToList();
  706. var users = UserRepository.Value.GetList(w => userIDList.Contains(w.UserID), i => i.CF_Student).ToList();
  707. var idList = new List<string>();
  708. //var importIDList = new List<>
  709. foreach (var idNumber in IDNumbers)
  710. {
  711. var user = users.FirstOrDefault(w => w.CF_Student.IDNumber.Equals(idNumber, StringComparison.OrdinalIgnoreCase));
  712. if (user == null)
  713. {
  714. idList.Add(idNumber);
  715. }
  716. else {
  717. }
  718. }
  719. foreach (var m in map)
  720. {
  721. var user = users.FirstOrDefault(w => w.CF_Student.IDNumber.Equals(m.IDNumber, StringComparison.InvariantCultureIgnoreCase));
  722. if (user != null)
  723. {
  724. user.CF_Student.PhotoUrl = m.PhotoPath;
  725. }
  726. }
  727. UnitOfWork.Commit();
  728. if (idList.Count() > 0)
  729. {
  730. NpoiExcelHelper neh = new NpoiExcelHelper();
  731. dt.Columns.Add("证件号码", Type.GetType("System.String"));
  732. dt.Columns.Add("错误原因", Type.GetType("System.String"));
  733. foreach (var id in idList)
  734. {
  735. DataRow row = dt.NewRow();
  736. row["证件号码"] = id.ToString();
  737. row["错误原因"] = "系统不存在该学生";
  738. dt.Rows.Add(row);
  739. }
  740. }
  741. return dt;
  742. }
  743. private StudentsView[] MapToStudentsView(DataTable dataSource, List<ImportErrorRowView> errorList)
  744. {
  745. var views = new List<StudentsView>();
  746. var classNames = dataSource.AsEnumerable().Select(s => s.Field<string>("班级名称").Trim()).Distinct().ToArray();
  747. var classes = ClassmajorRepository.Value.GetList(w => classNames.Contains(w.Name.Trim()), i => i.CF_Grademajor.CF_Schoolyear).ToArray();
  748. var schoolYearCodes = dataSource.AsEnumerable().Select(s => s.Field<string>("入学学年学期").Trim()).Distinct().ToArray();
  749. var schoolYears = SchoolyearRepository.Value.GetList(w => schoolYearCodes.Contains(w.Code.Trim())).ToArray();
  750. var dictionarySex = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Sex);
  751. var dictionaryCertificatesType = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CertificatesType);
  752. var dictionaryStudentStatus = IdNameExt.GetDictionaryItem(DictionaryItem.CF_STUDENTSTATUS);
  753. var dictionaryInschoolStatus = IdNameExt.GetDictionaryItem(DictionaryItem.CF_InschoolStatus);
  754. var dictionaryStudentType = IdNameExt.GetDictionaryItem(DictionaryItem.CF_STUDENTTYPE);
  755. var dictionaryCultureModel = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CULTUREMODEL);
  756. var dictionaryExamineeType = IdNameExt.GetDictionaryItem(DictionaryItem.CF_EXAMINEETYPE);
  757. var dictionaryEntranceWay = IdNameExt.GetDictionaryItem(DictionaryItem.CF_EntranceWay);
  758. var dictionaryFeatures = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Features);
  759. var dictionaryTerritorial = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Province);
  760. var dictionaryNation = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Nation);
  761. var dictionaryHealthy = IdNameExt.GetDictionaryItem(DictionaryItem.CF_HealthState);
  762. var dictionaryBloodGroup = IdNameExt.GetDictionaryItem(DictionaryItem.CF_BLOODGROUP);
  763. var dictionaryPolitics = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Politics);
  764. var dictionaryIsDreamProject = IdNameExt.GetDictionaryItem(DictionaryItem.CF_YesOrNoStatus);
  765. DataTimeHelper dth = new DataTimeHelper();
  766. string temp;
  767. string isDreamProject;
  768. foreach (DataRow dr in dataSource.Rows)
  769. {
  770. List<string> errorMessageList = new List<string>();
  771. var view = new StudentsView();
  772. view.LoginID = (dr.Field<string>("学号") ?? "").Trim();
  773. view.UserName = (dr.Field<string>("姓名") ?? "").Trim();
  774. view.Career = (dr.Field<string>("在校经历") ?? "").Trim();
  775. #region 性别
  776. var sexField = dr.Field<string>("性别");
  777. if (!string.IsNullOrEmpty(sexField))
  778. {
  779. var sex = dictionarySex.SingleOrDefault(w => w.Name.Trim() == sexField.Trim());
  780. if (sex == null)
  781. {
  782. errorMessageList.Add("性别数据格式不正确");
  783. //AddError(errorSource, dr, "性别数据格式不正确");
  784. //continue;
  785. }
  786. else
  787. {
  788. view.Sex = sex.Value;
  789. }
  790. }
  791. #endregion
  792. #region 是否是圆梦计划
  793. isDreamProject = (dr.Field<string>("是否是圆梦计划")??"").Trim();
  794. if (!string.IsNullOrEmpty(isDreamProject))
  795. {
  796. var IsDreamProject = dictionaryIsDreamProject.SingleOrDefault(w => w.Name.Trim() == isDreamProject);
  797. if (IsDreamProject == null)
  798. {
  799. errorMessageList.Add("是否是圆梦计划数据格式不正确");
  800. //AddError(errorSource, dr, "是否是圆梦计划数据格式不正确");
  801. //continue;
  802. }
  803. else
  804. {
  805. view.IsDreamProject = IsDreamProject.Value == 0 ? false : true;
  806. }
  807. }
  808. #endregion
  809. #region 证件类型
  810. var certificatesTypeField = dr.Field<string>("证件类型");
  811. if (!string.IsNullOrEmpty(certificatesTypeField))
  812. {
  813. var certificatesType = dictionaryCertificatesType.SingleOrDefault(w => w.Name.Trim() == certificatesTypeField.Trim());
  814. if (certificatesType == null)
  815. {
  816. errorMessageList.Add("证件类型数据格式不正确");
  817. //AddError(errorSource, dr, "证件类型数据格式不正确");
  818. //continue;
  819. }
  820. else
  821. {
  822. view.CertificatesType = certificatesType.Value;
  823. }
  824. }
  825. #endregion
  826. view.IDNumber = (dr.Field<string>("证件号码") ?? "").Trim();
  827. #region 班级名称
  828. var classField = dr.Field<string>("班级名称");
  829. if (!string.IsNullOrEmpty(classField))
  830. {
  831. var @class = classes.SingleOrDefault(w => w.Name.Trim() == classField.Trim());
  832. if (@class == null)
  833. {
  834. errorMessageList.Add("班级名称不存在");
  835. //AddError(errorSource, dr, "班级名称不存在");
  836. //continue;
  837. }
  838. else
  839. {
  840. view.ClassMajorID = @class.ClassmajorID;
  841. //view.PlanningGraduateDate = PlanningGraduateDateHelper.GetPlanningGraduateDate(@class.CF_Grademajor.CF_Schoolyear.FirstWeek);
  842. //string PlanningGraduateDate = GetPlanningGraduate(@class.CF_Grademajor.GrademajorID);
  843. //view.PlanningGraduateDate = GetPlanningGraduate(@class.CF_Grademajor.GrademajorID);//设置预计毕业时间
  844. }
  845. }
  846. #endregion
  847. #region 学籍状态
  848. var studentStatusField = dr.Field<string>("学籍状态");
  849. if (!string.IsNullOrEmpty(studentStatusField))
  850. {
  851. var studentStatus = dictionaryStudentStatus.SingleOrDefault(w => w.Name.Trim() == studentStatusField.Trim());
  852. if (studentStatus == null)
  853. {
  854. errorMessageList.Add("学籍状态数据格式不正确");
  855. //AddError(errorSource, dr, "学籍状态数据格式不正确");
  856. //continue;
  857. }
  858. else
  859. {
  860. view.StudentStatus = studentStatus.Value;
  861. }
  862. }
  863. #endregion
  864. #region 在校状态
  865. var inschoolStatusField = dr.Field<string>("在校状态");
  866. if (!string.IsNullOrEmpty(inschoolStatusField))
  867. {
  868. var inschoolStatus = dictionaryInschoolStatus.SingleOrDefault(w => w.Name.Trim() == inschoolStatusField.Trim());
  869. if (inschoolStatus == null)
  870. {
  871. errorMessageList.Add("在校状态数据格式不正确");
  872. //AddError(errorSource, dr, "在校状态数据格式不正确");
  873. //continue;
  874. }
  875. else
  876. {
  877. view.InSchoolStatusID = inschoolStatus.Value;
  878. }
  879. }
  880. #endregion
  881. #region 入学学年学期
  882. var schoolYearField = dr.Field<string>("入学学年学期");
  883. if (!string.IsNullOrEmpty(schoolYearField))
  884. {
  885. var schoolYear = schoolYears.SingleOrDefault(w => w.Code.Trim() == schoolYearField.Trim());
  886. if (schoolYear == null)
  887. {
  888. errorMessageList.Add("入学学年学期不存在");
  889. //AddError(errorSource, dr, "入学学年学期不存在");
  890. //continue;
  891. }
  892. else
  893. {
  894. view.EnteringSchoolYearID = schoolYear.SchoolyearID;
  895. }
  896. }
  897. #endregion
  898. #region 学生类别
  899. temp = (dr.Field<string>("学生类别") ?? "").Trim();
  900. if (!string.IsNullOrEmpty(temp))
  901. {
  902. var ent = dictionaryStudentType.SingleOrDefault(w => w.Name.Trim() == temp);
  903. if (ent == null)
  904. {
  905. errorMessageList.Add("学生类别不存在");
  906. //AddError(errorSource, dr, "学生类别不存在");
  907. //continue;
  908. }
  909. else
  910. {
  911. view.StudentType = ent.Value;
  912. }
  913. }
  914. #endregion
  915. #region 培养方式
  916. temp = (dr.Field<string>("培养方式") ?? "").Trim();
  917. if (!string.IsNullOrEmpty(temp))
  918. {
  919. var ent = dictionaryCultureModel.SingleOrDefault(w => w.Name.Trim() == temp);
  920. if (ent == null)
  921. {
  922. errorMessageList.Add("培养方式不存在");
  923. //AddError(errorSource, dr, "培养方式不存在");
  924. //continue;
  925. }
  926. else
  927. {
  928. view.CultureModel = ent.Value;
  929. }
  930. }
  931. #endregion
  932. view.StudentCardNo = (dr.Field<string>("学号") ?? "").Trim();//岭南报名系统学号存在学籍卡号字段
  933. //(dr.Field<string>("学籍卡编号") ?? "").Trim();
  934. view.GraduateCardNo = (dr.Field<string>("毕结业证书编号") ?? "").Trim();
  935. view.ExamineeNum = (dr.Field<string>("教育部考生号") ?? "").Trim();
  936. #region 考生类别
  937. temp = (dr.Field<string>("考生类别") ?? "").Trim();
  938. if (!string.IsNullOrEmpty(temp))
  939. {
  940. var ent = dictionaryExamineeType.SingleOrDefault(w => w.Name.Trim() == temp);
  941. if (ent == null)
  942. {
  943. errorMessageList.Add("考生类别不存在");
  944. //AddError(errorSource, dr, "考生类别不存在");
  945. //continue;
  946. }
  947. else
  948. {
  949. view.ExamineeType = ent.Value;
  950. }
  951. }
  952. #endregion
  953. #region 入学日期
  954. temp = (dr.Field<string>("入学日期") ?? "").Trim();
  955. if (!string.IsNullOrEmpty(temp))
  956. {
  957. DateTime dt;
  958. if (!DateTime.TryParseExact(temp, "yyyyMMdd", null, 0, out dt))
  959. {
  960. if (!DateTime.TryParse(temp, out dt))
  961. {
  962. errorMessageList.Add("入学日期数据格式不正确");
  963. //AddError(errorSource, dr, "入学日期数据格式不正确");
  964. //continue;
  965. }
  966. else
  967. {
  968. view.EntranceDate = dt;
  969. }
  970. }
  971. else
  972. {
  973. view.EntranceDate = dt;
  974. }
  975. }
  976. #endregion
  977. #region 入学方式
  978. temp = (dr.Field<string>("入学方式") ?? "").Trim();
  979. if (!string.IsNullOrEmpty(temp))
  980. {
  981. var ent = dictionaryEntranceWay.SingleOrDefault(w => w.Name.Trim() == temp);
  982. if (ent == null)
  983. {
  984. errorMessageList.Add("入学方式不存在");
  985. //AddError(errorSource, dr, "入学方式不存在");
  986. //continue;
  987. }
  988. else
  989. {
  990. view.EntranceWay = ent.Value;
  991. }
  992. }
  993. #endregion
  994. view.Placebirth = (dr.Field<string>("出生地") ?? "").Trim();
  995. #region 考生特征
  996. temp = (dr.Field<string>("考生特征") ?? "").Trim();
  997. if (!string.IsNullOrEmpty(temp))
  998. {
  999. var ent = dictionaryFeatures.SingleOrDefault(w => w.Name.Trim() == temp);
  1000. if (ent == null)
  1001. {
  1002. errorMessageList.Add("考生特征不存在");
  1003. //AddError(errorSource, dr, "考生特征不存在");
  1004. //continue;
  1005. }
  1006. else
  1007. {
  1008. view.Features = ent.Value;
  1009. }
  1010. }
  1011. #endregion
  1012. #region 高考总分
  1013. temp = (dr.Field<string>("高考总分") ?? "").Trim();
  1014. if (!string.IsNullOrEmpty(temp))
  1015. {
  1016. decimal d;
  1017. if (!decimal.TryParse(temp, out d))
  1018. {
  1019. errorMessageList.Add("高考总分数据格式不正确");
  1020. //AddError(errorSource, dr, "高考总分数据格式不正确");
  1021. //continue;
  1022. }
  1023. else
  1024. {
  1025. view.Score = d;
  1026. }
  1027. }
  1028. #endregion
  1029. #region 生源所属地
  1030. temp = (dr.Field<string>("生源所属地") ?? "").Trim();
  1031. if (!string.IsNullOrEmpty(temp))
  1032. {
  1033. var ent = dictionaryTerritorial.SingleOrDefault(w => w.Name.Trim() == temp);
  1034. if (ent == null)
  1035. {
  1036. errorMessageList.Add("生源所属地不存在");
  1037. //AddError(errorSource, dr, "生源所属地不存在");
  1038. //continue;
  1039. }
  1040. else
  1041. {
  1042. view.Territorial = ent.Value;
  1043. }
  1044. }
  1045. #endregion
  1046. view.Area = (dr.Field<string>("来源地区") ?? "").Trim();
  1047. view.UsedName = (dr.Field<string>("曾用名") ?? "").Trim();
  1048. view.DirectorName = (dr.Field<string>("导师姓名") ?? "").Trim();
  1049. #region 出生日期
  1050. temp = (dr.Field<string>("出生日期") ?? "").Trim();
  1051. if (!string.IsNullOrEmpty(temp))
  1052. {
  1053. DateTime dt;
  1054. if (!DateTime.TryParseExact(temp, "yyyyMMdd", null, 0, out dt))
  1055. {
  1056. if (!DateTime.TryParse(temp, out dt))
  1057. {
  1058. errorMessageList.Add("出生日期数据格式不正确");
  1059. //AddError(errorSource, dr, "出生日期数据格式不正确");
  1060. //continue;
  1061. }
  1062. else
  1063. {
  1064. view.BirthDate = dt;
  1065. }
  1066. }
  1067. else
  1068. {
  1069. view.BirthDate = dt;
  1070. }
  1071. }
  1072. #endregion
  1073. view.Country = (dr.Field<string>("国籍") ?? "").Trim();
  1074. // view.Politics = (dr.Field<string>("政治面貌") ?? "").Trim();
  1075. #region 政治面貌
  1076. temp = (dr.Field<string>("政治面貌") ?? "").Trim();
  1077. if (!string.IsNullOrEmpty(temp))
  1078. {
  1079. var politics = dictionaryPolitics.SingleOrDefault(w => w.Name.Trim() == temp);
  1080. if (politics == null)
  1081. {
  1082. errorMessageList.Add("政治面貌不存在");
  1083. //AddError(errorSource, dr, "政治面貌不存在");
  1084. //continue;
  1085. }
  1086. else
  1087. {
  1088. view.Politics = politics.Value;
  1089. }
  1090. }
  1091. #endregion
  1092. #region 民族
  1093. temp = (dr.Field<string>("民族") ?? "").Trim();
  1094. if (!string.IsNullOrEmpty(temp))
  1095. {
  1096. var ent = dictionaryNation.SingleOrDefault(w => w.Name.Trim() == temp);
  1097. if (ent == null)
  1098. {
  1099. errorMessageList.Add("民族不存在");
  1100. //AddError(errorSource, dr, "民族不存在");
  1101. //continue;
  1102. }
  1103. else
  1104. {
  1105. view.Nation = ent.Value;
  1106. }
  1107. }
  1108. #endregion
  1109. view.Place = (dr.Field<string>("籍贯") ?? "").Trim();
  1110. #region 健康状态
  1111. temp = (dr.Field<string>("健康状态") ?? "").Trim();
  1112. if (!string.IsNullOrEmpty(temp))
  1113. {
  1114. var ent = dictionaryHealthy.SingleOrDefault(w => w.Name.Trim() == temp);
  1115. if (ent == null)
  1116. {
  1117. errorMessageList.Add("健康状态不存在");
  1118. //AddError(errorSource, dr, "健康状态不存在");
  1119. //continue;
  1120. }
  1121. else
  1122. {
  1123. view.Healthy = ent.Value;
  1124. }
  1125. }
  1126. #endregion
  1127. #region 血型
  1128. temp = (dr.Field<string>("血型") ?? "").Trim();
  1129. if (!string.IsNullOrEmpty(temp))
  1130. {
  1131. var ent = dictionaryBloodGroup.SingleOrDefault(w => w.Name.Trim() == temp);
  1132. if (ent == null)
  1133. {
  1134. errorMessageList.Add("血型不存在");
  1135. //AddError(errorSource, dr, "血型不存在");
  1136. //continue;
  1137. }
  1138. else
  1139. {
  1140. view.BloodGroup = ent.Value;
  1141. }
  1142. }
  1143. #endregion
  1144. view.Specialty = (dr.Field<string>("特长") ?? "").Trim();
  1145. view.Height = (dr.Field<string>("身高") ?? "").Trim();
  1146. view.Weight = (dr.Field<string>("体重") ?? "").Trim();
  1147. view.Remarks = (dr.Field<string>("备注") ?? "").Trim();
  1148. view.CardNo = (dr.Field<string>("银行卡号") ?? "").Trim();
  1149. view.BankName = (dr.Field<string>("开户银行") ?? "").Trim();
  1150. view.Email = (dr.Field<string>("电子邮件") ?? "").Trim();
  1151. view.QQ = (dr.Field<string>("QQ") ?? "").Trim();
  1152. view.Mobile = (dr.Field<string>("移动电话") ?? "").Trim();
  1153. view.Telephone = (dr.Field<string>("固定电话") ?? "").Trim();
  1154. view.MicroMsgNo = (dr.Field<string>("微信号") ?? "").Trim();
  1155. view.ZipCode = (dr.Field<string>("邮编") ?? "").Trim();
  1156. view.Address = (dr.Field<string>("通信地址") ?? "").Trim();
  1157. view.WorkUnit = (dr.Field<string>("工作单位") ?? "").Trim();
  1158. view.HomeAddress = (dr.Field<string>("家庭地址") ?? "").Trim();
  1159. view.Recipient = (dr.Field<string>("收件人") ?? "").Trim();
  1160. view.Dormitory = (dr.Field<string>("宿舍编号") ?? "").Trim();
  1161. if (errorMessageList.Count > 0)
  1162. {
  1163. if (errorList.Any(x => x.Row == dr))
  1164. {
  1165. var errorRow = errorList.First(x => x.Row == dr);
  1166. errorRow.Error += "," + string.Join(",", errorMessageList);
  1167. }
  1168. else
  1169. {
  1170. errorList.Add(new ImportErrorRowView { Row = dr, Error = string.Join(",", errorMessageList) });
  1171. }
  1172. }
  1173. else if (!errorList.Any(x => x.Row == dr))
  1174. {
  1175. views.Add(view);
  1176. }
  1177. }
  1178. return views.ToArray();
  1179. }
  1180. private List<ImportErrorRowView> AddErrorAndExceptEmptyDataRow(DataTable dataSource)
  1181. {
  1182. var dic = new Dictionary<string, string>
  1183. {
  1184. {"学号","学号不能为空"},
  1185. {"姓名","姓名不能为空"},
  1186. {"性别","性别不能为空"},
  1187. {"证件类型","证件类型不能为空"},
  1188. {"证件号码","证件号码不能为空"},
  1189. {"班级名称","班级名称不能为空"},
  1190. {"学籍状态","学籍状态不能为空"},
  1191. {"在校状态","在校状态不能为空"},
  1192. {"入学学年学期","入学学年学期不能为空"},
  1193. };
  1194. var errorRowList = (from ds in dataSource.AsEnumerable()
  1195. from pair in dic
  1196. where string.IsNullOrEmpty(ds.Field<string>(pair.Key))
  1197. group pair by ds into g
  1198. select new ImportErrorRowView { Row = g.Key, Error = string.Join(",", g.Select(x => x.Value)) })
  1199. .ToList();
  1200. //foreach (var errorRow in errorRowList)
  1201. //{
  1202. // AddError(errorSource, errorRow.Row, errorRow.Error);
  1203. // dataSource.Rows.Remove(errorRow.Row);
  1204. //}
  1205. return errorRowList;
  1206. //foreach (var pair in dic)
  1207. //{
  1208. // var query = dataSource.AsEnumerable().Where(w => string.IsNullOrEmpty(w.Field<string>(pair.Key))).ToArray();
  1209. // foreach (var dr in query)
  1210. // {
  1211. // AddError(errorSource, dr, pair.Value);
  1212. // dataSource.Rows.Remove(dr);
  1213. // }
  1214. //}
  1215. }
  1216. private List<ImportErrorRowView> AddErrorAndExceptExistingDataRow(DataTable dataSource)
  1217. {
  1218. var loginIDs = dataSource.AsEnumerable().Select(s => s.Field<string>("学号")).ToArray();
  1219. var hasLoginIds = UserRepository.Value.GetList(w => loginIDs.Contains(w.LoginID)).Select(s => s.LoginID).ToArray();
  1220. var query = dataSource.AsEnumerable().Where(w => hasLoginIds.Contains(w.Field<string>("学号")))
  1221. .Select(x => new ImportErrorRowView { Row = x, Error = "该学号已存在" }).ToList();
  1222. return query;
  1223. //foreach (var dr in query)
  1224. //{
  1225. // AddError(errorSource, dr, "该学号已存在");
  1226. // dataSource.Rows.Remove(dr);
  1227. //}
  1228. }
  1229. private List<ImportErrorRowView> AddErrorAndExceptRepetitiveDataRow(DataTable dataSource)
  1230. {
  1231. var query = dataSource.AsEnumerable()
  1232. .GroupBy(key => key.Field<string>("学号").ToLower().Replace(")", ")").Replace("(", "("))
  1233. .Where(w => w.Count() > 1 && !string.IsNullOrEmpty(w.Key))
  1234. .SelectMany(s => s)
  1235. .Select(x => new ImportErrorRowView { Row = x, Error = "学号重复" }).ToList();
  1236. var idNumber = dataSource.AsEnumerable()
  1237. .GroupBy(key => key.Field<string>("证件号码").ToLower().Replace(")", ")").Replace("(", "("))
  1238. .Where(w => w.Count() > 1 && !string.IsNullOrEmpty(w.Key))
  1239. .SelectMany(s => s)
  1240. .Select(x => new ImportErrorRowView { Row = x, Error = "证件号码重复" }).ToList();
  1241. //foreach (var dr in query)
  1242. //{
  1243. // AddError(errorSource, dr, "学号重复");
  1244. // dataSource.Rows.Remove(dr);
  1245. //}
  1246. if (query.Count > 0)
  1247. {
  1248. return query;
  1249. }
  1250. if (idNumber.Count > 0)
  1251. {
  1252. return idNumber;
  1253. }
  1254. return query;
  1255. }
  1256. private void AddError(DataTable dtError, DataRow dataRow, string message)
  1257. {
  1258. var dr = dtError.NewRow();
  1259. if (dataRow != null)
  1260. {
  1261. dr.ItemArray = dataRow.ItemArray;
  1262. }
  1263. dr["错误信息"] = message;
  1264. dtError.Rows.Add(dr);
  1265. }
  1266. private void SaveOrUpdateInternal(StudentsView studentfileView, BaseStudentView tempView, CF_Parameter parameter,
  1267. IList<Sys_Role> roleList)
  1268. {
  1269. Sys_User user;
  1270. CF_Student student; //获取学生信息
  1271. CF_StudentProfile studentProfile;
  1272. CF_StudentContact studentContact;
  1273. CF_StudentAccount studentAccount;
  1274. CF_Recruitstudents recruitstudents;
  1275. List<Guid> StudentID = new List<Guid>();
  1276. //以导入信息中的学号查找学生,当没有该学生时新增,否则修改学生信息
  1277. if (tempView == null) //studentfileView.UserID == Guid.Empty
  1278. {
  1279. if (!string.IsNullOrEmpty(studentfileView.IDNumber) && StudentsDAL.Value.StudentRepository.Entities.Any(x => x.IDNumber == studentfileView.IDNumber))
  1280. {
  1281. throw new Exception("已存在相同证件号码的学生");
  1282. }
  1283. if (!string.IsNullOrEmpty(studentfileView.StudentNo) && StudentsDAL.Value.StudentRepository.Entities.Any(x => x.StudentCardNo == studentfileView.StudentNo))
  1284. {
  1285. throw new Exception("已存在相同学号的学生");
  1286. }
  1287. user = new Sys_User();
  1288. user.UserID = Guid.NewGuid();
  1289. StudentID.Add(user.UserID);
  1290. if (parameter == null)
  1291. {
  1292. //密码默认为6个8
  1293. user.Password = ("888888").MD5();
  1294. }
  1295. else
  1296. {
  1297. if (parameter.Value != null)
  1298. {
  1299. user.Password = parameter.Value;
  1300. }
  1301. else
  1302. {
  1303. //密码默认为6个8
  1304. user.Password = ("888888").MD5();
  1305. }
  1306. }
  1307. user.CreateTime = DateTime.Now;
  1308. UnitOfWork.Add(user);
  1309. SetNewStatus(user);
  1310. //添加学生表
  1311. student = new CF_Student();
  1312. student.UserID = user.UserID;
  1313. student.CreateTime = DateTime.Now;
  1314. UnitOfWork.Add(student);
  1315. SetNewStatus(student);
  1316. //学生扩展信息表
  1317. studentProfile = new CF_StudentProfile();
  1318. studentProfile.UserID = student.UserID;
  1319. studentProfile.CreateTime = DateTime.Now;
  1320. UnitOfWork.Add(studentProfile);
  1321. SetNewStatus(studentProfile);
  1322. studentContact = new CF_StudentContact();
  1323. studentContact.UserID = student.UserID;
  1324. studentContact.CreateTime = DateTime.Now;
  1325. UnitOfWork.Add(studentContact);
  1326. SetNewStatus(studentContact);
  1327. studentAccount = new CF_StudentAccount();
  1328. studentAccount.UserID = student.UserID;
  1329. studentAccount.CreateTime = DateTime.Now;
  1330. UnitOfWork.Add(studentAccount);
  1331. SetNewStatus(studentAccount);
  1332. recruitstudents = new CF_Recruitstudents();
  1333. recruitstudents.UserID = student.UserID;
  1334. recruitstudents.CreateTime = DateTime.Now;
  1335. UnitOfWork.Add(recruitstudents);
  1336. SetNewStatus(recruitstudents);
  1337. }
  1338. else
  1339. {
  1340. user = GetUser(tempView.UserID); //studentfileView.UserID
  1341. SetModifyStatus(user);
  1342. student = GetStudent(tempView.UserID); //studentfileView.UserID
  1343. SetModifyStatus(student);
  1344. studentProfile = GetProfile(tempView.UserID); //studentfileView.UserID
  1345. SetModifyStatus(studentProfile);
  1346. studentContact = GetContact(tempView.UserID); //studentfileView.UserID
  1347. SetModifyStatus(studentContact);
  1348. studentAccount = GetAccount(tempView.UserID); //studentfileView.UserID
  1349. SetModifyStatus(studentAccount);
  1350. recruitstudents = GetRecruit(tempView.UserID); //studentfileView.UserID
  1351. SetModifyStatus(recruitstudents);
  1352. }
  1353. user.LoginID = studentfileView.IDNumber;//岭南登录号用身份证号
  1354. if (!string.IsNullOrEmpty(studentfileView.UserName))
  1355. user.Name = studentfileView.UserName;
  1356. if (studentfileView.ClassMajorID != null)
  1357. student.ClassmajorID = studentfileView.ClassMajorID;
  1358. if (studentfileView.Sex != null)
  1359. student.Sex = (int)studentfileView.Sex;
  1360. if (studentfileView.CertificatesType != null)
  1361. student.CertificatesType = studentfileView.CertificatesType;
  1362. if (!string.IsNullOrEmpty(studentfileView.IDNumber))
  1363. student.IDNumber = studentfileView.IDNumber;
  1364. if (studentfileView.IsDreamProject)
  1365. student.IsDreamProject = studentfileView.IsDreamProject;
  1366. student.Career = studentfileView.Career;
  1367. if (!string.IsNullOrEmpty(studentfileView.PhotoUrl))
  1368. {
  1369. student.PhotoUrl = studentfileView.PhotoUrl;
  1370. }
  1371. student.PlanningGraduateDate = studentfileView.PlanningGraduateDate ?? studentfileView.PlanningGraduateDateStr;
  1372. //if (student.PlanningGraduateDate == null)
  1373. //{
  1374. // var GradeMajorID = ClassmajorRepository.Value.Entities.Where(x => x.ClassmajorID == studentfileView.ClassMajorID).FirstOrDefault().GrademajorID;
  1375. // student.PlanningGraduateDate = Convert.ToDateTime(GetPlanningGraduate(GradeMajorID.Value));
  1376. //}
  1377. student.StudentCardNo = studentfileView.StudentNo;
  1378. //毕、结业证书编号
  1379. student.GraduateCardNo = studentfileView.GraduateCardNo;
  1380. student.CultureModel = studentfileView.CultureModel;
  1381. if (studentfileView.StudentType != null)
  1382. student.StudentType = studentfileView.StudentType;
  1383. if (studentfileView.StudentStatus != null)
  1384. student.StudentStatus = studentfileView.StudentStatus;
  1385. if (studentfileView.InSchoolStatusID != null)
  1386. student.InSchoolStatusID = studentfileView.InSchoolStatusID;
  1387. if (studentfileView.ReplaceGraduateNo != null)
  1388. student.ReplaceGraduateNo = studentfileView.ReplaceGraduateNo;
  1389. user.Sys_Role = new HashSet<Sys_Role>();
  1390. roleList = roleList.Where(x => x.CF_StudentRole.StudentType == student.StudentType).ToList();
  1391. roleList.ForEach(x => user.Sys_Role.Add(x));
  1392. if (!string.IsNullOrEmpty(studentfileView.GraduationPictureUrl))
  1393. {
  1394. studentProfile.GraduationPictureUrl = studentfileView.GraduationPictureUrl;
  1395. }
  1396. studentProfile.UsedName = studentfileView.UsedName;
  1397. studentProfile.DirectorName = studentfileView.DirectorName;
  1398. studentProfile.BirthDate = studentfileView.BirthDate;
  1399. studentProfile.Country = studentfileView.Country;
  1400. if (studentfileView.Politics != null)
  1401. studentProfile.Politics = studentfileView.Politics;
  1402. studentProfile.Nation = studentfileView.Nation;
  1403. studentProfile.Place = studentfileView.Place;
  1404. studentProfile.Healthy = studentfileView.Healthy;
  1405. studentProfile.BloodGroup = studentfileView.BloodGroup;
  1406. //studentProfile.BornPlace = studentfileView.BornPlace;
  1407. studentProfile.Specialty = studentfileView.Specialty;
  1408. studentProfile.Height = studentfileView.Height;
  1409. studentProfile.Weight = studentfileView.Weight;
  1410. studentProfile.Remarks = studentfileView.Remarks;
  1411. studentContact.Email = studentfileView.Email;
  1412. studentContact.QQ = studentfileView.QQ;
  1413. studentContact.Mobile = studentfileView.Mobile;
  1414. studentContact.Telephone = studentfileView.Telephone;
  1415. studentContact.MicroMsgNo = studentfileView.MicroMsgNo;
  1416. studentContact.Zipcode = studentfileView.ZipCode;
  1417. studentContact.Address = studentfileView.Address;
  1418. studentContact.WorkUnit = studentfileView.WorkUnit;
  1419. studentContact.HomeAddress = studentfileView.HomeAddress;
  1420. studentContact.Recipient = studentfileView.Recipient;
  1421. studentContact.Dormitory = studentfileView.Dormitory;
  1422. studentAccount.CardNo = studentfileView.CardNo;
  1423. studentAccount.BankName = studentfileView.BankName;
  1424. recruitstudents.EntranceDate = studentfileView.EntranceDate;
  1425. recruitstudents.EntranceWay = studentfileView.EntranceWay;
  1426. recruitstudents.ExamineeNum = studentfileView.ExamineeNum;
  1427. recruitstudents.PlaceBirth = studentfileView.Placebirth;
  1428. recruitstudents.ExamineeType = studentfileView.ExamineeType;
  1429. recruitstudents.Features = studentfileView.Features;
  1430. recruitstudents.Score = studentfileView.Score;
  1431. recruitstudents.Territorial = studentfileView.Territorial;
  1432. recruitstudents.Area = studentfileView.Area;
  1433. recruitstudents.EnteringSchoolYearID = studentfileView.EnteringSchoolYearID;
  1434. UnitOfWork.Commit();
  1435. }
  1436. /// <summary>
  1437. /// 导入更新
  1438. /// </summary>
  1439. /// <param name="studentfileView"></param>
  1440. /// <param name="student"></param>
  1441. /// <param name="parameter"></param>
  1442. /// <param name="roleList"></param>
  1443. private void UpdateInternalForImport(StudentsView studentfileView, CF_Student student, CF_Parameter parameter,
  1444. IList<Sys_Role> roleList)
  1445. {
  1446. SetModifyStatus(student.Sys_User);
  1447. SetModifyStatus(student);
  1448. SetModifyStatus(student.CF_StudentProfile);
  1449. SetModifyStatus(student.CF_StudentContact);
  1450. SetModifyStatus(student.CF_StudentAccount);
  1451. SetModifyStatus(student.CF_Recruitstudents);
  1452. student.Sys_User.LoginID = studentfileView.IDNumber;//岭南LoginID为证件号码
  1453. if (!string.IsNullOrEmpty(studentfileView.UserName))
  1454. student.Sys_User.Name = studentfileView.UserName;
  1455. if (studentfileView.ClassMajorID != null)
  1456. student.ClassmajorID = student.ClassmajorID;
  1457. if (studentfileView.Sex != null)
  1458. student.Sex = (int)studentfileView.Sex;
  1459. if (studentfileView.CertificatesType != null)
  1460. student.CertificatesType = studentfileView.CertificatesType;
  1461. if (!string.IsNullOrEmpty(studentfileView.IDNumber))
  1462. student.IDNumber = studentfileView.IDNumber;
  1463. if (studentfileView.IsDreamProject)
  1464. student.IsDreamProject = studentfileView.IsDreamProject;
  1465. if (!string.IsNullOrEmpty(studentfileView.Career))
  1466. student.Career = studentfileView.Career;
  1467. if (!string.IsNullOrEmpty(studentfileView.PhotoUrl))
  1468. {
  1469. student.PhotoUrl = studentfileView.PhotoUrl;
  1470. }
  1471. student.PlanningGraduateDate = studentfileView.PlanningGraduateDate ?? studentfileView.PlanningGraduateDateStr;
  1472. //if (student.PlanningGraduateDate == null)
  1473. //{
  1474. // var GradeMajorID = ClassmajorRepository.Value.Entities.Where(x => x.ClassmajorID == studentfileView.ClassMajorID).FirstOrDefault().GrademajorID;
  1475. // student.PlanningGraduateDate = Convert.ToDateTime(GetPlanningGraduate(GradeMajorID.Value));
  1476. //}
  1477. if (!string.IsNullOrEmpty(studentfileView.StudentCardNo))
  1478. student.StudentCardNo = studentfileView.StudentCardNo;
  1479. //毕、结业证书编号
  1480. if (!string.IsNullOrEmpty(studentfileView.GraduateCardNo))
  1481. student.GraduateCardNo = studentfileView.GraduateCardNo;
  1482. if (studentfileView.CultureModel != null)
  1483. student.CultureModel = studentfileView.CultureModel;
  1484. if (studentfileView.StudentType != null)
  1485. student.StudentType = studentfileView.StudentType;
  1486. if (studentfileView.StudentStatus != null)
  1487. student.StudentStatus = studentfileView.StudentStatus;
  1488. if (studentfileView.InSchoolStatusID != null)
  1489. student.InSchoolStatusID = studentfileView.InSchoolStatusID;
  1490. student.Sys_User.Sys_Role = new HashSet<Sys_Role>();
  1491. roleList = roleList.Where(x => x.CF_StudentRole.StudentType == student.StudentType).ToList();
  1492. roleList.ForEach(x => student.Sys_User.Sys_Role.Add(x));
  1493. if (!string.IsNullOrEmpty(studentfileView.GraduationPictureUrl))
  1494. {
  1495. student.CF_StudentProfile.GraduationPictureUrl = studentfileView.GraduationPictureUrl;
  1496. }
  1497. if (!string.IsNullOrEmpty(studentfileView.UsedName))
  1498. student.CF_StudentProfile.UsedName = studentfileView.UsedName;
  1499. if (!string.IsNullOrEmpty(studentfileView.DirectorName))
  1500. student.CF_StudentProfile.DirectorName = studentfileView.DirectorName;
  1501. if (studentfileView.BirthDate != null)
  1502. student.CF_StudentProfile.BirthDate = studentfileView.BirthDate;
  1503. if (!string.IsNullOrEmpty(studentfileView.Country))
  1504. student.CF_StudentProfile.Country = studentfileView.Country;
  1505. if (studentfileView.Politics != null)
  1506. student.CF_StudentProfile.Politics = studentfileView.Politics;
  1507. if (studentfileView.Nation != null)
  1508. student.CF_StudentProfile.Nation = studentfileView.Nation;
  1509. if (!string.IsNullOrEmpty(studentfileView.Place))
  1510. student.CF_StudentProfile.Place = studentfileView.Place;
  1511. if (studentfileView.Healthy != null)
  1512. student.CF_StudentProfile.Healthy = studentfileView.Healthy;
  1513. if (studentfileView.BloodGroup != null)
  1514. student.CF_StudentProfile.BloodGroup = studentfileView.BloodGroup;
  1515. //studentProfile.BornPlace = studentfileView.BornPlace;
  1516. if (!string.IsNullOrEmpty(studentfileView.Specialty))
  1517. student.CF_StudentProfile.Specialty = studentfileView.Specialty;
  1518. if (!string.IsNullOrEmpty(studentfileView.Height))
  1519. student.CF_StudentProfile.Height = studentfileView.Height;
  1520. if (!string.IsNullOrEmpty(studentfileView.Weight))
  1521. student.CF_StudentProfile.Weight = studentfileView.Weight;
  1522. if (!string.IsNullOrEmpty(studentfileView.Remarks))
  1523. student.CF_StudentProfile.Remarks = studentfileView.Remarks;
  1524. if (!string.IsNullOrEmpty(studentfileView.Email))
  1525. student.CF_StudentContact.Email = studentfileView.Email;
  1526. if (!string.IsNullOrEmpty(studentfileView.QQ))
  1527. student.CF_StudentContact.QQ = studentfileView.QQ;
  1528. if (!string.IsNullOrEmpty(studentfileView.Mobile))
  1529. student.CF_StudentContact.Mobile = studentfileView.Mobile;
  1530. if (!string.IsNullOrEmpty(studentfileView.Telephone))
  1531. student.CF_StudentContact.Telephone = studentfileView.Telephone;
  1532. if (!string.IsNullOrEmpty(studentfileView.MicroMsgNo))
  1533. student.CF_StudentContact.MicroMsgNo = studentfileView.MicroMsgNo;
  1534. if (!string.IsNullOrEmpty(studentfileView.ZipCode))
  1535. student.CF_StudentContact.Zipcode = studentfileView.ZipCode;
  1536. if (!string.IsNullOrEmpty(studentfileView.Address))
  1537. student.CF_StudentContact.Address = studentfileView.Address;
  1538. if (!string.IsNullOrEmpty(studentfileView.WorkUnit))
  1539. student.CF_StudentContact.WorkUnit = studentfileView.WorkUnit;
  1540. if (!string.IsNullOrEmpty(studentfileView.HomeAddress))
  1541. student.CF_StudentContact.HomeAddress = studentfileView.HomeAddress;
  1542. if (!string.IsNullOrEmpty(studentfileView.Recipient))
  1543. student.CF_StudentContact.Recipient = studentfileView.Recipient;
  1544. if (!string.IsNullOrEmpty(studentfileView.Dormitory))
  1545. student.CF_StudentContact.Dormitory = studentfileView.Dormitory;
  1546. if (!string.IsNullOrEmpty(studentfileView.CardNo))
  1547. student.CF_StudentAccount.CardNo = studentfileView.CardNo;
  1548. if (!string.IsNullOrEmpty(studentfileView.BankName))
  1549. student.CF_StudentAccount.BankName = studentfileView.BankName;
  1550. if (studentfileView.EntranceDate != null)
  1551. student.CF_Recruitstudents.EntranceDate = studentfileView.EntranceDate;
  1552. if (studentfileView.EntranceWay != null)
  1553. student.CF_Recruitstudents.EntranceWay = studentfileView.EntranceWay;
  1554. if (!string.IsNullOrEmpty(studentfileView.ExamineeNum))
  1555. student.CF_Recruitstudents.ExamineeNum = studentfileView.ExamineeNum;
  1556. if (!string.IsNullOrEmpty(studentfileView.Placebirth))
  1557. student.CF_Recruitstudents.PlaceBirth = studentfileView.Placebirth;
  1558. if (studentfileView.ExamineeType != null)
  1559. student.CF_Recruitstudents.ExamineeType = studentfileView.ExamineeType;
  1560. if (studentfileView.Features != null)
  1561. student.CF_Recruitstudents.Features = studentfileView.Features;
  1562. if (studentfileView.Score != null)
  1563. student.CF_Recruitstudents.Score = studentfileView.Score;
  1564. if (studentfileView.Territorial != null)
  1565. student.CF_Recruitstudents.Territorial = studentfileView.Territorial;
  1566. if (!string.IsNullOrEmpty(studentfileView.Area))
  1567. student.CF_Recruitstudents.Area = studentfileView.Area;
  1568. if (studentfileView.EnteringSchoolYearID != null)
  1569. student.CF_Recruitstudents.EnteringSchoolYearID = studentfileView.EnteringSchoolYearID;
  1570. }
  1571. /// <summary>
  1572. /// 导入新增
  1573. /// </summary>
  1574. /// <param name="studentfileView"></param>
  1575. /// <param name="tempView"></param>
  1576. /// <param name="parameter"></param>
  1577. /// <param name="roleList"></param>
  1578. private void SaveInternalForImport(List<StudentsView> studentfileView, BaseStudentView tempView, CF_Parameter parameter,
  1579. IList<Sys_Role> roleList)
  1580. {
  1581. List<Guid> StudentID=new List<Guid>();
  1582. List<Sys_User> userList=new List<Sys_User>();
  1583. List<CF_Student> studentList=new List<CF_Student>(); //获取学生信息
  1584. List<CF_StudentProfile> studentProfileList = new List<CF_StudentProfile>();
  1585. List<CF_StudentContact> studentContactList= new List<CF_StudentContact>();
  1586. List<CF_StudentAccount> studentAccountList =new List<CF_StudentAccount>();
  1587. List<CF_Recruitstudents> recruitstudentsList = new List<CF_Recruitstudents>();
  1588. for (int i = 0; i < studentfileView.Count(); i++)
  1589. {
  1590. var pwd="";
  1591. if (parameter == null)
  1592. {
  1593. pwd = ("888888").MD5();
  1594. }
  1595. else
  1596. {
  1597. if (parameter.Value != null)
  1598. {
  1599. pwd = parameter.Value;
  1600. }
  1601. else
  1602. {
  1603. pwd = ("888888").MD5();
  1604. }
  1605. }
  1606. Sys_User user=new Sys_User();
  1607. int? tpye=null;
  1608. user.LoginID=studentfileView[i].IDNumber;//岭南LoginID为证件号码
  1609. if (!string.IsNullOrEmpty(studentfileView[i].UserName))
  1610. user.Name = studentfileView[i].UserName;
  1611. if (studentfileView[i].StudentType != null)
  1612. tpye= studentfileView[i].StudentType;
  1613. user.Sys_Role = new HashSet<Sys_Role>();
  1614. roleList = roleList.Where(x => x.CF_StudentRole.StudentType == tpye).ToList();
  1615. roleList.ForEach(x => user.Sys_Role.Add(x));
  1616. userList.Add(new Sys_User
  1617. {
  1618. UserID = Guid.NewGuid(),
  1619. Password = pwd,
  1620. CreateTime=DateTime.Now,
  1621. LoginID = user.LoginID,
  1622. Name = user.Name,
  1623. RecordStatus=(int)SYS_STATUS.USABLE,
  1624. Sys_Role=user.Sys_Role
  1625. });
  1626. StudentID.Add(userList[i].UserID);
  1627. CF_Student students =new CF_Student();
  1628. students.UserID=userList[i].UserID;
  1629. if (studentfileView[i].ClassMajorID != null)
  1630. students.ClassmajorID = studentfileView[i].ClassMajorID;
  1631. if (studentfileView[i].Sex != null)
  1632. students.Sex = (int)studentfileView[i].Sex;
  1633. if (studentfileView[i].CertificatesType != null)
  1634. students.CertificatesType = studentfileView[i].CertificatesType;
  1635. if (!string.IsNullOrEmpty(studentfileView[i].IDNumber))
  1636. students.IDNumber = studentfileView[i].IDNumber;
  1637. if (studentfileView[i].IsDreamProject)
  1638. students.IsDreamProject = studentfileView[i].IsDreamProject;
  1639. if (!string.IsNullOrEmpty(studentfileView[i].Career))
  1640. students.Career = studentfileView[i].Career;
  1641. if (!string.IsNullOrEmpty(studentfileView[i].PhotoUrl))
  1642. {
  1643. students.PhotoUrl = studentfileView[i].PhotoUrl;
  1644. }
  1645. students.PlanningGraduateDate = studentfileView[i].PlanningGraduateDate ?? studentfileView[i].PlanningGraduateDateStr;
  1646. //if (students.PlanningGraduateDate == null)
  1647. //{
  1648. // var GradeMajorID = ClassmajorRepository.Value.Entities.Where(x => x.ClassmajorID == studentfileView[i].ClassMajorID).FirstOrDefault().GrademajorID;
  1649. // students.PlanningGraduateDate = Convert.ToDateTime(GetPlanningGraduate(GradeMajorID.Value));
  1650. //}
  1651. if (!string.IsNullOrEmpty(studentfileView[i].StudentCardNo))
  1652. students.StudentCardNo = studentfileView[i].StudentCardNo;
  1653. //毕、结业证书编号
  1654. if (!string.IsNullOrEmpty(studentfileView[i].GraduateCardNo))
  1655. students.GraduateCardNo = studentfileView[i].GraduateCardNo;
  1656. if (studentfileView[i].CultureModel != null)
  1657. students.CultureModel = studentfileView[i].CultureModel;
  1658. if (studentfileView[i].StudentType != null)
  1659. students.StudentType = studentfileView[i].StudentType;
  1660. if (studentfileView[i].StudentStatus != null)
  1661. students.StudentStatus = studentfileView[i].StudentStatus;
  1662. if (studentfileView[i].InSchoolStatusID != null)
  1663. students.InSchoolStatusID = studentfileView[i].InSchoolStatusID;
  1664. studentList.Add(new CF_Student
  1665. {
  1666. UserID = students.UserID,
  1667. ClassmajorID = students.ClassmajorID,
  1668. Sex = students.Sex,
  1669. CertificatesType = students.CertificatesType,
  1670. IDNumber = students.IDNumber,
  1671. IsDreamProject = students.IsDreamProject,
  1672. Career = students.Career,
  1673. PhotoUrl = students.PhotoUrl,
  1674. PlanningGraduateDate = students.PlanningGraduateDate,
  1675. StudentCardNo = students.StudentCardNo,
  1676. GraduateCardNo = students.GraduateCardNo,
  1677. CultureModel = students.CultureModel,
  1678. StudentType = students.StudentType,
  1679. StudentStatus = students.StudentStatus,
  1680. InSchoolStatusID = students.InSchoolStatusID,
  1681. CreateTime = DateTime.Now,
  1682. RecordStatus = (int)SYS_STATUS.USABLE
  1683. });
  1684. CF_StudentProfile studentProfile = new CF_StudentProfile();
  1685. if (!string.IsNullOrEmpty(studentfileView[i].GraduationPictureUrl))
  1686. {
  1687. studentProfile.GraduationPictureUrl = studentfileView[i].GraduationPictureUrl;
  1688. }
  1689. if (!string.IsNullOrEmpty(studentfileView[i].UsedName))
  1690. studentProfile.UsedName = studentfileView[i].UsedName;
  1691. if (!string.IsNullOrEmpty(studentfileView[i].DirectorName))
  1692. studentProfile.DirectorName = studentfileView[i].DirectorName;
  1693. if (studentfileView[i].BirthDate != null)
  1694. studentProfile.BirthDate = studentfileView[i].BirthDate;
  1695. if (!string.IsNullOrEmpty(studentfileView[i].Country))
  1696. studentProfile.Country = studentfileView[i].Country;
  1697. if (studentfileView[i].Politics != null)
  1698. studentProfile.Politics = studentfileView[i].Politics;
  1699. if (studentfileView[i].Nation != null)
  1700. studentProfile.Nation = studentfileView[i].Nation;
  1701. if (!string.IsNullOrEmpty(studentfileView[i].Place))
  1702. studentProfile.Place = studentfileView[i].Place;
  1703. if (studentfileView[i].Healthy != null)
  1704. studentProfile.Healthy = studentfileView[i].Healthy;
  1705. if (studentfileView[i].BloodGroup != null)
  1706. studentProfile.BloodGroup = studentfileView[i].BloodGroup;
  1707. //studentProfile.BornPlace = studentfileView.BornPlace;
  1708. if (!string.IsNullOrEmpty(studentfileView[i].Specialty))
  1709. studentProfile.Specialty = studentfileView[i].Specialty;
  1710. if (!string.IsNullOrEmpty(studentfileView[i].Height))
  1711. studentProfile.Height = studentfileView[i].Height;
  1712. if (!string.IsNullOrEmpty(studentfileView[i].Weight))
  1713. studentProfile.Weight = studentfileView[i].Weight;
  1714. if (!string.IsNullOrEmpty(studentfileView[i].Remarks))
  1715. studentProfile.Remarks = studentfileView[i].Remarks;
  1716. studentProfileList.Add(new CF_StudentProfile
  1717. {
  1718. UserID = students.UserID,
  1719. UsedName = studentProfile.UsedName,
  1720. GraduationPictureUrl=studentProfile.GraduationPictureUrl,
  1721. DirectorName=studentProfile.DirectorName,
  1722. BirthDate=studentProfile.BirthDate,
  1723. Country=studentProfile.Country,
  1724. Politics=studentProfile.Politics,
  1725. Nation=studentProfile.Nation,
  1726. Place=studentProfile.Place,
  1727. Healthy=studentProfile.Healthy,
  1728. BloodGroup=studentProfile.BloodGroup,
  1729. Specialty=studentProfile.Specialty,
  1730. Height=studentProfile.Height,
  1731. Weight=studentProfile.Weight,
  1732. Remarks = studentProfile.Remarks,
  1733. CreateTime = DateTime.Now,
  1734. RecordStatus = (int)SYS_STATUS.USABLE
  1735. });
  1736. CF_StudentContact studentContact = new CF_StudentContact();
  1737. if (!string.IsNullOrEmpty(studentfileView[i].Email))
  1738. studentContact.Email = studentfileView[i].Email;
  1739. if (!string.IsNullOrEmpty(studentfileView[i].QQ))
  1740. studentContact.QQ = studentfileView[i].QQ;
  1741. if (!string.IsNullOrEmpty(studentfileView[i].Mobile))
  1742. studentContact.Mobile = studentfileView[i].Mobile;
  1743. if (!string.IsNullOrEmpty(studentfileView[i].Telephone))
  1744. studentContact.Telephone = studentfileView[i].Telephone;
  1745. if (!string.IsNullOrEmpty(studentfileView[i].MicroMsgNo))
  1746. studentContact.MicroMsgNo = studentfileView[i].MicroMsgNo;
  1747. if (!string.IsNullOrEmpty(studentfileView[i].ZipCode))
  1748. studentContact.Zipcode = studentfileView[i].ZipCode;
  1749. if (!string.IsNullOrEmpty(studentfileView[i].Address))
  1750. studentContact.Address = studentfileView[i].Address;
  1751. if (!string.IsNullOrEmpty(studentfileView[i].WorkUnit))
  1752. studentContact.WorkUnit = studentfileView[i].WorkUnit;
  1753. if (!string.IsNullOrEmpty(studentfileView[i].HomeAddress))
  1754. studentContact.HomeAddress = studentfileView[i].HomeAddress;
  1755. if (!string.IsNullOrEmpty(studentfileView[i].Recipient))
  1756. studentContact.Recipient = studentfileView[i].Recipient;
  1757. if (!string.IsNullOrEmpty(studentfileView[i].Dormitory))
  1758. studentContact.Dormitory = studentfileView[i].Dormitory;
  1759. studentContactList.Add(new CF_StudentContact
  1760. {
  1761. UserID = students.UserID,
  1762. Email=studentContact.Email,
  1763. QQ=studentContact.QQ,
  1764. Mobile=studentContact.Mobile,
  1765. Telephone=studentContact.Telephone,
  1766. MicroMsgNo=studentContact.MicroMsgNo,
  1767. Zipcode=studentContact.Zipcode,
  1768. Address=studentContact.Address,
  1769. WorkUnit=studentContact.WorkUnit,
  1770. HomeAddress=studentContact.HomeAddress,
  1771. Recipient=studentContact.Recipient,
  1772. Dormitory=studentContact.Dormitory,
  1773. CreateTime = DateTime.Now,
  1774. RecordStatus = (int)SYS_STATUS.USABLE
  1775. });
  1776. CF_StudentAccount studentAccount=new CF_StudentAccount();
  1777. if (!string.IsNullOrEmpty(studentfileView[i].CardNo))
  1778. studentAccount.CardNo = studentfileView[i].CardNo;
  1779. if (!string.IsNullOrEmpty(studentfileView[i].BankName))
  1780. studentAccount.BankName = studentfileView[i].BankName;
  1781. studentAccountList.Add(new CF_StudentAccount
  1782. {
  1783. UserID = students.UserID,
  1784. CardNo=studentAccount.CardNo,
  1785. BankName=studentAccount.BankName,
  1786. CreateTime = DateTime.Now,
  1787. RecordStatus = (int)SYS_STATUS.USABLE
  1788. });
  1789. CF_Recruitstudents recruitstudents = new CF_Recruitstudents();
  1790. if (studentfileView[i].EntranceDate != null)
  1791. recruitstudents.EntranceDate = studentfileView[i].EntranceDate;
  1792. if (studentfileView[i].EntranceWay != null)
  1793. recruitstudents.EntranceWay = studentfileView[i].EntranceWay;
  1794. if (!string.IsNullOrEmpty(studentfileView[i].ExamineeNum))
  1795. recruitstudents.ExamineeNum = studentfileView[i].ExamineeNum;
  1796. if (!string.IsNullOrEmpty(studentfileView[i].Placebirth))
  1797. recruitstudents.PlaceBirth = studentfileView[i].Placebirth;
  1798. if (studentfileView[i].ExamineeType != null)
  1799. recruitstudents.ExamineeType = studentfileView[i].ExamineeType;
  1800. if (studentfileView[i].Features != null)
  1801. recruitstudents.Features = studentfileView[i].Features;
  1802. if (studentfileView[i].Score != null)
  1803. recruitstudents.Score = studentfileView[i].Score;
  1804. if (studentfileView[i].Territorial != null)
  1805. recruitstudents.Territorial = studentfileView[i].Territorial;
  1806. if (!string.IsNullOrEmpty(studentfileView[i].Area))
  1807. recruitstudents.Area = studentfileView[i].Area;
  1808. if (studentfileView[i].EnteringSchoolYearID != null)
  1809. recruitstudents.EnteringSchoolYearID = studentfileView[i].EnteringSchoolYearID;
  1810. recruitstudentsList.Add(new CF_Recruitstudents
  1811. {
  1812. UserID = students.UserID,
  1813. EntranceDate=recruitstudents.EntranceDate,
  1814. EntranceWay=recruitstudents.EntranceWay,
  1815. ExamineeNum=recruitstudents.ExamineeNum,
  1816. PlaceBirth=recruitstudents.PlaceBirth,
  1817. ExamineeType=recruitstudents.ExamineeType,
  1818. Features=recruitstudents.Features,
  1819. Score=recruitstudents.Score,
  1820. Territorial=recruitstudents.Territorial,
  1821. Area=recruitstudents.Area,
  1822. EnteringSchoolYearID=recruitstudents.EnteringSchoolYearID,
  1823. CreateTime = DateTime.Now,
  1824. RecordStatus = (int)SYS_STATUS.USABLE
  1825. });
  1826. }
  1827. UnitOfWork.BulkInsert(userList);
  1828. UnitOfWork.BulkInsert(userList, (x => x.Sys_Role));
  1829. UnitOfWork.BulkInsert(studentList);
  1830. UnitOfWork.BulkInsert(studentProfileList);
  1831. UnitOfWork.BulkInsert(studentContactList);
  1832. UnitOfWork.BulkInsert(studentAccountList);
  1833. UnitOfWork.BulkInsert(recruitstudentsList);
  1834. }
  1835. public IGridResultSet<BaseStudentView> GetBaseStudentView(ViewModel.ConfiguretView configuretView, Guid? collegeID, Guid? grademajorID, Guid? classmajorID, Guid? userID, int pageIndex, int pageSize)
  1836. {
  1837. Expression<Func<CF_Student, bool>> filter = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1838. if (collegeID.HasValue)
  1839. filter = filter.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  1840. if (grademajorID.HasValue)
  1841. filter = filter.And(x => x.CF_Classmajor.GrademajorID == grademajorID);
  1842. if (classmajorID.HasValue)
  1843. filter = filter.And(x => x.ClassmajorID == classmajorID);
  1844. if (userID.HasValue)
  1845. {
  1846. filter = filter.And(x => x.UserID == userID);
  1847. }
  1848. var query = StudentsDAL.Value.GetBaseStudentViewQueryable(filter);
  1849. //查询条件
  1850. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  1851. {
  1852. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  1853. }
  1854. return query
  1855. .OrderByDescending(x => x.LoginID.Length).ThenBy(x => x.LoginID)
  1856. .ThenBy(x => x.ClassmajorCode.Length).ThenBy(x => x.ClassmajorCode)
  1857. .ToGridResultSet<BaseStudentView>(pageIndex, pageSize);
  1858. }
  1859. public DateTime? ReckonPlanningGraduateDate(Guid GrademajorID)
  1860. {
  1861. //由于LINQ不识别方法的系统的时间 ToDateTime(系统,字符串)的方法、将计算时间移至外围
  1862. StudentsView studentsEntity = StudentsDAL.Value.GetPlanningGraduateDate(GrademajorID);
  1863. return studentsEntity.PlanningGraduateDate.Value.AddDays(studentsEntity.WeeksNum);
  1864. }
  1865. //private DateTime GetPlanningGraduate(DateTime firstWeek)
  1866. //{
  1867. // if (firstWeek.Month >= 1 && firstWeek.Month <= 6)
  1868. // {
  1869. // return new DateTime(firstWeek.Year, 6, 30);
  1870. // }
  1871. // else
  1872. // {
  1873. // return new DateTime((firstWeek.Year + 1), 1, 31);
  1874. // }
  1875. //}
  1876. public string GetPlanningGraduate(Guid GrademajorID)
  1877. {
  1878. var graduationSchoolyear = this.SchoolyearRepository.Value.GetSingle(x => x.CF_Grademajor.Any(w => w.GrademajorID == GrademajorID));
  1879. if (graduationSchoolyear != null)
  1880. {
  1881. var date = PlanningGraduateDateHelper.GetPlanningGraduateDate(graduationSchoolyear.FirstWeek);
  1882. return date.ToString("yyyy-MM-dd");
  1883. }
  1884. else
  1885. {
  1886. return null;
  1887. }
  1888. //return GetPlanningGraduate(graduationSchoolyear.FirstWeek).ToString("yyyy-MM-dd");
  1889. //StudentsView studentsEntity = StudentsDAL.Value.GetPlanningGraduate(GrademajorID);
  1890. //int PlanningGraduate = (int)studentsEntity.Years;
  1891. //try
  1892. //{
  1893. // string SetPlanningGraduate;
  1894. // if (studentsEntity.PlanningGraduateSchoolCode == (int)EMIS.ViewModel.CF_Schoolcode.Spring)
  1895. // {
  1896. // SetPlanningGraduate = studentsEntity.PlanningGraduateYear.ToString() + "-06-30";
  1897. // }
  1898. // else if (studentsEntity.PlanningGraduateSchoolCode == (int)EMIS.ViewModel.CF_Schoolcode.Autumn)
  1899. // { //因秋季是跨年,毕业年份需要+1年
  1900. // SetPlanningGraduate = (studentsEntity.PlanningGraduateYear + 1).ToString() + "-01-31";
  1901. // }
  1902. // else
  1903. // throw new Exception("学期设置有问题,请核查");
  1904. // return SetPlanningGraduate;
  1905. //}
  1906. //catch
  1907. //{
  1908. // return "";
  1909. //}
  1910. //预计毕业时间,原来逻辑有问题,默认值为2016-01-31+30个月也就是2018-07-31,当学制不为3或2.5时,返回2018-07-31+学制年数:邓智荣
  1911. //DateTime SetPlanningGraduate = Convert.ToDateTime("2016-01-31").AddMonths(30);
  1912. //DateTime SetPlanningGraduate = Convert.ToDateTime(PlanningGraduate.ToString() + "-06-30");
  1913. //if (studentsEntity.LearnSystem == 3)
  1914. //{
  1915. // SetPlanningGraduate = Convert.ToDateTime(PlanningGraduate + "-06-30");
  1916. // // SetPlanningGraduate.AddYears((int)studentsEntity.LearnSystem);
  1917. //}
  1918. //if (studentsEntity.LearnSystem == (Decimal)2.5)
  1919. //{
  1920. // SetPlanningGraduate = Convert.ToDateTime(PlanningGraduate + "-01-31");
  1921. // // SetPlanningGraduate.AddMonths((int)studentsEntity.LearnSystem * 12);
  1922. //}
  1923. ////原逻辑只有学制2.5和3的判断,现加上2和4
  1924. //if (studentsEntity.LearnSystem == 2 || studentsEntity.LearnSystem == 4)
  1925. //{
  1926. // SetPlanningGraduate = Convert.ToDateTime(PlanningGraduate + "-06-30");
  1927. //}
  1928. //if (Convert.ToInt32(studentsEntity.LearnSystem) == studentsEntity.LearnSystem)
  1929. //{ //2、3或4年制
  1930. // SetPlanningGraduate = Convert.ToDateTime(PlanningGraduate + "-06-30");
  1931. //}
  1932. //else
  1933. //{ //2.5或3.5年制
  1934. // SetPlanningGraduate = Convert.ToDateTime(PlanningGraduate + "-01-31");
  1935. //}
  1936. //return SetPlanningGraduate.AddYears((int)studentsEntity.LearnSystem);//2.5 转int 2
  1937. }
  1938. public IGridResultSet<StudentsView> GetPlanningGraduateList()
  1939. {
  1940. Dictionary<int, DateTime?> diction = new Dictionary<int, DateTime?>();
  1941. //int key = 0;
  1942. var query = StudentsDAL.Value.GetPlanningGraduateDictionary().Where(x => x.PlanningGraduateDate != null);
  1943. List<DateTime?> list = query.Select(x => x.PlanningGraduateDate).OrderBy(x => x.Value).ToList();
  1944. List<StudentsView> stulist = query.OrderBy(x => x.PlanningGraduateDate).ToList();
  1945. List<string> datestr = new List<string>();
  1946. for (int i = 0; i < stulist.Count; i++)
  1947. {
  1948. stulist[i].PlanningGraduateStr = list[i].Value.ToString("yyyyMMdd");
  1949. }
  1950. //List<string> dictionList = query.Select(x => x.PlanningGraduateStr).ToList();
  1951. //foreach(DateTime date in dictionList)
  1952. //{
  1953. // diction.Add(key, date);
  1954. // key++;
  1955. //}
  1956. return stulist.AsQueryable().ToGridResultSet<StudentsView>();
  1957. }
  1958. public void ClearPhotoUrl(IList<Guid> studentIDList)
  1959. {
  1960. this.UnitOfWork.Update<CF_Student>((x => new CF_Student { PhotoUrl = null }), (x => studentIDList.Contains(x.UserID)));
  1961. }
  1962. public virtual int? GetDefaultLearnformForList()
  1963. {
  1964. return null;
  1965. }
  1966. public StudentsView GetStudentViewByLoginID(string loginID){
  1967. var student = StudentsDAL.Value.GetStudentQueryable(x => x.Sys_User.LoginID == loginID).FirstOrDefault();
  1968. return student;
  1969. }
  1970. public StudentsView GetStudentViewByIDNum(string idNum)
  1971. {
  1972. var student = StudentsDAL.Value.GetStudentQueryable(x => x.IDNumber == idNum).FirstOrDefault();
  1973. return student;
  1974. }
  1975. public int GetDataRange()
  1976. {
  1977. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  1978. var curUserID = curUser.UserID;
  1979. if (curUser.IsStudent)
  1980. {
  1981. return 6;
  1982. }
  1983. var menuNo = HttpHelper.GetMenuNo();
  1984. if (string.IsNullOrEmpty(menuNo))
  1985. {
  1986. menuNo = HttpContext.Current.Request.UrlReferrer.GetQueryStringByPath("FromMNU");
  1987. }
  1988. SYS_DataRange dataRange = DataRangeDAL.GetRoleDataRange(curUser.RoleID, menuNo);
  1989. switch (dataRange)
  1990. {
  1991. case SYS_DataRange.All:
  1992. default:
  1993. return (int)SYS_DataRange.All;
  1994. case SYS_DataRange.Campus:
  1995. return (int)SYS_DataRange.Campus;
  1996. case SYS_DataRange.College:
  1997. return (int)SYS_DataRange.College;
  1998. case SYS_DataRange.Department:
  1999. return (int)SYS_DataRange.Department;
  2000. case SYS_DataRange.Teacher:
  2001. return (int)SYS_DataRange.Teacher;
  2002. case SYS_DataRange.Assistant:
  2003. return (int)SYS_DataRange.Assistant;
  2004. }
  2005. }
  2006. public IGridResultSet<BaseStudentView> GetStudentOnlyInSchool(ConfiguretView configuretView, int pageIndex, int pageSize)
  2007. {
  2008. Expression<Func<CF_Student, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.InSchoolStatusID == (int)CF_InschoolStatus.InSchool);
  2009. Expression<Func<CF_Classmajor, bool>> classexp = (x => true);
  2010. Expression<Func<CF_Grademajor, bool>> gradeexp = (x => true);
  2011. var query = StudentsDAL.Value.GetInSchoolStudentViewQueryable(exp);
  2012. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  2013. {
  2014. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  2015. }
  2016. return query.OrderBy(x => x.ClassmajorCode.Length).ThenBy(x => x.ClassmajorCode).ThenBy(x => x.LoginID).ToGridResultSet<BaseStudentView>(pageIndex, pageSize);
  2017. }
  2018. /// <summary>
  2019. /// 查询列表
  2020. /// </summary>
  2021. /// <param name="configuretView"></param>
  2022. /// <param name="campusID">校区ID</param>
  2023. /// <param name="collegeID">院系所ID</param>
  2024. /// <param name="educationID">培养层次ID</param>
  2025. /// <param name="years">学年</param>
  2026. /// <param name="standardID">招生专业ID</param>
  2027. /// <param name="learnFormID">学习形式ID</param>
  2028. /// <param name="classMajorID">班级ID</param>
  2029. /// <param name="Shoolstatu">在校状态ID</param>
  2030. /// <param name="isPhotos">是否有照片</param>
  2031. /// <param name="graduationtmentDropdown">是否毕业学生</param>
  2032. /// <param name="pageIndex"></param>
  2033. /// <param name="pageSize"></param>
  2034. /// <returns></returns>
  2035. public IGridResultSet<StudentsView> GetStudentUserViewList(ConfiguretView configuretView,
  2036. int? campusID, Guid? collegeID, int? education, int? years, int? standardID, int? learningformID, int? classNum, int? studentStatusID, bool? isPhotos,
  2037. bool? isOnlyGraduation, bool? isPreviousNotGraduated, int pageIndex, int pageSize)
  2038. {
  2039. var currentSchoolyear = SchoolYearServices.Value.GetCurrentSchoolYear();
  2040. var inschoolStatusList = InSchoolSettingRepository.Value.GetList(x => x.IsSelected == true)
  2041. .Select(x => x.InSchoolStatusID).Distinct().ToList();
  2042. Expression<Func<CF_Student, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && inschoolStatusList.Contains(x.InSchoolStatusID));
  2043. Expression<Func<CF_Classmajor, bool>> classexp = (x => true);
  2044. Expression<Func<CF_Grademajor, bool>> gradeexp = (x => true);
  2045. if (campusID.HasValue)
  2046. {
  2047. gradeexp = gradeexp.And(x => x.SchoolAreaID == campusID);
  2048. }
  2049. if (collegeID.HasValue)
  2050. {
  2051. gradeexp = gradeexp.And(x => x.CF_Facultymajor.CollegeID == collegeID);
  2052. }
  2053. if (education.HasValue)
  2054. {
  2055. gradeexp = gradeexp.And(x => x.CF_Facultymajor.EducationID == education.Value);
  2056. }
  2057. if (years.HasValue)
  2058. {
  2059. gradeexp = gradeexp.And(x => x.SchoolyearID == years);
  2060. }
  2061. if (standardID.HasValue)
  2062. {
  2063. gradeexp = gradeexp.And(x => x.CF_Facultymajor.StandardID == standardID);
  2064. }
  2065. if (learningformID.HasValue)
  2066. {
  2067. gradeexp = gradeexp.And(x => x.CF_Facultymajor.LearningformID == learningformID);
  2068. }
  2069. if (classNum.HasValue)
  2070. {
  2071. classexp = classexp.And(x => x.ClassNum == classNum);
  2072. }
  2073. if (studentStatusID.HasValue)
  2074. {
  2075. exp = exp.And(x => x.StudentStatus == studentStatusID);
  2076. }
  2077. if (isPhotos.HasValue)
  2078. {
  2079. if (isPhotos.Value)
  2080. {
  2081. exp = exp.And(x => x.PhotoUrl != null);
  2082. }
  2083. else
  2084. {
  2085. exp = exp.And(x => x.PhotoUrl == null);
  2086. }
  2087. }
  2088. if (isOnlyGraduation == true)
  2089. {
  2090. gradeexp = gradeexp.And(x => x.GraduatingSemesterID == currentSchoolyear.SchoolYearID);
  2091. }
  2092. if (isPreviousNotGraduated == true)
  2093. {
  2094. gradeexp = gradeexp.And(x => x.CF_Schoolyear.Value < currentSchoolyear.Value);
  2095. exp = exp.And(x => x.StudentStatus == (int)CF_STUDENTSTATUS.Complete && x.InSchoolStatusID == (int)CF_InschoolStatus.Complete);
  2096. }
  2097. var query = StudentsDAL.Value.GetStudentQueryable(exp, classexp, gradeexp);
  2098. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  2099. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  2100. return this.GetQueryByAssistant(query, (x => x.ClassMajorID), this.GetQueryByDataRangeByCollege(query)).OrderBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  2101. .ThenBy(x => x.ClassMajorCode).ThenBy(x => x.LoginID).ToGridResultSet<StudentsView>(pageIndex, pageSize);
  2102. }
  2103. public RegistView GetRegistViewByUserID(Guid userID)
  2104. {
  2105. var registView = StudentsDAL.Value.GetRegustViewQueryable(x => x.UserID == userID).FirstOrDefault();
  2106. return registView;
  2107. }
  2108. public bool CheckNecessary(Guid userID)
  2109. {
  2110. var registView = this.GetRegistViewByUserID(userID);
  2111. if (registView == null)
  2112. {
  2113. return false;
  2114. }
  2115. if (string.IsNullOrEmpty(registView.LoginID))
  2116. {
  2117. return false;
  2118. }
  2119. if (!registView.CertificatesType.HasValue)
  2120. {
  2121. return false;
  2122. }
  2123. if (string.IsNullOrEmpty(registView.UserName))
  2124. {
  2125. return false;
  2126. }
  2127. if (string.IsNullOrEmpty(registView.Mobile))
  2128. {
  2129. return false;
  2130. }
  2131. if (string.IsNullOrEmpty(registView.Email))
  2132. {
  2133. return false;
  2134. }
  2135. if (string.IsNullOrEmpty(registView.PhotoUrl))
  2136. {
  2137. return false;
  2138. }
  2139. if (!registView.Sex.HasValue)
  2140. {
  2141. return false;
  2142. }
  2143. if (!registView.BirthDate.HasValue)
  2144. {
  2145. return false;
  2146. }
  2147. return true;
  2148. }
  2149. }
  2150. }