ExaminationBatchServices.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Bowin.Common.Linq.Entity;
  6. using EMIS.Entities;
  7. using EMIS.DataLogic.ExamManage;
  8. using System.Linq.Expressions;
  9. namespace EMIS.CommonLogic.ExamManage
  10. {
  11. public class ExaminationBatchServices : BaseServices,IExaminationBatchServices
  12. {
  13. public ExaminationBatchDAL ExaminationBatchDAL { get; set; }
  14. public IGridResultSet<EMIS.ViewModel.ExaminationBatchView> GetBatchListGridView(int pageIndex, int pageSize, params EMIS.ViewModel.ConfiguretView[] configuretViews)
  15. {
  16. //校区信息
  17. System.Linq.Expressions.Expression<Func<EX_ExaminationBatch, bool>> expCampus = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE);
  18. var query = ExaminationBatchDAL.GetBatchList(expCampus);
  19. //查询条件
  20. foreach (var configuretView in configuretViews)
  21. {
  22. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  23. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  24. }
  25. return query.OrderByDescending(x => x.Schoolyear)
  26. .ThenBy(x => x.ExaminationBatchID)
  27. .ToGridResultSet<EMIS.ViewModel.ExaminationBatchView>(pageIndex, pageSize);
  28. }
  29. public IQueryable<EMIS.ViewModel.ExaminationBatchView> GetBatchList(params EMIS.ViewModel.ConfiguretView[] configuretViews)
  30. {
  31. System.Linq.Expressions.Expression<Func<EX_ExaminationBatch, bool>> expCampus = (x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE);
  32. var query = ExaminationBatchDAL.GetBatchList(expCampus);
  33. //查询条件
  34. foreach (var configuretView in configuretViews)
  35. {
  36. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  37. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  38. }
  39. return query
  40. .OrderBy(x => x.ExaminationBatchID);
  41. }
  42. public EMIS.ViewModel.ExaminationBatchView GetExamBatch(Guid? ExaminationProjectID)
  43. {
  44. try
  45. {
  46. var query = ExaminationBatchDAL.GetBatchList(x => x.ExaminationBatchID == ExaminationProjectID).SingleOrDefault();
  47. return query;
  48. }
  49. catch (Exception ex)
  50. {
  51. throw new Exception(ex.Message);
  52. }
  53. }
  54. public EMIS.ViewModel.ExaminationBatchView GetExamBatch(Expression<Func<EX_ExaminationBatch, bool>> expCampus)
  55. {
  56. try
  57. {
  58. var query = ExaminationBatchDAL.GetBatchList(expCampus).SingleOrDefault();
  59. return query;
  60. }
  61. catch (Exception ex)
  62. {
  63. throw new Exception(ex.Message);
  64. }
  65. }
  66. public void Edit(EMIS.ViewModel.ExaminationBatchView view)
  67. {
  68. var entity = ExaminationBatchDAL.BatchRepository.Entities
  69. .SingleOrDefault(x => x.ExaminationBatchID == view.ExaminationBatchID);
  70. if (entity == null)
  71. {
  72. entity = new EX_ExaminationBatch();
  73. this.SetNewStatus(entity);
  74. ExaminationBatchDAL.BatchRepository.UnitOfWork.Add(entity);
  75. }
  76. entity.CreateTime = DateTime.Now;
  77. entity.ExaminationBatchID = view.ExaminationBatchID;
  78. entity.Name = view.Name;
  79. entity.RecordStatus = view.RecordStatus;
  80. entity.SchoolyearID = view.SchoolyearID;
  81. entity.Remark = view.Remark;
  82. entity.StartDate = view.StartDate;
  83. entity.EndDate = view.EndDate;
  84. this.SetModifyStatus(entity);
  85. ExaminationBatchDAL.BatchRepository.UnitOfWork.Commit();
  86. }
  87. public bool DeleteBatch(List<Guid?> ExamBatchIDs)
  88. {
  89. try
  90. {
  91. UnitOfWork.Delete<EX_ExaminationBatch>(x => ExamBatchIDs.Contains(x.ExaminationBatchID));
  92. UnitOfWork.Commit();
  93. return true;
  94. }
  95. catch (Exception)
  96. {
  97. throw;
  98. }
  99. }
  100. }
  101. }