StudentServices.cs 230 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Data;
  7. using System.Data.OleDb;
  8. using System.Linq.Expressions;
  9. using System.Transactions;
  10. using System.Globalization;
  11. using System.IO;
  12. using System.Web;
  13. using Bowin.Common;
  14. using Bowin.Common.Utility;
  15. using Bowin.Common.Linq;
  16. using Bowin.Common.Linq.Entity;
  17. using EMIS.Utility;
  18. using EMIS.Entities;
  19. using EMIS.ViewModel;
  20. using EMIS.ViewModel.CacheManage;
  21. using EMIS.ViewModel.StudentManage.StudentProfile;
  22. using EMIS.ViewModel.StudentManage.StudentRegister;
  23. using EMIS.ViewModel.StudentManage.StudentChange;
  24. using EMIS.DataLogic.StudentManage.StudentProfile;
  25. using EMIS.DataLogic.StudentManage.StudentRegister;
  26. using EMIS.DataLogic.StudentManage.StudentChange;
  27. using EMIS.DataLogic.SystemDAL;
  28. using EMIS.CommonLogic.SystemServices;
  29. using EMIS.CommonLogic.StudentManage.StudentStatistics;
  30. namespace EMIS.CommonLogic.StudentManage.StudentProfile
  31. {
  32. public class StudentServices : BaseWorkflowServices<CF_DifferentDynamic>, IStudentServices
  33. {
  34. public Lazy<StudentDAL> StudentDAL { get; set; }
  35. public Lazy<StudentReportDAL> StudentReportDAL { get; set; }
  36. public Lazy<StudentChangeDAL> StudentChangeDAL { get; set; }
  37. public Lazy<DataRangeDAL> DataRangeDAL { get; set; }
  38. public Lazy<IInSchoolSettingServices> InSchoolSettingServices { get; set; }
  39. /// <summary>
  40. /// 查询对应的学生信息StudentView
  41. /// </summary>
  42. /// <param name="configuretView"></param>
  43. /// <param name="campusID"></param>
  44. /// <param name="collegeID"></param>
  45. /// <param name="gradeID"></param>
  46. /// <param name="standardID"></param>
  47. /// <param name="educationID"></param>
  48. /// <param name="learningformID"></param>
  49. /// <param name="learnSystem"></param>
  50. /// <param name="classmajorID"></param>
  51. /// <param name="isPhoto"></param>
  52. /// <param name="reportStatus"></param>
  53. /// <param name="planningGraduateDate"></param>
  54. /// <param name="inSchoolStatus"></param>
  55. /// <param name="pageIndex"></param>
  56. /// <param name="pageSize"></param>
  57. /// <returns></returns>
  58. public IGridResultSet<StudentView> GetStudentViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID,
  59. int? learningformID, string learnSystem, Guid? classmajorID, int? isPhoto, int? reportStatus, string planningGraduateDate, int? inSchoolStatus, int pageIndex, int pageSize)
  60. {
  61. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  62. if (classmajorID.HasValue)
  63. {
  64. expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
  65. }
  66. if (isPhoto.HasValue)
  67. {
  68. if (isPhoto.Value == (int)CF_GeneralExist.Have)
  69. {
  70. expStudent = expStudent.And(x => x.PhotoUrl != null && x.PhotoUrl != "");
  71. }
  72. if (isPhoto.Value == (int)CF_GeneralExist.No)
  73. {
  74. expStudent = expStudent.And(x => x.PhotoUrl == null || x.PhotoUrl == "");
  75. }
  76. }
  77. if (!string.IsNullOrEmpty(planningGraduateDate) && planningGraduateDate != "-1")
  78. {
  79. DateTime planDate = DateTime.ParseExact(planningGraduateDate, "yyyyMMdd", CultureInfo.CurrentCulture);
  80. expStudent = expStudent.And(x => DateTime.Compare((DateTime)x.PlanningGraduateDate, planDate) == 0);
  81. }
  82. if (inSchoolStatus.HasValue)
  83. {
  84. expStudent = expStudent.And(x => x.InSchoolStatusID == inSchoolStatus);
  85. }
  86. var endStatusID = this.GetCorrectEndStatus();
  87. Expression<Func<CF_DifferentDynamic, bool>> expChange = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  88. expChange = expChange.And(x => x.ApprovalStatus == endStatusID);
  89. var query = StudentDAL.Value.GetStudentViewQueryable(expStudent, expChange);
  90. if (campusID.HasValue)
  91. {
  92. query = query.Where(x => x.CampusID == campusID);
  93. }
  94. if (collegeID.HasValue)
  95. {
  96. query = query.Where(x => x.CollegeID == collegeID);
  97. }
  98. if (gradeID.HasValue)
  99. {
  100. query = query.Where(x => x.GradeID == gradeID);
  101. }
  102. if (standardID.HasValue)
  103. {
  104. query = query.Where(x => x.StandardID == standardID);
  105. }
  106. if (educationID.HasValue)
  107. {
  108. query = query.Where(x => x.EducationID == educationID);
  109. }
  110. if (learningformID.HasValue)
  111. {
  112. query = query.Where(x => x.LearningformID == learningformID);
  113. }
  114. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  115. {
  116. var LearnSystems = Convert.ToDecimal(learnSystem);
  117. query = query.Where(x => x.LearnSystem == LearnSystems);
  118. }
  119. if (reportStatus.HasValue)
  120. {
  121. query = query.Where(x => x.ReportStatus == reportStatus);
  122. }
  123. //查询条件
  124. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  125. {
  126. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  127. }
  128. return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
  129. .OrderBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo)
  130. .ThenBy(x => x.GradeID).ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
  131. .ToGridResultSet<StudentView>(pageIndex, pageSize);
  132. }
  133. /// <summary>
  134. /// 查询对应的学生信息List
  135. /// </summary>
  136. /// <param name="configuretView"></param>
  137. /// <param name="campusID"></param>
  138. /// <param name="collegeID"></param>
  139. /// <param name="gradeID"></param>
  140. /// <param name="standardID"></param>
  141. /// <param name="educationID"></param>
  142. /// <param name="learningformID"></param>
  143. /// <param name="learnSystem"></param>
  144. /// <param name="classmajorID"></param>
  145. /// <param name="isPhoto"></param>
  146. /// <param name="reportStatus"></param>
  147. /// <param name="planningGraduateDate"></param>
  148. /// <param name="inSchoolStatus"></param>
  149. /// <returns></returns>
  150. public IList<StudentView> GetStudentViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID,
  151. int? learningformID, string learnSystem, Guid? classmajorID, int? isPhoto, int? reportStatus, string planningGraduateDate, int? inSchoolStatus)
  152. {
  153. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  154. if (classmajorID.HasValue)
  155. {
  156. expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
  157. }
  158. if (isPhoto.HasValue)
  159. {
  160. if (isPhoto.Value == (int)CF_GeneralExist.Have)
  161. {
  162. expStudent = expStudent.And(x => x.PhotoUrl != null && x.PhotoUrl != "");
  163. }
  164. if (isPhoto.Value == (int)CF_GeneralExist.No)
  165. {
  166. expStudent = expStudent.And(x => x.PhotoUrl == null || x.PhotoUrl == "");
  167. }
  168. }
  169. if (!string.IsNullOrEmpty(planningGraduateDate) && planningGraduateDate != "-1")
  170. {
  171. DateTime planDate = DateTime.ParseExact(planningGraduateDate, "yyyyMMdd", CultureInfo.CurrentCulture);
  172. expStudent = expStudent.And(x => DateTime.Compare((DateTime)x.PlanningGraduateDate, planDate) == 0);
  173. }
  174. if (inSchoolStatus.HasValue)
  175. {
  176. expStudent = expStudent.And(x => x.InSchoolStatusID == inSchoolStatus);
  177. }
  178. var endStatusID = this.GetCorrectEndStatus();
  179. Expression<Func<CF_DifferentDynamic, bool>> expChange = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  180. expChange = expChange.And(x => x.ApprovalStatus == endStatusID);
  181. var query = StudentDAL.Value.GetStudentViewQueryable(expStudent, expChange);
  182. if (campusID.HasValue)
  183. {
  184. query = query.Where(x => x.CampusID == campusID);
  185. }
  186. if (collegeID.HasValue)
  187. {
  188. query = query.Where(x => x.CollegeID == collegeID);
  189. }
  190. if (gradeID.HasValue)
  191. {
  192. query = query.Where(x => x.GradeID == gradeID);
  193. }
  194. if (standardID.HasValue)
  195. {
  196. query = query.Where(x => x.StandardID == standardID);
  197. }
  198. if (educationID.HasValue)
  199. {
  200. query = query.Where(x => x.EducationID == educationID);
  201. }
  202. if (learningformID.HasValue)
  203. {
  204. query = query.Where(x => x.LearningformID == learningformID);
  205. }
  206. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  207. {
  208. var LearnSystems = Convert.ToDecimal(learnSystem);
  209. query = query.Where(x => x.LearnSystem == LearnSystems);
  210. }
  211. if (reportStatus.HasValue)
  212. {
  213. query = query.Where(x => x.ReportStatus == reportStatus);
  214. }
  215. //查询条件
  216. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  217. {
  218. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  219. }
  220. return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
  221. .OrderBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo)
  222. .ThenBy(x => x.GradeID).ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
  223. .ToList();
  224. }
  225. /// <summary>
  226. /// 查询对应的学生信息List(userIDList)
  227. /// </summary>
  228. /// <param name="configuretView"></param>
  229. /// <param name="campusID"></param>
  230. /// <param name="collegeID"></param>
  231. /// <param name="gradeID"></param>
  232. /// <param name="standardID"></param>
  233. /// <param name="educationID"></param>
  234. /// <param name="learningformID"></param>
  235. /// <param name="learnSystem"></param>
  236. /// <param name="classmajorID"></param>
  237. /// <param name="isPhoto"></param>
  238. /// <param name="reportStatus"></param>
  239. /// <param name="planningGraduateDate"></param>
  240. /// <param name="inSchoolStatus"></param>
  241. /// <param name="userIDList"></param>
  242. /// <returns></returns>
  243. public IList<StudentView> GetStudentViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID,
  244. int? learningformID, string learnSystem, Guid? classmajorID, int? isPhoto, int? reportStatus, string planningGraduateDate, int? inSchoolStatus, List<Guid?> userIDList)
  245. {
  246. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  247. if (userIDList != null && userIDList.Count() > 0)
  248. {
  249. expStudent = expStudent.And(x => userIDList.Contains(x.UserID));
  250. }
  251. else
  252. {
  253. if (classmajorID.HasValue)
  254. {
  255. expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
  256. }
  257. if (isPhoto.HasValue)
  258. {
  259. if (isPhoto.Value == (int)CF_GeneralExist.Have)
  260. {
  261. expStudent = expStudent.And(x => x.PhotoUrl != null && x.PhotoUrl != "");
  262. }
  263. if (isPhoto.Value == (int)CF_GeneralExist.No)
  264. {
  265. expStudent = expStudent.And(x => x.PhotoUrl == null || x.PhotoUrl == "");
  266. }
  267. }
  268. if (!string.IsNullOrEmpty(planningGraduateDate) && planningGraduateDate != "-1")
  269. {
  270. DateTime planDate = DateTime.ParseExact(planningGraduateDate, "yyyyMMdd", CultureInfo.CurrentCulture);
  271. expStudent = expStudent.And(x => DateTime.Compare((DateTime)x.PlanningGraduateDate, planDate) == 0);
  272. }
  273. if (inSchoolStatus.HasValue)
  274. {
  275. expStudent = expStudent.And(x => x.InSchoolStatusID == inSchoolStatus);
  276. }
  277. }
  278. var endStatusID = this.GetCorrectEndStatus();
  279. Expression<Func<CF_DifferentDynamic, bool>> expChange = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  280. expChange = expChange.And(x => x.ApprovalStatus == endStatusID);
  281. var query = StudentDAL.Value.GetStudentViewQueryable(expStudent, expChange);
  282. if (userIDList == null || userIDList.Count() <= 0)
  283. {
  284. if (campusID.HasValue)
  285. {
  286. query = query.Where(x => x.CampusID == campusID);
  287. }
  288. if (collegeID.HasValue)
  289. {
  290. query = query.Where(x => x.CollegeID == collegeID);
  291. }
  292. if (gradeID.HasValue)
  293. {
  294. query = query.Where(x => x.GradeID == gradeID);
  295. }
  296. if (standardID.HasValue)
  297. {
  298. query = query.Where(x => x.StandardID == standardID);
  299. }
  300. if (educationID.HasValue)
  301. {
  302. query = query.Where(x => x.EducationID == educationID);
  303. }
  304. if (learningformID.HasValue)
  305. {
  306. query = query.Where(x => x.LearningformID == learningformID);
  307. }
  308. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  309. {
  310. var LearnSystems = Convert.ToDecimal(learnSystem);
  311. query = query.Where(x => x.LearnSystem == LearnSystems);
  312. }
  313. if (reportStatus.HasValue)
  314. {
  315. query = query.Where(x => x.ReportStatus == reportStatus);
  316. }
  317. //查询条件
  318. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  319. {
  320. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  321. }
  322. }
  323. return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
  324. .OrderBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo)
  325. .ThenBy(x => x.GradeID).ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
  326. .ToList();
  327. }
  328. /// <summary>
  329. /// 查询对应的学生信息List(根据userIDList)
  330. /// </summary>
  331. /// <param name="userIDList"></param>
  332. /// <returns></returns>
  333. public IList<StudentView> GetStudentViewList(List<Guid?> userIDList)
  334. {
  335. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  336. expStudent = expStudent.And(x => userIDList.Contains(x.UserID));
  337. var query = StudentDAL.Value.GetStudentViewQueryable(expStudent);
  338. return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query)).OrderBy(x => x.ClassmajorNo.Length)
  339. .ThenBy(x => x.ClassmajorNo).ThenBy(x => x.GradeID).ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ToList();
  340. }
  341. /// <summary>
  342. /// 查询对应的学生信息StudentBaseView(全部、在校或非在校信息)
  343. /// </summary>
  344. /// <param name="configuretView"></param>
  345. /// <param name="userID"></param>
  346. /// <param name="inSchoolStatus"></param>
  347. /// <param name="pageIndex"></param>
  348. /// <param name="pageSize"></param>
  349. /// <returns></returns>
  350. public IGridResultSet<StudentBaseView> GetStudentBaseViewGrid(ConfiguretView configuretView, Guid? userID, int? inSchoolStatus, int pageIndex, int pageSize)
  351. {
  352. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  353. if (inSchoolStatus.HasValue)
  354. {
  355. if (inSchoolStatus != null && inSchoolStatus > -1)
  356. {
  357. var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
  358. if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.Yes)
  359. {
  360. if (userID.HasValue)
  361. {
  362. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID) || x.UserID == userID);
  363. }
  364. else
  365. {
  366. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  367. }
  368. }
  369. if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.No)
  370. {
  371. if (userID.HasValue)
  372. {
  373. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID) || x.UserID == userID);
  374. }
  375. else
  376. {
  377. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  378. }
  379. }
  380. }
  381. }
  382. var query = StudentDAL.Value.GetStudentBaseViewQueryable(expStudent);
  383. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  384. {
  385. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  386. }
  387. return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
  388. .OrderBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo).ThenBy(x => x.GradeID)
  389. .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ToGridResultSet<StudentBaseView>(pageIndex, pageSize);
  390. }
  391. /// <summary>
  392. /// 查询对应的学生信息List(全部、在校或非在校信息)
  393. /// </summary>
  394. /// <param name="configuretView"></param>
  395. /// <param name="userID"></param>
  396. /// <param name="inSchoolStatus"></param>
  397. /// <returns></returns>
  398. public IList<StudentBaseView> GetStudentBaseViewList(ConfiguretView configuretView, Guid? userID, int? inSchoolStatus)
  399. {
  400. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  401. if (inSchoolStatus.HasValue)
  402. {
  403. if (inSchoolStatus != null && inSchoolStatus > -1)
  404. {
  405. var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
  406. if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.Yes)
  407. {
  408. if (userID.HasValue)
  409. {
  410. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID) || x.UserID == userID);
  411. }
  412. else
  413. {
  414. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  415. }
  416. }
  417. if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.No)
  418. {
  419. if (userID.HasValue)
  420. {
  421. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID) || x.UserID == userID);
  422. }
  423. else
  424. {
  425. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  426. }
  427. }
  428. }
  429. }
  430. var query = StudentDAL.Value.GetStudentBaseViewQueryable(expStudent);
  431. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  432. {
  433. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  434. }
  435. return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
  436. .OrderBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo).ThenBy(x => x.GradeID)
  437. .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ToList();
  438. }
  439. /// <summary>
  440. /// 查询对应的照片比对学生信息StudentView
  441. /// </summary>
  442. /// <param name="configuretView"></param>
  443. /// <param name="campusID"></param>
  444. /// <param name="collegeID"></param>
  445. /// <param name="gradeID"></param>
  446. /// <param name="standardID"></param>
  447. /// <param name="educationID"></param>
  448. /// <param name="learningformID"></param>
  449. /// <param name="learnSystem"></param>
  450. /// <param name="classmajorID"></param>
  451. /// <param name="isRecruitPhoto"></param>
  452. /// <param name="isPhoto"></param>
  453. /// <param name="isGraduationPhoto"></param>
  454. /// <param name="isPhotoComparison"></param>
  455. /// <param name="inSchoolStatus"></param>
  456. /// <param name="pageIndex"></param>
  457. /// <param name="pageSize"></param>
  458. /// <returns></returns>
  459. public IGridResultSet<StudentView> GetStudentPicComparisonGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID,
  460. int? learningformID, string learnSystem, Guid? classmajorID, int? isRecruitPhoto, int? isPhoto, int? isGraduationPhoto, int? isPhotoComparison, int? inSchoolStatus, int pageIndex, int pageSize)
  461. {
  462. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  463. if (classmajorID.HasValue)
  464. {
  465. expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
  466. }
  467. if (isPhoto.HasValue)
  468. {
  469. if (isPhoto.Value == (int)CF_GeneralExist.Have)
  470. {
  471. expStudent = expStudent.And(x => x.PhotoUrl != null && x.PhotoUrl != "");
  472. }
  473. if (isPhoto.Value == (int)CF_GeneralExist.No)
  474. {
  475. expStudent = expStudent.And(x => x.PhotoUrl == null || x.PhotoUrl == "");
  476. }
  477. }
  478. if (isGraduationPhoto.HasValue)
  479. {
  480. if (isGraduationPhoto.Value == (int)CF_GeneralExist.Have)
  481. {
  482. expStudent = expStudent.And(x => x.GraduationPictureUrl != null && x.GraduationPictureUrl != "");
  483. }
  484. if (isGraduationPhoto.Value == (int)CF_GeneralExist.No)
  485. {
  486. expStudent = expStudent.And(x => x.GraduationPictureUrl == null || x.GraduationPictureUrl == "");
  487. }
  488. }
  489. if (isPhotoComparison.HasValue)
  490. {
  491. if (isPhotoComparison.Value == (int)CF_GeneralPurpose.IsYes)
  492. {
  493. expStudent = expStudent.And(x => x.IsPhotoComparison == true);
  494. }
  495. if (isPhotoComparison.Value == (int)CF_GeneralPurpose.IsNo)
  496. {
  497. expStudent = expStudent.And(x => x.IsPhotoComparison != true);
  498. }
  499. }
  500. if (inSchoolStatus.HasValue)
  501. {
  502. expStudent = expStudent.And(x => x.InSchoolStatusID == inSchoolStatus);
  503. }
  504. var query = StudentDAL.Value.GetStudentViewQueryable(expStudent);
  505. if (campusID.HasValue)
  506. {
  507. query = query.Where(x => x.CampusID == campusID);
  508. }
  509. if (collegeID.HasValue)
  510. {
  511. query = query.Where(x => x.CollegeID == collegeID);
  512. }
  513. if (gradeID.HasValue)
  514. {
  515. query = query.Where(x => x.GradeID == gradeID);
  516. }
  517. if (standardID.HasValue)
  518. {
  519. query = query.Where(x => x.StandardID == standardID);
  520. }
  521. if (educationID.HasValue)
  522. {
  523. query = query.Where(x => x.EducationID == educationID);
  524. }
  525. if (learningformID.HasValue)
  526. {
  527. query = query.Where(x => x.LearningformID == learningformID);
  528. }
  529. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  530. {
  531. var LearnSystems = Convert.ToDecimal(learnSystem);
  532. query = query.Where(x => x.LearnSystem == LearnSystems);
  533. }
  534. if (isRecruitPhoto.HasValue)
  535. {
  536. if (isRecruitPhoto.Value == (int)CF_GeneralExist.Have)
  537. {
  538. query = query.Where(x => x.RecruitPictureUrl != null && x.RecruitPictureUrl != "");
  539. }
  540. if (isRecruitPhoto.Value == (int)CF_GeneralExist.No)
  541. {
  542. query = query.Where(x => x.RecruitPictureUrl == null || x.RecruitPictureUrl == "");
  543. }
  544. }
  545. //查询条件
  546. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  547. {
  548. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  549. }
  550. return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
  551. .OrderBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo)
  552. .ThenBy(x => x.GradeID).ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
  553. .ToGridResultSet<StudentView>(pageIndex, pageSize);
  554. }
  555. /// <summary>
  556. /// 查询对应的照片比对学生信息List
  557. /// </summary>
  558. /// <param name="configuretView"></param>
  559. /// <param name="campusID"></param>
  560. /// <param name="collegeID"></param>
  561. /// <param name="gradeID"></param>
  562. /// <param name="standardID"></param>
  563. /// <param name="educationID"></param>
  564. /// <param name="learningformID"></param>
  565. /// <param name="learnSystem"></param>
  566. /// <param name="classmajorID"></param>
  567. /// <param name="isRecruitPhoto"></param>
  568. /// <param name="isPhoto"></param>
  569. /// <param name="isGraduationPhoto"></param>
  570. /// <param name="isPhotoComparison"></param>
  571. /// <param name="inSchoolStatus"></param>
  572. /// <returns></returns>
  573. public IList<StudentView> GetStudentPicComparisonList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID,
  574. int? learningformID, string learnSystem, Guid? classmajorID, int? isRecruitPhoto, int? isPhoto, int? isGraduationPhoto, int? isPhotoComparison, int? inSchoolStatus)
  575. {
  576. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  577. if (classmajorID.HasValue)
  578. {
  579. expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
  580. }
  581. if (isPhoto.HasValue)
  582. {
  583. if (isPhoto.Value == (int)CF_GeneralExist.Have)
  584. {
  585. expStudent = expStudent.And(x => x.PhotoUrl != null && x.PhotoUrl != "");
  586. }
  587. if (isPhoto.Value == (int)CF_GeneralExist.No)
  588. {
  589. expStudent = expStudent.And(x => x.PhotoUrl == null || x.PhotoUrl == "");
  590. }
  591. }
  592. if (isGraduationPhoto.HasValue)
  593. {
  594. if (isGraduationPhoto.Value == (int)CF_GeneralExist.Have)
  595. {
  596. expStudent = expStudent.And(x => x.GraduationPictureUrl != null && x.GraduationPictureUrl != "");
  597. }
  598. if (isGraduationPhoto.Value == (int)CF_GeneralExist.No)
  599. {
  600. expStudent = expStudent.And(x => x.GraduationPictureUrl == null || x.GraduationPictureUrl == "");
  601. }
  602. }
  603. if (isPhotoComparison.HasValue)
  604. {
  605. if (isPhotoComparison.Value == (int)CF_GeneralPurpose.IsYes)
  606. {
  607. expStudent = expStudent.And(x => x.IsPhotoComparison == true);
  608. }
  609. if (isPhotoComparison.Value == (int)CF_GeneralPurpose.IsNo)
  610. {
  611. expStudent = expStudent.And(x => x.IsPhotoComparison != true);
  612. }
  613. }
  614. if (inSchoolStatus.HasValue)
  615. {
  616. expStudent = expStudent.And(x => x.InSchoolStatusID == inSchoolStatus);
  617. }
  618. var query = StudentDAL.Value.GetStudentViewQueryable(expStudent);
  619. if (campusID.HasValue)
  620. {
  621. query = query.Where(x => x.CampusID == campusID);
  622. }
  623. if (collegeID.HasValue)
  624. {
  625. query = query.Where(x => x.CollegeID == collegeID);
  626. }
  627. if (gradeID.HasValue)
  628. {
  629. query = query.Where(x => x.GradeID == gradeID);
  630. }
  631. if (standardID.HasValue)
  632. {
  633. query = query.Where(x => x.StandardID == standardID);
  634. }
  635. if (educationID.HasValue)
  636. {
  637. query = query.Where(x => x.EducationID == educationID);
  638. }
  639. if (learningformID.HasValue)
  640. {
  641. query = query.Where(x => x.LearningformID == learningformID);
  642. }
  643. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  644. {
  645. var LearnSystems = Convert.ToDecimal(learnSystem);
  646. query = query.Where(x => x.LearnSystem == LearnSystems);
  647. }
  648. if (isRecruitPhoto.HasValue)
  649. {
  650. if (isRecruitPhoto.Value == (int)CF_GeneralExist.Have)
  651. {
  652. query = query.Where(x => x.RecruitPictureUrl != null && x.RecruitPictureUrl != "");
  653. }
  654. if (isRecruitPhoto.Value == (int)CF_GeneralExist.No)
  655. {
  656. query = query.Where(x => x.RecruitPictureUrl == null || x.RecruitPictureUrl == "");
  657. }
  658. }
  659. //查询条件
  660. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  661. {
  662. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  663. }
  664. return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
  665. .OrderBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo)
  666. .ThenBy(x => x.GradeID).ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ToList();
  667. }
  668. /// <summary>
  669. /// 查询对应的照片比对学生信息List(userIDList)
  670. /// </summary>
  671. /// <param name="configuretView"></param>
  672. /// <param name="campusID"></param>
  673. /// <param name="collegeID"></param>
  674. /// <param name="gradeID"></param>
  675. /// <param name="standardID"></param>
  676. /// <param name="educationID"></param>
  677. /// <param name="learningformID"></param>
  678. /// <param name="learnSystem"></param>
  679. /// <param name="classmajorID"></param>
  680. /// <param name="isRecruitPhoto"></param>
  681. /// <param name="isPhoto"></param>
  682. /// <param name="isGraduationPhoto"></param>
  683. /// <param name="isPhotoComparison"></param>
  684. /// <param name="inSchoolStatus"></param>
  685. /// <param name="userIDList"></param>
  686. /// <returns></returns>
  687. public IList<StudentView> GetStudentPicComparisonList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID,
  688. int? learningformID, string learnSystem, Guid? classmajorID, int? isRecruitPhoto, int? isPhoto, int? isGraduationPhoto, int? isPhotoComparison, int? inSchoolStatus, List<Guid?> userIDList)
  689. {
  690. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  691. if (userIDList != null && userIDList.Count() > 0)
  692. {
  693. expStudent = expStudent.And(x => userIDList.Contains(x.UserID));
  694. }
  695. else
  696. {
  697. if (classmajorID.HasValue)
  698. {
  699. expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
  700. }
  701. if (isPhoto.HasValue)
  702. {
  703. if (isPhoto.Value == (int)CF_GeneralExist.Have)
  704. {
  705. expStudent = expStudent.And(x => x.PhotoUrl != null && x.PhotoUrl != "");
  706. }
  707. if (isPhoto.Value == (int)CF_GeneralExist.No)
  708. {
  709. expStudent = expStudent.And(x => x.PhotoUrl == null || x.PhotoUrl == "");
  710. }
  711. }
  712. if (isGraduationPhoto.HasValue)
  713. {
  714. if (isGraduationPhoto.Value == (int)CF_GeneralExist.Have)
  715. {
  716. expStudent = expStudent.And(x => x.GraduationPictureUrl != null && x.GraduationPictureUrl != "");
  717. }
  718. if (isGraduationPhoto.Value == (int)CF_GeneralExist.No)
  719. {
  720. expStudent = expStudent.And(x => x.GraduationPictureUrl == null || x.GraduationPictureUrl == "");
  721. }
  722. }
  723. if (isPhotoComparison.HasValue)
  724. {
  725. if (isPhotoComparison.Value == (int)CF_GeneralPurpose.IsYes)
  726. {
  727. expStudent = expStudent.And(x => x.IsPhotoComparison == true);
  728. }
  729. if (isPhotoComparison.Value == (int)CF_GeneralPurpose.IsNo)
  730. {
  731. expStudent = expStudent.And(x => x.IsPhotoComparison != true);
  732. }
  733. }
  734. if (inSchoolStatus.HasValue)
  735. {
  736. expStudent = expStudent.And(x => x.InSchoolStatusID == inSchoolStatus);
  737. }
  738. }
  739. var query = StudentDAL.Value.GetStudentViewQueryable(expStudent);
  740. if (userIDList == null || userIDList.Count() <= 0)
  741. {
  742. if (campusID.HasValue)
  743. {
  744. query = query.Where(x => x.CampusID == campusID);
  745. }
  746. if (collegeID.HasValue)
  747. {
  748. query = query.Where(x => x.CollegeID == collegeID);
  749. }
  750. if (gradeID.HasValue)
  751. {
  752. query = query.Where(x => x.GradeID == gradeID);
  753. }
  754. if (standardID.HasValue)
  755. {
  756. query = query.Where(x => x.StandardID == standardID);
  757. }
  758. if (educationID.HasValue)
  759. {
  760. query = query.Where(x => x.EducationID == educationID);
  761. }
  762. if (learningformID.HasValue)
  763. {
  764. query = query.Where(x => x.LearningformID == learningformID);
  765. }
  766. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  767. {
  768. var LearnSystems = Convert.ToDecimal(learnSystem);
  769. query = query.Where(x => x.LearnSystem == LearnSystems);
  770. }
  771. if (isRecruitPhoto.HasValue)
  772. {
  773. if (isRecruitPhoto.Value == (int)CF_GeneralExist.Have)
  774. {
  775. query = query.Where(x => x.RecruitPictureUrl != null && x.RecruitPictureUrl != "");
  776. }
  777. if (isRecruitPhoto.Value == (int)CF_GeneralExist.No)
  778. {
  779. query = query.Where(x => x.RecruitPictureUrl == null || x.RecruitPictureUrl == "");
  780. }
  781. }
  782. //查询条件
  783. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  784. {
  785. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  786. }
  787. }
  788. return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
  789. .OrderBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo)
  790. .ThenBy(x => x.GradeID).ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
  791. .ToList();
  792. }
  793. /// <summary>
  794. /// 查询对应的学生信息StudentView
  795. /// </summary>
  796. /// <param name="userID"></param>
  797. /// <returns></returns>
  798. public StudentView GetStudentView(Guid? userID)
  799. {
  800. try
  801. {
  802. var query = StudentDAL.Value.GetStudentViewQueryable(x => x.UserID == userID);
  803. return query.SingleOrDefault();
  804. }
  805. catch (Exception ex)
  806. {
  807. throw new Exception(ex.Message);
  808. }
  809. }
  810. /// <summary>
  811. /// 编辑(新增、修改,业务主键:学号或考生号唯一)
  812. /// </summary>
  813. /// <param name="studentView"></param>
  814. /// <param name="photoUrl"></param>
  815. public virtual void StudentEdit(StudentView studentView, string photoUrl)
  816. {
  817. try
  818. {
  819. //查询相关Web.config配置
  820. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringMonth == null)
  821. {
  822. throw new Exception("预计毕业月(春季、上学期入学月)未配置,请检查。");
  823. }
  824. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringDay == null)
  825. {
  826. throw new Exception("预计毕业日(春季、上学期入学日)未配置,请检查。");
  827. }
  828. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnMonth == null)
  829. {
  830. throw new Exception("预计毕业月(秋季、下学期入学月)未配置,请检查。");
  831. }
  832. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnDay == null)
  833. {
  834. throw new Exception("预计毕业日(秋季、下学期入学日)未配置,请检查。");
  835. }
  836. if (EMIS.Utility.Const.LOCAL_SETTING_ENTRANCESEMESTERID == null)
  837. {
  838. throw new Exception("入学学期(春季、上学期、秋季、下学期)未配置,请检查。");
  839. }
  840. var studentNoTotal = EMIS.Utility.Const.LOCAL_SETTING_LOGINIDTOTAL;
  841. if (studentNoTotal == null)
  842. {
  843. throw new Exception("学号总位数未配置,请检查。");
  844. }
  845. if (!string.IsNullOrEmpty(studentView.StudentNo))
  846. {
  847. if (studentView.StudentNo.Trim().Length != Convert.ToInt32(studentNoTotal))
  848. {
  849. throw new Exception("输入的学号总位数有误,学号总位数应为" + studentNoTotal + "位。");
  850. }
  851. }
  852. else
  853. {
  854. throw new Exception("学号不能为空,请输入学号。");
  855. }
  856. var userVerify = StudentDAL.Value.UserRepository.GetList(x => x.UserID != studentView.UserID && x.LoginID == studentView.StudentNo.Trim()).SingleOrDefault();
  857. if (userVerify == null)
  858. {
  859. var newStudentVerify = StudentDAL.Value.NewStudentRepository.GetList(x => x.AssignStatus == (int)CF_AssignStatus.Assigned
  860. && x.ExamineeNum != studentView.ExamineeNum && x.StudentNo == studentView.StudentNo.Trim()).SingleOrDefault();
  861. if (newStudentVerify != null)
  862. {
  863. throw new Exception("录取名单中已存在相同的学号(学号重复),请核查。");
  864. }
  865. if (!string.IsNullOrEmpty(studentView.ExamineeNum))
  866. {
  867. var examineeNumVerify = StudentDAL.Value.RecruitstudentsRepository.GetList(x => x.UserID != studentView.UserID
  868. && x.ExamineeNum == studentView.ExamineeNum.Trim()).SingleOrDefault();
  869. if (examineeNumVerify != null)
  870. {
  871. throw new Exception("已存在相同的考生号(考生号重复),请核查。");
  872. }
  873. }
  874. if (!string.IsNullOrEmpty(studentView.StudentCardNo))
  875. {
  876. var studentCardNoVerify = StudentDAL.Value.StudentRepository.GetList(x => x.UserID != studentView.UserID
  877. && x.StudentCardNo == studentView.StudentCardNo.Trim()).SingleOrDefault();
  878. if (studentCardNoVerify != null)
  879. {
  880. throw new Exception("已存在相同的学籍卡编号(学籍卡编号重复),请核查。");
  881. }
  882. }
  883. if (!string.IsNullOrEmpty(studentView.GraduateCardNo))
  884. {
  885. var graduateCardNoVerify = StudentDAL.Value.StudentRepository.GetList(x => x.UserID != studentView.UserID
  886. && x.GraduateCardNo == studentView.GraduateCardNo.Trim()).SingleOrDefault();
  887. if (graduateCardNoVerify != null)
  888. {
  889. throw new Exception("已存在相同的毕结业证书编号(毕结业证书编号重复),请核查。");
  890. }
  891. }
  892. if (!string.IsNullOrEmpty(studentView.ReplaceGraduateNo))
  893. {
  894. var replaceGraduateNoVerify = StudentDAL.Value.StudentRepository.GetList(x => x.UserID != studentView.UserID
  895. && x.ReplaceGraduateNo == studentView.ReplaceGraduateNo.Trim()).SingleOrDefault();
  896. if (replaceGraduateNoVerify != null)
  897. {
  898. throw new Exception("已存在相同的补证编号(补证编号重复),请核查。");
  899. }
  900. }
  901. var passwordParameter = StudentDAL.Value.ParameterRepository.GetSingle(x => x.ParameterTypeID == (int)ViewModel.CF_ParameterType.StudentInitPassword);
  902. var roleList = StudentDAL.Value.RoleRepository.GetList(x => x.TypeID == (int)SYS_RoleType.Student, (x => x.CF_StudentRole)).ToList();
  903. List<Sys_User> newUserInList = new List<Sys_User>();
  904. List<Sys_User> newUserUpList = new List<Sys_User>();
  905. List<CF_Student> newStudentInList = new List<CF_Student>();
  906. List<CF_Student> newStudentUpList = new List<CF_Student>();
  907. List<CF_StudentProfile> newStudentProfileInList = new List<CF_StudentProfile>();
  908. List<CF_StudentProfile> newStudentProfileUpList = new List<CF_StudentProfile>();
  909. List<CF_StudentContact> newStudentContactInList = new List<CF_StudentContact>();
  910. List<CF_StudentContact> newStudentContactUpList = new List<CF_StudentContact>();
  911. List<CF_StudentAccount> newStudentAccountInList = new List<CF_StudentAccount>();
  912. List<CF_StudentAccount> newStudentAccountUpList = new List<CF_StudentAccount>();
  913. List<CF_Recruitstudents> newRecruitstudentsInList = new List<CF_Recruitstudents>();
  914. List<CF_Recruitstudents> newRecruitstudentsUpList = new List<CF_Recruitstudents>();
  915. if (studentView.UserID != Guid.Empty)
  916. {
  917. //修改
  918. var student = StudentDAL.Value.StudentRepository.GetList(x => x.UserID == studentView.UserID,
  919. (x => x.CF_StudentProfile), (x => x.CF_StudentContact), (x => x.CF_StudentAccount),
  920. (x => x.CF_Recruitstudents), (x => x.Sys_User)).SingleOrDefault();
  921. if (student == null)
  922. {
  923. throw new Exception("数据有误,请核查。");
  924. }
  925. else
  926. {
  927. student.Sys_User.LoginID = studentView.StudentNo.Trim();
  928. student.Sys_User.Name = studentView.Name.Trim();
  929. this.SetModifyStatus(student.Sys_User);
  930. newUserUpList.Add(student.Sys_User);
  931. student.ClassmajorID = studentView.ClassmajorID;
  932. student.SexID = studentView.SexID;
  933. student.BirthDate = studentView.BirthDate;
  934. student.NationID = studentView.NationID;
  935. student.PoliticsID = studentView.PoliticsID;
  936. student.CertificatesType = studentView.CertificatesType;
  937. student.IDNumber = studentView.IDNumber;
  938. student.StudentType = studentView.StudentType;
  939. student.Sys_User.Sys_Role = new HashSet<Sys_Role>();
  940. roleList = roleList.Where(x => x.CF_StudentRole.StudentType == studentView.StudentType).ToList();
  941. if (roleList != null && roleList.Count > 0)
  942. {
  943. roleList.ForEach(x => student.Sys_User.Sys_Role.Add(x));
  944. }
  945. else
  946. {
  947. //对应角色为空时,默认为不分配用户角色
  948. }
  949. student.InSchoolStatusID = studentView.InSchoolStatusID;
  950. student.StudentStatus = studentView.StudentStatus;
  951. student.StudentCardNo = studentView.StudentCardNo;
  952. if (!string.IsNullOrEmpty(photoUrl))
  953. {
  954. student.PhotoUrl = photoUrl;
  955. }
  956. if (studentView.PlanningGraduateDate.HasValue)
  957. {
  958. student.PlanningGraduateDate = studentView.PlanningGraduateDate;
  959. }
  960. if(studentView.GraduateDate.HasValue)
  961. {
  962. student.GraduateDate = studentView.GraduateDate;
  963. }
  964. student.GraduateCardNo = studentView.GraduateCardNo;
  965. student.ReplaceGraduateNo = studentView.ReplaceGraduateNo;
  966. student.DegreeStatus = studentView.DegreeStatus;
  967. //if (!string.IsNullOrEmpty(studentView.GraduationPictureUrl))
  968. //{
  969. // student.GraduationPictureUrl = studentView.GraduationPictureUrl;
  970. //}
  971. student.Career = studentView.Career;
  972. //student.IsPhotoComparison = studentView.IsPhotoComparison;
  973. //student.IsProofread = studentView.IsProofread;
  974. student.Remark = studentView.Remark;
  975. this.SetModifyStatus(student);
  976. newStudentUpList.Add(student);
  977. if (student.CF_StudentProfile == null)
  978. {
  979. var studentProfile = new CF_StudentProfile();
  980. studentProfile.UserID = student.UserID;
  981. studentProfile.UsedName = studentView.UsedName;
  982. studentProfile.LiteracyLevelID = studentView.LiteracyLevelID;
  983. studentProfile.CultureModelID = studentView.CultureModelID;
  984. studentProfile.IsDreamProject = studentView.IsDreamProject;
  985. studentProfile.Country = studentView.Country;
  986. studentProfile.Place = studentView.Place;
  987. studentProfile.BornPlace = studentView.BornPlace;
  988. studentProfile.HealthStateID = studentView.HealthStateID;
  989. studentProfile.BloodGroup = studentView.BloodGroup;
  990. studentProfile.Specialty = studentView.Specialty;
  991. studentProfile.Height = studentView.Height;
  992. studentProfile.Weight = studentView.Weight;
  993. studentProfile.DirectorName = studentView.DirectorName;
  994. this.SetNewStatus(studentProfile);
  995. newStudentProfileInList.Add(studentProfile);
  996. }
  997. else
  998. {
  999. student.CF_StudentProfile.UsedName = studentView.UsedName;
  1000. student.CF_StudentProfile.LiteracyLevelID = studentView.LiteracyLevelID;
  1001. student.CF_StudentProfile.CultureModelID = studentView.CultureModelID;
  1002. student.CF_StudentProfile.IsDreamProject = studentView.IsDreamProject;
  1003. student.CF_StudentProfile.Country = studentView.Country;
  1004. student.CF_StudentProfile.Place = studentView.Place;
  1005. student.CF_StudentProfile.BornPlace = studentView.BornPlace;
  1006. student.CF_StudentProfile.HealthStateID = studentView.HealthStateID;
  1007. student.CF_StudentProfile.BloodGroup = studentView.BloodGroup;
  1008. student.CF_StudentProfile.Specialty = studentView.Specialty;
  1009. student.CF_StudentProfile.Height = studentView.Height;
  1010. student.CF_StudentProfile.Weight = studentView.Weight;
  1011. student.CF_StudentProfile.DirectorName = studentView.DirectorName;
  1012. this.SetModifyStatus(student.CF_StudentProfile);
  1013. newStudentProfileUpList.Add(student.CF_StudentProfile);
  1014. }
  1015. if (student.CF_StudentContact == null)
  1016. {
  1017. var studentContact = new CF_StudentContact();
  1018. studentContact.UserID = student.UserID;
  1019. studentContact.Email = studentView.Email;
  1020. studentContact.Telephone = studentView.Email;
  1021. studentContact.Mobile = studentView.Email;
  1022. studentContact.ZIPCode = studentView.ZIPCode;
  1023. studentContact.WeChatNum = studentView.WeChatNum;
  1024. studentContact.QQ = studentView.QQ;
  1025. studentContact.HomeAddress = studentView.HomeAddress;
  1026. studentContact.WorkUnit = studentView.WorkUnit;
  1027. studentContact.Address = studentView.Address;
  1028. studentContact.Recipient = studentView.Recipient;
  1029. studentContact.Dormitory = studentView.Dormitory;
  1030. this.SetNewStatus(studentContact);
  1031. newStudentContactInList.Add(studentContact);
  1032. }
  1033. else
  1034. {
  1035. student.CF_StudentContact.Email = studentView.Email;
  1036. student.CF_StudentContact.Telephone = studentView.Telephone;
  1037. student.CF_StudentContact.Mobile = studentView.Mobile;
  1038. student.CF_StudentContact.ZIPCode = studentView.ZIPCode;
  1039. student.CF_StudentContact.WeChatNum = studentView.WeChatNum;
  1040. student.CF_StudentContact.QQ = studentView.QQ;
  1041. student.CF_StudentContact.HomeAddress = studentView.HomeAddress;
  1042. student.CF_StudentContact.WorkUnit = studentView.WorkUnit;
  1043. student.CF_StudentContact.Address = studentView.Address;
  1044. student.CF_StudentContact.Recipient = studentView.Recipient;
  1045. student.CF_StudentContact.Dormitory = studentView.Dormitory;
  1046. this.SetModifyStatus(student.CF_StudentContact);
  1047. newStudentContactUpList.Add(student.CF_StudentContact);
  1048. }
  1049. if (student.CF_StudentAccount == null)
  1050. {
  1051. var studentAccount = new CF_StudentAccount();
  1052. studentAccount.UserID = student.UserID;
  1053. studentAccount.BankName = studentView.BankName;
  1054. studentAccount.CardNo = studentView.CardNo;
  1055. this.SetNewStatus(studentAccount);
  1056. newStudentAccountInList.Add(studentAccount);
  1057. }
  1058. else
  1059. {
  1060. student.CF_StudentAccount.BankName = studentView.BankName;
  1061. student.CF_StudentAccount.CardNo = studentView.CardNo;
  1062. this.SetModifyStatus(student.CF_StudentAccount);
  1063. newStudentAccountUpList.Add(student.CF_StudentAccount);
  1064. }
  1065. if (student.CF_Recruitstudents == null)
  1066. {
  1067. var recruitstudents = new CF_Recruitstudents();
  1068. recruitstudents.UserID = student.UserID;
  1069. recruitstudents.ExamineeNum = studentView.ExamineeNum;
  1070. recruitstudents.AdmissionTicketNo = studentView.AdmissionTicketNo;
  1071. recruitstudents.ExamineeType = studentView.ExamineeType;
  1072. recruitstudents.EnteringSchoolYearID = studentView.StartSchoolyearID;
  1073. recruitstudents.EntranceDate = studentView.EntranceDate;
  1074. recruitstudents.Score = studentView.Score;
  1075. recruitstudents.EntranceWayID = studentView.EntranceWayID;
  1076. recruitstudents.FeaturesID = studentView.FeaturesID;
  1077. recruitstudents.TerritorialID = studentView.TerritorialID;
  1078. recruitstudents.Area = studentView.Area;
  1079. //if (!string.IsNullOrEmpty(studentView.RecruitPictureUrl))
  1080. //{
  1081. // recruitstudents.RecruitPictureUrl = studentView.RecruitPictureUrl;
  1082. //}
  1083. this.SetNewStatus(recruitstudents);
  1084. newRecruitstudentsInList.Add(recruitstudents);
  1085. }
  1086. else
  1087. {
  1088. student.CF_Recruitstudents.ExamineeNum = studentView.ExamineeNum;
  1089. student.CF_Recruitstudents.AdmissionTicketNo = studentView.AdmissionTicketNo;
  1090. student.CF_Recruitstudents.ExamineeType = studentView.ExamineeType;
  1091. student.CF_Recruitstudents.EnteringSchoolYearID = studentView.StartSchoolyearID;
  1092. student.CF_Recruitstudents.EntranceDate = studentView.EntranceDate;
  1093. student.CF_Recruitstudents.Score = studentView.Score;
  1094. student.CF_Recruitstudents.EntranceWayID = studentView.EntranceWayID;
  1095. student.CF_Recruitstudents.FeaturesID = studentView.FeaturesID;
  1096. student.CF_Recruitstudents.TerritorialID = studentView.TerritorialID;
  1097. student.CF_Recruitstudents.Area = studentView.Area;
  1098. //if (!string.IsNullOrEmpty(studentView.RecruitPictureUrl))
  1099. //{
  1100. // student.CF_Recruitstudents.RecruitPictureUrl = studentView.RecruitPictureUrl;
  1101. //}
  1102. this.SetModifyStatus(student.CF_Recruitstudents);
  1103. newRecruitstudentsUpList.Add(student.CF_Recruitstudents);
  1104. }
  1105. }
  1106. }
  1107. else
  1108. {
  1109. //新增
  1110. var newUser = new Sys_User();
  1111. newUser.UserID = Guid.NewGuid();
  1112. newUser.LoginID = studentView.StudentNo.Trim();
  1113. newUser.Name = studentView.Name.Trim();
  1114. if (passwordParameter == null)
  1115. {
  1116. newUser.Password = ("A" + studentView.StudentNo.Trim()).MD5();
  1117. }
  1118. else
  1119. {
  1120. if (passwordParameter.Value != null)
  1121. {
  1122. newUser.Password = passwordParameter.Value;
  1123. }
  1124. else
  1125. {
  1126. newUser.Password = ("A" + studentView.StudentNo.Trim()).MD5();
  1127. }
  1128. }
  1129. this.SetNewStatus(newUser, (int)SYS_STATUS.USABLE);
  1130. newUserInList.Add(newUser);
  1131. newUser.Sys_Role = new HashSet<Sys_Role>();
  1132. roleList = roleList.Where(x => x.CF_StudentRole.StudentType == studentView.StudentType).ToList();
  1133. if (roleList != null && roleList.Count > 0)
  1134. {
  1135. roleList.ForEach(x => newUser.Sys_Role.Add(x));
  1136. }
  1137. else
  1138. {
  1139. //对应角色为空时,默认为不分配用户角色
  1140. }
  1141. var newStudent = new CF_Student();
  1142. newStudent.UserID = newUser.UserID;
  1143. newStudent.ClassmajorID = studentView.ClassmajorID;
  1144. newStudent.SexID = studentView.SexID;
  1145. newStudent.BirthDate = studentView.BirthDate;
  1146. newStudent.NationID = studentView.NationID;
  1147. newStudent.PoliticsID = studentView.PoliticsID;
  1148. newStudent.CertificatesType = studentView.CertificatesType;
  1149. newStudent.IDNumber = studentView.IDNumber;
  1150. newStudent.StudentType = studentView.StudentType;
  1151. newStudent.InSchoolStatusID = studentView.InSchoolStatusID;
  1152. newStudent.StudentStatus = studentView.StudentStatus;
  1153. newStudent.StudentCardNo = studentView.StudentCardNo;
  1154. if (!string.IsNullOrEmpty(photoUrl))
  1155. {
  1156. newStudent.PhotoUrl = photoUrl;
  1157. }
  1158. newStudent.PlanningGraduateDate = this.GetClassmajorPlanningGraduateDate(studentView.ClassmajorID);
  1159. newStudent.GraduateDate = this.GetClassmajorGraduateDate(studentView.ClassmajorID);
  1160. newStudent.GraduateCardNo = studentView.GraduateCardNo;
  1161. newStudent.ReplaceGraduateNo = studentView.ReplaceGraduateNo;
  1162. newStudent.DegreeStatus = studentView.DegreeStatus;
  1163. //if (!string.IsNullOrEmpty(studentView.GraduationPictureUrl))
  1164. //{
  1165. // newStudent.GraduationPictureUrl = studentView.GraduationPictureUrl;
  1166. //}
  1167. newStudent.Career = studentView.Career;
  1168. //newStudent.IsPhotoComparison = studentView.IsPhotoComparison;
  1169. //newStudent.IsProofread = studentView.IsProofread;
  1170. newStudent.Remark = studentView.Remark;
  1171. this.SetNewStatus(newStudent);
  1172. newStudentInList.Add(newStudent);
  1173. var newStudentProfile = new CF_StudentProfile();
  1174. newStudentProfile.UserID = newStudent.UserID;
  1175. newStudentProfile.UsedName = studentView.UsedName;
  1176. newStudentProfile.LiteracyLevelID = studentView.LiteracyLevelID;
  1177. newStudentProfile.CultureModelID = studentView.CultureModelID;
  1178. newStudentProfile.IsDreamProject = studentView.IsDreamProject;
  1179. newStudentProfile.Country = studentView.Country;
  1180. newStudentProfile.Place = studentView.Place;
  1181. newStudentProfile.BornPlace = studentView.BornPlace;
  1182. newStudentProfile.HealthStateID = studentView.HealthStateID;
  1183. newStudentProfile.BloodGroup = studentView.BloodGroup;
  1184. newStudentProfile.Specialty = studentView.Specialty;
  1185. newStudentProfile.Height = studentView.Height;
  1186. newStudentProfile.Weight = studentView.Weight;
  1187. newStudentProfile.DirectorName = studentView.DirectorName;
  1188. this.SetNewStatus(newStudentProfile);
  1189. newStudentProfileInList.Add(newStudentProfile);
  1190. var newStudentContact = new CF_StudentContact();
  1191. newStudentContact.UserID = newStudent.UserID;
  1192. newStudentContact.Email = studentView.Email;
  1193. newStudentContact.Telephone = studentView.Telephone;
  1194. newStudentContact.Mobile = studentView.Mobile;
  1195. newStudentContact.ZIPCode = studentView.ZIPCode;
  1196. newStudentContact.WeChatNum = studentView.WeChatNum;
  1197. newStudentContact.QQ = studentView.QQ;
  1198. newStudentContact.HomeAddress = studentView.HomeAddress;
  1199. newStudentContact.WorkUnit = studentView.WorkUnit;
  1200. newStudentContact.Address = studentView.Address;
  1201. newStudentContact.Recipient = studentView.Recipient;
  1202. newStudentContact.Dormitory = studentView.Dormitory;
  1203. this.SetNewStatus(newStudentContact);
  1204. newStudentContactInList.Add(newStudentContact);
  1205. var newStudentAccount = new CF_StudentAccount();
  1206. newStudentAccount.UserID = newStudent.UserID;
  1207. newStudentAccount.CardNo = studentView.CardNo;
  1208. newStudentAccount.BankName = studentView.BankName;
  1209. this.SetNewStatus(newStudentAccount);
  1210. newStudentAccountInList.Add(newStudentAccount);
  1211. var newRecruitstudents = new CF_Recruitstudents();
  1212. newRecruitstudents.UserID = newStudent.UserID;
  1213. newRecruitstudents.ExamineeNum = studentView.ExamineeNum;
  1214. newRecruitstudents.AdmissionTicketNo = studentView.AdmissionTicketNo;
  1215. newRecruitstudents.ExamineeType = studentView.ExamineeType;
  1216. newRecruitstudents.EnteringSchoolYearID = studentView.StartSchoolyearID;
  1217. newRecruitstudents.EntranceDate = studentView.EntranceDate;
  1218. newRecruitstudents.Score = studentView.Score;
  1219. newRecruitstudents.EntranceWayID = studentView.EntranceWayID;
  1220. newRecruitstudents.FeaturesID = studentView.FeaturesID;
  1221. newRecruitstudents.TerritorialID = studentView.TerritorialID;
  1222. newRecruitstudents.Area = studentView.Area;
  1223. //if (!string.IsNullOrEmpty(studentView.RecruitPictureUrl))
  1224. //{
  1225. // newRecruitstudents.RecruitPictureUrl = studentView.RecruitPictureUrl;
  1226. //}
  1227. this.SetNewStatus(newRecruitstudents);
  1228. newRecruitstudentsInList.Add(newRecruitstudents);
  1229. }
  1230. using (TransactionScope ts = new TransactionScope())
  1231. {
  1232. UnitOfWork.BulkInsert<Sys_User>(newUserInList);
  1233. UnitOfWork.BulkInsert(newUserInList, (x => x.Sys_Role));
  1234. UnitOfWork.BulkInsert<CF_Student>(newStudentInList);
  1235. UnitOfWork.BulkInsert<CF_StudentProfile>(newStudentProfileInList);
  1236. UnitOfWork.BulkInsert<CF_StudentContact>(newStudentContactInList);
  1237. UnitOfWork.BulkInsert<CF_StudentAccount>(newStudentAccountInList);
  1238. UnitOfWork.BulkInsert<CF_Recruitstudents>(newRecruitstudentsInList);
  1239. if (newUserUpList != null && newUserUpList.Count() > 0)
  1240. {
  1241. UnitOfWork.BatchUpdate(newUserUpList);
  1242. UnitOfWork.Delete(newUserUpList, (x => x.Sys_Role));
  1243. UnitOfWork.BulkInsert(newUserUpList, (x => x.Sys_Role));
  1244. }
  1245. if (newStudentUpList != null && newStudentUpList.Count() > 0)
  1246. {
  1247. UnitOfWork.BatchUpdate(newStudentUpList);
  1248. }
  1249. if (newStudentProfileUpList != null && newStudentProfileUpList.Count() > 0)
  1250. {
  1251. UnitOfWork.BatchUpdate(newStudentProfileUpList);
  1252. }
  1253. if (newStudentContactUpList != null && newStudentContactUpList.Count() > 0)
  1254. {
  1255. UnitOfWork.BatchUpdate(newStudentContactUpList);
  1256. }
  1257. if (newStudentAccountUpList != null && newStudentAccountUpList.Count() > 0)
  1258. {
  1259. UnitOfWork.BatchUpdate(newStudentAccountUpList);
  1260. }
  1261. if (newRecruitstudentsUpList != null && newRecruitstudentsUpList.Count() > 0)
  1262. {
  1263. UnitOfWork.BatchUpdate(newRecruitstudentsUpList);
  1264. }
  1265. ts.Complete();
  1266. }
  1267. }
  1268. else
  1269. {
  1270. var studentVerify = StudentDAL.Value.StudentRepository.GetList(x => x.UserID != studentView.UserID,
  1271. (x => x.Sys_User)).Where(x => x.Sys_User.LoginID == studentView.StudentNo.Trim()).SingleOrDefault();
  1272. if (studentVerify != null)
  1273. {
  1274. throw new Exception("已存在相同的学号(学号重复),请核查。");
  1275. }
  1276. else
  1277. {
  1278. var staffVerify = StudentDAL.Value.StaffRepository.GetList(x => x.UserID != studentView.UserID,
  1279. (x => x.Sys_User)).Where(x => x.Sys_User.LoginID == studentView.StudentNo.Trim()).SingleOrDefault();
  1280. if (staffVerify != null)
  1281. {
  1282. throw new Exception("教师信息中已存在相同的用户(用户名重复),请核查。");
  1283. }
  1284. else
  1285. {
  1286. throw new Exception("用户信息中已存在相同的用户(用户名重复),请核查。");
  1287. }
  1288. }
  1289. }
  1290. }
  1291. catch (Exception ex)
  1292. {
  1293. throw new Exception(ex.Message);
  1294. }
  1295. }
  1296. /// <summary>
  1297. /// 删除
  1298. /// 注:删除成功后,需对相应的录取名单提交状态进行更新(以学号和证件号码进行查询)
  1299. /// </summary>
  1300. /// <param name="userIDs"></param>
  1301. /// <returns></returns>
  1302. public bool StudentDelete(List<Guid?> userIDs)
  1303. {
  1304. try
  1305. {
  1306. var studentList = StudentDAL.Value.StudentRepository.GetList(x => userIDs.Contains(x.UserID), (x => x.Sys_User)).ToList();
  1307. var iDNumberList = studentList.Where(x => !string.IsNullOrEmpty(x.IDNumber)).Select(x => x.IDNumber).ToList();
  1308. var newStudentList = StudentDAL.Value.NewStudentRepository.GetList(x => iDNumberList.Contains(x.IDNumber)).ToList();
  1309. List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
  1310. foreach (var student in studentList)
  1311. {
  1312. var newStudent = newStudentList.Where(x => x.IDNumber == student.IDNumber
  1313. && x.StudentNo == student.Sys_User.LoginID).SingleOrDefault();
  1314. if (newStudent != null)
  1315. {
  1316. newStudent.RecordStatus = (int)CF_NewStudentEnterStatus.NotSubmitted;
  1317. SetModifyStatus(newStudent);
  1318. newStudentUpList.Add(newStudent);
  1319. }
  1320. }
  1321. UnitOfWork.Remove<CF_StudentExperience>(x => userIDs.Contains((Guid)x.UserID));
  1322. UnitOfWork.Remove<CF_StudentFamily>(x => userIDs.Contains((Guid)x.UserID));
  1323. UnitOfWork.Remove<CF_StudentContact>(x => userIDs.Contains(x.UserID));
  1324. UnitOfWork.Remove<CF_StudentAccount>(x => userIDs.Contains(x.UserID));
  1325. UnitOfWork.Remove<CF_Recruitstudents>(x => userIDs.Contains(x.UserID));
  1326. UnitOfWork.Remove<CF_StudentProfile>(x => userIDs.Contains(x.UserID));
  1327. UnitOfWork.Remove<CF_Student>(x => userIDs.Contains(x.UserID));
  1328. var userList = StudentDAL.Value.UserRepository.GetList(x => userIDs.Contains(x.UserID), (x => x.Sys_Role)).ToList();
  1329. userList.ForEach(x => x.Sys_Role = new HashSet<Sys_Role>());
  1330. UnitOfWork.Remove<Sys_User>(x => userIDs.Contains(x.UserID));
  1331. UnitOfWork.Commit();
  1332. return true;
  1333. }
  1334. catch (Exception)
  1335. {
  1336. throw;
  1337. }
  1338. }
  1339. /// <summary>
  1340. /// 查询对应的学籍异动信息StudentChangeView
  1341. /// </summary>
  1342. /// <param name="configuretView"></param>
  1343. /// <param name="userID"></param>
  1344. /// <param name="schoolyearID"></param>
  1345. /// <param name="changeTypeID"></param>
  1346. /// <param name="pageIndex"></param>
  1347. /// <param name="pageSize"></param>
  1348. /// <returns></returns>
  1349. public IGridResultSet<StudentChangeView> GetStudentChangeViewGrid(ConfiguretView configuretView, Guid? userID, Guid? schoolyearID, int? changeTypeID, int pageIndex, int pageSize)
  1350. {
  1351. var approveStatusList = this.GetStatusViewList();
  1352. var endStatusID = this.GetCorrectEndStatus();
  1353. Expression<Func<CF_DifferentDynamic, bool>> expStudentChange = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1354. expStudentChange = expStudentChange.And(x => x.UserID == userID);
  1355. expStudentChange = expStudentChange.And(x => x.ApprovalStatus == endStatusID);
  1356. if (schoolyearID.HasValue)
  1357. {
  1358. expStudentChange = expStudentChange.And(x => x.SchoolyearID == schoolyearID);
  1359. }
  1360. if (changeTypeID.HasValue)
  1361. {
  1362. expStudentChange = expStudentChange.And(x => x.ChangeTypeID == changeTypeID);
  1363. }
  1364. var query = StudentChangeDAL.Value.GetStudentChangeViewQueryable(expStudentChange);
  1365. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  1366. {
  1367. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  1368. }
  1369. var result = query.OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ThenBy(x => x.SchoolyearValue).ToGridResultSet<StudentChangeView>(pageIndex, pageSize);
  1370. result.rows.ForEach(x => x.ApprovalStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  1371. return result;
  1372. }
  1373. /// <summary>
  1374. /// 查询对应的学籍异动信息List
  1375. /// </summary>
  1376. /// <param name="configuretView"></param>
  1377. /// <param name="userID"></param>
  1378. /// <param name="schoolyearID"></param>
  1379. /// <param name="changeTypeID"></param>
  1380. /// <returns></returns>
  1381. public IList<StudentChangeView> GetStudentChangeViewList(ConfiguretView configuretView, Guid? userID, Guid? schoolyearID, int? changeTypeID)
  1382. {
  1383. var approveStatusList = this.GetStatusViewList();
  1384. var endStatusID = this.GetCorrectEndStatus();
  1385. Expression<Func<CF_DifferentDynamic, bool>> expStudentChange = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1386. expStudentChange = expStudentChange.And(x => x.UserID == userID);
  1387. expStudentChange = expStudentChange.And(x => x.ApprovalStatus == endStatusID);
  1388. if (schoolyearID.HasValue)
  1389. {
  1390. expStudentChange = expStudentChange.And(x => x.SchoolyearID == schoolyearID);
  1391. }
  1392. if (changeTypeID.HasValue)
  1393. {
  1394. expStudentChange = expStudentChange.And(x => x.ChangeTypeID == changeTypeID);
  1395. }
  1396. var query = StudentChangeDAL.Value.GetStudentChangeViewQueryable(expStudentChange);
  1397. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  1398. {
  1399. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  1400. }
  1401. var result = query.OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ThenBy(x => x.SchoolyearValue).ToList();
  1402. result.ForEach(x => x.ApprovalStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  1403. return result;
  1404. }
  1405. /// <summary>
  1406. /// 查询对应的学籍注册信息StudentReportView
  1407. /// </summary>
  1408. /// <param name="configuretView"></param>
  1409. /// <param name="userID"></param>
  1410. /// <param name="schoolyearID"></param>
  1411. /// <param name="reportStatus"></param>
  1412. /// <param name="pageIndex"></param>
  1413. /// <param name="pageSize"></param>
  1414. /// <returns></returns>
  1415. public IGridResultSet<StudentReportView> GetStudentReportViewGrid(ConfiguretView configuretView, Guid? userID, Guid? schoolyearID, int? reportStatus, int pageIndex, int pageSize)
  1416. {
  1417. Expression<Func<EM_StudentReport, bool>> expStudentReport = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1418. expStudentReport = expStudentReport.And(x => x.UserID == userID);
  1419. if (schoolyearID.HasValue)
  1420. {
  1421. expStudentReport = expStudentReport.And(x => x.SchoolyearID == schoolyearID);
  1422. }
  1423. if (reportStatus.HasValue)
  1424. {
  1425. expStudentReport = expStudentReport.And(x => x.ReportStatus == reportStatus);
  1426. }
  1427. var query = StudentReportDAL.Value.GetStudentReportViewQueryable(expStudentReport);
  1428. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  1429. {
  1430. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  1431. }
  1432. return query.OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ThenBy(x => x.SchoolyearValue).ToGridResultSet<StudentReportView>(pageIndex, pageSize);
  1433. }
  1434. /// <summary>
  1435. /// 查询对应的学籍注册信息List
  1436. /// </summary>
  1437. /// <param name="configuretView"></param>
  1438. /// <param name="userID"></param>
  1439. /// <param name="schoolyearID"></param>
  1440. /// <param name="reportStatus"></param>
  1441. /// <returns></returns>
  1442. public IList<StudentReportView> GetStudentReportViewList(ConfiguretView configuretView, Guid? userID, Guid? schoolyearID, int? reportStatus)
  1443. {
  1444. Expression<Func<EM_StudentReport, bool>> expStudentReport = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1445. expStudentReport = expStudentReport.And(x => x.UserID == userID);
  1446. if (schoolyearID.HasValue)
  1447. {
  1448. expStudentReport = expStudentReport.And(x => x.SchoolyearID == schoolyearID);
  1449. }
  1450. if (reportStatus.HasValue)
  1451. {
  1452. expStudentReport = expStudentReport.And(x => x.ReportStatus == reportStatus);
  1453. }
  1454. var query = StudentReportDAL.Value.GetStudentReportViewQueryable(expStudentReport);
  1455. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  1456. {
  1457. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  1458. }
  1459. return query.OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ThenBy(x => x.SchoolyearValue).ToList();
  1460. }
  1461. /// <summary>
  1462. /// 删除照片(单个删除)
  1463. /// </summary>
  1464. /// <param name="userID"></param>
  1465. public void DeletePhoto(Guid? userID)
  1466. {
  1467. try
  1468. {
  1469. var student = StudentDAL.Value.StudentRepository.GetList(x => x.UserID == userID).SingleOrDefault();
  1470. if (student != null)
  1471. {
  1472. if (!string.IsNullOrEmpty(student.PhotoUrl))
  1473. {
  1474. FileUploadHelper.DeleteFile(student.PhotoUrl);
  1475. student.PhotoUrl = null;
  1476. this.UnitOfWork.Commit();
  1477. }
  1478. else
  1479. {
  1480. throw new Exception("对应的照片不存在。");
  1481. }
  1482. }
  1483. else
  1484. {
  1485. throw new Exception("对应的信息未保存,数据有误。");
  1486. }
  1487. }
  1488. catch (Exception ex)
  1489. {
  1490. throw new Exception(ex.Message);
  1491. }
  1492. }
  1493. /// <summary>
  1494. /// 删除照片(批量删除)
  1495. /// </summary>
  1496. /// <param name="userIDs"></param>
  1497. /// <returns></returns>
  1498. public bool PicDelete(List<Guid?> userIDs)
  1499. {
  1500. try
  1501. {
  1502. List<string> photoUrlList = new List<string>();
  1503. List<CF_Student> studentUpList = new List<CF_Student>();
  1504. var studentList = StudentDAL.Value.StudentRepository.GetList(x => userIDs.Contains(x.UserID)).ToList();
  1505. foreach (var student in studentList)
  1506. {
  1507. if (student != null)
  1508. {
  1509. if (!string.IsNullOrEmpty(student.PhotoUrl))
  1510. {
  1511. photoUrlList.Add(student.PhotoUrl);
  1512. student.PhotoUrl = null;
  1513. studentUpList.Add(student);
  1514. }
  1515. }
  1516. }
  1517. using (TransactionScope ts = new TransactionScope())
  1518. {
  1519. foreach (var photoUrl in photoUrlList)
  1520. {
  1521. FileUploadHelper.DeleteFile(photoUrl);
  1522. }
  1523. if (studentUpList != null && studentUpList.Count() > 0)
  1524. {
  1525. UnitOfWork.BatchUpdate(studentUpList);
  1526. }
  1527. ts.Complete();
  1528. }
  1529. return true;
  1530. }
  1531. catch (Exception)
  1532. {
  1533. throw;
  1534. }
  1535. }
  1536. /// <summary>
  1537. /// 照片比对通过
  1538. /// </summary>
  1539. /// <param name="userIDList"></param>
  1540. /// <returns></returns>
  1541. public string StudentPicComparisonPass(List<Guid?> userIDList)
  1542. {
  1543. try
  1544. {
  1545. var studentList = StudentDAL.Value.StudentRepository.GetList(x => userIDList.Contains(x.UserID), (x => x.CF_Recruitstudents)).ToList();
  1546. int success = 0;
  1547. int fail = 0;
  1548. string tipMessage = null;
  1549. var studentUpList = new List<CF_Student>();
  1550. foreach (var userID in userIDList)
  1551. {
  1552. var student = studentList.Where(x => x.UserID == userID).SingleOrDefault();
  1553. if (student == null)
  1554. {
  1555. throw new Exception("数据有误,请检查。");
  1556. }
  1557. else
  1558. {
  1559. if (student.CF_Recruitstudents == null)
  1560. {
  1561. fail++;
  1562. }
  1563. else if (string.IsNullOrWhiteSpace(student.CF_Recruitstudents.RecruitPictureUrl) || string.IsNullOrWhiteSpace(student.PhotoUrl) || string.IsNullOrWhiteSpace(student.GraduationPictureUrl))
  1564. {
  1565. fail++;
  1566. }
  1567. else
  1568. {
  1569. student.IsPhotoComparison = true;
  1570. SetModifyStatus(student);
  1571. studentUpList.Add(student);
  1572. success++;
  1573. }
  1574. }
  1575. }
  1576. if (studentUpList != null && studentUpList.Count() > 0)
  1577. {
  1578. UnitOfWork.BatchUpdate(studentUpList);
  1579. }
  1580. if (success > 0 && fail <= 0)
  1581. {
  1582. tipMessage = success + "条";
  1583. }
  1584. else
  1585. {
  1586. tipMessage = success + "条," + fail + "条失败,原因:录取照片、学籍照片或学历照片信息不全,请检查";
  1587. }
  1588. return tipMessage;
  1589. }
  1590. catch (Exception ex)
  1591. {
  1592. throw new Exception(ex.Message);
  1593. }
  1594. }
  1595. /// <summary>
  1596. /// 照片比对驳回
  1597. /// </summary>
  1598. /// <param name="userIDList"></param>
  1599. /// <returns></returns>
  1600. public string StudentPicComparisonUndo(List<Guid?> userIDList)
  1601. {
  1602. try
  1603. {
  1604. var studentList = StudentDAL.Value.StudentRepository.GetList(x => userIDList.Contains(x.UserID), (x => x.CF_Recruitstudents)).ToList();
  1605. int success = 0;
  1606. int fail = 0;
  1607. string tipMessage = null;
  1608. var studentUpList = new List<CF_Student>();
  1609. foreach (var userID in userIDList)
  1610. {
  1611. var student = studentList.Where(x => x.UserID == userID).SingleOrDefault();
  1612. if (student == null)
  1613. {
  1614. fail++;
  1615. }
  1616. else
  1617. {
  1618. student.IsPhotoComparison = false;
  1619. SetModifyStatus(student);
  1620. studentUpList.Add(student);
  1621. success++;
  1622. }
  1623. }
  1624. if (studentUpList != null && studentUpList.Count() > 0)
  1625. {
  1626. UnitOfWork.BatchUpdate(studentUpList);
  1627. }
  1628. if (success > 0 && fail <= 0)
  1629. {
  1630. tipMessage = success + "条";
  1631. }
  1632. else
  1633. {
  1634. tipMessage = success + "条," + fail + "条失败,原因:数据有误,请检查";
  1635. }
  1636. return tipMessage;
  1637. }
  1638. catch (Exception ex)
  1639. {
  1640. throw new Exception(ex.Message);
  1641. }
  1642. }
  1643. /// <summary>
  1644. /// DBF文件创建
  1645. /// </summary>
  1646. /// <param name="dt"></param>
  1647. /// <param name="colnameList"></param>
  1648. /// <param name="savePath"></param>
  1649. /// <returns></returns>
  1650. public string CreateDBFFile(DataTable dt, List<string> colnameList, string savePath = null)
  1651. {
  1652. if (dt == null || dt.Rows.Count <= 0) return null;
  1653. if (colnameList == null || colnameList.Count <= 0) return null;
  1654. var tagetPhysicalPath = FileUploadHelper.GetFileUploadTagetPhysicalPath(savePath);
  1655. var newFileName = DateTime.Today.ToString("MMdd") + "DBF.dbf";
  1656. var physicalFileName = tagetPhysicalPath + newFileName;
  1657. string connString = "Provider=Microsoft.Jet.OLEDB.4.0; " + "Data Source=" + tagetPhysicalPath + "; " + "Extended Properties=dBASE IV;";
  1658. OleDbConnection conn = new OleDbConnection(connString);
  1659. conn.Open();
  1660. OleDbCommand oleDbComm;
  1661. try
  1662. {
  1663. if (File.Exists(physicalFileName))
  1664. {
  1665. File.Delete(physicalFileName);
  1666. }
  1667. StringBuilder createTable = new StringBuilder();
  1668. createTable.Append("CREATE TABLE " + newFileName + " (");
  1669. for (int i = 0; i < colnameList.Count; i++)
  1670. {
  1671. createTable.Append(colnameList[i]);
  1672. if (colnameList[i].Equals("KSH", StringComparison.OrdinalIgnoreCase))
  1673. {
  1674. createTable.Append(" char(18)");
  1675. }
  1676. else if (colnameList[i].Equals("XM", StringComparison.OrdinalIgnoreCase))
  1677. {
  1678. createTable.Append(" char(40)");
  1679. }
  1680. else if (colnameList[i].Equals("XB", StringComparison.OrdinalIgnoreCase))
  1681. {
  1682. createTable.Append(" char(2)");
  1683. }
  1684. else if (colnameList[i].Equals("CSRQ", StringComparison.OrdinalIgnoreCase))
  1685. {
  1686. createTable.Append(" char(8)");
  1687. }
  1688. else if (colnameList[i].Equals("SFZH", StringComparison.OrdinalIgnoreCase))
  1689. {
  1690. createTable.Append(" char(18)");
  1691. }
  1692. else if (colnameList[i].Equals("YXDM", StringComparison.OrdinalIgnoreCase))
  1693. {
  1694. createTable.Append(" char(5)");
  1695. }
  1696. else if (colnameList[i].Equals("YXMC", StringComparison.OrdinalIgnoreCase))
  1697. {
  1698. createTable.Append(" char(60)");
  1699. }
  1700. else if (colnameList[i].Equals("ZYDM", StringComparison.OrdinalIgnoreCase))
  1701. {
  1702. createTable.Append(" char(8)");
  1703. }
  1704. else if (colnameList[i].Equals("ZYMC", StringComparison.OrdinalIgnoreCase))
  1705. {
  1706. createTable.Append(" char(50)");
  1707. }
  1708. else if (colnameList[i].Equals("XZ", StringComparison.OrdinalIgnoreCase))
  1709. {
  1710. createTable.Append(" char(3)");
  1711. }
  1712. else if (colnameList[i].Equals("XXXS", StringComparison.OrdinalIgnoreCase))
  1713. {
  1714. createTable.Append(" char(10)");
  1715. }
  1716. else if (colnameList[i].Equals("CC", StringComparison.OrdinalIgnoreCase))
  1717. {
  1718. createTable.Append(" char(12)");
  1719. }
  1720. else if (colnameList[i].Equals("RXRQ", StringComparison.OrdinalIgnoreCase))
  1721. {
  1722. createTable.Append(" char(8)");
  1723. }
  1724. else if (colnameList[i].Equals("BYRQ", StringComparison.OrdinalIgnoreCase))
  1725. {
  1726. createTable.Append(" char(8)");
  1727. }
  1728. else if (colnameList[i].Equals("BJYJL", StringComparison.OrdinalIgnoreCase))
  1729. {
  1730. createTable.Append(" char(4)");
  1731. }
  1732. else if (colnameList[i].Equals("ZSBH", StringComparison.OrdinalIgnoreCase))
  1733. {
  1734. createTable.Append(" char(18)");
  1735. }
  1736. else if (colnameList[i].Equals("XZM", StringComparison.OrdinalIgnoreCase))
  1737. {
  1738. createTable.Append(" char(40)");
  1739. }
  1740. else if (colnameList[i].Equals("SYSSDM", StringComparison.OrdinalIgnoreCase))
  1741. {
  1742. createTable.Append(" char(2)");
  1743. }
  1744. else if (colnameList[i].Equals("XH", StringComparison.OrdinalIgnoreCase))
  1745. {
  1746. createTable.Append(" char(15)");
  1747. }
  1748. else if (colnameList[i].Equals("ZZMM", StringComparison.OrdinalIgnoreCase))
  1749. {
  1750. createTable.Append(" char(16)");
  1751. }
  1752. else if (colnameList[i].Equals("MZ", StringComparison.OrdinalIgnoreCase))
  1753. {
  1754. createTable.Append(" char(24)");
  1755. }
  1756. else if (colnameList[i].Equals("FY", StringComparison.OrdinalIgnoreCase))
  1757. {
  1758. createTable.Append(" char(24)");
  1759. }
  1760. else if (colnameList[i].Equals("XSH", StringComparison.OrdinalIgnoreCase))
  1761. {
  1762. createTable.Append(" char(24)");
  1763. }
  1764. else if (colnameList[i].Equals("BH", StringComparison.OrdinalIgnoreCase))
  1765. {
  1766. createTable.Append(" char(24)");
  1767. }
  1768. else if (colnameList[i].Equals("BM", StringComparison.OrdinalIgnoreCase))
  1769. {
  1770. createTable.Append(" char(100)");
  1771. }
  1772. else if (colnameList[i].Equals("YJBYRQ", StringComparison.OrdinalIgnoreCase))
  1773. {
  1774. createTable.Append(" char(8)");
  1775. }
  1776. else if (colnameList[i].Equals("BZ", StringComparison.OrdinalIgnoreCase))
  1777. {
  1778. createTable.Append(" char(50)");
  1779. }
  1780. else
  1781. {
  1782. createTable.Append(" char(50)");
  1783. }
  1784. if (i != colnameList.Count - 1)
  1785. {
  1786. createTable.Append(", ");
  1787. }
  1788. else
  1789. {
  1790. createTable.Append(")");
  1791. }
  1792. }
  1793. oleDbComm = new OleDbCommand(createTable.ToString(), conn);
  1794. oleDbComm.ExecuteNonQuery();
  1795. StringBuilder createInsert = new StringBuilder();
  1796. foreach (DataRow dr in dt.Rows)
  1797. {
  1798. createInsert.Clear();
  1799. createInsert.Append(" INSERT INTO " + newFileName + " (");
  1800. for (int i = 0; i < colnameList.Count; i++)
  1801. {
  1802. createInsert.Append(colnameList[i]);
  1803. if (i != colnameList.Count - 1)
  1804. {
  1805. createInsert.Append(", ");
  1806. }
  1807. }
  1808. createInsert.Append(") VALUES (");
  1809. for (int i = 0; i < dt.Columns.Count; i++)
  1810. {
  1811. createInsert.Append("'" + dr[i].ToString() + "'");
  1812. if (i != dt.Columns.Count - 1)
  1813. {
  1814. createInsert.Append(", ");
  1815. }
  1816. else
  1817. {
  1818. createInsert.Append(")");
  1819. }
  1820. }
  1821. oleDbComm = new OleDbCommand(createInsert.ToString(), conn);
  1822. oleDbComm.ExecuteNonQuery();
  1823. }
  1824. return physicalFileName;
  1825. }
  1826. catch (Exception ex)
  1827. {
  1828. throw new Exception(ex.Message);
  1829. }
  1830. finally
  1831. {
  1832. conn.Close();
  1833. }
  1834. }
  1835. /// <summary>
  1836. /// 操行录入
  1837. /// </summary>
  1838. /// <param name="userIDs"></param>
  1839. /// <param name="studentConductView"></param>
  1840. /// <returns></returns>
  1841. public string StudentConductInput(List<Guid?> userIDs, StudentConductView studentConductView)
  1842. {
  1843. try
  1844. {
  1845. var studentConductList = StudentDAL.Value.StudentConductRepository.GetList(x => userIDs.Contains(x.UserID)).ToList();
  1846. int success = 0;
  1847. string tipMessage = null;
  1848. List<EM_StudentConduct> studentConductInList = new List<EM_StudentConduct>();
  1849. List<EM_StudentConduct> studentConductUpList = new List<EM_StudentConduct>();
  1850. foreach (var userID in userIDs)
  1851. {
  1852. var studentConduct = studentConductList.Where(x => x.UserID == userID && x.SchoolyearNumID == studentConductView.SchoolyearNumID).SingleOrDefault();
  1853. if (studentConduct != null)
  1854. {
  1855. studentConduct.Comment = studentConductView.Comment;
  1856. this.SetModifyStatus(studentConduct);
  1857. studentConductUpList.Add(studentConduct);
  1858. success++;
  1859. }
  1860. else
  1861. {
  1862. var newStudentConduct = new EM_StudentConduct();
  1863. newStudentConduct.StudentConductID = Guid.NewGuid();
  1864. newStudentConduct.UserID = userID;
  1865. newStudentConduct.SchoolyearNumID = studentConductView.SchoolyearNumID;
  1866. newStudentConduct.Comment = studentConductView.Comment;
  1867. newStudentConduct.Remark = null;
  1868. this.SetNewStatus(newStudentConduct);
  1869. studentConductInList.Add(newStudentConduct);
  1870. success++;
  1871. }
  1872. }
  1873. UnitOfWork.BulkInsert<EM_StudentConduct>(studentConductInList);
  1874. if (studentConductUpList != null && studentConductUpList.Count() > 0)
  1875. {
  1876. UnitOfWork.BatchUpdate(studentConductUpList);
  1877. }
  1878. if (success > 0)
  1879. {
  1880. tipMessage = success + "条";
  1881. }
  1882. else
  1883. {
  1884. tipMessage = success + "条";
  1885. }
  1886. return tipMessage;
  1887. }
  1888. catch (Exception ex)
  1889. {
  1890. throw new Exception(ex.Message);
  1891. }
  1892. }
  1893. /// <summary>
  1894. /// 毕业证书编号Excel导入
  1895. /// </summary>
  1896. /// <param name="cellheader"></param>
  1897. /// <param name="inCount"></param>
  1898. /// <param name="upCount"></param>
  1899. /// <param name="errdataList"></param>
  1900. /// <param name="errCount"></param>
  1901. /// <param name="sourcePhysicalPath"></param>
  1902. public void GraduateNoImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount, out List<StudentView> errdataList, out int? errCount, string sourcePhysicalPath)
  1903. {
  1904. try
  1905. {
  1906. StringBuilder errorMsg = new StringBuilder();
  1907. List<StudentView> errList = new List<StudentView>();
  1908. cellheader.Remove("ErrorMessage");
  1909. List<StudentView> enlist = NpoiExcelHelper.ExcelToEntityList<StudentView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
  1910. cellheader.Add("ErrorMessage", "未导入原因");
  1911. //对List集合进行有效性校验
  1912. if (enlist.Count() <= 0)
  1913. {
  1914. throw new Exception("Excel文件数据为空,请检查。");
  1915. }
  1916. Regex reg = null; //正则表达式
  1917. //DateTime result; //用于返回判断日期字段格式
  1918. inCount = 0; //导入个数
  1919. upCount = 0; //更新个数
  1920. errCount = 0; //失败个数
  1921. string errorMsgStr = ""; //错误信息
  1922. List<CF_Student> newStudentInList = new List<CF_Student>();
  1923. List<CF_Student> newStudentUpList = new List<CF_Student>();
  1924. //移除StuUpList
  1925. List<CF_Student> removeStuUpList = new List<CF_Student>();
  1926. //将循环中相关数据库查询统一查询出来进行匹配(尽量避免在循环中进行数据库查询)
  1927. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  1928. //身份证号List
  1929. var iDNumberList = enlist.Where(x => !string.IsNullOrEmpty(x.IDNumber)).Select(x => x.IDNumber).ToList();
  1930. //毕业证书编号List
  1931. var graduateCardNoList = enlist.Where(x => !string.IsNullOrEmpty(x.GraduateCardNo)).Select(x => x.GraduateCardNo).ToList();
  1932. expStudent = expStudent.And(x => iDNumberList.Contains(x.IDNumber) || graduateCardNoList.Contains(x.GraduateCardNo));
  1933. //对比后的newStudentList
  1934. var newStudentList = StudentDAL.Value.StudentRepository.GetList(expStudent).ToList();
  1935. //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等)
  1936. for (int i = 0; i < enlist.Count; i++)
  1937. {
  1938. StudentView en = enlist[i];
  1939. CF_Student newStudent = new CF_Student();
  1940. //身份证号
  1941. if (string.IsNullOrEmpty(en.IDNumber))
  1942. {
  1943. errCount++;
  1944. errorMsgStr = "身份证号不能为空";
  1945. en.ErrorMessage = errorMsgStr;
  1946. errList.Add(en);
  1947. errorMsg.AppendLine(errorMsgStr);
  1948. continue;
  1949. }
  1950. else
  1951. {
  1952. var studentIDNumberList = newStudentList.Where(x => x.IDNumber == en.IDNumber.Trim()).ToList();
  1953. if (studentIDNumberList != null && studentIDNumberList.Count() > 1)
  1954. {
  1955. errCount++;
  1956. errorMsgStr = "对应的身份证号存在多个学生信息,请检查";
  1957. en.ErrorMessage = errorMsgStr;
  1958. errList.Add(en);
  1959. errorMsg.AppendLine(errorMsgStr);
  1960. continue;
  1961. }
  1962. else
  1963. {
  1964. var student = studentIDNumberList.Where(x => x.IDNumber == en.IDNumber.Trim()).SingleOrDefault();
  1965. if (student == null)
  1966. {
  1967. errCount++;
  1968. errorMsgStr = "对应的身份证号不存在相应的学生信息,请检查";
  1969. en.ErrorMessage = errorMsgStr;
  1970. errList.Add(en);
  1971. errorMsg.AppendLine(errorMsgStr);
  1972. continue;
  1973. }
  1974. else
  1975. {
  1976. //学生信息
  1977. newStudent.UserID = student.UserID;
  1978. newStudent.IDNumber = en.IDNumber.Trim();
  1979. }
  1980. }
  1981. }
  1982. //毕业证书编号
  1983. if (string.IsNullOrEmpty(en.GraduateCardNo))
  1984. {
  1985. errCount++;
  1986. errorMsgStr = "毕业证书编号不能为空";
  1987. en.ErrorMessage = errorMsgStr;
  1988. errList.Add(en);
  1989. errorMsg.AppendLine(errorMsgStr);
  1990. continue;
  1991. }
  1992. else
  1993. {
  1994. reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
  1995. if (!reg.IsMatch(en.GraduateCardNo))
  1996. {
  1997. errCount++;
  1998. errorMsgStr = "毕业证书编号格式不正确,请检查(数字或英文字母)";
  1999. en.ErrorMessage = errorMsgStr;
  2000. errList.Add(en);
  2001. errorMsg.AppendLine(errorMsgStr);
  2002. continue;
  2003. }
  2004. else
  2005. {
  2006. var graduateNoStudentList = newStudentList.Where(x => x.UserID != newStudent.UserID && x.GraduateCardNo == en.GraduateCardNo.Trim()).ToList();
  2007. if (graduateNoStudentList != null && graduateNoStudentList.Count() > 1)
  2008. {
  2009. errCount++;
  2010. errorMsgStr = "对应的毕业证书编号存在多个学生信息中(重复),请检查";
  2011. en.ErrorMessage = errorMsgStr;
  2012. errList.Add(en);
  2013. errorMsg.AppendLine(errorMsgStr);
  2014. continue;
  2015. }
  2016. else
  2017. {
  2018. var graduateNoStudent = graduateNoStudentList.Where(x => x.GraduateCardNo == en.GraduateCardNo.Trim()).SingleOrDefault();
  2019. if (graduateNoStudent == null)
  2020. {
  2021. newStudent.GraduateCardNo = en.GraduateCardNo.Trim();
  2022. }
  2023. else
  2024. {
  2025. errCount++;
  2026. errorMsgStr = "对应的毕业证书编号已存在学生信息中(重复),请检查";
  2027. en.ErrorMessage = errorMsgStr;
  2028. errList.Add(en);
  2029. errorMsg.AppendLine(errorMsgStr);
  2030. continue;
  2031. }
  2032. }
  2033. }
  2034. }
  2035. ////Excel表重复性验证(注:当数据表中没有此记录,但是Excel中有重复数据时的去掉)
  2036. //for (int j = i + 1; j < enlist.Count; j++)
  2037. //{
  2038. // StudentView enA = enlist[j];
  2039. // //根据Excel表中的业务主键进行去重(学号、毕业证书编号或学生信息ID唯一)
  2040. // if (en.StudentNo == enA.StudentNo || en.GraduateCardNo == enA.GraduateCardNo || en.UserID == enA.UserID)
  2041. // {
  2042. // //用于标识Excel表中的重复记录(由于是批量进行插入数据表)
  2043. // }
  2044. //}
  2045. //数据表重复性验证(学号、毕业证书编号或学生信息ID唯一)
  2046. var studentVerify = newStudentList.Where(x => x.UserID == newStudent.UserID).SingleOrDefault();
  2047. if (studentVerify == null)
  2048. {
  2049. //由于前面已做相应判断,此处代码暂时无效
  2050. //新增
  2051. if (!newStudentInList.Any(x => x.UserID == newStudent.UserID))
  2052. {
  2053. inCount++;
  2054. }
  2055. else
  2056. {
  2057. //Excel表重复性验证
  2058. //(注:当数据表中没有此记录,但是Excel中有重复数据,可在此处进行抛出到失败数据文件中,目前暂不考虑)
  2059. inCount++;
  2060. }
  2061. }
  2062. else
  2063. {
  2064. //注:毕业证书编号唯一
  2065. //更新(Excel中有重复时,以数据重复抛出到失败数据文件中进行处理,不进行更新)
  2066. if (!removeStuUpList.Any(x => x.GraduateCardNo == en.GraduateCardNo.Trim()))
  2067. {
  2068. if (!newStudentUpList.Any(x => x.GraduateCardNo == en.GraduateCardNo.Trim()))
  2069. {
  2070. studentVerify.GraduateCardNo = newStudent.GraduateCardNo;
  2071. studentVerify.InSchoolStatusID = (int)CF_InschoolStatus.Graduation;
  2072. studentVerify.StudentStatus = (int)CF_StudentStatus.Graduation;
  2073. SetModifyStatus(studentVerify);
  2074. newStudentUpList.Add(studentVerify);
  2075. upCount++;
  2076. }
  2077. else
  2078. {
  2079. var stuUpList = newStudentUpList.Where(x => x.GraduateCardNo == en.GraduateCardNo.Trim()).ToList();
  2080. foreach (var stuUp in stuUpList)
  2081. {
  2082. errCount++;
  2083. errorMsgStr = "毕业证书编号重复,请检查";
  2084. en.ErrorMessage = errorMsgStr;
  2085. errList.Add(new StudentView()
  2086. {
  2087. IDNumber = en.IDNumber,
  2088. GraduateCardNo = en.GraduateCardNo,
  2089. ErrorMessage = en.ErrorMessage
  2090. });
  2091. errorMsg.AppendLine(errorMsgStr);
  2092. newStudentUpList.Remove(stuUp);
  2093. removeStuUpList.Add(stuUp);
  2094. upCount--;
  2095. }
  2096. errCount++;
  2097. errorMsgStr = "毕业证书编号重复,请检查";
  2098. en.ErrorMessage = errorMsgStr;
  2099. errList.Add(en);
  2100. errorMsg.AppendLine(errorMsgStr);
  2101. continue;
  2102. }
  2103. }
  2104. else
  2105. {
  2106. errCount++;
  2107. errorMsgStr = "毕业证书编号重复,请检查";
  2108. en.ErrorMessage = errorMsgStr;
  2109. errList.Add(en);
  2110. errorMsg.AppendLine(errorMsgStr);
  2111. continue;
  2112. }
  2113. }
  2114. }
  2115. //移除Up
  2116. if (removeStuUpList != null && removeStuUpList.Count() > 0)
  2117. {
  2118. foreach (var removeStuUp in removeStuUpList)
  2119. {
  2120. newStudentUpList.Remove(removeStuUp);
  2121. }
  2122. }
  2123. //批量统一提交更新
  2124. if (newStudentUpList != null && newStudentUpList.Count() > 0)
  2125. {
  2126. UnitOfWork.BatchUpdate<CF_Student>(newStudentUpList);
  2127. }
  2128. errdataList = errList.Distinct().ToList();
  2129. }
  2130. catch (Exception ex)
  2131. {
  2132. throw new Exception(ex.Message);
  2133. }
  2134. }
  2135. /// <summary>
  2136. /// 导入学籍照片
  2137. /// </summary>
  2138. /// <param name="photoPaths"></param>
  2139. /// <param name="importPicType"></param>
  2140. /// <param name="inCount"></param>
  2141. /// <param name="errCount"></param>
  2142. /// <param name="errDataTable"></param>
  2143. public void StudentPicImport(IList<string> photoPaths, string importPicType, out int? inCount, out int? errCount, out DataTable errDataTable)
  2144. {
  2145. try
  2146. {
  2147. var mapList = photoPaths.Select(s => new
  2148. {
  2149. PhotoInfo = Path.GetFileName(s).Trim(),
  2150. PhotoName = Path.GetFileNameWithoutExtension(s).Trim(),
  2151. PhotoPath = s,
  2152. }).ToArray();
  2153. var photoNameList = mapList.Select(s => s.PhotoName).Distinct().ToList();
  2154. inCount = 0;
  2155. errCount = 0;
  2156. errDataTable = new DataTable();
  2157. List<CF_Student> studentUpList = new List<CF_Student>();
  2158. if (importPicType.Equals("StudentNo"))
  2159. {
  2160. errDataTable.Columns.Add("PhotoInfo", typeof(string));
  2161. errDataTable.Columns.Add("StudentNo", typeof(string));
  2162. errDataTable.Columns.Add("ErrorMessage", typeof(string));
  2163. var userList = StudentDAL.Value.UserRepository.GetList(x => photoNameList.Contains(x.LoginID), (x => x.CF_Student)).ToList();
  2164. foreach (var map in mapList)
  2165. {
  2166. var user = userList.Where(x => x.LoginID == map.PhotoName).SingleOrDefault();
  2167. if (user == null)
  2168. {
  2169. DataRow errDataRow = errDataTable.NewRow();
  2170. errDataRow["PhotoInfo"] = map.PhotoInfo;
  2171. errDataRow["StudentNo"] = map.PhotoName;
  2172. errDataRow["ErrorMessage"] = "不存在对应的学号(" + map.PhotoName + ")";
  2173. errDataTable.Rows.Add(errDataRow);
  2174. errCount++;
  2175. }
  2176. else
  2177. {
  2178. if (user.CF_Student == null)
  2179. {
  2180. DataRow errDataRow = errDataTable.NewRow();
  2181. errDataRow["PhotoInfo"] = map.PhotoInfo;
  2182. errDataRow["StudentNo"] = map.PhotoName;
  2183. errDataRow["ErrorMessage"] = "不存在对应的学号(" + map.PhotoName + ")";
  2184. errDataTable.Rows.Add(errDataRow);
  2185. errCount++;
  2186. }
  2187. else
  2188. {
  2189. user.CF_Student.PhotoUrl = map.PhotoPath;
  2190. studentUpList.Add(user.CF_Student);
  2191. inCount++;
  2192. }
  2193. }
  2194. }
  2195. }
  2196. else if (importPicType.Equals("ExamineeNum"))
  2197. {
  2198. var newPhotoNameList = new List<string>();
  2199. foreach (var photoName in photoNameList)
  2200. {
  2201. var photoNameStart = photoName.Substring(0, 1);
  2202. if (photoNameStart.Equals("F") || photoNameStart.Equals("Z"))
  2203. {
  2204. newPhotoNameList.Add(photoName.Substring(1));
  2205. }
  2206. }
  2207. errDataTable.Columns.Add("PhotoInfo", typeof(string));
  2208. errDataTable.Columns.Add("ExamineeNum", typeof(string));
  2209. errDataTable.Columns.Add("ErrorMessage", typeof(string));
  2210. var recruitStudentList = StudentDAL.Value.RecruitstudentsRepository.GetList(x => photoNameList.Contains(x.ExamineeNum) || newPhotoNameList.Contains(x.ExamineeNum), (x => x.CF_Student)).ToList();
  2211. foreach (var map in mapList)
  2212. {
  2213. var photoNameStart = map.PhotoName.Substring(0, 1);
  2214. if (photoNameStart.Equals("F") || photoNameStart.Equals("Z"))
  2215. {
  2216. var recruitStudent = recruitStudentList.Where(x => x.ExamineeNum == map.PhotoName || x.ExamineeNum == map.PhotoName.Substring(1)).SingleOrDefault();
  2217. if (recruitStudent == null)
  2218. {
  2219. DataRow errDataRow = errDataTable.NewRow();
  2220. errDataRow["PhotoInfo"] = map.PhotoInfo;
  2221. errDataRow["ExamineeNum"] = map.PhotoName;
  2222. errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
  2223. errDataTable.Rows.Add(errDataRow);
  2224. errCount++;
  2225. }
  2226. else
  2227. {
  2228. if (recruitStudent.CF_Student == null)
  2229. {
  2230. DataRow errDataRow = errDataTable.NewRow();
  2231. errDataRow["PhotoInfo"] = map.PhotoInfo;
  2232. errDataRow["ExamineeNum"] = map.PhotoName;
  2233. errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
  2234. errDataTable.Rows.Add(errDataRow);
  2235. errCount++;
  2236. }
  2237. else
  2238. {
  2239. recruitStudent.CF_Student.PhotoUrl = map.PhotoPath;
  2240. studentUpList.Add(recruitStudent.CF_Student);
  2241. inCount++;
  2242. }
  2243. }
  2244. }
  2245. else
  2246. {
  2247. var recruitStudent = recruitStudentList.Where(x => x.ExamineeNum == map.PhotoName).SingleOrDefault();
  2248. if (recruitStudent == null)
  2249. {
  2250. DataRow errDataRow = errDataTable.NewRow();
  2251. errDataRow["PhotoInfo"] = map.PhotoInfo;
  2252. errDataRow["ExamineeNum"] = map.PhotoName;
  2253. errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
  2254. errDataTable.Rows.Add(errDataRow);
  2255. errCount++;
  2256. }
  2257. else
  2258. {
  2259. if (recruitStudent.CF_Student == null)
  2260. {
  2261. DataRow errDataRow = errDataTable.NewRow();
  2262. errDataRow["PhotoInfo"] = map.PhotoInfo;
  2263. errDataRow["ExamineeNum"] = map.PhotoName;
  2264. errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
  2265. errDataTable.Rows.Add(errDataRow);
  2266. errCount++;
  2267. }
  2268. else
  2269. {
  2270. recruitStudent.CF_Student.PhotoUrl = map.PhotoPath;
  2271. studentUpList.Add(recruitStudent.CF_Student);
  2272. inCount++;
  2273. }
  2274. }
  2275. }
  2276. }
  2277. }
  2278. else if (importPicType.Equals("IDNumber"))
  2279. {
  2280. errDataTable.Columns.Add("PhotoInfo", typeof(string));
  2281. errDataTable.Columns.Add("IDNumber", typeof(string));
  2282. errDataTable.Columns.Add("ErrorMessage", typeof(string));
  2283. var studentList = StudentDAL.Value.StudentRepository.GetList(x => photoNameList.Contains(x.IDNumber)).ToList();
  2284. foreach (var map in mapList)
  2285. {
  2286. var newStudentList = studentList.Where(x => x.IDNumber == map.PhotoName).ToList();
  2287. if (newStudentList != null && newStudentList.Count() > 1)
  2288. {
  2289. DataRow errDataRow = errDataTable.NewRow();
  2290. errDataRow["PhotoInfo"] = map.PhotoInfo;
  2291. errDataRow["IDNumber"] = map.PhotoName;
  2292. errDataRow["ErrorMessage"] = "存在多个对应的证件号码(" + map.PhotoName + ")";
  2293. errDataTable.Rows.Add(errDataRow);
  2294. errCount++;
  2295. }
  2296. else
  2297. {
  2298. if (newStudentList != null && newStudentList.Count() == 1)
  2299. {
  2300. var student = newStudentList.Where(x => x.IDNumber == map.PhotoName).SingleOrDefault();
  2301. if (student == null)
  2302. {
  2303. DataRow errDataRow = errDataTable.NewRow();
  2304. errDataRow["PhotoInfo"] = map.PhotoInfo;
  2305. errDataRow["IDNumber"] = map.PhotoName;
  2306. errDataRow["ErrorMessage"] = "不存在对应的证件号码(" + map.PhotoName + ")";
  2307. errDataTable.Rows.Add(errDataRow);
  2308. errCount++;
  2309. }
  2310. else
  2311. {
  2312. student.PhotoUrl = map.PhotoPath;
  2313. studentUpList.Add(student);
  2314. inCount++;
  2315. }
  2316. }
  2317. else
  2318. {
  2319. DataRow errDataRow = errDataTable.NewRow();
  2320. errDataRow["PhotoInfo"] = map.PhotoInfo;
  2321. errDataRow["IDNumber"] = map.PhotoName;
  2322. errDataRow["ErrorMessage"] = "不存在对应的证件号码(" + map.PhotoName + ")";
  2323. errDataTable.Rows.Add(errDataRow);
  2324. errCount++;
  2325. }
  2326. }
  2327. }
  2328. }
  2329. if (studentUpList != null && studentUpList.Count() > 0)
  2330. {
  2331. UnitOfWork.BatchUpdate<CF_Student>(studentUpList);
  2332. }
  2333. }
  2334. catch (Exception)
  2335. {
  2336. throw;
  2337. }
  2338. }
  2339. /// <summary>
  2340. /// 导入学历照片
  2341. /// </summary>
  2342. /// <param name="photoPaths"></param>
  2343. /// <param name="importGraPicType"></param>
  2344. public void StudentGraPicImport(IList<string> photoPaths, string importGraPicType, out int? inCount, out int? errCount, out DataTable errDataTable)
  2345. {
  2346. try
  2347. {
  2348. var mapList = photoPaths.Select(s => new
  2349. {
  2350. PhotoInfo = Path.GetFileName(s).Trim(),
  2351. PhotoName = Path.GetFileNameWithoutExtension(s).Trim(),
  2352. PhotoPath = s,
  2353. }).ToArray();
  2354. var photoNameList = mapList.Select(s => s.PhotoName).Distinct().ToList();
  2355. inCount = 0;
  2356. errCount = 0;
  2357. errDataTable = new DataTable();
  2358. List<CF_Student> studentUpList = new List<CF_Student>();
  2359. if (importGraPicType.Equals("StudentNo"))
  2360. {
  2361. errDataTable.Columns.Add("PhotoInfo", typeof(string));
  2362. errDataTable.Columns.Add("StudentNo", typeof(string));
  2363. errDataTable.Columns.Add("ErrorMessage", typeof(string));
  2364. var userList = StudentDAL.Value.UserRepository.GetList(x => photoNameList.Contains(x.LoginID), (x => x.CF_Student)).ToList();
  2365. foreach (var map in mapList)
  2366. {
  2367. var user = userList.Where(x => x.LoginID == map.PhotoName).SingleOrDefault();
  2368. if (user == null)
  2369. {
  2370. DataRow errDataRow = errDataTable.NewRow();
  2371. errDataRow["PhotoInfo"] = map.PhotoInfo;
  2372. errDataRow["StudentNo"] = map.PhotoName;
  2373. errDataRow["ErrorMessage"] = "不存在对应的学号(" + map.PhotoName + ")";
  2374. errDataTable.Rows.Add(errDataRow);
  2375. errCount++;
  2376. }
  2377. else
  2378. {
  2379. if (user.CF_Student == null)
  2380. {
  2381. DataRow errDataRow = errDataTable.NewRow();
  2382. errDataRow["PhotoInfo"] = map.PhotoInfo;
  2383. errDataRow["StudentNo"] = map.PhotoName;
  2384. errDataRow["ErrorMessage"] = "不存在对应的学号(" + map.PhotoName + ")";
  2385. errDataTable.Rows.Add(errDataRow);
  2386. errCount++;
  2387. }
  2388. else
  2389. {
  2390. user.CF_Student.GraduationPictureUrl = map.PhotoPath;
  2391. studentUpList.Add(user.CF_Student);
  2392. inCount++;
  2393. }
  2394. }
  2395. }
  2396. }
  2397. else if (importGraPicType.Equals("ExamineeNum"))
  2398. {
  2399. var newPhotoNameList = new List<string>();
  2400. foreach (var photoName in photoNameList)
  2401. {
  2402. var photoNameStart = photoName.Substring(0, 1);
  2403. if (photoNameStart.Equals("F") || photoNameStart.Equals("Z"))
  2404. {
  2405. newPhotoNameList.Add(photoName.Substring(1));
  2406. }
  2407. }
  2408. errDataTable.Columns.Add("PhotoInfo", typeof(string));
  2409. errDataTable.Columns.Add("ExamineeNum", typeof(string));
  2410. errDataTable.Columns.Add("ErrorMessage", typeof(string));
  2411. var recruitStudentList = StudentDAL.Value.RecruitstudentsRepository.GetList(x => photoNameList.Contains(x.ExamineeNum) || newPhotoNameList.Contains(x.ExamineeNum), (x => x.CF_Student)).ToList();
  2412. foreach (var map in mapList)
  2413. {
  2414. var photoNameStart = map.PhotoName.Substring(0, 1);
  2415. if (photoNameStart.Equals("F") || photoNameStart.Equals("Z"))
  2416. {
  2417. var recruitStudent = recruitStudentList.Where(x => x.ExamineeNum == map.PhotoName || x.ExamineeNum == map.PhotoName.Substring(1)).SingleOrDefault();
  2418. if (recruitStudent == null)
  2419. {
  2420. DataRow errDataRow = errDataTable.NewRow();
  2421. errDataRow["PhotoInfo"] = map.PhotoInfo;
  2422. errDataRow["ExamineeNum"] = map.PhotoName;
  2423. errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
  2424. errDataTable.Rows.Add(errDataRow);
  2425. errCount++;
  2426. }
  2427. else
  2428. {
  2429. if (recruitStudent.CF_Student == null)
  2430. {
  2431. DataRow errDataRow = errDataTable.NewRow();
  2432. errDataRow["PhotoInfo"] = map.PhotoInfo;
  2433. errDataRow["ExamineeNum"] = map.PhotoName;
  2434. errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
  2435. errDataTable.Rows.Add(errDataRow);
  2436. errCount++;
  2437. }
  2438. else
  2439. {
  2440. recruitStudent.CF_Student.GraduationPictureUrl = map.PhotoPath;
  2441. studentUpList.Add(recruitStudent.CF_Student);
  2442. inCount++;
  2443. }
  2444. }
  2445. }
  2446. else
  2447. {
  2448. var recruitStudent = recruitStudentList.Where(x => x.ExamineeNum == map.PhotoName).SingleOrDefault();
  2449. if (recruitStudent == null)
  2450. {
  2451. DataRow errDataRow = errDataTable.NewRow();
  2452. errDataRow["PhotoInfo"] = map.PhotoInfo;
  2453. errDataRow["ExamineeNum"] = map.PhotoName;
  2454. errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
  2455. errDataTable.Rows.Add(errDataRow);
  2456. errCount++;
  2457. }
  2458. else
  2459. {
  2460. if (recruitStudent.CF_Student == null)
  2461. {
  2462. DataRow errDataRow = errDataTable.NewRow();
  2463. errDataRow["PhotoInfo"] = map.PhotoInfo;
  2464. errDataRow["ExamineeNum"] = map.PhotoName;
  2465. errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
  2466. errDataTable.Rows.Add(errDataRow);
  2467. errCount++;
  2468. }
  2469. else
  2470. {
  2471. recruitStudent.CF_Student.GraduationPictureUrl = map.PhotoPath;
  2472. studentUpList.Add(recruitStudent.CF_Student);
  2473. inCount++;
  2474. }
  2475. }
  2476. }
  2477. }
  2478. }
  2479. else if (importGraPicType.Equals("IDNumber"))
  2480. {
  2481. errDataTable.Columns.Add("PhotoInfo", typeof(string));
  2482. errDataTable.Columns.Add("IDNumber", typeof(string));
  2483. errDataTable.Columns.Add("ErrorMessage", typeof(string));
  2484. var studentList = StudentDAL.Value.StudentRepository.GetList(x => photoNameList.Contains(x.IDNumber)).ToList();
  2485. foreach (var map in mapList)
  2486. {
  2487. var newStudentList = studentList.Where(x => x.IDNumber == map.PhotoName).ToList();
  2488. if (newStudentList != null && newStudentList.Count() > 1)
  2489. {
  2490. DataRow errDataRow = errDataTable.NewRow();
  2491. errDataRow["PhotoInfo"] = map.PhotoInfo;
  2492. errDataRow["IDNumber"] = map.PhotoName;
  2493. errDataRow["ErrorMessage"] = "存在多个对应的证件号码(" + map.PhotoName + ")";
  2494. errDataTable.Rows.Add(errDataRow);
  2495. errCount++;
  2496. }
  2497. else
  2498. {
  2499. if (newStudentList != null && newStudentList.Count() == 1)
  2500. {
  2501. var student = newStudentList.Where(x => x.IDNumber == map.PhotoName).SingleOrDefault();
  2502. if (student == null)
  2503. {
  2504. DataRow errDataRow = errDataTable.NewRow();
  2505. errDataRow["PhotoInfo"] = map.PhotoInfo;
  2506. errDataRow["IDNumber"] = map.PhotoName;
  2507. errDataRow["ErrorMessage"] = "不存在对应的证件号码(" + map.PhotoName + ")";
  2508. errDataTable.Rows.Add(errDataRow);
  2509. errCount++;
  2510. }
  2511. else
  2512. {
  2513. student.GraduationPictureUrl = map.PhotoPath;
  2514. studentUpList.Add(student);
  2515. inCount++;
  2516. }
  2517. }
  2518. else
  2519. {
  2520. DataRow errDataRow = errDataTable.NewRow();
  2521. errDataRow["PhotoInfo"] = map.PhotoInfo;
  2522. errDataRow["IDNumber"] = map.PhotoName;
  2523. errDataRow["ErrorMessage"] = "不存在对应的证件号码(" + map.PhotoName + ")";
  2524. errDataTable.Rows.Add(errDataRow);
  2525. errCount++;
  2526. }
  2527. }
  2528. }
  2529. }
  2530. if (studentUpList != null && studentUpList.Count() > 0)
  2531. {
  2532. UnitOfWork.BatchUpdate<CF_Student>(studentUpList);
  2533. }
  2534. }
  2535. catch (Exception)
  2536. {
  2537. throw;
  2538. }
  2539. }
  2540. /// <summary>
  2541. /// 查询对应的学生照片RemoteFileInfoList
  2542. /// </summary>
  2543. /// <param name="studentViewList"></param>
  2544. /// <param name="exportPicType"></param>
  2545. /// <returns></returns>
  2546. public IList<FileUploadHelper.RemoteFileInfo> GetStudentPicRemoteFileInfoList(List<StudentView> studentViewList, string exportPicType)
  2547. {
  2548. try
  2549. {
  2550. var remoteFileList = new List<FileUploadHelper.RemoteFileInfo>();
  2551. if (studentViewList != null && studentViewList.Count() > 0)
  2552. {
  2553. switch (exportPicType)
  2554. {
  2555. case "StudentNoToPic":
  2556. remoteFileList = studentViewList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x =>
  2557. new EMIS.Utility.FileUploadHelper.RemoteFileInfo()
  2558. {
  2559. FileName = x.StudentNo + Path.GetExtension(x.PhotoUrl.Trim()),
  2560. RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : x.PhotoUrl.Trim()) //Url.Content(x.PhotoUrl.Trim())
  2561. }).ToList();
  2562. break;
  2563. case "ExamineeNumToPic":
  2564. remoteFileList = studentViewList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x =>
  2565. new EMIS.Utility.FileUploadHelper.RemoteFileInfo()
  2566. {
  2567. FileName = x.ExamineeNum + Path.GetExtension(x.PhotoUrl.Trim()),
  2568. RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : x.PhotoUrl.Trim())
  2569. }).ToList();
  2570. break;
  2571. case "IDNumberToPic":
  2572. remoteFileList = studentViewList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x =>
  2573. new EMIS.Utility.FileUploadHelper.RemoteFileInfo()
  2574. {
  2575. FileName = x.IDNumber + Path.GetExtension(x.PhotoUrl.Trim()),
  2576. RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : x.PhotoUrl.Trim())
  2577. }).ToList();
  2578. break;
  2579. case "StudentNoAndNameToPic":
  2580. remoteFileList = studentViewList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x =>
  2581. new EMIS.Utility.FileUploadHelper.RemoteFileInfo()
  2582. {
  2583. FileName = x.StudentNo + x.Name + Path.GetExtension(x.PhotoUrl.Trim()),
  2584. RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : x.PhotoUrl.Trim())
  2585. }).ToList();
  2586. break;
  2587. default:
  2588. break;
  2589. }
  2590. }
  2591. return remoteFileList;
  2592. }
  2593. catch (Exception)
  2594. {
  2595. throw;
  2596. }
  2597. }
  2598. /// <summary>
  2599. /// 查询默认的学习形式(个性化配置)
  2600. /// 默认为全部
  2601. /// </summary>
  2602. /// <returns></returns>
  2603. public virtual int? GetDefaultLearnformForList()
  2604. {
  2605. return null;
  2606. }
  2607. /// <summary>
  2608. /// 查询班级信息对应的预计毕业日期DateTime
  2609. /// </summary>
  2610. /// <param name="classmajorID"></param>
  2611. /// <returns></returns>
  2612. public DateTime? GetClassmajorPlanningGraduateDate(Guid? classmajorID)
  2613. {
  2614. try
  2615. {
  2616. var classmajor = StudentDAL.Value.ClassmajorRepository.GetList(x => x.ClassmajorID == classmajorID, (x => x.CF_Grademajor)).SingleOrDefault();
  2617. if (classmajor != null)
  2618. {
  2619. if (classmajor.CF_Grademajor != null)
  2620. {
  2621. if (classmajor.CF_Grademajor.GraduateSchoolyearID.HasValue)
  2622. {
  2623. var graduateSchoolyear = StudentDAL.Value.SchoolyearRepository.GetList(x => x.SchoolyearID == classmajor.CF_Grademajor.GraduateSchoolyearID).SingleOrDefault();
  2624. if (graduateSchoolyear != null)
  2625. {
  2626. var planningGraduateDate = PlanningGraduateDateHelper.GetPlanningGraduateDate(graduateSchoolyear.FirstWeek);
  2627. return planningGraduateDate;
  2628. }
  2629. }
  2630. }
  2631. return null;
  2632. }
  2633. else
  2634. {
  2635. return null;
  2636. }
  2637. }
  2638. catch (Exception ex)
  2639. {
  2640. throw new Exception(ex.Message);
  2641. }
  2642. }
  2643. /// <summary>
  2644. /// 查询年级专业ID对应的预计毕业日期string
  2645. /// </summary>
  2646. /// <param name="grademajorID"></param>
  2647. /// <returns></returns>
  2648. public string GetPlanningGraduateDate(Guid? grademajorID)
  2649. {
  2650. try
  2651. {
  2652. var grademajor = StudentDAL.Value.GrademajorRepository.GetList(x => x.GrademajorID == grademajorID).SingleOrDefault();
  2653. if (grademajor != null)
  2654. {
  2655. if (grademajor.GraduateSchoolyearID.HasValue)
  2656. {
  2657. var graduateSchoolyear = StudentDAL.Value.SchoolyearRepository.GetList(x => x.SchoolyearID == grademajor.GraduateSchoolyearID).SingleOrDefault();
  2658. if (graduateSchoolyear != null)
  2659. {
  2660. var planningGraduateDate = PlanningGraduateDateHelper.GetPlanningGraduateDate(graduateSchoolyear.FirstWeek);
  2661. return planningGraduateDate.ToString("yyyy-MM-dd");
  2662. }
  2663. }
  2664. return null;
  2665. }
  2666. else
  2667. {
  2668. return null;
  2669. }
  2670. }
  2671. catch (Exception ex)
  2672. {
  2673. throw new Exception(ex.Message);
  2674. }
  2675. }
  2676. /// <summary>
  2677. /// 查询班级信息对应的毕业学期中的毕业日期DateTime
  2678. /// </summary>
  2679. /// <param name="classmajorID"></param>
  2680. /// <returns></returns>
  2681. public DateTime? GetClassmajorGraduateDate(Guid? classmajorID)
  2682. {
  2683. try
  2684. {
  2685. var classmajor = StudentDAL.Value.ClassmajorRepository.GetList(x => x.ClassmajorID == classmajorID, (x => x.CF_Grademajor)).SingleOrDefault();
  2686. if (classmajor != null)
  2687. {
  2688. if (classmajor.CF_Grademajor != null)
  2689. {
  2690. if (classmajor.CF_Grademajor.GraduateSchoolyearID.HasValue)
  2691. {
  2692. var graduateSchoolyear = StudentDAL.Value.GraduateSchoolyearRepository.GetList(x => x.SchoolyearID == classmajor.CF_Grademajor.GraduateSchoolyearID).SingleOrDefault();
  2693. if (graduateSchoolyear != null)
  2694. {
  2695. var graduateDate = graduateSchoolyear.GraduateDate;
  2696. return graduateDate;
  2697. }
  2698. }
  2699. }
  2700. return null;
  2701. }
  2702. else
  2703. {
  2704. return null;
  2705. }
  2706. }
  2707. catch (Exception ex)
  2708. {
  2709. throw new Exception(ex.Message);
  2710. }
  2711. }
  2712. /// <summary>
  2713. /// 查询年级专业对应的毕业学期中的毕业日期string
  2714. /// </summary>
  2715. /// <param name="grademajorID"></param>
  2716. /// <returns></returns>
  2717. public string GetGraduateDate(Guid? grademajorID)
  2718. {
  2719. try
  2720. {
  2721. var grademajor = StudentDAL.Value.GrademajorRepository.GetList(x => x.GrademajorID == grademajorID).SingleOrDefault();
  2722. if (grademajor != null)
  2723. {
  2724. if (grademajor.GraduateSchoolyearID.HasValue)
  2725. {
  2726. var graduateSchoolyear = StudentDAL.Value.GraduateSchoolyearRepository
  2727. .GetList(x => x.SchoolyearID == grademajor.GraduateSchoolyearID).SingleOrDefault();
  2728. if (graduateSchoolyear != null)
  2729. {
  2730. var graduateDate = graduateSchoolyear.GraduateDate;
  2731. if (graduateDate.HasValue)
  2732. {
  2733. return graduateDate.Value.ToString("yyyy-MM-dd");
  2734. }
  2735. }
  2736. }
  2737. return null;
  2738. }
  2739. else
  2740. {
  2741. return null;
  2742. }
  2743. }
  2744. catch (Exception ex)
  2745. {
  2746. throw new Exception(ex.Message);
  2747. }
  2748. }
  2749. /// <summary>
  2750. /// 查询对应的学生预计毕业日期
  2751. /// </summary>
  2752. /// <param name="configuretView"></param>
  2753. /// <param name="pageIndex"></param>
  2754. /// <param name="pageSize"></param>
  2755. /// <returns></returns>
  2756. public IGridResultSet<StudentView> GetStudentPlanningGraduateDateGrid(ConfiguretView configuretView, int pageIndex, int pageSize)
  2757. {
  2758. Expression<Func<CF_Student, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  2759. var query = StudentDAL.Value.GetStudentPlanningGraduateDateQueryable(exp).Where(x => x.PlanningGraduateDate != null).ToList();
  2760. foreach (var item in query)
  2761. {
  2762. item.PlanningGraduateDateStr = item.PlanningGraduateDate.Value.ToString("yyyyMMdd");
  2763. }
  2764. var result = query.AsQueryable();
  2765. //查询条件
  2766. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  2767. {
  2768. result = result.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  2769. }
  2770. return result.OrderByDescending(x => x.PlanningGraduateDateStr).ToGridResultSet<StudentView>(pageIndex, pageSize);
  2771. }
  2772. /// <summary>
  2773. /// 查询对应的学生预计毕业日期List
  2774. /// </summary>
  2775. /// <param name="configuretView"></param>
  2776. /// <returns></returns>
  2777. public IList<StudentView> GetStudentPlanningGraduateDateList(ConfiguretView configuretView)
  2778. {
  2779. Expression<Func<CF_Student, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  2780. var query = StudentDAL.Value.GetStudentPlanningGraduateDateQueryable(exp).Where(x => x.PlanningGraduateDate != null).ToList();
  2781. foreach (var item in query)
  2782. {
  2783. item.PlanningGraduateDateStr = item.PlanningGraduateDate.Value.ToString("yyyyMMdd");
  2784. }
  2785. var result = query.AsQueryable();
  2786. //查询条件
  2787. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  2788. {
  2789. result = result.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  2790. }
  2791. return result.OrderByDescending(x => x.PlanningGraduateDateStr).ToList();
  2792. }
  2793. /// <summary>
  2794. /// 查询对应的数据范围ID
  2795. /// </summary>
  2796. /// <returns></returns>
  2797. public int? GetDataRangeID()
  2798. {
  2799. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  2800. if (curUser.IsStudent)
  2801. {
  2802. return (int)SYS_DataRange.Student;
  2803. }
  2804. var menuNo = HttpHelper.GetMenuNo();
  2805. if (string.IsNullOrEmpty(menuNo))
  2806. {
  2807. menuNo = HttpContext.Current.Request.UrlReferrer.GetQueryStringByPath("FromMNU");
  2808. }
  2809. var dataRange = DataRangeDAL.Value.GetRoleDataRange(curUser.RoleID, menuNo);
  2810. switch (dataRange)
  2811. {
  2812. case SYS_DataRange.All:
  2813. return (int)SYS_DataRange.All;
  2814. case SYS_DataRange.Campus:
  2815. return (int)SYS_DataRange.Campus;
  2816. case SYS_DataRange.College:
  2817. return (int)SYS_DataRange.College;
  2818. case SYS_DataRange.Department:
  2819. return (int)SYS_DataRange.Department;
  2820. case SYS_DataRange.Teacher:
  2821. return (int)SYS_DataRange.Teacher;
  2822. case SYS_DataRange.Assistant:
  2823. return (int)SYS_DataRange.Assistant;
  2824. default:
  2825. return (int)SYS_DataRange.All;
  2826. }
  2827. }
  2828. /// <summary>
  2829. /// 学生信息Excel导入
  2830. /// </summary>
  2831. /// <param name="cellheader"></param>
  2832. /// <param name="inCount"></param>
  2833. /// <param name="upCount"></param>
  2834. /// <param name="errdataList"></param>
  2835. /// <param name="errCount"></param>
  2836. /// <param name="sourcePhysicalPath"></param>
  2837. public virtual void StudentImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount, out List<StudentView> errdataList, out int? errCount, string sourcePhysicalPath)
  2838. {
  2839. try
  2840. {
  2841. //查询相关Web.config配置
  2842. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringMonth == null)
  2843. {
  2844. throw new Exception("预计毕业月(春季、上学期入学月)未配置,请检查。");
  2845. }
  2846. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringDay == null)
  2847. {
  2848. throw new Exception("预计毕业日(春季、上学期入学日)未配置,请检查。");
  2849. }
  2850. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnMonth == null)
  2851. {
  2852. throw new Exception("预计毕业月(秋季、下学期入学月)未配置,请检查。");
  2853. }
  2854. if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnDay == null)
  2855. {
  2856. throw new Exception("预计毕业日(秋季、下学期入学日)未配置,请检查。");
  2857. }
  2858. if (EMIS.Utility.Const.LOCAL_SETTING_ENTRANCESEMESTERID == null)
  2859. {
  2860. throw new Exception("入学学期(春季、上学期、秋季、下学期)未配置,请检查。");
  2861. }
  2862. var studentNoTotal = EMIS.Utility.Const.LOCAL_SETTING_LOGINIDTOTAL;
  2863. if (studentNoTotal == null)
  2864. {
  2865. throw new Exception("学号总位数未配置,请检查。");
  2866. }
  2867. StringBuilder errorMsg = new StringBuilder(); // 错误信息
  2868. List<StudentView> errList = new List<StudentView>();
  2869. // 1.1解析文件,存放到一个List集合里
  2870. cellheader.Remove("ErrorMessage");//移除“未导入原因”列(ErrorMessage)
  2871. List<StudentView> enlist = NpoiExcelHelper.ExcelToEntityList<StudentView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
  2872. cellheader.Add("ErrorMessage", "未导入原因");
  2873. //对List集合进行有效性校验
  2874. if (enlist.Count() <= 0)
  2875. {
  2876. throw new Exception("Excel文件数据为空,请检查。");
  2877. }
  2878. Regex reg = null; //正则表达式
  2879. DateTime result; //用于返回判断日期字段格式
  2880. inCount = 0; //导入个数
  2881. upCount = 0; //更新个数
  2882. errCount = 0; //失败个数
  2883. string errorMsgStr = ""; //错误信息
  2884. List<Sys_User> newUserInList = new List<Sys_User>();
  2885. List<Sys_User> newUserUpList = new List<Sys_User>();
  2886. List<CF_Student> newStudentInList = new List<CF_Student>();
  2887. List<CF_Student> newStudentUpList = new List<CF_Student>();
  2888. List<CF_StudentProfile> newStudentProfileInList = new List<CF_StudentProfile>();
  2889. List<CF_StudentProfile> newStudentProfileUpList = new List<CF_StudentProfile>();
  2890. List<CF_StudentContact> newStudentContactInList = new List<CF_StudentContact>();
  2891. List<CF_StudentContact> newStudentContactUpList = new List<CF_StudentContact>();
  2892. List<CF_StudentAccount> newStudentAccountInList = new List<CF_StudentAccount>();
  2893. List<CF_StudentAccount> newStudentAccountUpList = new List<CF_StudentAccount>();
  2894. List<CF_Recruitstudents> newRecruitstudentsInList = new List<CF_Recruitstudents>();
  2895. List<CF_Recruitstudents> newRecruitstudentsUpList = new List<CF_Recruitstudents>();
  2896. var passwordParameter = StudentDAL.Value.ParameterRepository.GetSingle(x => x.ParameterTypeID == (int)ViewModel.CF_ParameterType.StudentInitPassword);
  2897. var roleList = StudentDAL.Value.RoleRepository.GetList(x => x.TypeID == (int)SYS_RoleType.Student, (x => x.CF_StudentRole)).ToList();
  2898. //将循环中相关数据库查询统一查询出来进行匹配(尽量避免在循环中进行数据库查询)
  2899. //性别
  2900. var sexList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Sex).ToList();
  2901. //民族
  2902. var nationList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Nation).ToList();
  2903. //政治面貌
  2904. var politicsList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Politics).ToList();
  2905. //学生类别
  2906. var studentTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_STUDENTTYPE).ToList();
  2907. //证件类型
  2908. var certificatesTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CertificatesType).ToList();
  2909. //在校状态
  2910. var inschoolStatusList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_InschoolStatus).ToList();
  2911. //学籍状态
  2912. var studentStatusList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_StudentStatus).ToList();
  2913. //文化程度
  2914. var literacyLevelList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_LiteracyLevel).ToList();
  2915. //培养方式
  2916. var cultureModelList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CULTUREMODEL).ToList();
  2917. //考生类别
  2918. var examineeTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_EXAMINEETYPE).ToList();
  2919. //入学方式
  2920. var entranceWayList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_EntranceWay).ToList();
  2921. //考生特征
  2922. var featuresList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Features).ToList();
  2923. //生源所属地
  2924. var territorialList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Province).ToList();
  2925. //健康状况
  2926. var healthStateList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_HealthState).ToList();
  2927. //血型
  2928. var bloodGroupList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_BLOODGROUP).ToList();
  2929. //是否
  2930. var generalPurposeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_GeneralPurpose).ToList();
  2931. //有无
  2932. var generalExistList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_GeneralExist).ToList();
  2933. //班级编号
  2934. var classmajorNoList = enlist.Where(x => !string.IsNullOrEmpty(x.ClassmajorNo)).Select(x => x.ClassmajorNo.Trim()).ToList();
  2935. //对比后的newClassmajorList
  2936. var newClassmajorList = StudentDAL.Value.ClassmajorRepository.GetList(x => classmajorNoList.Contains(x.No)).ToList();
  2937. //学籍卡编号
  2938. var studentCardNoList = enlist.Where(x => !string.IsNullOrEmpty(x.StudentCardNo)).Select(x => x.StudentCardNo.Trim()).ToList();
  2939. //对比后的newStudentCardNoList
  2940. var newStudentCardNoList = StudentDAL.Value.StudentRepository.GetList(x => studentCardNoList.Contains(x.StudentCardNo)).ToList();
  2941. //毕结业证书编号
  2942. var graduateCardNoList = enlist.Where(x => !string.IsNullOrEmpty(x.GraduateCardNo)).Select(x => x.GraduateCardNo.Trim()).ToList();
  2943. //对比后的newGraduateCardNoList
  2944. var newGraduateCardNoList = StudentDAL.Value.StudentRepository.GetList(x => graduateCardNoList.Contains(x.GraduateCardNo)).ToList();
  2945. //考生号
  2946. var examineeNumList = enlist.Where(x => !string.IsNullOrEmpty(x.ExamineeNum)).Select(x => x.ExamineeNum.Trim()).ToList();
  2947. //对比后的newExamineeNumList
  2948. var newExamineeNumList = StudentDAL.Value.RecruitstudentsRepository.GetList(x => examineeNumList.Contains(x.ExamineeNum)).ToList();
  2949. //学号
  2950. var studentNoList = enlist.Where(x => !string.IsNullOrEmpty(x.StudentNo)).Select(x => x.StudentNo.Trim()).ToList();
  2951. //对比后的newNewStuList
  2952. var newNewStuList = StudentDAL.Value.NewStudentRepository.GetList(x => x.AssignStatus == (int)CF_AssignStatus.Assigned).Where(x => studentNoList.Contains(x.StudentNo)).ToList();
  2953. //对比后的newStudentList
  2954. var newStudentList = StudentDAL.Value.StudentRepository.GetList(x => studentNoList.Contains(x.Sys_User.LoginID),
  2955. (x => x.CF_StudentProfile), (x => x.CF_StudentContact), (x => x.CF_StudentAccount),
  2956. (x => x.CF_Recruitstudents), (x => x.Sys_User)).ToList();
  2957. //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等)
  2958. for (int i = 0; i < enlist.Count; i++)
  2959. {
  2960. StudentView en = enlist[i]; //Excel表数据视图
  2961. var newUser = new Sys_User();
  2962. var newStudent = new CF_Student();
  2963. var newStudentProfile = new CF_StudentProfile();
  2964. var newStudentContact = new CF_StudentContact();
  2965. var newStudentAccount = new CF_StudentAccount();
  2966. var newRecruitstudents = new CF_Recruitstudents();
  2967. //考生号
  2968. if (string.IsNullOrWhiteSpace(en.ExamineeNum))
  2969. {
  2970. errCount++;
  2971. errorMsgStr = "考生号不能为空";
  2972. en.ErrorMessage = errorMsgStr;
  2973. errList.Add(en);
  2974. errorMsg.AppendLine(errorMsgStr);
  2975. continue;
  2976. }
  2977. else
  2978. {
  2979. reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
  2980. if (!reg.IsMatch(en.ExamineeNum.Trim()))
  2981. {
  2982. errCount++;
  2983. errorMsgStr = "考生号格式不正确,请检查(数字或英文字母)";
  2984. en.ErrorMessage = errorMsgStr;
  2985. errList.Add(en);
  2986. errorMsg.AppendLine(errorMsgStr);
  2987. continue;
  2988. }
  2989. else
  2990. {
  2991. newRecruitstudents.ExamineeNum = en.ExamineeNum.Trim();
  2992. }
  2993. }
  2994. //准考证号
  2995. if (string.IsNullOrWhiteSpace(en.AdmissionTicketNo))
  2996. {
  2997. //暂不考虑
  2998. }
  2999. else
  3000. {
  3001. reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
  3002. if (!reg.IsMatch(en.AdmissionTicketNo.Trim()))
  3003. {
  3004. errCount++;
  3005. errorMsgStr = "准考证号格式不正确,请检查(数字或英文字母)";
  3006. en.ErrorMessage = errorMsgStr;
  3007. errList.Add(en);
  3008. errorMsg.AppendLine(errorMsgStr);
  3009. continue;
  3010. }
  3011. else
  3012. {
  3013. newRecruitstudents.AdmissionTicketNo = en.AdmissionTicketNo.Trim();
  3014. }
  3015. }
  3016. //学号
  3017. if (string.IsNullOrWhiteSpace(en.StudentNo))
  3018. {
  3019. errCount++;
  3020. errorMsgStr = "学号不能为空";
  3021. en.ErrorMessage = errorMsgStr;
  3022. errList.Add(en);
  3023. errorMsg.AppendLine(errorMsgStr);
  3024. continue;
  3025. }
  3026. else
  3027. {
  3028. reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
  3029. if (!reg.IsMatch(en.StudentNo.Trim()))
  3030. {
  3031. errCount++;
  3032. errorMsgStr = "学号格式不正确,请检查(数字或英文字母)";
  3033. en.ErrorMessage = errorMsgStr;
  3034. errList.Add(en);
  3035. errorMsg.AppendLine(errorMsgStr);
  3036. continue;
  3037. }
  3038. else
  3039. {
  3040. if (en.StudentNo.Trim().Length != Convert.ToInt32(studentNoTotal))
  3041. {
  3042. errCount++;
  3043. errorMsgStr = "学号总位数有误,学号总位数应为" + studentNoTotal + "位。";
  3044. en.ErrorMessage = errorMsgStr;
  3045. errList.Add(en);
  3046. errorMsg.AppendLine(errorMsgStr);
  3047. continue;
  3048. }
  3049. else
  3050. {
  3051. newUser.LoginID = en.StudentNo.Trim();
  3052. }
  3053. }
  3054. }
  3055. //姓名
  3056. if (string.IsNullOrWhiteSpace(en.Name))
  3057. {
  3058. errCount++;
  3059. errorMsgStr = "姓名不能为空";
  3060. en.ErrorMessage = errorMsgStr;
  3061. errList.Add(en);
  3062. errorMsg.AppendLine(errorMsgStr);
  3063. continue;
  3064. }
  3065. else
  3066. {
  3067. newUser.Name = en.Name.Trim();
  3068. }
  3069. //曾用名
  3070. if (string.IsNullOrWhiteSpace(en.UsedName))
  3071. {
  3072. //暂不考虑
  3073. }
  3074. else
  3075. {
  3076. newStudentProfile.UsedName = en.UsedName.Trim();
  3077. }
  3078. //性别
  3079. if (string.IsNullOrWhiteSpace(en.SexStr))
  3080. {
  3081. errCount++;
  3082. errorMsgStr = "性别不能为空";
  3083. en.ErrorMessage = errorMsgStr;
  3084. errList.Add(en);
  3085. errorMsg.AppendLine(errorMsgStr);
  3086. continue;
  3087. }
  3088. else
  3089. {
  3090. var sex = sexList.Where(x => x.Name == en.SexStr.Trim()).SingleOrDefault();
  3091. if (sex == null)
  3092. {
  3093. errCount++;
  3094. errorMsgStr = "性别不存在,请检查";
  3095. en.ErrorMessage = errorMsgStr;
  3096. errList.Add(en);
  3097. errorMsg.AppendLine(errorMsgStr);
  3098. continue;
  3099. }
  3100. else
  3101. {
  3102. newStudent.SexID = sex.Value;
  3103. }
  3104. }
  3105. //出生日期
  3106. if (string.IsNullOrWhiteSpace(en.BirthDateStr))
  3107. {
  3108. errCount++;
  3109. errorMsgStr = "出生日期不能为空";
  3110. en.ErrorMessage = errorMsgStr;
  3111. errList.Add(en);
  3112. errorMsg.AppendLine(errorMsgStr);
  3113. continue;
  3114. }
  3115. else
  3116. {
  3117. //reg = new Regex(@"(\d{4})-(\d{1,2})-(\d{1,2})"); //日期正则表达式,2017-12-28
  3118. if (!DateTime.TryParse(en.BirthDateStr, out result))
  3119. {
  3120. errCount++;
  3121. errorMsgStr = "出生日期格式不正确,请检查";
  3122. en.ErrorMessage = errorMsgStr;
  3123. errList.Add(en);
  3124. errorMsg.AppendLine(errorMsgStr);
  3125. continue;
  3126. }
  3127. else
  3128. {
  3129. newStudent.BirthDate = Convert.ToDateTime(en.BirthDateStr);
  3130. }
  3131. }
  3132. //民族
  3133. if (string.IsNullOrWhiteSpace(en.NationStr))
  3134. {
  3135. errCount++;
  3136. errorMsgStr = "民族不能为空";
  3137. en.ErrorMessage = errorMsgStr;
  3138. errList.Add(en);
  3139. errorMsg.AppendLine(errorMsgStr);
  3140. continue;
  3141. }
  3142. else
  3143. {
  3144. var nation = nationList.Where(x => x.Name == en.NationStr.Trim()).SingleOrDefault();
  3145. if (nation == null)
  3146. {
  3147. errCount++;
  3148. errorMsgStr = "民族不存在,请检查";
  3149. en.ErrorMessage = errorMsgStr;
  3150. errList.Add(en);
  3151. errorMsg.AppendLine(errorMsgStr);
  3152. continue;
  3153. }
  3154. else
  3155. {
  3156. newStudent.NationID = nation.Value;
  3157. }
  3158. }
  3159. //政治面貌
  3160. if (string.IsNullOrWhiteSpace(en.PoliticsStr))
  3161. {
  3162. errCount++;
  3163. errorMsgStr = "政治面貌不能为空";
  3164. en.ErrorMessage = errorMsgStr;
  3165. errList.Add(en);
  3166. errorMsg.AppendLine(errorMsgStr);
  3167. continue;
  3168. }
  3169. else
  3170. {
  3171. var politics = politicsList.Where(x => x.Name == en.PoliticsStr.Trim()).SingleOrDefault();
  3172. if (politics == null)
  3173. {
  3174. errCount++;
  3175. errorMsgStr = "政治面貌不存在,请检查";
  3176. en.ErrorMessage = errorMsgStr;
  3177. errList.Add(en);
  3178. errorMsg.AppendLine(errorMsgStr);
  3179. continue;
  3180. }
  3181. else
  3182. {
  3183. newStudent.PoliticsID = politics.Value;
  3184. }
  3185. }
  3186. //学生类别
  3187. if (string.IsNullOrWhiteSpace(en.StudentTypeStr))
  3188. {
  3189. newStudent.StudentType = (int)CF_STUDENTTYPE.DefaultType;
  3190. }
  3191. else
  3192. {
  3193. var studentType = studentTypeList.Where(x => x.Name == en.StudentTypeStr.Trim()).SingleOrDefault();
  3194. if (studentType == null)
  3195. {
  3196. errCount++;
  3197. errorMsgStr = "学生类别不存在,请检查";
  3198. en.ErrorMessage = errorMsgStr;
  3199. errList.Add(en);
  3200. errorMsg.AppendLine(errorMsgStr);
  3201. continue;
  3202. }
  3203. else
  3204. {
  3205. newStudent.StudentType = studentType.Value;
  3206. }
  3207. }
  3208. //证件类型
  3209. if (string.IsNullOrWhiteSpace(en.CertificatesTypeStr))
  3210. {
  3211. //默认为身份证
  3212. newStudent.CertificatesType = (int)CF_CertificatesType.IdCrad;
  3213. }
  3214. else
  3215. {
  3216. var certificatesType = certificatesTypeList.Where(x => x.Name == en.CertificatesTypeStr.Trim()).SingleOrDefault();
  3217. if (certificatesType == null)
  3218. {
  3219. errCount++;
  3220. errorMsgStr = "证件类型不存在,请检查";
  3221. en.ErrorMessage = errorMsgStr;
  3222. errList.Add(en);
  3223. errorMsg.AppendLine(errorMsgStr);
  3224. continue;
  3225. }
  3226. else
  3227. {
  3228. newStudent.CertificatesType = certificatesType.Value;
  3229. }
  3230. }
  3231. //证件号码
  3232. if (string.IsNullOrWhiteSpace(en.IDNumber))
  3233. {
  3234. errCount++;
  3235. errorMsgStr = "证件号码不能为空";
  3236. en.ErrorMessage = errorMsgStr;
  3237. errList.Add(en);
  3238. errorMsg.AppendLine(errorMsgStr);
  3239. continue;
  3240. }
  3241. else
  3242. {
  3243. //reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
  3244. //if (!reg.IsMatch(en.IDNumber.Trim()))
  3245. //{
  3246. // errCount++;
  3247. // errorMsgStr = "证件号码格式不正确,请检查(数字或英文字母)";
  3248. // en.ErrorMessage = errorMsgStr;
  3249. // errList.Add(en);
  3250. // errorMsg.AppendLine(errorMsgStr);
  3251. // continue;
  3252. //}
  3253. //else
  3254. //{
  3255. // newStudent.IDNumber = en.IDNumber.Trim();
  3256. //}
  3257. newStudent.IDNumber = en.IDNumber.Trim();
  3258. }
  3259. //在校状态
  3260. if (string.IsNullOrWhiteSpace(en.InSchoolStatusStr))
  3261. {
  3262. errCount++;
  3263. errorMsgStr = "在校状态不能为空";
  3264. en.ErrorMessage = errorMsgStr;
  3265. errList.Add(en);
  3266. errorMsg.AppendLine(errorMsgStr);
  3267. continue;
  3268. }
  3269. else
  3270. {
  3271. var inSchoolStatus = inschoolStatusList.Where(x => x.Name == en.InSchoolStatusStr.Trim()).SingleOrDefault();
  3272. if (inSchoolStatus == null)
  3273. {
  3274. errCount++;
  3275. errorMsgStr = "在校状态不存在,请检查";
  3276. en.ErrorMessage = errorMsgStr;
  3277. errList.Add(en);
  3278. errorMsg.AppendLine(errorMsgStr);
  3279. continue;
  3280. }
  3281. else
  3282. {
  3283. newStudent.InSchoolStatusID = inSchoolStatus.Value;
  3284. }
  3285. }
  3286. //学籍状态
  3287. if (string.IsNullOrWhiteSpace(en.StudentStatusStr))
  3288. {
  3289. errCount++;
  3290. errorMsgStr = "学籍状态不能为空";
  3291. en.ErrorMessage = errorMsgStr;
  3292. errList.Add(en);
  3293. errorMsg.AppendLine(errorMsgStr);
  3294. continue;
  3295. }
  3296. else
  3297. {
  3298. var studentStatus = studentStatusList.Where(x => x.Name == en.StudentStatusStr.Trim()).SingleOrDefault();
  3299. if (studentStatus == null)
  3300. {
  3301. errCount++;
  3302. errorMsgStr = "学籍状态不存在,请检查";
  3303. en.ErrorMessage = errorMsgStr;
  3304. errList.Add(en);
  3305. errorMsg.AppendLine(errorMsgStr);
  3306. continue;
  3307. }
  3308. else
  3309. {
  3310. newStudent.StudentStatus = studentStatus.Value;
  3311. }
  3312. }
  3313. //班级编号
  3314. if (string.IsNullOrWhiteSpace(en.ClassmajorNo))
  3315. {
  3316. errCount++;
  3317. errorMsgStr = "班级编号不能为空";
  3318. en.ErrorMessage = errorMsgStr;
  3319. errList.Add(en);
  3320. errorMsg.AppendLine(errorMsgStr);
  3321. continue;
  3322. }
  3323. else
  3324. {
  3325. var classmajor = newClassmajorList.Where(x => x.No == en.ClassmajorNo.Trim()).SingleOrDefault();
  3326. if (classmajor == null)
  3327. {
  3328. errCount++;
  3329. errorMsgStr = "班级编号不存在,请检查";
  3330. en.ErrorMessage = errorMsgStr;
  3331. errList.Add(en);
  3332. errorMsg.AppendLine(errorMsgStr);
  3333. continue;
  3334. }
  3335. else
  3336. {
  3337. //判断班级编号与班级名称(以班级编号为准)
  3338. if (string.IsNullOrWhiteSpace(en.ClassmajorName))
  3339. {
  3340. //暂不考虑
  3341. }
  3342. else
  3343. {
  3344. //班级编号与班级名称不对应
  3345. if (classmajor.Name.Trim() != en.ClassmajorName.Trim())
  3346. {
  3347. errCount++;
  3348. errorMsgStr = "班级编号与班级名称不对应(以班级编号为准),请检查";
  3349. en.ErrorMessage = errorMsgStr;
  3350. errList.Add(en);
  3351. errorMsg.AppendLine(errorMsgStr);
  3352. continue;
  3353. }
  3354. }
  3355. newStudent.ClassmajorID = classmajor.ClassmajorID;
  3356. newStudent.PlanningGraduateDate = this.GetClassmajorPlanningGraduateDate(classmajor.ClassmajorID);
  3357. newStudent.GraduateDate = this.GetClassmajorGraduateDate(classmajor.ClassmajorID);
  3358. }
  3359. }
  3360. //班级名称
  3361. if (string.IsNullOrWhiteSpace(en.ClassmajorName))
  3362. {
  3363. //暂不考虑
  3364. }
  3365. else
  3366. {
  3367. //暂不考虑
  3368. }
  3369. //文化程度
  3370. if (string.IsNullOrWhiteSpace(en.LiteracyLevelStr))
  3371. {
  3372. //暂不考虑
  3373. }
  3374. else
  3375. {
  3376. var literacyLevel = literacyLevelList.Where(x => x.Name == en.LiteracyLevelStr.Trim()).SingleOrDefault();
  3377. if (literacyLevel == null)
  3378. {
  3379. errCount++;
  3380. errorMsgStr = "文化程度不存在,请检查";
  3381. en.ErrorMessage = errorMsgStr;
  3382. errList.Add(en);
  3383. errorMsg.AppendLine(errorMsgStr);
  3384. continue;
  3385. }
  3386. else
  3387. {
  3388. newStudentProfile.LiteracyLevelID = literacyLevel.Value;
  3389. }
  3390. }
  3391. //培养方式
  3392. if (string.IsNullOrWhiteSpace(en.CultureModelStr))
  3393. {
  3394. //暂不考虑
  3395. }
  3396. else
  3397. {
  3398. var cultureModel = cultureModelList.Where(x => x.Name == en.CultureModelStr.Trim()).SingleOrDefault();
  3399. if (cultureModel == null)
  3400. {
  3401. errCount++;
  3402. errorMsgStr = "培养方式不存在,请检查";
  3403. en.ErrorMessage = errorMsgStr;
  3404. errList.Add(en);
  3405. errorMsg.AppendLine(errorMsgStr);
  3406. continue;
  3407. }
  3408. else
  3409. {
  3410. newStudentProfile.CultureModelID = cultureModel.Value;
  3411. }
  3412. }
  3413. //考生类别
  3414. if (string.IsNullOrWhiteSpace(en.ExamineeTypeStr))
  3415. {
  3416. //暂不考虑
  3417. }
  3418. else
  3419. {
  3420. var examineeType = examineeTypeList.Where(x => x.Name == en.ExamineeTypeStr.Trim()).SingleOrDefault();
  3421. if (examineeType == null)
  3422. {
  3423. errCount++;
  3424. errorMsgStr = "考生类别不存在,请检查";
  3425. en.ErrorMessage = errorMsgStr;
  3426. errList.Add(en);
  3427. errorMsg.AppendLine(errorMsgStr);
  3428. continue;
  3429. }
  3430. else
  3431. {
  3432. newRecruitstudents.ExamineeType = examineeType.Value;
  3433. }
  3434. }
  3435. //入学日期
  3436. if (string.IsNullOrWhiteSpace(en.EntranceDateStr))
  3437. {
  3438. //暂不考虑
  3439. }
  3440. else
  3441. {
  3442. if (!DateTime.TryParse(en.EntranceDateStr, out result))
  3443. {
  3444. errCount++;
  3445. errorMsgStr = "入学日期格式不正确,请检查";
  3446. en.ErrorMessage = errorMsgStr;
  3447. errList.Add(en);
  3448. errorMsg.AppendLine(errorMsgStr);
  3449. continue;
  3450. }
  3451. else
  3452. {
  3453. newRecruitstudents.EntranceDate = Convert.ToDateTime(en.EntranceDateStr);
  3454. }
  3455. }
  3456. //总分
  3457. if (string.IsNullOrWhiteSpace(en.ScoreStr))
  3458. {
  3459. //暂不考虑
  3460. }
  3461. else
  3462. {
  3463. reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$"); //数字正则表达式
  3464. if (!reg.IsMatch(en.ScoreStr))
  3465. {
  3466. errCount++;
  3467. errorMsgStr = "总分格式不正确,请检查";
  3468. en.ErrorMessage = errorMsgStr;
  3469. errList.Add(en);
  3470. errorMsg.AppendLine(errorMsgStr);
  3471. continue;
  3472. }
  3473. else
  3474. {
  3475. newRecruitstudents.Score = Convert.ToDecimal(en.ScoreStr);
  3476. }
  3477. }
  3478. //入学方式
  3479. if (string.IsNullOrWhiteSpace(en.EntranceWayStr))
  3480. {
  3481. //暂不考虑
  3482. }
  3483. else
  3484. {
  3485. var entranceWay = entranceWayList.Where(x => x.Name == en.EntranceWayStr.Trim()).SingleOrDefault();
  3486. if (entranceWay == null)
  3487. {
  3488. errCount++;
  3489. errorMsgStr = "入学方式不存在,请检查";
  3490. en.ErrorMessage = errorMsgStr;
  3491. errList.Add(en);
  3492. errorMsg.AppendLine(errorMsgStr);
  3493. continue;
  3494. }
  3495. else
  3496. {
  3497. newRecruitstudents.EntranceWayID = entranceWay.Value;
  3498. }
  3499. }
  3500. //考生特征
  3501. if (string.IsNullOrWhiteSpace(en.FeaturesStr))
  3502. {
  3503. //暂不考虑
  3504. }
  3505. else
  3506. {
  3507. var features = featuresList.Where(x => x.Name == en.FeaturesStr.Trim()).SingleOrDefault();
  3508. if (features == null)
  3509. {
  3510. errCount++;
  3511. errorMsgStr = "考生特征不存在,请检查";
  3512. en.ErrorMessage = errorMsgStr;
  3513. errList.Add(en);
  3514. errorMsg.AppendLine(errorMsgStr);
  3515. continue;
  3516. }
  3517. else
  3518. {
  3519. newRecruitstudents.FeaturesID = features.Value;
  3520. }
  3521. }
  3522. //生源所属地
  3523. if (string.IsNullOrWhiteSpace(en.TerritorialStr))
  3524. {
  3525. //暂不考虑
  3526. }
  3527. else
  3528. {
  3529. var territorial = territorialList.Where(x => x.Name == en.TerritorialStr.Trim()).SingleOrDefault();
  3530. if (territorial == null)
  3531. {
  3532. errCount++;
  3533. errorMsgStr = "生源所属地不存在,请检查";
  3534. en.ErrorMessage = errorMsgStr;
  3535. errList.Add(en);
  3536. errorMsg.AppendLine(errorMsgStr);
  3537. continue;
  3538. }
  3539. else
  3540. {
  3541. newRecruitstudents.TerritorialID = territorial.Value;
  3542. }
  3543. }
  3544. //来源地区
  3545. if (string.IsNullOrWhiteSpace(en.Area))
  3546. {
  3547. //暂不考虑
  3548. }
  3549. else
  3550. {
  3551. newRecruitstudents.Area = en.Area.Trim();
  3552. }
  3553. //国籍
  3554. if (string.IsNullOrWhiteSpace(en.Country))
  3555. {
  3556. //暂不考虑
  3557. }
  3558. else
  3559. {
  3560. newStudentProfile.Country = en.Country.Trim();
  3561. }
  3562. //籍贯
  3563. if (string.IsNullOrWhiteSpace(en.Place))
  3564. {
  3565. //暂不考虑
  3566. }
  3567. else
  3568. {
  3569. newStudentProfile.Place = en.Place.Trim();
  3570. }
  3571. //出生地
  3572. if (string.IsNullOrWhiteSpace(en.BornPlace))
  3573. {
  3574. //暂不考虑
  3575. }
  3576. else
  3577. {
  3578. newStudentProfile.BornPlace = en.BornPlace.Trim();
  3579. }
  3580. //电子邮箱
  3581. if (string.IsNullOrWhiteSpace(en.Email))
  3582. {
  3583. //暂不考虑
  3584. }
  3585. else
  3586. {
  3587. reg = new Regex(@"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"); //正则表达式
  3588. if (!reg.IsMatch(en.Email.Trim()))
  3589. {
  3590. errCount++;
  3591. errorMsgStr = "电子邮箱格式不正确,请检查";
  3592. en.ErrorMessage = errorMsgStr;
  3593. errList.Add(en);
  3594. errorMsg.AppendLine(errorMsgStr);
  3595. continue;
  3596. }
  3597. else
  3598. {
  3599. newStudentContact.Email = en.Email.Trim();
  3600. }
  3601. }
  3602. //移动电话
  3603. if (string.IsNullOrWhiteSpace(en.Mobile))
  3604. {
  3605. //暂不考虑
  3606. }
  3607. else
  3608. {
  3609. newStudentContact.Mobile = en.Mobile.Trim();
  3610. }
  3611. //家庭电话
  3612. if (string.IsNullOrWhiteSpace(en.Telephone))
  3613. {
  3614. //暂不考虑
  3615. }
  3616. else
  3617. {
  3618. newStudentContact.Telephone = en.Telephone.Trim();
  3619. }
  3620. //邮政编码
  3621. if (string.IsNullOrWhiteSpace(en.ZIPCode))
  3622. {
  3623. //暂不考虑
  3624. }
  3625. else
  3626. {
  3627. reg = new Regex(@"[1-9]\d{5}(?!\d)"); //正则表达式
  3628. if (!reg.IsMatch(en.ZIPCode.Trim()))
  3629. {
  3630. errCount++;
  3631. errorMsgStr = "邮政编码格式不正确,请检查";
  3632. en.ErrorMessage = errorMsgStr;
  3633. errList.Add(en);
  3634. errorMsg.AppendLine(errorMsgStr);
  3635. continue;
  3636. }
  3637. else
  3638. {
  3639. newStudentContact.ZIPCode = en.ZIPCode.Trim();
  3640. }
  3641. }
  3642. //健康状况
  3643. if (string.IsNullOrWhiteSpace(en.HealthStateStr))
  3644. {
  3645. newStudentProfile.HealthStateID = (int)CF_HealthState.Healthy;
  3646. }
  3647. else
  3648. {
  3649. var healthState = healthStateList.Where(x => x.Name == en.HealthStateStr.Trim()).SingleOrDefault();
  3650. if (healthState == null)
  3651. {
  3652. errCount++;
  3653. errorMsgStr = "健康状况不存在,请检查";
  3654. en.ErrorMessage = errorMsgStr;
  3655. errList.Add(en);
  3656. errorMsg.AppendLine(errorMsgStr);
  3657. continue;
  3658. }
  3659. else
  3660. {
  3661. newStudentProfile.HealthStateID = healthState.Value;
  3662. }
  3663. }
  3664. //血型
  3665. if (string.IsNullOrWhiteSpace(en.BloodGroupStr))
  3666. {
  3667. //暂不考虑
  3668. }
  3669. else
  3670. {
  3671. var bloodGroup = bloodGroupList.Where(x => x.Name == en.BloodGroupStr.Trim()).SingleOrDefault();
  3672. if (bloodGroup == null)
  3673. {
  3674. errCount++;
  3675. errorMsgStr = "血型不存在,请检查";
  3676. en.ErrorMessage = errorMsgStr;
  3677. errList.Add(en);
  3678. errorMsg.AppendLine(errorMsgStr);
  3679. continue;
  3680. }
  3681. else
  3682. {
  3683. newStudentProfile.BloodGroup = bloodGroup.Value;
  3684. }
  3685. }
  3686. //特长
  3687. if (string.IsNullOrWhiteSpace(en.Specialty))
  3688. {
  3689. //暂不考虑
  3690. }
  3691. else
  3692. {
  3693. newStudentProfile.Specialty = en.Specialty.Trim();
  3694. }
  3695. //身高(cm)
  3696. if (string.IsNullOrWhiteSpace(en.Height))
  3697. {
  3698. //暂不考虑
  3699. }
  3700. else
  3701. {
  3702. reg = new Regex(@"^\d+(\.\d+)?$"); //正则表达式
  3703. if (!reg.IsMatch(en.Height.Trim()))
  3704. {
  3705. errCount++;
  3706. errorMsgStr = "身高(cm)格式不正确,请检查";
  3707. en.ErrorMessage = errorMsgStr;
  3708. errList.Add(en);
  3709. errorMsg.AppendLine(errorMsgStr);
  3710. continue;
  3711. }
  3712. else
  3713. {
  3714. newStudentProfile.Height = en.Height.Trim();
  3715. }
  3716. }
  3717. //体重(kg)
  3718. if (string.IsNullOrWhiteSpace(en.Weight))
  3719. {
  3720. //暂不考虑
  3721. }
  3722. else
  3723. {
  3724. reg = new Regex(@"^\d+(\.\d+)?$"); //正则表达式
  3725. if (!reg.IsMatch(en.Weight.Trim()))
  3726. {
  3727. errCount++;
  3728. errorMsgStr = "体重(cm)格式不正确,请检查";
  3729. en.ErrorMessage = errorMsgStr;
  3730. errList.Add(en);
  3731. errorMsg.AppendLine(errorMsgStr);
  3732. continue;
  3733. }
  3734. else
  3735. {
  3736. newStudentProfile.Weight = en.Weight.Trim();
  3737. }
  3738. }
  3739. //微信号
  3740. if (string.IsNullOrWhiteSpace(en.WeChatNum))
  3741. {
  3742. //暂不考虑
  3743. }
  3744. else
  3745. {
  3746. newStudentContact.WeChatNum = en.WeChatNum.Trim();
  3747. }
  3748. //QQ
  3749. if (string.IsNullOrWhiteSpace(en.QQ))
  3750. {
  3751. //暂不考虑
  3752. }
  3753. else
  3754. {
  3755. reg = new Regex(@"[1-9][0-9]{4,}"); //正则表达式
  3756. if (!reg.IsMatch(en.QQ.Trim()))
  3757. {
  3758. errCount++;
  3759. errorMsgStr = "QQ格式不正确,请检查";
  3760. en.ErrorMessage = errorMsgStr;
  3761. errList.Add(en);
  3762. errorMsg.AppendLine(errorMsgStr);
  3763. continue;
  3764. }
  3765. else
  3766. {
  3767. newStudentContact.QQ = en.QQ.Trim();
  3768. }
  3769. }
  3770. //家庭住址
  3771. if (string.IsNullOrWhiteSpace(en.HomeAddress))
  3772. {
  3773. //暂不考虑
  3774. }
  3775. else
  3776. {
  3777. newStudentContact.HomeAddress = en.HomeAddress.Trim();
  3778. }
  3779. //工作单位
  3780. if (string.IsNullOrWhiteSpace(en.WorkUnit))
  3781. {
  3782. //暂不考虑
  3783. }
  3784. else
  3785. {
  3786. newStudentContact.WorkUnit = en.WorkUnit.Trim();
  3787. }
  3788. //通信地址
  3789. if (string.IsNullOrWhiteSpace(en.Address))
  3790. {
  3791. //暂不考虑
  3792. }
  3793. else
  3794. {
  3795. newStudentContact.Address = en.Address.Trim();
  3796. }
  3797. //宿舍地址
  3798. if (string.IsNullOrWhiteSpace(en.Dormitory))
  3799. {
  3800. //暂不考虑
  3801. }
  3802. else
  3803. {
  3804. newStudentContact.Dormitory = en.Dormitory.Trim();
  3805. }
  3806. //收件人
  3807. if (string.IsNullOrWhiteSpace(en.Recipient))
  3808. {
  3809. //暂不考虑
  3810. }
  3811. else
  3812. {
  3813. newStudentContact.Recipient = en.Recipient.Trim();
  3814. }
  3815. //圆梦计划
  3816. if (string.IsNullOrWhiteSpace(en.IsDreamProjectStr))
  3817. {
  3818. newStudentProfile.IsDreamProject = false;
  3819. }
  3820. else
  3821. {
  3822. var isDreamProject = generalPurposeList.Where(x => x.Name == en.IsDreamProjectStr.Trim()).SingleOrDefault();
  3823. if (isDreamProject == null)
  3824. {
  3825. errCount++;
  3826. errorMsgStr = "是否圆梦计划不存在,请检查";
  3827. en.ErrorMessage = errorMsgStr;
  3828. errList.Add(en);
  3829. errorMsg.AppendLine(errorMsgStr);
  3830. continue;
  3831. }
  3832. else
  3833. {
  3834. newStudentProfile.IsDreamProject = isDreamProject.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
  3835. }
  3836. }
  3837. //导师姓名
  3838. if (string.IsNullOrWhiteSpace(en.DirectorName))
  3839. {
  3840. //暂不考虑
  3841. }
  3842. else
  3843. {
  3844. newStudentProfile.DirectorName = en.DirectorName.Trim();
  3845. }
  3846. //开户银行
  3847. if (string.IsNullOrWhiteSpace(en.BankName))
  3848. {
  3849. //暂不考虑
  3850. }
  3851. else
  3852. {
  3853. newStudentAccount.BankName = en.BankName.Trim();
  3854. }
  3855. //银行卡号
  3856. if (string.IsNullOrWhiteSpace(en.CardNo))
  3857. {
  3858. //暂不考虑
  3859. }
  3860. else
  3861. {
  3862. reg = new Regex(@"^[0-9]*$"); //正则表达式
  3863. if (!reg.IsMatch(en.CardNo.Trim()))
  3864. {
  3865. errCount++;
  3866. errorMsgStr = "银行卡号格式不正确,请检查";
  3867. en.ErrorMessage = errorMsgStr;
  3868. errList.Add(en);
  3869. errorMsg.AppendLine(errorMsgStr);
  3870. continue;
  3871. }
  3872. else
  3873. {
  3874. newStudentAccount.CardNo = en.CardNo.Trim();
  3875. }
  3876. }
  3877. //学籍卡编号
  3878. if (string.IsNullOrWhiteSpace(en.StudentCardNo))
  3879. {
  3880. //暂不考虑
  3881. }
  3882. else
  3883. {
  3884. reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式
  3885. if (!reg.IsMatch(en.StudentCardNo.Trim()))
  3886. {
  3887. errCount++;
  3888. errorMsgStr = "学籍卡编号格式不正确,请检查";
  3889. en.ErrorMessage = errorMsgStr;
  3890. errList.Add(en);
  3891. errorMsg.AppendLine(errorMsgStr);
  3892. continue;
  3893. }
  3894. else
  3895. {
  3896. newStudent.StudentCardNo = en.StudentCardNo.Trim();
  3897. }
  3898. }
  3899. //毕结业证书编号
  3900. if (string.IsNullOrWhiteSpace(en.GraduateCardNo))
  3901. {
  3902. //暂不考虑
  3903. }
  3904. else
  3905. {
  3906. reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式
  3907. if (!reg.IsMatch(en.GraduateCardNo.Trim()))
  3908. {
  3909. errCount++;
  3910. errorMsgStr = "毕结业证书编号格式不正确,请检查";
  3911. en.ErrorMessage = errorMsgStr;
  3912. errList.Add(en);
  3913. errorMsg.AppendLine(errorMsgStr);
  3914. continue;
  3915. }
  3916. else
  3917. {
  3918. newStudent.GraduateCardNo = en.GraduateCardNo.Trim();
  3919. }
  3920. }
  3921. //学位有无
  3922. if (string.IsNullOrWhiteSpace(en.DegreeStatusStr))
  3923. {
  3924. newStudent.DegreeStatus = false;
  3925. }
  3926. else
  3927. {
  3928. var degreeStatus = generalExistList.Where(x => x.Name == en.DegreeStatusStr.Trim()).SingleOrDefault();
  3929. if (degreeStatus == null)
  3930. {
  3931. errCount++;
  3932. errorMsgStr = "学位有无不存在,请检查";
  3933. en.ErrorMessage = errorMsgStr;
  3934. errList.Add(en);
  3935. errorMsg.AppendLine(errorMsgStr);
  3936. continue;
  3937. }
  3938. else
  3939. {
  3940. newStudent.DegreeStatus = degreeStatus.Value == (int)CF_GeneralExist.Have ? true : false;
  3941. }
  3942. }
  3943. //在校经历
  3944. if (string.IsNullOrWhiteSpace(en.Career))
  3945. {
  3946. //暂不考虑
  3947. }
  3948. else
  3949. {
  3950. newStudent.Career = en.Career.Trim();
  3951. }
  3952. //备注
  3953. if (string.IsNullOrWhiteSpace(en.Remark))
  3954. {
  3955. //暂不考虑
  3956. }
  3957. else
  3958. {
  3959. newStudent.Remark = en.Remark.Trim();
  3960. }
  3961. ////Excel表重复性验证(注:当数据表中没有此记录,但是Excel中有重复数据时的去掉)
  3962. //for (int j = i + 1; j < enlist.Count; j++)
  3963. //{
  3964. // StudentView enA = enlist[j];
  3965. // //根据Excel表中的业务主键进行去重(学号或考生号唯一)
  3966. // if (en.StudentNo == enA.StudentNo || en.ExamineeNum == enA.ExamineeNum)
  3967. // {
  3968. // //用于标识Excel表中的重复记录(由于是批量进行插入数据表)
  3969. // }
  3970. //}
  3971. //数据表重复性验证(学号或考生号唯一)
  3972. var userVerify = newStudentList.Select(x => x.Sys_User).Where(x => x.LoginID == newUser.LoginID).SingleOrDefault();
  3973. if (userVerify == null)
  3974. {
  3975. var newNewStuVerify = newNewStuList.Where(x => x.ExamineeNum != newRecruitstudents.ExamineeNum
  3976. && x.StudentNo == newUser.LoginID).SingleOrDefault();
  3977. if (newNewStuVerify != null)
  3978. {
  3979. errCount++;
  3980. errorMsgStr = "学号重复(录取名单中学号重复),请核查";
  3981. en.ErrorMessage = errorMsgStr;
  3982. errList.Add(en);
  3983. errorMsg.AppendLine(errorMsgStr);
  3984. continue;
  3985. }
  3986. if (!newRecruitstudentsUpList.Any(x => x.ExamineeNum == newRecruitstudents.ExamineeNum))
  3987. {
  3988. if (!newRecruitstudentsInList.Any(x => x.ExamineeNum == newRecruitstudents.ExamineeNum))
  3989. {
  3990. var newExamineeNumVerify = newExamineeNumList.Where(x => x.ExamineeNum == newRecruitstudents.ExamineeNum).SingleOrDefault();
  3991. if (newExamineeNumVerify != null)
  3992. {
  3993. errCount++;
  3994. errorMsgStr = "考生号重复,请核查";
  3995. en.ErrorMessage = errorMsgStr;
  3996. errList.Add(en);
  3997. errorMsg.AppendLine(errorMsgStr);
  3998. continue;
  3999. }
  4000. }
  4001. else
  4002. {
  4003. errCount++;
  4004. errorMsgStr = "考生号重复(Excel中),请检查";
  4005. en.ErrorMessage = errorMsgStr;
  4006. errList.Add(en);
  4007. errorMsg.AppendLine(errorMsgStr);
  4008. continue;
  4009. }
  4010. }
  4011. else
  4012. {
  4013. errCount++;
  4014. errorMsgStr = "考生号重复(Excel中),请检查";
  4015. en.ErrorMessage = errorMsgStr;
  4016. errList.Add(en);
  4017. errorMsg.AppendLine(errorMsgStr);
  4018. continue;
  4019. }
  4020. if (!string.IsNullOrEmpty(newStudent.StudentCardNo))
  4021. {
  4022. if (!newStudentUpList.Any(x => x.StudentCardNo == newStudent.StudentCardNo))
  4023. {
  4024. if (!newStudentInList.Any(x => x.StudentCardNo == newStudent.StudentCardNo))
  4025. {
  4026. var newStudentCardNoVerify = newStudentCardNoList.Where(x => x.StudentCardNo == newStudent.StudentCardNo).SingleOrDefault();
  4027. if (newStudentCardNoVerify != null)
  4028. {
  4029. errCount++;
  4030. errorMsgStr = "学籍卡编号重复,请核查";
  4031. en.ErrorMessage = errorMsgStr;
  4032. errList.Add(en);
  4033. errorMsg.AppendLine(errorMsgStr);
  4034. continue;
  4035. }
  4036. }
  4037. else
  4038. {
  4039. errCount++;
  4040. errorMsgStr = "学籍卡编号重复(Excel中),请检查";
  4041. en.ErrorMessage = errorMsgStr;
  4042. errList.Add(en);
  4043. errorMsg.AppendLine(errorMsgStr);
  4044. continue;
  4045. }
  4046. }
  4047. else
  4048. {
  4049. errCount++;
  4050. errorMsgStr = "学籍卡编号重复(Excel中),请检查";
  4051. en.ErrorMessage = errorMsgStr;
  4052. errList.Add(en);
  4053. errorMsg.AppendLine(errorMsgStr);
  4054. continue;
  4055. }
  4056. }
  4057. if (!string.IsNullOrEmpty(newStudent.GraduateCardNo))
  4058. {
  4059. if (!newStudentUpList.Any(x => x.GraduateCardNo == newStudent.GraduateCardNo))
  4060. {
  4061. if (!newStudentInList.Any(x => x.GraduateCardNo == newStudent.GraduateCardNo))
  4062. {
  4063. var newGraduateCardNoVerify = newGraduateCardNoList.Where(x => x.GraduateCardNo == newStudent.GraduateCardNo).SingleOrDefault();
  4064. if (newGraduateCardNoVerify != null)
  4065. {
  4066. errCount++;
  4067. errorMsgStr = "毕结业证书编号重复,请核查";
  4068. en.ErrorMessage = errorMsgStr;
  4069. errList.Add(en);
  4070. errorMsg.AppendLine(errorMsgStr);
  4071. continue;
  4072. }
  4073. }
  4074. else
  4075. {
  4076. errCount++;
  4077. errorMsgStr = "毕结业证书编号重复(Excel中),请检查";
  4078. en.ErrorMessage = errorMsgStr;
  4079. errList.Add(en);
  4080. errorMsg.AppendLine(errorMsgStr);
  4081. continue;
  4082. }
  4083. }
  4084. else
  4085. {
  4086. errCount++;
  4087. errorMsgStr = "毕结业证书编号重复(Excel中),请检查";
  4088. en.ErrorMessage = errorMsgStr;
  4089. errList.Add(en);
  4090. errorMsg.AppendLine(errorMsgStr);
  4091. continue;
  4092. }
  4093. }
  4094. //新增
  4095. if (!newUserInList.Any(x => x.LoginID == newUser.LoginID))
  4096. {
  4097. newUser.UserID = Guid.NewGuid();
  4098. if (passwordParameter == null)
  4099. {
  4100. newUser.Password = ("A" + newUser.LoginID.Trim()).MD5();
  4101. }
  4102. else
  4103. {
  4104. if (passwordParameter.Value != null)
  4105. {
  4106. newUser.Password = passwordParameter.Value;
  4107. }
  4108. else
  4109. {
  4110. newUser.Password = ("A" + newUser.LoginID.Trim()).MD5();
  4111. }
  4112. }
  4113. this.SetNewStatus(newUser, (int)SYS_STATUS.USABLE);
  4114. newUserInList.Add(newUser);
  4115. newUser.Sys_Role = new HashSet<Sys_Role>();
  4116. roleList = roleList.Where(x => x.CF_StudentRole.StudentType == newStudent.StudentType).ToList();
  4117. if (roleList != null && roleList.Count > 0)
  4118. {
  4119. roleList.ForEach(x => newUser.Sys_Role.Add(x));
  4120. }
  4121. else
  4122. {
  4123. //对应角色为空时,默认为不分配用户角色
  4124. }
  4125. newStudent.UserID = newUser.UserID;
  4126. newStudent.IsPhotoComparison = false;
  4127. newStudent.IsProofread = false;
  4128. this.SetNewStatus(newStudent);
  4129. newStudentInList.Add(newStudent);
  4130. newStudentProfile.UserID = newStudent.UserID;
  4131. this.SetNewStatus(newStudentProfile);
  4132. newStudentProfileInList.Add(newStudentProfile);
  4133. newStudentContact.UserID = newStudent.UserID;
  4134. this.SetNewStatus(newStudentContact);
  4135. newStudentContactInList.Add(newStudentContact);
  4136. newStudentAccount.UserID = newStudent.UserID;
  4137. this.SetNewStatus(newStudentAccount);
  4138. newStudentAccountInList.Add(newStudentAccount);
  4139. newRecruitstudents.UserID = newStudent.UserID;
  4140. this.SetNewStatus(newRecruitstudents);
  4141. newRecruitstudentsInList.Add(newRecruitstudents);
  4142. inCount++;
  4143. }
  4144. else
  4145. {
  4146. //Excel表重复性验证
  4147. //(注:当数据表中没有此记录,但是Excel中有重复数据,可在此处进行抛出到失败数据文件中)
  4148. errCount++;
  4149. errorMsgStr = "学号重复(Excel中),请检查";
  4150. en.ErrorMessage = errorMsgStr;
  4151. errList.Add(en);
  4152. errorMsg.AppendLine(errorMsgStr);
  4153. continue;
  4154. }
  4155. }
  4156. else
  4157. {
  4158. //更新(判断Excel有重复时,以最后一条记录更新为准)
  4159. var studentVerify = newStudentList.Where(x => x.UserID == userVerify.UserID).SingleOrDefault();
  4160. if (studentVerify == null)
  4161. {
  4162. errCount++;
  4163. errorMsgStr = "学号冲突(与其它帐号冲突),请检查";
  4164. en.ErrorMessage = errorMsgStr;
  4165. errList.Add(en);
  4166. errorMsg.AppendLine(errorMsgStr);
  4167. continue;
  4168. }
  4169. else
  4170. {
  4171. var newNewStuVerify = newNewStuList.Where(x => x.ExamineeNum != newRecruitstudents.ExamineeNum
  4172. && x.StudentNo == newUser.LoginID).SingleOrDefault();
  4173. if (newNewStuVerify != null)
  4174. {
  4175. errCount++;
  4176. errorMsgStr = "学号重复(录取名单中学号重复),请核查";
  4177. en.ErrorMessage = errorMsgStr;
  4178. errList.Add(en);
  4179. errorMsg.AppendLine(errorMsgStr);
  4180. continue;
  4181. }
  4182. if (!newRecruitstudentsInList.Any(x => x.ExamineeNum == newRecruitstudents.ExamineeNum))
  4183. {
  4184. if (!newRecruitstudentsUpList.Any(x => x.ExamineeNum == newRecruitstudents.ExamineeNum))
  4185. {
  4186. var newExamineeNumVerify = newExamineeNumList.Where(x => x.UserID != userVerify.UserID
  4187. && x.ExamineeNum == newRecruitstudents.ExamineeNum).ToList();
  4188. if (newExamineeNumVerify != null && newExamineeNumVerify.Count() > 0)
  4189. {
  4190. errCount++;
  4191. errorMsgStr = "考生号已存在(与其它学生冲突),请检查";
  4192. en.ErrorMessage = errorMsgStr;
  4193. errList.Add(en);
  4194. errorMsg.AppendLine(errorMsgStr);
  4195. continue;
  4196. }
  4197. }
  4198. else
  4199. {
  4200. errCount++;
  4201. errorMsgStr = "考生号重复(Excel中),请检查";
  4202. en.ErrorMessage = errorMsgStr;
  4203. errList.Add(en);
  4204. errorMsg.AppendLine(errorMsgStr);
  4205. continue;
  4206. }
  4207. }
  4208. else
  4209. {
  4210. errCount++;
  4211. errorMsgStr = "考生号重复(Excel中),请检查";
  4212. en.ErrorMessage = errorMsgStr;
  4213. errList.Add(en);
  4214. errorMsg.AppendLine(errorMsgStr);
  4215. continue;
  4216. }
  4217. if (!string.IsNullOrEmpty(newStudent.StudentCardNo))
  4218. {
  4219. if (!newStudentInList.Any(x => x.StudentCardNo == newStudent.StudentCardNo))
  4220. {
  4221. if (!newStudentUpList.Any(x => x.StudentCardNo == newStudent.StudentCardNo))
  4222. {
  4223. var newStudentCardNoVerify = newStudentCardNoList.Where(x => x.UserID != userVerify.UserID
  4224. && x.StudentCardNo == newStudent.StudentCardNo).ToList();
  4225. if (newStudentCardNoVerify != null && newStudentCardNoVerify.Count() > 0)
  4226. {
  4227. errCount++;
  4228. errorMsgStr = "学籍卡编号已存在(与其它学生冲突),请检查";
  4229. en.ErrorMessage = errorMsgStr;
  4230. errList.Add(en);
  4231. errorMsg.AppendLine(errorMsgStr);
  4232. continue;
  4233. }
  4234. }
  4235. else
  4236. {
  4237. errCount++;
  4238. errorMsgStr = "学籍卡编号重复(Excel中),请检查";
  4239. en.ErrorMessage = errorMsgStr;
  4240. errList.Add(en);
  4241. errorMsg.AppendLine(errorMsgStr);
  4242. continue;
  4243. }
  4244. }
  4245. else
  4246. {
  4247. errCount++;
  4248. errorMsgStr = "学籍卡编号重复(Excel中),请检查";
  4249. en.ErrorMessage = errorMsgStr;
  4250. errList.Add(en);
  4251. errorMsg.AppendLine(errorMsgStr);
  4252. continue;
  4253. }
  4254. }
  4255. if (!string.IsNullOrEmpty(newStudent.GraduateCardNo))
  4256. {
  4257. if (!newStudentInList.Any(x => x.GraduateCardNo == newStudent.GraduateCardNo))
  4258. {
  4259. if (!newStudentUpList.Any(x => x.GraduateCardNo == newStudent.GraduateCardNo))
  4260. {
  4261. var newGraduateCardNoVerify = newGraduateCardNoList.Where(x => x.UserID != userVerify.UserID
  4262. && x.GraduateCardNo == newStudent.GraduateCardNo).ToList();
  4263. if (newGraduateCardNoVerify != null && newGraduateCardNoVerify.Count() > 0)
  4264. {
  4265. errCount++;
  4266. errorMsgStr = "毕结业证书编号已存在(与其它学生冲突),请检查";
  4267. en.ErrorMessage = errorMsgStr;
  4268. errList.Add(en);
  4269. errorMsg.AppendLine(errorMsgStr);
  4270. continue;
  4271. }
  4272. }
  4273. else
  4274. {
  4275. errCount++;
  4276. errorMsgStr = "毕结业证书编号重复(Excel中),请检查";
  4277. en.ErrorMessage = errorMsgStr;
  4278. errList.Add(en);
  4279. errorMsg.AppendLine(errorMsgStr);
  4280. continue;
  4281. }
  4282. }
  4283. else
  4284. {
  4285. errCount++;
  4286. errorMsgStr = "毕结业证书编号重复(Excel中),请检查";
  4287. en.ErrorMessage = errorMsgStr;
  4288. errList.Add(en);
  4289. errorMsg.AppendLine(errorMsgStr);
  4290. continue;
  4291. }
  4292. }
  4293. studentVerify.Sys_User.LoginID = newUser.LoginID.Trim();
  4294. studentVerify.Sys_User.Name = newUser.Name.Trim();
  4295. this.SetModifyStatus(studentVerify.Sys_User);
  4296. newUserUpList.Add(studentVerify.Sys_User);
  4297. studentVerify.SexID = newStudent.SexID;
  4298. studentVerify.BirthDate = newStudent.BirthDate;
  4299. studentVerify.NationID = newStudent.NationID;
  4300. studentVerify.PoliticsID = newStudent.PoliticsID;
  4301. studentVerify.CertificatesType = newStudent.CertificatesType;
  4302. studentVerify.IDNumber = newStudent.IDNumber;
  4303. studentVerify.StudentType = newStudent.StudentType;
  4304. studentVerify.Sys_User.Sys_Role = new HashSet<Sys_Role>();
  4305. roleList = roleList.Where(x => x.CF_StudentRole.StudentType == newStudent.StudentType).ToList();
  4306. if (roleList != null && roleList.Count > 0)
  4307. {
  4308. roleList.ForEach(x => studentVerify.Sys_User.Sys_Role.Add(x));
  4309. }
  4310. else
  4311. {
  4312. //对应角色为空时,默认为不分配用户角色
  4313. }
  4314. studentVerify.StudentCardNo = newStudent.StudentCardNo;
  4315. studentVerify.GraduateCardNo = newStudent.GraduateCardNo;
  4316. studentVerify.DegreeStatus = newStudent.DegreeStatus;
  4317. studentVerify.Career = newStudent.Career;
  4318. studentVerify.Remark = newStudent.Remark;
  4319. this.SetModifyStatus(studentVerify);
  4320. newStudentUpList.Add(studentVerify);
  4321. if (studentVerify.CF_StudentProfile == null)
  4322. {
  4323. var studentProfile = new CF_StudentProfile();
  4324. studentProfile.UserID = studentVerify.UserID;
  4325. studentProfile.UsedName = newStudentProfile.UsedName;
  4326. studentProfile.LiteracyLevelID = newStudentProfile.LiteracyLevelID;
  4327. studentProfile.CultureModelID = newStudentProfile.CultureModelID;
  4328. studentProfile.IsDreamProject = newStudentProfile.IsDreamProject;
  4329. studentProfile.Country = newStudentProfile.Country;
  4330. studentProfile.Place = newStudentProfile.Place;
  4331. studentProfile.BornPlace = newStudentProfile.BornPlace;
  4332. studentProfile.HealthStateID = newStudentProfile.HealthStateID;
  4333. studentProfile.BloodGroup = newStudentProfile.BloodGroup;
  4334. studentProfile.Specialty = newStudentProfile.Specialty;
  4335. studentProfile.Height = newStudentProfile.Height;
  4336. studentProfile.Weight = newStudentProfile.Weight;
  4337. studentProfile.DirectorName = newStudentProfile.DirectorName;
  4338. this.SetNewStatus(studentProfile);
  4339. newStudentProfileInList.Add(studentProfile);
  4340. }
  4341. else
  4342. {
  4343. studentVerify.CF_StudentProfile.UsedName = newStudentProfile.UsedName;
  4344. studentVerify.CF_StudentProfile.LiteracyLevelID = newStudentProfile.LiteracyLevelID;
  4345. studentVerify.CF_StudentProfile.CultureModelID = newStudentProfile.CultureModelID;
  4346. studentVerify.CF_StudentProfile.IsDreamProject = newStudentProfile.IsDreamProject;
  4347. studentVerify.CF_StudentProfile.Country = newStudentProfile.Country;
  4348. studentVerify.CF_StudentProfile.Place = newStudentProfile.Place;
  4349. studentVerify.CF_StudentProfile.BornPlace = newStudentProfile.BornPlace;
  4350. studentVerify.CF_StudentProfile.HealthStateID = newStudentProfile.HealthStateID;
  4351. studentVerify.CF_StudentProfile.BloodGroup = newStudentProfile.BloodGroup;
  4352. studentVerify.CF_StudentProfile.Specialty = newStudentProfile.Specialty;
  4353. studentVerify.CF_StudentProfile.Height = newStudentProfile.Height;
  4354. studentVerify.CF_StudentProfile.Weight = newStudentProfile.Weight;
  4355. studentVerify.CF_StudentProfile.DirectorName = newStudentProfile.DirectorName;
  4356. this.SetModifyStatus(studentVerify.CF_StudentProfile);
  4357. newStudentProfileUpList.Add(studentVerify.CF_StudentProfile);
  4358. }
  4359. if (studentVerify.CF_StudentContact == null)
  4360. {
  4361. var studentContact = new CF_StudentContact();
  4362. studentContact.UserID = studentVerify.UserID;
  4363. studentContact.Email = newStudentContact.Email;
  4364. studentContact.Telephone = newStudentContact.Email;
  4365. studentContact.Mobile = newStudentContact.Email;
  4366. studentContact.ZIPCode = newStudentContact.ZIPCode;
  4367. studentContact.WeChatNum = newStudentContact.WeChatNum;
  4368. studentContact.QQ = newStudentContact.QQ;
  4369. studentContact.HomeAddress = newStudentContact.HomeAddress;
  4370. studentContact.WorkUnit = newStudentContact.WorkUnit;
  4371. studentContact.Address = newStudentContact.Address;
  4372. studentContact.Recipient = newStudentContact.Recipient;
  4373. studentContact.Dormitory = newStudentContact.Dormitory;
  4374. this.SetNewStatus(studentContact);
  4375. newStudentContactInList.Add(studentContact);
  4376. }
  4377. else
  4378. {
  4379. studentVerify.CF_StudentContact.Email = newStudentContact.Email;
  4380. studentVerify.CF_StudentContact.Telephone = newStudentContact.Telephone;
  4381. studentVerify.CF_StudentContact.Mobile = newStudentContact.Mobile;
  4382. studentVerify.CF_StudentContact.ZIPCode = newStudentContact.ZIPCode;
  4383. studentVerify.CF_StudentContact.WeChatNum = newStudentContact.WeChatNum;
  4384. studentVerify.CF_StudentContact.QQ = newStudentContact.QQ;
  4385. studentVerify.CF_StudentContact.HomeAddress = newStudentContact.HomeAddress;
  4386. studentVerify.CF_StudentContact.WorkUnit = newStudentContact.WorkUnit;
  4387. studentVerify.CF_StudentContact.Address = newStudentContact.Address;
  4388. studentVerify.CF_StudentContact.Recipient = newStudentContact.Recipient;
  4389. studentVerify.CF_StudentContact.Dormitory = newStudentContact.Dormitory;
  4390. this.SetModifyStatus(studentVerify.CF_StudentContact);
  4391. newStudentContactUpList.Add(studentVerify.CF_StudentContact);
  4392. }
  4393. if (studentVerify.CF_StudentAccount == null)
  4394. {
  4395. var studentAccount = new CF_StudentAccount();
  4396. studentAccount.UserID = studentVerify.UserID;
  4397. studentAccount.BankName = newStudentAccount.BankName;
  4398. studentAccount.CardNo = newStudentAccount.CardNo;
  4399. this.SetNewStatus(studentAccount);
  4400. newStudentAccountInList.Add(studentAccount);
  4401. }
  4402. else
  4403. {
  4404. studentVerify.CF_StudentAccount.BankName = newStudentAccount.BankName;
  4405. studentVerify.CF_StudentAccount.CardNo = newStudentAccount.CardNo;
  4406. this.SetModifyStatus(studentVerify.CF_StudentAccount);
  4407. newStudentAccountUpList.Add(studentVerify.CF_StudentAccount);
  4408. }
  4409. if (studentVerify.CF_Recruitstudents == null)
  4410. {
  4411. var recruitstudents = new CF_Recruitstudents();
  4412. recruitstudents.UserID = studentVerify.UserID;
  4413. recruitstudents.ExamineeNum = newRecruitstudents.ExamineeNum;
  4414. recruitstudents.AdmissionTicketNo = newRecruitstudents.AdmissionTicketNo;
  4415. recruitstudents.ExamineeType = newRecruitstudents.ExamineeType;
  4416. recruitstudents.EntranceDate = newRecruitstudents.EntranceDate;
  4417. recruitstudents.Score = newRecruitstudents.Score;
  4418. recruitstudents.EntranceWayID = newRecruitstudents.EntranceWayID;
  4419. recruitstudents.FeaturesID = newRecruitstudents.FeaturesID;
  4420. recruitstudents.TerritorialID = newRecruitstudents.TerritorialID;
  4421. recruitstudents.Area = newRecruitstudents.Area;
  4422. this.SetNewStatus(recruitstudents);
  4423. newRecruitstudentsInList.Add(recruitstudents);
  4424. }
  4425. else
  4426. {
  4427. studentVerify.CF_Recruitstudents.ExamineeNum = newRecruitstudents.ExamineeNum;
  4428. studentVerify.CF_Recruitstudents.AdmissionTicketNo = newRecruitstudents.AdmissionTicketNo;
  4429. studentVerify.CF_Recruitstudents.ExamineeType = newRecruitstudents.ExamineeType;
  4430. studentVerify.CF_Recruitstudents.EntranceDate = newRecruitstudents.EntranceDate;
  4431. studentVerify.CF_Recruitstudents.Score = newRecruitstudents.Score;
  4432. studentVerify.CF_Recruitstudents.EntranceWayID = newRecruitstudents.EntranceWayID;
  4433. studentVerify.CF_Recruitstudents.FeaturesID = newRecruitstudents.FeaturesID;
  4434. studentVerify.CF_Recruitstudents.TerritorialID = newRecruitstudents.TerritorialID;
  4435. studentVerify.CF_Recruitstudents.Area = newRecruitstudents.Area;
  4436. this.SetModifyStatus(studentVerify.CF_Recruitstudents);
  4437. newRecruitstudentsUpList.Add(studentVerify.CF_Recruitstudents);
  4438. }
  4439. upCount++;
  4440. }
  4441. }
  4442. }
  4443. TransactionOptions transactionOption = new TransactionOptions();
  4444. transactionOption.IsolationLevel = System.Transactions.IsolationLevel.Serializable;
  4445. transactionOption.Timeout = new TimeSpan(0, 3, 0);
  4446. using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, transactionOption))
  4447. {
  4448. UnitOfWork.BulkInsert<Sys_User>(newUserInList);
  4449. UnitOfWork.BulkInsert(newUserInList, (x => x.Sys_Role));
  4450. UnitOfWork.BulkInsert<CF_Student>(newStudentInList);
  4451. UnitOfWork.BulkInsert<CF_StudentProfile>(newStudentProfileInList);
  4452. UnitOfWork.BulkInsert<CF_StudentContact>(newStudentContactInList);
  4453. UnitOfWork.BulkInsert<CF_StudentAccount>(newStudentAccountInList);
  4454. UnitOfWork.BulkInsert<CF_Recruitstudents>(newRecruitstudentsInList);
  4455. if (newUserUpList != null && newUserUpList.Count() > 0)
  4456. {
  4457. UnitOfWork.BatchUpdate(newUserUpList);
  4458. }
  4459. if (newStudentUpList != null && newStudentUpList.Count() > 0)
  4460. {
  4461. UnitOfWork.BatchUpdate(newStudentUpList);
  4462. }
  4463. if (newStudentProfileUpList != null && newStudentProfileUpList.Count() > 0)
  4464. {
  4465. UnitOfWork.BatchUpdate(newStudentProfileUpList);
  4466. }
  4467. if (newStudentContactUpList != null && newStudentContactUpList.Count() > 0)
  4468. {
  4469. UnitOfWork.BatchUpdate(newStudentContactUpList);
  4470. }
  4471. if (newStudentAccountUpList != null && newStudentAccountUpList.Count() > 0)
  4472. {
  4473. UnitOfWork.BatchUpdate(newStudentAccountUpList);
  4474. }
  4475. if (newRecruitstudentsUpList != null && newRecruitstudentsUpList.Count() > 0)
  4476. {
  4477. UnitOfWork.BatchUpdate(newRecruitstudentsUpList);
  4478. }
  4479. ts.Complete();
  4480. }
  4481. errdataList = errList.Distinct().ToList(); //错误列表List
  4482. }
  4483. catch (Exception)
  4484. {
  4485. throw;
  4486. }
  4487. }
  4488. /// <summary>
  4489. /// 学生信息新增刷新相关业务处理
  4490. /// </summary>
  4491. /// <param name="userID"></param>
  4492. public void StudentOnAddRefresh(List<Guid> userID)
  4493. {
  4494. throw new NotImplementedException();
  4495. }
  4496. }
  4497. }