LevelScoreServices.cs 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.ScoreManage;
  6. using EMIS.ViewModel.ScoreManage;
  7. using EMIS.Entities;
  8. using System.Linq.Expressions;
  9. using EMIS.ViewModel;
  10. using Bowin.Common.Linq;
  11. using Bowin.Common.Linq.Entity;
  12. using Bowin.Common.DataTime;
  13. using Bowin.Common.Utility;
  14. using System.Text.RegularExpressions;
  15. using EMIS.DataLogic.Repositories;
  16. using EMIS.DataLogic.ExaminationApply;
  17. using EMIS.DataLogic.Common.CalendarManage;
  18. using EMIS.ViewModel.Cache;
  19. namespace EMIS.CommonLogic.ScoreManage
  20. {
  21. public class LevelScoreServices : BaseServices, ILevelScoreServices
  22. {
  23. public LevelScoreDAL levelScoreDAL { get; set; }
  24. public ExaminationScoreDAL examinationScoreDAL { get; set; }
  25. public StudentRepository studentRepository { get; set; }
  26. public ExaminationSubjectDAL examinationSubjectDAL { get; set; }
  27. public SchoolYearDAL schoolYearDAL { get; set; }
  28. //学生版过级成绩
  29. public IGridResultSet<LevelScoreView> GetStudentLevelScoreGrid(ConfiguretView configuretView, Guid userId, int pageIndex, int pageSize)
  30. {
  31. Expression<Func<ER_ProjectScore, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  32. exp = (x => x.UserID == userId);
  33. var query = levelScoreDAL.GetLevelScoreViewQueryable(exp).ToList();
  34. var examinationScoreList = examinationScoreDAL.GetExaminationScoreViewForProjectScore(exp).ToList();
  35. //if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  36. // query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  37. query.ForEach(x =>
  38. {
  39. var examinationScore = examinationScoreList.Where(y => y.UserID == userId && y.ExaminationProjectID == x.ExaminationProjectID);
  40. //x.ScoreList = new Dictionary<int?, decimal?>();
  41. foreach (var score in examinationScore)
  42. {
  43. //x.ScoreList.Add(score.ExaminationSubjectID, score.Score);
  44. x.ScoreStr += score.ExaminationSubjectName + ":" + score.Score + ";\r\n";
  45. }
  46. });
  47. var result = query.OrderBy(x => x.ExaminationProjectName).AsQueryable<LevelScoreView>().ToGridResultSet<LevelScoreView>(pageIndex, pageSize);
  48. return result;
  49. }
  50. public IGridResultSet<ExaminationScoreView> GetExaminationScoreViewGrid(ConfiguretView configuretView, Guid? schoolYearID, Guid? examinationBatchID,
  51. Guid? examinationTypeID, Guid? examinationProjectID, int pageIndex, int pageSize)
  52. {
  53. Expression<Func<ER_ExaminationScore, bool>> esexp = x => true;
  54. Expression<Func<EX_ExaminationBatchProject, bool>> ebrexp = x => true;
  55. Expression<Func<EX_ExaminationBatch, bool>> ebexp = x => true;
  56. Expression<Func<EX_ExaminationProject, bool>> epexp = x => true;
  57. var user = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  58. if (user != null)
  59. {
  60. esexp = esexp.And(x => x.UserID == user.UserID);
  61. }
  62. if (schoolYearID.HasValue)
  63. ebexp = ebexp.And(x => x.SchoolyearID == schoolYearID);
  64. if (examinationBatchID.HasValue)
  65. ebrexp = ebrexp.And(x => x.ExaminationBatchID == examinationBatchID);
  66. if (examinationTypeID.HasValue)
  67. epexp = epexp.And(x => x.ExaminationTypeID == examinationTypeID);
  68. if (examinationProjectID.HasValue)
  69. ebrexp = ebrexp.And(x => x.ExaminationProjectID == examinationProjectID);
  70. var query = examinationScoreDAL.GetExaminationScoreView(esexp, ebrexp, ebexp, epexp, x => true, x => true, x => true, x => true);
  71. if (!string.IsNullOrEmpty(configuretView.ConditionValue) && !string.IsNullOrEmpty(configuretView.Attribute))
  72. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  73. return query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.ExaminationBatchID).ThenBy(x => x.ExaminationTypeID).ThenBy(x => x.ExaminationProjectID)
  74. .ThenBy(x => x.ExaminationSubjectID).ToGridResultSet<ExaminationScoreView>(pageIndex, pageSize);
  75. }
  76. }
  77. }