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; }
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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);
- }
-
-
-
-
-
-
-
-
-
-
-
- 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();
- }
-
-
-
-
-
- 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);
- }
- }
-
-
-
-
-
- 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 (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);
- }
- }
-
-
-
-
-
- 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;
- }
- }
-
-
-
-
- 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);
- }
- }
-
-
-
-
-
- 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);
- }
-
- ts.Complete();
- }
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
-
-
-
-
-
-
-
-
- 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;
- }
- }
-
-
-
-
-
-
-
-
-
- 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>();
-
- cellheader.Remove("ErrorMessage");
- List<NewStudentView> enlist = NpoiExcelHelper.ExcelToEntityList<NewStudentView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
- cellheader.Add("ErrorMessage", "未导入原因");
-
- 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();
-
- 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();
-
- var newStudentList = newStudentAllList.Where(x => examineeNumList.Contains(x.ExamineeNum)).ToList();
-
- for (int i = 0; i < enlist.Count; i++)
- {
- NewStudentView en = enlist[i];
- 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))
- {
-
- 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
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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
- {
-
- }
- }
-
- 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
- {
-
- 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))
- {
-
- 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();
-
- 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;
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var examineeNumVerify = newStudentList.Where(x => x.ExamineeNum == newStudent.ExamineeNum).SingleOrDefault();
- if (examineeNumVerify == null)
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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
- {
-
-
- errCount++;
- errorMsgStr = "考生号重复(Excel中),请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- }
- else
- {
-
-
- 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
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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;
- }
- }
- }
- }
|