EvaluationOpenControlDAL.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Repositories;
  6. using EMIS.ViewModel.EvaluationManage;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
  10. using EMIS.ViewModel;
  11. namespace EMIS.DataLogic.Common.EvaluationManage
  12. {
  13. public class EvaluationOpenControlDAL
  14. {
  15. public EvaluationGradeControlRepository EvaluationGradeControlRepository { get; set; }
  16. public SchoolyearRepository schoolyearRepository { get; set; }
  17. public GrademajorRepository GrademajorRepository { get; set; }
  18. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  19. public ClassmajorRepository classmajorRepository { get; set; }
  20. public EvaluationTypeRepository EvaluationTypeRepository { get; set; }
  21. /// <summary>
  22. /// 读取评价控制信息
  23. /// </summary>
  24. /// <param name="exp"></param>
  25. /// <returns></returns>
  26. public IQueryable<EvaluationOpenControlView> GetEvaluationControlQueryable(Expression<Func<EM_EvaluationGradeControl, bool>> exp)
  27. {
  28. var query = from egc in EvaluationGradeControlRepository.GetList(exp)
  29. join sy in schoolyearRepository.Entities on egc.SchoolyearID equals sy.SchoolyearID into schoolyear
  30. from year in schoolyear.DefaultIfEmpty()
  31. join grad in GrademajorRepository.Entities on egc.GrademajorID equals grad.GrademajorID into grademajor
  32. from g in grademajor.DefaultIfEmpty()
  33. select new EvaluationOpenControlView
  34. {
  35. EvaluationGradeControlID=egc.EvaluationGradeControlID,
  36. SchoolyearID = year.SchoolyearID,
  37. SchoolyearCode = year.Code,
  38. GrademajorID=g.GrademajorID,
  39. GrademajorCode=g.Code,
  40. GrademajorName=g.Name,
  41. CollegeID=g.CF_Facultymajor.CF_College.CollegeID,
  42. CollegeName=g.CF_Facultymajor.CF_College.Name,
  43. StartTime=egc.StartTime,
  44. EndTime=egc.EndTime,
  45. EvaluationCount=egc.Number
  46. };
  47. return query;
  48. }
  49. /// <summary>
  50. /// 读取未控制的评价控制信息
  51. /// </summary>
  52. /// <param name="exp"></param>
  53. /// <returns></returns>
  54. public IQueryable<GrademajorView> GrademajorViewGridQueryable(Expression<Func<CF_Grademajor, bool>> exp, Expression<Func<EM_EvaluationGradeControl, bool>> exps)
  55. {
  56. var query = from a in GrademajorRepository.GetList(exp)
  57. join c in dictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_Standard).Name) on a.CF_Facultymajor.StandardID equals c.Value
  58. join sc in
  59. (from sc in classmajorRepository.Entities
  60. group sc by sc.GrademajorID into g
  61. select new
  62. {
  63. GrademajorID = g.Key,
  64. StudentCount = g.Sum(x => x.CF_Student.Count())
  65. }) on a.GrademajorID equals sc.GrademajorID into dsc
  66. from esc in dsc.DefaultIfEmpty()
  67. join egc in EvaluationGradeControlRepository.GetList(exps) on a.GrademajorID equals egc.GrademajorID into e
  68. from eg in e.DefaultIfEmpty()
  69. where eg.EvaluationGradeControlID == null
  70. select new GrademajorView
  71. {
  72. GrademajorID = a.GrademajorID,
  73. Code = a.Code,
  74. Name = a.Name,
  75. Abbreviation = a.Abbreviation,
  76. GradeID = a.GradeID,
  77. Professional = a.Professional,
  78. SemesterID = a.SemesterID,
  79. FacultymajorID = a.CF_Facultymajor.FacultymajorID,
  80. FacultymajorCode = a.CF_Facultymajor.Code,
  81. FacultymajorName = a.CF_Facultymajor.Name,
  82. EducationID = a.CF_Facultymajor.EducationID,
  83. LearningformID = a.CF_Facultymajor.LearningformID,
  84. LearnSystem = a.CF_Facultymajor.LearnSystem,
  85. StandardID = a.CF_Facultymajor.StandardID,
  86. CollegeID = a.CF_Facultymajor.CollegeID,
  87. CollegeName = a.CF_Facultymajor.CF_College.Name,
  88. CollegeCode = a.CF_Facultymajor.CF_College.No,
  89. CampusID = a.CF_Facultymajor.CF_College.CampusID,
  90. GraduateSchoolyearID = a.GraduateSchoolyearID,
  91. GraduateValue = a.CF_Schoolyear.Value,
  92. GraduateSchoolyearCode = a.CF_Schoolyear.Code,
  93. StudentCount = esc.StudentCount == null ? 0 : esc.StudentCount,
  94. CreateUserID = a.CreateUserID,
  95. CreateTime = a.CreateTime,
  96. Remark = a.Remark
  97. };
  98. return query;
  99. }
  100. }
  101. }