123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- using Bowin.Common.Linq.Entity;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.ExamManage;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using Bowin.Common.Linq;
- using System.Text;
- using EMIS.DataLogic.ExamManage;
- using EMIS.DataLogic.SystemDAL;
- using EMIS.ViewModel.SystemView;
- namespace EMIS.CommonLogic.ExamManage
- {
- public class LevelSettingSubjectServices: BaseServices, ILevelSettingSubjectServices
- {
- public LevelSettingSubjectDAL levelSettingSubjectDAL { get; set; }
- public DictionaryDAL dictionaryDAL { get; set; }
- public IGridResultSet<LevelSettingView> GetLevelSettingViewGrid(ConfiguretView examinationSubjectView, Guid? examinationTypeID, Guid? examinationProjectID, int pageIndex, int pageSize)
- {
- Expression<Func<EX_ExaminationProject, bool>> erexp = x => true;
- if (examinationTypeID.HasValue)
- {
- erexp = erexp.And(x => x.ExaminationTypeID == examinationTypeID);
- }
- if (examinationProjectID.HasValue)
- {
- erexp = erexp.And(x => x.ExaminationProjectID == examinationProjectID);
- }
- var query = levelSettingSubjectDAL.GetLevelSettingView(erexp);
- if (!string.IsNullOrEmpty(examinationSubjectView.ConditionValue) && !string.IsNullOrEmpty(examinationSubjectView.Attribute))
- query = query.DynamicWhere(examinationSubjectView.Attribute, examinationSubjectView.Condition, examinationSubjectView.ConditionValue);
- return query.OrderBy(x => x.ExaminationTypeName).ThenBy(x => x.ExaminationProjectName).ThenBy(x => x.LevelName).ToGridResultSet<LevelSettingView>(pageIndex, pageSize);
- }
- public LevelSettingView GetLevelSettingView(Guid? levelSettingID)
- {
- var query = levelSettingSubjectDAL.GetLevelSettingSubjectView(levelSettingID);
- return query;
- }
- public void Edit(LevelSettingView levelSettingView, List<LevelSettingSubjectView> levelSettingSubjectViewList)
- {
- try
- {
- List<ER_LevelSettingSubject> levelSettingSubjectList = new List<ER_LevelSettingSubject>();
- if (!levelSettingView.LevelSettingID.HasValue || levelSettingView.LevelSettingID == Guid.Empty)
- {
- ER_LevelSetting levelSetting = new ER_LevelSetting();
- levelSetting.LevelSettingID = Guid.NewGuid();
- levelSetting.ExaminationProjectID = levelSettingView.ExaminationProjectID;
- levelSetting.LevelName = levelSettingView.LevelName;
- levelSetting.IsPassed = levelSettingView.IsPassedEdit;
- levelSetting.IsPassLine = levelSettingView.IsPassLineEdit;
- SetNewStatus(levelSetting);
- foreach (var levelSettingSubjectView in levelSettingSubjectViewList)
- {
- ER_LevelSettingSubject levelSettingSubject = new ER_LevelSettingSubject();
- levelSettingSubject.LevelSettingSubjectID = Guid.NewGuid();
- levelSettingSubject.LevelSettingID = levelSetting.LevelSettingID;
- levelSettingSubject.ExaminationSubjectID = levelSettingSubjectView.ExaminationSubjectID;
- levelSettingSubject.PassScore = levelSettingSubjectView.PassScore;
- SetNewStatus(levelSettingSubject);
- levelSettingSubjectList.Add(levelSettingSubject);
- //UnitOfWork.Add(levelSettingSubject);
- }
- UnitOfWork.Add(levelSetting);
- UnitOfWork.BulkInsert(levelSettingSubjectList);
- UnitOfWork.Commit();
- }
- else
- {
- var levelSetting = levelSettingSubjectDAL.levelSettingRepository.GetList(x => x.LevelSettingID == levelSettingView.LevelSettingID).FirstOrDefault();
- if (levelSetting == null)
- {
- throw new Exception("您要修改的记录已被删除或不存在");
- }
- levelSetting.ExaminationProjectID = levelSettingView.ExaminationProjectID;
- levelSetting.LevelName = levelSettingView.LevelName;
- levelSetting.IsPassed = levelSettingView.IsPassedEdit;
- levelSetting.IsPassLine = levelSettingView.IsPassLineEdit;
- SetModifyStatus(levelSetting);
- if (levelSettingSubjectViewList.Count > 0)
- {
- UnitOfWork.Delete<ER_LevelSettingSubject>(x => x.LevelSettingID == levelSetting.LevelSettingID);
- foreach (var levelSettingSubjectView in levelSettingSubjectViewList)
- {
- ER_LevelSettingSubject levelSettingSubject = new ER_LevelSettingSubject();
- levelSettingSubject.LevelSettingSubjectID = Guid.NewGuid();
- levelSettingSubject.LevelSettingID = levelSetting.LevelSettingID;
- levelSettingSubject.ExaminationSubjectID = levelSettingSubjectView.ExaminationSubjectID;
- levelSettingSubject.PassScore = levelSettingSubjectView.PassScore;
- SetNewStatus(levelSettingSubject);
- levelSettingSubjectList.Add(levelSettingSubject);
- //UnitOfWork.Add(levelSettingSubject);
- }
- }
- UnitOfWork.BulkInsert(levelSettingSubjectList);
- UnitOfWork.Commit();
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- public void Delete(List<Guid?> LevelSettingIDList)
- {
- try
- {
- var ProjectScoreList = levelSettingSubjectDAL.projectScoreRepository.GetList(x => LevelSettingIDList.Contains(x.LevelSettingID));
- if (ProjectScoreList.Count() > 0)
- {
- throw new Exception("选中的设置有已被使用的记录不能删除");
- }
- UnitOfWork.Delete<ER_LevelSettingSubject>(x => LevelSettingIDList.Contains(x.LevelSettingID));
- UnitOfWork.Delete<ER_LevelSetting>(x => LevelSettingIDList.Contains(x.LevelSettingID));
- }
- catch (Exception)
- {
- throw;
- }
- }
- public IGridResultSet<LevelSettingSubjectView> GetLevelSettingSubjectViewGridByID(Guid? levelSettingID, int pageIndex, int pageSize)
- {
- var query = levelSettingSubjectDAL.GetLevelSettingSubjectViewByLevelID(levelSettingID);
- return query.OrderBy(x => x.ExaminationSubjectID).ToGridResultSet<LevelSettingSubjectView>(pageIndex, pageSize);
- }
- public IGridResultSet<DictionaryItemView> GetExaminationSubjectDicSelect(Guid? examinationProjectID, int pageIndex, int pageSize)
- {
- var examinationSubjectIDList = levelSettingSubjectDAL.examinationProjectSubjectRepository.Entities.Where(x => x.ExaminationProjectID == examinationProjectID).Select(x => x.ExaminationSubjectID).ToList();
- var query = dictionaryDAL.GetDictionaryItemQuery("EX_ExaminationSubject").Where(x => examinationSubjectIDList.Contains(x.Value));
- return query.OrderBy(x => x.OrderNo).ToGridResultSet<DictionaryItemView>(pageIndex, pageSize);
- }
- public IGridResultSet<DictionaryItemView> GetLevelSettingSubjectViewGridByProjectID(ConfiguretView configuretView, Guid? examinationProjectID, int pageIndex, int pageSize)
- {
- var LevelSettingSubjectList = levelSettingSubjectDAL.GetLevelSettingSubjectViewByProjectID(examinationProjectID).ToList();
- List<int?> subjectIDList = LevelSettingSubjectList.Select(x => x.ExaminationSubjectID).ToList();
- var query = from a in levelSettingSubjectDAL.dictionaryItemRepository.GetList(x => x.DictionaryCode == "EX_ExaminationSubject" && subjectIDList.Contains(x.Value))
- select new DictionaryItemView
- {
- DictionaryItemID = a.DictionaryItemID,
- DictionaryCode = a.DictionaryCode,
- Code = a.Code,
- DictionaryName = a.Sys_Dictionary.Name,
- Value = a.Value,
- IsEditable = a.IsEditable.Value,
- IsVisible = a.RecordStatus > 0,
- Name = a.Name,
- OrderNo = a.OrderNo,
- RecordStatus = a.RecordStatus,
- };
- return query.OrderBy(x => x.Value).ToGridResultSet<DictionaryItemView>(pageIndex, pageSize);
- }
- }
- }
|