123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Transactions;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.Utility;
- using Bowin.Common.DataTime;
- using EMIS.Entities;
- using EMIS.Utility;
- using EMIS.ViewModel;
- using EMIS.ViewModel.UniversityManage.TeacherManage;
- using EMIS.ViewModel.SystemManage.UserManage;
- using EMIS.ViewModel.CacheManage;
- using EMIS.DataLogic.UniversityManage.TeacherManage;
- namespace EMIS.CommonLogic.UniversityManage.TeacherManage
- {
- public class StaffServices : BaseServices, IStaffServices
- {
- public Lazy<StaffDAL> staffDAL { get; set; }
- public Lazy<DataTimeHelper> TimeHelper { get; set; }
- /// <summary>
- /// 查询教师信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="departmentID"></param>
- /// <param name="isPhoto"></param>
- /// <param name="teacherTypeID"></param>
- /// <param name="incumbencyState"></param>
- /// <param name="titleID"></param>
- /// <param name="isDualTeacher"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<StaffView> GetStaffViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, Guid? departmentID, int? isPhoto, int? teacherTypeID,
- int? incumbencyState, int? titleID, int? isDualTeacher, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Staff, bool>> expStaff = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (collegeID.HasValue)
- {
- expStaff = expStaff.And(x => x.CollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- expStaff = expStaff.And(x => x.DepartmentID == departmentID);
- }
- if (isPhoto.HasValue)
- {
- if (isPhoto.Value == (int)CF_GeneralExist.Have)
- {
- expStaff = expStaff.And(x => x.PhotoUrl != null && x.PhotoUrl != "");
- }
- if (isPhoto.Value == (int)CF_GeneralExist.No)
- {
- expStaff = expStaff.And(x => x.PhotoUrl == null || x.PhotoUrl == "");
- }
- }
- if (teacherTypeID.HasValue)
- {
- expStaff = expStaff.And(x => x.TeacherTypeID == teacherTypeID);
- }
- if (incumbencyState.HasValue)
- {
- expStaff = expStaff.And(x => x.IncumbencyState == incumbencyState);
- }
- if (titleID.HasValue)
- {
- expStaff = expStaff.And(x => x.TitleID == titleID);
- }
- if (isDualTeacher.HasValue)
- {
- if (isDualTeacher.Value == (int)CF_GeneralPurpose.IsYes)
- {
- expStaff = expStaff.And(x => x.IsDualTeacher == true);
- }
- if (isDualTeacher.Value == (int)CF_GeneralPurpose.IsNo)
- {
- expStaff = expStaff.And(x => x.IsDualTeacher != true);
- }
- }
- var query = staffDAL.Value.GetStaffViewQueryable(expStaff);
- if (campusID.HasValue)
- {
- //校区
- query = query.Where(x => x.CampusID == campusID);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRange(query, x => x.UserID).OrderBy(x => x.StaffCode.Length).ThenBy(x => x.StaffCode)
- .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ToGridResultSet<StaffView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询教师信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="departmentID"></param>
- /// <param name="isPhoto"></param>
- /// <param name="teacherTypeID"></param>
- /// <param name="incumbencyState"></param>
- /// <param name="titleID"></param>
- /// <param name="isDualTeacher"></param>
- /// <returns></returns>
- public IList<StaffView> GetStaffViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, Guid? departmentID, int? isPhoto, int? teacherTypeID,
- int? incumbencyState, int? titleID, int? isDualTeacher)
- {
- Expression<Func<CF_Staff, bool>> expStaff = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (collegeID.HasValue)
- {
- expStaff = expStaff.And(x => x.CollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- expStaff = expStaff.And(x => x.DepartmentID == departmentID);
- }
- if (isPhoto.HasValue)
- {
- if (isPhoto.Value == (int)CF_GeneralExist.Have)
- {
- expStaff = expStaff.And(x => x.PhotoUrl != null && x.PhotoUrl != "");
- }
- if (isPhoto.Value == (int)CF_GeneralExist.No)
- {
- expStaff = expStaff.And(x => x.PhotoUrl == null || x.PhotoUrl == "");
- }
- }
- if (teacherTypeID.HasValue)
- {
- expStaff = expStaff.And(x => x.TeacherTypeID == teacherTypeID);
- }
- if (incumbencyState.HasValue)
- {
- expStaff = expStaff.And(x => x.IncumbencyState == incumbencyState);
- }
- if (titleID.HasValue)
- {
- expStaff = expStaff.And(x => x.TitleID == titleID);
- }
- if (isDualTeacher.HasValue)
- {
- if (isDualTeacher.Value == (int)CF_GeneralPurpose.IsYes)
- {
- expStaff = expStaff.And(x => x.IsDualTeacher == true);
- }
- if (isDualTeacher.Value == (int)CF_GeneralPurpose.IsNo)
- {
- expStaff = expStaff.And(x => x.IsDualTeacher != true);
- }
- }
- var query = staffDAL.Value.GetStaffViewQueryable(expStaff);
- if (campusID.HasValue)
- {
- //校区
- query = query.Where(x => x.CampusID == campusID);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRange(query, x => x.UserID).OrderBy(x => x.StaffCode.Length).ThenBy(x => x.StaffCode)
- .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ToList();
- }
- /// <summary>
- /// 查询教师信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="loginID"></param>
- /// <param name="name"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<StaffView> GetStaffViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, string loginID, string name, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Staff, bool>> expStaff = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (collegeID.HasValue)
- {
- expStaff = expStaff.And(x => x.CollegeID == collegeID);
- }
- if (!string.IsNullOrEmpty(loginID))
- {
- expStaff = expStaff.And(x => x.Sys_User.LoginID.Contains(loginID));
- }
- if (!string.IsNullOrEmpty(name))
- {
- expStaff = expStaff.And(x => x.Sys_User.Name.Contains(name));
- }
- var query = staffDAL.Value.GetStaffViewQueryable(expStaff);
- if (campusID.HasValue)
- {
- //校区
- query = query.Where(x => x.CampusID == campusID);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StaffCode.Length)
- .ThenBy(x => x.StaffCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ToGridResultSet<StaffView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询教师信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="loginID"></param>
- /// <param name="name"></param>
- /// <returns></returns>
- public IList<StaffView> GetStaffViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, string loginID, string name)
- {
- Expression<Func<CF_Staff, bool>> expStaff = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (collegeID.HasValue)
- {
- expStaff = expStaff.And(x => x.CollegeID == collegeID);
- }
- if (!string.IsNullOrEmpty(loginID))
- {
- expStaff = expStaff.And(x => x.Sys_User.LoginID.Contains(loginID));
- }
- if (!string.IsNullOrEmpty(name))
- {
- expStaff = expStaff.And(x => x.Sys_User.Name.Contains(name));
- }
- var query = staffDAL.Value.GetStaffViewQueryable(expStaff);
- if (campusID.HasValue)
- {
- //校区
- query = query.Where(x => x.CampusID == campusID);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StaffCode.Length)
- .ThenBy(x => x.StaffCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ToList();
- }
- /// <summary>
- /// 查询教师信息View(无数据范围)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="departmentID"></param>
- /// <param name="isPhoto"></param>
- /// <param name="teacherTypeID"></param>
- /// <param name="incumbencyState"></param>
- /// <param name="titleID"></param>
- /// <param name="isDualTeacher"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<StaffView> GetStaffViewGridWithNoDataRange(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, Guid? departmentID, int? isPhoto,
- int? teacherTypeID, int? incumbencyState, int? titleID, int? isDualTeacher, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Staff, bool>> expStaff = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (collegeID.HasValue)
- {
- expStaff = expStaff.And(x => x.CollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- expStaff = expStaff.And(x => x.DepartmentID == departmentID);
- }
- if (isPhoto.HasValue)
- {
- if (isPhoto.Value == (int)CF_GeneralExist.Have)
- {
- expStaff = expStaff.And(x => x.PhotoUrl != null && x.PhotoUrl != "");
- }
- if (isPhoto.Value == (int)CF_GeneralExist.No)
- {
- expStaff = expStaff.And(x => x.PhotoUrl == null || x.PhotoUrl == "");
- }
- }
- if (teacherTypeID.HasValue)
- {
- expStaff = expStaff.And(x => x.TeacherTypeID == teacherTypeID);
- }
- if (incumbencyState.HasValue)
- {
- expStaff = expStaff.And(x => x.IncumbencyState == incumbencyState);
- }
- if (titleID.HasValue)
- {
- expStaff = expStaff.And(x => x.TitleID == titleID);
- }
- if (isDualTeacher.HasValue)
- {
- if (isDualTeacher.Value == (int)CF_GeneralPurpose.IsYes)
- {
- expStaff = expStaff.And(x => x.IsDualTeacher == true);
- }
- if (isDualTeacher.Value == (int)CF_GeneralPurpose.IsNo)
- {
- expStaff = expStaff.And(x => x.IsDualTeacher != true);
- }
- }
- var query = staffDAL.Value.GetStaffViewQueryable(expStaff);
- if (campusID.HasValue)
- {
- //校区
- query = query.Where(x => x.CampusID == campusID);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.StaffCode.Length).ThenBy(x => x.StaffCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ToGridResultSet<StaffView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询教师信息List(无数据范围)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="departmentID"></param>
- /// <param name="isPhoto"></param>
- /// <param name="teacherTypeID"></param>
- /// <param name="incumbencyState"></param>
- /// <param name="titleID"></param>
- /// <param name="isDualTeacher"></param>
- /// <returns></returns>
- public IList<StaffView> GetStaffViewListWithNoDataRange(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, Guid? departmentID, int? isPhoto,
- int? teacherTypeID, int? incumbencyState, int? titleID, int? isDualTeacher)
- {
- Expression<Func<CF_Staff, bool>> expStaff = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (collegeID.HasValue)
- {
- expStaff = expStaff.And(x => x.CollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- expStaff = expStaff.And(x => x.DepartmentID == departmentID);
- }
- if (isPhoto.HasValue)
- {
- if (isPhoto.Value == (int)CF_GeneralExist.Have)
- {
- expStaff = expStaff.And(x => x.PhotoUrl != null && x.PhotoUrl != "");
- }
- if (isPhoto.Value == (int)CF_GeneralExist.No)
- {
- expStaff = expStaff.And(x => x.PhotoUrl == null || x.PhotoUrl == "");
- }
- }
- if (teacherTypeID.HasValue)
- {
- expStaff = expStaff.And(x => x.TeacherTypeID == teacherTypeID);
- }
- if (incumbencyState.HasValue)
- {
- expStaff = expStaff.And(x => x.IncumbencyState == incumbencyState);
- }
- if (titleID.HasValue)
- {
- expStaff = expStaff.And(x => x.TitleID == titleID);
- }
- if (isDualTeacher.HasValue)
- {
- if (isDualTeacher.Value == (int)CF_GeneralPurpose.IsYes)
- {
- expStaff = expStaff.And(x => x.IsDualTeacher == true);
- }
- if (isDualTeacher.Value == (int)CF_GeneralPurpose.IsNo)
- {
- expStaff = expStaff.And(x => x.IsDualTeacher != true);
- }
- }
- var query = staffDAL.Value.GetStaffViewQueryable(expStaff);
- if (campusID.HasValue)
- {
- //校区
- query = query.Where(x => x.CampusID == campusID);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.StaffCode.Length).ThenBy(x => x.StaffCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ToList();
- }
- /// <summary>
- /// 查询教师信息StaffView(全部)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<StaffView> GetAllStaffView(ConfiguretView configuretView, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Staff, bool>> expStaff = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = staffDAL.Value.GetStaffViewQueryable(expStaff);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.StaffCode.Length).ThenBy(x => x.StaffCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ToGridResultSet<StaffView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询教师信息List(全部)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <returns></returns>
- public IList<StaffView> GetAllStaffList(ConfiguretView configuretView)
- {
- Expression<Func<CF_Staff, bool>> expStaff = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = staffDAL.Value.GetStaffViewQueryable(expStaff);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.StaffCode.Length).ThenBy(x => x.StaffCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ToList();
- }
- /// <summary>
- /// 查询对应的教师信息StaffView(全部)
- /// </summary>
- /// <returns></returns>
- public List<StaffView> GetListStaffView()
- {
- Expression<Func<CF_Staff, bool>> expStaff = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = staffDAL.Value.GetStaffViewQueryable(expStaff);
- return query.OrderBy(x => x.StaffCode.Length).ThenBy(x => x.StaffCode).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ToList();
- }
- /// <summary>
- /// 查询对应的教师信息CF_Staff(全部)
- /// </summary>
- /// <returns></returns>
- public List<CF_Staff> GetStaffList()
- {
- Expression<Func<CF_Staff, bool>> expStaff = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var query = staffDAL.Value.staffRepository.GetList(expStaff);
- return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.Sys_User.LoginID.Length).ThenBy(x => x.Sys_User.LoginID).ToList();
- }
- /// <summary>
- /// 查询对应的教师信息CF_Staff
- /// </summary>
- /// <param name="userID"></param>
- /// <returns></returns>
- public CF_Staff GetStaff(Guid? userID)
- {
- try
- {
- Expression<Func<CF_Staff, bool>> expStaff = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expStaff = expStaff.And(x => x.UserID == userID);
- var query = staffDAL.Value.staffRepository.GetList(expStaff, (x => x.CF_StaffManageCampus), (x => x.CF_StaffManageCollege), (x => x.CF_StaffManageDepartment), (x => x.CF_StaffProfile), (x => x.Sys_User)).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询对应的教师信息CF_StaffProfile
- /// </summary>
- /// <param name="userID"></param>
- /// <returns></returns>
- public CF_StaffProfile GetStaffProfile(Guid? userID)
- {
- try
- {
- Expression<Func<CF_StaffProfile, bool>> expStaffProfile = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expStaffProfile = expStaffProfile.And(x => x.UserID == userID);
- var query = staffDAL.Value.staffProfileRepository.GetList(expStaffProfile).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询对应的教师信息CF_Staff
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public CF_Staff GetStaff(Expression<Func<CF_Staff, bool>> exp)
- {
- try
- {
- return staffDAL.Value.staffRepository.GetSingle(exp);
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询对应的教师信息StaffView
- /// </summary>
- /// <param name="userID"></param>
- /// <returns></returns>
- public StaffView GetStaffView(Guid? userID)
- {
- try
- {
- var query = staffDAL.Value.GetStaffViewQueryable(x => x.UserID == userID).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询对应的教师信息StaffView
- /// </summary>
- /// <param name="exp"></param>
- /// <returns></returns>
- public StaffView GetStaffView(Expression<Func<CF_Staff, bool>> exp)
- {
- try
- {
- var query = staffDAL.Value.GetStaffViewQueryable(exp).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询对应的教师信息List
- /// </summary>
- /// <param name="userID"></param>
- /// <returns></returns>
- public List<StaffView> GetListStaffView(Guid? userID)
- {
- Expression<Func<CF_Staff, bool>> expStaff = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expStaff = expStaff.And(x => x.UserID == userID);
- var query = staffDAL.Value.GetStaffViewQueryable(expStaff);
- return query.OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenBy(x => x.StaffCode.Length).ThenBy(x => x.StaffCode).ToList();
- }
- /// <summary>
- /// 编辑(新增、修改,业务主键:教职工号或证件号码)
- /// </summary>
- /// <param name="staffView"></param>
- /// <param name="photoUrl"></param>
- public void StaffEdit(StaffView staffView, string photoUrl)
- {
- try
- {
- var userVerify = staffDAL.Value.UserRepository.GetList(x => x.UserID != staffView.UserID && x.LoginID == staffView.StaffCode).SingleOrDefault();
- if (userVerify == null)
- {
- if (!string.IsNullOrEmpty(staffView.CertificatesNum))
- {
- var staffVerify = staffDAL.Value.staffRepository.GetList(x => x.UserID != staffView.UserID && x.CertificatesNum == staffView.CertificatesNum).SingleOrDefault();
- if (staffVerify != null)
- {
- throw new Exception("已存在相同的证件号码(证件号码重复),请核查。");
- }
- }
- var college = staffDAL.Value.CollegeRepository.GetList(x => x.CollegeID == staffView.CollegeID).SingleOrDefault();
- if (staffView.DepartmentID.HasValue)
- {
- var department = staffDAL.Value.DepartmentRepository.GetList(x => x.DepartmentID == staffView.DepartmentID).SingleOrDefault();
- if (department.CollegeID != staffView.CollegeID)
- {
- throw new Exception("所属教研室和" + RSL.Get("College") + "不匹配,请核查。");
- }
- }
- var teacherInitPassword = staffDAL.Value.ParameterRepository.GetList(x => x.ParameterTypeID == (int)CF_ParameterType.TeacherInitPassword).SingleOrDefault();
- var teacherRoleList = staffDAL.Value.RoleRepository.GetList(x => x.TypeID == (int)SYS_RoleType.Teacher && x.RoleName.Contains("教师")).ToList();
- List<Sys_User> newUserInList = new List<Sys_User>();
- List<Sys_User> newUserUpList = new List<Sys_User>();
- List<CF_Staff> newStaffInList = new List<CF_Staff>();
- List<CF_Staff> newStaffUpList = new List<CF_Staff>();
- List<CF_StaffProfile> newStaffProfileInList = new List<CF_StaffProfile>();
- List<CF_StaffProfile> newStaffProfileUpList = new List<CF_StaffProfile>();
- List<CF_StaffManageCampus> newStaffManageCampusInList = new List<CF_StaffManageCampus>();
- List<CF_StaffManageCollege> newStaffManageCollegeInList = new List<CF_StaffManageCollege>();
- List<CF_StaffManageDepartment> newStaffManageDepartmentInList = new List<CF_StaffManageDepartment>();
- List<Guid?> CampusUserIDDelList = new List<Guid?>();
- List<Guid?> CollegeUserIDDelList = new List<Guid?>();
- List<Guid?> DepartmentUserIDDelList = new List<Guid?>();
- if (staffView.UserID != Guid.Empty)
- {
- //表示修改
- var staff = staffDAL.Value.staffRepository.GetList(x => x.UserID == staffView.UserID, (x => x.CF_StaffManageCampus), (x => x.CF_StaffManageCollege),
- (x => x.CF_StaffManageDepartment), (x => x.CF_StaffProfile), (x => x.Sys_User)).SingleOrDefault();
- if (staff == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- else
- {
- staff.Sys_User.LoginID = staffView.StaffCode.Trim();
- staff.Sys_User.Name = staffView.Name.Trim();
- this.SetModifyStatus(staff.Sys_User);
- newUserUpList.Add(staff.Sys_User);
- staff.StaffCode = staffView.StaffCode.Trim();
- if (staff.CollegeID != staffView.CollegeID)
- {
- CampusUserIDDelList.Add(staffView.UserID);
- var staffManageCampus = new CF_StaffManageCampus();
- staffManageCampus.StaffManageCampusID = Guid.NewGuid();
- staffManageCampus.UserID = staffView.UserID;
- staffManageCampus.CampusID = college.CampusID;
- this.SetNewStatus(staffManageCampus);
- newStaffManageCampusInList.Add(staffManageCampus);
- CollegeUserIDDelList.Add(staffView.UserID);
- var staffManageCollege = new CF_StaffManageCollege();
- staffManageCollege.StaffManageCollegeID = Guid.NewGuid();
- staffManageCollege.UserID = staffView.UserID;
- staffManageCollege.CollegeID = staffView.CollegeID;
- this.SetNewStatus(staffManageCollege);
- newStaffManageCollegeInList.Add(staffManageCollege);
- DepartmentUserIDDelList.Add(staffView.UserID);
- if (staffView.DepartmentID.HasValue && staffView.DepartmentID != Guid.Empty)
- {
- var staffManageDepartment = new CF_StaffManageDepartment();
- staffManageDepartment.StaffManageDepartmentID = Guid.NewGuid();
- staffManageDepartment.UserID = staffView.UserID;
- staffManageDepartment.DepartmentID = staffView.DepartmentID;
- this.SetNewStatus(staffManageDepartment);
- newStaffManageDepartmentInList.Add(staffManageDepartment);
- }
- }
- else
- {
- if (staff.CF_StaffManageCampus.Count() <= 0 || staff.CF_StaffManageCampus == null)
- {
- var staffManageCampus = new CF_StaffManageCampus();
- staffManageCampus.StaffManageCampusID = Guid.NewGuid();
- staffManageCampus.UserID = staffView.UserID;
- staffManageCampus.CampusID = college.CampusID;
- this.SetNewStatus(staffManageCampus);
- newStaffManageCampusInList.Add(staffManageCampus);
- }
- if (staff.CF_StaffManageCollege.Count() <= 0 || staff.CF_StaffManageCollege == null)
- {
- var staffManageCollege = new CF_StaffManageCollege();
- staffManageCollege.StaffManageCollegeID = Guid.NewGuid();
- staffManageCollege.UserID = staffView.UserID;
- staffManageCollege.CollegeID = staffView.CollegeID;
- this.SetNewStatus(staffManageCollege);
- newStaffManageCollegeInList.Add(staffManageCollege);
- }
- if (staff.DepartmentID != staffView.DepartmentID)
- {
- DepartmentUserIDDelList.Add(staffView.UserID);
- if (staffView.DepartmentID.HasValue && staffView.DepartmentID != Guid.Empty)
- {
- var staffManageDepartment = new CF_StaffManageDepartment();
- staffManageDepartment.StaffManageDepartmentID = Guid.NewGuid();
- staffManageDepartment.UserID = staffView.UserID;
- staffManageDepartment.DepartmentID = staffView.DepartmentID;
- this.SetNewStatus(staffManageDepartment);
- newStaffManageDepartmentInList.Add(staffManageDepartment);
- }
- }
- else
- {
- if (staff.CF_StaffManageDepartment.Count() <= 0 || staff.CF_StaffManageDepartment == null)
- {
- if (staffView.DepartmentID.HasValue && staffView.DepartmentID != Guid.Empty)
- {
- var staffManageDepartment = new CF_StaffManageDepartment();
- staffManageDepartment.StaffManageDepartmentID = Guid.NewGuid();
- staffManageDepartment.UserID = staffView.UserID;
- staffManageDepartment.DepartmentID = staffView.DepartmentID;
- this.SetNewStatus(staffManageDepartment);
- newStaffManageDepartmentInList.Add(staffManageDepartment);
- }
- }
- }
- }
- staff.CollegeID = staffView.CollegeID;
- staff.DepartmentID = staffView.DepartmentID;
- staff.SexID = staffView.SexID;
- staff.BirthDate = staffView.BirthDate;
- staff.NationID = staffView.NationID;
- staff.PoliticsID = staffView.PoliticsID;
- staff.CertificatesType = staffView.CertificatesType;
- staff.CertificatesNum = staffView.CertificatesNum;
- staff.TeacherTypeID = staffView.TeacherTypeID;
- staff.IncumbencyState = staffView.IncumbencyState;
- staff.SituationID = staffView.SituationID;
- staff.TitleID = staffView.TitleID;
- staff.LiteracyLevelID = staffView.LiteracyLevelID;
- staff.LearnPositionID = staffView.LearnPositionID;
- staff.IsDualTeacher = staffView.IsDualTeacher;
- staff.PaymentLevelID = staffView.PaymentLevelID;
- staff.WorkDate = staffView.WorkDate;
- staff.ComeSchoolDate = staffView.ComeSchoolDate;
- if (!string.IsNullOrEmpty(photoUrl))
- {
- staff.PhotoUrl = photoUrl;
- }
- staff.Profile = staffView.Profile;
- staff.Remark = staffView.Remark;
- this.SetModifyStatus(staff);
- newStaffUpList.Add(staff);
- if (staff.CF_StaffProfile == null)
- {
- var staffProfile = new CF_StaffProfile();
- staffProfile.UserID = staff.UserID;
- staffProfile.UsedName = staffView.UsedName;
- staffProfile.Nationality = staffView.Nationality;
- staffProfile.Place = staffView.Place;
- staffProfile.Email = staffView.Email;
- staffProfile.ZIPCode = staffView.ZIPCode;
- staffProfile.WeChatNum = staffView.WeChatNum;
- staffProfile.QQ = staffView.QQ;
- staffProfile.Telephone = staffView.Telephone;
- staffProfile.OfficeTelephone = staffView.OfficeTelephone;
- staffProfile.HousePhone = staffView.HousePhone;
- staffProfile.Mobile = staffView.Mobile;
- staffProfile.Speciality = staffView.Speciality;
- staffProfile.HealthStateID = staffView.HealthStateID;
- staffProfile.ReligionID = staffView.ReligionID;
- staffProfile.Account = staffView.Account;
- staffProfile.Residence = staffView.Residence;
- staffProfile.HomeAddress = staffView.HomeAddress;
- staffProfile.Address = staffView.Address;
- staffProfile.NowAddress = staffView.NowAddress;
- this.SetNewStatus(staffProfile);
- newStaffProfileInList.Add(staffProfile);
- }
- else
- {
- staff.CF_StaffProfile.UsedName = staffView.UsedName;
- staff.CF_StaffProfile.Nationality = staffView.Nationality;
- staff.CF_StaffProfile.Place = staffView.Place;
- staff.CF_StaffProfile.Email = staffView.Email;
- staff.CF_StaffProfile.ZIPCode = staffView.ZIPCode;
- staff.CF_StaffProfile.WeChatNum = staffView.WeChatNum;
- staff.CF_StaffProfile.QQ = staffView.QQ;
- staff.CF_StaffProfile.Telephone = staffView.Telephone;
- staff.CF_StaffProfile.OfficeTelephone = staffView.OfficeTelephone;
- staff.CF_StaffProfile.HousePhone = staffView.HousePhone;
- staff.CF_StaffProfile.Mobile = staffView.Mobile;
- staff.CF_StaffProfile.Speciality = staffView.Speciality;
- staff.CF_StaffProfile.HealthStateID = staffView.HealthStateID;
- staff.CF_StaffProfile.ReligionID = staffView.ReligionID;
- staff.CF_StaffProfile.Account = staffView.Account;
- staff.CF_StaffProfile.Residence = staffView.Residence;
- staff.CF_StaffProfile.HomeAddress = staffView.HomeAddress;
- staff.CF_StaffProfile.Address = staffView.Address;
- staff.CF_StaffProfile.NowAddress = staffView.NowAddress;
- this.SetModifyStatus(staff.CF_StaffProfile);
- newStaffProfileUpList.Add(staff.CF_StaffProfile);
- }
- }
- }
- else
- {
- //表示新增
- var newUser = new Sys_User();
- newUser.UserID = Guid.NewGuid();
- newUser.LoginID = staffView.StaffCode.Trim();
- newUser.Name = staffView.Name.Trim();
- if (teacherInitPassword == null)
- {
- newUser.Password = ("A" + staffView.StaffCode.Trim()).MD5();
- }
- else
- {
- if (teacherInitPassword.Value != null)
- {
- newUser.Password = teacherInitPassword.Value;
- }
- else
- {
- newUser.Password = ("A" + staffView.StaffCode.Trim()).MD5();
- }
- }
- this.SetNewStatus(newUser, (int)SYS_STATUS.USABLE);
- newUserInList.Add(newUser);
- newUser.Sys_Role = new HashSet<Sys_Role>();
- if (teacherRoleList != null && teacherRoleList.Count() > 0)
- {
- teacherRoleList.ForEach(x => newUser.Sys_Role.Add(x));
- }
- else
- {
- //对应角色为空时,默认为不分配用户角色
- }
- var newStaff = new CF_Staff();
- newStaff.UserID = newUser.UserID;
- newStaff.StaffCode = staffView.StaffCode.Trim();
- newStaff.CollegeID = staffView.CollegeID;
- var staffManageCampus = new CF_StaffManageCampus();
- staffManageCampus.StaffManageCampusID = Guid.NewGuid();
- staffManageCampus.UserID = newStaff.UserID;
- staffManageCampus.CampusID = college.CampusID;
- this.SetNewStatus(staffManageCampus);
- newStaffManageCampusInList.Add(staffManageCampus);
- var staffManageCollege = new CF_StaffManageCollege();
- staffManageCollege.StaffManageCollegeID = Guid.NewGuid();
- staffManageCollege.UserID = newStaff.UserID;
- staffManageCollege.CollegeID = staffView.CollegeID;
- this.SetNewStatus(staffManageCollege);
- newStaffManageCollegeInList.Add(staffManageCollege);
- newStaff.DepartmentID = staffView.DepartmentID;
- if (staffView.DepartmentID.HasValue && staffView.DepartmentID != Guid.Empty)
- {
- var staffManageDepartment = new CF_StaffManageDepartment();
- staffManageDepartment.StaffManageDepartmentID = Guid.NewGuid();
- staffManageDepartment.UserID = newStaff.UserID;
- staffManageDepartment.DepartmentID = staffView.DepartmentID;
- this.SetNewStatus(staffManageDepartment);
- newStaffManageDepartmentInList.Add(staffManageDepartment);
- }
- newStaff.SexID = staffView.SexID;
- newStaff.BirthDate = staffView.BirthDate;
- newStaff.NationID = staffView.NationID;
- newStaff.PoliticsID = staffView.PoliticsID;
- newStaff.CertificatesType = staffView.CertificatesType;
- newStaff.CertificatesNum = staffView.CertificatesNum;
- newStaff.TeacherTypeID = staffView.TeacherTypeID;
- newStaff.IncumbencyState = staffView.IncumbencyState;
- newStaff.SituationID = staffView.SituationID;
- newStaff.TitleID = staffView.TitleID;
- newStaff.LiteracyLevelID = staffView.LiteracyLevelID;
- newStaff.LearnPositionID = staffView.LearnPositionID;
- newStaff.IsDualTeacher = staffView.IsDualTeacher;
- newStaff.PaymentLevelID = staffView.PaymentLevelID;
- newStaff.WorkDate = staffView.WorkDate;
- newStaff.ComeSchoolDate = staffView.ComeSchoolDate;
- if (!string.IsNullOrEmpty(photoUrl))
- {
- newStaff.PhotoUrl = photoUrl;
- }
- newStaff.Profile = staffView.Profile;
- newStaff.Remark = staffView.Remark;
- this.SetNewStatus(newStaff);
- newStaffInList.Add(newStaff);
- var newStaffProfile = new CF_StaffProfile();
- newStaffProfile.UserID = newStaff.UserID;
- newStaffProfile.UsedName = staffView.UsedName;
- newStaffProfile.Nationality = staffView.Nationality;
- newStaffProfile.Place = staffView.Place;
- newStaffProfile.Email = staffView.Email;
- newStaffProfile.ZIPCode = staffView.ZIPCode;
- newStaffProfile.WeChatNum = staffView.WeChatNum;
- newStaffProfile.QQ = staffView.QQ;
- newStaffProfile.Telephone = staffView.Telephone;
- newStaffProfile.OfficeTelephone = staffView.OfficeTelephone;
- newStaffProfile.HousePhone = staffView.HousePhone;
- newStaffProfile.Mobile = staffView.Mobile;
- newStaffProfile.Speciality = staffView.Speciality;
- newStaffProfile.HealthStateID = staffView.HealthStateID;
- newStaffProfile.ReligionID = staffView.ReligionID;
- newStaffProfile.Account = staffView.Account;
- newStaffProfile.Residence = staffView.Residence;
- newStaffProfile.HomeAddress = staffView.HomeAddress;
- newStaffProfile.Address = staffView.Address;
- newStaffProfile.NowAddress = staffView.NowAddress;
- this.SetNewStatus(newStaffProfile);
- newStaffProfileInList.Add(newStaffProfile);
- }
- using (TransactionScope ts = new TransactionScope())
- {
- UnitOfWork.Delete<CF_StaffManageDepartment>(x => DepartmentUserIDDelList.Contains(x.UserID));
- UnitOfWork.Delete<CF_StaffManageCollege>(x => CollegeUserIDDelList.Contains(x.UserID));
- UnitOfWork.Delete<CF_StaffManageCampus>(x => CampusUserIDDelList.Contains(x.UserID));
- UnitOfWork.BulkInsert<Sys_User>(newUserInList);
- UnitOfWork.BulkInsert(newUserInList, (x => x.Sys_Role));
- UnitOfWork.BulkInsert<CF_Staff>(newStaffInList);
- UnitOfWork.BulkInsert<CF_StaffProfile>(newStaffProfileInList);
- UnitOfWork.BulkInsert<CF_StaffManageCampus>(newStaffManageCampusInList);
- UnitOfWork.BulkInsert<CF_StaffManageCollege>(newStaffManageCollegeInList);
- UnitOfWork.BulkInsert<CF_StaffManageDepartment>(newStaffManageDepartmentInList);
- if (newUserUpList != null && newUserUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newUserUpList);
- }
- if (newStaffUpList != null && newStaffUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStaffUpList);
- }
- if (newStaffProfileUpList != null && newStaffProfileUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStaffProfileUpList);
- }
- ts.Complete();
- }
- }
- else
- {
- var staffVerify = staffDAL.Value.staffRepository.GetList(x => x.UserID != staffView.UserID, (x => x.Sys_User)).Where(x => x.Sys_User.LoginID == staffView.StaffCode.Trim()).SingleOrDefault();
- if (staffVerify != null)
- {
- throw new Exception("已存在相同的教职工号(教职工号重复),请核查。");
- }
- else
- {
- var studentVerify = staffDAL.Value.StudentRepository.GetList(x => x.UserID != staffView.UserID,
- (x => x.Sys_User)).Where(x => x.Sys_User.LoginID == staffView.StaffCode.Trim()).SingleOrDefault();
- if (studentVerify != 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 StaffDelete(List<Guid?> userIDs)
- {
- try
- {
- UnitOfWork.Remove<CF_StaffManageDepartment>(x => userIDs.Contains(x.UserID));
- UnitOfWork.Remove<CF_StaffManageCollege>(x => userIDs.Contains(x.UserID));
- UnitOfWork.Remove<CF_StaffManageCampus>(x => userIDs.Contains(x.UserID));
- UnitOfWork.Remove<CF_StaffProfile>(x => userIDs.Contains(x.UserID));
- UnitOfWork.Remove<CF_Staff>(x => userIDs.Contains(x.UserID));
- var userList = staffDAL.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>
- /// 验证
- /// </summary>
- /// <param name="collegeID"></param>
- /// <param name="departmentID"></param>
- /// <returns></returns>
- public bool GetVerification(Guid? collegeID, Guid? departmentID)
- {
- try
- {
- var college = staffDAL.Value.CollegeRepository.GetList(x => x.CollegeID == collegeID).SingleOrDefault();
- if (departmentID.HasValue)
- {
- var department = staffDAL.Value.DepartmentRepository.GetList(x => x.DepartmentID == departmentID).SingleOrDefault();
- if (department.CollegeID != collegeID)
- {
- return false;
- }
- }
- return true;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除照片(单个删除)
- /// </summary>
- /// <param name="userID"></param>
- public void DeletePhoto(Guid? userID)
- {
- try
- {
- var staff = staffDAL.Value.staffRepository.GetList(x => x.UserID == userID).SingleOrDefault();
- if (staff != null)
- {
- if (!string.IsNullOrEmpty(staff.PhotoUrl))
- {
- FileUploadHelper.DeleteFile(staff.PhotoUrl);
- staff.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_Staff> staffUpList = new List<CF_Staff>();
- var staffList = staffDAL.Value.staffRepository.GetList(x => userIDs.Contains(x.UserID)).ToList();
- foreach (var staff in staffList)
- {
- if (staff != null)
- {
- if (!string.IsNullOrEmpty(staff.PhotoUrl))
- {
- photoUrlList.Add(staff.PhotoUrl);
- staff.PhotoUrl = null;
- staffUpList.Add(staff);
- }
- }
- }
- using (TransactionScope ts = new TransactionScope())
- {
- foreach (var photoUrl in photoUrlList)
- {
- FileUploadHelper.DeleteFile(photoUrl);
- }
- if (staffUpList != null && staffUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(staffUpList);
- }
- ts.Complete();
- }
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 查询教师对应的角色信息UserView
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="userID"></param>
- /// <param name="roleID"></param>
- /// <param name="dataRange"></param>
- /// <param name="roleStatus"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<UserView> GetRoleListViewGrid(ConfiguretView configuretView, Guid? userID, Guid? roleID, int? dataRange, int? roleStatus, int pageIndex, int pageSize)
- {
- Expression<Func<CF_Staff, bool>> expStaff = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expStaff = expStaff.And(x => x.UserID == userID);
- var query = staffDAL.Value.GetStaffRoleViewQueryable(expStaff);
- if (roleID.HasValue)
- {
- query = query.Where(x => x.RoleID == roleID);
- }
- if (dataRange.HasValue)
- {
- query = query.Where(x => x.DataRange == dataRange);
- }
- if (roleStatus.HasValue)
- {
- query = query.Where(x => x.RoleStatus == roleStatus);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.LoginID.Length).ThenBy(x => x.LoginID).ThenBy(x => x.RoleOrderNo).ToGridResultSet<UserView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询教师对应的角色信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="userID"></param>
- /// <param name="roleID"></param>
- /// <param name="dataRange"></param>
- /// <param name="roleStatus"></param>
- /// <returns></returns>
- public IList<UserView> GetRoleListViewList(ConfiguretView configuretView, Guid? userID, Guid? roleID, int? dataRange, int? roleStatus)
- {
- Expression<Func<CF_Staff, bool>> expStaff = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expStaff = expStaff.And(x => x.UserID == userID);
- var query = staffDAL.Value.GetStaffRoleViewQueryable(expStaff);
- if (roleID.HasValue)
- {
- query = query.Where(x => x.RoleID == roleID);
- }
- if (dataRange.HasValue)
- {
- query = query.Where(x => x.DataRange == dataRange);
- }
- if (roleStatus.HasValue)
- {
- query = query.Where(x => x.RoleStatus == roleStatus);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.LoginID.Length).ThenBy(x => x.LoginID).ThenBy(x => x.RoleOrderNo).ToList();
- }
- /// <summary>
- /// 导入照片
- /// </summary>
- /// <param name="photoPaths"></param>
- /// <param name="importPicType"></param>
- public void StaffPicImport(IList<string> photoPaths, string importPicType)
- {
- List<CF_Staff> staffUpList = new List<CF_Staff>();
- var mapList = photoPaths.Select(s => new
- {
- PhotoName = Path.GetFileNameWithoutExtension(s).Trim(),
- PhotoPath = s,
- }).ToArray();
- var photoNameList = mapList.Select(s => s.PhotoName).Distinct().ToArray();
- var userList = new List<Sys_User>();
- var staffList = new List<CF_Staff>();
- switch (importPicType)
- {
- case "StaffCode":
- userList = staffDAL.Value.UserRepository.GetList(x => photoNameList.Contains(x.LoginID), (x => x.CF_Staff)).ToList();
- break;
- case "IDNumber":
- staffList = staffDAL.Value.staffRepository.GetList(x => photoNameList.Contains(x.CertificatesNum)).ToList();
- break;
- }
- foreach (var map in mapList)
- {
- switch (importPicType)
- {
- case "StaffCode":
- var user = userList.FirstOrDefault(w => w.LoginID == map.PhotoName);
- if (user == null)
- {
- throw new Exception("导入照片中存在无法匹对信息(名称:" + map.PhotoName + "-教职工号)" + ",请检查。");
- }
- else
- {
- if (user.CF_Staff == null)
- {
- throw new Exception("导入照片中存在无法匹对信息(名称:" + map.PhotoName + "-教职工号)" + ",请检查。");
- }
- else
- {
- user.CF_Staff.PhotoUrl = map.PhotoPath;
- staffUpList.Add(user.CF_Staff);
- }
- }
- break;
- case "IDNumber":
- var staff = staffList.FirstOrDefault(w => w.CertificatesNum == map.PhotoName);
- if (staff == null)
- {
- throw new Exception("导入照片中存在无法匹对信息(名称:" + map.PhotoName + "-证件号码)" + ",请检查。");
- }
- else
- {
- staff.PhotoUrl = map.PhotoPath;
- staffUpList.Add(staff);
- }
- break;
- }
- }
- if (staffUpList != null && staffUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(staffUpList);
- }
- }
- /// <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 StaffImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount, out List<StaffView> errdataList, out int? errCount, string sourcePhysicalPath)
- {
- try
- {
- StringBuilder errorMsg = new StringBuilder();
- List<StaffView> errList = new List<StaffView>();
- cellheader.Remove("ErrorMessage");
- List<StaffView> enlist = NpoiExcelHelper.ExcelToEntityList<StaffView>(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 = ""; //错误信息
- var teacherInitPassword = staffDAL.Value.ParameterRepository.GetList(x => x.ParameterTypeID == (int)CF_ParameterType.TeacherInitPassword).SingleOrDefault();
- var teacherRoleList = staffDAL.Value.RoleRepository.GetList(x => x.TypeID == (int)SYS_RoleType.Teacher && x.RoleName.Contains("教师")).ToList();
- List<Sys_User> newUserInList = new List<Sys_User>();
- List<Sys_User> newUserUpList = new List<Sys_User>();
- List<CF_Staff> newStaffInList = new List<CF_Staff>();
- List<CF_Staff> newStaffUpList = new List<CF_Staff>();
- List<CF_StaffProfile> newStaffProfileInList = new List<CF_StaffProfile>();
- List<CF_StaffProfile> newStaffProfileUpList = new List<CF_StaffProfile>();
- List<CF_StaffManageCampus> newStaffManageCampusInList = new List<CF_StaffManageCampus>();
- List<CF_StaffManageCollege> newStaffManageCollegeInList = new List<CF_StaffManageCollege>();
- List<CF_StaffManageDepartment> newStaffManageDepartmentInList = new List<CF_StaffManageDepartment>();
- List<Guid?> CampusUserIDDelList = new List<Guid?>();
- List<Guid?> CollegeUserIDDelList = new List<Guid?>();
- List<Guid?> DepartmentUserIDDelList = new List<Guid?>();
- //将循环中相关数据库查询统一查询出来进行匹配(尽量避免在循环中进行数据库查询)
- //用户信息
- var userList = staffDAL.Value.UserRepository.GetList(x => true).ToList();
- //教职工号
- var staffCodeList = enlist.Where(x => !string.IsNullOrEmpty(x.StaffCode)).Select(x => x.StaffCode.Trim()).ToList();
- //对比后的newUserList
- var newUserList = userList.Where(x => staffCodeList.Contains(x.LoginID)).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 certificatesTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CertificatesType).ToList();
- //教师类型
- var teacherTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_TeacherType).ToList();
- //在职状态
- var incumbencyStateList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_IncumbencyState).ToList();
- //任课状况
- var situationList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Situation).ToList();
- //职称
- var titleList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Title).ToList();
- //文化程度
- var literacyLevelList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_LiteracyLevel).ToList();
- //学位
- var learnPositionList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_LearnPosition).ToList();
- //是否
- var generalPurposeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_GeneralPurpose).ToList();
- //课酬级别
- var paymentLevelList = IdNameExt.GetDictionaryItem(DictionaryItem.TP_PaymentLevel).ToList();
- //健康状况
- var healthStateList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_HealthState).ToList();
- //宗教信仰
- var religionList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Religion).ToList();
- //院系所信息
- var collegeList = staffDAL.Value.CollegeRepository.GetList(x => true).ToList();
- //院系所
- var collegeNameList = enlist.Where(x => !string.IsNullOrEmpty(x.CollegeName)).Select(x => x.CollegeName.Trim()).ToList();
- //对比后的newCollegeList
- var newCollegeList = collegeList.Where(x => collegeNameList.Contains(x.Name)).ToList();
- //教研室信息
- var departmentList = staffDAL.Value.DepartmentRepository.GetList(x => true).ToList();
- //所属教研室
- var departmentNameList = enlist.Where(x => !string.IsNullOrEmpty(x.DepartmentName)).Select(x => x.DepartmentName.Trim()).ToList();
- //对比后的newDepartmentList
- var newDepartmentList = departmentList.Where(x => departmentNameList.Contains(x.Name)).ToList();
- //证件号码
- var certificatesNumList = enlist.Where(x => !string.IsNullOrEmpty(x.CertificatesNum)).Select(x => x.CertificatesNum.Trim()).ToList();
- //教师信息
- var staffList = staffDAL.Value.staffRepository.GetList(x => true, (x => x.CF_StaffManageDepartment), (x => x.CF_StaffManageCollege),
- (x => x.CF_StaffManageCampus), (x => x.CF_StaffProfile), (x => x.Sys_User)).ToList();
- //对比后的certificatesNumStaffList
- var certificatesNumStaffList = staffList.Where(x => certificatesNumList.Contains(x.CertificatesNum)).ToList();
- //对比后的newUserIDList
- var newUserIDList = newUserList.Select(x => x.UserID).ToList();
- //对比后的newStaffList
- var newStaffList = staffList.Where(x => newUserIDList.Contains(x.UserID)).ToList();
- //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等)
- for (int i = 0; i < enlist.Count; i++)
- {
- StaffView en = enlist[i]; //Excel表数据视图
- Sys_User newUser = new Sys_User();
- CF_Staff newStaff = new CF_Staff();
- CF_StaffProfile newStaffProfile = new CF_StaffProfile();
- //教职工号
- if (string.IsNullOrWhiteSpace(en.StaffCode))
- {
- 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.StaffCode.Trim()))
- {
- errCount++;
- errorMsgStr = "教职工号格式不正确,请检查(数字或英文字母)";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newUser.LoginID = en.StaffCode.Trim();
- newStaff.StaffCode = en.StaffCode.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
- {
- newStaffProfile.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
- {
- newStaff.SexID = sex.Value;
- }
- }
- //出生日期
- if (string.IsNullOrWhiteSpace(en.BirthDateStr))
- {
- //暂不考虑
- }
- 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
- {
- newStaff.BirthDate = Convert.ToDateTime(en.BirthDateStr);
- }
- }
- //民族
- if (string.IsNullOrWhiteSpace(en.NationStr))
- {
- //暂不考虑
- }
- 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
- {
- newStaff.NationID = nation.Value;
- }
- }
- //政治面貌
- if (string.IsNullOrWhiteSpace(en.PoliticsStr))
- {
- //暂不考虑
- }
- 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
- {
- newStaff.PoliticsID = politics.Value;
- }
- }
- //院系所
- if (string.IsNullOrWhiteSpace(en.CollegeName))
- {
- errCount++;
- errorMsgStr = RSL.Get("College") + "不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var college = newCollegeList.Where(x => x.Name == en.CollegeName.Trim()).SingleOrDefault();
- if (college == null)
- {
- errCount++;
- errorMsgStr = RSL.Get("College") + "不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStaff.CollegeID = college.CollegeID;
- en.CampusID = college.CampusID;
- }
- }
- //所属教研室
- if (string.IsNullOrWhiteSpace(en.DepartmentName))
- {
- //暂不考虑
- }
- else
- {
- var department = newDepartmentList.Where(x => x.Name == en.DepartmentName.Trim()).SingleOrDefault();
- if (department == null)
- {
- errCount++;
- errorMsgStr = "所属教研室不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //判断院系所与所属教研室是否匹配
- if (department.CollegeID != newStaff.CollegeID)
- {
- errCount++;
- errorMsgStr = "所属教研室和" + RSL.Get("College") + "不匹配,请核查。";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStaff.DepartmentID = department.DepartmentID;
- }
- }
- }
- //证件类型
- if (string.IsNullOrWhiteSpace(en.CertificatesTypeStr))
- {
- //默认为身份证
- newStaff.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
- {
- newStaff.CertificatesType = certificatesType.Value;
- }
- }
- //证件号码
- if (string.IsNullOrWhiteSpace(en.CertificatesNum))
- {
- //暂不考虑
- }
- else
- {
- if (string.IsNullOrWhiteSpace(en.CertificatesTypeStr))
- {
- 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.CertificatesNum.Trim()))
- {
- errCount++;
- errorMsgStr = "证件号码格式不正确,请检查(数字或英文字母)";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStaff.CertificatesNum = en.CertificatesNum.Trim();
- }
- }
- }
- //教师类型
- if (string.IsNullOrWhiteSpace(en.TeacherTypeStr))
- {
- errCount++;
- errorMsgStr = "教师类型不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var teacherType = teacherTypeList.Where(x => x.Name == en.TeacherTypeStr.Trim()).SingleOrDefault();
- if (teacherType == null)
- {
- errCount++;
- errorMsgStr = "教师类型不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStaff.TeacherTypeID = teacherType.Value;
- }
- }
- //在职状态
- if (string.IsNullOrWhiteSpace(en.IncumbencyStateStr))
- {
- errCount++;
- errorMsgStr = "在职状态不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var incumbencyState = incumbencyStateList.Where(x => x.Name == en.IncumbencyStateStr.Trim()).SingleOrDefault();
- if (incumbencyState == null)
- {
- errCount++;
- errorMsgStr = "在职状态不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStaff.IncumbencyState = incumbencyState.Value;
- }
- }
- //任课状况
- if (string.IsNullOrWhiteSpace(en.SituationStr))
- {
- //暂不考虑
- }
- else
- {
- var situation = situationList.Where(x => x.Name == en.SituationStr.Trim()).SingleOrDefault();
- if (situation == null)
- {
- errCount++;
- errorMsgStr = "任课状况不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStaff.SituationID = situation.Value;
- }
- }
- //职称
- if (string.IsNullOrWhiteSpace(en.TitleStr))
- {
- //暂不考虑
- }
- else
- {
- var title = titleList.Where(x => x.Name == en.TitleStr.Trim()).SingleOrDefault();
- if (title == null)
- {
- errCount++;
- errorMsgStr = "职称不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStaff.TitleID = title.Value;
- }
- }
- //文化程度
- 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
- {
- newStaff.LiteracyLevelID = literacyLevel.Value;
- }
- }
- //学位
- if (string.IsNullOrWhiteSpace(en.LearnPositionStr))
- {
- //暂不考虑
- }
- else
- {
- var learnPosition = learnPositionList.Where(x => x.Name == en.LearnPositionStr.Trim()).SingleOrDefault();
- if (learnPosition == null)
- {
- errCount++;
- errorMsgStr = "学位不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStaff.LearnPositionID = learnPosition.Value;
- }
- }
- //是否双师型
- if (string.IsNullOrWhiteSpace(en.IsDualTeacherStr))
- {
- newStaff.IsDualTeacher = false;
- }
- else
- {
- var isDualTeacher = generalPurposeList.Where(x => x.Name == en.IsDualTeacherStr.Trim()).SingleOrDefault();
- if (isDualTeacher == null)
- {
- errCount++;
- errorMsgStr = "是否双师型不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStaff.IsDualTeacher = isDualTeacher.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
- }
- }
- //课酬级别
- if (string.IsNullOrWhiteSpace(en.PaymentLevelStr))
- {
- //暂不考虑
- }
- else
- {
- var paymentLevel = paymentLevelList.Where(x => x.Name == en.PaymentLevelStr.Trim()).SingleOrDefault();
- if (paymentLevel == null)
- {
- errCount++;
- errorMsgStr = "课酬级别不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStaff.PaymentLevelID = paymentLevel.Value;
- }
- }
- //国籍
- if (string.IsNullOrWhiteSpace(en.Nationality))
- {
- //暂不考虑
- }
- else
- {
- newStaffProfile.Nationality = en.Nationality.Trim();
- }
- //籍贯
- if (string.IsNullOrWhiteSpace(en.Place))
- {
- //暂不考虑
- }
- else
- {
- newStaffProfile.Place = en.Place.Trim();
- }
- //参加工作年月
- if (string.IsNullOrWhiteSpace(en.WorkDateStr))
- {
- //暂不考虑
- }
- else
- {
- if (!DateTime.TryParse(en.WorkDateStr, out result))
- {
- errCount++;
- errorMsgStr = "参加工作年月格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStaff.WorkDate = Convert.ToDateTime(en.WorkDateStr);
- }
- }
- //来校年月
- if (string.IsNullOrWhiteSpace(en.ComeSchoolDateStr))
- {
- //暂不考虑
- }
- else
- {
- if (!DateTime.TryParse(en.ComeSchoolDateStr, out result))
- {
- errCount++;
- errorMsgStr = "来校年月格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStaff.ComeSchoolDate = Convert.ToDateTime(en.ComeSchoolDateStr);
- }
- }
- //电子邮箱
- 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
- {
- newStaffProfile.Email = en.Email.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
- {
- newStaffProfile.ZIPCode = en.ZIPCode.Trim();
- }
- }
- //微信号
- if (string.IsNullOrWhiteSpace(en.WeChatNum))
- {
- //暂不考虑
- }
- else
- {
- newStaffProfile.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
- {
- newStaffProfile.QQ = en.QQ.Trim();
- }
- }
- //家庭电话
- if (string.IsNullOrWhiteSpace(en.Telephone))
- {
- //暂不考虑
- }
- else
- {
- newStaffProfile.Telephone = en.Telephone.Trim();
- }
- //办公电话
- if (string.IsNullOrWhiteSpace(en.OfficeTelephone))
- {
- //暂不考虑
- }
- else
- {
- newStaffProfile.OfficeTelephone = en.OfficeTelephone.Trim();
- }
- //住宅电话
- if (string.IsNullOrWhiteSpace(en.HousePhone))
- {
- //暂不考虑
- }
- else
- {
- newStaffProfile.HousePhone = en.HousePhone.Trim();
- }
- //移动电话
- if (string.IsNullOrWhiteSpace(en.Mobile))
- {
- //暂不考虑
- }
- else
- {
- newStaffProfile.Mobile = en.Mobile.Trim();
- }
- //健康状况
- if (string.IsNullOrWhiteSpace(en.HealthStateStr))
- {
- newStaffProfile.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
- {
- newStaffProfile.HealthStateID = healthState.Value;
- }
- }
- //宗教信仰
- if (string.IsNullOrWhiteSpace(en.ReligionStr))
- {
- //暂不考虑
- }
- else
- {
- var religion = religionList.Where(x => x.Name == en.ReligionStr.Trim()).SingleOrDefault();
- if (religion == null)
- {
- errCount++;
- errorMsgStr = "宗教信仰不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStaffProfile.ReligionID = religion.Value;
- }
- }
- //特长
- if (string.IsNullOrWhiteSpace(en.Speciality))
- {
- //暂不考虑
- }
- else
- {
- newStaffProfile.Speciality = en.Speciality.Trim();
- }
- //银行卡号
- if (string.IsNullOrWhiteSpace(en.Account))
- {
- //暂不考虑
- }
- else
- {
- reg = new Regex(@"^[0-9]*$"); //正则表达式
- if (!reg.IsMatch(en.Account.Trim()))
- {
- errCount++;
- errorMsgStr = "银行卡号格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStaffProfile.Account = en.Account.Trim();
- }
- }
- //户口所在地
- if (string.IsNullOrWhiteSpace(en.Residence))
- {
- //暂不考虑
- }
- else
- {
- newStaffProfile.Residence = en.Residence.Trim();
- }
- //家庭住址
- if (string.IsNullOrWhiteSpace(en.HomeAddress))
- {
- //暂不考虑
- }
- else
- {
- newStaffProfile.HomeAddress = en.HomeAddress.Trim();
- }
- //通信地址
- if (string.IsNullOrWhiteSpace(en.Address))
- {
- //暂不考虑
- }
- else
- {
- newStaffProfile.Address = en.Address.Trim();
- }
- //现住地址
- if (string.IsNullOrWhiteSpace(en.NowAddress))
- {
- //暂不考虑
- }
- else
- {
- newStaffProfile.NowAddress = en.NowAddress.Trim();
- }
- //简介
- if (string.IsNullOrWhiteSpace(en.Profile))
- {
- //暂不考虑
- }
- else
- {
- newStaff.Profile = en.Profile.Trim();
- }
- //备注
- if (string.IsNullOrWhiteSpace(en.Remark))
- {
- //暂不考虑
- }
- else
- {
- newStaff.Remark = en.Remark.Trim();
- }
- ////Excel表重复性验证(注:当数据表中没有此记录,但是Excel中有重复数据时的去掉)
- //for (int j = i + 1; j < enlist.Count; j++)
- //{
- // StaffView enA = enlist[j];
- // //根据Excel表中的业务主键进行去重(教职工号或证件号码唯一)
- // if (en.StaffCode == enA.StaffCode && en.CertificatesNum == enA.CertificatesNum)
- // {
- // //用于标识Excel表中的重复记录(由于是批量进行插入数据表)
- // }
- //}
- //数据表重复性验证(教职工号或证件号码唯一)
- var userVerify = newUserList.Where(x => x.LoginID == newUser.LoginID).SingleOrDefault();
- if (userVerify == null)
- {
- //判断证件号码
- if (!string.IsNullOrEmpty(newStaff.CertificatesNum))
- {
- if (!newStaffUpList.Any(x => x.CertificatesNum == newStaff.CertificatesNum))
- {
- if (!newStaffInList.Any(x => x.CertificatesNum == newStaff.CertificatesNum))
- {
- var certificatesNumVerify = certificatesNumStaffList.Where(x => x.CertificatesNum == newStaff.CertificatesNum).ToList();
- if (certificatesNumVerify != null && certificatesNumVerify.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 (!newUserInList.Any(x => x.LoginID == newUser.LoginID))
- {
- newUser.UserID = Guid.NewGuid();
- if (teacherInitPassword == null)
- {
- newUser.Password = ("A" + newUser.LoginID.Trim()).MD5();
- }
- else
- {
- if (teacherInitPassword.Value != null)
- {
- newUser.Password = teacherInitPassword.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>();
- if (teacherRoleList != null && teacherRoleList.Count() > 0)
- {
- teacherRoleList.ForEach(x => newUser.Sys_Role.Add(x));
- }
- else
- {
- //对应角色为空时,默认为不分配用户角色
- }
- newStaff.UserID = newUser.UserID;
- var staffManageCampus = new CF_StaffManageCampus();
- staffManageCampus.StaffManageCampusID = Guid.NewGuid();
- staffManageCampus.UserID = newUser.UserID;
- staffManageCampus.CampusID = en.CampusID;
- this.SetNewStatus(staffManageCampus);
- newStaffManageCampusInList.Add(staffManageCampus);
- var staffManageCollege = new CF_StaffManageCollege();
- staffManageCollege.StaffManageCollegeID = Guid.NewGuid();
- staffManageCollege.UserID = newUser.UserID;
- staffManageCollege.CollegeID = newStaff.CollegeID;
- this.SetNewStatus(staffManageCollege);
- newStaffManageCollegeInList.Add(staffManageCollege);
- if (newStaff.DepartmentID.HasValue && newStaff.DepartmentID != Guid.Empty)
- {
- var staffManageDepartment = new CF_StaffManageDepartment();
- staffManageDepartment.StaffManageDepartmentID = Guid.NewGuid();
- staffManageDepartment.UserID = newUser.UserID;
- staffManageDepartment.DepartmentID = newStaff.DepartmentID;
- this.SetNewStatus(staffManageDepartment);
- newStaffManageDepartmentInList.Add(staffManageDepartment);
- }
- this.SetNewStatus(newStaff);
- newStaffInList.Add(newStaff);
- newStaffProfile.UserID = newStaff.UserID;
- this.SetNewStatus(newStaffProfile);
- newStaffProfileInList.Add(newStaffProfile);
- inCount++;
- }
- else
- {
- //Excel表重复性验证
- //(注:当数据表中没有此记录,但是Excel中有重复数据,可在此处进行抛出到失败数据文件中)
- errCount++;
- errorMsgStr = "教职工号重复(Excel中),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- else
- {
- //更新(判断Excel有重复时,以最后一条记录更新为准)
- var staffVerify = newStaffList.Where(x => x.UserID == userVerify.UserID).SingleOrDefault();
- if (staffVerify == null)
- {
- errCount++;
- errorMsgStr = "教职工号冲突(与其它帐号冲突),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //判断证件号码
- if (!string.IsNullOrEmpty(newStaff.CertificatesNum))
- {
- if (!newStaffInList.Any(x => x.CertificatesNum == newStaff.CertificatesNum))
- {
- if (!newStaffUpList.Any(x => x.CertificatesNum == newStaff.CertificatesNum))
- {
- var certificatesNumVerify = certificatesNumStaffList.Where(x => x.UserID != userVerify.UserID
- && x.CertificatesNum == newStaff.CertificatesNum).ToList();
- if (certificatesNumVerify != null && certificatesNumVerify.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;
- }
- }
- staffVerify.Sys_User.LoginID = newUser.LoginID.Trim();
- staffVerify.Sys_User.Name = newUser.Name.Trim();
- this.SetModifyStatus(staffVerify.Sys_User);
- newUserUpList.Add(staffVerify.Sys_User);
- staffVerify.StaffCode = newUser.LoginID.Trim();
- if (staffVerify.CollegeID != newStaff.CollegeID)
- {
- CampusUserIDDelList.Add(staffVerify.UserID);
- var staffManageCampus = new CF_StaffManageCampus();
- staffManageCampus.StaffManageCampusID = Guid.NewGuid();
- staffManageCampus.UserID = staffVerify.UserID;
- staffManageCampus.CampusID = en.CampusID;
- this.SetNewStatus(staffManageCampus);
- newStaffManageCampusInList.Add(staffManageCampus);
- CollegeUserIDDelList.Add(staffVerify.UserID);
- var staffManageCollege = new CF_StaffManageCollege();
- staffManageCollege.StaffManageCollegeID = Guid.NewGuid();
- staffManageCollege.UserID = staffVerify.UserID;
- staffManageCollege.CollegeID = newStaff.CollegeID;
- this.SetNewStatus(staffManageCollege);
- newStaffManageCollegeInList.Add(staffManageCollege);
- DepartmentUserIDDelList.Add(staffVerify.UserID);
- if (newStaff.DepartmentID.HasValue && newStaff.DepartmentID != Guid.Empty)
- {
- var staffManageDepartment = new CF_StaffManageDepartment();
- staffManageDepartment.StaffManageDepartmentID = Guid.NewGuid();
- staffManageDepartment.UserID = staffVerify.UserID;
- staffManageDepartment.DepartmentID = newStaff.DepartmentID;
- this.SetNewStatus(staffManageDepartment);
- newStaffManageDepartmentInList.Add(staffManageDepartment);
- }
- }
- else
- {
- if (staffVerify.CF_StaffManageCampus.Count() <= 0 || staffVerify.CF_StaffManageCampus == null)
- {
- var staffManageCampus = new CF_StaffManageCampus();
- staffManageCampus.StaffManageCampusID = Guid.NewGuid();
- staffManageCampus.UserID = staffVerify.UserID;
- staffManageCampus.CampusID = en.CampusID;
- this.SetNewStatus(staffManageCampus);
- newStaffManageCampusInList.Add(staffManageCampus);
- }
- if (staffVerify.CF_StaffManageCollege.Count() <= 0 || staffVerify.CF_StaffManageCollege == null)
- {
- var staffManageCollege = new CF_StaffManageCollege();
- staffManageCollege.StaffManageCollegeID = Guid.NewGuid();
- staffManageCollege.UserID = staffVerify.UserID;
- staffManageCollege.CollegeID = newStaff.CollegeID;
- this.SetNewStatus(staffManageCollege);
- newStaffManageCollegeInList.Add(staffManageCollege);
- }
- if (staffVerify.DepartmentID != newStaff.DepartmentID)
- {
- DepartmentUserIDDelList.Add(staffVerify.UserID);
- if (newStaff.DepartmentID.HasValue && newStaff.DepartmentID != Guid.Empty)
- {
- var staffManageDepartment = new CF_StaffManageDepartment();
- staffManageDepartment.StaffManageDepartmentID = Guid.NewGuid();
- staffManageDepartment.UserID = staffVerify.UserID;
- staffManageDepartment.DepartmentID = newStaff.DepartmentID;
- this.SetNewStatus(staffManageDepartment);
- newStaffManageDepartmentInList.Add(staffManageDepartment);
- }
- }
- else
- {
- if (staffVerify.CF_StaffManageDepartment.Count() <= 0 || staffVerify.CF_StaffManageDepartment == null)
- {
- if (newStaff.DepartmentID.HasValue && newStaff.DepartmentID != Guid.Empty)
- {
- var staffManageDepartment = new CF_StaffManageDepartment();
- staffManageDepartment.StaffManageDepartmentID = Guid.NewGuid();
- staffManageDepartment.UserID = staffVerify.UserID;
- staffManageDepartment.DepartmentID = newStaff.DepartmentID;
- this.SetNewStatus(staffManageDepartment);
- newStaffManageDepartmentInList.Add(staffManageDepartment);
- }
- }
- }
- }
- staffVerify.CollegeID = newStaff.CollegeID;
- staffVerify.DepartmentID = newStaff.DepartmentID;
- staffVerify.SexID = newStaff.SexID;
- staffVerify.BirthDate = newStaff.BirthDate;
- staffVerify.NationID = newStaff.NationID;
- staffVerify.PoliticsID = newStaff.PoliticsID;
- staffVerify.CertificatesType = newStaff.CertificatesType;
- staffVerify.CertificatesNum = newStaff.CertificatesNum;
- staffVerify.TeacherTypeID = newStaff.TeacherTypeID;
- staffVerify.IncumbencyState = newStaff.IncumbencyState;
- staffVerify.SituationID = newStaff.SituationID;
- staffVerify.TitleID = newStaff.TitleID;
- staffVerify.LiteracyLevelID = newStaff.LiteracyLevelID;
- staffVerify.LearnPositionID = newStaff.LearnPositionID;
- staffVerify.IsDualTeacher = newStaff.IsDualTeacher;
- staffVerify.PaymentLevelID = newStaff.PaymentLevelID;
- staffVerify.WorkDate = newStaff.WorkDate;
- staffVerify.ComeSchoolDate = newStaff.ComeSchoolDate;
- staffVerify.Profile = newStaff.Profile;
- staffVerify.Remark = newStaff.Remark;
- this.SetModifyStatus(staffVerify);
- newStaffUpList.Add(staffVerify);
- if (staffVerify.CF_StaffProfile == null)
- {
- var staffProfile = new CF_StaffProfile();
- staffProfile.UserID = staffVerify.UserID;
- staffProfile.UsedName = newStaffProfile.UsedName;
- staffProfile.Nationality = newStaffProfile.Nationality;
- staffProfile.Place = newStaffProfile.Place;
- staffProfile.Email = newStaffProfile.Email;
- staffProfile.ZIPCode = newStaffProfile.ZIPCode;
- staffProfile.WeChatNum = newStaffProfile.WeChatNum;
- staffProfile.QQ = newStaffProfile.QQ;
- staffProfile.Telephone = newStaffProfile.Telephone;
- staffProfile.OfficeTelephone = newStaffProfile.OfficeTelephone;
- staffProfile.HousePhone = newStaffProfile.HousePhone;
- staffProfile.Mobile = newStaffProfile.Mobile;
- staffProfile.Speciality = newStaffProfile.Speciality;
- staffProfile.HealthStateID = newStaffProfile.HealthStateID;
- staffProfile.ReligionID = newStaffProfile.ReligionID;
- staffProfile.Account = newStaffProfile.Account;
- staffProfile.Residence = newStaffProfile.Residence;
- staffProfile.HomeAddress = newStaffProfile.HomeAddress;
- staffProfile.Address = newStaffProfile.Address;
- staffProfile.NowAddress = newStaffProfile.NowAddress;
- this.SetNewStatus(staffProfile);
- newStaffProfileInList.Add(staffProfile);
- }
- else
- {
- staffVerify.CF_StaffProfile.UsedName = newStaffProfile.UsedName;
- staffVerify.CF_StaffProfile.Nationality = newStaffProfile.Nationality;
- staffVerify.CF_StaffProfile.Place = newStaffProfile.Place;
- staffVerify.CF_StaffProfile.Email = newStaffProfile.Email;
- staffVerify.CF_StaffProfile.ZIPCode = newStaffProfile.ZIPCode;
- staffVerify.CF_StaffProfile.WeChatNum = newStaffProfile.WeChatNum;
- staffVerify.CF_StaffProfile.QQ = newStaffProfile.QQ;
- staffVerify.CF_StaffProfile.Telephone = newStaffProfile.Telephone;
- staffVerify.CF_StaffProfile.OfficeTelephone = newStaffProfile.OfficeTelephone;
- staffVerify.CF_StaffProfile.HousePhone = newStaffProfile.HousePhone;
- staffVerify.CF_StaffProfile.Mobile = newStaffProfile.Mobile;
- staffVerify.CF_StaffProfile.Speciality = newStaffProfile.Speciality;
- staffVerify.CF_StaffProfile.HealthStateID = newStaffProfile.HealthStateID;
- staffVerify.CF_StaffProfile.ReligionID = newStaffProfile.ReligionID;
- staffVerify.CF_StaffProfile.Account = newStaffProfile.Account;
- staffVerify.CF_StaffProfile.Residence = newStaffProfile.Residence;
- staffVerify.CF_StaffProfile.HomeAddress = newStaffProfile.HomeAddress;
- staffVerify.CF_StaffProfile.Address = newStaffProfile.Address;
- staffVerify.CF_StaffProfile.NowAddress = newStaffProfile.NowAddress;
- this.SetModifyStatus(staffVerify.CF_StaffProfile);
- newStaffProfileUpList.Add(staffVerify.CF_StaffProfile);
- }
- upCount++;
- }
- }
- }
- using (TransactionScope ts = new TransactionScope())
- {
- UnitOfWork.Delete<CF_StaffManageDepartment>(x => DepartmentUserIDDelList.Contains(x.UserID));
- UnitOfWork.Delete<CF_StaffManageCollege>(x => CollegeUserIDDelList.Contains(x.UserID));
- UnitOfWork.Delete<CF_StaffManageCampus>(x => CampusUserIDDelList.Contains(x.UserID));
- UnitOfWork.BulkInsert<Sys_User>(newUserInList);
- UnitOfWork.BulkInsert(newUserInList, (x => x.Sys_Role));
- UnitOfWork.BulkInsert<CF_Staff>(newStaffInList);
- UnitOfWork.BulkInsert<CF_StaffProfile>(newStaffProfileInList);
- UnitOfWork.BulkInsert<CF_StaffManageCampus>(newStaffManageCampusInList);
- UnitOfWork.BulkInsert<CF_StaffManageCollege>(newStaffManageCollegeInList);
- UnitOfWork.BulkInsert<CF_StaffManageDepartment>(newStaffManageDepartmentInList);
- if (newUserUpList != null && newUserUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newUserUpList);
- }
- if (newStaffUpList != null && newStaffUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStaffUpList);
- }
- if (newStaffProfileUpList != null && newStaffProfileUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStaffProfileUpList);
- }
- ts.Complete();
- }
- errdataList = errList.Distinct().ToList(); //错误列表List
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|