123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel;
- using EMIS.ViewModel.StudentManage.OnlineChecking;
- using EMIS.ViewModel.SystemView;
- using EMIS.DataLogic.StudentManage.OnlineChecking;
- using EMIS.Entities;
- using System.Linq.Expressions;
- namespace EMIS.CommonLogic.StudentManage.OnlineChecking
- {
- public class OpenObjectServices : BaseServices, IOpenObjectServices
- {
- public OpenObjectDAL OpenObjectDAL { get; set; }
- /// <summary>
- /// 查询对应的学生校对控制开放对象信息OpenObjectView
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="educationID"></param>
- /// <param name="schoolyearNumID"></param>
- /// <param name="dateRange"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<OpenObjectView> GetStudentEditObjectViewGrid(ConfiguretView configuretView, int? educationID, int? schoolyearNumID, DateTime? dateRange, int pageIndex, int pageSize)
- {
- Expression<Func<CF_StudentEditObjects, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (educationID.HasValue)
- {
- exp = exp.And(x => x.EducationID == educationID);
- }
- if (schoolyearNumID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearNumID == schoolyearNumID);
- }
- if (dateRange.HasValue)
- {
- exp = exp.And(x => x.Starttime <= dateRange);
- }
- if (dateRange.HasValue)
- {
- exp = exp.And(x => x.Endtime >= dateRange);
- }
- var query = OpenObjectDAL.GetStudentEditObjectQueryable(exp);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.EducationID).ThenBy(x => x.SchoolyearNumID).ToGridResultSet<OpenObjectView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的学生校对控制开放对象信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="educationID"></param>
- /// <param name="schoolyearNumID"></param>
- /// <param name="dateRange"></param>
- /// <returns></returns>
- public IList<OpenObjectView> GetStudentEditObjectViewList(ConfiguretView configuretView, int? educationID, int? schoolyearNumID, DateTime? dateRange)
- {
- Expression<Func<CF_StudentEditObjects, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (educationID.HasValue)
- {
- exp = exp.And(x => x.EducationID == educationID);
- }
- if (schoolyearNumID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearNumID == schoolyearNumID);
- }
- if (dateRange.HasValue)
- {
- exp = exp.And(x => x.Starttime <= dateRange);
- }
- if (dateRange.HasValue)
- {
- exp = exp.And(x => x.Endtime >= dateRange);
- }
- var query = OpenObjectDAL.GetStudentEditObjectQueryable(exp);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.EducationID).ThenBy(x => x.SchoolyearNumID).ToList();
- }
- /// <summary>
- /// 查询对应的开放对象信息OpenObjectView
- /// </summary>
- /// <param name="studentEditObjectID"></param>
- /// <returns></returns>
- public OpenObjectView GetStudentEditObjectView(Guid? studentEditObjectID)
- {
- try
- {
- Expression<Func<CF_StudentEditObjects, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => x.StudentEditObjectsID == studentEditObjectID);
- var query = OpenObjectDAL.GetStudentEditObjectQueryable(exp).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑(新增、修改)
- /// </summary>
- /// <param name="openObjectView"></param>
- public void StudentEditObjectEdit(OpenObjectView openObjectView)
- {
- try
- {
- var studentEditObjectVerify = OpenObjectDAL.StudentEditObjectsRepository.GetList(x => x.StudentEditObjectsID != openObjectView.StudentEditObjectsID
- && x.EducationID == openObjectView.EducationID && x.SchoolyearNumID == openObjectView.SchoolyearNumID).SingleOrDefault();
- if (studentEditObjectVerify == null)
- {
- if (openObjectView.StudentEditObjectsID != Guid.Empty)
- {
- var studentEditObject = OpenObjectDAL.StudentEditObjectsRepository.GetList(x => x.StudentEditObjectsID == openObjectView.StudentEditObjectsID).SingleOrDefault();
- if (studentEditObject == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- else
- {
- //表示修改
- studentEditObject.EducationID = openObjectView.EducationID;
- studentEditObject.SchoolyearNumID = openObjectView.SchoolyearNumID;
- studentEditObject.Starttime = openObjectView.Starttime;
- studentEditObject.Endtime = openObjectView.Endtime;
- studentEditObject.Remark = openObjectView.Remark;
- SetModifyStatus(studentEditObject);
- }
- }
- else
- {
- //表示新增
- var newStudentEditObject = new CF_StudentEditObjects();
- newStudentEditObject.StudentEditObjectsID = Guid.NewGuid();
- newStudentEditObject.EducationID = openObjectView.EducationID;
- newStudentEditObject.SchoolyearNumID = openObjectView.SchoolyearNumID;
- newStudentEditObject.Starttime = openObjectView.Starttime;
- newStudentEditObject.Endtime = openObjectView.Endtime;
- newStudentEditObject.Remark = openObjectView.Remark;
- SetNewStatus(newStudentEditObject);
- UnitOfWork.Add(newStudentEditObject);
- }
- }
- else
- {
- throw new Exception("已存在相同的开放对象信息,请核查。");
- }
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 开放对象批量新增
- /// </summary>
- /// <param name="schoolyearNumIDList"></param>
- /// <param name="openObjectView"></param>
- /// <returns></returns>
- public string StudentEditObjectBatchAdd(List<int?> schoolyearNumIDList, OpenObjectView openObjectView)
- {
- try
- {
- Expression<Func<CF_StudentEditObjects, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- exp = exp.And(x => schoolyearNumIDList.Contains(x.SchoolyearNumID));
- var studentEditObjectList = OpenObjectDAL.StudentEditObjectsRepository.GetList(exp).ToList();
- int success = 0;
- int fail = 0;
- string tipMessage = null;
- List<CF_StudentEditObjects> studentEditObjectInList = new List<CF_StudentEditObjects>();
- foreach (var schoolyearNumID in schoolyearNumIDList)
- {
- var studentEditObjectVerify = studentEditObjectList.Where(x => x.EducationID == openObjectView.EducationID &&
- x.SchoolyearNumID == schoolyearNumID).SingleOrDefault();
- if (studentEditObjectVerify == null)
- {
- //新增
- var newStudentEditObject = new CF_StudentEditObjects();
- newStudentEditObject.StudentEditObjectsID = Guid.NewGuid();
- newStudentEditObject.EducationID = openObjectView.EducationID;
- newStudentEditObject.SchoolyearNumID = schoolyearNumID;
- newStudentEditObject.Starttime = openObjectView.Starttime;
- newStudentEditObject.Endtime = openObjectView.Endtime;
- //newStudentEditObject.Remark = openObjectView.Remark;
- SetNewStatus(newStudentEditObject);
- studentEditObjectInList.Add(newStudentEditObject);
- success++;
- }
- else
- {
- //表示已存在相同的开放对象信息
- fail++;
- }
- }
- UnitOfWork.BulkInsert(studentEditObjectInList);
- if (success > 0 && fail <= 0)
- {
- tipMessage = success + "条";
- }
- else
- {
- tipMessage = success + "条," + fail + "条失败,原因:已存在相同的开放对象信息,请检查";
- }
- return tipMessage;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 查询开放对象中未新增的培养层次信息DictionaryItemView
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="educationID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<DictionaryItemView> GetSchoolyearNumNoAddGrid(ConfiguretView configuretView, int? educationID, int pageIndex, int pageSize)
- {
- Expression<Func<CF_StudentEditObjects, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (educationID.HasValue)
- {
- exp = exp.And(x => x.EducationID == educationID);
- }
- var query = OpenObjectDAL.GetSchoolyearNumNoAddQueryable(exp);
- query = query.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.DictionaryCode).ThenBy(x => x.OrderNo).ToGridResultSet<DictionaryItemView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询开放对象中未新增的培养层次信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="educationID"></param>
- /// <returns></returns>
- public IList<DictionaryItemView> GetSchoolyearNumNoAddList(ConfiguretView configuretView, int? educationID)
- {
- Expression<Func<CF_StudentEditObjects, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (educationID.HasValue)
- {
- exp = exp.And(x => x.EducationID == educationID);
- }
- var query = OpenObjectDAL.GetSchoolyearNumNoAddQueryable(exp);
- query = query.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.DictionaryCode).ThenBy(x => x.OrderNo).ToList();
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="studentEditObjectIDs"></param>
- /// <returns></returns>
- public bool StudentEditObjectDelete(List<Guid?> studentEditObjectIDs)
- {
- try
- {
- UnitOfWork.Delete<CF_StudentEditObjects>(x => studentEditObjectIDs.Contains(x.StudentEditObjectsID));
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|