123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.Linq;
- using EMIS.Utility;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.EducationManage;
- using EMIS.DataLogic.EducationManage;
- using EMIS.ViewModel.UniversityManage.AdministrativeOrgan;
- namespace EMIS.CommonLogic.EducationManage
- {
- public class EducationMissionOpenControlServices : BaseServices, IEducationMissionOpenControlServices
- {
- public EducationMissionOpenControlDAL EducationMissionOpenControlDAL { get; set; }
- /// <summary>
- /// 查询对应的教学任务控制信息EducationMissionOpenControlView
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="dateRange"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<EducationMissionOpenControlView> GetEducationMissionOpenControlViewGrid(ConfiguretView configuretView,
- Guid? schoolyearID, Guid? campusID, Guid? collegeID, DateTime? dateRange, int pageIndex, int pageSize)
- {
- Expression<Func<EM_EducationMissionOpenControl, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CollegeID == collegeID);
- }
- if (dateRange.HasValue)
- {
- exp = exp.And(x => x.StartDate <= dateRange);
- }
- if (dateRange.HasValue)
- {
- exp = exp.And(x => x.EndDate >= dateRange);
- }
- var query = EducationMissionOpenControlDAL.GetEducationMissionOpenControlViewQueryable(exp);
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.Value)
- .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
- .ToGridResultSet<EducationMissionOpenControlView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的教学任务控制信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="dateRange"></param>
- /// <returns></returns>
- public List<EducationMissionOpenControlView> GetEducationMissionOpenControlViewList(ConfiguretView configuretView,
- Guid? schoolyearID, Guid? campusID, Guid? collegeID, DateTime? dateRange)
- {
- Expression<Func<EM_EducationMissionOpenControl, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CollegeID == collegeID);
- }
- if (dateRange.HasValue)
- {
- exp = exp.And(x => x.StartDate <= dateRange);
- }
- if (dateRange.HasValue)
- {
- exp = exp.And(x => x.EndDate >= dateRange);
- }
- var query = EducationMissionOpenControlDAL.GetEducationMissionOpenControlViewQueryable(exp);
- if (campusID.HasValue)
- {
- query = query.Where(x => x.CampusID == campusID);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.Value)
- .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
- .ToList();
- }
- /// <summary>
- /// 根据对应的教学任务控制ID查询教学任务控制信息EducationMissionOpenControlView
- /// </summary>
- /// <param name="educationMissionOpenControlID"></param>
- /// <returns></returns>
- public EducationMissionOpenControlView GetEducationMissionOpenControlView(Guid? educationMissionOpenControlID)
- {
- try
- {
- Expression<Func<EM_EducationMissionOpenControl, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.EducationMissionOpenControlID == educationMissionOpenControlID);
- var query = EducationMissionOpenControlDAL.GetEducationMissionOpenControlViewQueryable(exp).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="educationMissionOpenControlView"></param>
- public void EducationMissionOpenControlEdit(EducationMissionOpenControlView educationMissionOpenControlView)
- {
- try
- {
- //查询数据库进行验证
- var educationMissionOpenControlVerify = EducationMissionOpenControlDAL.EducationMissionOpenControlRepository
- .GetList(x => x.EducationMissionOpenControlID != educationMissionOpenControlView.EducationMissionOpenControlID
- && x.SchoolyearID == educationMissionOpenControlView.SchoolyearID
- && x.CollegeID == educationMissionOpenControlView.CollegeID).SingleOrDefault();
- if (educationMissionOpenControlVerify == null)
- {
- //数据有误验证
- if (educationMissionOpenControlView.EducationMissionOpenControlID != Guid.Empty)
- {
- var educationMissionOpenControl = EducationMissionOpenControlDAL.EducationMissionOpenControlRepository
- .GetList(x => x.EducationMissionOpenControlID == educationMissionOpenControlView.EducationMissionOpenControlID)
- .SingleOrDefault();
- if (educationMissionOpenControl == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- else
- {
- //表示修改
- educationMissionOpenControl.CollegeID = educationMissionOpenControlView.CollegeID;
- educationMissionOpenControl.SchoolyearID = educationMissionOpenControlView.SchoolyearID;
- educationMissionOpenControl.StartDate = educationMissionOpenControlView.StartDate;
- educationMissionOpenControl.EndDate = educationMissionOpenControlView.EndDate;
- SetModifyStatus(educationMissionOpenControl);
- }
- }
- else
- {
- //表示新增
- EM_EducationMissionOpenControl educationMissionOpenControl = new EM_EducationMissionOpenControl();
- educationMissionOpenControl.EducationMissionOpenControlID = Guid.NewGuid();
- educationMissionOpenControl.CollegeID = educationMissionOpenControlView.CollegeID;
- educationMissionOpenControl.SchoolyearID = educationMissionOpenControlView.SchoolyearID;
- educationMissionOpenControl.StartDate = educationMissionOpenControlView.StartDate;
- educationMissionOpenControl.EndDate = educationMissionOpenControlView.EndDate;
- SetNewStatus(educationMissionOpenControl);
- UnitOfWork.Add(educationMissionOpenControl);
- }
- }
- else
- {
- throw new Exception("已存在相同的教学控制信息,请核查。");
- }
- //事务提交
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 教学控制信息批量新增
- /// </summary>
- /// <param name="collegeIDList"></param>
- /// <param name="educationMissionOpenControlView"></param>
- /// <returns></returns>
- public string EducationMissionOpenControlBatchAdd(List<Guid?> collegeIDList, EducationMissionOpenControlView educationMissionOpenControlView)
- {
- try
- {
- Expression<Func<EM_EducationMissionOpenControl, bool>> expEduOpenControl = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expEduOpenControl = expEduOpenControl.And(x => collegeIDList.Contains(x.CollegeID));
- var eduOpenControlList = EducationMissionOpenControlDAL.EducationMissionOpenControlRepository.GetList(expEduOpenControl).ToList();
- int success = 0; //成功
- int fail = 0; //失败
- string tipMessage = null; //提示消息
- List<EM_EducationMissionOpenControl> eduOpenControlInList = new List<EM_EducationMissionOpenControl>();
- foreach (var collegeID in collegeIDList)
- {
- var eduOpenControlVerify = eduOpenControlList.Where(x => x.CollegeID == collegeID
- && x.SchoolyearID == educationMissionOpenControlView.SchoolyearID).SingleOrDefault();
- if (eduOpenControlVerify == null)
- {
- //新增
- var newEduOpenControl = new EM_EducationMissionOpenControl();
- newEduOpenControl.EducationMissionOpenControlID = Guid.NewGuid();
- newEduOpenControl.SchoolyearID = educationMissionOpenControlView.SchoolyearID;
- newEduOpenControl.CollegeID = collegeID;
- newEduOpenControl.StartDate = educationMissionOpenControlView.StartDate;
- newEduOpenControl.EndDate = educationMissionOpenControlView.EndDate;
- SetNewStatus(newEduOpenControl);
- eduOpenControlInList.Add(newEduOpenControl);
- success++;
- }
- else
- {
- //表示已存在相同的教学控制信息
- fail++;
- }
- }
- //批量插入
- UnitOfWork.BulkInsert<EM_EducationMissionOpenControl>(eduOpenControlInList);
- if (success > 0 && fail <= 0)
- {
- tipMessage = success + "条";
- }
- else
- {
- tipMessage = success + "条," + fail + "条失败,原因:已存在相同的教学控制信息,请检查";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询教学控制中未新增的院系所信息CollegeView
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="unitCategoryID"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<CollegeView> GetCollegeViewNoAddGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID,
- int? unitCategoryID, Guid? schoolyearID, int pageIndex, int pageSize)
- {
- //院系所信息
- Expression<Func<CF_College, bool>> expCollege = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (campusID.HasValue)
- {
- expCollege = expCollege.And(x => x.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- expCollege = expCollege.And(x => x.CollegeID == collegeID);
- }
- if (unitCategoryID.HasValue)
- {
- expCollege = expCollege.And(x => x.CF_CollegeProfile.UnitCategoryID == unitCategoryID);
- }
-
- //教学控制
- Expression<Func<EM_EducationMissionOpenControl, bool>> expEduOpenControl = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (schoolyearID.HasValue)
- {
- expEduOpenControl = expEduOpenControl.And(x => x.SchoolyearID == schoolyearID);
- }
- var query = EducationMissionOpenControlDAL.GetCollegeViewNoAddQueryable(expCollege, expEduOpenControl);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query)
- .OrderBy(x => x.No.Length).ThenBy(x => x.No)
- .ToGridResultSet<CollegeView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询教学控制中未新增的院系所信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="schoolyearID"></param>
- /// <returns></returns>
- public IList<CollegeView> GetCollegeViewNoAddList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID,
- int? unitCategoryID, Guid? schoolyearID)
- {
- //院系所信息
- Expression<Func<CF_College, bool>> expCollege = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (campusID.HasValue)
- {
- expCollege = expCollege.And(x => x.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- expCollege = expCollege.And(x => x.CollegeID == collegeID);
- }
- if (unitCategoryID.HasValue)
- {
- expCollege = expCollege.And(x => x.CF_CollegeProfile.UnitCategoryID == unitCategoryID);
- }
- //教学控制
- Expression<Func<EM_EducationMissionOpenControl, bool>> expEduOpenControl = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (schoolyearID.HasValue)
- {
- expEduOpenControl = expEduOpenControl.And(x => x.SchoolyearID == schoolyearID);
- }
- var query = EducationMissionOpenControlDAL.GetCollegeViewNoAddQueryable(expCollege, expEduOpenControl);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCollege(query)
- .OrderBy(x => x.No.Length).ThenBy(x => x.No).ToList();
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="educationMissionOpenControlIDs"></param>
- /// <returns></returns>
- public bool EducationMissionOpenControlDelete(List<Guid?> educationMissionOpenControlIDs)
- {
- try
- {
- UnitOfWork.Delete<EM_EducationMissionOpenControl>(x => educationMissionOpenControlIDs.Contains(x.EducationMissionOpenControlID));
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|