12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Data;
- using System.IO;
- using System.Transactions;
- using Bowin.Common.Utility;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.Entities;
- using EMIS.Utility;
- using EMIS.ViewModel;
- using EMIS.ViewModel.CacheManage;
- using EMIS.ViewModel.EnrollManage.NewStudentManage;
- using EMIS.DataLogic.EnrollManage.NewStudentManage;
- namespace EMIS.CommonLogic.EnrollManage.NewStudentManage
- {
- public class NewStudentServices : BaseServices, INewStudentServices
- {
- public NewStudentDAL NewStudentDAL { get; set; }
- /// <summary>
- /// 查询对应的新生名单信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="gradeID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="isPhoto"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<NewStudentView> GetNewStudentViewGrid(ConfiguretView configuretView, int? gradeID, int? standardID, int? educationID, int? learningformID, string learnSystem, int? isPhoto, int pageIndex, int pageSize)
- {
- Expression<Func<CF_NewStudent, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.NotAssigned);
- if (gradeID.HasValue)
- {
- exp = exp.And(x => x.GradeID == gradeID);
- }
- if (isPhoto.HasValue)
- {
- if (isPhoto.Value == (int)CF_GeneralExist.Have)
- {
- exp = exp.And(x => x.RecruitPictureUrl != null && x.RecruitPictureUrl != "");
- }
- if (isPhoto.Value == (int)CF_GeneralExist.No)
- {
- exp = exp.And(x => x.RecruitPictureUrl == null || x.RecruitPictureUrl == "");
- }
- }
- var query = NewStudentDAL.GetNewStudentViewQueryable(exp);
- if (standardID.HasValue)
- {
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderByDescending(x => x.GradeID).ThenBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID)
- .ThenBy(x => x.LearnSystem).ToGridResultSet<NewStudentView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的新生名单信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="gradeID"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="isPhoto"></param>
- /// <returns></returns>
- public IList<NewStudentView> GetNewStudentViewList(ConfiguretView configuretView, int? gradeID, int? standardID, int? educationID, int? learningformID, string learnSystem, int? isPhoto)
- {
- Expression<Func<CF_NewStudent, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.NotAssigned);
- if (gradeID.HasValue)
- {
- exp = exp.And(x => x.GradeID == gradeID);
- }
- if (isPhoto.HasValue)
- {
- if (isPhoto.Value == (int)CF_GeneralExist.Have)
- {
- exp = exp.And(x => x.RecruitPictureUrl != null && x.RecruitPictureUrl != "");
- }
- if (isPhoto.Value == (int)CF_GeneralExist.No)
- {
- exp = exp.And(x => x.RecruitPictureUrl == null || x.RecruitPictureUrl == "");
- }
- }
- var query = NewStudentDAL.GetNewStudentViewQueryable(exp);
- if (standardID.HasValue)
- {
- query = query.Where(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- query = query.Where(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- query = query.Where(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderByDescending(x => x.GradeID).ThenBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID)
- .ThenBy(x => x.LearnSystem).ToList();
- }
- /// <summary>
- /// 查询对应的新生名单信息NewStudentView
- /// </summary>
- /// <param name="newStudentID"></param>
- /// <returns></returns>
- public NewStudentView GetNewStudentView(Guid? newStudentID)
- {
- try
- {
- Expression<Func<CF_NewStudent, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.NotAssigned);
- exp = exp.And(x => x.NewStudentID == newStudentID);
- var query = NewStudentDAL.GetNewStudentViewQueryable(exp).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑(新增、修改,业务主键:考生号唯一)
- /// </summary>
- /// <param name="newStudentView"></param>
- /// <param name="photoUrl"></param>
- public void NewStudentEdit(NewStudentView newStudentView, string photoUrl)
- {
- try
- {
- var examineeNumVerify = NewStudentDAL.NewStudentRepository.GetList(x => x.NewStudentID != newStudentView.NewStudentID
- && x.ExamineeNum == newStudentView.ExamineeNum.Trim()).SingleOrDefault();
- if (examineeNumVerify == null)
- {
- //if (!string.IsNullOrEmpty(newStudentView.AdmissionTicketNo))
- //{
- // var admissionTicketNoVerify = NewStudentDAL.NewStudentRepository.GetList(x => x.NewStudentID != newStudentView.NewStudentID
- // && x.AdmissionTicketNo == newStudentView.AdmissionTicketNo.Trim()).SingleOrDefault();
- // if (admissionTicketNoVerify != null)
- // {
- // if (admissionTicketNoVerify.AssignStatus == (int)CF_AssignStatus.PreAssigned)
- // {
- // throw new Exception("新生分配信息中已存在此准考证号(准考证号重复),请核查。");
- // }
- // else if (admissionTicketNoVerify.AssignStatus == (int)CF_AssignStatus.Assigned)
- // {
- // throw new Exception("录取名单信息中已存在此准考证号(准考证号重复),请核查。");
- // }
- // else
- // {
- // throw new Exception("已存在相同的准考证号(准考证号重复),请核查。");
- // }
- // }
- //}
- if (newStudentView.NewStudentID != Guid.Empty)
- {
- var newStudent = NewStudentDAL.NewStudentRepository.GetList(x => x.NewStudentID == newStudentView.NewStudentID
- && x.AssignStatus == (int)CF_AssignStatus.NotAssigned).SingleOrDefault();
- if (newStudent == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- else
- {
- //表示修改
- newStudent.ExamineeNum = newStudentView.ExamineeNum.Trim();
- if (!string.IsNullOrEmpty(newStudentView.AdmissionTicketNo))
- {
- newStudent.AdmissionTicketNo = newStudentView.AdmissionTicketNo.Trim();
- }
- else
- {
- newStudent.AdmissionTicketNo = newStudentView.AdmissionTicketNo;
- }
- newStudent.Name = newStudentView.Name;
- newStudent.SexID = newStudentView.SexID;
- newStudent.NationID = newStudentView.NationID;
- newStudent.PoliticsID = newStudentView.PoliticsID;
- newStudent.BirthDate = newStudentView.BirthDate;
- newStudent.CertificatesType = newStudentView.CertificatesType;
- newStudent.IDNumber = newStudentView.IDNumber;
- newStudent.GradeID = newStudentView.GradeID;
- newStudent.SemesterID = newStudentView.SemesterID;
- newStudent.SpecialtyID = newStudentView.SpecialtyID;
- newStudent.EntranceDate = newStudentView.EntranceDate;
- newStudent.Score = newStudentView.Score;
- newStudent.Telephone = newStudentView.Telephone;
- newStudent.ZIPCode = newStudentView.ZIPCode;
- newStudent.EntranceWayID = newStudentView.EntranceWayID;
- newStudent.FeaturesID = newStudentView.FeaturesID;
- newStudent.TerritorialID = newStudentView.TerritorialID;
- newStudent.Address = newStudentView.Address;
- newStudent.Dormitory = newStudentView.Dormitory;
- if (!string.IsNullOrEmpty(photoUrl))
- {
- newStudent.RecruitPictureUrl = photoUrl;
- }
- newStudent.Remark = newStudentView.Remark;
- SetModifyStatus(newStudent);
- }
- }
- else
- {
- //表示新增
- var newStudent = new CF_NewStudent();
- newStudent.NewStudentID = Guid.NewGuid();
- newStudent.ExamineeNum = newStudentView.ExamineeNum.Trim();
- if (!string.IsNullOrEmpty(newStudentView.AdmissionTicketNo))
- {
- newStudent.AdmissionTicketNo = newStudentView.AdmissionTicketNo.Trim();
- }
- else
- {
- newStudent.AdmissionTicketNo = newStudentView.AdmissionTicketNo;
- }
- newStudent.Name = newStudentView.Name;
- newStudent.SexID = newStudentView.SexID;
- newStudent.NationID = newStudentView.NationID;
- newStudent.PoliticsID = newStudentView.PoliticsID;
- newStudent.BirthDate = newStudentView.BirthDate;
- newStudent.CertificatesType = newStudentView.CertificatesType;
- newStudent.IDNumber = newStudentView.IDNumber;
- newStudent.GradeID = newStudentView.GradeID;
- newStudent.SemesterID = newStudentView.SemesterID;
- newStudent.SpecialtyID = newStudentView.SpecialtyID;
- newStudent.EntranceDate = newStudentView.EntranceDate;
- newStudent.Score = newStudentView.Score;
- newStudent.Telephone = newStudentView.Telephone;
- newStudent.ZIPCode = newStudentView.ZIPCode;
- newStudent.EntranceWayID = newStudentView.EntranceWayID;
- newStudent.FeaturesID = newStudentView.FeaturesID;
- newStudent.TerritorialID = newStudentView.TerritorialID;
- newStudent.Address = newStudentView.Address;
- newStudent.Dormitory = newStudentView.Dormitory;
- if (!string.IsNullOrEmpty(photoUrl))
- {
- newStudent.RecruitPictureUrl = photoUrl;
- }
- newStudent.IsDoubt = false;
- newStudent.AssignStatus = (int)CF_AssignStatus.NotAssigned;
- newStudent.Remark = newStudentView.Remark;
- SetNewStatus(newStudent, (int)CF_NewStudentEnterStatus.NotSubmitted);
- UnitOfWork.Add(newStudent);
- }
- }
- else
- {
- if (examineeNumVerify.AssignStatus == (int)CF_AssignStatus.PreAssigned)
- {
- throw new Exception("新生分配信息中已存在此考生号(考生号重复),请核查。");
- }
- else if (examineeNumVerify.AssignStatus == (int)CF_AssignStatus.Assigned)
- {
- throw new Exception("录取名单信息中已存在此考生号(考生号重复),请核查。");
- }
- else
- {
- throw new Exception("已存在相同的考生号(考生号重复),请核查。");
- }
- }
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="newStudentIDList"></param>
- /// <returns></returns>
- public bool NewStudentDelete(List<Guid?> newStudentIDList)
- {
- try
- {
- UnitOfWork.Delete<CF_NewStudent>(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.NotAssigned);
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 删除照片(单个删除)
- /// </summary>
- /// <param name="newStudentID"></param>
- public void DeletePhoto(Guid? newStudentID)
- {
- try
- {
- var newStudent = NewStudentDAL.NewStudentRepository.GetList(x => x.NewStudentID == newStudentID && x.AssignStatus == (int)CF_AssignStatus.NotAssigned).SingleOrDefault();
- if (newStudent != null)
- {
- if (!string.IsNullOrEmpty(newStudent.RecruitPictureUrl))
- {
- FileUploadHelper.DeleteFile(newStudent.RecruitPictureUrl);
- newStudent.RecruitPictureUrl = null;
- this.UnitOfWork.Commit();
- }
- else
- {
- throw new Exception("对应的照片不存在。");
- }
- }
- else
- {
- throw new Exception("对应的信息未保存,数据有误。");
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除照片(批量删除)
- /// </summary>
- /// <param name="newStudentIDs"></param>
- /// <returns></returns>
- public bool PicDelete(List<Guid?> newStudentIDs)
- {
- try
- {
- List<string> photoUrlList = new List<string>();
- List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
- var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDs.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.NotAssigned).ToList();
- foreach (var newStudent in newStudentList)
- {
- if (newStudent != null)
- {
- if (!string.IsNullOrEmpty(newStudent.RecruitPictureUrl))
- {
- photoUrlList.Add(newStudent.RecruitPictureUrl);
- newStudent.RecruitPictureUrl = null;
- newStudentUpList.Add(newStudent);
- }
- }
- }
- using (TransactionScope ts = new TransactionScope())
- {
- foreach (var photoUrl in photoUrlList)
- {
- FileUploadHelper.DeleteFile(photoUrl);
- }
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentUpList);
- }
- //this.UnitOfWork.Commit();
- ts.Complete();
- }
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 导入照片
- /// </summary>
- /// <param name="photoPaths"></param>
- /// <param name="importPicType"></param>
- /// <param name="inCount"></param>
- /// <param name="errCount"></param>
- /// <param name="errDataTable"></param>
- public void NewStudentPicImport(IList<string> photoPaths, string importPicType, out int? inCount, out int? errCount, out DataTable errDataTable)
- {
- try
- {
- var mapList = photoPaths.Select(s => new
- {
- PhotoInfo = Path.GetFileName(s).Trim(),
- PhotoName = Path.GetFileNameWithoutExtension(s).Trim(),
- PhotoPath = s,
- }).ToArray();
- var photoNameList = mapList.Select(s => s.PhotoName).Distinct().ToList();
- inCount = 0;
- errCount = 0;
- errDataTable = new DataTable();
- List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
- if (importPicType.Equals("ExamineeNum"))
- {
- var newPhotoNameList = new List<string>();
- foreach (var photoName in photoNameList)
- {
- var photoNameStart = photoName.Substring(0, 1);
- if (photoNameStart.Equals("F") || photoNameStart.Equals("Z"))
- {
- newPhotoNameList.Add(photoName.Substring(1));
- }
- }
- errDataTable.Columns.Add("PhotoInfo", typeof(string));
- errDataTable.Columns.Add("ExamineeNum", typeof(string));
- errDataTable.Columns.Add("ErrorMessage", typeof(string));
- var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => x.AssignStatus == (int)CF_AssignStatus.NotAssigned && (photoNameList.Contains(x.ExamineeNum) || newPhotoNameList.Contains(x.ExamineeNum))).ToList();
- foreach (var map in mapList)
- {
- var photoNameStart = map.PhotoName.Substring(0, 1);
- if (photoNameStart.Equals("F") || photoNameStart.Equals("Z"))
- {
- var newStudent = newStudentList.Where(x => x.ExamineeNum == map.PhotoName || x.ExamineeNum == map.PhotoName.Substring(1)).SingleOrDefault();
- if (newStudent == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["ExamineeNum"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- newStudent.RecruitPictureUrl = map.PhotoPath;
- this.SetModifyStatus(newStudent);
- newStudentUpList.Add(newStudent);
- inCount++;
- }
- }
- else
- {
- var newStudent = newStudentList.Where(x => x.ExamineeNum == map.PhotoName).SingleOrDefault();
- if (newStudent == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["ExamineeNum"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的考生号(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- newStudent.RecruitPictureUrl = map.PhotoPath;
- this.SetModifyStatus(newStudent);
- newStudentUpList.Add(newStudent);
- inCount++;
- }
- }
- }
- }
- else if (importPicType.Equals("IDNumber"))
- {
- errDataTable.Columns.Add("PhotoInfo", typeof(string));
- errDataTable.Columns.Add("IDNumber", typeof(string));
- errDataTable.Columns.Add("ErrorMessage", typeof(string));
- var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => x.AssignStatus == (int)CF_AssignStatus.NotAssigned && photoNameList.Contains(x.IDNumber)).ToList();
- foreach (var map in mapList)
- {
- var newStudentVerifyList = newStudentList.Where(x => x.IDNumber == map.PhotoName).ToList();
- if (newStudentVerifyList != null && newStudentVerifyList.Count() > 1)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["IDNumber"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "存在多个对应的证件号码(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- if (newStudentVerifyList != null && newStudentVerifyList.Count() == 1)
- {
- var newStudent = newStudentVerifyList.Where(x => x.IDNumber == map.PhotoName).SingleOrDefault();
- if (newStudent == null)
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["IDNumber"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的证件号码(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- else
- {
- newStudent.RecruitPictureUrl = map.PhotoPath;
- this.SetModifyStatus(newStudent);
- newStudentUpList.Add(newStudent);
- inCount++;
- }
- }
- else
- {
- DataRow errDataRow = errDataTable.NewRow();
- errDataRow["PhotoInfo"] = map.PhotoInfo;
- errDataRow["IDNumber"] = map.PhotoName;
- errDataRow["ErrorMessage"] = "不存在对应的证件号码(" + map.PhotoName + ")";
- errDataTable.Rows.Add(errDataRow);
- errCount++;
- }
- }
- }
- }
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentUpList);
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <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 NewStudentImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount, out List<NewStudentView> errdataList, out int? errCount, string sourcePhysicalPath)
- {
- try
- {
- StringBuilder errorMsg = new StringBuilder(); // 错误信息
- List<NewStudentView> errList = new List<NewStudentView>();
- // 1.1解析文件,存放到一个List集合里
- cellheader.Remove("ErrorMessage");//移除“未导入原因”列(ErrorMessage)
- List<NewStudentView> enlist = NpoiExcelHelper.ExcelToEntityList<NewStudentView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
- cellheader.Add("ErrorMessage", "未导入原因");
- //对List集合进行有效性校验
- if (enlist.Count() <= 0)
- {
- throw new Exception("Excel文件数据为空,请检查。");
- }
- Regex reg = null; //正则表达式
- DateTime result; //用于返回判断日期字段格式
- inCount = 0; //导入个数
- upCount = 0; //更新个数
- errCount = 0; //失败个数
- string errorMsgStr = ""; //错误信息
- List<CF_NewStudent> newStudentInList = new List<CF_NewStudent>();
- List<CF_NewStudent> newStudentUpList = new List<CF_NewStudent>();
- //将循环中相关数据库查询统一查询出来进行匹配(尽量避免在循环中进行数据库查询)
- //性别
- 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 gradeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Grade).ToList();
- //学期
- var semesterList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Semester).ToList();
- //专业代码、专业名称、专业ID(Value)
- var standardList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Standard).ToList();
- //培养层次(所修学历)
- var educationList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Education).ToList();
- //学习形式
- var learningFormList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Learningform).ToList();
- //证件类型
- var certificatesTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_CertificatesType).ToList();
- //专业信息
- var specialtyList = NewStudentDAL.SpecialtyRepository.GetList(x => true).ToList();
- //考生号
- var examineeNumList = enlist.Where(x => !string.IsNullOrEmpty(x.ExamineeNum)).Select(x => x.ExamineeNum.Trim()).ToList();
- //新生名单
- var newStudentAllList = NewStudentDAL.NewStudentRepository.GetList(x => true).ToList();
- //对比后的newStudentList
- var newStudentList = newStudentAllList.Where(x => examineeNumList.Contains(x.ExamineeNum)).ToList();
- //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等)
- for (int i = 0; i < enlist.Count; i++)
- {
- NewStudentView en = enlist[i]; //Excel表数据视图
- CF_NewStudent newStudent = new CF_NewStudent();
- //考生号
- if (string.IsNullOrEmpty(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))
- {
- errCount++;
- errorMsgStr = "考生号格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //考生号
- newStudent.ExamineeNum = en.ExamineeNum.Trim();
- }
- }
- //准考证号
- if (!string.IsNullOrEmpty(en.AdmissionTicketNo))
- {
- reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //准考证号正则表达式
- if (!reg.IsMatch(en.AdmissionTicketNo))
- {
- errCount++;
- errorMsgStr = "准考证号格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //准考证号
- newStudent.AdmissionTicketNo = en.AdmissionTicketNo.Trim();
- }
- }
- else
- {
- //为空
- }
- //姓名
- if (string.IsNullOrEmpty(en.Name))
- {
- errCount++;
- errorMsgStr = "姓名不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //姓名
- newStudent.Name = en.Name.Trim();
- }
- //性别
- if (string.IsNullOrEmpty(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.IsNullOrEmpty(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.IsNullOrEmpty(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.IsNullOrEmpty(en.BirthDateStr))
- {
- //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);
- }
- }
- else
- {
- //为空
- }
- //证件类型
- if (string.IsNullOrEmpty(en.CertificatesTypeStr))
- {
- errCount++;
- errorMsgStr = "证件类型不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- 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.IsNullOrEmpty(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))
- //{
- // 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.IsNullOrEmpty(en.GradeStr))
- {
- errCount++;
- errorMsgStr = "年级不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var grade = gradeList.Where(x => x.Name == en.GradeStr.Trim()).SingleOrDefault();
- if (grade == null)
- {
- errCount++;
- errorMsgStr = "年级不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- newStudent.GradeID = grade.Value;
- }
- }
- //学期
- if (string.IsNullOrEmpty(en.SemesterStr))
- {
- errCount++;
- errorMsgStr = "学期不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var semester = semesterList.Where(x => x.Name == en.SemesterStr.Trim()).SingleOrDefault();
- if (semester == null)
- {
- errCount++;
- errorMsgStr = "学期不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //学期
- newStudent.SemesterID = semester.Value;
- }
- }
- //专业代码
- if (string.IsNullOrEmpty(en.StandardCode))
- {
- errCount++;
- errorMsgStr = "专业代码不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var standardCode = standardList.Where(x => x.Code == en.StandardCode.Trim()).FirstOrDefault();
- if (standardCode == null)
- {
- errCount++;
- errorMsgStr = "专业代码不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //专业代码
- }
- }
- //专业名称
- if (string.IsNullOrEmpty(en.StandardName))
- {
- errCount++;
- errorMsgStr = "专业名称不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var standardName = standardList.Where(x => x.Name == en.StandardName.Trim()).FirstOrDefault();
- if (standardName == null)
- {
- errCount++;
- errorMsgStr = "专业名称不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //专业名称
- }
- }
- //专业代码与专业名称查询专业ID(Value)
- if (string.IsNullOrEmpty(en.StandardCode) || string.IsNullOrEmpty(en.StandardName))
- {
- errCount++;
- errorMsgStr = "专业代码或专业名称不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var standardID = standardList.Where(x => x.Code == en.StandardCode.Trim() && x.Name == en.StandardName.Trim()).SingleOrDefault();
- if (standardID == null)
- {
- errCount++;
- errorMsgStr = "专业代码与专业名称对应的元素值不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //专业ID(Value)
- en.StandardID = standardID.Value.Value;
- }
- }
- //培养层次(所修学历)
- if (string.IsNullOrEmpty(en.EducationStr))
- {
- errCount++;
- errorMsgStr = RSL.Get("EducationID") + "不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var education = educationList.Where(x => x.Name == en.EducationStr.Trim()).SingleOrDefault();
- if (education == null)
- {
- errCount++;
- errorMsgStr = RSL.Get("EducationID") + "不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- en.EducationID = education.Value.Value;
- }
- }
- //学习形式
- if (string.IsNullOrEmpty(en.LearningformStr))
- {
- errCount++;
- errorMsgStr = "学习形式不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var learningForm = learningFormList.Where(x => x.Name == en.LearningformStr.Trim()).SingleOrDefault();
- if (learningForm == null)
- {
- errCount++;
- errorMsgStr = "学习形式不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- en.LearningformID = learningForm.Value.Value;
- }
- }
- //学制
- if (string.IsNullOrEmpty(en.LearnSystemStr))
- {
- errCount++;
- errorMsgStr = "学制不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$"); //学制字段正则表达式()
- if (!reg.IsMatch(en.LearnSystemStr))
- {
- errCount++;
- errorMsgStr = "学制格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //学制
- en.LearnSystem = Convert.ToDecimal(en.LearnSystemStr);
- }
- }
- //入学日期
- if (!string.IsNullOrEmpty(en.EntranceDateStr))
- {
- //reg = new Regex(@"(\d{4})-(\d{1,2})-(\d{1,2})"); //日期正则表达式,2017-12-28
- if (!DateTime.TryParse(en.EntranceDateStr, out result))
- {
- errCount++;
- errorMsgStr = "入学日期格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //入学日期
- newStudent.EntranceDate = Convert.ToDateTime(en.EntranceDateStr);
- }
- }
- else
- {
- //为空
- }
- //总分
- if (!string.IsNullOrEmpty(en.ScoreStr))
- {
- 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
- {
- //总分
- newStudent.Score = Convert.ToDecimal(en.ScoreStr);
- }
- }
- else
- {
- //为空
- }
- //联系电话
- if (string.IsNullOrEmpty(en.Telephone))
- {
- //暂不考虑
- }
- else
- {
- reg = new Regex(@"^[-0-9]+$"); //联系电话正则表达式
- if (!reg.IsMatch(en.Telephone))
- {
- errCount++;
- errorMsgStr = "联系电话格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //联系电话
- newStudent.Telephone = en.Telephone;
- }
- }
- //通讯地址
- if (string.IsNullOrEmpty(en.Address))
- {
- //暂不考虑
- }
- else
- {
- newStudent.Address = en.Address;
- }
- //宿舍地址
- if (string.IsNullOrEmpty(en.Dormitory))
- {
- //暂不考虑
- }
- else
- {
- newStudent.Dormitory = en.Dormitory;
- }
- //备注
- if (string.IsNullOrEmpty(en.Remark))
- {
- //暂不考虑
- }
- else
- {
- newStudent.Remark = en.Remark;
- }
- //专业信息查询
- var specialty = specialtyList.Where(x => x.StandardID == en.StandardID && x.LearnSystem == en.LearnSystem && x.EducationID == en.EducationID
- && x.LearningformID == en.LearningformID).SingleOrDefault();
- //专业信息ID
- if (specialty == null)
- {
- errCount++;
- errorMsgStr = "专业信息不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //查询专业信息(启用、禁用状态)
- if (specialty.RecordStatus > (int)SYS_STATUS.UNUSABLE)
- {
- newStudent.SpecialtyID = specialty.SpecialtyID;
- }
- else
- {
- newStudent.SpecialtyID = specialty.SpecialtyID;
- errCount++;
- errorMsgStr = "专业信息为禁用状态,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- ////Excel表重复性验证(注:当数据表中没有此记录,但是Excel中有重复数据时的去掉)
- //for (int j = i + 1; j < enlist.Count; j++)
- //{
- // NewStudentView enA = enlist[j];
- // //根据Excel表中的业务主键进行去重(考生号唯一)
- // if (en.ExamineeNum == enA.ExamineeNum)
- // {
- // //用于标识Excel表中的重复记录(由于是批量进行插入数据表)
- // }
- //}
- //由于新生管理模块中存在新生分配的业务,在进行新生信息新增时,
- //需要对新生分配、录取名单中的信息进行提示性验证(业务主键:考生号唯一)
- //处理方法:进行Excel导入时,对新生分配、录取名单中的信息提示性验证(当错误信息抛出)
- //注:(未分配-1,预分配-2,已分配-3)
- //数据表重复性验证(考生号唯一)
- var examineeNumVerify = newStudentList.Where(x => x.ExamineeNum == newStudent.ExamineeNum).SingleOrDefault();
- if (examineeNumVerify == null)
- {
- //if (!string.IsNullOrEmpty(newStudent.AdmissionTicketNo))
- //{
- // if (!newStudentUpList.Any(x => x.AdmissionTicketNo == newStudent.AdmissionTicketNo))
- // {
- // if (!newStudentInList.Any(x => x.AdmissionTicketNo == newStudent.AdmissionTicketNo))
- // {
- // var admissionTicketNoVerify = newStudentList.Where(x => x.AdmissionTicketNo == newStudent.AdmissionTicketNo).SingleOrDefault();
- // if (admissionTicketNoVerify != null)
- // {
- // if (admissionTicketNoVerify.AssignStatus == (int)CF_AssignStatus.PreAssigned)
- // {
- // errCount++;
- // errorMsgStr = "新生分配信息中已存在此准考证号(准考证号重复),请核查";
- // en.ErrorMessage = errorMsgStr;
- // errList.Add(en);
- // errorMsg.AppendLine(errorMsgStr);
- // continue;
- // }
- // else if (admissionTicketNoVerify.AssignStatus == (int)CF_AssignStatus.Assigned)
- // {
- // errCount++;
- // errorMsgStr = "录取名单信息中已存在此准考证号(准考证号重复),请核查";
- // en.ErrorMessage = errorMsgStr;
- // errList.Add(en);
- // errorMsg.AppendLine(errorMsgStr);
- // continue;
- // }
- // else
- // {
- // errCount++;
- // errorMsgStr = "已存在相同的准考证号(准考证号重复),请核查";
- // en.ErrorMessage = errorMsgStr;
- // errList.Add(en);
- // errorMsg.AppendLine(errorMsgStr);
- // continue;
- // }
- // }
- // }
- // 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 (!newStudentInList.Any(x => x.ExamineeNum == newStudent.ExamineeNum))
- {
- newStudent.NewStudentID = Guid.NewGuid();
- newStudent.IsDoubt = false;
- newStudent.AssignStatus = (int)CF_AssignStatus.NotAssigned;
- SetNewStatus(newStudent, (int)CF_NewStudentEnterStatus.NotSubmitted);
- newStudentInList.Add(newStudent);
- inCount++;
- }
- else
- {
- //Excel表重复性验证
- //(注:当数据表中没有此记录,但是Excel中有重复数据,可在此处进行抛出到失败数据文件中)
- errCount++;
- errorMsgStr = "考生号重复(Excel中),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- else
- {
- //由于新生管理模块中存在新生分配的业务,只更新分配状态为:未分配-1
- //分配状态为:预分配-2,已分配-3
- if (examineeNumVerify.AssignStatus == (int)CF_AssignStatus.PreAssigned)
- {
- errCount++;
- errorMsgStr = "导入失败,新生分配信息中已存在此考生号(考生号重复)";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else if (examineeNumVerify.AssignStatus == (int)CF_AssignStatus.Assigned)
- {
- errCount++;
- errorMsgStr = "导入失败,录取名单信息中已存在此考生号(考生号重复)";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //更新(Excel有重复时,以最后一条记录的更新为准)
- //if (!string.IsNullOrEmpty(newStudent.AdmissionTicketNo))
- //{
- // if (!newStudentInList.Any(x => x.AdmissionTicketNo == newStudent.AdmissionTicketNo))
- // {
- // if (!newStudentUpList.Any(x => x.AdmissionTicketNo == newStudent.AdmissionTicketNo))
- // {
- // var admissionTicketNoVerify = newStudentList.Where(x => x.AdmissionTicketNo == newStudent.AdmissionTicketNo).SingleOrDefault();
- // if (admissionTicketNoVerify != null)
- // {
- // if (admissionTicketNoVerify.AssignStatus == (int)CF_AssignStatus.PreAssigned)
- // {
- // errCount++;
- // errorMsgStr = "新生分配信息中已存在此准考证号(准考证号重复),请核查";
- // en.ErrorMessage = errorMsgStr;
- // errList.Add(en);
- // errorMsg.AppendLine(errorMsgStr);
- // continue;
- // }
- // else if (admissionTicketNoVerify.AssignStatus == (int)CF_AssignStatus.Assigned)
- // {
- // errCount++;
- // errorMsgStr = "录取名单信息中已存在此准考证号(准考证号重复),请核查";
- // en.ErrorMessage = errorMsgStr;
- // errList.Add(en);
- // errorMsg.AppendLine(errorMsgStr);
- // continue;
- // }
- // else
- // {
- // errCount++;
- // errorMsgStr = "已存在相同的准考证号(准考证号重复),请核查";
- // en.ErrorMessage = errorMsgStr;
- // errList.Add(en);
- // errorMsg.AppendLine(errorMsgStr);
- // continue;
- // }
- // }
- // }
- // 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;
- // }
- //}
- examineeNumVerify.ExamineeNum = newStudent.ExamineeNum;
- examineeNumVerify.AdmissionTicketNo = newStudent.AdmissionTicketNo;
- examineeNumVerify.Name = newStudent.Name;
- examineeNumVerify.SexID = newStudent.SexID;
- examineeNumVerify.NationID = newStudent.NationID;
- examineeNumVerify.PoliticsID = newStudent.PoliticsID;
- examineeNumVerify.BirthDate = newStudent.BirthDate;
- examineeNumVerify.CertificatesType = newStudent.CertificatesType;
- examineeNumVerify.IDNumber = newStudent.IDNumber;
- examineeNumVerify.GradeID = newStudent.GradeID;
- examineeNumVerify.SemesterID = newStudent.SemesterID;
- examineeNumVerify.SpecialtyID = newStudent.SpecialtyID;
- examineeNumVerify.EntranceDate = newStudent.EntranceDate;
- examineeNumVerify.Score = newStudent.Score;
- examineeNumVerify.Telephone = newStudent.Telephone;
- examineeNumVerify.Address = newStudent.Address;
- examineeNumVerify.Dormitory = newStudent.Dormitory;
- examineeNumVerify.Remark = newStudent.Remark;
- SetModifyStatus(examineeNumVerify);
- newStudentUpList.Add(examineeNumVerify);
- upCount++;
- }
- }
- }
- using (TransactionScope ts = new TransactionScope())
- {
- UnitOfWork.BulkInsert(newStudentInList);
- if (newStudentUpList != null && newStudentUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newStudentUpList);
- }
- ts.Complete();
- }
- errdataList = errList.Distinct().ToList();
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|