CommunicateDAL.cs 4.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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.DQPSystem;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. namespace EMIS.DataLogic.DQPSystem
  11. {
  12. public class CommunicateDAL
  13. {
  14. public SOCRepository SOCRepository { get; set; }
  15. public StaffRepository StaffRepository { get; set; }
  16. public StaffProfileRepository StaffProfileRepository { get; set; }
  17. public ClassmajorRepository ClassmajorRepository { get; set; }
  18. public UserRepository UserRepository { get; set; }
  19. public SOCStaffRepository SOCStaffRepository { get; set; }
  20. public StudentContactRepository StudentContactRepository { get; set; }
  21. public IQueryable<TeacherCommunicateView> GetTeacherCommunicateViewQueryable(Expression<Func<CF_Staff, bool>> staffExp,
  22. Expression<Func<DQP_SOC, bool>> socExp)
  23. {
  24. var sql = (from soc in SOCRepository.GetList(socExp)
  25. from teacher in SOCStaffRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.SOCID == soc.SOCID)
  26. from staff in StaffRepository.Entities.Where(staffExp).Where(x => x.UserID == teacher.UserID)
  27. from student in soc.CF_Student
  28. from user in UserRepository.Entities.Where(x => x.UserID == student.UserID)
  29. from contact in StudentContactRepository.Entities.Where(x => x.UserID == student.UserID)
  30. from classmajor in ClassmajorRepository.Entities.Where(x => x.ClassmajorID == student.ClassmajorID)
  31. group student by new TeacherCommunicateView
  32. {
  33. UserID = student.UserID,
  34. ClassmajorID = classmajor.ClassmajorID,
  35. ClassmajorNo = classmajor.No,
  36. ClassmajorName = classmajor.Name,
  37. LoginID = user.LoginID,
  38. Name = user.Name,
  39. QQ = contact.QQ
  40. } into g
  41. select g.Key);
  42. return sql;
  43. }
  44. public IQueryable<StudentCommunicateView> GetStudentCommunicateViewQueryable(Expression<Func<CF_Student, bool>> studentExp,
  45. Expression<Func<DQP_SOC, bool>> socExp)
  46. {
  47. var sql = (from soc in SOCRepository.GetList(socExp)
  48. from me in soc.CF_Student.AsQueryable().Where(studentExp)
  49. from teacher in SOCStaffRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.SOCID == soc.SOCID)
  50. from user in UserRepository.Entities.Where(x => x.UserID == teacher.UserID)
  51. from staff in StaffRepository.Entities.Where(x => x.UserID == teacher.UserID)
  52. from profile in StaffProfileRepository.Entities.Where(x => x.UserID == staff.UserID)
  53. group staff by new StudentCommunicateView
  54. {
  55. UserID = staff.UserID,
  56. RoleOrder = 0,
  57. Role = "老师",
  58. ClassmajorID = null,
  59. ClassmajorNo = null,
  60. ClassmajorName = null,
  61. LoginID = user.LoginID,
  62. Name = user.Name,
  63. QQ = profile.QQ
  64. } into g
  65. select g.Key)
  66. .Concat(
  67. from soc in SOCRepository.GetList(socExp)
  68. from me in soc.CF_Student.AsQueryable().Where(studentExp)
  69. from student in soc.CF_Student
  70. from user in UserRepository.Entities.Where(x => x.UserID == student.UserID)
  71. from contact in StudentContactRepository.Entities.Where(x => x.UserID == student.UserID)
  72. from classmajor in ClassmajorRepository.Entities.Where(x => x.ClassmajorID == student.ClassmajorID)
  73. group student by new StudentCommunicateView
  74. {
  75. UserID = student.UserID,
  76. RoleOrder = 1,
  77. Role = "学生",
  78. ClassmajorID = classmajor.ClassmajorID,
  79. ClassmajorNo = classmajor.No,
  80. ClassmajorName = classmajor.Name,
  81. LoginID = user.LoginID,
  82. Name = user.Name,
  83. QQ = contact.QQ
  84. } into g
  85. select g.Key);
  86. return sql;
  87. }
  88. }
  89. }