123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571 |
-
- using Bowin.Common.Linq.Entity;
- using EMIS.DataLogic.ScoreManage;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.ScoreManage;
- using System;
- using Bowin.Common.Linq;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using Bowin.Common.Utility;
- using System.Data;
- using EMIS.DataLogic.Common.Students;
- using EMIS.Utility;
- using System.Web;
- using System.IO;
- using System.Web.Mvc;
- using EMIS.DataLogic.ExamManage;
- using System.Transactions;
- using EMIS.DataLogic.Repositories;
- using System.Threading;
- using System.Globalization;
- namespace EMIS.CommonLogic.ScoreManage
- {
- public class ExaminationScoreServices:BaseServices, IExaminationScoreServices
- {
- public LevelSettingSubjectDAL levelSettingSubjectDAL { get; set; }
- public ExaminationScoreDAL examinationScoreDAL { get; set; }
- public StudentsDAL studentsDAL { get; set; }
- public ExaminationRegistrationRepository examinationRegistrationRepository { get; set; }
- public ExaminationProjectFeeTypeRepository examinationProjectFeeTypeRepository { get; set; }
- public LevelSettingRepository levelSettingRepository { get; set; }
- public LevelSettingSubjectRepository levelSettingSubjectRepository { get; set; }
- public ExaminationProjectRepository examinationProjectRepository { get; set; }
- public ProjectFeeDAL ProjectFeeDAL { get; set; }
- public IGridResultSet<ExaminationScoreView> GetExaminationScoreViewGrid(ConfiguretView configuretView, Guid? schoolYearID, Guid? examinationBatchID,
- Guid? examinationTypeID, Guid? examinationProjectID, int? campusID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID,
- int pageIndex, int pageSize)
- {
- Expression<Func<ER_ExaminationScore, bool>> esexp = x => true;
- Expression< Func < EX_ExaminationBatchProject, bool>> ebrexp = x => true;
- Expression<Func<EX_ExaminationBatch, bool>> ebexp = x => true;
- Expression<Func<EX_ExaminationProject, bool>> epexp = x => true;
- Expression<Func<CF_Classmajor, bool>> claexp = x => true;
- Expression< Func < CF_Grademajor, bool>> graexp = x => true;
- Expression<Func<CF_Facultymajor, bool>> facexp = x => true;
- Expression< Func < CF_College, bool>> colexp = x => true;
- if (schoolYearID.HasValue)
- ebexp = ebexp.And(x => x.SchoolyearID == schoolYearID);
- if (examinationBatchID.HasValue)
- ebrexp = ebrexp.And(x => x.ExaminationBatchID == examinationBatchID);
- if (examinationTypeID.HasValue)
- epexp = epexp.And(x => x.ExaminationTypeID == examinationTypeID);
- if (examinationProjectID.HasValue)
- ebrexp = ebrexp.And(x => x.ExaminationProjectID == examinationProjectID);
- if (campusID.HasValue)
- graexp = graexp.And(x => x.SchoolAreaID == campusID);
- if (collegeID.HasValue)
- colexp = colexp.And(x => x.CollegeID == collegeID);
- if (year.HasValue)
- graexp = graexp.And(x => x.SchoolyearID == year);
- if (standardID.HasValue)
- facexp = facexp.And(x => x.StandardID == standardID);
- if (classmajorID.HasValue)
- claexp = claexp.And(x => x.ClassmajorID == classmajorID);
- var query = examinationScoreDAL.GetExaminationScoreView(esexp, ebrexp, ebexp, epexp, claexp, graexp, facexp, colexp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- return this.GetQueryByAssistant(query, (x => x.ClassmajorID), this.GetQueryByDataRangeByCollege(query)).OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.ExaminationBatchID).ThenBy(x => x.ExaminationTypeID).ThenBy(x => x.ExaminationProjectID)
- .ThenBy(x => x.ExaminationSubjectID).ThenByDescending(x => x.SchoolyearNumID).ThenBy(x => x.CollegeID).ThenBy(x => x.StandardID).ThenBy(x => x.ClassmajorID)
- .ThenBy(x => x.StudentNo).ToGridResultSet<ExaminationScoreView>(pageIndex, pageSize);
- }
- public List<ExaminationScoreView> GetExaminationScoreViewList(ConfiguretView configuretView, Guid? schoolYearID, Guid? examinationBatchID,
- Guid? examinationTypeID, Guid? examinationProjectID, int? campusID, Guid? collegeID, int? year, int? standardID, Guid? classmajorID,
- List<Guid?> idList)
- {
- Expression<Func<ER_ExaminationScore, bool>> esexp = x => true;
- Expression<Func<EX_ExaminationBatchProject, bool>> ebrexp = x => true;
- Expression<Func<EX_ExaminationBatch, bool>> ebexp = x => true;
- Expression<Func<EX_ExaminationProject, bool>> epexp = x => true;
- Expression<Func<CF_Classmajor, bool>> claexp = x => true;
- Expression<Func<CF_Grademajor, bool>> graexp = x => true;
- Expression<Func<CF_Facultymajor, bool>> facexp = x => true;
- Expression<Func<CF_College, bool>> colexp = x => true;
- if (schoolYearID.HasValue)
- ebexp = ebexp.And(x => x.SchoolyearID == schoolYearID);
- if (examinationBatchID.HasValue)
- ebrexp = ebrexp.And(x => x.ExaminationBatchID == examinationBatchID);
- if (examinationTypeID.HasValue)
- epexp = epexp.And(x => x.ExaminationTypeID == examinationTypeID);
- if (examinationProjectID.HasValue)
- ebrexp = ebrexp.And(x => x.ExaminationProjectID == examinationProjectID);
- if (campusID.HasValue)
- graexp = graexp.And(x => x.SchoolAreaID == campusID);
- if (collegeID.HasValue)
- colexp = colexp.And(x => x.CollegeID == collegeID);
- if (year.HasValue)
- graexp = graexp.And(x => x.SchoolyearID == year);
- if (standardID.HasValue)
- facexp = facexp.And(x => x.StandardID == standardID);
- if (classmajorID.HasValue)
- claexp = claexp.And(x => x.ClassmajorID == classmajorID);
- if (idList.Count > 0)
- {
- esexp = esexp.And(x => idList.Contains(x.ExaminationScoreID));
- }
- var query = examinationScoreDAL.GetExaminationScoreView(esexp, ebrexp, ebexp, epexp, claexp, graexp, facexp, colexp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- return query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.ExaminationBatchID).ThenBy(x => x.ExaminationTypeID).ThenBy(x => x.ExaminationProjectID)
- .ThenBy(x => x.ExaminationSubjectID).ThenByDescending(x => x.SchoolyearNumID).ThenBy(x => x.CollegeID).ThenBy(x => x.StandardID).ThenBy(x => x.ClassmajorID)
- .ThenBy(x => x.StudentNo).ToList();
- }
- public ExaminationScoreView GetExaminationScoreView(Guid? examinationScoreID)
- {
- try
- {
- var examinationScoreView = examinationScoreDAL.GetExaminationScoreView(x => x.ExaminationScoreID == examinationScoreID, x => true, x => true, x => true, x => true, x => true, x => true, x => true).FirstOrDefault();
- return examinationScoreView;
- }
- catch (Exception)
- {
- throw;
- }
- }
- public void Edit(ExaminationScoreView examinationScoreView)
- {
- try
- {
- var ExaminationBatchProject = examinationScoreDAL.examinationBatchProjectRepository.Entities.Where(x => x.ExaminationBatchID == examinationScoreView.ExaminationBatchID && x.ExaminationProjectID == examinationScoreView.ExaminationProjectID).FirstOrDefault();
- var user = examinationScoreDAL.studentRepository.Entities.Where(x => x.UserID == examinationScoreView.UserID).FirstOrDefault();
- var examinationRegistration = examinationRegistrationRepository.Entities.Where(x => x.ExaminationBatchProjectID == ExaminationBatchProject.ExaminationBatchProjectID && x.UserID == examinationScoreView.UserID).FirstOrDefault();
- if (examinationRegistration == null)
- {
- throw new Exception("该学生尚未报名该项目");
- }
- var examinationProjectFeeType = examinationProjectFeeTypeRepository.Entities.Where(x => x.ExaminationProjectFeeTypeID == examinationRegistration.ExaminationProjectFeeTypeID).FirstOrDefault();
- //var levelSettingList = levelSettingRepository.Entities.Where(x => x.ExaminationProjectID == examinationScoreView.ExaminationProjectID).ToList();
- //var passline = levelSettingList.FirstOrDefault(x => x.IsPassLine.Value);
- //if (passline == null)
- //{
- // throw new Exception("该项目未设置及格线");
- //}
- //var levelSettingSubject = levelSettingSubjectRepository.Entities.Where(x => x.LevelSettingID == passline.LevelSettingID && x.ExaminationSubjectID == examinationScoreView.ExaminationSubjectID).FirstOrDefault();
- // if (examinationScoreView.Score >= levelSettingSubject.PassScore && examinationScoreView.Expire == null)
- // {
- // throw new Exception("分数已经达到及格线,有效期必须填值");
- // }
- // else if(examinationScoreView.Score < levelSettingSubject.PassScore && examinationScoreView.Expire != null)
- // {
- // throw new Exception("分数未达到及格线,有效期不需要填值");
- // }
- if (ExaminationBatchProject == null)
- {
- throw new Exception("找不到对应的批次项目");
- }
- if (user == null)
- {
- throw new Exception("系统不存在该学生,请核实");
- }
- if (examinationScoreView.ExaminationScoreID.HasValue && examinationScoreView.ExaminationScoreID != Guid.Empty)
- {
- var examinationScore = examinationScoreDAL.examinationScoreRepository.Entities.Where(x => x.ExaminationScoreID == examinationScoreView.ExaminationScoreID).FirstOrDefault();
- if (examinationScore == null)
- {
- throw new Exception("该项目成绩已经不存在");
- }
- examinationScore.ExaminationBatchProjectID = ExaminationBatchProject.ExaminationBatchProjectID;
- examinationScore.UserID = user.UserID;
- examinationScore.ExaminationSubjectID = examinationScoreView.ExaminationSubjectID;
- examinationScore.Score = examinationScoreView.Score;
- examinationScore.Expire = examinationScoreView.Expire;
- examinationScore.Remark = examinationScoreView.Remark;
- examinationScore.IsResit = examinationProjectFeeType.IsResit;
- SetModifyStatus(examinationScore);
- UnitOfWork.Commit();
- }
- else
- {
- ER_ExaminationScore examinationScore = new ER_ExaminationScore();
- examinationScore.ExaminationScoreID = Guid.NewGuid();
- examinationScore.ExaminationBatchProjectID = ExaminationBatchProject.ExaminationBatchProjectID;
- examinationScore.UserID = user.UserID;
- examinationScore.ExaminationSubjectID = examinationScoreView.ExaminationSubjectID;
- examinationScore.Score = examinationScoreView.Score;
- examinationScore.Expire = examinationScoreView.Expire;
- examinationScore.Remark = examinationScoreView.Remark;
- examinationScore.IsResit = examinationProjectFeeType.IsResit;
- SetNewStatus(examinationScore);
- UnitOfWork.Add(examinationScore);
- UnitOfWork.Commit();
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- public void Delete(List<Guid?> ExaminationScoreIDList)
- {
- try
- {
- if (examinationScoreDAL.resitRepository.Entities.Any(x => ExaminationScoreIDList.Contains(x.ExaminationScoreID)))
- {
- throw new Exception("选择要删除的数据存在对应的补考名单,无法删除");
- }
- if (examinationScoreDAL.GetProjectScoreByExaminationScore(x => ExaminationScoreIDList.Contains(x.ExaminationScoreID)).Any())
- {
- throw new Exception("选择要删除的数据存在对应的认定成绩,无法删除");
- }
- UnitOfWork.Delete<ER_ExaminationScore>(x => ExaminationScoreIDList.Contains(x.ExaminationScoreID));
- }
- catch (Exception)
- {
- throw;
- }
- }
- public void Import(Dictionary<string, string> cellheader, out int OkCount, out DataTable errdataList, out int ErrCount, DataTable dt, string sourcePhysicalPath,
- Guid? schoolyearID, Guid? examinationBatchID, Guid? examinationTypeID, Guid? examinationProjectID)
- {
- DataTable errdt = dt.Clone();
- //errdt.Rows.RemoveAt(0);
- StringBuilder errorMsg = new StringBuilder(); // 错误信息
- var result = new ExcelImportResult();
- var excel = new NpoiExcelHelper();
- var errorTable = new DataTable();
- List<ExaminationScoreView> errList = new List<ExaminationScoreView>();
- cellheader.Remove("ErrorMessage");//去除异常列、导入操作不需要
- // 1.1解析文件,存放到一个List集合里
-
- List <ExaminationScoreView> enlist =
- NpoiExcelHelper.ExcelToEntityList<ExaminationScoreView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
- Expression<Func<CF_Student, bool>> filter = x => true;
- List<ER_ExaminationScore> insertList = new List<ER_ExaminationScore>();
- var subjectList = this.GetSubjectByProject(examinationProjectID);
- var inSchoolStatusIDList = studentsDAL.InSchoolSettingRepository.GetList(x => x.IsSelected == true).Select(w => w.InSchoolStatusID).ToList();
- //filter = filter.And(x => inSchoolStatusIDList.Contains(x.InSchoolStatusID));读取所有学生
- //节省点网络传输……
- var studentIDNumberList = enlist.Select(x => (x.IDNumber ?? "").Trim()).ToList();
- filter = filter.And(x => studentIDNumberList.Contains(x.IDNumber));
- var studentList = studentsDAL.GetInSchoolStudentViewQueryable(filter).ToList();
- var schoolYearList = examinationScoreDAL.schoolyearRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
- var ExaminationBatchProjectList = examinationScoreDAL.examinationBatchProjectRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE, x => x.EX_ExaminationBatch, x => x.EX_ExaminationProject).ToList();
- var ExaminationSubjectList = levelSettingSubjectDAL.dictionaryItemRepository.GetList(x => x.DictionaryCode == "EX_ExaminationSubject").ToList();
- var ExaminationScoreList = examinationScoreDAL.GetExaminationScoreView(x => true, x => true, x => true, x => true, x => true, x => true, x => true, x => true).ToList();
- var examinationRegistrationList = examinationRegistrationRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
- var examinationProjectFeeTypeList = examinationProjectFeeTypeRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
- var examinationProjectList = examinationProjectRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
- var levelSettingList = levelSettingRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
- var levelSettingSubjectList = levelSettingSubjectRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
-
- cellheader.Add("ErrorMessage", "错误信息");
- cellheader.ForEach(x => errorTable.Columns.Add(x.Value));
- if (enlist.Count() <= 0)
- {
- throw new Exception("请填写Excel模板信息数据。");
- }
- errdt.Clear();
- errdt.Columns.Add("错误信息");
- dt.Columns.Add("错误信息");
- for (int i = 0; i < enlist.Count(); i++)
- {
- var rows = dt.Rows[i + 1];
- string errorMsgStr = "第" + (i + 1) + "行数据检测异常:";
- ExaminationScoreView en = enlist[i];
- bool isHaveNoInputValue = false;
- en.IsExcelVaildateOK = true;
- Type enType = en.GetType();
- Dictionary<int?, decimal?> dic = new Dictionary<int?, decimal?>();
- int? subjectNotScoreCount = 0;
- #region 检查是否有未填的值
- if (string.IsNullOrEmpty(en.SchoolyearCode))
- {
- errorMsgStr += "学年学期不能为空;";
- isHaveNoInputValue = true;
- }
- if (string.IsNullOrEmpty(en.ExaminationBatchName))
- {
- errorMsgStr += "考试批次不能为空;";
- isHaveNoInputValue = true;
- }
- if (string.IsNullOrEmpty(en.ExaminationProjectName))
- {
- errorMsgStr += "考试项目不能为空;";
- isHaveNoInputValue = true;
- }
- if (string.IsNullOrEmpty(en.IDNumber.Trim()))
- {
- errorMsgStr += "证件号不能为空;";
- isHaveNoInputValue = true;
- }
- foreach (var subject in subjectList)
- {
- dic.Add(subject.ExaminationSubjectID,dt.Rows[i+1][subject.ExaminationSubject].ToString().ParseStrTo<decimal>());
- en.ExaminationSubjectIDAndScore = dic;
- //foreach (var pi in enType.GetProperties())
- //{
- // if (pi.Name == subject.SubjectCode)
- // {
- // if (pi.GetValue(en, null) == null || pi.GetValue(en, null).ToString() == "")
- // {
- // subjectNotScoreCount++;
- // //errorMsgStr += subject.ExaminationSubject + "的成绩不能为空;";
- // //isHaveNoInputValue = true;
- // dic.Add(subject.ExaminationSubjectID, null);
- // }
- // else
- // {
- // dic.Add(subject.ExaminationSubjectID, decimal.Parse(pi.GetValue(en, null).ToString()));
- // }
- // en.ExaminationSubjectIDAndScore = dic;
- // }
- //}
- }
- if (subjectNotScoreCount == subjectList.Count)
- {
- errorMsgStr += "成绩不能为空;";
- isHaveNoInputValue = true;
- }
- if (!string.IsNullOrEmpty(en.ExpireImport))
- {
- try
- {
- DateTime date;
- IFormatProvider ifp = new CultureInfo("zh-CN", true);
- var expire = en.ExpireImport.Replace("/", "-");
- //if (expire.IndexOf("-") == -1)
- //{
- // expireDate = DateTime.ParseExact(expire, "yyyyMMdd", Thread.CurrentThread.CurrentCulture);
- //}
- if (DateTime.TryParse(expire, out date))
- {
- en.Expire = Convert.ToDateTime(en.ExpireImport);
- }
- else if (DateTime.TryParseExact(expire, "yyyyMMdd", ifp, DateTimeStyles.None, out date))
- {
- en.Expire = DateTime.ParseExact(expire, "yyyyMMdd", Thread.CurrentThread.CurrentCulture);
- }
- else
- {
- en.Expire = DateTime.FromOADate(double.Parse(expire.Trim().ToString()));
- }
- }
- catch
- {
- errorMsgStr += "有效期格式不正确;";
- isHaveNoInputValue = true;
- }
- }
-
- #endregion
- #region 检查数据是否存在
- if (!schoolYearList.Any(x => x.Code == en.SchoolyearCode))
- {
- errorMsgStr += "学年学期不存在;";
- isHaveNoInputValue = true;
- }
- else {
- en.SchoolyearID = schoolYearList.FirstOrDefault(x => x.Code == en.SchoolyearCode).SchoolyearID;
- }
- if (!ExaminationBatchProjectList.Any(x => x.EX_ExaminationBatch.Name == en.ExaminationBatchName && x.EX_ExaminationProject.Name == en.ExaminationProjectName && x.EX_ExaminationBatch.SchoolyearID == en.SchoolyearID))
- {
- errorMsgStr += "考试批次项目不存在;";
- isHaveNoInputValue = true;
- }
- else{
- en.ExaminationBatchProjectID = ExaminationBatchProjectList.FirstOrDefault(x => x.EX_ExaminationBatch.Name == en.ExaminationBatchName && x.EX_ExaminationProject.Name == en.ExaminationProjectName && x.EX_ExaminationBatch.SchoolyearID == en.SchoolyearID).ExaminationBatchProjectID;
- en.ExaminationProjectID = examinationProjectList.FirstOrDefault(x => x.Name == en.ExaminationProjectName).ExaminationProjectID;
- }
- if (!studentList.Any(x => x.IDNumber.ToLower() == en.IDNumber.Trim().ToLower()))
- {
- errorMsgStr += "学生不存在;";
- isHaveNoInputValue = true;
- }
- else{
- en.UserID = studentList.FirstOrDefault(x => x.IDNumber.ToLower() == en.IDNumber.Trim().ToLower()).UserID;
- }
- #endregion
- foreach (var examinationSubjectID in en.ExaminationSubjectIDAndScore.Keys)
- {
- //if(en.ExaminationSubjectIDAndScore[examinationSubjectID].HasValue)
- //{
- if (en.ExaminationSubjectIDAndScore[examinationSubjectID].HasValue && ExaminationScoreList.Any(x => x.ExaminationBatchProjectID == en.ExaminationBatchProjectID && x.ExaminationSubjectID == examinationSubjectID
- && x.UserID == en.UserID))
- {
- errorMsgStr += "该学生 考试项目“" + en.ExaminationProjectName + "” 科目考核项“" + ExaminationSubjectList.FirstOrDefault(x => x.Value == examinationSubjectID).Name + "”的成绩已存在;";
- isHaveNoInputValue = true;
- }
- //}
- }
- //if (ExaminationScoreList.Any(x => x.ExaminationBatchProjectID == en.ExaminationBatchProjectID && x.ExaminationSubjectID == en.ExaminationSubjectID
- // && x.UserID == en.UserID))
- //{
- // errorMsgStr += "该学生 考试项目“" + en.ExaminationProjectName + "” 科目考核项“" + en.ExaminationSubjectName + "”的成绩已存在;";
- // isHaveNoInputValue = true;
- //}
- var examinationRegistration = examinationRegistrationList.Where(x => x.ExaminationBatchProjectID == en.ExaminationBatchProjectID && x.UserID == en.UserID).FirstOrDefault();
- var examinationProjectFeeType = examinationProjectFeeTypeList.FirstOrDefault();
- if (examinationRegistration == null)
- {
- errorMsgStr += "该学生尚未报名该项目,无法录入成绩;";
- isHaveNoInputValue = true;
- }
- else
- {
- examinationProjectFeeType = examinationProjectFeeTypeList.Where(x => x.ExaminationProjectFeeTypeID == examinationRegistration.ExaminationProjectFeeTypeID).FirstOrDefault();
- }
- //var checkLevelSettingList = levelSettingList.Where(x => x.ExaminationProjectID == en.ExaminationProjectID).ToList();
- //var passLineSetting = checkLevelSettingList.FirstOrDefault(x => x.IsPassLine.Value);
- //if (passLineSetting == null)
- //{
- // errorMsgStr += "该项目没有设置及格线";
- // isHaveNoInputValue = true;
- //}
- //else {
- // var passScore = levelSettingSubjectList.Where(x => x.LevelSettingID == passLineSetting.LevelSettingID && x.ExaminationSubjectID == en.ExaminationSubjectID).FirstOrDefault();
- // if (en.Score >= passScore.PassScore && en.Expire == null)
- // {
- // errorMsgStr += "分数已经达到及格线,有效期必须填值;";
- // isHaveNoInputValue = true;
- // }
- // else if (en.Score < passScore.PassScore && en.Expire != null)
- // {
- // errorMsgStr += "分数未达到及格线,有效期不需要填值;";
- // isHaveNoInputValue = true;
- // }
- //}
- if (isHaveNoInputValue)
- {
- en.IsExcelVaildateOK = false;
- en.ErrorMessage = errorMsgStr;
- rows["错误信息"] = errorMsgStr;
- errdt.Rows.Add(rows.ItemArray);
- errList.Add(en);
- }
- else{
- //enlist[i].IsExcelVaildateOK = true;
- foreach(var score in en.ExaminationSubjectIDAndScore)
- {
- if(score.Value.HasValue)
- {
- ER_ExaminationScore examinationScore = new ER_ExaminationScore();
- examinationScore.ExaminationScoreID = Guid.NewGuid();
- examinationScore.ExaminationBatchProjectID = en.ExaminationBatchProjectID;
- examinationScore.ExaminationSubjectID = score.Key;
- examinationScore.UserID = en.UserID;
- examinationScore.Score = score.Value;
- examinationScore.Expire = en.Expire;
- examinationScore.Remark = en.Remark;
- examinationScore.IsResit = examinationProjectFeeType.IsResit;
- SetNewStatus(examinationScore);
- if (examinationScore != null)
- {
- insertList.Add(examinationScore);
- }
- }
- }
-
- }
- }
- ErrCount = errList.Distinct().Count();
- // errdt.Rows.RemoveAt(0);
- errdataList = errdt;
- //errList.Distinct().ToList();
- OkCount = insertList.Count;
- //if (ErrCount > 0)
- //{
- // errList.ForEach(x => errorTable.Rows.Add(x));
- // var errorCellHeader = cellheader;
- //}
- //else
- //{
- using (TransactionScope ts = new TransactionScope())
- {
- //批量插入
- UnitOfWork.BulkInsert(insertList);
- ts.Complete();
- }
- //}
- }
- private string WriteErrorFile(NpoiExcelHelper excel, IEnumerable<string> errorCellheader, DataTable errorTable)
- {
- var errorExcelBuff = excel.ExportMemoryStream(errorTable, "", errorCellheader.ToArray());
- var logicalPath = Const.LOCAL_SETTING_UPLOAD_FILEPATH + "/" + Guid.NewGuid().ToString() + ".xls";
- var physicalPath = HttpContext.Current.Server.MapPath(logicalPath);
- var fs = File.Create(physicalPath);
- fs.Write(errorExcelBuff, 0, errorExcelBuff.Length);
- fs.Flush();
- fs.Close();
- return UrlHelper.GenerateContentUrl(logicalPath, HttpContext.Current.Request.RequestContext.HttpContext);
- }
- public List<ExaminationProjectSubjectView> GetSubjectByProject(Guid? examinationProjectID)
- {
- Expression<Func<EX_ExaminationProjectSubject, bool>> exp = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE);
- if (examinationProjectID.HasValue)
- {
- exp = exp.And(x => x.ExaminationProjectID == examinationProjectID);
- }
- var query = ProjectFeeDAL.GetProjectSubjectList(exp).GroupBy(x => x.ExaminationSubjectID).Select(x => x.FirstOrDefault());
- return query.OrderBy(x => x.ExaminationSubjectID).ToList();
- }
- public IGridResultSet<ExaminationProjectSubjectView> GetSubjectByProjectGrid(ConfiguretView configuretView, Guid? examinationProjectID, int pageIndex, int pageSize)
- {
- Expression<Func<EX_ExaminationProjectSubject, bool>> exp = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE);
- if (examinationProjectID.HasValue)
- {
- exp = exp.And(x => x.ExaminationProjectID == examinationProjectID);
- }
- var query = ProjectFeeDAL.GetProjectSubjectList(exp).GroupBy(x => x.ExaminationSubjectID).Select(x => x.FirstOrDefault());
- return query.OrderBy(x => x.ExaminationSubjectID).ToGridResultSet<ExaminationProjectSubjectView>(pageIndex, pageSize);
- }
- public IQueryable<ExaminationProjectSubjectView> GetSubjectByProjectList(params EMIS.ViewModel.ConfiguretView[] configuretViews)
- {
- Expression<Func<EX_ExaminationProjectSubject, bool>> exp = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE);
- var query = ProjectFeeDAL.GetProjectSubjectList(exp);
- //查询条件
- foreach (var configuretView in configuretViews)
- {
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query
- .OrderBy(x => x.ExaminationProjectID).AsQueryable();
- }
- }
- }
|