123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- 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;
- namespace EMIS.CommonLogic.ExamManage
- {
- public class ExamBatchProjectServices : BaseServices, IExamBatchProjectServices
- {
- public ExaminationBatchDAL ExaminationBatchDAL { get; set; }
- public ExamBatchProjectDAL ExamBatchProjectDAL { get; set; }
- public ProjectFeeDAL ProjectFeeDAL { get; set; }
- public IGridResultSet<EMIS.ViewModel.ExamBatchProjectView> GetBatchProjectListGridView(int pageIndex, int pageSize, params EMIS.ViewModel.ConfiguretView[] configuretViews)
- {
- //校区信息
- System.Linq.Expressions.Expression<Func<EX_ExaminationBatchProject, bool>> expCampus = (x =>true);
- var query = ExamBatchProjectDAL.GetBatchProjectList(expCampus);
- //查询条件
- foreach (var configuretView in configuretViews)
- {
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query
- .OrderByDescending(x => x.Schoolyear).ThenBy(x => x.StartDate)
- .ThenBy(x => x.ExaminationBatchID).ThenBy(x => x.Name)
- .ToGridResultSet<EMIS.ViewModel.ExamBatchProjectView>(pageIndex, pageSize);
- }
- public IGridResultSet<EMIS.ViewModel.ExaminationApply.ExaminationTypeView> GetExamBatchExamTypeListViewGrid(int pageIndex, int pageSize, params EMIS.ViewModel.ConfiguretView[] configuretViews)
- {
- System.Linq.Expressions.Expression<Func<EX_ExaminationBatchProject, bool>> expCampus = (x => x.RecordStatus == (int)SYS_STATUS.USABLE);
- var query = ExamBatchProjectDAL.GetBatchProjectList(expCampus);
- //查询条件
- 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.ExaminationBatchProjectID).GroupBy(x => new
- {
- x.ExaminationBatchID,
- x.ExaminationTypeID,
- x.ExaminationType
- }).Select(x => new EMIS.ViewModel.ExaminationApply.ExaminationTypeView()
- {
- ExaminationBatchID = x.Key.ExaminationBatchID,
- ExaminationTypeID = x.Key.ExaminationTypeID.Value,
- Name = x.Key.ExaminationType
- });
- return result
- .OrderBy(x => x.ExaminationBatchID)
- .ToGridResultSet<EMIS.ViewModel.ExaminationApply.ExaminationTypeView>(pageIndex, pageSize);
- }
- public IQueryable<EMIS.ViewModel.ExamBatchProjectView> GetBatchProjectList(params EMIS.ViewModel.ConfiguretView[] configuretViews)
- {
- System.Linq.Expressions.Expression<Func<EX_ExaminationBatchProject, bool>> expCampus = (x => x.RecordStatus == (int)SYS_STATUS.USABLE);
- var query = ExamBatchProjectDAL.GetBatchProjectList(expCampus);
- //查询条件
- 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.ExaminationBatchID).AsQueryable();
- }
- public List<ExamBatchProjectView> SelectProjects(Guid ExaminationBatchID, List<Guid?> list)
- {
- //筛选已经存在的考试
- var examlist = ExamBatchProjectDAL.GetBatchProjectList(q => q.ExaminationBatchID == ExaminationBatchID).Select(q => q.ExaminationProjectID).ToArray();
- list = list.Where(q => !examlist.Contains(q)).ToList();
- var addlist = new List<EX_ExaminationBatchProject>();
- var batch = ExaminationBatchDAL.GetBatchList(q => q.ExaminationBatchID == ExaminationBatchID).SingleOrDefault();
- list.ForEach(id =>
- {
- var project = ProjectFeeDAL.ProjectRepository.GetSingle(q => q.ExaminationProjectID == id);
- var entity = new EX_ExaminationBatchProject()
- {
- ExaminationBatchProjectID = Guid.NewGuid(),
- ExaminationBatchID = ExaminationBatchID,
- ExaminationProjectID = id,
- StartDate = batch.StartDate,
- EndDate = batch.EndDate,
- Remark = project.Remark,
- RecordStatus = (int)SYS_STATUS.UNUSABLE
- };
- this.SetModifyStatus(entity);
- addlist.Add(entity);
- this.ExamBatchProjectDAL.BatchProjectRepository.UnitOfWork.Add(entity);
- });
- this.ExamBatchProjectDAL.BatchProjectRepository.UnitOfWork.Commit();
- System.Linq.Expressions.Expression<Func<EX_ExaminationBatchProject, bool>> expCampus = (x => x.ExaminationBatchID == ExaminationBatchID && list.Contains(x.ExaminationProjectID));
- var query = ExamBatchProjectDAL.GetBatchProjectList(expCampus);
- return query.ToList();
- }
- public EMIS.ViewModel.ExamBatchProjectView GetView(Expression<Func<EX_ExaminationBatchProject, bool>> expCampus)
- {
- var query = ExamBatchProjectDAL.GetBatchProjectList(expCampus).SingleOrDefault();
- return query;
- }
- public void Edit(ExamBatchProjectView view, IList<ExamBatchProjectView> listData)
- {
- try
- {
- var dbBatchProjectList = ExamBatchProjectDAL.BatchProjectRepository.Entities.ToList();
- //var entity = ExaminationBatchDAL.BatchRepository.Entities
- // .SingleOrDefault(x => x.ExaminationBatchID == view.ExaminationBatchID);
- //if (entity == null)
- //{
- // entity = new EX_ExaminationBatch();
- // this.SetNewStatus(entity);
- // ExaminationBatchDAL.BatchRepository.UnitOfWork.Add(entity);
- //}
- List<EX_ExaminationBatchProject> batchProjectList = new List<EX_ExaminationBatchProject>();
- foreach (var data in listData)
- {
- if (dbBatchProjectList.Where(x => x.ExaminationBatchID == view.ExaminationBatchID && x.ExaminationProjectID == data.ExaminationProjectID).Count() > 0)
- {
- throw new Exception("要添加的项目该批次已存在,请检查后再添加");
- }
- EX_ExaminationBatchProject item = new EX_ExaminationBatchProject();
- item.ExaminationBatchProjectID = Guid.NewGuid();
- item.ExaminationBatchID = view.ExaminationBatchID;
- item.ExaminationProjectID = data.ExaminationProjectID;
- //ExamBatchProjectDAL.BatchProjectRepository.Entities.SingleOrDefault(x => x.ExaminationBatchProjectID == data.ExaminationBatchProjectID);
- item.SimulateTime = data.SimulateTime;
- item.Training = data.Training;
- item.TakeCourseTime = data.TakeCourseTime;
- item.MaxRegistCount = data.MaxRegistCount;
- item.Remark = data.Remark;
- //item.RecordStatus = (int)SYS_STATUS.USABLE;
- //item.CreateTime = DateTime.Now;
- item.StartDate = view.StartDate;
- item.EndDate = view.EndDate;
- this.SetNewStatus(item);
- batchProjectList.Add(item);
- }
- UnitOfWork.BulkInsert(batchProjectList);
- }
- catch (Exception)
- {
- throw;
- }
- //ExaminationBatchDAL.BatchRepository.UnitOfWork.Commit();
- }
- public void Edit(ExamBatchProjectView view)
- {
- var item = ExamBatchProjectDAL.BatchProjectRepository.Entities
- .SingleOrDefault(x => x.ExaminationBatchProjectID == view.ExaminationBatchProjectID);
- item.SimulateTime = view.SimulateTime;
- item.Training = view.Training;
- item.TakeCourseTime = view.TakeCourseTime;
- item.MaxRegistCount = view.MaxRegistCount;
- item.Remark = view.Remark;
- item.StartDate = view.StartDate;
- item.EndDate = view.EndDate;
- this.SetModifyStatus(item);
- ExaminationBatchDAL.BatchRepository.UnitOfWork.Commit();
- }
- public bool DeleteBatchProject(List<Guid?> ExamBatchProjectIDs)
- {
- try
- {
- UnitOfWork.Delete<EX_ExaminationBatchProject>(x => ExamBatchProjectIDs.Contains(x.ExaminationBatchProjectID));
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|