using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Linq.Expressions; using System.Text; using System.Text.RegularExpressions; using System.Transactions; using System.IO; using Bowin.Common.Utility; using Bowin.Common.Linq; using Bowin.Common.Linq.Entity; using EMIS.Utility; using EMIS.Entities; using EMIS.ViewModel; using EMIS.ViewModel.EnrollManage.NewStudentManage; using EMIS.DataLogic.EnrollManage.NewStudentManage; using EMIS.CommonLogic.Students; namespace EMIS.CommonLogic.EnrollManage.NewStudentManage { public class NewStudentEnterServices : BaseServices, INewStudentEnterServices { public NewStudentDAL NewStudentDAL { get; set; } public Lazy StudentServices { get; set; } /// /// 查询录取名单信息View /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetNewStudentEnterViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? grademajorID, Guid? classmajorID, int? generalPurpose, int? generalExist, int? dictionaryNewStudentEnterStatus, int pageIndex, int pageSize) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.Assigned); if (collegeID.HasValue) { exp = exp.And(x => x.CollegeID == collegeID); } if (gradeID.HasValue) { exp = exp.And(x => x.GradeID == gradeID); } if (classmajorID.HasValue) { exp = exp.And(x => x.ClassmajorID == classmajorID); } if (generalPurpose.HasValue) { if (generalPurpose == 1) { exp = exp.And(x => x.IsDoubt == true); } if (generalPurpose == 0) { exp = exp.And(x => x.IsDoubt != true); } } if (dictionaryNewStudentEnterStatus.HasValue) { exp = exp.And(x => x.RecordStatus == dictionaryNewStudentEnterStatus); } var query = NewStudentDAL.GetNewStudentEnterViewQueryable(exp); if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } 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 (grademajorID.HasValue) { query = query.Where(x => x.GrademajorID == grademajorID); } if (generalExist.HasValue) { if (generalExist.Value == (int)CF_GeneralExist.Have) { query = query.Where(x => !string.IsNullOrEmpty(x.StudentNo)); } if (generalExist.Value == (int)CF_GeneralExist.No) { query = query.Where(x => string.IsNullOrEmpty(x.StudentNo)); } } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.GradeID).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ThenBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem) .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ToGridResultSet(pageIndex, pageSize); } /// /// 查询录取名单信息List /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IList GetNewStudentEnterViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? grademajorID, Guid? classmajorID, int? generalPurpose, int? generalExist, int? dictionaryNewStudentEnterStatus) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.Assigned); if (collegeID.HasValue) { exp = exp.And(x => x.CollegeID == collegeID); } if (gradeID.HasValue) { exp = exp.And(x => x.GradeID == gradeID); } if (classmajorID.HasValue) { exp = exp.And(x => x.ClassmajorID == classmajorID); } if (generalPurpose.HasValue) { if (generalPurpose == 1) { exp = exp.And(x => x.IsDoubt == true); } if (generalPurpose == 0) { exp = exp.And(x => x.IsDoubt != true); } } if (dictionaryNewStudentEnterStatus.HasValue) { exp = exp.And(x => x.RecordStatus == dictionaryNewStudentEnterStatus); } var query = NewStudentDAL.GetNewStudentEnterViewQueryable(exp); if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } 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 (grademajorID.HasValue) { query = query.Where(x => x.GrademajorID == grademajorID); } if (generalExist.HasValue) { if (generalExist.Value == (int)CF_GeneralExist.Have) { query = query.Where(x => !string.IsNullOrEmpty(x.StudentNo)); } if (generalExist.Value == (int)CF_GeneralExist.No) { query = query.Where(x => string.IsNullOrEmpty(x.StudentNo)); } } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.GradeID).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ThenBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem) .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ToList(); } /// /// 查询对应的录取名单信息NewStudentView /// /// /// public NewStudentView GetNewStudentEnterView(Guid? newStudentID) { try { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.Assigned); exp = exp.And(x => x.NewStudentID == newStudentID); var query = NewStudentDAL.GetNewStudentEnterViewQueryable(exp).SingleOrDefault(); return query; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 录取查询 /// /// /// /// public NewStudentView GetNewStudentEnterView(string examineeNum, string userName) { try { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.Assigned); exp = exp.And(x => x.ExamineeNum == examineeNum); exp = exp.And(x => x.Name == userName); var query = NewStudentDAL.GetNewStudentEnterViewQueryable(exp).SingleOrDefault(); return query; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 编辑(新增、修改,业务主键:考生号唯一) /// 注:需对相应的业务进行处理,如:学号等 /// /// /// public void NewStudentEnterEdit(NewStudentView newStudentView, string photoUrl) { try { //查询对应的招生专业信息 var recruitSpecialty = NewStudentDAL.RecruitSpecialtyRepository.GetList(x => x.GradeID == newStudentView.GradeID && x.CollegeID == newStudentView.CollegeID && x.SpecialtyID == newStudentView.SpecialtyID).SingleOrDefault(); if (recruitSpecialty == null) { throw new Exception("对应的招生专业不存在(未开设相对应的招生专业)。"); } //查询对应的专业信息 var specialty = NewStudentDAL.SpecialtyRepository.GetList(x => x.SpecialtyID == newStudentView.SpecialtyID).SingleOrDefault(); //根据专业信息和选择的院系所查询院系专业信息 var facultymajorList = NewStudentDAL.FacultymajorRepository.GetList(x => x.CollegeID == newStudentView.CollegeID && x.StandardID == specialty.StandardID && x.EducationID == specialty.EducationID && x.LearningformID == specialty.LearningformID && x.LearnSystem == specialty.LearnSystem).Select(x => x.FacultymajorID).ToList(); //if (facultymajorList.Count == 0) //{ // throw new Exception(RSL.Get("College") + "对应的专业不存在(院系专业信息)。"); //} //根据院系专业和新生的年级查询年级专业信息 var grademajorList = NewStudentDAL.GrademajorRepository.GetList(x => facultymajorList.Contains(x.FacultymajorID.Value) && x.GradeID == newStudentView.GradeID, x => x.CF_Classmajor).Select(x => x.GrademajorID).ToList(); //if (grademajorList.Count == 0) //{ // throw new Exception("年级对应的专业不存在(年级专业信息)。"); //} //根据年级专业查询班级信息 var classajorList = NewStudentDAL.ClassmajorRepository.GetList(x => grademajorList.Contains(x.GrademajorID.Value)).ToList(); //if (classajorList.Count == 0) //{ // throw new Exception("对应的班级信息不存在。"); //} if (newStudentView.ClassmajorID != null) { var classajor = classajorList.Where(x => x.ClassmajorID == newStudentView.ClassmajorID).FirstOrDefault(); if (classajor == null) { throw new Exception("选择的班级信息与对应的专业信息不相符。"); } } //查询数据库进行验证 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.NotAssigned) // { // throw new Exception("新生名单信息中已存在此准考证号(准考证号重复),请核查。"); // } // else if (admissionTicketNoVerify.AssignStatus == (int)CF_AssignStatus.PreAssigned) // { // throw new Exception("新生分配信息中已存在此准考证号(准考证号重复),请核查。"); // } // else // { // throw new Exception("已存在相同的准考证号(准考证号重复),请核查。"); // } // } //} //查询Web.config学号位数配置 var studentNoTotal = EMIS.Utility.Const.LOCAL_SETTING_LOGINIDTOTAL; if (!string.IsNullOrEmpty(newStudentView.StudentNo)) { if (studentNoTotal == null) { throw new Exception("学号总位数未配置,请检查。"); } else { //有学号一定要有班级信息 if (!newStudentView.ClassmajorID.HasValue) { throw new Exception("请选择对应的班级名称(学号不为空时,班级名称不能为空)。"); } else { //新生名单信息数据重复性验证(学号唯一) var newStudentNoVerify = NewStudentDAL.NewStudentRepository.GetList(x => x.NewStudentID != newStudentView.NewStudentID && x.AssignStatus == (int)CF_AssignStatus.Assigned && x.StudentNo == newStudentView.StudentNo.Trim()).SingleOrDefault(); if (newStudentNoVerify != null) { throw new Exception("录取名单中已存在此学号(学号重复),请检查。"); } //用户信息数据重复性验证(用户名唯一) var userVerify = NewStudentDAL.UserRepository.GetList(x => x.LoginID == newStudentView.StudentNo.Trim()).SingleOrDefault(); if (userVerify != null) { //学生信息数据重复性验证(学号唯一,根据业务主键排除) var studentNoVerify = NewStudentDAL.StudentRepository.GetList(x => true, (x => x.CF_Recruitstudents), (x => x.Sys_User)) .Where(x => (x.IDNumber != newStudentView.IDNumber && x.CF_Recruitstudents.ExamineeNum != newStudentView.ExamineeNum) && x.Sys_User.LoginID == newStudentView.StudentNo.Trim()).SingleOrDefault(); if (studentNoVerify != null) { throw new Exception("学生信息中已存在此学号,请检查。"); } else { studentNoVerify = NewStudentDAL.StudentRepository.GetList(x => true, (x => x.Sys_User)) .Where(x => x.Sys_User.LoginID == newStudentView.StudentNo.Trim()).SingleOrDefault(); if (studentNoVerify == null) { throw new Exception("用户信息中已存在相同的用户(用户名重复),请核查。"); } } } //判断学号位数与Web.config配置位数是否一致 if (newStudentView.StudentNo.Length != Convert.ToInt32(studentNoTotal)) { throw new Exception("输入的学号总位数有误,学号总位数应为" + studentNoTotal + "位。"); } } } } //查询最大的录取通知编号(只查询已分配状态的信息--录取名单,业务主键:年级、院系所) var maxCollegeEnrollment = NewStudentDAL.GetEnrollmentNo(x => x.GradeID == newStudentView.GradeID && x.CollegeID == newStudentView.CollegeID && x.AssignStatus == (int)CF_AssignStatus.Assigned).SingleOrDefault(); //查询院系所信息 var college = NewStudentDAL.CollegeRepository.GetList(x => x.CollegeID == newStudentView.CollegeID).SingleOrDefault(); //通知书编号 long newEnrollmentNo = 0; if (maxCollegeEnrollment == null) { //表示初始录取通书编号 int total = (newStudentView.GradeID.ToString() + college.No).Length; newEnrollmentNo = Convert.ToInt64((newStudentView.GradeID.ToString() + college.No).PadRight(total + 4, '0') + "1"); } else { newEnrollmentNo = Convert.ToInt64(maxCollegeEnrollment.EnrollmentNo) + 1; } //数据有误验证 if (newStudentView.NewStudentID != Guid.Empty) { var newStudent = NewStudentDAL.NewStudentRepository.GetList(x => x.NewStudentID == newStudentView.NewStudentID && x.AssignStatus == (int)CF_AssignStatus.Assigned).SingleOrDefault(); if (newStudent == null) { throw new Exception("数据有误,请核查。"); } else { //表示修改 newStudent.ExamineeNum = newStudentView.ExamineeNum; 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 (newStudent.GradeID != newStudentView.GradeID || newStudent.CollegeID != newStudentView.CollegeID) { newStudent.EnrollmentNo = newEnrollmentNo.ToString(); } if (!string.IsNullOrEmpty(photoUrl)) { newStudent.RecruitPictureUrl = photoUrl; } newStudent.CollegeID = newStudentView.CollegeID; newStudent.ClassmajorID = newStudentView.ClassmajorID; newStudent.StudentNo = newStudentView.StudentNo; newStudent.Remark = newStudentView.Remark; SetModifyStatus(newStudent); } } else { //表示新增 var newStudent = new CF_NewStudent(); newStudent.NewStudentID = Guid.NewGuid(); newStudent.ExamineeNum = newStudentView.ExamineeNum; 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; newStudent.EnrollmentNo = newEnrollmentNo.ToString(); if (!string.IsNullOrEmpty(photoUrl)) { newStudent.RecruitPictureUrl = photoUrl; } newStudent.IsDoubt = false; newStudent.AssignStatus = (int)CF_AssignStatus.Assigned; newStudent.CollegeID = newStudentView.CollegeID; newStudent.ClassmajorID = newStudentView.ClassmajorID; newStudent.StudentNo = newStudentView.StudentNo; newStudent.Remark = newStudentView.Remark; SetNewStatus(newStudent, (int)CF_NewStudentEnterStatus.NotSubmitted); UnitOfWork.Add(newStudent); } } else { if (examineeNumVerify.AssignStatus == (int)CF_AssignStatus.NotAssigned) { throw new Exception("新生名单信息中已存在此考生号(考生号重复),请核查。"); } else if (examineeNumVerify.AssignStatus == (int)CF_AssignStatus.PreAssigned) { throw new Exception("新生分配信息中已存在此考生号(考生号重复),请核查。"); } else { throw new Exception("已存在相同的考生号(考生号重复),请核查。"); } } UnitOfWork.Commit(); } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 删除 /// /// /// public bool NewStudentEnterDelete(List newStudentIDList) { try { UnitOfWork.Delete(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned); 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.Assigned).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 newStudentIDs) { try { List photoUrlList = new List(); List newStudentUpList = new List(); var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDs.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).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; } } /// /// 取消分配 /// /// /// public string NewStudentEnterCancelAssignCollege(List newStudentIDList) { try { //查询新生信息 var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).ToList(); int success = 0; //成功 int fail = 0; //失败 string tipMessage = null; //提示消息 List newStudentUpList = new List(); foreach (var newStudentID in newStudentIDList) { var newStudent = newStudentList.Where(x => x.NewStudentID == newStudentID).SingleOrDefault(); if (newStudent == null) { throw new Exception("数据有误,请检查。"); } else { if (newStudent.RecordStatus == (int)CF_NewStudentEnterStatus.NotSubmitted) { newStudent.EnrollmentNo = null; newStudent.IsDoubt = false; newStudent.AssignStatus = (int)CF_AssignStatus.NotAssigned; newStudent.CollegeID = null; newStudent.ClassmajorID = null; newStudent.StudentNo = null; SetModifyStatus(newStudent); newStudentUpList.Add(newStudent); success++; } else { fail++; } } } //批量统一提交更新 if (newStudentUpList != null && newStudentUpList.Count() > 0) { UnitOfWork.BatchUpdate(newStudentUpList); } if (success > 0 && fail <= 0) { tipMessage = success + "条"; } else { tipMessage = success + "条," + fail + "条失败,原因:无法对已提交状态的信息取消分配,请检查"; } return tipMessage; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 导入照片 /// /// /// /// /// /// public void NewStudentEnterPicImport(IList 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 newStudentUpList = new List(); List newRecruitStudentUpList = new List(); if (importPicType.Equals("ExamineeNum")) { var newPhotoNameList = new List(); 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.Assigned && (photoNameList.Contains(x.ExamineeNum) || newPhotoNameList.Contains(x.ExamineeNum))).ToList(); var recruitStudentList = NewStudentDAL.RecruitstudentsRepository.GetList(x => 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 { var recruitStudent = recruitStudentList.Where(x => x.ExamineeNum == map.PhotoName || x.ExamineeNum == map.PhotoName.Substring(1)).SingleOrDefault(); if (recruitStudent != null) { recruitStudent.RecruitPictureUrl = map.PhotoPath; this.SetModifyStatus(recruitStudent); newRecruitStudentUpList.Add(recruitStudent); } 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 { var recruitStudent = recruitStudentList.Where(x => x.ExamineeNum == map.PhotoName).SingleOrDefault(); if (recruitStudent != null) { recruitStudent.RecruitPictureUrl = map.PhotoPath; this.SetModifyStatus(recruitStudent); newRecruitStudentUpList.Add(recruitStudent); } 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.Assigned && photoNameList.Contains(x.IDNumber)).ToList(); var studentList = NewStudentDAL.StudentRepository.GetList(x => photoNameList.Contains(x.IDNumber), x => x.CF_Recruitstudents).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 { var studentVerifyList = studentList.Where(x => x.IDNumber == map.PhotoName).ToList(); if (studentVerifyList != null && studentVerifyList.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 (studentVerifyList != null && studentVerifyList.Count() == 1) { var student = studentVerifyList.Where(x => x.IDNumber == map.PhotoName).SingleOrDefault(); if (student != null) { if (student.CF_Recruitstudents != null) { student.CF_Recruitstudents.RecruitPictureUrl = map.PhotoPath; this.SetModifyStatus(student.CF_Recruitstudents); newRecruitStudentUpList.Add(student.CF_Recruitstudents); } } } 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++; } } } } else { errDataTable.Columns.Add("PhotoInfo", typeof(string)); errDataTable.Columns.Add("StudentNo", typeof(string)); errDataTable.Columns.Add("ErrorMessage", typeof(string)); var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => x.AssignStatus == (int)CF_AssignStatus.Assigned && photoNameList.Contains(x.StudentNo)).ToList(); var userList = NewStudentDAL.UserRepository.GetList(x => photoNameList.Contains(x.LoginID), x => x.CF_Student.CF_Recruitstudents).ToList(); foreach (var map in mapList) { var newStudent = newStudentList.Where(x => x.StudentNo == map.PhotoName).SingleOrDefault(); if (newStudent == null) { DataRow errDataRow = errDataTable.NewRow(); errDataRow["PhotoInfo"] = map.PhotoInfo; errDataRow["StudentNo"] = map.PhotoName; errDataRow["ErrorMessage"] = "不存在对应的学号(" + map.PhotoName + ")"; errDataTable.Rows.Add(errDataRow); errCount++; } else { var user = userList.Where(x => x.LoginID == map.PhotoName).SingleOrDefault(); if (user != null) { if (user.CF_Student != null) { if (user.CF_Student.CF_Recruitstudents != null) { user.CF_Student.CF_Recruitstudents.RecruitPictureUrl = map.PhotoPath; this.SetModifyStatus(user.CF_Student.CF_Recruitstudents); newRecruitStudentUpList.Add(user.CF_Student.CF_Recruitstudents); } } } newStudent.RecruitPictureUrl = map.PhotoPath; this.SetModifyStatus(newStudent); newStudentUpList.Add(newStudent); inCount++; } } } using (TransactionScope ts = new TransactionScope()) { if (newRecruitStudentUpList != null && newRecruitStudentUpList.Count() > 0) { UnitOfWork.BatchUpdate(newRecruitStudentUpList); } if (newStudentUpList != null && newStudentUpList.Count() > 0) { UnitOfWork.BatchUpdate(newStudentUpList); } ts.Complete(); } } catch (Exception) { throw; } } /// /// 导入标识 /// /// /// /// /// /// /// public void NewStudentEnterDoubtImport(Dictionary cellheader, out int? inCount, out int? upCount, out List errdataList, out int? errCount, string sourcePhysicalPath) { try { StringBuilder errorMsg = new StringBuilder(); List errList = new List(); cellheader.Remove("ErrorMessage"); List enlist = NpoiExcelHelper.ExcelToEntityList(cellheader, sourcePhysicalPath, out errorMsg, out errList); cellheader.Add("ErrorMessage", "未导入原因"); if (enlist.Count() <= 0) { throw new Exception("Excel文件数据为空,请检查。"); } inCount = 0; upCount = 0; errCount = 0; string errorMsgStr = ""; List newStudentUpList = new List(); //将循环中相关数据库查询统一查询出来进行匹配(尽量避免在循环中进行数据库查询) //姓名 var nameList = enlist.Where(x => !string.IsNullOrEmpty(x.Name)).Select(x => x.Name).ToList(); //身份证号 var iDNumberList = enlist.Where(x => !string.IsNullOrEmpty(x.IDNumber)).Select(x => x.IDNumber).ToList(); //录取名单(由于需要和Excel中数据进行比对,数据太多就会报异常,所以需要先查询出来) var newStudentAllList = NewStudentDAL.NewStudentRepository.GetList(x => true).ToList(); //对比后的newStudentList var newStudentList = newStudentAllList.Where(x => nameList.Contains(x.Name) && iDNumberList.Contains(x.IDNumber)).ToList(); //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等) for (int i = 0; i < enlist.Count; i++) { NewStudentView en = enlist[i]; //Excel表数据视图 CF_NewStudent newStudent = new CF_NewStudent(); //新生信息实体 //姓名 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.IDNumber)) { errCount++; errorMsgStr = "身份证号不能为空"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { newStudent.IDNumber = en.IDNumber.Trim(); } ////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 newStudentEnetey = newStudentList.Where(x => x.IDNumber == newStudent.IDNumber && x.Name == newStudent.Name).SingleOrDefault(); if (newStudentEnetey == null) { errCount++; errorMsgStr = "此标识名单不存在,请检查"; en.ErrorMessage = errorMsgStr; errList.Add(en); errorMsg.AppendLine(errorMsgStr); continue; } else { //由于新生管理模块中存在新生分配的业务,只更新分配状态为:已分配-3、提交状态为:未提交-2的信息 //分配状态为:未分配-1,预分配-2,已分配-3,提交状态:未提交-1,已提交-2 if (newStudentEnetey.AssignStatus == (int)CF_AssignStatus.Assigned) { if (newStudentEnetey.RecordStatus == (int)CF_NewStudentEnterStatus.NotSubmitted) { //(Excel有重复时,以最后一条记录的更新为准) if (newStudentEnetey.IsDoubt == true) { //更新 newStudentEnetey.IsDoubt = true; SetModifyStatus(newStudentEnetey); newStudentUpList.Add(newStudentEnetey); upCount++; } else { //标识 newStudentEnetey.IsDoubt = true; SetModifyStatus(newStudentEnetey); newStudentUpList.Add(newStudentEnetey); inCount++; } } else { 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; } } } if (newStudentUpList != null && newStudentUpList.Count() > 0) { UnitOfWork.BatchUpdate(newStudentUpList); } errdataList = errList.Distinct().ToList(); } catch (Exception) { throw; } } /// /// 查询标识名单信息View /// /// /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetNewStudentEnterDoubtViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID, int? learningformID, string learnSystem, int? isPhotoUrl, int pageIndex, int pageSize) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.Assigned); exp = exp.And(x => x.IsDoubt == true); if (collegeID.HasValue) { exp = exp.And(x => x.CollegeID == collegeID); } if (gradeID.HasValue) { exp = exp.And(x => x.GradeID == gradeID); } if (isPhotoUrl.HasValue) { if (isPhotoUrl.Value == (int)CF_GeneralExist.Have) { exp = exp.And(x => x.RecruitPictureUrl != null && x.RecruitPictureUrl != ""); } if (isPhotoUrl.Value == (int)CF_GeneralExist.No) { exp = exp.And(x => x.RecruitPictureUrl == null || x.RecruitPictureUrl == ""); } } var query = NewStudentDAL.GetNewStudentEnterViewQueryable(exp); if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } 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 this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeID) .ThenBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem) .ThenBy(x => x.ExamineeNum.Length).ThenBy(x => x.ExamineeNum).OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ToGridResultSet(pageIndex, pageSize); } /// /// 查询标识名单信息List /// /// /// /// /// /// /// /// /// /// /// public IList GetNewStudentEnterDoubtViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? gradeID, int? standardID, int? educationID, int? learningformID, string learnSystem, int? isPhotoUrl) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); exp = exp.And(x => x.AssignStatus == (int)CF_AssignStatus.Assigned); exp = exp.And(x => x.IsDoubt == true); if (collegeID.HasValue) { exp = exp.And(x => x.CollegeID == collegeID); } if (gradeID.HasValue) { exp = exp.And(x => x.GradeID == gradeID); } if (isPhotoUrl.HasValue) { if (isPhotoUrl.Value == (int)CF_GeneralExist.Have) { exp = exp.And(x => x.RecruitPictureUrl != null && x.RecruitPictureUrl != ""); } if (isPhotoUrl.Value == (int)CF_GeneralExist.No) { exp = exp.And(x => x.RecruitPictureUrl == null || x.RecruitPictureUrl == ""); } } var query = NewStudentDAL.GetNewStudentEnterViewQueryable(exp); if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } 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 this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeID) .ThenBy(x => x.StandardName).ThenBy(x => x.EducationID).ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem) .ThenBy(x => x.ExamineeNum.Length).ThenBy(x => x.ExamineeNum).OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ToList(); } /// /// 审核(确定) /// /// /// public string NewStudentEnterDoubtApprove(List newStudentIDList) { try { //查询新生信息 var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).ToList(); int success = 0; //成功 int fail = 0; //失败 string tipMessage = null; //提示消息 List newStudentUpList = new List(); foreach (var newStudentID in newStudentIDList) { var newStudent = newStudentList.Where(x => x.NewStudentID == newStudentID).SingleOrDefault(); if (newStudent == null) { throw new Exception("数据有误,请检查。"); } else { if (newStudent.AssignStatus == (int)CF_AssignStatus.Assigned) { newStudent.IsDoubt = false; SetModifyStatus(newStudent); newStudentUpList.Add(newStudent); success++; } else { fail++; } } } //批量统一提交更新 if (newStudentUpList != null && newStudentUpList.Count() > 0) { UnitOfWork.BatchUpdate(newStudentUpList); } if (success > 0 && fail <= 0) { tipMessage = success + "条"; } else { tipMessage = success + "条," + fail + "条失败,原因:数据有误,请检查"; } return tipMessage; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 初始化(班级信息、学号) /// /// /// public string NewStudentEnterInit(List newStudentIDList) { try { //查询新生信息 var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).ToList(); int success = 0; //成功 int fail = 0; //失败 string tipMessage = null; //提示消息 List newStudentUpList = new List(); foreach (var newStudentID in newStudentIDList) { var newStudent = newStudentList.Where(x => x.NewStudentID == newStudentID).SingleOrDefault(); if (newStudent == null) { throw new Exception("数据有误,请检查。"); } else { if (newStudent.RecordStatus == (int)CF_NewStudentEnterStatus.NotSubmitted) { newStudent.ClassmajorID = null; newStudent.StudentNo = null; SetModifyStatus(newStudent); newStudentUpList.Add(newStudent); success++; } else { fail++; } } } //批量统一提交更新 if (newStudentUpList != null && newStudentUpList.Count() > 0) { UnitOfWork.BatchUpdate(newStudentUpList); } if (success > 0 && fail <= 0) { tipMessage = success + "条"; } else { tipMessage = success + "条," + fail + "条失败,原因:无法对已提交状态的信息进行初始化,请检查"; } return tipMessage; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 手动分配班级和生成学号(此为默认规则,一对一的情况,初始学号为:班级编号+流水号,下一位学号为:对应的最大学号+1) /// 注:个性化配置 /// /// /// /// public virtual string NewStudentEnterAssignClass(List newStudentIDList, Guid? classmajorID) { try { var studentNoTotal = EMIS.Utility.Const.LOCAL_SETTING_LOGINIDTOTAL; if (studentNoTotal == null) { throw new Exception("学号总位数未配置,请检查。"); } //查询录取名单信息(已分配状态) var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).ToList(); //年级ID var gradeIDList = newStudentList.Where(x => !string.IsNullOrEmpty(x.GradeID.ToString())).Select(x => x.GradeID).ToList(); //专业信息ID var specialtyIDList = newStudentList.Where(x => !string.IsNullOrEmpty(x.SpecialtyID.ToString())).Select(x => x.SpecialtyID).ToList(); //院系所ID var collegeIDList = newStudentList.Where(x => !string.IsNullOrEmpty(x.CollegeID.ToString())).Select(x => x.CollegeID).ToList(); //查询专业信息 var specialtyList = NewStudentDAL.SpecialtyRepository.GetList(x => specialtyIDList.Contains(x.SpecialtyID)).ToList(); //查询招生专业信息(暂时不需对招生专业进行验证) var recruitSpecialtyAllList = NewStudentDAL.RecruitSpecialtyRepository.GetList(x => true).ToList(); //查询招生专业 var recruitSpecialtyList = recruitSpecialtyAllList.Where(x => gradeIDList.Contains(x.GradeID) && specialtyIDList.Contains(x.SpecialtyID) && collegeIDList.Contains(x.CollegeID)).ToList(); //查询对应的院系专业信息 var facultymajorList = NewStudentDAL.GetFacultymajorByNewStudent(x => newStudentIDList.Contains(x.NewStudentID)).ToList(); //院系专业ID var facultymajorIDList = facultymajorList.Where(x => !string.IsNullOrEmpty(x.FacultymajorID.ToString())).Select(x => x.FacultymajorID).ToList(); //查询对应的年级专业信息 var grademajorList = NewStudentDAL.GetGrademajorByNewStudent(x => newStudentIDList.Contains(x.NewStudentID), x => facultymajorIDList.Contains(x.FacultymajorID)).ToList(); //年级专业ID var grademajorIDList = grademajorList.Where(x => !string.IsNullOrEmpty(x.GrademajorID.ToString())).Select(x => x.GrademajorID).ToList(); //查询对应的班级信息 var classmajorList = NewStudentDAL.GetClassmajorByNewStudent(x => newStudentIDList.Contains(x.NewStudentID), x => facultymajorIDList.Contains(x.FacultymajorID), x => grademajorIDList.Contains(x.GrademajorID)).ToList(); //班级信息ID var classmajorIDList = classmajorList.Where(x => !string.IsNullOrEmpty(x.ClassmajorID.ToString())).Select(x => x.ClassmajorID).ToList(); //查询各班级信息中最大的学号(新生信息表、学生信息表) var maxStudentNoList = NewStudentDAL.GetMaxStudentNoClass(x => classmajorIDList.Contains(x.ClassmajorID)).ToList(); int classmajorfail = 0; int fail = 0; int success = 0; string tipMessage = null; long startStudentNo = 0; long newStudentNo = 0; List newStudentUpList = new List(); foreach (var newStudent in newStudentList) { //需要对选择的班级信息分别进行验证(一一对应的情况下,才可分配班级及生成学号) //查询班级信息(根据新生ID、选择的班级信息ID查询) var classmajorVerify = classmajorList.Where(x => x.NewStudentID == newStudent.NewStudentID && x.ClassmajorID == classmajorID).SingleOrDefault(); //判断对应的班级信息 if (classmajorVerify != null) { //判断当选择的信息中存在班级信息或学号等情况(只要两者之中有一个存在,将不考虑生成) if (newStudent.ClassmajorID.HasValue || !string.IsNullOrEmpty(newStudent.StudentNo)) { //表示不生成 fail++; continue; } else { //查询对应班级信息中最大的学号(新生信息表、学生信息表) var maxStudentNo = maxStudentNoList.Where(x => x.ClassmajorID == classmajorID).SingleOrDefault(); //查询选择生成的录取名单List中是否有分配到同一班级的信息 var newStudentRepeatList = newStudentUpList.Where(x => x.ClassmajorID == classmajorID).ToList(); //表示当前班级无对应的学号,此时应为初始学号(班级编号+2位流水号,需匹配Web.config配置) if (maxStudentNo == null) { //初始学号(班级编号+流水号,不够学号总位数的用0填充,可在此处通过个性化配置来定义学号生成规则) startStudentNo = Convert.ToInt64(classmajorVerify.ClassmajorNo.PadRight(Convert.ToInt32(studentNoTotal) - 1, '0') + "1"); //表示无相同班级的信息 if (newStudentRepeatList.Count <= 0) { //初始学号 newStudentNo = startStudentNo; } else { //相同班级的信息中最大学号+1,作为下一个学号 newStudentNo = Convert.ToInt64(newStudentRepeatList.OrderByDescending(x => Convert.ToInt64(x.StudentNo)).FirstOrDefault().StudentNo) + 1; } } else { //表示无相同班级的信息 if (newStudentRepeatList.Count <= 0) { //数据表中的最大学号+1,作为下一个学号 newStudentNo = Convert.ToInt64(maxStudentNo.StudentNo) + 1; } else { //相同班级的信息中最大学号+1,作为下一个学号 newStudentNo = Convert.ToInt64(newStudentRepeatList.OrderByDescending(x => Convert.ToInt64(x.StudentNo)).FirstOrDefault().StudentNo) + 1; } } newStudent.ClassmajorID = classmajorID; newStudent.StudentNo = newStudentNo.ToString(); SetModifyStatus(newStudent); newStudentUpList.Add(newStudent); success++; } } else { //表示选择的班级信息不相符,无法分班及生成学号 classmajorfail++; continue; } } //批量更新 if (newStudentUpList != null && newStudentUpList.Count() > 0) { UnitOfWork.BatchUpdate(newStudentUpList); } if (classmajorfail <= 0 && fail <= 0) { tipMessage = success + "条录取名单的学号"; } else { if (classmajorfail <= 0 && fail > 0) { tipMessage = success + "个学号,失败" + fail + "条,原因:班级信息或学号已存在,如需生成请初始化后重新生成"; } else if (classmajorfail > 0 && fail <= 0) { tipMessage = success + "个学号," + classmajorfail + "条由于与选择的班级信息不相符,无法生成,请核查"; } else { tipMessage = success + "个学号," + fail + "条由于班级信息或学号已存在无法生成," + classmajorfail + "条由于与选择的班级信息不相符,无法生成,请核查"; } } return tipMessage; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 自动分配班级和生成学号 /// 注:个性化配置 /// 此为默认规则,一对一的情况,初始学号为:班级编号+流水号,下一位学号为:对应的最大学号+1) /// 目前只支持,学号=班级编号+流水号的情况,针对学号生成规则不同、专业分方向、有两个班以上等等情况,需要进行扩展-普教版本 /// /// /// public virtual string NewStudentEnterAutoAssignClass(List newStudentIDList) { try { var studentNoTotal = EMIS.Utility.Const.LOCAL_SETTING_LOGINIDTOTAL; if (studentNoTotal == null) { throw new Exception("学号总位数未配置,请检查。"); } //查询录取名单信息(已分配状态) var newStudentList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).ToList(); //年级ID var gradeIDList = newStudentList.Where(x => !string.IsNullOrEmpty(x.GradeID.ToString())).Select(x => x.GradeID).ToList(); //专业信息ID var specialtyIDList = newStudentList.Where(x => !string.IsNullOrEmpty(x.SpecialtyID.ToString())).Select(x => x.SpecialtyID).ToList(); //院系所ID var collegeIDList = newStudentList.Where(x => !string.IsNullOrEmpty(x.CollegeID.ToString())).Select(x => x.CollegeID).ToList(); //查询专业信息 var specialtyList = NewStudentDAL.SpecialtyRepository.GetList(x => specialtyIDList.Contains(x.SpecialtyID)).ToList(); //查询招生专业信息(暂时不需对招生专业进行验证) var recruitSpecialtyAllList = NewStudentDAL.RecruitSpecialtyRepository.GetList(x => true).ToList(); //查询招生专业 var recruitSpecialtyList = recruitSpecialtyAllList.Where(x => gradeIDList.Contains(x.GradeID) && specialtyIDList.Contains(x.SpecialtyID) && collegeIDList.Contains(x.CollegeID)).ToList(); //查询对应的院系专业信息 var facultymajorList = NewStudentDAL.GetFacultymajorByNewStudent(x => newStudentIDList.Contains(x.NewStudentID)).ToList(); //院系专业ID var facultymajorIDList = facultymajorList.Where(x => !string.IsNullOrEmpty(x.FacultymajorID.ToString())).Select(x => x.FacultymajorID).ToList(); //查询对应的年级专业信息 var grademajorList = NewStudentDAL.GetGrademajorByNewStudent(x => newStudentIDList.Contains(x.NewStudentID), x => facultymajorIDList.Contains(x.FacultymajorID)).ToList(); //年级专业ID var grademajorIDList = grademajorList.Where(x => !string.IsNullOrEmpty(x.GrademajorID.ToString())).Select(x => x.GrademajorID).ToList(); //查询对应的班级信息 var classmajorList = NewStudentDAL.GetClassmajorByNewStudent(x => newStudentIDList.Contains(x.NewStudentID), x => facultymajorIDList.Contains(x.FacultymajorID), x => grademajorIDList.Contains(x.GrademajorID)).ToList(); //班级信息ID var classmajorIDList = classmajorList.Where(x => !string.IsNullOrEmpty(x.ClassmajorID.ToString())).Select(x => x.ClassmajorID).ToList(); //查询各班级信息中最大的学号(新生信息表、学生信息表) var maxStudentNoList = NewStudentDAL.GetMaxStudentNoClass(x => classmajorIDList.Contains(x.ClassmajorID)).ToList(); int facultymajorfail = 0; int grademajorfail = 0; int classmajorfail = 0; int fail = 0; int success = 0; string tipMessage = null; long startStudentNo = 0; long newStudentNo = 0; List newStudentUpList = new List(); foreach (var newStudent in newStudentList) { //需要对院系专业、年级专业、班级信息分别进行验证(一一对应的情况下,才可自动分配班级及生成学号) //查询院系专业 var facultymajorVerify = facultymajorList.Where(x => x.NewStudentID == newStudent.NewStudentID).ToList(); //判断对应的院系专业 if (facultymajorVerify != null && facultymajorVerify.Count() > 0) { if (facultymajorVerify.Count() == 1) { //查询年级专业 var grademajorVerify = grademajorList.Where(x => x.NewStudentID == newStudent.NewStudentID).ToList(); //判断对应的年级专业 if (grademajorVerify != null && grademajorVerify.Count() > 0) { if (grademajorVerify.Count() == 1) { //查询班级信息 var classmajorVerify = classmajorList.Where(x => x.NewStudentID == newStudent.NewStudentID).ToList(); //判断对应的班级信息 if (classmajorVerify != null && classmajorVerify.Count() > 0) { if (classmajorVerify.Count() == 1) { //判断当选择的信息中存在班级信息或学号等情况(只要两者之中有一个存在,将不考虑生成) if (newStudent.ClassmajorID.HasValue || !string.IsNullOrEmpty(newStudent.StudentNo)) { //表示不生成 fail++; continue; } else { //对可分配的班级信息及学号进行查询 //查询对应班级信息中最大的学号(新生信息表、学生信息表) var specialtyClass = classmajorVerify.Where(x => x.NewStudentID == newStudent.NewStudentID).SingleOrDefault(); var maxStudentNo = maxStudentNoList.Where(x => x.ClassmajorID == specialtyClass.ClassmajorID).SingleOrDefault(); //查询选择生成的录取名单List中是否有分配到同一班级的信息 var newStudentRepeatList = newStudentUpList.Where(x => x.ClassmajorID == specialtyClass.ClassmajorID).ToList(); //表示当前班级无对应的学号,此时应为初始学号(班级编号+2位流水号,需匹配Web.config配置) if (maxStudentNo == null) { //初始学号(班级编号+流水号,不够学号总位数的用0填充,可在此处通过个性化配置来定义学号生成规则) startStudentNo = Convert.ToInt64(specialtyClass.ClassmajorNo.PadRight(Convert.ToInt32(studentNoTotal) - 1, '0') + "1"); //表示无相同班级的信息 if (newStudentRepeatList.Count <= 0) { //初始学号 newStudentNo = startStudentNo; } else { //相同班级的信息中最大学号+1,作为下一个学号 newStudentNo = Convert.ToInt64(newStudentRepeatList.OrderByDescending(x => Convert.ToInt64(x.StudentNo)).FirstOrDefault().StudentNo) + 1; } } else { //表示无相同班级的信息 if (newStudentRepeatList.Count <= 0) { //数据表中的最大学号+1,作为下一个学号 newStudentNo = Convert.ToInt64(maxStudentNo.StudentNo) + 1; } else { //相同班级的信息中最大学号+1,作为下一个学号 newStudentNo = Convert.ToInt64(newStudentRepeatList.OrderByDescending(x => Convert.ToInt64(x.StudentNo)).FirstOrDefault().StudentNo) + 1; } } newStudent.ClassmajorID = specialtyClass.ClassmajorID; newStudent.StudentNo = newStudentNo.ToString(); SetModifyStatus(newStudent); newStudentUpList.Add(newStudent); success++; } } else { //表示对应的班级信息存在多个,无法确定对应的班级信息(可在此处进行扩展,针对专业分方向的情况) classmajorfail++; continue; } } else { //表示对应的班级信息不存在,无法分班及生成学号 classmajorfail++; continue; } } else { //表示对应的年级专业信息存在多个,无法确定对应的年级专业(可在此处进行扩展,针对专业分方向的情况) grademajorfail++; continue; } } else { //表示对应的年级专业信息不存在,无法分班及生成学号 grademajorfail++; continue; } } else { //表示对应的院系专业信息存在多个,无法确定对应的院系专业(可在此处进行扩展,针对专业分方向的情况) facultymajorfail++; continue; } } else { //表示对应的院系专业信息不存在,无法分班及生成学号 facultymajorfail++; continue; } } //批量更新 if (newStudentUpList != null && newStudentUpList.Count() > 0) { UnitOfWork.BatchUpdate(newStudentUpList); } if (facultymajorfail <= 0 && grademajorfail <= 0 && classmajorfail <= 0 && fail <= 0) { tipMessage = success + "个学号"; } else { if (facultymajorfail <= 0 && grademajorfail <= 0 && classmajorfail <= 0 && fail > 0) { tipMessage = success + "个学号,失败" + fail + "条,原因:班级信息或学号已存在,如需生成请初始化后重新生成"; } else if (facultymajorfail > 0 && grademajorfail <= 0 && classmajorfail <= 0 && fail <= 0) { tipMessage = success + "个学号," + facultymajorfail + "条由于院系专业信息的原因无法生成,请核查"; } else if (facultymajorfail <= 0 && grademajorfail > 0 && classmajorfail <= 0 && fail <= 0) { tipMessage = success + "个学号," + grademajorfail + "条由于年级专业信息的原因无法生成,请核查"; } else if (facultymajorfail <= 0 && grademajorfail <= 0 && classmajorfail > 0 && fail <= 0) { tipMessage = success + "个学号," + classmajorfail + "条由于班级信息的原因无法生成,请核查"; } else { tipMessage = success + "个学号," + fail + "条由于班级信息或学号已存在无法生成," + facultymajorfail + "条由于院系专业信息的原因无法生成," + grademajorfail + "条由于年级专业信息的原因无法生成," + classmajorfail + "条由于班级信息的原因无法生成,请核查"; } } return tipMessage; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 提交(需判断是否已分班且生成学号,并对学生信息进行验证,如:考生号或准考证号唯一、学号唯一) /// 注:个性化配置 /// 此为默认规则 /// /// /// public virtual string NewStudentEnterSubmit(List newStudentIDList) { 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("预计毕业日(秋季、下学期入学日)未配置,请检查。"); } //查询录取名单信息(已分配状态) var newStudentEnterList = NewStudentDAL.NewStudentRepository.GetList(x => newStudentIDList.Contains(x.NewStudentID) && x.AssignStatus == (int)CF_AssignStatus.Assigned).ToList(); //查询班级信息ID为空的录取名单(注:如果有班级信息,对应的专业班级一定存在(无需验证是否有专业班级)) var classIDVerifyList = newStudentEnterList.Where(x => string.IsNullOrEmpty(x.ClassmajorID.ToString())).ToList(); if (classIDVerifyList != null && classIDVerifyList.Count() > 0) { throw new Exception("选择提交的名单中存在未分班的数据,请检查。"); } //查询学号为空的录取名单 var studentNoVerifyList = newStudentEnterList.Where(x => string.IsNullOrEmpty(x.StudentNo)).ToList(); if (studentNoVerifyList != null && studentNoVerifyList.Count() > 0) { throw new Exception("选择提交的名单中存在未生成学号的数据,请检查。"); } //有疑义名单判断 if (newStudentEnterList.Any(x => x.IsDoubt == true)) { throw new Exception("选择提交的名单中存在有疑议的数据,请检查。"); } //已提交状态判断 if (newStudentEnterList.Any(x => x.RecordStatus == (int)EMIS.ViewModel.CF_NewStudentEnterStatus.Submitted)) { throw new Exception("选择提交的名单中存在已提交的数据,请检查。"); } //年级 var gradeIDList = newStudentEnterList.Where(x => !string.IsNullOrEmpty(x.GradeID.ToString())).Select(x => x.GradeID).ToList(); //考生号 var examineeNumList = newStudentEnterList.Where(x => !string.IsNullOrEmpty(x.ExamineeNum)).Select(x => x.ExamineeNum).ToList(); ////准考证号 //var admissionTicketNoList = newStudentEnterList.Where(x => !string.IsNullOrEmpty(x.AdmissionTicketNo)).Select(x => x.AdmissionTicketNo).ToList(); //身份证号 var iDNumberList = newStudentEnterList.Where(x => !string.IsNullOrEmpty(x.IDNumber)).Select(x => x.IDNumber).ToList(); //学号 var studentNoList = newStudentEnterList.Where(x => !string.IsNullOrEmpty(x.StudentNo)).Select(x => x.StudentNo).ToList(); //查询学年学期信息(验证对应的年级专业的入学学期与Web.config配置是否一致,有班级信息相应的学年学期信息一定存在) //如不致,以年级专业对应的入学学期为准 var schoolyearVerifyList = NewStudentDAL.SchoolyearRepository.GetList(x => gradeIDList.Contains(x.Years)).ToList(); //班级信息ID var classIDList = newStudentEnterList.Where(x => !string.IsNullOrEmpty(x.ClassmajorID.ToString())).Select(x => x.ClassmajorID).ToList(); ////查询学生信息(用于验证考生号、准考证号) //var studentVerifyList = NewStudentDAL.RecruitstudentsRepository.GetList(x => examineeNumList.Contains(x.ExamineeNum) || admissionTicketNoList.Contains(x.AdmissionTicketNo)).ToList(); //查询学生信息(用于验证考生号) var studentVerifyList = NewStudentDAL.RecruitstudentsRepository.GetList(x => examineeNumList.Contains(x.ExamineeNum)).ToList(); //查询用户信息(用于验证学号) var userVerifyList = NewStudentDAL.UserRepository.GetList(x => studentNoList.Contains(x.LoginID)).ToList(); //查询班级信息(用于验证班级) var classMajorVerifyList = NewStudentDAL.ClassmajorRepository.GetList(x => classIDList.Contains(x.ClassmajorID)).ToList(); //年级专业ID(根据班级信息ID) var classMajorIDList = classMajorVerifyList.Where(x => !string.IsNullOrEmpty(x.GrademajorID.ToString())).Select(x => x.GrademajorID).ToList(); //查询年级专业(根据年级专业ID) var gradeMajorVerifyList = NewStudentDAL.GrademajorRepository.GetList(x => classMajorIDList.Contains(x.GrademajorID)).ToList(); //查询年级专业的毕业学期ID(根据年级专业ID) var gradschoolyearIDList = NewStudentDAL.GrademajorRepository.GetList(x => classMajorIDList.Contains(x.GrademajorID)).Select(x => x.GraduateSchoolyearID).ToList(); //查询毕业学期(用于验证毕业学期) var gradschoolyearVerifyList = NewStudentDAL.SchoolyearRepository.GetList(x => gradschoolyearIDList.Contains(x.SchoolyearID)).ToList(); //查询毕业学期对应的毕业日期List var graduateDateList = NewStudentDAL.GraduateSchoolyearRepository.GetList(x => true).ToList(); //查询学生用户密码规则定义 var passwordParameter = NewStudentDAL.ParameterRepository.GetSingle(x => x.ParameterTypeID == (int)ViewModel.CF_ParameterType.StudentInitPassword); //查询学生角色信息 var roleList = NewStudentDAL.RoleRepository.GetList(x => x.TypeID == (int)SYS_RoleType.Student, (x => x.CF_StudentRole)).ToList(); int studentfail = 0; int studentNofail = 0; int success = 0; string tipMessage = null; List newStudentUpList = new List(); List userInList = new List(); List studentInList = new List(); List studentProfileInList = new List(); List studentContactInList = new List(); List studentAccountInList = new List(); List studentRecruitInList = new List(); //List studentFamilyInList = new List(); //List studentExperienceInList = new List(); foreach (var newStudentEnter in newStudentEnterList) { Sys_User user = new Sys_User(); CF_Student student = new CF_Student(); CF_StudentProfile studentProfile = new CF_StudentProfile(); CF_StudentContact studentContact = new CF_StudentContact(); CF_StudentAccount studentAccount = new CF_StudentAccount(); CF_Recruitstudents studentRecruit = new CF_Recruitstudents(); //CF_StudentFamily studentFamily = new CF_StudentFamily(); //CF_StudentExperience studentExperience = new CF_StudentExperience(); //验证考生号 var examineeNumVerify = studentVerifyList.Where(x => x.ExamineeNum == newStudentEnter.ExamineeNum).SingleOrDefault(); if (examineeNumVerify == null) { ////验证准考证号 //if (!string.IsNullOrEmpty(newStudentEnter.AdmissionTicketNo)) //{ // var admissionTicketNoVerify = studentVerifyList.Where(x => x.AdmissionTicketNo == newStudentEnter.AdmissionTicketNo).SingleOrDefault(); // if (admissionTicketNoVerify != null) // { // //准考证号验证不通过 // studentfail++; // continue; // } //} //考生号验证通过,验证学号 var userVerify = userVerifyList.Where(x => x.LoginID == newStudentEnter.StudentNo).SingleOrDefault(); if (userVerify == null) { //学号验证通过 user.UserID = Guid.NewGuid(); user.LoginID = newStudentEnter.StudentNo; user.Name = newStudentEnter.Name; if (passwordParameter == null) { user.Password = ("A" + newStudentEnter.StudentNo).MD5(); } else { if (passwordParameter.Value != null) { user.Password = passwordParameter.Value; } else { user.Password = ("A" + newStudentEnter.StudentNo).MD5(); } } SetNewStatus(user, (int)SYS_STATUS.USABLE); userInList.Add(user); user.Sys_Role = new HashSet(); roleList = roleList.Where(x => x.CF_StudentRole.StudentType == (int)CF_STUDENTTYPE.DefaultType).ToList(); if (roleList != null && roleList.Count > 0) { roleList.ForEach(x => user.Sys_Role.Add(x)); } student.UserID = user.UserID; student.ClassmajorID = newStudentEnter.ClassmajorID; student.SexID = newStudentEnter.SexID; student.BirthDate = newStudentEnter.BirthDate; student.NationID = newStudentEnter.NationID; student.PoliticsID = newStudentEnter.PoliticsID; student.CertificatesType = newStudentEnter.CertificatesType; student.IDNumber = newStudentEnter.IDNumber; student.StudentType = (int)CF_STUDENTTYPE.DefaultType; student.InSchoolStatusID = (int)CF_InschoolStatus.InSchool; student.StudentStatus = (int)CF_StudentStatus.Registration; student.StudentCardNo = user.LoginID; student.PhotoUrl = null; //对应的班级信息 var classMajor = classMajorVerifyList.Where(x => x.ClassmajorID == newStudentEnter.ClassmajorID).SingleOrDefault(); //对应的年级专业的毕业学期 var gradeMajor = gradeMajorVerifyList.Where(x => x.GrademajorID == classMajor.GrademajorID).SingleOrDefault(); if (gradeMajor != null) { //查询对应毕业学期信息 var gradschoolyear = gradschoolyearVerifyList.Where(x => x.SchoolyearID == gradeMajor.GraduateSchoolyearID).SingleOrDefault(); if (gradschoolyear != null) { //预计毕业日期 student.PlanningGraduateDate = PlanningGraduateDateHelper.GetPlanningGraduateDate(gradschoolyear.FirstWeek); } else { //预计毕业日期 student.PlanningGraduateDate = null; } //查询对应的毕业日期 var graduateDate = graduateDateList.Where(x => x.SchoolyearID == gradeMajor.GraduateSchoolyearID).SingleOrDefault(); if (graduateDate != null) { //毕业日期 student.GraduateDate = graduateDate.GraduateDate; } else { //毕业日期 student.GraduateDate = null; } } else { //预计毕业日期 student.PlanningGraduateDate = null; //毕业日期 student.GraduateDate = null; } student.GraduateCardNo = null; student.ReplaceGraduateNo = null; student.DegreeStatus = false; student.GraduationPictureUrl = null; student.Career = null; student.IsPhotoComparison = false; student.IsProofread = false; student.Remark = newStudentEnter.Remark; SetNewStatus(student, (int)SYS_STATUS.USABLE); studentInList.Add(student); studentProfile.UserID = user.UserID; studentProfile.UsedName = null; studentProfile.LiteracyLevelID = null; studentProfile.CultureModelID = null; studentProfile.IsDreamProject = false; studentProfile.Country = "中国"; studentProfile.Place = null; studentProfile.BornPlace = null; studentProfile.HealthStateID = null; studentProfile.BloodGroup = null; studentProfile.Specialty = null; studentProfile.Height = null; studentProfile.Weight = null; studentProfile.DirectorName = null; SetNewStatus(studentProfile, (int)SYS_STATUS.USABLE); studentProfileInList.Add(studentProfile); studentContact.UserID = user.UserID; studentContact.Email = null; studentContact.Telephone = newStudentEnter.Telephone; studentContact.Mobile = newStudentEnter.Telephone; studentContact.ZIPCode = newStudentEnter.ZIPCode; studentContact.WeChatNum = null; studentContact.QQ = null; studentContact.HomeAddress = null; studentContact.WorkUnit = null; studentContact.Address = newStudentEnter.Address; studentContact.Recipient = newStudentEnter.Name; studentContact.Dormitory = null; SetNewStatus(studentContact, (int)SYS_STATUS.USABLE); studentContactInList.Add(studentContact); studentAccount.UserID = user.UserID; studentAccount.CardNo = null; studentAccount.BankName = null; SetNewStatus(studentAccount, (int)SYS_STATUS.USABLE); studentAccountInList.Add(studentAccount); studentRecruit.UserID = user.UserID; studentRecruit.ExamineeNum = newStudentEnter.ExamineeNum; studentRecruit.AdmissionTicketNo = newStudentEnter.AdmissionTicketNo; studentRecruit.ExamineeType = null; //查询对应入学学年学期 var enterSchoolYear = schoolyearVerifyList.Where(x => x.Years == newStudentEnter.GradeID && x.SchoolcodeID == classMajor.CF_Grademajor.SemesterID).SingleOrDefault(); if (enterSchoolYear != null) { studentRecruit.EnteringSchoolYearID = enterSchoolYear.SchoolyearID; } else { studentRecruit.EnteringSchoolYearID = null; } studentRecruit.EntranceDate = newStudentEnter.EntranceDate; studentRecruit.Score = newStudentEnter.Score; studentRecruit.EntranceWayID = newStudentEnter.EntranceWayID; studentRecruit.FeaturesID = newStudentEnter.FeaturesID; studentRecruit.TerritorialID = newStudentEnter.TerritorialID; studentRecruit.Area = null; studentRecruit.RecruitPictureUrl = newStudentEnter.RecruitPictureUrl; SetNewStatus(studentRecruit, (int)SYS_STATUS.USABLE); studentRecruitInList.Add(studentRecruit); //studentFamily.StudentFamilyID = Guid.NewGuid(); //studentFamily.UserID = user.UserID; //SetNewStatus(studentFamily, (int)SYS_STATUS.USABLE); //studentFamilyInList.Add(studentFamily); //studentExperience.StudentExperienceID = Guid.NewGuid(); //studentExperience.UserID = user.UserID; //SetNewStatus(studentExperience, (int)SYS_STATUS.USABLE); //studentExperienceInList.Add(studentExperience); //获取提交成功的录取名单信息(用于做其它的处理,如:删除、更新等) newStudentEnter.RecordStatus = (int)CF_NewStudentEnterStatus.Submitted; SetModifyStatus(newStudentEnter); newStudentUpList.Add(newStudentEnter); success++; } else { //学号验证不通过 studentNofail++; continue; } } else { //考生号验证不通过 studentfail++; continue; } } using (TransactionScope ts = new TransactionScope()) { //批量插入 UnitOfWork.BulkInsert(userInList); UnitOfWork.BulkInsert(userInList, (x => x.Sys_Role)); //插入相应的关系表 UnitOfWork.BulkInsert(studentInList); UnitOfWork.BulkInsert(studentProfileInList); UnitOfWork.BulkInsert(studentContactInList); UnitOfWork.BulkInsert(studentAccountInList); UnitOfWork.BulkInsert(studentRecruitInList); //UnitOfWork.BulkInsert(studentFamilyInList); //UnitOfWork.BulkInsert(studentExperienceInList); //刷新对应的学生相关信息 StudentServices.Value.AddStudentEnd(studentInList.Select(x => x.UserID).ToList()); //提交成功后,更新相应的录取名单状态 if (newStudentUpList != null && newStudentUpList.Count() > 0) { UnitOfWork.BatchUpdate(newStudentUpList); //批量更新 } ts.Complete(); } if (studentfail <= 0 && studentNofail <= 0) { tipMessage = success + "条录取名单进入学生信息库"; } else { if (studentNofail > 0 && studentfail <= 0) { tipMessage = success + "条录取名单进入学生信息库," + studentNofail + "条录取名单提交失败,原因:学号已存在,请检查"; } else if (studentNofail <= 0 && studentfail > 0) { tipMessage = success + "条录取名单进入学生信息库," + studentfail + "条录取名单提交失败,原因:考生号或准考证号已存在,请检查"; } else { tipMessage = success + "条录取名单进入学生信息库," + studentNofail + "条录取名单由于学号已存在提交失败," + studentfail + "条录取名单由于考生号或准考证号已存在提交失败,请检查"; } } return tipMessage; } catch (Exception ex) { throw new Exception(ex.Message); } } } }