123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.SupervisionManage;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.SupervisionManage;
- using EMIS.ViewModel;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using EMIS.CommonLogic.SystemServices;
- namespace EMIS.CommonLogic.SupervisionManage
- {
- public class SupEvaluationServices : BaseServices, ISupEvaluationServices
- {
- public SupEvaluationDAL SupEvaluationDAL { get; set; }
- public IGridResultSet<SupEvaluationView> GetSupEvaluationViewGrid(ConfiguretView configuretView,Guid? schoolyearID, Guid? collegeID, DateTime? startTimes, DateTime? endTimes, int? SupervisionTypeID, int DataRange, int pageIndex, int pageSize)
- {
- Expression<Func<SUP_LessonRecord, bool>> lessonFilter = (x => true);
- Expression<Func<SUP_ProjectRecord, bool>> projectFilter = (x => true);
- Expression<Func<CF_Staff, bool>> supervisorExp = (x => true);
- if (schoolyearID.HasValue)
- {
- lessonFilter = lessonFilter.And(x => x.SchoolyearID == schoolyearID);
- projectFilter = projectFilter.And(x => x.SchoolyearID == schoolyearID);
- }
- if (collegeID.HasValue)
- {
- supervisorExp = supervisorExp.And(x => x.CollegeID == collegeID);
- }
- if(startTimes.HasValue)
- {
- lessonFilter = lessonFilter.And(x => x.LessonDate >= startTimes);
- projectFilter = projectFilter.And(x => x.ProjectDate >= startTimes);
- }
- if (endTimes.HasValue)
- {
- var endDate= endTimes.Value.AddDays(1);
- lessonFilter = lessonFilter.And(x => x.LessonDate < endDate);
- projectFilter = projectFilter.And(x => x.ProjectDate < endDate);
- }
-
- if(DataRange!=(int)SYS_DataRange.All)
- {
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- var curUserID = curUser.UserID;
- lessonFilter = lessonFilter.And(x => x.UserID == curUserID);
- projectFilter = projectFilter.And(x => x.UserID == curUserID);
- }
- var query = SupEvaluationDAL.GetSupEvaluationViewQueryable(lessonFilter, projectFilter, supervisorExp);
- if (SupervisionTypeID.HasValue)
- {
- if (SupervisionTypeID == (int)SUP_EvaluationType.Lesson)
- {
- query = query.Where(x => x.SupervisionTypeID ==null);
- }
- else
- {
- query = query.Where(x => x.SupervisionTypeID == (int)SUP_SupervisionType.Evaluation);
- }
-
- }
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- var result = query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x=>x.SupervisionCollegeName).ThenBy(x=>x.UserName)
- .ThenBy(x => x.CourseName).ThenByDescending(x => x.LessonDate).ToGridResultSet<SupEvaluationView>(pageIndex, pageSize);
- return result;
- }
- public List<SupEvaluationView> GetSupEvaluationViewGridList(ConfiguretView configuretView,Guid? schoolyearID, Guid? collegeID, DateTime? startTimes, DateTime? endTimes, int? SupervisionTypeID, int DataRange, List<Guid> selectedLessonRecordID, List<Guid> selectedProjectRecordID)
- {
- Expression<Func<SUP_LessonRecord, bool>> lessonFilter = (x => true);
- Expression<Func<SUP_ProjectRecord, bool>> projectFilter = (x => true);
- Expression<Func<CF_Staff, bool>> supervisorExp = (x => true);
- if (schoolyearID.HasValue)
- {
- lessonFilter = lessonFilter.And(x => x.SchoolyearID == schoolyearID);
- projectFilter = projectFilter.And(x => x.SchoolyearID == schoolyearID);
- }
- if (collegeID.HasValue)
- {
- supervisorExp = supervisorExp.And(x => x.CollegeID == collegeID);
- }
- if (startTimes.HasValue)
- {
- lessonFilter = lessonFilter.And(x => x.LessonDate >= startTimes);
- projectFilter = projectFilter.And(x => x.ProjectDate >= startTimes);
- }
- if (endTimes.HasValue)
- {
- lessonFilter = lessonFilter.And(x => x.LessonDate < endTimes.Value.AddDays(1));
- projectFilter = projectFilter.And(x => x.ProjectDate < endTimes.Value.AddDays(1));
- }
- if (DataRange != (int)SYS_DataRange.All)
- {
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- var curUserID = curUser.UserID;
- lessonFilter = lessonFilter.And(x => x.UserID == curUserID);
- projectFilter = projectFilter.And(x => x.UserID == curUserID);
- }
- var query = SupEvaluationDAL.GetSupEvaluationViewQueryable(lessonFilter, projectFilter, supervisorExp);
- if (selectedLessonRecordID.Count > 0)
- {
- List<Guid?> LessonRecordIDList = new List<Guid?>();
- foreach(var LessonRecordID in selectedLessonRecordID)
- {
- LessonRecordIDList.Add(LessonRecordID);
- }
- query = query.Where(x => LessonRecordIDList.Contains(x.LessonRecordID));
- }
- if (selectedProjectRecordID.Count > 0)
- {
- List<Guid?> ProjectRecordIDList = new List<Guid?>();
- foreach (var ProjectRecordID in selectedLessonRecordID)
- {
- ProjectRecordIDList.Add(ProjectRecordID);
- }
- query = query.Where(x => ProjectRecordIDList.Contains(x.ProjectRecordID));
- }
- if (SupervisionTypeID.HasValue)
- {
- query = query.Where(x => x.SupervisionTypeID == SupervisionTypeID);
- }
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- return query.ToList();
- }
- }
- }
|