12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Data;
- using System.Data.OleDb;
- using System.Linq.Expressions;
- using System.Transactions;
- using System.Globalization;
- using System.IO;
- using System.Web;
- using Bowin.Common;
- using Bowin.Common.Utility;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.Utility;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.CacheManage;
- using EMIS.ViewModel.StudentManage.StudentProfile;
- using EMIS.ViewModel.StudentManage.StudentRegister;
- using EMIS.ViewModel.StudentManage.StudentChange;
- using EMIS.DataLogic.StudentManage.StudentProfile;
- using EMIS.DataLogic.StudentManage.StudentRegister;
- using EMIS.DataLogic.StudentManage.StudentChange;
- using EMIS.DataLogic.SystemDAL;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.CommonLogic.StudentManage.StudentStatistics;
- namespace EMIS.CommonLogic.StudentManage.StudentProfile
- {
- public class StudentServices : BaseWorkflowServices<CF_DifferentDynamic>, IStudentServices
- {
- public Lazy<StudentDAL> StudentDAL { get; set; }
- public Lazy<StudentReportDAL> StudentReportDAL { get; set; }
- public Lazy<StudentChangeDAL> StudentChangeDAL { get; set; }
- public Lazy<DataRangeDAL> DataRangeDAL { get; set; }
- public Lazy<IInSchoolSettingServices> InSchoolSettingServices { get; set; }
-
- /// <summary>
- /// 查询对应的学生信息StudentView
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="gradeID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="classmajorID"></param>
- /// <param name="isPhoto"></param>
- /// <param name="reportStatus"></param>
- /// <param name="planningGraduateDate"></param>
- /// <param name="inSchoolStatus"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<StudentView> GetStudentViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID,
- int? learningformID, string learnSystem, Guid? classmajorID, int? isPhoto, int? reportStatus, string planningGraduateDate, int? inSchoolStatus, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (classmajorID.HasValue)
- {
- expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
- }
- if (isPhoto.HasValue)
- {
- if (isPhoto.Value == (int)CF_GeneralExist.Have)
- {
- expStudent = expStudent.And(x => x.PhotoUrl != null && x.PhotoUrl != "");
- }
- if (isPhoto.Value == (int)CF_GeneralExist.No)
- {
- expStudent = expStudent.And(x => x.PhotoUrl == null || x.PhotoUrl == "");
- }
- }
- if (!string.IsNullOrEmpty(planningGraduateDate) && planningGraduateDate != "-1")
- {
- DateTime planDate = DateTime.ParseExact(planningGraduateDate, "yyyyMMdd", CultureInfo.CurrentCulture);
- expStudent = expStudent.And(x => DateTime.Compare((DateTime)x.PlanningGraduateDate, planDate) == 0);
- }
- if (inSchoolStatus.HasValue)
- {
- expStudent = expStudent.And(x => x.InSchoolStatusID == inSchoolStatus);
- }
- var endStatusID = this.GetCorrectEndStatus();
- Expression<Func<CF_DifferentDynamic, bool>> expChange = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expChange = expChange.And(x => x.ApprovalStatus == endStatusID);
- var query = StudentDAL.Value.GetStudentViewQueryable(expStudent, expChange);
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (gradeID.HasValue)
- {
- query = query.Where(x => x.GradeID == gradeID);
- }
- if (standardID.HasValue)
- {
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- if (reportStatus.HasValue)
- {
- query = query.Where(x => x.ReportStatus == reportStatus);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
- .OrderBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo)
- .ThenBy(x => x.GradeID).ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
- .ToGridResultSet<StudentView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的学生信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="gradeID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="classmajorID"></param>
- /// <param name="isPhoto"></param>
- /// <param name="reportStatus"></param>
- /// <param name="planningGraduateDate"></param>
- /// <param name="inSchoolStatus"></param>
- /// <returns></returns>
- public IList<StudentView> GetStudentViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID,
- int? learningformID, string learnSystem, Guid? classmajorID, int? isPhoto, int? reportStatus, string planningGraduateDate, int? inSchoolStatus)
- {
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (classmajorID.HasValue)
- {
- expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
- }
- if (isPhoto.HasValue)
- {
- if (isPhoto.Value == (int)CF_GeneralExist.Have)
- {
- expStudent = expStudent.And(x => x.PhotoUrl != null && x.PhotoUrl != "");
- }
- if (isPhoto.Value == (int)CF_GeneralExist.No)
- {
- expStudent = expStudent.And(x => x.PhotoUrl == null || x.PhotoUrl == "");
- }
- }
- if (!string.IsNullOrEmpty(planningGraduateDate) && planningGraduateDate != "-1")
- {
- DateTime planDate = DateTime.ParseExact(planningGraduateDate, "yyyyMMdd", CultureInfo.CurrentCulture);
- expStudent = expStudent.And(x => DateTime.Compare((DateTime)x.PlanningGraduateDate, planDate) == 0);
- }
- if (inSchoolStatus.HasValue)
- {
- expStudent = expStudent.And(x => x.InSchoolStatusID == inSchoolStatus);
- }
- var endStatusID = this.GetCorrectEndStatus();
- Expression<Func<CF_DifferentDynamic, bool>> expChange = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expChange = expChange.And(x => x.ApprovalStatus == endStatusID);
- var query = StudentDAL.Value.GetStudentViewQueryable(expStudent, expChange);
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (gradeID.HasValue)
- {
- query = query.Where(x => x.GradeID == gradeID);
- }
- if (standardID.HasValue)
- {
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- if (reportStatus.HasValue)
- {
- query = query.Where(x => x.ReportStatus == reportStatus);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
- .OrderBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo)
- .ThenBy(x => x.GradeID).ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
- .ToList();
- }
- /// <summary>
- /// 查询对应的学生信息List(userIDList)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="gradeID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="classmajorID"></param>
- /// <param name="isPhoto"></param>
- /// <param name="reportStatus"></param>
- /// <param name="planningGraduateDate"></param>
- /// <param name="inSchoolStatus"></param>
- /// <param name="userIDList"></param>
- /// <returns></returns>
- public IList<StudentView> GetStudentViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID,
- int? learningformID, string learnSystem, Guid? classmajorID, int? isPhoto, int? reportStatus, string planningGraduateDate, int? inSchoolStatus, List<Guid?> userIDList)
- {
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (userIDList != null && userIDList.Count() > 0)
- {
- expStudent = expStudent.And(x => userIDList.Contains(x.UserID));
- }
- else
- {
- if (classmajorID.HasValue)
- {
- expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
- }
- if (isPhoto.HasValue)
- {
- if (isPhoto.Value == (int)CF_GeneralExist.Have)
- {
- expStudent = expStudent.And(x => x.PhotoUrl != null && x.PhotoUrl != "");
- }
- if (isPhoto.Value == (int)CF_GeneralExist.No)
- {
- expStudent = expStudent.And(x => x.PhotoUrl == null || x.PhotoUrl == "");
- }
- }
- if (!string.IsNullOrEmpty(planningGraduateDate) && planningGraduateDate != "-1")
- {
- DateTime planDate = DateTime.ParseExact(planningGraduateDate, "yyyyMMdd", CultureInfo.CurrentCulture);
- expStudent = expStudent.And(x => DateTime.Compare((DateTime)x.PlanningGraduateDate, planDate) == 0);
- }
- if (inSchoolStatus.HasValue)
- {
- expStudent = expStudent.And(x => x.InSchoolStatusID == inSchoolStatus);
- }
- }
- var endStatusID = this.GetCorrectEndStatus();
- Expression<Func<CF_DifferentDynamic, bool>> expChange = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expChange = expChange.And(x => x.ApprovalStatus == endStatusID);
- var query = StudentDAL.Value.GetStudentViewQueryable(expStudent, expChange);
- if (userIDList == null || userIDList.Count() <= 0)
- {
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (gradeID.HasValue)
- {
- query = query.Where(x => x.GradeID == gradeID);
- }
- if (standardID.HasValue)
- {
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- if (reportStatus.HasValue)
- {
- query = query.Where(x => x.ReportStatus == reportStatus);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- }
- return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
- .OrderBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo)
- .ThenBy(x => x.GradeID).ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
- .ToList();
- }
- /// <summary>
- /// 查询对应的学生信息List(根据userIDList)
- /// </summary>
- /// <param name="userIDList"></param>
- /// <returns></returns>
- public IList<StudentView> GetStudentViewList(List<Guid?> userIDList)
- {
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expStudent = expStudent.And(x => userIDList.Contains(x.UserID));
- var query = StudentDAL.Value.GetStudentViewQueryable(expStudent);
-
- return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query)).OrderBy(x => x.ClassmajorNo.Length)
- .ThenBy(x => x.ClassmajorNo).ThenBy(x => x.GradeID).ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ToList();
- }
- /// <summary>
- /// 查询对应的学生信息StudentBaseView(全部、在校或非在校信息)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="userID"></param>
- /// <param name="inSchoolStatus"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<StudentBaseView> GetStudentBaseViewGrid(ConfiguretView configuretView, Guid? userID, int? inSchoolStatus, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (inSchoolStatus.HasValue)
- {
- if (inSchoolStatus != null && inSchoolStatus > -1)
- {
- var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
- if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.Yes)
- {
- if (userID.HasValue)
- {
- expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID) || x.UserID == userID);
- }
- else
- {
- expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- }
- if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.No)
- {
- if (userID.HasValue)
- {
- expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID) || x.UserID == userID);
- }
- else
- {
- expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- }
- }
- }
- var query = StudentDAL.Value.GetStudentBaseViewQueryable(expStudent);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
- .OrderBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo).ThenBy(x => x.GradeID)
- .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ToGridResultSet<StudentBaseView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的学生信息List(全部、在校或非在校信息)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="userID"></param>
- /// <param name="inSchoolStatus"></param>
- /// <returns></returns>
- public IList<StudentBaseView> GetStudentBaseViewList(ConfiguretView configuretView, Guid? userID, int? inSchoolStatus)
- {
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (inSchoolStatus.HasValue)
- {
- if (inSchoolStatus != null && inSchoolStatus > -1)
- {
- var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
- if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.Yes)
- {
- if (userID.HasValue)
- {
- expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID) || x.UserID == userID);
- }
- else
- {
- expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- }
- if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.No)
- {
- if (userID.HasValue)
- {
- expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID) || x.UserID == userID);
- }
- else
- {
- expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
- }
- }
- }
- }
- var query = StudentDAL.Value.GetStudentBaseViewQueryable(expStudent);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
- .OrderBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo).ThenBy(x => x.GradeID)
- .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ToList();
- }
- /// <summary>
- /// 查询对应的照片比对学生信息StudentView
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="gradeID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="classmajorID"></param>
- /// <param name="isRecruitPhoto"></param>
- /// <param name="isPhoto"></param>
- /// <param name="isGraduationPhoto"></param>
- /// <param name="isPhotoComparison"></param>
- /// <param name="inSchoolStatus"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<StudentView> GetStudentPicComparisonGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID,
- int? learningformID, string learnSystem, Guid? classmajorID, int? isRecruitPhoto, int? isPhoto, int? isGraduationPhoto, int? isPhotoComparison, int? inSchoolStatus, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (classmajorID.HasValue)
- {
- expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
- }
- if (isPhoto.HasValue)
- {
- if (isPhoto.Value == (int)CF_GeneralExist.Have)
- {
- expStudent = expStudent.And(x => x.PhotoUrl != null && x.PhotoUrl != "");
- }
- if (isPhoto.Value == (int)CF_GeneralExist.No)
- {
- expStudent = expStudent.And(x => x.PhotoUrl == null || x.PhotoUrl == "");
- }
- }
- if (isGraduationPhoto.HasValue)
- {
- if (isGraduationPhoto.Value == (int)CF_GeneralExist.Have)
- {
- expStudent = expStudent.And(x => x.GraduationPictureUrl != null && x.GraduationPictureUrl != "");
- }
- if (isGraduationPhoto.Value == (int)CF_GeneralExist.No)
- {
- expStudent = expStudent.And(x => x.GraduationPictureUrl == null || x.GraduationPictureUrl == "");
- }
- }
- if (isPhotoComparison.HasValue)
- {
- if (isPhotoComparison.Value == (int)CF_GeneralPurpose.IsYes)
- {
- expStudent = expStudent.And(x => x.IsPhotoComparison == true);
- }
- if (isPhotoComparison.Value == (int)CF_GeneralPurpose.IsNo)
- {
- expStudent = expStudent.And(x => x.IsPhotoComparison != true);
- }
- }
- if (inSchoolStatus.HasValue)
- {
- expStudent = expStudent.And(x => x.InSchoolStatusID == inSchoolStatus);
- }
- var query = StudentDAL.Value.GetStudentViewQueryable(expStudent);
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (gradeID.HasValue)
- {
- query = query.Where(x => x.GradeID == gradeID);
- }
- if (standardID.HasValue)
- {
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- if (isRecruitPhoto.HasValue)
- {
- if (isRecruitPhoto.Value == (int)CF_GeneralExist.Have)
- {
- query = query.Where(x => x.RecruitPictureUrl != null && x.RecruitPictureUrl != "");
- }
- if (isRecruitPhoto.Value == (int)CF_GeneralExist.No)
- {
- query = query.Where(x => x.RecruitPictureUrl == null || x.RecruitPictureUrl == "");
- }
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
- .OrderBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo)
- .ThenBy(x => x.GradeID).ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
- .ToGridResultSet<StudentView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的照片比对学生信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="gradeID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="classmajorID"></param>
- /// <param name="isRecruitPhoto"></param>
- /// <param name="isPhoto"></param>
- /// <param name="isGraduationPhoto"></param>
- /// <param name="isPhotoComparison"></param>
- /// <param name="inSchoolStatus"></param>
- /// <returns></returns>
- public IList<StudentView> GetStudentPicComparisonList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID,
- int? learningformID, string learnSystem, Guid? classmajorID, int? isRecruitPhoto, int? isPhoto, int? isGraduationPhoto, int? isPhotoComparison, int? inSchoolStatus)
- {
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (classmajorID.HasValue)
- {
- expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
- }
- if (isPhoto.HasValue)
- {
- if (isPhoto.Value == (int)CF_GeneralExist.Have)
- {
- expStudent = expStudent.And(x => x.PhotoUrl != null && x.PhotoUrl != "");
- }
- if (isPhoto.Value == (int)CF_GeneralExist.No)
- {
- expStudent = expStudent.And(x => x.PhotoUrl == null || x.PhotoUrl == "");
- }
- }
- if (isGraduationPhoto.HasValue)
- {
- if (isGraduationPhoto.Value == (int)CF_GeneralExist.Have)
- {
- expStudent = expStudent.And(x => x.GraduationPictureUrl != null && x.GraduationPictureUrl != "");
- }
- if (isGraduationPhoto.Value == (int)CF_GeneralExist.No)
- {
- expStudent = expStudent.And(x => x.GraduationPictureUrl == null || x.GraduationPictureUrl == "");
- }
- }
- if (isPhotoComparison.HasValue)
- {
- if (isPhotoComparison.Value == (int)CF_GeneralPurpose.IsYes)
- {
- expStudent = expStudent.And(x => x.IsPhotoComparison == true);
- }
- if (isPhotoComparison.Value == (int)CF_GeneralPurpose.IsNo)
- {
- expStudent = expStudent.And(x => x.IsPhotoComparison != true);
- }
- }
- if (inSchoolStatus.HasValue)
- {
- expStudent = expStudent.And(x => x.InSchoolStatusID == inSchoolStatus);
- }
- var query = StudentDAL.Value.GetStudentViewQueryable(expStudent);
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (gradeID.HasValue)
- {
- query = query.Where(x => x.GradeID == gradeID);
- }
- if (standardID.HasValue)
- {
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- if (isRecruitPhoto.HasValue)
- {
- if (isRecruitPhoto.Value == (int)CF_GeneralExist.Have)
- {
- query = query.Where(x => x.RecruitPictureUrl != null && x.RecruitPictureUrl != "");
- }
- if (isRecruitPhoto.Value == (int)CF_GeneralExist.No)
- {
- query = query.Where(x => x.RecruitPictureUrl == null || x.RecruitPictureUrl == "");
- }
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
- .OrderBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo)
- .ThenBy(x => x.GradeID).ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ToList();
- }
- /// <summary>
- /// 查询对应的照片比对学生信息List(userIDList)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="gradeID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="classmajorID"></param>
- /// <param name="isRecruitPhoto"></param>
- /// <param name="isPhoto"></param>
- /// <param name="isGraduationPhoto"></param>
- /// <param name="isPhotoComparison"></param>
- /// <param name="inSchoolStatus"></param>
- /// <param name="userIDList"></param>
- /// <returns></returns>
- public IList<StudentView> GetStudentPicComparisonList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID,
- int? learningformID, string learnSystem, Guid? classmajorID, int? isRecruitPhoto, int? isPhoto, int? isGraduationPhoto, int? isPhotoComparison, int? inSchoolStatus, List<Guid?> userIDList)
- {
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (userIDList != null && userIDList.Count() > 0)
- {
- expStudent = expStudent.And(x => userIDList.Contains(x.UserID));
- }
- else
- {
- if (classmajorID.HasValue)
- {
- expStudent = expStudent.And(x => x.ClassmajorID == classmajorID);
- }
- if (isPhoto.HasValue)
- {
- if (isPhoto.Value == (int)CF_GeneralExist.Have)
- {
- expStudent = expStudent.And(x => x.PhotoUrl != null && x.PhotoUrl != "");
- }
- if (isPhoto.Value == (int)CF_GeneralExist.No)
- {
- expStudent = expStudent.And(x => x.PhotoUrl == null || x.PhotoUrl == "");
- }
- }
- if (isGraduationPhoto.HasValue)
- {
- if (isGraduationPhoto.Value == (int)CF_GeneralExist.Have)
- {
- expStudent = expStudent.And(x => x.GraduationPictureUrl != null && x.GraduationPictureUrl != "");
- }
- if (isGraduationPhoto.Value == (int)CF_GeneralExist.No)
- {
- expStudent = expStudent.And(x => x.GraduationPictureUrl == null || x.GraduationPictureUrl == "");
- }
- }
- if (isPhotoComparison.HasValue)
- {
- if (isPhotoComparison.Value == (int)CF_GeneralPurpose.IsYes)
- {
- expStudent = expStudent.And(x => x.IsPhotoComparison == true);
- }
- if (isPhotoComparison.Value == (int)CF_GeneralPurpose.IsNo)
- {
- expStudent = expStudent.And(x => x.IsPhotoComparison != true);
- }
- }
- if (inSchoolStatus.HasValue)
- {
- expStudent = expStudent.And(x => x.InSchoolStatusID == inSchoolStatus);
- }
- }
-
- var query = StudentDAL.Value.GetStudentViewQueryable(expStudent);
- if (userIDList == null || userIDList.Count() <= 0)
- {
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (gradeID.HasValue)
- {
- query = query.Where(x => x.GradeID == gradeID);
- }
- if (standardID.HasValue)
- {
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- if (isRecruitPhoto.HasValue)
- {
- if (isRecruitPhoto.Value == (int)CF_GeneralExist.Have)
- {
- query = query.Where(x => x.RecruitPictureUrl != null && x.RecruitPictureUrl != "");
- }
- if (isRecruitPhoto.Value == (int)CF_GeneralExist.No)
- {
- query = query.Where(x => x.RecruitPictureUrl == null || x.RecruitPictureUrl == "");
- }
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- }
- return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query))
- .OrderBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo)
- .ThenBy(x => x.GradeID).ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
- .ToList();
- }
- /// <summary>
- /// 查询对应的学生信息StudentView
- /// </summary>
- /// <param name="userID"></param>
- /// <returns></returns>
- public StudentView GetStudentView(Guid? userID)
- {
- try
- {
- var query = StudentDAL.Value.GetStudentViewQueryable(x => x.UserID == userID);
- return query.SingleOrDefault();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑(新增、修改,业务主键:学号或考生号唯一)
- /// </summary>
- /// <param name="studentView"></param>
- /// <param name="photoUrl"></param>
- public virtual void StudentEdit(StudentView studentView, string photoUrl)
- {
- try
- {
- //查询相关Web.config配置
- if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringMonth == null)
- {
- throw new Exception("预计毕业月(春季、上学期入学月)未配置,请检查。");
- }
- if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringDay == null)
- {
- throw new Exception("预计毕业日(春季、上学期入学日)未配置,请检查。");
- }
- if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnMonth == null)
- {
- throw new Exception("预计毕业月(秋季、下学期入学月)未配置,请检查。");
- }
- if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnDay == null)
- {
- throw new Exception("预计毕业日(秋季、下学期入学日)未配置,请检查。");
- }
- if (EMIS.Utility.Const.LOCAL_SETTING_ENTRANCESEMESTERID == null)
- {
- throw new Exception("入学学期(春季、上学期、秋季、下学期)未配置,请检查。");
- }
- var studentNoTotal = EMIS.Utility.Const.LOCAL_SETTING_LOGINIDTOTAL;
- if (studentNoTotal == null)
- {
- throw new Exception("学号总位数未配置,请检查。");
- }
- if (!string.IsNullOrEmpty(studentView.StudentNo))
- {
- if (studentView.StudentNo.Trim().Length != Convert.ToInt32(studentNoTotal))
- {
- throw new Exception("输入的学号总位数有误,学号总位数应为" + studentNoTotal + "位。");
- }
- }
- else
- {
- throw new Exception("学号不能为空,请输入学号。");
- }
- var userVerify = StudentDAL.Value.UserRepository.GetList(x => x.UserID != studentView.UserID && x.LoginID == studentView.StudentNo.Trim()).SingleOrDefault();
- if (userVerify == null)
- {
- var newStudentVerify = StudentDAL.Value.NewStudentRepository.GetList(x => x.AssignStatus == (int)CF_AssignStatus.Assigned
- && x.ExamineeNum != studentView.ExamineeNum && x.StudentNo == studentView.StudentNo.Trim()).SingleOrDefault();
- if (newStudentVerify != null)
- {
- throw new Exception("录取名单中已存在相同的学号(学号重复),请核查。");
- }
- if (!string.IsNullOrEmpty(studentView.ExamineeNum))
- {
- var examineeNumVerify = StudentDAL.Value.RecruitstudentsRepository.GetList(x => x.UserID != studentView.UserID
- && x.ExamineeNum == studentView.ExamineeNum.Trim()).SingleOrDefault();
- if (examineeNumVerify != null)
- {
- throw new Exception("已存在相同的考生号(考生号重复),请核查。");
- }
- }
- if (!string.IsNullOrEmpty(studentView.StudentCardNo))
- {
- var studentCardNoVerify = StudentDAL.Value.StudentRepository.GetList(x => x.UserID != studentView.UserID
- && x.StudentCardNo == studentView.StudentCardNo.Trim()).SingleOrDefault();
- if (studentCardNoVerify != null)
- {
- throw new Exception("已存在相同的学籍卡编号(学籍卡编号重复),请核查。");
- }
- }
- if (!string.IsNullOrEmpty(studentView.GraduateCardNo))
- {
- var graduateCardNoVerify = StudentDAL.Value.StudentRepository.GetList(x => x.UserID != studentView.UserID
- && x.GraduateCardNo == studentView.GraduateCardNo.Trim()).SingleOrDefault();
- if (graduateCardNoVerify != null)
- {
- throw new Exception("已存在相同的毕结业证书编号(毕结业证书编号重复),请核查。");
- }
- }
- if (!string.IsNullOrEmpty(studentView.ReplaceGraduateNo))
- {
- var replaceGraduateNoVerify = StudentDAL.Value.StudentRepository.GetList(x => x.UserID != studentView.UserID
- && x.ReplaceGraduateNo == studentView.ReplaceGraduateNo.Trim()).SingleOrDefault();
- if (replaceGraduateNoVerify != null)
- {
- throw new Exception("已存在相同的补证编号(补证编号重复),请核查。");
- }
- }
- var passwordParameter = StudentDAL.Value.ParameterRepository.GetSingle(x => x.ParameterTypeID == (int)ViewModel.CF_ParameterType.StudentInitPassword);
- var roleList = StudentDAL.Value.RoleRepository.GetList(x => x.TypeID == (int)SYS_RoleType.Student, (x => x.CF_StudentRole)).ToList();
- List<Sys_User> newUserInList = new List<Sys_User>();
- List<Sys_User> newUserUpList = new List<Sys_User>();
- List<CF_Student> newStudentInList = new List<CF_Student>();
- List<CF_Student> newStudentUpList = new List<CF_Student>();
- List<CF_StudentProfile> newStudentProfileInList = new List<CF_StudentProfile>();
- List<CF_StudentProfile> newStudentProfileUpList = new List<CF_StudentProfile>();
- List<CF_StudentContact> newStudentContactInList = new List<CF_StudentContact>();
- List<CF_StudentContact> newStudentContactUpList = new List<CF_StudentContact>();
- List<CF_StudentAccount> newStudentAccountInList = new List<CF_StudentAccount>();
- List<CF_StudentAccount> newStudentAccountUpList = new List<CF_StudentAccount>();
- List<CF_Recruitstudents> newRecruitstudentsInList = new List<CF_Recruitstudents>();
- List<CF_Recruitstudents> newRecruitstudentsUpList = new List<CF_Recruitstudents>();
- if (studentView.UserID != Guid.Empty)
- {
- //修改
- var student = StudentDAL.Value.StudentRepository.GetList(x => x.UserID == studentView.UserID,
- (x => x.CF_StudentProfile), (x => x.CF_StudentContact), (x => x.CF_StudentAccount),
- (x => x.CF_Recruitstudents), (x => x.Sys_User)).SingleOrDefault();
- if (student == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- else
- {
- student.Sys_User.LoginID = studentView.StudentNo.Trim();
- student.Sys_User.Name = studentView.Name.Trim();
- this.SetModifyStatus(student.Sys_User);
- newUserUpList.Add(student.Sys_User);
- student.ClassmajorID = studentView.ClassmajorID;
- student.SexID = studentView.SexID;
- student.BirthDate = studentView.BirthDate;
- student.NationID = studentView.NationID;
- student.PoliticsID = studentView.PoliticsID;
- student.CertificatesType = studentView.CertificatesType;
- student.IDNumber = studentView.IDNumber;
- student.StudentType = studentView.StudentType;
- student.Sys_User.Sys_Role = new HashSet<Sys_Role>();
- roleList = roleList.Where(x => x.CF_StudentRole.StudentType == studentView.StudentType).ToList();
- if (roleList != null && roleList.Count > 0)
- {
- roleList.ForEach(x => student.Sys_User.Sys_Role.Add(x));
- }
- else
- {
- //对应角色为空时,默认为不分配用户角色
- }
- student.InSchoolStatusID = studentView.InSchoolStatusID;
- student.StudentStatus = studentView.StudentStatus;
- student.StudentCardNo = studentView.StudentCardNo;
- if (!string.IsNullOrEmpty(photoUrl))
- {
- student.PhotoUrl = photoUrl;
- }
- if (studentView.PlanningGraduateDate.HasValue)
- {
- student.PlanningGraduateDate = studentView.PlanningGraduateDate;
- }
- if(studentView.GraduateDate.HasValue)
- {
- student.GraduateDate = studentView.GraduateDate;
- }
- student.GraduateCardNo = studentView.GraduateCardNo;
- student.ReplaceGraduateNo = studentView.ReplaceGraduateNo;
- student.DegreeStatus = studentView.DegreeStatus;
- //if (!string.IsNullOrEmpty(studentView.GraduationPictureUrl))
- //{
- // student.GraduationPictureUrl = studentView.GraduationPictureUrl;
- //}
- student.Career = studentView.Career;
- //student.IsPhotoComparison = studentView.IsPhotoComparison;
- //student.IsProofread = studentView.IsProofread;
- student.Remark = studentView.Remark;
- this.SetModifyStatus(student);
- newStudentUpList.Add(student);
- if (student.CF_StudentProfile == null)
- {
- var studentProfile = new CF_StudentProfile();
- studentProfile.UserID = student.UserID;
- studentProfile.UsedName = studentView.UsedName;
- studentProfile.LiteracyLevelID = studentView.LiteracyLevelID;
- studentProfile.CultureModelID = studentView.CultureModelID;
- studentProfile.IsDreamProject = studentView.IsDreamProject;
- studentProfile.Country = studentView.Country;
- studentProfile.Place = studentView.Place;
- studentProfile.BornPlace = studentView.BornPlace;
- studentProfile.HealthStateID = studentView.HealthStateID;
- studentProfile.BloodGroup = studentView.BloodGroup;
- studentProfile.Specialty = studentView.Specialty;
- studentProfile.Height = studentView.Height;
- studentProfile.Weight = studentView.Weight;
- studentProfile.DirectorName = studentView.DirectorName;
- this.SetNewStatus(studentProfile);
- newStudentProfileInList.Add(studentProfile);
- }
- else
- {
- student.CF_StudentProfile.UsedName = studentView.UsedName;
- student.CF_StudentProfile.LiteracyLevelID = studentView.LiteracyLevelID;
- student.CF_StudentProfile.CultureModelID = studentView.CultureModelID;
- student.CF_StudentProfile.IsDreamProject = studentView.IsDreamProject;
- student.CF_StudentProfile.Country = studentView.Country;
- student.CF_StudentProfile.Place = studentView.Place;
- student.CF_StudentProfile.BornPlace = studentView.BornPlace;
- student.CF_StudentProfile.HealthStateID = studentView.HealthStateID;
- student.CF_StudentProfile.BloodGroup = studentView.BloodGroup;
- student.CF_StudentProfile.Specialty = studentView.Specialty;
- student.CF_StudentProfile.Height = studentView.Height;
- student.CF_StudentProfile.Weight = studentView.Weight;
- student.CF_StudentProfile.DirectorName = studentView.DirectorName;
- this.SetModifyStatus(student.CF_StudentProfile);
- newStudentProfileUpList.Add(student.CF_StudentProfile);
- }
- if (student.CF_StudentContact == null)
- {
- var studentContact = new CF_StudentContact();
- studentContact.UserID = student.UserID;
- studentContact.Email = studentView.Email;
- studentContact.Telephone = studentView.Email;
- studentContact.Mobile = studentView.Email;
- studentContact.ZIPCode = studentView.ZIPCode;
- studentContact.WeChatNum = studentView.WeChatNum;
- studentContact.QQ = studentView.QQ;
- studentContact.HomeAddress = studentView.HomeAddress;
- studentContact.WorkUnit = studentView.WorkUnit;
- studentContact.Address = studentView.Address;
- studentContact.Recipient = studentView.Recipient;
- studentContact.Dormitory = studentView.Dormitory;
- this.SetNewStatus(studentContact);
- newStudentContactInList.Add(studentContact);
- }
- else
- {
- student.CF_StudentContact.Email = studentView.Email;
- student.CF_StudentContact.Telephone = studentView.Telephone;
- student.CF_StudentContact.Mobile = studentView.Mobile;
- student.CF_StudentContact.ZIPCode = studentView.ZIPCode;
- student.CF_StudentContact.WeChatNum = studentView.WeChatNum;
- student.CF_StudentContact.QQ = studentView.QQ;
- student.CF_StudentContact.HomeAddress = studentView.HomeAddress;
- student.CF_StudentContact.WorkUnit = studentView.WorkUnit;
- student.CF_StudentContact.Address = studentView.Address;
- student.CF_StudentContact.Recipient = studentView.Recipient;
- student.CF_StudentContact.Dormitory = studentView.Dormitory;
- this.SetModifyStatus(student.CF_StudentContact);
- newStudentContactUpList.Add(student.CF_StudentContact);
- }
- if (student.CF_StudentAccount == null)
- {
- var studentAccount = new CF_StudentAccount();
- studentAccount.UserID = student.UserID;
- studentAccount.BankName = studentView.BankName;
- studentAccount.CardNo = studentView.CardNo;
- this.SetNewStatus(studentAccount);
- newStudentAccountInList.Add(studentAccount);
- }
- else
- {
- student.CF_StudentAccount.BankName = studentView.BankName;
- student.CF_StudentAccount.CardNo = studentView.CardNo;
- this.SetModifyStatus(student.CF_StudentAccount);
- newStudentAccountUpList.Add(student.CF_StudentAccount);
- }
- if (student.CF_Recruitstudents == null)
- {
- var recruitstudents = new CF_Recruitstudents();
- recruitstudents.UserID = student.UserID;
- recruitstudents.ExamineeNum = studentView.ExamineeNum;
- recruitstudents.AdmissionTicketNo = studentView.AdmissionTicketNo;
- recruitstudents.ExamineeType = studentView.ExamineeType;
- recruitstudents.EnteringSchoolYearID = studentView.StartSchoolyearID;
- recruitstudents.EntranceDate = studentView.EntranceDate;
- recruitstudents.Score = studentView.Score;
- recruitstudents.EntranceWayID = studentView.EntranceWayID;
- recruitstudents.FeaturesID = studentView.FeaturesID;
- recruitstudents.TerritorialID = studentView.TerritorialID;
- recruitstudents.Area = studentView.Area;
- //if (!string.IsNullOrEmpty(studentView.RecruitPictureUrl))
- //{
- // recruitstudents.RecruitPictureUrl = studentView.RecruitPictureUrl;
- //}
- this.SetNewStatus(recruitstudents);
- newRecruitstudentsInList.Add(recruitstudents);
- }
- else
- {
- student.CF_Recruitstudents.ExamineeNum = studentView.ExamineeNum;
- student.CF_Recruitstudents.AdmissionTicketNo = studentView.AdmissionTicketNo;
- student.CF_Recruitstudents.ExamineeType = studentView.ExamineeType;
- student.CF_Recruitstudents.EnteringSchoolYearID = studentView.StartSchoolyearID;
- student.CF_Recruitstudents.EntranceDate = studentView.EntranceDate;
- student.CF_Recruitstudents.Score = studentView.Score;
- student.CF_Recruitstudents.EntranceWayID = studentView.EntranceWayID;
- student.CF_Recruitstudents.FeaturesID = studentView.FeaturesID;
- student.CF_Recruitstudents.TerritorialID = studentView.TerritorialID;
- student.CF_Recruitstudents.Area = studentView.Area;
- //if (!string.IsNullOrEmpty(studentView.RecruitPictureUrl))
- //{
- // student.CF_Recruitstudents.RecruitPictureUrl = studentView.RecruitPictureUrl;
- //}
- this.SetModifyStatus(student.CF_Recruitstudents);
- newRecruitstudentsUpList.Add(student.CF_Recruitstudents);
- }
- }
- }
- else
- {
- //新增
- var newUser = new Sys_User();
- newUser.UserID = Guid.NewGuid();
- newUser.LoginID = studentView.StudentNo.Trim();
- newUser.Name = studentView.Name.Trim();
- if (passwordParameter == null)
- {
- newUser.Password = ("A" + studentView.StudentNo.Trim()).MD5();
- }
- else
- {
- if (passwordParameter.Value != null)
- {
- newUser.Password = passwordParameter.Value;
- }
- else
- {
- newUser.Password = ("A" + studentView.StudentNo.Trim()).MD5();
- }
- }
- this.SetNewStatus(newUser, (int)SYS_STATUS.USABLE);
- newUserInList.Add(newUser);
- newUser.Sys_Role = new HashSet<Sys_Role>();
- roleList = roleList.Where(x => x.CF_StudentRole.StudentType == studentView.StudentType).ToList();
- if (roleList != null && roleList.Count > 0)
- {
- roleList.ForEach(x => newUser.Sys_Role.Add(x));
- }
- else
- {
- //对应角色为空时,默认为不分配用户角色
- }
- var newStudent = new CF_Student();
- newStudent.UserID = newUser.UserID;
- newStudent.ClassmajorID = studentView.ClassmajorID;
- newStudent.SexID = studentView.SexID;
- newStudent.BirthDate = studentView.BirthDate;
- newStudent.NationID = studentView.NationID;
- newStudent.PoliticsID = studentView.PoliticsID;
- newStudent.CertificatesType = studentView.CertificatesType;
- newStudent.IDNumber = studentView.IDNumber;
- newStudent.StudentType = studentView.StudentType;
- newStudent.InSchoolStatusID = studentView.InSchoolStatusID;
- newStudent.StudentStatus = studentView.StudentStatus;
- newStudent.StudentCardNo = studentView.StudentCardNo;
- if (!string.IsNullOrEmpty(photoUrl))
- {
- newStudent.PhotoUrl = photoUrl;
- }
- newStudent.PlanningGraduateDate = this.GetClassmajorPlanningGraduateDate(studentView.ClassmajorID);
- newStudent.GraduateDate = this.GetClassmajorGraduateDate(studentView.ClassmajorID);
- newStudent.GraduateCardNo = studentView.GraduateCardNo;
- newStudent.ReplaceGraduateNo = studentView.ReplaceGraduateNo;
- newStudent.DegreeStatus = studentView.DegreeStatus;
- //if (!string.IsNullOrEmpty(studentView.GraduationPictureUrl))
- //{
- // newStudent.GraduationPictureUrl = studentView.GraduationPictureUrl;
- //}
- newStudent.Career = studentView.Career;
- //newStudent.IsPhotoComparison = studentView.IsPhotoComparison;
- //newStudent.IsProofread = studentView.IsProofread;
- newStudent.Remark = studentView.Remark;
- this.SetNewStatus(newStudent);
- newStudentInList.Add(newStudent);
- var newStudentProfile = new CF_StudentProfile();
- newStudentProfile.UserID = newStudent.UserID;
- newStudentProfile.UsedName = studentView.UsedName;
- newStudentProfile.LiteracyLevelID = studentView.LiteracyLevelID;
- newStudentProfile.CultureModelID = studentView.CultureModelID;
- newStudentProfile.IsDreamProject = studentView.IsDreamProject;
- newStudentProfile.Country = studentView.Country;
- newStudentProfile.Place = studentView.Place;
- newStudentProfile.BornPlace = studentView.BornPlace;
- newStudentProfile.HealthStateID = studentView.HealthStateID;
- newStudentProfile.BloodGroup = studentView.BloodGroup;
- newStudentProfile.Specialty = studentView.Specialty;
- newStudentProfile.Height = studentView.Height;
- newStudentProfile.Weight = studentView.Weight;
- newStudentProfile.DirectorName = studentView.DirectorName;
- this.SetNewStatus(newStudentProfile);
- newStudentProfileInList.Add(newStudentProfile);
- var newStudentContact = new CF_StudentContact();
- newStudentContact.UserID = newStudent.UserID;
- newStudentContact.Email = studentView.Email;
- newStudentContact.Telephone = studentView.Telephone;
- newStudentContact.Mobile = studentView.Mobile;
- newStudentContact.ZIPCode = studentView.ZIPCode;
- newStudentContact.WeChatNum = studentView.WeChatNum;
- newStudentContact.QQ = studentView.QQ;
- newStudentContact.HomeAddress = studentView.HomeAddress;
- newStudentContact.WorkUnit = studentView.WorkUnit;
- newStudentContact.Address = studentView.Address;
- newStudentContact.Recipient = studentView.Recipient;
- newStudentContact.Dormitory = studentView.Dormitory;
- this.SetNewStatus(newStudentContact);
- newStudentContactInList.Add(newStudentContact);
- var newStudentAccount = new CF_StudentAccount();
- newStudentAccount.UserID = newStudent.UserID;
- newStudentAccount.CardNo = studentView.CardNo;
- newStudentAccount.BankName = studentView.BankName;
- this.SetNewStatus(newStudentAccount);
- newStudentAccountInList.Add(newStudentAccount);
- var newRecruitstudents = new CF_Recruitstudents();
- newRecruitstudents.UserID = newStudent.UserID;
- newRecruitstudents.ExamineeNum = studentView.ExamineeNum;
- newRecruitstudents.AdmissionTicketNo = studentView.AdmissionTicketNo;
- newRecruitstudents.ExamineeType = studentView.ExamineeType;
- newRecruitstudents.EnteringSchoolYearID = studentView.StartSchoolyearID;
- newRecruitstudents.EntranceDate = studentView.EntranceDate;
- newRecruitstudents.Score = studentView.Score;
- newRecruitstudents.EntranceWayID = studentView.EntranceWayID;
- newRecruitstudents.FeaturesID = studentView.FeaturesID;
- newRecruitstudents.TerritorialID = studentView.TerritorialID;
- newRecruitstudents.Area = studentView.Area;
- //if (!string.IsNullOrEmpty(studentView.RecruitPictureUrl))
- //{
- // newRecruitstudents.RecruitPictureUrl = studentView.RecruitPictureUrl;
- //}
- this.SetNewStatus(newRecruitstudents);
- newRecruitstudentsInList.Add(newRecruitstudents);
- }
- using (TransactionScope ts = new TransactionScope())
- {
- UnitOfWork.BulkInsert<Sys_User>(newUserInList);
- UnitOfWork.BulkInsert(newUserInList, (x => x.Sys_Role));
- UnitOfWork.BulkInsert<CF_Student>(newStudentInList);
- UnitOfWork.BulkInsert<CF_StudentProfile>(newStudentProfileInList);
- UnitOfWork.BulkInsert<CF_StudentContact>(newStudentContactInList);
- UnitOfWork.BulkInsert<CF_StudentAccount>(newStudentAccountInList);
- UnitOfWork.BulkInsert<CF_Recruitstudents>(newRecruitstudentsInList);
- if (newUserUpList != null && newUserUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newUserUpList);
- UnitOfWork.Delete(newUserUpList, (x => x.Sys_Role));
- UnitOfWork.BulkInsert(newUserUpList, (x => x.Sys_Role));
- }
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentUpList);
- }
- if (newStudentProfileUpList != null && newStudentProfileUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentProfileUpList);
- }
- if (newStudentContactUpList != null && newStudentContactUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentContactUpList);
- }
- if (newStudentAccountUpList != null && newStudentAccountUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentAccountUpList);
- }
- if (newRecruitstudentsUpList != null && newRecruitstudentsUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newRecruitstudentsUpList);
- }
- ts.Complete();
- }
- }
- else
- {
- var studentVerify = StudentDAL.Value.StudentRepository.GetList(x => x.UserID != studentView.UserID,
- (x => x.Sys_User)).Where(x => x.Sys_User.LoginID == studentView.StudentNo.Trim()).SingleOrDefault();
- if (studentVerify != null)
- {
- throw new Exception("已存在相同的学号(学号重复),请核查。");
- }
- else
- {
- var staffVerify = StudentDAL.Value.StaffRepository.GetList(x => x.UserID != studentView.UserID,
- (x => x.Sys_User)).Where(x => x.Sys_User.LoginID == studentView.StudentNo.Trim()).SingleOrDefault();
- if (staffVerify != null)
- {
- throw new Exception("教师信息中已存在相同的用户(用户名重复),请核查。");
- }
- else
- {
- throw new Exception("用户信息中已存在相同的用户(用户名重复),请核查。");
- }
- }
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// 注:删除成功后,需对相应的录取名单提交状态进行更新(以学号和证件号码进行查询)
- /// </summary>
- /// <param name="userIDs"></param>
- /// <returns></returns>
- public bool StudentDelete(List<Guid?> userIDs)
- {
- try
- {
- var studentList = StudentDAL.Value.StudentRepository.GetList(x => userIDs.Contains(x.UserID), (x => x.Sys_User)).ToList();
- var iDNumberList = studentList.Where(x => !string.IsNullOrEmpty(x.IDNumber)).Select(x => x.IDNumber).ToList();
- var newStudentList = StudentDAL.Value.NewStudentRepository.GetList(x => iDNumberList.Contains(x.IDNumber)).ToList();
- List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
- foreach (var student in studentList)
- {
- var newStudent = newStudentList.Where(x => x.IDNumber == student.IDNumber
- && x.StudentNo == student.Sys_User.LoginID).SingleOrDefault();
- if (newStudent != null)
- {
- newStudent.RecordStatus = (int)CF_NewStudentEnterStatus.NotSubmitted;
- SetModifyStatus(newStudent);
- newStudentUpList.Add(newStudent);
- }
- }
- UnitOfWork.Remove<CF_StudentExperience>(x => userIDs.Contains((Guid)x.UserID));
- UnitOfWork.Remove<CF_StudentFamily>(x => userIDs.Contains((Guid)x.UserID));
- UnitOfWork.Remove<CF_StudentContact>(x => userIDs.Contains(x.UserID));
- UnitOfWork.Remove<CF_StudentAccount>(x => userIDs.Contains(x.UserID));
- UnitOfWork.Remove<CF_Recruitstudents>(x => userIDs.Contains(x.UserID));
- UnitOfWork.Remove<CF_StudentProfile>(x => userIDs.Contains(x.UserID));
- UnitOfWork.Remove<CF_Student>(x => userIDs.Contains(x.UserID));
- var userList = StudentDAL.Value.UserRepository.GetList(x => userIDs.Contains(x.UserID), (x => x.Sys_Role)).ToList();
- userList.ForEach(x => x.Sys_Role = new HashSet<Sys_Role>());
- UnitOfWork.Remove<Sys_User>(x => userIDs.Contains(x.UserID));
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 查询对应的学籍异动信息StudentChangeView
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="userID"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="changeTypeID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<StudentChangeView> GetStudentChangeViewGrid(ConfiguretView configuretView, Guid? userID, Guid? schoolyearID, int? changeTypeID, int pageIndex, int pageSize)
- {
- var approveStatusList = this.GetStatusViewList();
- var endStatusID = this.GetCorrectEndStatus();
- Expression<Func<CF_DifferentDynamic, bool>> expStudentChange = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expStudentChange = expStudentChange.And(x => x.UserID == userID);
- expStudentChange = expStudentChange.And(x => x.ApprovalStatus == endStatusID);
- if (schoolyearID.HasValue)
- {
- expStudentChange = expStudentChange.And(x => x.SchoolyearID == schoolyearID);
- }
- if (changeTypeID.HasValue)
- {
- expStudentChange = expStudentChange.And(x => x.ChangeTypeID == changeTypeID);
- }
- var query = StudentChangeDAL.Value.GetStudentChangeViewQueryable(expStudentChange);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- var result = query.OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ThenBy(x => x.SchoolyearValue).ToGridResultSet<StudentChangeView>(pageIndex, pageSize);
- result.rows.ForEach(x => x.ApprovalStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
- return result;
- }
- /// <summary>
- /// 查询对应的学籍异动信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="userID"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="changeTypeID"></param>
- /// <returns></returns>
- public IList<StudentChangeView> GetStudentChangeViewList(ConfiguretView configuretView, Guid? userID, Guid? schoolyearID, int? changeTypeID)
- {
- var approveStatusList = this.GetStatusViewList();
- var endStatusID = this.GetCorrectEndStatus();
- Expression<Func<CF_DifferentDynamic, bool>> expStudentChange = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expStudentChange = expStudentChange.And(x => x.UserID == userID);
- expStudentChange = expStudentChange.And(x => x.ApprovalStatus == endStatusID);
- if (schoolyearID.HasValue)
- {
- expStudentChange = expStudentChange.And(x => x.SchoolyearID == schoolyearID);
- }
- if (changeTypeID.HasValue)
- {
- expStudentChange = expStudentChange.And(x => x.ChangeTypeID == changeTypeID);
- }
- var query = StudentChangeDAL.Value.GetStudentChangeViewQueryable(expStudentChange);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- var result = query.OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ThenBy(x => x.SchoolyearValue).ToList();
- result.ForEach(x => x.ApprovalStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
- return result;
- }
- /// <summary>
- /// 查询对应的学籍注册信息StudentReportView
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="userID"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="reportStatus"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<StudentReportView> GetStudentReportViewGrid(ConfiguretView configuretView, Guid? userID, Guid? schoolyearID, int? reportStatus, int pageIndex, int pageSize)
- {
- Expression<Func<EM_StudentReport, bool>> expStudentReport = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expStudentReport = expStudentReport.And(x => x.UserID == userID);
- if (schoolyearID.HasValue)
- {
- expStudentReport = expStudentReport.And(x => x.SchoolyearID == schoolyearID);
- }
- if (reportStatus.HasValue)
- {
- expStudentReport = expStudentReport.And(x => x.ReportStatus == reportStatus);
- }
- var query = StudentReportDAL.Value.GetStudentReportViewQueryable(expStudentReport);
-
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ThenBy(x => x.SchoolyearValue).ToGridResultSet<StudentReportView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的学籍注册信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="userID"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="reportStatus"></param>
- /// <returns></returns>
- public IList<StudentReportView> GetStudentReportViewList(ConfiguretView configuretView, Guid? userID, Guid? schoolyearID, int? reportStatus)
- {
- Expression<Func<EM_StudentReport, bool>> expStudentReport = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expStudentReport = expStudentReport.And(x => x.UserID == userID);
- if (schoolyearID.HasValue)
- {
- expStudentReport = expStudentReport.And(x => x.SchoolyearID == schoolyearID);
- }
- if (reportStatus.HasValue)
- {
- expStudentReport = expStudentReport.And(x => x.ReportStatus == reportStatus);
- }
- var query = StudentReportDAL.Value.GetStudentReportViewQueryable(expStudentReport);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ThenBy(x => x.SchoolyearValue).ToList();
- }
- /// <summary>
- /// 删除照片(单个删除)
- /// </summary>
- /// <param name="userID"></param>
- public void DeletePhoto(Guid? userID)
- {
- try
- {
- var student = StudentDAL.Value.StudentRepository.GetList(x => x.UserID == userID).SingleOrDefault();
- if (student != null)
- {
- if (!string.IsNullOrEmpty(student.PhotoUrl))
- {
- FileUploadHelper.DeleteFile(student.PhotoUrl);
- student.PhotoUrl = null;
- this.UnitOfWork.Commit();
- }
- else
- {
- throw new Exception("对应的照片不存在。");
- }
- }
- else
- {
- throw new Exception("对应的信息未保存,数据有误。");
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除照片(批量删除)
- /// </summary>
- /// <param name="userIDs"></param>
- /// <returns></returns>
- public bool PicDelete(List<Guid?> userIDs)
- {
- try
- {
- List<string> photoUrlList = new List<string>();
- List<CF_Student> studentUpList = new List<CF_Student>();
- var studentList = StudentDAL.Value.StudentRepository.GetList(x => userIDs.Contains(x.UserID)).ToList();
- foreach (var student in studentList)
- {
- if (student != null)
- {
- if (!string.IsNullOrEmpty(student.PhotoUrl))
- {
- photoUrlList.Add(student.PhotoUrl);
- student.PhotoUrl = null;
- studentUpList.Add(student);
- }
- }
- }
- using (TransactionScope ts = new TransactionScope())
- {
- foreach (var photoUrl in photoUrlList)
- {
- FileUploadHelper.DeleteFile(photoUrl);
- }
- if (studentUpList != null && studentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(studentUpList);
- }
- ts.Complete();
- }
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 照片比对通过
- /// </summary>
- /// <param name="userIDList"></param>
- /// <returns></returns>
- public string StudentPicComparisonPass(List<Guid?> userIDList)
- {
- try
- {
- var studentList = StudentDAL.Value.StudentRepository.GetList(x => userIDList.Contains(x.UserID), (x => x.CF_Recruitstudents)).ToList();
- int success = 0;
- int fail = 0;
- string tipMessage = null;
- var studentUpList = new List<CF_Student>();
- foreach (var userID in userIDList)
- {
- var student = studentList.Where(x => x.UserID == userID).SingleOrDefault();
- if (student == null)
- {
- throw new Exception("数据有误,请检查。");
- }
- else
- {
- if (student.CF_Recruitstudents == null)
- {
- fail++;
- }
- else if (string.IsNullOrWhiteSpace(student.CF_Recruitstudents.RecruitPictureUrl) || string.IsNullOrWhiteSpace(student.PhotoUrl) || string.IsNullOrWhiteSpace(student.GraduationPictureUrl))
- {
- fail++;
- }
- else
- {
- student.IsPhotoComparison = true;
- SetModifyStatus(student);
- studentUpList.Add(student);
- success++;
- }
- }
- }
- if (studentUpList != null && studentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(studentUpList);
- }
- if (success > 0 && fail <= 0)
- {
- tipMessage = success + "条";
- }
- else
- {
- tipMessage = success + "条," + fail + "条失败,原因:录取照片、学籍照片或学历照片信息不全,请检查";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 照片比对驳回
- /// </summary>
- /// <param name="userIDList"></param>
- /// <returns></returns>
- public string StudentPicComparisonUndo(List<Guid?> userIDList)
- {
- try
- {
- var studentList = StudentDAL.Value.StudentRepository.GetList(x => userIDList.Contains(x.UserID), (x => x.CF_Recruitstudents)).ToList();
- int success = 0;
- int fail = 0;
- string tipMessage = null;
- var studentUpList = new List<CF_Student>();
- foreach (var userID in userIDList)
- {
- var student = studentList.Where(x => x.UserID == userID).SingleOrDefault();
- if (student == null)
- {
- fail++;
- }
- else
- {
- student.IsPhotoComparison = false;
- SetModifyStatus(student);
- studentUpList.Add(student);
- success++;
- }
- }
- if (studentUpList != null && studentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(studentUpList);
- }
- if (success > 0 && fail <= 0)
- {
- tipMessage = success + "条";
- }
- else
- {
- tipMessage = success + "条," + fail + "条失败,原因:数据有误,请检查";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// DBF文件创建
- /// </summary>
- /// <param name="dt"></param>
- /// <param name="colnameList"></param>
- /// <param name="savePath"></param>
- /// <returns></returns>
- public string CreateDBFFile(DataTable dt, List<string> colnameList, string savePath = null)
- {
- if (dt == null || dt.Rows.Count <= 0) return null;
- if (colnameList == null || colnameList.Count <= 0) return null;
- var tagetPhysicalPath = FileUploadHelper.GetFileUploadTagetPhysicalPath(savePath);
- var newFileName = DateTime.Today.ToString("MMdd") + "DBF.dbf";
- var physicalFileName = tagetPhysicalPath + newFileName;
- string connString = "Provider=Microsoft.Jet.OLEDB.4.0; " + "Data Source=" + tagetPhysicalPath + "; " + "Extended Properties=dBASE IV;";
- OleDbConnection conn = new OleDbConnection(connString);
- conn.Open();
- OleDbCommand oleDbComm;
- try
- {
- if (File.Exists(physicalFileName))
- {
- File.Delete(physicalFileName);
- }
- StringBuilder createTable = new StringBuilder();
- createTable.Append("CREATE TABLE " + newFileName + " (");
- for (int i = 0; i < colnameList.Count; i++)
- {
- createTable.Append(colnameList[i]);
- if (colnameList[i].Equals("KSH", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(18)");
- }
- else if (colnameList[i].Equals("XM", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(40)");
- }
- else if (colnameList[i].Equals("XB", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(2)");
- }
- else if (colnameList[i].Equals("CSRQ", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(8)");
- }
- else if (colnameList[i].Equals("SFZH", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(18)");
- }
- else if (colnameList[i].Equals("YXDM", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(5)");
- }
- else if (colnameList[i].Equals("YXMC", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(60)");
- }
- else if (colnameList[i].Equals("ZYDM", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(8)");
- }
- else if (colnameList[i].Equals("ZYMC", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(50)");
- }
- else if (colnameList[i].Equals("XZ", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(3)");
- }
- else if (colnameList[i].Equals("XXXS", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(10)");
- }
- else if (colnameList[i].Equals("CC", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(12)");
- }
- else if (colnameList[i].Equals("RXRQ", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(8)");
- }
- else if (colnameList[i].Equals("BYRQ", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(8)");
- }
- else if (colnameList[i].Equals("BJYJL", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(4)");
- }
- else if (colnameList[i].Equals("ZSBH", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(18)");
- }
- else if (colnameList[i].Equals("XZM", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(40)");
- }
- else if (colnameList[i].Equals("SYSSDM", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(2)");
- }
- else if (colnameList[i].Equals("XH", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(15)");
- }
- else if (colnameList[i].Equals("ZZMM", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(16)");
- }
- else if (colnameList[i].Equals("MZ", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(24)");
- }
- else if (colnameList[i].Equals("FY", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(24)");
- }
- else if (colnameList[i].Equals("XSH", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(24)");
- }
- else if (colnameList[i].Equals("BH", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(24)");
- }
- else if (colnameList[i].Equals("BM", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(100)");
- }
- else if (colnameList[i].Equals("YJBYRQ", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(8)");
- }
- else if (colnameList[i].Equals("BZ", StringComparison.OrdinalIgnoreCase))
- {
- createTable.Append(" char(50)");
- }
- else
- {
- createTable.Append(" char(50)");
- }
- if (i != colnameList.Count - 1)
- {
- createTable.Append(", ");
- }
- else
- {
- createTable.Append(")");
- }
- }
- oleDbComm = new OleDbCommand(createTable.ToString(), conn);
- oleDbComm.ExecuteNonQuery();
- StringBuilder createInsert = new StringBuilder();
- foreach (DataRow dr in dt.Rows)
- {
- createInsert.Clear();
- createInsert.Append(" INSERT INTO " + newFileName + " (");
- for (int i = 0; i < colnameList.Count; i++)
- {
- createInsert.Append(colnameList[i]);
- if (i != colnameList.Count - 1)
- {
- createInsert.Append(", ");
- }
- }
- createInsert.Append(") VALUES (");
- for (int i = 0; i < dt.Columns.Count; i++)
- {
- createInsert.Append("'" + dr[i].ToString() + "'");
- if (i != dt.Columns.Count - 1)
- {
- createInsert.Append(", ");
- }
- else
- {
- createInsert.Append(")");
- }
- }
- oleDbComm = new OleDbCommand(createInsert.ToString(), conn);
- oleDbComm.ExecuteNonQuery();
- }
- return physicalFileName;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- finally
- {
- conn.Close();
- }
- }
- /// <summary>
- /// 操行录入
- /// </summary>
- /// <param name="userIDs"></param>
- /// <param name="studentConductView"></param>
- /// <returns></returns>
- public string StudentConductInput(List<Guid?> userIDs, StudentConductView studentConductView)
- {
- try
- {
- var studentConductList = StudentDAL.Value.StudentConductRepository.GetList(x => userIDs.Contains(x.UserID)).ToList();
- int success = 0;
- string tipMessage = null;
- List<EM_StudentConduct> studentConductInList = new List<EM_StudentConduct>();
- List<EM_StudentConduct> studentConductUpList = new List<EM_StudentConduct>();
- foreach (var userID in userIDs)
- {
- var studentConduct = studentConductList.Where(x => x.UserID == userID && x.SchoolyearNumID == studentConductView.SchoolyearNumID).SingleOrDefault();
- if (studentConduct != null)
- {
- studentConduct.Comment = studentConductView.Comment;
- this.SetModifyStatus(studentConduct);
- studentConductUpList.Add(studentConduct);
- success++;
- }
- else
- {
- var newStudentConduct = new EM_StudentConduct();
- newStudentConduct.StudentConductID = Guid.NewGuid();
- newStudentConduct.UserID = userID;
- newStudentConduct.SchoolyearNumID = studentConductView.SchoolyearNumID;
- newStudentConduct.Comment = studentConductView.Comment;
- newStudentConduct.Remark = null;
- this.SetNewStatus(newStudentConduct);
- studentConductInList.Add(newStudentConduct);
- success++;
- }
- }
- UnitOfWork.BulkInsert<EM_StudentConduct>(studentConductInList);
- if (studentConductUpList != null && studentConductUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(studentConductUpList);
- }
- if (success > 0)
- {
- tipMessage = success + "条";
- }
- else
- {
- tipMessage = success + "条";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 毕业证书编号Excel导入
- /// </summary>
- /// <param name="cellheader"></param>
- /// <param name="inCount"></param>
- /// <param name="upCount"></param>
- /// <param name="errdataList"></param>
- /// <param name="errCount"></param>
- /// <param name="sourcePhysicalPath"></param>
- public void GraduateNoImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount, out List<StudentView> errdataList, out int? errCount, string sourcePhysicalPath)
- {
- try
- {
- StringBuilder errorMsg = new StringBuilder();
- List<StudentView> errList = new List<StudentView>();
- cellheader.Remove("ErrorMessage");
- List<StudentView> enlist = NpoiExcelHelper.ExcelToEntityList<StudentView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
- cellheader.Add("ErrorMessage", "未导入原因");
- //对List集合进行有效性校验
- if (enlist.Count() <= 0)
- {
- throw new Exception("Excel文件数据为空,请检查。");
- }
- Regex reg = null; //正则表达式
- //DateTime result; //用于返回判断日期字段格式
- inCount = 0; //导入个数
- upCount = 0; //更新个数
- errCount = 0; //失败个数
- string errorMsgStr = ""; //错误信息
- List<CF_Student> newStudentInList = new List<CF_Student>();
- List<CF_Student> newStudentUpList = new List<CF_Student>();
- //移除StuUpList
- List<CF_Student> removeStuUpList = new List<CF_Student>();
- //将循环中相关数据库查询统一查询出来进行匹配(尽量避免在循环中进行数据库查询)
- Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- //身份证号List
- var iDNumberList = enlist.Where(x => !string.IsNullOrEmpty(x.IDNumber)).Select(x => x.IDNumber).ToList();
- //毕业证书编号List
- var graduateCardNoList = enlist.Where(x => !string.IsNullOrEmpty(x.GraduateCardNo)).Select(x => x.GraduateCardNo).ToList();
- expStudent = expStudent.And(x => iDNumberList.Contains(x.IDNumber) || graduateCardNoList.Contains(x.GraduateCardNo));
- //对比后的newStudentList
- var newStudentList = StudentDAL.Value.StudentRepository.GetList(expStudent).ToList();
- //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等)
- for (int i = 0; i < enlist.Count; i++)
- {
- StudentView en = enlist[i];
- CF_Student newStudent = new CF_Student();
- //身份证号
- if (string.IsNullOrEmpty(en.IDNumber))
- {
- errCount++;
- errorMsgStr = "身份证号不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var studentIDNumberList = newStudentList.Where(x => x.IDNumber == en.IDNumber.Trim()).ToList();
- if (studentIDNumberList != null && studentIDNumberList.Count() > 1)
- {
- errCount++;
- errorMsgStr = "对应的身份证号存在多个学生信息,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var student = studentIDNumberList.Where(x => x.IDNumber == en.IDNumber.Trim()).SingleOrDefault();
- if (student == null)
- {
- errCount++;
- errorMsgStr = "对应的身份证号不存在相应的学生信息,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //学生信息
- newStudent.UserID = student.UserID;
- newStudent.IDNumber = en.IDNumber.Trim();
- }
- }
- }
- //毕业证书编号
- if (string.IsNullOrEmpty(en.GraduateCardNo))
- {
- errCount++;
- errorMsgStr = "毕业证书编号不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
- if (!reg.IsMatch(en.GraduateCardNo))
- {
- errCount++;
- errorMsgStr = "毕业证书编号格式不正确,请检查(数字或英文字母)";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var graduateNoStudentList = newStudentList.Where(x => x.UserID != newStudent.UserID && x.GraduateCardNo == en.GraduateCardNo.Trim()).ToList();
- if (graduateNoStudentList != null && graduateNoStudentList.Count() > 1)
- {
- errCount++;
- errorMsgStr = "对应的毕业证书编号存在多个学生信息中(重复),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var graduateNoStudent = graduateNoStudentList.Where(x => x.GraduateCardNo == en.GraduateCardNo.Trim()).SingleOrDefault();
- if (graduateNoStudent == null)
- {
- newStudent.GraduateCardNo = en.GraduateCardNo.Trim();
- }
- else
- {
- errCount++;
- errorMsgStr = "对应的毕业证书编号已存在学生信息中(重复),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- }
- }
- ////Excel表重复性验证(注:当数据表中没有此记录,但是Excel中有重复数据时的去掉)
- //for (int j = i + 1; j < enlist.Count; j++)
- //{
- // StudentView enA = enlist[j];
- // //根据Excel表中的业务主键进行去重(学号、毕业证书编号或学生信息ID唯一)
- // if (en.StudentNo == enA.StudentNo || en.GraduateCardNo == enA.GraduateCardNo || en.UserID == enA.UserID)
- // {
- // //用于标识Excel表中的重复记录(由于是批量进行插入数据表)
- // }
- //}
- //数据表重复性验证(学号、毕业证书编号或学生信息ID唯一)
- var studentVerify = newStudentList.Where(x => x.UserID == newStudent.UserID).SingleOrDefault();
- if (studentVerify == null)
- {
- //由于前面已做相应判断,此处代码暂时无效
- //新增
- if (!newStudentInList.Any(x => x.UserID == newStudent.UserID))
- {
- inCount++;
- }
- else
- {
- //Excel表重复性验证
- //(注:当数据表中没有此记录,但是Excel中有重复数据,可在此处进行抛出到失败数据文件中,目前暂不考虑)
- inCount++;
- }
- }
- else
- {
- //注:毕业证书编号唯一
- //更新(Excel中有重复时,以数据重复抛出到失败数据文件中进行处理,不进行更新)
- if (!removeStuUpList.Any(x => x.GraduateCardNo == en.GraduateCardNo.Trim()))
- {
- if (!newStudentUpList.Any(x => x.GraduateCardNo == en.GraduateCardNo.Trim()))
- {
- studentVerify.GraduateCardNo = newStudent.GraduateCardNo;
- studentVerify.InSchoolStatusID = (int)CF_InschoolStatus.Graduation;
- studentVerify.StudentStatus = (int)CF_StudentStatus.Graduation;
- SetModifyStatus(studentVerify);
- newStudentUpList.Add(studentVerify);
- upCount++;
- }
- else
- {
- var stuUpList = newStudentUpList.Where(x => x.GraduateCardNo == en.GraduateCardNo.Trim()).ToList();
- foreach (var stuUp in stuUpList)
- {
- errCount++;
- errorMsgStr = "毕业证书编号重复,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(new StudentView()
- {
- IDNumber = en.IDNumber,
- GraduateCardNo = en.GraduateCardNo,
- ErrorMessage = en.ErrorMessage
- });
- errorMsg.AppendLine(errorMsgStr);
- newStudentUpList.Remove(stuUp);
- removeStuUpList.Add(stuUp);
- upCount--;
- }
- errCount++;
- errorMsgStr = "毕业证书编号重复,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- else
- {
- errCount++;
- errorMsgStr = "毕业证书编号重复,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- }
- //移除Up
- if (removeStuUpList != null && removeStuUpList.Count() > 0)
- {
- foreach (var removeStuUp in removeStuUpList)
- {
- newStudentUpList.Remove(removeStuUp);
- }
- }
- //批量统一提交更新
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate<CF_Student>(newStudentUpList);
- }
- errdataList = errList.Distinct().ToList();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 导入学籍照片
- /// </summary>
- /// <param name="photoPaths"></param>
- /// <param name="importPicType"></param>
- /// <param name="inCount"></param>
- /// <param name="errCount"></param>
- /// <param name="errDataTable"></param>
- public void StudentPicImport(IList<string> photoPaths, string importPicType, out int? inCount, out int? errCount, out DataTable errDataTable)
- {
- try
- {
- var mapList = photoPaths.Select(s => new
- {
- PhotoInfo = Path.GetFileName(s).Trim(),
- PhotoName = Path.GetFileNameWithoutExtension(s).Trim(),
- PhotoPath = s,
- }).ToArray();
- var photoNameList = mapList.Select(s => s.PhotoName).Distinct().ToList();
- inCount = 0;
- errCount = 0;
- errDataTable = new DataTable();
- List<CF_Student> studentUpList = new List<CF_Student>();
- if (importPicType.Equals("StudentNo"))
- {
- errDataTable.Columns.Add("PhotoInfo", typeof(string));
- errDataTable.Columns.Add("StudentNo", typeof(string));
- errDataTable.Columns.Add("ErrorMessage", typeof(string));
- var userList = StudentDAL.Value.UserRepository.GetList(x => photoNameList.Contains(x.LoginID), (x => x.CF_Student)).ToList();
- foreach (var map in mapList)
- {
- var user = userList.Where(x => x.LoginID == map.PhotoName).SingleOrDefault();
- if (user == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["StudentNo"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的学号(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- if (user.CF_Student == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["StudentNo"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的学号(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- user.CF_Student.PhotoUrl = map.PhotoPath;
- studentUpList.Add(user.CF_Student);
- inCount++;
- }
- }
- }
- }
- else if (importPicType.Equals("ExamineeNum"))
- {
- var newPhotoNameList = new List<string>();
- foreach (var photoName in photoNameList)
- {
- var photoNameStart = photoName.Substring(0, 1);
- if (photoNameStart.Equals("F") || photoNameStart.Equals("Z"))
- {
- newPhotoNameList.Add(photoName.Substring(1));
- }
- }
- errDataTable.Columns.Add("PhotoInfo", typeof(string));
- errDataTable.Columns.Add("ExamineeNum", typeof(string));
- errDataTable.Columns.Add("ErrorMessage", typeof(string));
- var recruitStudentList = StudentDAL.Value.RecruitstudentsRepository.GetList(x => photoNameList.Contains(x.ExamineeNum) || newPhotoNameList.Contains(x.ExamineeNum), (x => x.CF_Student)).ToList();
- foreach (var map in mapList)
- {
- var photoNameStart = map.PhotoName.Substring(0, 1);
- if (photoNameStart.Equals("F") || photoNameStart.Equals("Z"))
- {
- var recruitStudent = recruitStudentList.Where(x => x.ExamineeNum == map.PhotoName || x.ExamineeNum == map.PhotoName.Substring(1)).SingleOrDefault();
- if (recruitStudent == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["ExamineeNum"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- if (recruitStudent.CF_Student == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["ExamineeNum"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- recruitStudent.CF_Student.PhotoUrl = map.PhotoPath;
- studentUpList.Add(recruitStudent.CF_Student);
- inCount++;
- }
- }
- }
- else
- {
- var recruitStudent = recruitStudentList.Where(x => x.ExamineeNum == map.PhotoName).SingleOrDefault();
- if (recruitStudent == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["ExamineeNum"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- if (recruitStudent.CF_Student == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["ExamineeNum"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- recruitStudent.CF_Student.PhotoUrl = map.PhotoPath;
- studentUpList.Add(recruitStudent.CF_Student);
- inCount++;
- }
- }
- }
- }
- }
- else if (importPicType.Equals("IDNumber"))
- {
- errDataTable.Columns.Add("PhotoInfo", typeof(string));
- errDataTable.Columns.Add("IDNumber", typeof(string));
- errDataTable.Columns.Add("ErrorMessage", typeof(string));
- var studentList = StudentDAL.Value.StudentRepository.GetList(x => photoNameList.Contains(x.IDNumber)).ToList();
- foreach (var map in mapList)
- {
- var newStudentList = studentList.Where(x => x.IDNumber == map.PhotoName).ToList();
- if (newStudentList != null && newStudentList.Count() > 1)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["IDNumber"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "存在多个对应的证件号码(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- if (newStudentList != null && newStudentList.Count() == 1)
- {
- var student = newStudentList.Where(x => x.IDNumber == map.PhotoName).SingleOrDefault();
- if (student == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["IDNumber"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的证件号码(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- student.PhotoUrl = map.PhotoPath;
- studentUpList.Add(student);
- inCount++;
- }
- }
- else
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["IDNumber"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的证件号码(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- }
- }
- }
- if (studentUpList != null && studentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate<CF_Student>(studentUpList);
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 导入学历照片
- /// </summary>
- /// <param name="photoPaths"></param>
- /// <param name="importGraPicType"></param>
- public void StudentGraPicImport(IList<string> photoPaths, string importGraPicType, out int? inCount, out int? errCount, out DataTable errDataTable)
- {
- try
- {
- var mapList = photoPaths.Select(s => new
- {
- PhotoInfo = Path.GetFileName(s).Trim(),
- PhotoName = Path.GetFileNameWithoutExtension(s).Trim(),
- PhotoPath = s,
- }).ToArray();
- var photoNameList = mapList.Select(s => s.PhotoName).Distinct().ToList();
- inCount = 0;
- errCount = 0;
- errDataTable = new DataTable();
- List<CF_Student> studentUpList = new List<CF_Student>();
- if (importGraPicType.Equals("StudentNo"))
- {
- errDataTable.Columns.Add("PhotoInfo", typeof(string));
- errDataTable.Columns.Add("StudentNo", typeof(string));
- errDataTable.Columns.Add("ErrorMessage", typeof(string));
- var userList = StudentDAL.Value.UserRepository.GetList(x => photoNameList.Contains(x.LoginID), (x => x.CF_Student)).ToList();
- foreach (var map in mapList)
- {
- var user = userList.Where(x => x.LoginID == map.PhotoName).SingleOrDefault();
- if (user == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["StudentNo"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的学号(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- if (user.CF_Student == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["StudentNo"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的学号(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- user.CF_Student.GraduationPictureUrl = map.PhotoPath;
- studentUpList.Add(user.CF_Student);
- inCount++;
- }
- }
- }
- }
- else if (importGraPicType.Equals("ExamineeNum"))
- {
- var newPhotoNameList = new List<string>();
- foreach (var photoName in photoNameList)
- {
- var photoNameStart = photoName.Substring(0, 1);
- if (photoNameStart.Equals("F") || photoNameStart.Equals("Z"))
- {
- newPhotoNameList.Add(photoName.Substring(1));
- }
- }
- errDataTable.Columns.Add("PhotoInfo", typeof(string));
- errDataTable.Columns.Add("ExamineeNum", typeof(string));
- errDataTable.Columns.Add("ErrorMessage", typeof(string));
- var recruitStudentList = StudentDAL.Value.RecruitstudentsRepository.GetList(x => photoNameList.Contains(x.ExamineeNum) || newPhotoNameList.Contains(x.ExamineeNum), (x => x.CF_Student)).ToList();
- foreach (var map in mapList)
- {
- var photoNameStart = map.PhotoName.Substring(0, 1);
- if (photoNameStart.Equals("F") || photoNameStart.Equals("Z"))
- {
- var recruitStudent = recruitStudentList.Where(x => x.ExamineeNum == map.PhotoName || x.ExamineeNum == map.PhotoName.Substring(1)).SingleOrDefault();
- if (recruitStudent == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["ExamineeNum"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- if (recruitStudent.CF_Student == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["ExamineeNum"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- recruitStudent.CF_Student.GraduationPictureUrl = map.PhotoPath;
- studentUpList.Add(recruitStudent.CF_Student);
- inCount++;
- }
- }
- }
- else
- {
- var recruitStudent = recruitStudentList.Where(x => x.ExamineeNum == map.PhotoName).SingleOrDefault();
- if (recruitStudent == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["ExamineeNum"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- if (recruitStudent.CF_Student == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["ExamineeNum"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- recruitStudent.CF_Student.GraduationPictureUrl = map.PhotoPath;
- studentUpList.Add(recruitStudent.CF_Student);
- inCount++;
- }
- }
- }
- }
- }
- else if (importGraPicType.Equals("IDNumber"))
- {
- errDataTable.Columns.Add("PhotoInfo", typeof(string));
- errDataTable.Columns.Add("IDNumber", typeof(string));
- errDataTable.Columns.Add("ErrorMessage", typeof(string));
- var studentList = StudentDAL.Value.StudentRepository.GetList(x => photoNameList.Contains(x.IDNumber)).ToList();
- foreach (var map in mapList)
- {
- var newStudentList = studentList.Where(x => x.IDNumber == map.PhotoName).ToList();
- if (newStudentList != null && newStudentList.Count() > 1)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["IDNumber"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "存在多个对应的证件号码(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- if (newStudentList != null && newStudentList.Count() == 1)
- {
- var student = newStudentList.Where(x => x.IDNumber == map.PhotoName).SingleOrDefault();
- if (student == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["IDNumber"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的证件号码(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- student.GraduationPictureUrl = map.PhotoPath;
- studentUpList.Add(student);
- inCount++;
- }
- }
- else
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["IDNumber"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的证件号码(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- }
- }
- }
- if (studentUpList != null && studentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate<CF_Student>(studentUpList);
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 查询对应的学生照片RemoteFileInfoList
- /// </summary>
- /// <param name="studentViewList"></param>
- /// <param name="exportPicType"></param>
- /// <returns></returns>
- public IList<FileUploadHelper.RemoteFileInfo> GetStudentPicRemoteFileInfoList(List<StudentView> studentViewList, string exportPicType)
- {
- try
- {
- var remoteFileList = new List<FileUploadHelper.RemoteFileInfo>();
- if (studentViewList != null && studentViewList.Count() > 0)
- {
- switch (exportPicType)
- {
- case "StudentNoToPic":
- remoteFileList = studentViewList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x =>
- new EMIS.Utility.FileUploadHelper.RemoteFileInfo()
- {
- FileName = x.StudentNo + Path.GetExtension(x.PhotoUrl.Trim()),
- RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : x.PhotoUrl.Trim()) //Url.Content(x.PhotoUrl.Trim())
- }).ToList();
- break;
- case "ExamineeNumToPic":
- remoteFileList = studentViewList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x =>
- new EMIS.Utility.FileUploadHelper.RemoteFileInfo()
- {
- FileName = x.ExamineeNum + Path.GetExtension(x.PhotoUrl.Trim()),
- RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : x.PhotoUrl.Trim())
- }).ToList();
- break;
- case "IDNumberToPic":
- remoteFileList = studentViewList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x =>
- new EMIS.Utility.FileUploadHelper.RemoteFileInfo()
- {
- FileName = x.IDNumber + Path.GetExtension(x.PhotoUrl.Trim()),
- RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : x.PhotoUrl.Trim())
- }).ToList();
- break;
- case "StudentNoAndNameToPic":
- remoteFileList = studentViewList.Where(x => !string.IsNullOrEmpty(x.PhotoUrl)).Select(x =>
- new EMIS.Utility.FileUploadHelper.RemoteFileInfo()
- {
- FileName = x.StudentNo + x.Name + Path.GetExtension(x.PhotoUrl.Trim()),
- RemotePath = (x.PhotoUrl.Trim().StartsWith("http://") ? x.PhotoUrl.Trim() : x.PhotoUrl.Trim())
- }).ToList();
- break;
- default:
- break;
- }
- }
- return remoteFileList;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 查询默认的学习形式(个性化配置)
- /// 默认为全部
- /// </summary>
- /// <returns></returns>
- public virtual int? GetDefaultLearnformForList()
- {
- return null;
- }
- /// <summary>
- /// 查询班级信息对应的预计毕业日期DateTime
- /// </summary>
- /// <param name="classmajorID"></param>
- /// <returns></returns>
- public DateTime? GetClassmajorPlanningGraduateDate(Guid? classmajorID)
- {
- try
- {
- var classmajor = StudentDAL.Value.ClassmajorRepository.GetList(x => x.ClassmajorID == classmajorID, (x => x.CF_Grademajor)).SingleOrDefault();
- if (classmajor != null)
- {
- if (classmajor.CF_Grademajor != null)
- {
- if (classmajor.CF_Grademajor.GraduateSchoolyearID.HasValue)
- {
- var graduateSchoolyear = StudentDAL.Value.SchoolyearRepository.GetList(x => x.SchoolyearID == classmajor.CF_Grademajor.GraduateSchoolyearID).SingleOrDefault();
- if (graduateSchoolyear != null)
- {
- var planningGraduateDate = PlanningGraduateDateHelper.GetPlanningGraduateDate(graduateSchoolyear.FirstWeek);
- return planningGraduateDate;
- }
- }
- }
- return null;
- }
- else
- {
- return null;
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询年级专业ID对应的预计毕业日期string
- /// </summary>
- /// <param name="grademajorID"></param>
- /// <returns></returns>
- public string GetPlanningGraduateDate(Guid? grademajorID)
- {
- try
- {
- var grademajor = StudentDAL.Value.GrademajorRepository.GetList(x => x.GrademajorID == grademajorID).SingleOrDefault();
- if (grademajor != null)
- {
- if (grademajor.GraduateSchoolyearID.HasValue)
- {
- var graduateSchoolyear = StudentDAL.Value.SchoolyearRepository.GetList(x => x.SchoolyearID == grademajor.GraduateSchoolyearID).SingleOrDefault();
- if (graduateSchoolyear != null)
- {
- var planningGraduateDate = PlanningGraduateDateHelper.GetPlanningGraduateDate(graduateSchoolyear.FirstWeek);
- return planningGraduateDate.ToString("yyyy-MM-dd");
- }
- }
- return null;
- }
- else
- {
- return null;
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询班级信息对应的毕业学期中的毕业日期DateTime
- /// </summary>
- /// <param name="classmajorID"></param>
- /// <returns></returns>
- public DateTime? GetClassmajorGraduateDate(Guid? classmajorID)
- {
- try
- {
- var classmajor = StudentDAL.Value.ClassmajorRepository.GetList(x => x.ClassmajorID == classmajorID, (x => x.CF_Grademajor)).SingleOrDefault();
- if (classmajor != null)
- {
- if (classmajor.CF_Grademajor != null)
- {
- if (classmajor.CF_Grademajor.GraduateSchoolyearID.HasValue)
- {
- var graduateSchoolyear = StudentDAL.Value.GraduateSchoolyearRepository.GetList(x => x.SchoolyearID == classmajor.CF_Grademajor.GraduateSchoolyearID).SingleOrDefault();
- if (graduateSchoolyear != null)
- {
- var graduateDate = graduateSchoolyear.GraduateDate;
- return graduateDate;
- }
- }
- }
- return null;
- }
- else
- {
- return null;
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询年级专业对应的毕业学期中的毕业日期string
- /// </summary>
- /// <param name="grademajorID"></param>
- /// <returns></returns>
- public string GetGraduateDate(Guid? grademajorID)
- {
- try
- {
- var grademajor = StudentDAL.Value.GrademajorRepository.GetList(x => x.GrademajorID == grademajorID).SingleOrDefault();
- if (grademajor != null)
- {
- if (grademajor.GraduateSchoolyearID.HasValue)
- {
- var graduateSchoolyear = StudentDAL.Value.GraduateSchoolyearRepository
- .GetList(x => x.SchoolyearID == grademajor.GraduateSchoolyearID).SingleOrDefault();
- if (graduateSchoolyear != null)
- {
- var graduateDate = graduateSchoolyear.GraduateDate;
- if (graduateDate.HasValue)
- {
- return graduateDate.Value.ToString("yyyy-MM-dd");
- }
- }
- }
- return null;
- }
- else
- {
- return null;
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询对应的学生预计毕业日期
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<StudentView> GetStudentPlanningGraduateDateGrid(ConfiguretView configuretView, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Student, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = StudentDAL.Value.GetStudentPlanningGraduateDateQueryable(exp).Where(x => x.PlanningGraduateDate != null).ToList();
- foreach (var item in query)
- {
- item.PlanningGraduateDateStr = item.PlanningGraduateDate.Value.ToString("yyyyMMdd");
- }
- var result = query.AsQueryable();
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- result = result.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return result.OrderByDescending(x => x.PlanningGraduateDateStr).ToGridResultSet<StudentView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的学生预计毕业日期List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <returns></returns>
- public IList<StudentView> GetStudentPlanningGraduateDateList(ConfiguretView configuretView)
- {
- Expression<Func<CF_Student, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = StudentDAL.Value.GetStudentPlanningGraduateDateQueryable(exp).Where(x => x.PlanningGraduateDate != null).ToList();
- foreach (var item in query)
- {
- item.PlanningGraduateDateStr = item.PlanningGraduateDate.Value.ToString("yyyyMMdd");
- }
- var result = query.AsQueryable();
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- result = result.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return result.OrderByDescending(x => x.PlanningGraduateDateStr).ToList();
- }
- /// <summary>
- /// 查询对应的数据范围ID
- /// </summary>
- /// <returns></returns>
- public int? GetDataRangeID()
- {
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- if (curUser.IsStudent)
- {
- return (int)SYS_DataRange.Student;
- }
- var menuNo = HttpHelper.GetMenuNo();
- if (string.IsNullOrEmpty(menuNo))
- {
- menuNo = HttpContext.Current.Request.UrlReferrer.GetQueryStringByPath("FromMNU");
- }
- var dataRange = DataRangeDAL.Value.GetRoleDataRange(curUser.RoleID, menuNo);
- switch (dataRange)
- {
- case SYS_DataRange.All:
- return (int)SYS_DataRange.All;
- case SYS_DataRange.Campus:
- return (int)SYS_DataRange.Campus;
- case SYS_DataRange.College:
- return (int)SYS_DataRange.College;
- case SYS_DataRange.Department:
- return (int)SYS_DataRange.Department;
- case SYS_DataRange.Teacher:
- return (int)SYS_DataRange.Teacher;
- case SYS_DataRange.Assistant:
- return (int)SYS_DataRange.Assistant;
- default:
- return (int)SYS_DataRange.All;
- }
- }
- /// <summary>
- /// 学生信息Excel导入
- /// </summary>
- /// <param name="cellheader"></param>
- /// <param name="inCount"></param>
- /// <param name="upCount"></param>
- /// <param name="errdataList"></param>
- /// <param name="errCount"></param>
- /// <param name="sourcePhysicalPath"></param>
- public virtual void StudentImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount, out List<StudentView> errdataList, out int? errCount, string sourcePhysicalPath)
- {
- try
- {
- //查询相关Web.config配置
- if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringMonth == null)
- {
- throw new Exception("预计毕业月(春季、上学期入学月)未配置,请检查。");
- }
- if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateSpringDay == null)
- {
- throw new Exception("预计毕业日(春季、上学期入学日)未配置,请检查。");
- }
- if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnMonth == null)
- {
- throw new Exception("预计毕业月(秋季、下学期入学月)未配置,请检查。");
- }
- if (EMIS.Utility.Const.LOCAL_SETTING_PlanningGraduateDateAutumnDay == null)
- {
- throw new Exception("预计毕业日(秋季、下学期入学日)未配置,请检查。");
- }
- if (EMIS.Utility.Const.LOCAL_SETTING_ENTRANCESEMESTERID == null)
- {
- throw new Exception("入学学期(春季、上学期、秋季、下学期)未配置,请检查。");
- }
- var studentNoTotal = EMIS.Utility.Const.LOCAL_SETTING_LOGINIDTOTAL;
- if (studentNoTotal == null)
- {
- throw new Exception("学号总位数未配置,请检查。");
- }
- StringBuilder errorMsg = new StringBuilder(); // 错误信息
- List<StudentView> errList = new List<StudentView>();
- // 1.1解析文件,存放到一个List集合里
- cellheader.Remove("ErrorMessage");//移除“未导入原因”列(ErrorMessage)
- List<StudentView> enlist = NpoiExcelHelper.ExcelToEntityList<StudentView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
- cellheader.Add("ErrorMessage", "未导入原因");
- //对List集合进行有效性校验
- if (enlist.Count() <= 0)
- {
- throw new Exception("Excel文件数据为空,请检查。");
- }
- Regex reg = null; //正则表达式
- DateTime result; //用于返回判断日期字段格式
- inCount = 0; //导入个数
- upCount = 0; //更新个数
- errCount = 0; //失败个数
- string errorMsgStr = ""; //错误信息
- List<Sys_User> newUserInList = new List<Sys_User>();
- List<Sys_User> newUserUpList = new List<Sys_User>();
- List<CF_Student> newStudentInList = new List<CF_Student>();
- List<CF_Student> newStudentUpList = new List<CF_Student>();
- List<CF_StudentProfile> newStudentProfileInList = new List<CF_StudentProfile>();
- List<CF_StudentProfile> newStudentProfileUpList = new List<CF_StudentProfile>();
- List<CF_StudentContact> newStudentContactInList = new List<CF_StudentContact>();
- List<CF_StudentContact> newStudentContactUpList = new List<CF_StudentContact>();
- List<CF_StudentAccount> newStudentAccountInList = new List<CF_StudentAccount>();
- List<CF_StudentAccount> newStudentAccountUpList = new List<CF_StudentAccount>();
- List<CF_Recruitstudents> newRecruitstudentsInList = new List<CF_Recruitstudents>();
- List<CF_Recruitstudents> newRecruitstudentsUpList = new List<CF_Recruitstudents>();
-
- var passwordParameter = StudentDAL.Value.ParameterRepository.GetSingle(x => x.ParameterTypeID == (int)ViewModel.CF_ParameterType.StudentInitPassword);
- var roleList = StudentDAL.Value.RoleRepository.GetList(x => x.TypeID == (int)SYS_RoleType.Student, (x => x.CF_StudentRole)).ToList();
- //将循环中相关数据库查询统一查询出来进行匹配(尽量避免在循环中进行数据库查询)
- //性别
- var sexList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Sex).ToList();
- //民族
- var nationList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Nation).ToList();
- //政治面貌
- var politicsList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Politics).ToList();
- //学生类别
- var studentTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_STUDENTTYPE).ToList();
- //证件类型
- var certificatesTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CertificatesType).ToList();
- //在校状态
- var inschoolStatusList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_InschoolStatus).ToList();
- //学籍状态
- var studentStatusList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_StudentStatus).ToList();
- //文化程度
- var literacyLevelList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_LiteracyLevel).ToList();
- //培养方式
- var cultureModelList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CULTUREMODEL).ToList();
- //考生类别
- var examineeTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_EXAMINEETYPE).ToList();
- //入学方式
- var entranceWayList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_EntranceWay).ToList();
- //考生特征
- var featuresList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Features).ToList();
- //生源所属地
- var territorialList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Province).ToList();
- //健康状况
- var healthStateList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_HealthState).ToList();
- //血型
- var bloodGroupList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_BLOODGROUP).ToList();
- //是否
- var generalPurposeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_GeneralPurpose).ToList();
- //有无
- var generalExistList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_GeneralExist).ToList();
- //班级编号
- var classmajorNoList = enlist.Where(x => !string.IsNullOrEmpty(x.ClassmajorNo)).Select(x => x.ClassmajorNo.Trim()).ToList();
- //对比后的newClassmajorList
- var newClassmajorList = StudentDAL.Value.ClassmajorRepository.GetList(x => classmajorNoList.Contains(x.No)).ToList();
- //学籍卡编号
- var studentCardNoList = enlist.Where(x => !string.IsNullOrEmpty(x.StudentCardNo)).Select(x => x.StudentCardNo.Trim()).ToList();
- //对比后的newStudentCardNoList
- var newStudentCardNoList = StudentDAL.Value.StudentRepository.GetList(x => studentCardNoList.Contains(x.StudentCardNo)).ToList();
- //毕结业证书编号
- var graduateCardNoList = enlist.Where(x => !string.IsNullOrEmpty(x.GraduateCardNo)).Select(x => x.GraduateCardNo.Trim()).ToList();
- //对比后的newGraduateCardNoList
- var newGraduateCardNoList = StudentDAL.Value.StudentRepository.GetList(x => graduateCardNoList.Contains(x.GraduateCardNo)).ToList();
- //考生号
- var examineeNumList = enlist.Where(x => !string.IsNullOrEmpty(x.ExamineeNum)).Select(x => x.ExamineeNum.Trim()).ToList();
- //对比后的newExamineeNumList
- var newExamineeNumList = StudentDAL.Value.RecruitstudentsRepository.GetList(x => examineeNumList.Contains(x.ExamineeNum)).ToList();
- //学号
- var studentNoList = enlist.Where(x => !string.IsNullOrEmpty(x.StudentNo)).Select(x => x.StudentNo.Trim()).ToList();
- //对比后的newNewStuList
- var newNewStuList = StudentDAL.Value.NewStudentRepository.GetList(x => x.AssignStatus == (int)CF_AssignStatus.Assigned).Where(x => studentNoList.Contains(x.StudentNo)).ToList();
- //对比后的newStudentList
- var newStudentList = StudentDAL.Value.StudentRepository.GetList(x => studentNoList.Contains(x.Sys_User.LoginID),
- (x => x.CF_StudentProfile), (x => x.CF_StudentContact), (x => x.CF_StudentAccount),
- (x => x.CF_Recruitstudents), (x => x.Sys_User)).ToList();
- //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等)
- for (int i = 0; i < enlist.Count; i++)
- {
- StudentView en = enlist[i]; //Excel表数据视图
- var newUser = new Sys_User();
- var newStudent = new CF_Student();
- var newStudentProfile = new CF_StudentProfile();
- var newStudentContact = new CF_StudentContact();
- var newStudentAccount = new CF_StudentAccount();
- var newRecruitstudents = new CF_Recruitstudents();
- //考生号
- if (string.IsNullOrWhiteSpace(en.ExamineeNum))
- {
- errCount++;
- errorMsgStr = "考生号不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
- if (!reg.IsMatch(en.ExamineeNum.Trim()))
- {
- errCount++;
- errorMsgStr = "考生号格式不正确,请检查(数字或英文字母)";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newRecruitstudents.ExamineeNum = en.ExamineeNum.Trim();
- }
- }
- //准考证号
- if (string.IsNullOrWhiteSpace(en.AdmissionTicketNo))
- {
- //暂不考虑
- }
- else
- {
- reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
- if (!reg.IsMatch(en.AdmissionTicketNo.Trim()))
- {
- errCount++;
- errorMsgStr = "准考证号格式不正确,请检查(数字或英文字母)";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newRecruitstudents.AdmissionTicketNo = en.AdmissionTicketNo.Trim();
- }
- }
- //学号
- if (string.IsNullOrWhiteSpace(en.StudentNo))
- {
- errCount++;
- errorMsgStr = "学号不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
- if (!reg.IsMatch(en.StudentNo.Trim()))
- {
- errCount++;
- errorMsgStr = "学号格式不正确,请检查(数字或英文字母)";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- if (en.StudentNo.Trim().Length != Convert.ToInt32(studentNoTotal))
- {
- errCount++;
- errorMsgStr = "学号总位数有误,学号总位数应为" + studentNoTotal + "位。";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newUser.LoginID = en.StudentNo.Trim();
- }
- }
- }
- //姓名
- if (string.IsNullOrWhiteSpace(en.Name))
- {
- errCount++;
- errorMsgStr = "姓名不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newUser.Name = en.Name.Trim();
- }
- //曾用名
- if (string.IsNullOrWhiteSpace(en.UsedName))
- {
- //暂不考虑
- }
- else
- {
- newStudentProfile.UsedName = en.UsedName.Trim();
- }
- //性别
- if (string.IsNullOrWhiteSpace(en.SexStr))
- {
- errCount++;
- errorMsgStr = "性别不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var sex = sexList.Where(x => x.Name == en.SexStr.Trim()).SingleOrDefault();
- if (sex == null)
- {
- errCount++;
- errorMsgStr = "性别不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudent.SexID = sex.Value;
- }
- }
- //出生日期
- if (string.IsNullOrWhiteSpace(en.BirthDateStr))
- {
- errCount++;
- errorMsgStr = "出生日期不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //reg = new Regex(@"(\d{4})-(\d{1,2})-(\d{1,2})"); //日期正则表达式,2017-12-28
- if (!DateTime.TryParse(en.BirthDateStr, out result))
- {
- errCount++;
- errorMsgStr = "出生日期格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudent.BirthDate = Convert.ToDateTime(en.BirthDateStr);
- }
- }
- //民族
- if (string.IsNullOrWhiteSpace(en.NationStr))
- {
- errCount++;
- errorMsgStr = "民族不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var nation = nationList.Where(x => x.Name == en.NationStr.Trim()).SingleOrDefault();
- if (nation == null)
- {
- errCount++;
- errorMsgStr = "民族不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudent.NationID = nation.Value;
- }
- }
- //政治面貌
- if (string.IsNullOrWhiteSpace(en.PoliticsStr))
- {
- errCount++;
- errorMsgStr = "政治面貌不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var politics = politicsList.Where(x => x.Name == en.PoliticsStr.Trim()).SingleOrDefault();
- if (politics == null)
- {
- errCount++;
- errorMsgStr = "政治面貌不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudent.PoliticsID = politics.Value;
- }
- }
- //学生类别
- if (string.IsNullOrWhiteSpace(en.StudentTypeStr))
- {
- newStudent.StudentType = (int)CF_STUDENTTYPE.DefaultType;
- }
- else
- {
- var studentType = studentTypeList.Where(x => x.Name == en.StudentTypeStr.Trim()).SingleOrDefault();
- if (studentType == null)
- {
- errCount++;
- errorMsgStr = "学生类别不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudent.StudentType = studentType.Value;
- }
- }
- //证件类型
- if (string.IsNullOrWhiteSpace(en.CertificatesTypeStr))
- {
- //默认为身份证
- newStudent.CertificatesType = (int)CF_CertificatesType.IdCrad;
- }
- else
- {
- var certificatesType = certificatesTypeList.Where(x => x.Name == en.CertificatesTypeStr.Trim()).SingleOrDefault();
- if (certificatesType == null)
- {
- errCount++;
- errorMsgStr = "证件类型不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudent.CertificatesType = certificatesType.Value;
- }
- }
- //证件号码
- if (string.IsNullOrWhiteSpace(en.IDNumber))
- {
- errCount++;
- errorMsgStr = "证件号码不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
- //if (!reg.IsMatch(en.IDNumber.Trim()))
- //{
- // errCount++;
- // errorMsgStr = "证件号码格式不正确,请检查(数字或英文字母)";
- // en.ErrorMessage = errorMsgStr;
- // errList.Add(en);
- // errorMsg.AppendLine(errorMsgStr);
- // continue;
- //}
- //else
- //{
- // newStudent.IDNumber = en.IDNumber.Trim();
- //}
- newStudent.IDNumber = en.IDNumber.Trim();
- }
- //在校状态
- if (string.IsNullOrWhiteSpace(en.InSchoolStatusStr))
- {
- errCount++;
- errorMsgStr = "在校状态不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var inSchoolStatus = inschoolStatusList.Where(x => x.Name == en.InSchoolStatusStr.Trim()).SingleOrDefault();
- if (inSchoolStatus == null)
- {
- errCount++;
- errorMsgStr = "在校状态不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudent.InSchoolStatusID = inSchoolStatus.Value;
- }
- }
- //学籍状态
- if (string.IsNullOrWhiteSpace(en.StudentStatusStr))
- {
- errCount++;
- errorMsgStr = "学籍状态不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var studentStatus = studentStatusList.Where(x => x.Name == en.StudentStatusStr.Trim()).SingleOrDefault();
- if (studentStatus == null)
- {
- errCount++;
- errorMsgStr = "学籍状态不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudent.StudentStatus = studentStatus.Value;
- }
- }
- //班级编号
- if (string.IsNullOrWhiteSpace(en.ClassmajorNo))
- {
- errCount++;
- errorMsgStr = "班级编号不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var classmajor = newClassmajorList.Where(x => x.No == en.ClassmajorNo.Trim()).SingleOrDefault();
- if (classmajor == null)
- {
- errCount++;
- errorMsgStr = "班级编号不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //判断班级编号与班级名称(以班级编号为准)
- if (string.IsNullOrWhiteSpace(en.ClassmajorName))
- {
- //暂不考虑
- }
- else
- {
- //班级编号与班级名称不对应
- if (classmajor.Name.Trim() != en.ClassmajorName.Trim())
- {
- errCount++;
- errorMsgStr = "班级编号与班级名称不对应(以班级编号为准),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- newStudent.ClassmajorID = classmajor.ClassmajorID;
- newStudent.PlanningGraduateDate = this.GetClassmajorPlanningGraduateDate(classmajor.ClassmajorID);
- newStudent.GraduateDate = this.GetClassmajorGraduateDate(classmajor.ClassmajorID);
- }
- }
- //班级名称
- if (string.IsNullOrWhiteSpace(en.ClassmajorName))
- {
- //暂不考虑
- }
- else
- {
- //暂不考虑
- }
- //文化程度
- if (string.IsNullOrWhiteSpace(en.LiteracyLevelStr))
- {
- //暂不考虑
- }
- else
- {
- var literacyLevel = literacyLevelList.Where(x => x.Name == en.LiteracyLevelStr.Trim()).SingleOrDefault();
- if (literacyLevel == null)
- {
- errCount++;
- errorMsgStr = "文化程度不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudentProfile.LiteracyLevelID = literacyLevel.Value;
- }
- }
- //培养方式
- if (string.IsNullOrWhiteSpace(en.CultureModelStr))
- {
- //暂不考虑
- }
- else
- {
- var cultureModel = cultureModelList.Where(x => x.Name == en.CultureModelStr.Trim()).SingleOrDefault();
- if (cultureModel == null)
- {
- errCount++;
- errorMsgStr = "培养方式不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudentProfile.CultureModelID = cultureModel.Value;
- }
- }
- //考生类别
- if (string.IsNullOrWhiteSpace(en.ExamineeTypeStr))
- {
- //暂不考虑
- }
- else
- {
- var examineeType = examineeTypeList.Where(x => x.Name == en.ExamineeTypeStr.Trim()).SingleOrDefault();
- if (examineeType == null)
- {
- errCount++;
- errorMsgStr = "考生类别不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newRecruitstudents.ExamineeType = examineeType.Value;
- }
- }
- //入学日期
- if (string.IsNullOrWhiteSpace(en.EntranceDateStr))
- {
- //暂不考虑
- }
- else
- {
- if (!DateTime.TryParse(en.EntranceDateStr, out result))
- {
- errCount++;
- errorMsgStr = "入学日期格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newRecruitstudents.EntranceDate = Convert.ToDateTime(en.EntranceDateStr);
- }
- }
- //总分
- if (string.IsNullOrWhiteSpace(en.ScoreStr))
- {
- //暂不考虑
- }
- else
- {
- reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$"); //数字正则表达式
- if (!reg.IsMatch(en.ScoreStr))
- {
- errCount++;
- errorMsgStr = "总分格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newRecruitstudents.Score = Convert.ToDecimal(en.ScoreStr);
- }
- }
- //入学方式
- if (string.IsNullOrWhiteSpace(en.EntranceWayStr))
- {
- //暂不考虑
- }
- else
- {
- var entranceWay = entranceWayList.Where(x => x.Name == en.EntranceWayStr.Trim()).SingleOrDefault();
- if (entranceWay == null)
- {
- errCount++;
- errorMsgStr = "入学方式不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newRecruitstudents.EntranceWayID = entranceWay.Value;
- }
- }
- //考生特征
- if (string.IsNullOrWhiteSpace(en.FeaturesStr))
- {
- //暂不考虑
- }
- else
- {
- var features = featuresList.Where(x => x.Name == en.FeaturesStr.Trim()).SingleOrDefault();
- if (features == null)
- {
- errCount++;
- errorMsgStr = "考生特征不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newRecruitstudents.FeaturesID = features.Value;
- }
- }
- //生源所属地
- if (string.IsNullOrWhiteSpace(en.TerritorialStr))
- {
- //暂不考虑
- }
- else
- {
- var territorial = territorialList.Where(x => x.Name == en.TerritorialStr.Trim()).SingleOrDefault();
- if (territorial == null)
- {
- errCount++;
- errorMsgStr = "生源所属地不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newRecruitstudents.TerritorialID = territorial.Value;
- }
- }
- //来源地区
- if (string.IsNullOrWhiteSpace(en.Area))
- {
- //暂不考虑
- }
- else
- {
- newRecruitstudents.Area = en.Area.Trim();
- }
- //国籍
- if (string.IsNullOrWhiteSpace(en.Country))
- {
- //暂不考虑
- }
- else
- {
- newStudentProfile.Country = en.Country.Trim();
- }
- //籍贯
- if (string.IsNullOrWhiteSpace(en.Place))
- {
- //暂不考虑
- }
- else
- {
- newStudentProfile.Place = en.Place.Trim();
- }
- //出生地
- if (string.IsNullOrWhiteSpace(en.BornPlace))
- {
- //暂不考虑
- }
- else
- {
- newStudentProfile.BornPlace = en.BornPlace.Trim();
- }
- //电子邮箱
- if (string.IsNullOrWhiteSpace(en.Email))
- {
- //暂不考虑
- }
- else
- {
- reg = new Regex(@"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"); //正则表达式
- if (!reg.IsMatch(en.Email.Trim()))
- {
- errCount++;
- errorMsgStr = "电子邮箱格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudentContact.Email = en.Email.Trim();
- }
- }
- //移动电话
- if (string.IsNullOrWhiteSpace(en.Mobile))
- {
- //暂不考虑
- }
- else
- {
- newStudentContact.Mobile = en.Mobile.Trim();
- }
- //家庭电话
- if (string.IsNullOrWhiteSpace(en.Telephone))
- {
- //暂不考虑
- }
- else
- {
- newStudentContact.Telephone = en.Telephone.Trim();
- }
- //邮政编码
- if (string.IsNullOrWhiteSpace(en.ZIPCode))
- {
- //暂不考虑
- }
- else
- {
- reg = new Regex(@"[1-9]\d{5}(?!\d)"); //正则表达式
- if (!reg.IsMatch(en.ZIPCode.Trim()))
- {
- errCount++;
- errorMsgStr = "邮政编码格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudentContact.ZIPCode = en.ZIPCode.Trim();
- }
- }
- //健康状况
- if (string.IsNullOrWhiteSpace(en.HealthStateStr))
- {
- newStudentProfile.HealthStateID = (int)CF_HealthState.Healthy;
- }
- else
- {
- var healthState = healthStateList.Where(x => x.Name == en.HealthStateStr.Trim()).SingleOrDefault();
- if (healthState == null)
- {
- errCount++;
- errorMsgStr = "健康状况不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudentProfile.HealthStateID = healthState.Value;
- }
- }
- //血型
- if (string.IsNullOrWhiteSpace(en.BloodGroupStr))
- {
- //暂不考虑
- }
- else
- {
- var bloodGroup = bloodGroupList.Where(x => x.Name == en.BloodGroupStr.Trim()).SingleOrDefault();
- if (bloodGroup == null)
- {
- errCount++;
- errorMsgStr = "血型不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudentProfile.BloodGroup = bloodGroup.Value;
- }
- }
- //特长
- if (string.IsNullOrWhiteSpace(en.Specialty))
- {
- //暂不考虑
- }
- else
- {
- newStudentProfile.Specialty = en.Specialty.Trim();
- }
- //身高(cm)
- if (string.IsNullOrWhiteSpace(en.Height))
- {
- //暂不考虑
- }
- else
- {
- reg = new Regex(@"^\d+(\.\d+)?$"); //正则表达式
- if (!reg.IsMatch(en.Height.Trim()))
- {
- errCount++;
- errorMsgStr = "身高(cm)格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudentProfile.Height = en.Height.Trim();
- }
- }
- //体重(kg)
- if (string.IsNullOrWhiteSpace(en.Weight))
- {
- //暂不考虑
- }
- else
- {
- reg = new Regex(@"^\d+(\.\d+)?$"); //正则表达式
- if (!reg.IsMatch(en.Weight.Trim()))
- {
- errCount++;
- errorMsgStr = "体重(cm)格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudentProfile.Weight = en.Weight.Trim();
- }
- }
- //微信号
- if (string.IsNullOrWhiteSpace(en.WeChatNum))
- {
- //暂不考虑
- }
- else
- {
- newStudentContact.WeChatNum = en.WeChatNum.Trim();
- }
- //QQ
- if (string.IsNullOrWhiteSpace(en.QQ))
- {
- //暂不考虑
- }
- else
- {
- reg = new Regex(@"[1-9][0-9]{4,}"); //正则表达式
- if (!reg.IsMatch(en.QQ.Trim()))
- {
- errCount++;
- errorMsgStr = "QQ格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudentContact.QQ = en.QQ.Trim();
- }
- }
- //家庭住址
- if (string.IsNullOrWhiteSpace(en.HomeAddress))
- {
- //暂不考虑
- }
- else
- {
- newStudentContact.HomeAddress = en.HomeAddress.Trim();
- }
- //工作单位
- if (string.IsNullOrWhiteSpace(en.WorkUnit))
- {
- //暂不考虑
- }
- else
- {
- newStudentContact.WorkUnit = en.WorkUnit.Trim();
- }
- //通信地址
- if (string.IsNullOrWhiteSpace(en.Address))
- {
- //暂不考虑
- }
- else
- {
- newStudentContact.Address = en.Address.Trim();
- }
- //宿舍地址
- if (string.IsNullOrWhiteSpace(en.Dormitory))
- {
- //暂不考虑
- }
- else
- {
- newStudentContact.Dormitory = en.Dormitory.Trim();
- }
- //收件人
- if (string.IsNullOrWhiteSpace(en.Recipient))
- {
- //暂不考虑
- }
- else
- {
- newStudentContact.Recipient = en.Recipient.Trim();
- }
- //圆梦计划
- if (string.IsNullOrWhiteSpace(en.IsDreamProjectStr))
- {
- newStudentProfile.IsDreamProject = false;
- }
- else
- {
- var isDreamProject = generalPurposeList.Where(x => x.Name == en.IsDreamProjectStr.Trim()).SingleOrDefault();
- if (isDreamProject == null)
- {
- errCount++;
- errorMsgStr = "是否圆梦计划不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudentProfile.IsDreamProject = isDreamProject.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
- }
- }
- //导师姓名
- if (string.IsNullOrWhiteSpace(en.DirectorName))
- {
- //暂不考虑
- }
- else
- {
- newStudentProfile.DirectorName = en.DirectorName.Trim();
- }
- //开户银行
- if (string.IsNullOrWhiteSpace(en.BankName))
- {
- //暂不考虑
- }
- else
- {
- newStudentAccount.BankName = en.BankName.Trim();
- }
- //银行卡号
- if (string.IsNullOrWhiteSpace(en.CardNo))
- {
- //暂不考虑
- }
- else
- {
- reg = new Regex(@"^[0-9]*$"); //正则表达式
- if (!reg.IsMatch(en.CardNo.Trim()))
- {
- errCount++;
- errorMsgStr = "银行卡号格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudentAccount.CardNo = en.CardNo.Trim();
- }
- }
- //学籍卡编号
- if (string.IsNullOrWhiteSpace(en.StudentCardNo))
- {
- //暂不考虑
- }
- else
- {
- reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式
- if (!reg.IsMatch(en.StudentCardNo.Trim()))
- {
- errCount++;
- errorMsgStr = "学籍卡编号格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudent.StudentCardNo = en.StudentCardNo.Trim();
- }
- }
- //毕结业证书编号
- if (string.IsNullOrWhiteSpace(en.GraduateCardNo))
- {
- //暂不考虑
- }
- else
- {
- reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式
- if (!reg.IsMatch(en.GraduateCardNo.Trim()))
- {
- errCount++;
- errorMsgStr = "毕结业证书编号格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudent.GraduateCardNo = en.GraduateCardNo.Trim();
- }
- }
- //学位有无
- if (string.IsNullOrWhiteSpace(en.DegreeStatusStr))
- {
- newStudent.DegreeStatus = false;
- }
- else
- {
- var degreeStatus = generalExistList.Where(x => x.Name == en.DegreeStatusStr.Trim()).SingleOrDefault();
- if (degreeStatus == null)
- {
- errCount++;
- errorMsgStr = "学位有无不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudent.DegreeStatus = degreeStatus.Value == (int)CF_GeneralExist.Have ? true : false;
- }
- }
- //在校经历
- if (string.IsNullOrWhiteSpace(en.Career))
- {
- //暂不考虑
- }
- else
- {
- newStudent.Career = en.Career.Trim();
- }
- //备注
- if (string.IsNullOrWhiteSpace(en.Remark))
- {
- //暂不考虑
- }
- else
- {
- newStudent.Remark = en.Remark.Trim();
- }
- ////Excel表重复性验证(注:当数据表中没有此记录,但是Excel中有重复数据时的去掉)
- //for (int j = i + 1; j < enlist.Count; j++)
- //{
- // StudentView enA = enlist[j];
- // //根据Excel表中的业务主键进行去重(学号或考生号唯一)
- // if (en.StudentNo == enA.StudentNo || en.ExamineeNum == enA.ExamineeNum)
- // {
- // //用于标识Excel表中的重复记录(由于是批量进行插入数据表)
- // }
- //}
- //数据表重复性验证(学号或考生号唯一)
- var userVerify = newStudentList.Select(x => x.Sys_User).Where(x => x.LoginID == newUser.LoginID).SingleOrDefault();
- if (userVerify == null)
- {
- var newNewStuVerify = newNewStuList.Where(x => x.ExamineeNum != newRecruitstudents.ExamineeNum
- && x.StudentNo == newUser.LoginID).SingleOrDefault();
- if (newNewStuVerify != null)
- {
- errCount++;
- errorMsgStr = "学号重复(录取名单中学号重复),请核查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- if (!newRecruitstudentsUpList.Any(x => x.ExamineeNum == newRecruitstudents.ExamineeNum))
- {
- if (!newRecruitstudentsInList.Any(x => x.ExamineeNum == newRecruitstudents.ExamineeNum))
- {
- var newExamineeNumVerify = newExamineeNumList.Where(x => x.ExamineeNum == newRecruitstudents.ExamineeNum).SingleOrDefault();
- if (newExamineeNumVerify != null)
- {
- errCount++;
- errorMsgStr = "考生号重复,请核查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- else
- {
- errCount++;
- errorMsgStr = "考生号重复(Excel中),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- else
- {
- errCount++;
- errorMsgStr = "考生号重复(Excel中),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- if (!string.IsNullOrEmpty(newStudent.StudentCardNo))
- {
- if (!newStudentUpList.Any(x => x.StudentCardNo == newStudent.StudentCardNo))
- {
- if (!newStudentInList.Any(x => x.StudentCardNo == newStudent.StudentCardNo))
- {
- var newStudentCardNoVerify = newStudentCardNoList.Where(x => x.StudentCardNo == newStudent.StudentCardNo).SingleOrDefault();
- if (newStudentCardNoVerify != null)
- {
- errCount++;
- errorMsgStr = "学籍卡编号重复,请核查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- else
- {
- errCount++;
- errorMsgStr = "学籍卡编号重复(Excel中),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- else
- {
- errCount++;
- errorMsgStr = "学籍卡编号重复(Excel中),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- if (!string.IsNullOrEmpty(newStudent.GraduateCardNo))
- {
- if (!newStudentUpList.Any(x => x.GraduateCardNo == newStudent.GraduateCardNo))
- {
- if (!newStudentInList.Any(x => x.GraduateCardNo == newStudent.GraduateCardNo))
- {
- var newGraduateCardNoVerify = newGraduateCardNoList.Where(x => x.GraduateCardNo == newStudent.GraduateCardNo).SingleOrDefault();
- if (newGraduateCardNoVerify != null)
- {
- errCount++;
- errorMsgStr = "毕结业证书编号重复,请核查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- else
- {
- errCount++;
- errorMsgStr = "毕结业证书编号重复(Excel中),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- else
- {
- errCount++;
- errorMsgStr = "毕结业证书编号重复(Excel中),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- //新增
- if (!newUserInList.Any(x => x.LoginID == newUser.LoginID))
- {
- newUser.UserID = Guid.NewGuid();
- if (passwordParameter == null)
- {
- newUser.Password = ("A" + newUser.LoginID.Trim()).MD5();
- }
- else
- {
- if (passwordParameter.Value != null)
- {
- newUser.Password = passwordParameter.Value;
- }
- else
- {
- newUser.Password = ("A" + newUser.LoginID.Trim()).MD5();
- }
- }
- this.SetNewStatus(newUser, (int)SYS_STATUS.USABLE);
- newUserInList.Add(newUser);
- newUser.Sys_Role = new HashSet<Sys_Role>();
- roleList = roleList.Where(x => x.CF_StudentRole.StudentType == newStudent.StudentType).ToList();
- if (roleList != null && roleList.Count > 0)
- {
- roleList.ForEach(x => newUser.Sys_Role.Add(x));
- }
- else
- {
- //对应角色为空时,默认为不分配用户角色
- }
- newStudent.UserID = newUser.UserID;
- newStudent.IsPhotoComparison = false;
- newStudent.IsProofread = false;
- this.SetNewStatus(newStudent);
- newStudentInList.Add(newStudent);
- newStudentProfile.UserID = newStudent.UserID;
- this.SetNewStatus(newStudentProfile);
- newStudentProfileInList.Add(newStudentProfile);
- newStudentContact.UserID = newStudent.UserID;
- this.SetNewStatus(newStudentContact);
- newStudentContactInList.Add(newStudentContact);
- newStudentAccount.UserID = newStudent.UserID;
- this.SetNewStatus(newStudentAccount);
- newStudentAccountInList.Add(newStudentAccount);
- newRecruitstudents.UserID = newStudent.UserID;
- this.SetNewStatus(newRecruitstudents);
- newRecruitstudentsInList.Add(newRecruitstudents);
- inCount++;
- }
- else
- {
- //Excel表重复性验证
- //(注:当数据表中没有此记录,但是Excel中有重复数据,可在此处进行抛出到失败数据文件中)
- errCount++;
- errorMsgStr = "学号重复(Excel中),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- else
- {
- //更新(判断Excel有重复时,以最后一条记录更新为准)
- var studentVerify = newStudentList.Where(x => x.UserID == userVerify.UserID).SingleOrDefault();
- if (studentVerify == null)
- {
- errCount++;
- errorMsgStr = "学号冲突(与其它帐号冲突),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var newNewStuVerify = newNewStuList.Where(x => x.ExamineeNum != newRecruitstudents.ExamineeNum
- && x.StudentNo == newUser.LoginID).SingleOrDefault();
- if (newNewStuVerify != null)
- {
- errCount++;
- errorMsgStr = "学号重复(录取名单中学号重复),请核查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- if (!newRecruitstudentsInList.Any(x => x.ExamineeNum == newRecruitstudents.ExamineeNum))
- {
- if (!newRecruitstudentsUpList.Any(x => x.ExamineeNum == newRecruitstudents.ExamineeNum))
- {
- var newExamineeNumVerify = newExamineeNumList.Where(x => x.UserID != userVerify.UserID
- && x.ExamineeNum == newRecruitstudents.ExamineeNum).ToList();
- if (newExamineeNumVerify != null && newExamineeNumVerify.Count() > 0)
- {
- errCount++;
- errorMsgStr = "考生号已存在(与其它学生冲突),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- else
- {
- errCount++;
- errorMsgStr = "考生号重复(Excel中),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- else
- {
- errCount++;
- errorMsgStr = "考生号重复(Excel中),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- if (!string.IsNullOrEmpty(newStudent.StudentCardNo))
- {
- if (!newStudentInList.Any(x => x.StudentCardNo == newStudent.StudentCardNo))
- {
- if (!newStudentUpList.Any(x => x.StudentCardNo == newStudent.StudentCardNo))
- {
- var newStudentCardNoVerify = newStudentCardNoList.Where(x => x.UserID != userVerify.UserID
- && x.StudentCardNo == newStudent.StudentCardNo).ToList();
- if (newStudentCardNoVerify != null && newStudentCardNoVerify.Count() > 0)
- {
- errCount++;
- errorMsgStr = "学籍卡编号已存在(与其它学生冲突),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- else
- {
- errCount++;
- errorMsgStr = "学籍卡编号重复(Excel中),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- else
- {
- errCount++;
- errorMsgStr = "学籍卡编号重复(Excel中),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- if (!string.IsNullOrEmpty(newStudent.GraduateCardNo))
- {
- if (!newStudentInList.Any(x => x.GraduateCardNo == newStudent.GraduateCardNo))
- {
- if (!newStudentUpList.Any(x => x.GraduateCardNo == newStudent.GraduateCardNo))
- {
- var newGraduateCardNoVerify = newGraduateCardNoList.Where(x => x.UserID != userVerify.UserID
- && x.GraduateCardNo == newStudent.GraduateCardNo).ToList();
- if (newGraduateCardNoVerify != null && newGraduateCardNoVerify.Count() > 0)
- {
- errCount++;
- errorMsgStr = "毕结业证书编号已存在(与其它学生冲突),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- else
- {
- errCount++;
- errorMsgStr = "毕结业证书编号重复(Excel中),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- else
- {
- errCount++;
- errorMsgStr = "毕结业证书编号重复(Excel中),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- studentVerify.Sys_User.LoginID = newUser.LoginID.Trim();
- studentVerify.Sys_User.Name = newUser.Name.Trim();
- this.SetModifyStatus(studentVerify.Sys_User);
- newUserUpList.Add(studentVerify.Sys_User);
- studentVerify.SexID = newStudent.SexID;
- studentVerify.BirthDate = newStudent.BirthDate;
- studentVerify.NationID = newStudent.NationID;
- studentVerify.PoliticsID = newStudent.PoliticsID;
- studentVerify.CertificatesType = newStudent.CertificatesType;
- studentVerify.IDNumber = newStudent.IDNumber;
- studentVerify.StudentType = newStudent.StudentType;
- studentVerify.Sys_User.Sys_Role = new HashSet<Sys_Role>();
- roleList = roleList.Where(x => x.CF_StudentRole.StudentType == newStudent.StudentType).ToList();
- if (roleList != null && roleList.Count > 0)
- {
- roleList.ForEach(x => studentVerify.Sys_User.Sys_Role.Add(x));
- }
- else
- {
- //对应角色为空时,默认为不分配用户角色
- }
- studentVerify.StudentCardNo = newStudent.StudentCardNo;
- studentVerify.GraduateCardNo = newStudent.GraduateCardNo;
- studentVerify.DegreeStatus = newStudent.DegreeStatus;
- studentVerify.Career = newStudent.Career;
- studentVerify.Remark = newStudent.Remark;
- this.SetModifyStatus(studentVerify);
- newStudentUpList.Add(studentVerify);
- if (studentVerify.CF_StudentProfile == null)
- {
- var studentProfile = new CF_StudentProfile();
- studentProfile.UserID = studentVerify.UserID;
- studentProfile.UsedName = newStudentProfile.UsedName;
- studentProfile.LiteracyLevelID = newStudentProfile.LiteracyLevelID;
- studentProfile.CultureModelID = newStudentProfile.CultureModelID;
- studentProfile.IsDreamProject = newStudentProfile.IsDreamProject;
- studentProfile.Country = newStudentProfile.Country;
- studentProfile.Place = newStudentProfile.Place;
- studentProfile.BornPlace = newStudentProfile.BornPlace;
- studentProfile.HealthStateID = newStudentProfile.HealthStateID;
- studentProfile.BloodGroup = newStudentProfile.BloodGroup;
- studentProfile.Specialty = newStudentProfile.Specialty;
- studentProfile.Height = newStudentProfile.Height;
- studentProfile.Weight = newStudentProfile.Weight;
- studentProfile.DirectorName = newStudentProfile.DirectorName;
- this.SetNewStatus(studentProfile);
- newStudentProfileInList.Add(studentProfile);
- }
- else
- {
- studentVerify.CF_StudentProfile.UsedName = newStudentProfile.UsedName;
- studentVerify.CF_StudentProfile.LiteracyLevelID = newStudentProfile.LiteracyLevelID;
- studentVerify.CF_StudentProfile.CultureModelID = newStudentProfile.CultureModelID;
- studentVerify.CF_StudentProfile.IsDreamProject = newStudentProfile.IsDreamProject;
- studentVerify.CF_StudentProfile.Country = newStudentProfile.Country;
- studentVerify.CF_StudentProfile.Place = newStudentProfile.Place;
- studentVerify.CF_StudentProfile.BornPlace = newStudentProfile.BornPlace;
- studentVerify.CF_StudentProfile.HealthStateID = newStudentProfile.HealthStateID;
- studentVerify.CF_StudentProfile.BloodGroup = newStudentProfile.BloodGroup;
- studentVerify.CF_StudentProfile.Specialty = newStudentProfile.Specialty;
- studentVerify.CF_StudentProfile.Height = newStudentProfile.Height;
- studentVerify.CF_StudentProfile.Weight = newStudentProfile.Weight;
- studentVerify.CF_StudentProfile.DirectorName = newStudentProfile.DirectorName;
- this.SetModifyStatus(studentVerify.CF_StudentProfile);
- newStudentProfileUpList.Add(studentVerify.CF_StudentProfile);
- }
- if (studentVerify.CF_StudentContact == null)
- {
- var studentContact = new CF_StudentContact();
- studentContact.UserID = studentVerify.UserID;
- studentContact.Email = newStudentContact.Email;
- studentContact.Telephone = newStudentContact.Email;
- studentContact.Mobile = newStudentContact.Email;
- studentContact.ZIPCode = newStudentContact.ZIPCode;
- studentContact.WeChatNum = newStudentContact.WeChatNum;
- studentContact.QQ = newStudentContact.QQ;
- studentContact.HomeAddress = newStudentContact.HomeAddress;
- studentContact.WorkUnit = newStudentContact.WorkUnit;
- studentContact.Address = newStudentContact.Address;
- studentContact.Recipient = newStudentContact.Recipient;
- studentContact.Dormitory = newStudentContact.Dormitory;
- this.SetNewStatus(studentContact);
- newStudentContactInList.Add(studentContact);
- }
- else
- {
- studentVerify.CF_StudentContact.Email = newStudentContact.Email;
- studentVerify.CF_StudentContact.Telephone = newStudentContact.Telephone;
- studentVerify.CF_StudentContact.Mobile = newStudentContact.Mobile;
- studentVerify.CF_StudentContact.ZIPCode = newStudentContact.ZIPCode;
- studentVerify.CF_StudentContact.WeChatNum = newStudentContact.WeChatNum;
- studentVerify.CF_StudentContact.QQ = newStudentContact.QQ;
- studentVerify.CF_StudentContact.HomeAddress = newStudentContact.HomeAddress;
- studentVerify.CF_StudentContact.WorkUnit = newStudentContact.WorkUnit;
- studentVerify.CF_StudentContact.Address = newStudentContact.Address;
- studentVerify.CF_StudentContact.Recipient = newStudentContact.Recipient;
- studentVerify.CF_StudentContact.Dormitory = newStudentContact.Dormitory;
- this.SetModifyStatus(studentVerify.CF_StudentContact);
- newStudentContactUpList.Add(studentVerify.CF_StudentContact);
- }
- if (studentVerify.CF_StudentAccount == null)
- {
- var studentAccount = new CF_StudentAccount();
- studentAccount.UserID = studentVerify.UserID;
- studentAccount.BankName = newStudentAccount.BankName;
- studentAccount.CardNo = newStudentAccount.CardNo;
- this.SetNewStatus(studentAccount);
- newStudentAccountInList.Add(studentAccount);
- }
- else
- {
- studentVerify.CF_StudentAccount.BankName = newStudentAccount.BankName;
- studentVerify.CF_StudentAccount.CardNo = newStudentAccount.CardNo;
- this.SetModifyStatus(studentVerify.CF_StudentAccount);
- newStudentAccountUpList.Add(studentVerify.CF_StudentAccount);
- }
- if (studentVerify.CF_Recruitstudents == null)
- {
- var recruitstudents = new CF_Recruitstudents();
- recruitstudents.UserID = studentVerify.UserID;
- recruitstudents.ExamineeNum = newRecruitstudents.ExamineeNum;
- recruitstudents.AdmissionTicketNo = newRecruitstudents.AdmissionTicketNo;
- recruitstudents.ExamineeType = newRecruitstudents.ExamineeType;
- recruitstudents.EntranceDate = newRecruitstudents.EntranceDate;
- recruitstudents.Score = newRecruitstudents.Score;
- recruitstudents.EntranceWayID = newRecruitstudents.EntranceWayID;
- recruitstudents.FeaturesID = newRecruitstudents.FeaturesID;
- recruitstudents.TerritorialID = newRecruitstudents.TerritorialID;
- recruitstudents.Area = newRecruitstudents.Area;
- this.SetNewStatus(recruitstudents);
- newRecruitstudentsInList.Add(recruitstudents);
- }
- else
- {
- studentVerify.CF_Recruitstudents.ExamineeNum = newRecruitstudents.ExamineeNum;
- studentVerify.CF_Recruitstudents.AdmissionTicketNo = newRecruitstudents.AdmissionTicketNo;
- studentVerify.CF_Recruitstudents.ExamineeType = newRecruitstudents.ExamineeType;
- studentVerify.CF_Recruitstudents.EntranceDate = newRecruitstudents.EntranceDate;
- studentVerify.CF_Recruitstudents.Score = newRecruitstudents.Score;
- studentVerify.CF_Recruitstudents.EntranceWayID = newRecruitstudents.EntranceWayID;
- studentVerify.CF_Recruitstudents.FeaturesID = newRecruitstudents.FeaturesID;
- studentVerify.CF_Recruitstudents.TerritorialID = newRecruitstudents.TerritorialID;
- studentVerify.CF_Recruitstudents.Area = newRecruitstudents.Area;
- this.SetModifyStatus(studentVerify.CF_Recruitstudents);
- newRecruitstudentsUpList.Add(studentVerify.CF_Recruitstudents);
- }
- upCount++;
- }
- }
- }
- TransactionOptions transactionOption = new TransactionOptions();
- transactionOption.IsolationLevel = System.Transactions.IsolationLevel.Serializable;
- transactionOption.Timeout = new TimeSpan(0, 3, 0);
- using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, transactionOption))
- {
- UnitOfWork.BulkInsert<Sys_User>(newUserInList);
- UnitOfWork.BulkInsert(newUserInList, (x => x.Sys_Role));
- UnitOfWork.BulkInsert<CF_Student>(newStudentInList);
- UnitOfWork.BulkInsert<CF_StudentProfile>(newStudentProfileInList);
- UnitOfWork.BulkInsert<CF_StudentContact>(newStudentContactInList);
- UnitOfWork.BulkInsert<CF_StudentAccount>(newStudentAccountInList);
- UnitOfWork.BulkInsert<CF_Recruitstudents>(newRecruitstudentsInList);
- if (newUserUpList != null && newUserUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newUserUpList);
- }
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentUpList);
- }
- if (newStudentProfileUpList != null && newStudentProfileUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentProfileUpList);
- }
- if (newStudentContactUpList != null && newStudentContactUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentContactUpList);
- }
- if (newStudentAccountUpList != null && newStudentAccountUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentAccountUpList);
- }
- if (newRecruitstudentsUpList != null && newRecruitstudentsUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newRecruitstudentsUpList);
- }
- ts.Complete();
- }
- errdataList = errList.Distinct().ToList(); //错误列表List
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 学生信息新增刷新相关业务处理
- /// </summary>
- /// <param name="userID"></param>
- public void StudentOnAddRefresh(List<Guid> userID)
- {
- throw new NotImplementedException();
- }
- }
- }
|