123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Common.Specialtymanage;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.Specialtymanage;
- using EMIS.ViewModel;
- using System.Text.RegularExpressions;
- using Bowin.Common.Utility;
- using EMIS.ViewModel.Cache;
- using EMIS.Utility;
- using System.Linq.Expressions;
- using EMIS.DataLogic.ExamManage;
- using EMIS.DataLogic.CerificateManage;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.ViewModel.CerificateManage;
- using EMIS.DataLogic.Repositories;
- namespace EMIS.CommonLogic.CerificateManage
- {
- public class CertisfierDistributeServices : BaseServices, ICertisfierDistributeServices
- {
- public ProjectScoreRepository ProjectScoreRepository { get; set; }
- public CertisfierDistributeDAL Logic { get; set; }
- public ISerialNumberServices SerialNumberService { get; set; }
- public IGridResultSet<ExamBatchProjectView> GetExamProjectListViewGrid(int pageIndex, int pageSize, params EMIS.ViewModel.ConfiguretView[] configuretViews)
- {
- System.Linq.Expressions.Expression<Func<ER_CertisfierDistribute, bool>> expCampus = (x => true);
- var query = Logic.GetCerificateViewListOnlyGenerated(expCampus, x => true, x => true, x => true, x => true);
- //查询条件
- foreach (var configuretView in configuretViews)
- {
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- var result = query.OrderBy(x => x.ExaminationProjectID).GroupBy(x => new
- {
- x.ExaminationProjectID,
- x.ProjectName,
- }).Select(x => new ExamBatchProjectView()
- {
- ExaminationProjectID = x.Key.ExaminationProjectID.Value,
- Name = x.Key.ProjectName,
- });
- return result
- .OrderBy(x => x.ExaminationProjectID)
- .ToGridResultSet<ExamBatchProjectView>(pageIndex, pageSize);
- }
- public object GetCertisfierListViewGrid(ConfiguretView examinationSubjectView, Guid? schoolyearID,
- Guid? examinationProjectID, Guid? collegeID, int? schoolAreaID, int? year, Guid? classmajorID, int? standardID, int? distributeTypeID, int? recordStatus,
- Guid? userid,int pageIndex, int pageSize)
- {
- Expression<Func<ER_CertisfierDistribute, bool>> expCertisfier = (x => true);
- Expression<Func<CF_College, bool>> expcol = (x => true);
- Expression<Func<CF_Grademajor, bool>> expgra = (x => true);
- Expression<Func<CF_Classmajor, bool>> expcla = (x => true);
- Expression<Func<CF_Facultymajor, bool>> expfac = (x => true);
- if (schoolyearID.HasValue)
- {
- expCertisfier = expCertisfier.And(x => x.SchoolyearID == schoolyearID);
- }
- if (examinationProjectID.HasValue)
- {
- expCertisfier = expCertisfier.And(x => x.ExaminationProjectID == examinationProjectID);
- }
- if (collegeID.HasValue)
- {
- expcol = expcol.And(x => x.CollegeID == collegeID);
- }
- if (schoolAreaID.HasValue)
- {
- expgra = expgra.And(x => x.SchoolAreaID == schoolAreaID);
- }
- if (year.HasValue)
- {
- expgra = expgra.And(x => x.SchoolyearID == year);
- }
- if (classmajorID.HasValue)
- {
- expcla = expcla.And(x => x.ClassmajorID == classmajorID);
- }
- if (standardID.HasValue)
- {
- expfac = expfac.And(x => x.StandardID == standardID);
- }
- if (distributeTypeID.HasValue)
- {
- expCertisfier = expCertisfier.And(x => x.DistributeTypeID == distributeTypeID);
- }
- if (recordStatus.HasValue)
- {
- expCertisfier = expCertisfier.And(x => x.RecordStatus == recordStatus);
- }
- if (userid.HasValue)
- {
- expCertisfier = expCertisfier.And(x => x.UserID == userid);
- }
- var query = Logic.GetCerificateViewListOnlyGenerated(expCertisfier, expcol, expgra, expcla, expfac);
-
- if (!string.IsNullOrEmpty(examinationSubjectView.ConditionValue) && !string.IsNullOrEmpty(examinationSubjectView.Attribute))
- query = query.DynamicWhere(examinationSubjectView.Attribute, examinationSubjectView.Condition, examinationSubjectView.ConditionValue);
- query = this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query));
- int Count = query.Count();
- int Already = query.Where(x => x.RecordStatus == (int)ER_CertisfierDistributeStatus.Complete).Count();
- int NotReceived = query.Where(x => x.RecordStatus == (int)ER_CertisfierDistributeStatus.Waiting).Count();
- var pages = query.OrderBy(x => x.RecordStatus).ThenByDescending(x => x.SchoolYearCode).ThenBy(x => x.ProjectName).ThenBy(x => x.SaveNo.Length).ThenBy(x => x.SaveNo).ThenBy(x => x.ClassmajorName).ThenBy(x => x.IDNumber)
- .ToGridResultSet<EMIS.ViewModel.CerificateView>(pageIndex, pageSize);
- return new { Count = Count, Already = Already, NotReceived = NotReceived, rows = pages.rows, pages.total };
- //return query.OrderBy(x => x.Schoolyear).ThenByDescending(x => x.Years).ThenBy(x => x.IDNumber).ToGridResultSet<CerificateView>(pageIndex, pageSize);
- }
- public ViewModel.CerificateView GetView(Guid? ViewID)
- {
- Expression<Func<ER_CertisfierDistribute, bool>> expCertisfier = (x => true);
- if (ViewID.HasValue)
- {
- expCertisfier = expCertisfier.And(x => x.CertisfierDistributeID == ViewID);
- }
- var query = Logic.GetCerificateViewListOnlyGenerated(expCertisfier, x => true, x => true, x => true, x => true).FirstOrDefault();
- return query;
- }
- public void Edit(ViewModel.CerificateView view)
- {
- UnitOfWork.Delete<ER_CertisfierDistribute>(q => q.CertisfierDistributeID == view.CertisfierDistributeID);
- Logic.DistributeRepository.UnitOfWork.Commit();
- }
- public void UpdateCertisfierDistributeType(ViewModel.CerificateView view)
- {
- Logic.DistributeRepository.UnitOfWork.Update<ER_CertisfierDistribute>(x => new ER_CertisfierDistribute()
- {
- DistributeTypeID = view.DistributeTypeID,
- ContactPerson = view.DistributeTypeID == (int)ER_CertisfierDistributeType.Self ? null : (view.DistributeTypeID == (int)ER_CertisfierDistributeType.Entrust ? view.EntrustDistributer : view.ContactPerson),
- ContactNo = view.DistributeTypeID == (int)ER_CertisfierDistributeType.Self ? null : (view.DistributeTypeID == (int)ER_CertisfierDistributeType.Entrust ? view.ContactNo : view.MailContactNo),
- ContactIDNo = view.ContactIDNo,
- Address = view.Address,
- ModifyTime = DateTime.Now,
- },
- x => view.CertisfierDistributeID == x.CertisfierDistributeID);
- UnitOfWork.Commit();
- }
- public ViewModel.CerificateView GetView(System.Linq.Expressions.Expression<Func<Entities.ER_CertisfierDistribute, bool>> expCampus)
- {
- var query = Logic.GetCerificateViewListOnlyGenerated(expCampus, x => true, x => true, x => true, x => true).SingleOrDefault();
- return query;
- }
- public List<CerificateView> GetList(ConfiguretView examinationSubjectView, Guid? schoolyearID,
- Guid? examinationProjectID, Guid? collegeID, int? schoolAreaID, int? year, Guid? classmajorID, int? standardID, int? distributeTypeID, int? recordStatus,
- List<Guid?> ids)
- {
- Expression<Func<ER_CertisfierDistribute, bool>> expCertisfier = (x => true);
- Expression<Func<CF_College, bool>> expcol = (x => true);
- Expression<Func<CF_Grademajor, bool>> expgra = (x => true);
- Expression<Func<CF_Classmajor, bool>> expcla = (x => true);
- Expression<Func<CF_Facultymajor, bool>> expfac = (x => true);
- if (schoolyearID.HasValue)
- {
- expCertisfier = expCertisfier.And(x => x.SchoolyearID == schoolyearID);
- }
- if (examinationProjectID.HasValue)
- {
- expCertisfier = expCertisfier.And(x => x.ExaminationProjectID == examinationProjectID);
- }
- if (collegeID.HasValue)
- {
- expcol = expcol.And(x => x.CollegeID == collegeID);
- }
- if (schoolAreaID.HasValue)
- {
- expgra = expgra.And(x => x.SchoolAreaID == schoolAreaID);
- }
- if (year.HasValue)
- {
- expgra = expgra.And(x => x.SchoolyearID == year);
- }
- if (classmajorID.HasValue)
- {
- expcla = expcla.And(x => x.ClassmajorID == classmajorID);
- }
- if (standardID.HasValue)
- {
- expfac = expfac.And(x => x.StandardID == standardID);
- }
- if (distributeTypeID.HasValue)
- {
- expCertisfier = expCertisfier.And(x => x.DistributeTypeID == distributeTypeID);
- }
- if (recordStatus.HasValue)
- {
- expCertisfier = expCertisfier.And(x => x.RecordStatus == recordStatus);
- }
- if (ids.Count() > 0)
- {
- expCertisfier = expCertisfier.And(x => ids.Contains(x.CertisfierDistributeID));
- }
- //if (userid.HasValue)
- //{
- // expCertisfier = expCertisfier.And(x => x.UserID == userid);
- //}
- var query = Logic.GetCerificateViewListOnlyGenerated(expCertisfier, expcol, expgra, expcla, expfac);
- if (!string.IsNullOrEmpty(examinationSubjectView.ConditionValue) && !string.IsNullOrEmpty(examinationSubjectView.Attribute))
- query = query.DynamicWhere(examinationSubjectView.Attribute, examinationSubjectView.Condition, examinationSubjectView.ConditionValue);
- return query.OrderBy(x => x.RecordStatus).ThenByDescending(x => x.SchoolYearCode).ThenBy(x => x.ProjectName).ThenBy(x => x.SaveNo.Length).ThenBy(x => x.SaveNo).ThenBy(x => x.ClassmajorName).ThenBy(x => x.IDNumber).ToList();
- }
- public bool Delete(List<Guid?> IDs)
- {
- UnitOfWork.Delete<ER_CertisfierDistribute>(x => IDs.Contains(x.CertisfierDistributeID));
- UnitOfWork.Commit();
- return true;
- }
- public bool OpenDistribute(List<Guid?> IDs)
- {
- //var list = ProjectScoreRepository.GetList(x => IDs.Contains(x.ProjectScoreID)).ToList();
- //var distributeList = Logic.GetCertisfierDistributByProjectScore(x => IDs.Contains(x.ProjectScoreID)).ToList();
- //if (distributeList.Any(x => x.RecordStatus != (int)ER_CertisfierDistributeStatus.Making))
- //{
- // throw new Exception("证书已经开放领取,不能重复开放。");
- //}
- ////判断是否已经有证书领取表的记录,没有则新增,有则更改状态
- //foreach (var item in list)
- //{
- // var distribute = distributeList.SingleOrDefault(x => x.ExaminationProjectID == item.ExaminationProjectID && x.UserID == item.UserID);
- // if (distribute == null)
- // {
- // distribute = new ER_CertisfierDistribute()
- // {
- // UserID = item.UserID,
- // CertisfierDistributeID = Guid.NewGuid(),
- // ExaminationProjectID = item.ExaminationProjectID,
- // DistributeTypeID = (int)ER_CertisfierDistributeType.Self
- // };
- // SetNewStatus<ER_CertisfierDistribute>(distribute);
- // distribute.RecordStatus = (int)ER_CertisfierDistributeStatus.Waiting;
- // UnitOfWork.Add(distribute);
- // }
- // else if (distribute.RecordStatus == (int)ER_CertisfierDistributeStatus.Making)
- // {
- // distribute.RecordStatus = (int)ER_CertisfierDistributeStatus.Waiting;
- // }
- //}
- try
- {
- var list = Logic.DistributeRepository.Entities.Where(x => IDs.Contains(x.CertisfierDistributeID)).ToList();
- list.ForEach(x => {
- x.RecordStatus = (int)ER_CertisfierDistributeStatus.Waiting;
- x.DistributeTypeID = (int)ER_CertisfierDistributeType.Self;
- });
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- public bool CancelOpenDistribute(List<Guid?> IDs)
- {
- var hasCantCancel = Logic.DistributeRepository.Entities.Any(x => IDs.Contains(x.CertisfierDistributeID) && x.RecordStatus != (int)ER_CertisfierDistributeStatus.Waiting);
- if (hasCantCancel)
- {
- throw new Exception("只能撤销待领证状态的信息。");
- }
- Logic.DistributeRepository.UnitOfWork.Update<ER_CertisfierDistribute>(x => new ER_CertisfierDistribute() { RecordStatus = (int)ER_CertisfierDistributeStatus.Making, DistributeTypeID = null, Distributer = null, DistributeTime = null, No = null }, x => IDs.Contains(x.CertisfierDistributeID));
- UnitOfWork.Commit();
- return true;
- }
- public bool CancelDistribute(List<Guid?> IDs)
- {
- var hasCantCancel = Logic.DistributeRepository.Entities.Any(x => IDs.Contains(x.CertisfierDistributeID) && x.RecordStatus != (int)ER_CertisfierDistributeStatus.Complete);
- if (hasCantCancel)
- {
- throw new Exception("只能撤销已领证状态的信息。");
- }
- Logic.DistributeRepository.UnitOfWork.Update<ER_CertisfierDistribute>(x => new ER_CertisfierDistribute() { RecordStatus = (int)ER_CertisfierDistributeStatus.Waiting, Distributer = null, DistributeTime = null, No = null }, x => IDs.Contains(x.CertisfierDistributeID));
- UnitOfWork.Commit();
- return true;
- }
- public bool ConfirmDistribute(List<Guid?> IDs, string Distributer)
- {
- var list = Logic.DistributeRepository.Entities.Where(x => IDs.Contains(x.CertisfierDistributeID)).ToList();
- var nowTime = DateTime.Now;
- var distributeNo = SerialNumberService.SetDialySN(Const.EX_CERTISFIERDISTRIBUTE_NO_PREFIX, 3)
- .Replace(Const.EX_CERTISFIERDISTRIBUTE_NO_PREFIX, Const.EX_CERTISFIERDISTRIBUTE_NO_PREFIX + DateTime.Today.ToString("yyMMdd"));
- //更新状态为待领取的
- foreach (var distribute in list)
- {
- if (distribute.RecordStatus == (int)ER_CertisfierDistributeStatus.Complete)
- {
- throw new Exception("待领证状态下的数据才能确认领取,如果需要重新确认领取,请先进行撤销领取操作");
- }
- if (distribute.RecordStatus == (int)ER_CertisfierDistributeStatus.Making)
- {
- throw new Exception("只有待领证状态下的数据才能确认领取");
- }
- if (distribute != null && distribute.RecordStatus == (int)ER_CertisfierDistributeStatus.Waiting)
- {
- distribute.RecordStatus = (int)ER_CertisfierDistributeStatus.Complete;
- distribute.Distributer = Distributer;
- distribute.DistributeTime = nowTime;
- distribute.No = distributeNo;
- //SerialNumberService.GetSN("LQ", 3, DateTime.Now.ToString("yyMMdd"));
- }
- }
- UnitOfWork.Commit();
- return true;
- }
- /// <summary>
- /// Excel导入
- /// </summary>
- /// <param name="cellheader"></param>
- /// <param name="inCount"></param>
- /// <param name="upCount"></param>
- /// <param name="errdataList"></param>
- /// <param name="errCount"></param>
- /// <param name="sourcePhysicalPath"></param>
- public void Import(Dictionary<string, string> cellheader, out int? inCount, out int? upCount,
- out List<CerificateView> errdataList, out int? errCount, string sourcePhysicalPath)
- {
- try
- {
- StringBuilder errorMsg = new StringBuilder(); // 错误信息
- List<CerificateView> errList = new List<CerificateView>();
- // 1.1解析文件,存放到一个List集合里
- cellheader.Remove("ErrorMessage");//移除“未导入原因”列(ErrorMessage)
- List<CerificateView> enlist = NpoiExcelHelper.ExcelToEntityList<CerificateView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
- cellheader.Add("ErrorMessage", "未导入原因");
- //对List集合进行有效性校验
- if (enlist.Count() <= 0)
- {
- throw new Exception("Excel文件数据为空,请检查。");
- }
- Regex reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$"); //学制字段正则表达式()
- inCount = 0; //导入个数
- upCount = 0; //更新个数
- errCount = 0; //失败个数
- string errorMsgStr = ""; //错误信息
- List<CerificateView> upList = new List<CerificateView>(); //专业信息update实体List
- //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等)
- for (int i = 0; i < enlist.Count; i++)
- {
- CerificateView en = enlist[i]; //Excel表数据视图
- CF_Specialty specialty = new CF_Specialty(); //专业信息实体
- //证件号码
- if (string.IsNullOrEmpty(en.IDNumber))
- {
- errCount++;
- errorMsgStr = "证件号码不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- //考试项目
- if (string.IsNullOrEmpty(en.ProjectName))
- {
- errCount++;
- errorMsgStr = "考试项目不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- //邮寄单号
- if (string.IsNullOrEmpty(en.DeliveryNoteNo))
- {
- errCount++;
- errorMsgStr = "邮寄单号不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- var entity = Logic.GetCerificateViewListOnlyGenerated(x => true, x => true, x => true, x => true, x => true).Where(x => x.ProjectName == en.ProjectName && x.IDNumber == en.IDNumber).FirstOrDefault();
- if (entity == null)
- {
- errCount++;
- errorMsgStr = "找不到考试项目和对应的学生";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- if (entity.RecordStatus == (int)ER_CertisfierDistributeStatus.Making)
- {
- errCount++;
- errorMsgStr = "制证中不允许导入";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- UnitOfWork.Update<ER_CertisfierDistribute>(x => new ER_CertisfierDistribute() { DeliveryNoteNo = en.DeliveryNoteNo, ContactPerson = en.ContactPerson, ContactNo = en.ContactNo, Address = en.Address, RecordStatus = (int)ER_CertisfierDistributeStatus.Complete }, x => x.CertisfierDistributeID == entity.CertisfierDistributeID);
- upCount++;
- }
- UnitOfWork.Commit();
- errdataList = errList.Distinct().ToList(); //错误列表List
- }
- catch (Exception ex)
- {
- //目前会出现,由于错误信息字符太长,无法抛出弹出框的问题
- throw new Exception(ex.Message);
- }
- }
- public IGridResultSet<CertificateMobileView> GetCertificateMobileViewGrid(int? pageIndex, int? pageSize, Guid userID)
- {
- Expression<Func<ER_ProjectScore, bool>> exp = (x => x.UserID == userID);
- Expression<Func<ER_ProjectScore, bool>> detailExp = (x => true);
- var certificateViewList = this.Logic.GetCertificateMobileViewQueryable(exp)
- .OrderBy(x => x.DistributeStatusID).ToGridResultSet(pageIndex, pageSize);
- if (pageSize.HasValue && pageIndex.HasValue)
- {
- var projectScoreIDList = certificateViewList.rows.Select(x => x.ProjectScoreID).ToList();
- //detailExp = (x => projectScoreIDList.Contains(x.ProjectScoreID));
- }
- else
- {
- detailExp = exp;
- }
- //var scoreList = this.Logic.GetCertificateMobileScoreViewQueryable(exp).ToList();
- //certificateViewList.rows.ForEach(x =>
- //{
- // var curScoreList = scoreList.Where(w => w.ExaminationProjectID == x.ExaminationProjectID).ToList();
- // x.ScoreViewList = curScoreList;
- //});
- return certificateViewList;
- }
- /// <summary>
- /// 存放编号导入
- /// </summary>
- /// <param name="cellheader"></param>
- /// <param name="inCount"></param>
- /// <param name="upCount"></param>
- /// <param name="errdataList"></param>
- /// <param name="errCount"></param>
- /// <param name="sourcePhysicalPath"></param>
- public void NumberImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount,
- out List<CerificateView> errdataList, out int? errCount, string sourcePhysicalPath)
- {
- try
- {
- StringBuilder errorMsg = new StringBuilder(); // 错误信息
- List<CerificateView> errList = new List<CerificateView>();
- var CerificateList = Logic.DistributeRepository.Entities.ToList();
- var CerificateViewList = Logic.GetCerificateViewListOnlyGenerated(x => true, x => true, x => true, x => true, x => true).ToList();
- var ProjectList = Logic.ExaminationProjectRepository.Entities.ToList();
- var studentList = Logic.StudentRepository.Entities.ToList();
- var userList = Logic.UserRepository.Entities.ToList();
- // 1.1解析文件,存放到一个List集合里
- cellheader.Remove("ErrorMessage");//移除“未导入原因”列(ErrorMessage)
- List<CerificateView> enlist = NpoiExcelHelper.ExcelToEntityList<CerificateView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
- cellheader.Add("ErrorMessage", "未导入原因");
- //对List集合进行有效性校验
- if (enlist.Count() <= 0)
- {
- throw new Exception("Excel文件数据为空,请检查。");
- }
- Regex reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$"); //学制字段正则表达式()
- inCount = 0; //导入个数
- upCount = 0; //更新个数
- errCount = 0; //失败个数
- string errorMsgStr = ""; //错误信息
- List<ER_CertisfierDistribute> upList = new List<ER_CertisfierDistribute>(); //专业信息update实体List
- //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等)
- for (int i = 0; i < enlist.Count; i++)
- {
- CerificateView en = enlist[i]; //Excel表数据视图
- //证件号码
- if (string.IsNullOrEmpty(en.IDNumber))
- {
- errCount++;
- errorMsgStr = "证件号码不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else if (!studentList.Any(x => x.IDNumber.Trim() == en.IDNumber.Trim()))
- {
- errCount++;
- errorMsgStr = "学生不存在,请检查证件号码";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- //考试项目
- if (string.IsNullOrEmpty(en.ProjectName))
- {
- errCount++;
- errorMsgStr = "考试项目不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else if (!ProjectList.Any(x => x.Name.Trim() == en.ProjectName.Trim()))
- {
- errCount++;
- errorMsgStr = "考试项目不存在,请检查考试项目名称";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- var entity = CerificateViewList.Where(x => x.ProjectName.Trim() == en.ProjectName.Trim() && x.IDNumber.Trim() == en.IDNumber.Trim()).FirstOrDefault();
- if (entity == null)
- {
- errCount++;
- errorMsgStr = "找不到考试项目和对应的学生,请检查该学生是否有该项目的证书";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- if (entity.RecordStatus == (int)ER_CertisfierDistributeStatus.Making || entity.RecordStatus == null)
- {
- errCount++;
- errorMsgStr = "制证中的证书无法导入存放编号";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- //if (entity.RecordStatus == (int)ER_CertisfierDistributeStatus.Making)
- //{
- // errCount++;
- // errorMsgStr = "制证中不允许导入";
- // en.ErrorMessage = errorMsgStr;
- // errList.Add(en);
- // errorMsg.AppendLine(errorMsgStr);
- // continue;
- //}
- //UnitOfWork.Update<ER_CertisfierDistribute>(x => new ER_CertisfierDistribute() { DeliveryNoteNo = en.DeliveryNoteNo, ContactPerson = en.ContactPerson, ContactNo = en.ContactNo, Address = en.Address, RecordStatus = (int)ER_CertisfierDistributeStatus.Complete }, x => x.CertisfierDistributeID == entity.CertisfierDistributeID);
- //CerificateList.FirstOrDefault(x => x.)
- var Cerificate = CerificateList.FirstOrDefault(x => x.ExaminationProjectID == entity.ExaminationProjectID && x.UserID == entity.UserID);
- Cerificate.SaveNo = en.SaveNo;
- upList.Add(Cerificate);
- upCount++;
- }
- UnitOfWork.BatchUpdate(upList);
- errdataList = errList.Distinct().ToList(); //错误列表List
- }
- catch (Exception ex)
- {
- //目前会出现,由于错误信息字符太长,无法抛出弹出框的问题
- throw new Exception(ex.Message);
- }
- }
- }
- }
|