TeacherEvaluationCountDAL.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Repositories;
  6. using System.Linq.Expressions;
  7. using EMIS.Entities;
  8. using EMIS.ViewModel.EvaluationManage;
  9. using EMIS.DataLogic.SystemDAL;
  10. using EMIS.ViewModel;
  11. using EMIS.ViewModel.EducationManage;
  12. using EMIS.ViewModel.EvaluationManage.EvaluationEnter;
  13. using EMIS.Utility;
  14. using EMIS.DataLogic.Common.Students;
  15. using Bowin.Common.Linq;
  16. namespace EMIS.DataLogic.Common.EvaluationManage
  17. {
  18. public class TeacherEvaluationCountDAL
  19. {
  20. public StudentRepository StudentRepository { get; set; }
  21. public StaffRepository StaffRepository { get; set; }
  22. public EvaluationSettingRepository EvaluationSettingRepository { get; set; }
  23. public UserRepository UserRepository { get; set; }
  24. //public StudentEvaluationRepository StudentEvaluationRepository { get; set; }
  25. public EducationMissionRepository EducationMissionRepository { get; set; }
  26. public EducationMissionClassRepository EducationMissionClassRepository { get; set; }
  27. public EM_EvaluationSetting EvaluationSetting { get; set; }
  28. public SchoolyearRepository SchoolyearRepository { get; set; }
  29. public EvaluationEnterRepository EvaluationEnterRepository { get; set; }
  30. public IQueryable<TeacherEvaluationCountView> GetTeacherView(Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> exp,
  31. Expression<Func<EM_EvaluationSetting, bool>> expset
  32. )
  33. // Expression<Func<EM_EducationMissionClass, bool>> exp =null
  34. {
  35. var query3 = from s in StaffRepository.Entities
  36. //from set in s.EM_EvaluationSetting
  37. join nses in
  38. (from sr in StaffRepository.Entities
  39. from es in sr.EM_EvaluationSetting.Where(x => x.OpenStatus == 1)
  40. //join set in EvaluationSettingRepository.GetList(expset) on es.EvaluationSettingID equals set.EvaluationSettingID
  41. join em in EducationMissionClassRepository.Entities on es.EducationMissionClassID equals em.EducationMissionClassID
  42. join emc in EducationMissionRepository.Entities on em.EducationMissionID equals emc.EducationMissionID
  43. join sy in SchoolyearRepository.GetList(exp) on emc.SchoolyearID equals sy.SchoolyearID
  44. group sr by new { sr.UserID, sy.SchoolyearID, sy.Code } into ns
  45. select new
  46. {
  47. //TypeID = ns.Key.EvaluationIntTypeID,
  48. SchoolCode = ns.Key.Code,
  49. SchoolyearID = ns.Key.SchoolyearID,
  50. UserID = ns.Key.UserID,
  51. NeedEvaluationCount = ns.Count()
  52. }) on s.UserID equals nses.UserID
  53. join set in
  54. (from sr in StaffRepository.Entities
  55. from est in sr.EM_EvaluationSetting.Where(x => x.OpenStatus == 1)
  56. //join set in EvaluationSettingRepository.GetList(expset) on est.EvaluationSettingID equals set.EvaluationSettingID
  57. join em in EducationMissionClassRepository.Entities on est.EducationMissionClassID equals em.EducationMissionClassID
  58. join emc in EducationMissionRepository.Entities on em.EducationMissionID equals emc.EducationMissionID
  59. join sy in SchoolyearRepository.GetList(exp) on emc.SchoolyearID equals sy.SchoolyearID
  60. where (from et in EvaluationEnterRepository.Entities.Where(x => x.StaffUserID == sr.UserID) select et.EducationMissionClassID).Contains(est.EducationMissionClassID)
  61. group sr by new { sr.UserID, sy.SchoolyearID, sy.Code, } into nst
  62. select new
  63. {
  64. //TypeID = nst.Key.EvaluationIntTypeID,
  65. SchoolCode = nst.Key.Code,
  66. SchoolyearID = nst.Key.SchoolyearID,
  67. UserID = nst.Key.UserID,
  68. CompleteCount = nst.Count(),
  69. }) on s.UserID equals set.UserID
  70. into g
  71. from n_set in g.DefaultIfEmpty()
  72. select new TeacherEvaluationCountView
  73. {
  74. CollegeID = s.CF_College.CollegeID,
  75. TeacherNo = s.StaffCode,
  76. TeacherName = s.Sys_User.Name,
  77. //EvaluationTypeID = n_set.TypeID,
  78. //EvaluationTypeName = set.EM_EvaluationTable.Name,
  79. DepartmentID = s.CF_Department.DepartmentID,
  80. //s.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID,
  81. //SchoolyearNumID
  82. ////s.CF_Classmajor.CF_Grademajor.SchoolyearID,
  83. //StandardID = s.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID,
  84. //StudentNo = s.Sys_User.LoginID,
  85. //Name = s.Sys_User.Name,
  86. //ClassmajorID = s.ClassmajorID,
  87. //ClassmajorName = s.CF_Classmajor.Name,
  88. SchoolyearID = n_set.SchoolyearID,//s.CF_Classmajor.CF_Grademajor.CF_Schoolyear.SchoolyearID,
  89. SchoolyearCode = nses.SchoolCode,//s.CF_Classmajor.CF_Grademajor.CF_Schoolyear.Code,
  90. CompleteCount = n_set.CompleteCount == null ? 0 : n_set.CompleteCount,
  91. NeedEvaluationCount = nses.NeedEvaluationCount,
  92. UncompletedCount = nses.NeedEvaluationCount - (n_set.CompleteCount == null ? 0 : n_set.CompleteCount),
  93. };
  94. return query3;
  95. }
  96. }
  97. }