DutyDAL.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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.CalendarManage;
  9. namespace EMIS.DataLogic.Common.CalendarManage
  10. {
  11. public class DutyDAL
  12. {
  13. public dutyRepository dutyRepository { get; set; }
  14. public UserRepository userRepository { get; set; }
  15. public DepartmentRepository departmentRepository { get; set; }
  16. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  17. /// <summary>
  18. /// 读取值班管理信息
  19. /// </summary>
  20. /// <param name="exp"></param>
  21. /// <returns></returns>
  22. public IQueryable<DutyView> GetDutyQueryable(Expression<Func<EM_duty, bool>> exp)
  23. {
  24. var query = from a in dutyRepository.GetList(exp)
  25. join b in userRepository.Entities on a.UserID equals b.UserID
  26. join c in departmentRepository.Entities on a.DepartmentID equals c.DepartmentID
  27. join d in dictionaryItemRepository.Entities on new { a.TimesSegment, DictionaryCode = "CF_TimesSegment" }
  28. equals new { TimesSegment = d.Value.Value, d.DictionaryCode } into gbsta
  29. from gicbsta in gbsta.DefaultIfEmpty()
  30. select new DutyView
  31. {
  32. DutyID = a.DutyID,
  33. UserID = a.UserID,
  34. LoginID = b.LoginID,
  35. UserName = b.Name,
  36. TimesSegment = a.TimesSegment,
  37. TimesSegmentName = gicbsta.Name,
  38. DutyTime = a.DutyTime,
  39. StartHour = a.StartHour,
  40. StartMinutes = a.StartMinutes,
  41. StartDate = a.StartHour + ":" + (a.StartMinutes == 0 ? "00" : a.StartMinutes.ToString()),
  42. EndHour = a.EndHour,
  43. EndMinutes = a.EndMinutes,
  44. EndDate = a.EndHour + ":" + (a.EndMinutes == 0 ? "00" : a.EndMinutes.ToString()),
  45. Description = a.Description,
  46. CollegeID= c.CollegeID,
  47. CampusID=c.CF_College.CampusID,
  48. DepartmentID = a.DepartmentID,
  49. DepartmentName = c.Name,
  50. CreateUserID = a.CreateUserID,
  51. CreateTime = a.CreateTime
  52. };
  53. return query;
  54. }
  55. }
  56. }