using System; using System.Collections.Generic; using System.Linq; using System.Text; using Bowin.Common.Linq.Entity; using EMIS.Entities; using EMIS.DataLogic.ExamManage; using System.Linq.Expressions; namespace EMIS.CommonLogic.ExamManage { public class ExaminationBatchServices : BaseServices,IExaminationBatchServices { public ExaminationBatchDAL ExaminationBatchDAL { get; set; } public IGridResultSet GetBatchListGridView(int pageIndex, int pageSize, params EMIS.ViewModel.ConfiguretView[] configuretViews) { //校区信息 System.Linq.Expressions.Expression> expCampus = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE); var query = ExaminationBatchDAL.GetBatchList(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.ExaminationBatchID) .ToGridResultSet(pageIndex, pageSize); } public IQueryable GetBatchList(params EMIS.ViewModel.ConfiguretView[] configuretViews) { System.Linq.Expressions.Expression> expCampus = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE); var query = ExaminationBatchDAL.GetBatchList(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); } public EMIS.ViewModel.ExaminationBatchView GetExamBatch(Guid? ExaminationProjectID) { try { var query = ExaminationBatchDAL.GetBatchList(x => x.ExaminationBatchID == ExaminationProjectID).SingleOrDefault(); return query; } catch (Exception ex) { throw new Exception(ex.Message); } } public EMIS.ViewModel.ExaminationBatchView GetExamBatch(Expression> expCampus) { try { var query = ExaminationBatchDAL.GetBatchList(expCampus).SingleOrDefault(); return query; } catch (Exception ex) { throw new Exception(ex.Message); } } public void Edit(EMIS.ViewModel.ExaminationBatchView view) { 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); } entity.CreateTime = DateTime.Now; entity.ExaminationBatchID = view.ExaminationBatchID; entity.Name = view.Name; entity.RecordStatus = view.RecordStatus; entity.SchoolyearID = view.SchoolyearID; entity.Remark = view.Remark; entity.StartDate = view.StartDate; entity.EndDate = view.EndDate; this.SetModifyStatus(entity); ExaminationBatchDAL.BatchRepository.UnitOfWork.Commit(); } public bool DeleteBatch(List ExamBatchIDs) { try { UnitOfWork.Delete(x => ExamBatchIDs.Contains(x.ExaminationBatchID)); UnitOfWork.Commit(); return true; } catch (Exception) { throw; } } } }