123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.EducationManage;
- using EMIS.DataLogic.Repositories;
- using EMIS.DataLogic.SelectCourse.SelectCourseResult;
- using EMIS.DataLogic.SelectCourse;
- using EMIS.DataLogic.UniversityManage.SpecialtyClassManage;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.SelectCourse.SelectCourseResult;
- using Bowin.Common.Linq;
- namespace EMIS.CommonLogic.SelectCourse.SelectCourseResult
- {
- public class SelectCourseListServices : BaseServices, ISelectCourseListServices
- {
- public EducationMissionClassDAL educationMissionClassDAL { get; set; }
- public MissionClassTeacherRepository missionClassTeacherRepository { get; set; }
- public SelectCourseResultDAL SelectCourseResultDAL { get; set; }
- public SelectCourseListDAL SelectCourseListDAL { get; set; }
- public OptionalCourseSettingDAL optionalCourseSettingDAL { get; set; }
- public ClassmajorDAL classmajorDAL { get; set; }
- public ExecutablePlanDAL ExecutablePlanDAL { get; set; }
- public OptionalCourseSettingDAL OptionalCourseSettingDAL { get; set; }
- public OpenControlSettingDAL OpenControlSettingDAL { get; set; }
- public ExecutableFreeSelectionCouseDAL ExecutableFreeSelectionCouseDAL { get; set; }
- public IStudentSelectCourseServices IStudentSelectCourseServices { get; set; }
- public IGridResultSet<SelectCourseListView> GetSelectCourseViewList
- (ViewModel.ConfiguretView configuretView, Guid? schoolYearID, Guid? collegeID,
- Guid? courseID, int? courseTypeID, int? selectCourseTypeID, int? isCreated, int? isOpened, int pageIndex, int pageSize)
- {
- Expression<Func<EM_ExecutableOptionalCourse, bool>> eocExp = (x => true);
- Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> efcExp = (x => true);
- var query = SelectCourseListDAL.GetSelectCourseListViewQueryable(eocExp, efcExp);
- //var query1 = SelectCourseResultDAL.GetSelectCourseResultTeacher(eocExp, efcExp);
- //var query2 = SelectCourseResultDAL.GetSelectCourseResultTeachingMode(eocExp, efcExp);
- if (schoolYearID.HasValue)
- {
- query = query.Where(x => x.SchoolyearID == schoolYearID);
- //query1 = query1.Where(x => x.SchoolyearID == schoolYearID);
- efcExp.And(x => x.SchoolyearID == schoolYearID);
- }
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- efcExp.And(x => x.CF_Department.CollegeID == collegeID);
- }
- if (courseID.HasValue)
- {
- query = query.Where(x => x.CoursematerialID == courseID);
- efcExp.And(x => x.EM_FreeSelectionCouse.CoursematerialID == courseID);
- }
- if (courseTypeID.HasValue)
- {
- query = query.Where(x => x.CourseTypeID == courseTypeID);
- //query1 = query1.Where(x => x.CourseTypeID == courseTypeID);
- efcExp.And(x => x.CourseTypeID == courseTypeID);
- }
- if (selectCourseTypeID.HasValue)
- {
- query = query.Where(x => x.SelectCourseType == selectCourseTypeID);
- //query1 = query1.Where(x => x.SelectCourseType == selectCourseTypeID);
- }
- if (isCreated.HasValue)
- {
- query = query.Where(x => x.RecordStatus == isCreated);
- efcExp.And(x => x.RecordStatus == isCreated);
- //if (isCreated == (int)EMIS.ViewModel.CF_GeneralPurpose.IsYes)
- // query = query.Where(x => x.RecordStatus == (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Created);
- //else if (isCreated == (int)EMIS.ViewModel.CF_GeneralPurpose.IsNo)
- // query = query.Where(x => x.RecordStatus != (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Created);
- }
- if (isOpened.HasValue)
- {
- query = query.Where(x => x.IsOpened == (isOpened == 1 ? true : false));
- //query1 = query1.Where(x => x.IsOpened == (isOpened == 1 ? true : false));
- }
- //未提交状态不显示
- query = query.Where(x => x.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen);
- //query1 = query1.Where(x => x.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen);
- //query2 = query2.Where(x => x.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen);
- //任选具体上课时间
- //var queryScheduling = SelectCourseListDAL.GetScheduling(efcExp).ToList();
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SelectCourseType).ToGridResultSet<SelectCourseListView>(pageIndex, pageSize);
- //var teacher = query1.ToList().OrderBy(x => x.SelectCourseType);
- //var teachingMode = query2.ToList().OrderBy(x => x.SelectCourseType);
- //result.rows.ForEach(x => x.TeacherName = string.Join(",", teacher.Where(w => w.ID == x.ID).Select(w => w.TeacherName)));
- //if (queryScheduling.Count > 0)
- //{
- // var schedulingList = IStudentSelectCourseServices.GetWeekdayTimesSegmentName(queryScheduling);
- // result.rows.ForEach(x =>
- // {
- // var list = schedulingList.Where(w => w.ID == x.ID);
- // x.WeekdayTimesSegmentName = string.Join(";", list.OrderBy(w => w.Weekday).Select(w => w.WeekdayTimesSegmentName));
- // });
- //}
- return result;
- }
- public List<SelectCourseListView> GetSelectCourseList
- (ViewModel.ConfiguretView configuretView, Guid? schoolYearID, Guid? collegeID,
- Guid? courseID, int? courseTypeID, int? selectCourseTypeID, int? isCreated, int? isOpened)
- {
- Expression<Func<EM_ExecutableOptionalCourse, bool>> eocExp = (x => true);
- Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> efcExp = (x => true);
- var query = SelectCourseListDAL.GetSelectCourseListViewQueryable(eocExp, efcExp);
- //var query1 = SelectCourseResultDAL.GetSelectCourseResultTeacher(eocExp, efcExp);
- if (schoolYearID.HasValue)
- {
- query = query.Where(x => x.SchoolyearID == schoolYearID);
- //query1 = query1.Where(x => x.SchoolyearID == schoolYearID);
- }
- if (collegeID.HasValue)
- {
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (courseID.HasValue)
- {
- query = query.Where(x => x.CoursematerialID == courseID);
- }
- if (courseTypeID.HasValue)
- {
- query = query.Where(x => x.CourseTypeID == courseTypeID);
- //query1 = query1.Where(x => x.CourseTypeID == courseTypeID);
- }
- if (selectCourseTypeID.HasValue)
- {
- query = query.Where(x => x.SelectCourseType == selectCourseTypeID);
- //query1 = query1.Where(x => x.SelectCourseType == selectCourseTypeID);
- }
- if (isCreated.HasValue)
- {
- query = query.Where(x => x.RecordStatus == isCreated);
- //if (isCreated == (int)EMIS.ViewModel.CF_GeneralPurpose.IsYes)
- // query = query.Where(x => x.RecordStatus == (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Created);
- //else if (isCreated == (int)EMIS.ViewModel.CF_GeneralPurpose.IsNo)
- // query = query.Where(x => x.RecordStatus != (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Created);
- }
- if (isOpened.HasValue)
- {
- query = query.Where(x => x.IsOpened == (isOpened == 1 ? true : false));
- //query1 = query1.Where(x => x.IsOpened == (isOpened == 1 ? true : false));
- }
- //未提交状态不显示
- query = query.Where(x => x.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen);
- //query1 = query1.Where(x => x.RecordStatus > (int)EMIS.ViewModel.EM_SelectCourseResultStatus.NotOpen);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- //var teacher = query1.ToList().OrderBy(x => x.SelectCourseType);
- var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SelectCourseType).ToList();
- //result.ForEach(x => x.TeacherName = string.Join(",", teacher.Where(w => w.ID == x.ID).Select(w => w.TeacherName)));
- return result;
- }
- public bool SelectCourseListDelete(List<Guid?> IDs, List<int?> Types, List<Guid?> UserIDs)
- {
- try
- {
- if (IDs.Count > 0)
- {
- for (int i = 0; i < IDs.Count; i++)
- {
- if (Types[i] == 0)
- { //限选
- var id = IDs[i].Value;
- var UserID = UserIDs[i].Value;
- EM_ExecutableOptionalCourse ExecutableOptionalCourse = SelectCourseResultDAL.ExecutableOptionalCourseRepository.GetList(x => x.ExecutableOptionalCourseID == id, x => x.CF_Student).FirstOrDefault();
- ExecutableOptionalCourse.CF_Student.RemoveWhere(x => x.UserID == UserID);
- }
- else if (Types[i] == 1)
- { //任选
- var id = IDs[i].Value;
- var UserID = UserIDs[i].Value;
- EM_ExecutableFreeSelectionCouse ExecutableFreeSelectionCouse = SelectCourseResultDAL.ExecutableFreeSelectionCouseRepository.GetList(x => x.ExecutableFreeSelectionCouseID == id, x => x.CF_Student).FirstOrDefault();
- ExecutableFreeSelectionCouse.CF_Student.RemoveWhere(x => x.UserID == UserID);
- }
- }
- this.UnitOfWork.Commit();
- return true;
- }
- else
- throw new Exception("请选择要删除的学生信息");
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- }
- }
|