12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Transactions;
- using Bowin.Common.Utility;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.CacheManage;
- using EMIS.ViewModel.StudentManage.StudentProfile;
- namespace EMIS.ExtensionLogic.ServiceLogic.StudentManage
- {
- public class StudentServices : EMIS.CommonLogic.StudentManage.StudentProfile.StudentServices
- {
- /// <summary>
- /// 编辑(新增、修改,业务主键:学号或考生号唯一)
- /// 注:学号总位数问题(广州美术)
- /// </summary>
- /// <param name="studentView"></param>
- /// <param name="photoUrl"></param>
- public override 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>
- /// 学生信息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 override 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;
- }
- }
- }
- }
|