123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.DQPSystem;
- using EMIS.ViewModel;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using EMIS.DataLogic.DQPSystem;
- using EMIS.CommonLogic.CalendarManage;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.Utility.FormValidate;
- using EMIS.ViewModel.Students;
- using EMIS.ViewModel.EducationManage;
- using EMIS.DataLogic.EducationManage;
- using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
- using EMIS.ViewModel.UniversityManage.AdministrativeOrgan;
- namespace EMIS.CommonLogic.DQPSystem
- {
- public partial class SOCServices : BaseServices, ISOCServices, IFileUploadServices
- {
- public SOCDAL SOCDAL { get; set; }
- public SOCTemplateDAL SOCTemplateDAL { get; set; }
- public ISchoolYearServices SchoolYearServices { get; set; }
- public IRoleServices RoleServices { get; set; }
- public EducationMissionClassDAL EducationMissionClassDAL { get; set; }
- public IGridResultSet<SOCView> GetSOCViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? coursematerialID, Guid? collegeID, int pageIndex, int pageSize)
- {
- Expression<Func<DQP_SOC, bool>> exp = x => true;
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (coursematerialID.HasValue)
- {
- exp = exp.And(x => x.CoursematerialID == coursematerialID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CF_Department.CollegeID == collegeID);
- }
- var role = RoleServices.GetEnabledTeacherRoleViewList();
- var teacherRole = role.Where(x => x.RoleName == "教师");
-
- var query = SOCDAL.GetSOCViewQueryable(exp, null);
- if (curUser.RoleID == teacherRole.FirstOrDefault().RoleID)
- {
- query = SOCDAL.GetSOCViewQueryable(exp, curUser.UserID);
- }
- else
- {
- query = this.GetQueryByDataRangeByDepartment(query);
- }
-
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
-
- var result = query
- .OrderBy(x => x.SchoolyearCode.Length)
- .ThenByDescending(x => x.SchoolyearCode).ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ThenBy(x => x.EducationMissionName)
- .ToGridResultSet<SOCView>(pageIndex, pageSize);
- return result;
- }
- public IGridResultSet<SOCView> GetSOCViewByTeacherIDGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? userID, int pageIndex, int pageSize)
- {
- Expression<Func<DQP_SOC, bool>> exp = x => true;
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- }
- var query = SOCDAL.GetSOCViewQueryable(exp, userID);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- var result = query
- .OrderBy(x => x.SchoolyearCode.Length)
- .ThenByDescending(x => x.SchoolyearCode).ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ThenBy(x => x.EducationMissionName)
- .ToGridResultSet<SOCView>(pageIndex, pageSize);
- return result;
- }
- public SOCView GetSOCViewByID(Guid? SOCID)
- {
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- return SOCDAL.GetSOCViewQueryable(x => x.SOCID == SOCID, curUser.UserID).FirstOrDefault();
- }
- public IGridResultSet<SOCDetailView> GetSOCDetailViewGridByID(Guid? SOCID)
- {
- Expression<Func<DQP_SOCDetail, bool>> exp = x => true;
- if (SOCID.HasValue)
- {
- exp = exp.And(x => x.SOCID == SOCID);
- }
- var query = SOCDAL.GetSOCDetailViewQueryable(exp);
- return query.OrderBy(x => x.Name).ToGridResultSet<SOCDetailView>();
- }
- public SOCDetailView GetSOCDetailViewByID(Guid? SOCDetailID)
- {
- var query = SOCDAL.GetSOCDetailViewQueryable(x => x.SOCDetailID == SOCDetailID);
- return query.FirstOrDefault();
- }
- public void GenerateSOC()
- {
- try
- {
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
- var dbSOCViewList = SOCDAL.GetSOCViewQueryable(x => true, curUser.UserID).ToList();//获取已有的SOC
- var query = SOCDAL.GetSOCGenerateViewQueryble(schoolYear.SchoolyearID, curUser.UserID).ToList();//根据教学任务生成
- var educationIDList = query.Select(x => x.EducationMissionID).ToList();//获取教学任务ID
- var emquery = SOCDAL.GetEducationMissionMassageByID(x => educationIDList.Contains(x.EducationMissionID)).ToList();//根据教学任务ID获取相关信息(学生)
- List<DQP_SOC> socList = new List<DQP_SOC>();
- List<DQP_SOCDetail> detailList = new List<DQP_SOCDetail>();
- //List<DQP_SOCStaff> staffList = new List<DQP_SOCStaff>();
- List<DQP_SOCStaff> addStaffList = new List<DQP_SOCStaff>();
- List<DQP_SOCDetailAttachment> attachmentList = new List<DQP_SOCDetailAttachment>();
- foreach (var edu in query)
- {
- if (!dbSOCViewList.Any(x => x.SchoolyearID == edu.SOCView.SchoolyearID && x.CoursematerialID == edu.SOCView.CoursematerialID && x.DepartmentID == edu.SOCView.DepartmentID
- && x.HandleModeID == edu.HandleModeID))
- {
- List<DQP_SOCStaff> staffList = new List<DQP_SOCStaff>();
- DQP_SOC soc = new DQP_SOC();
- soc.SOCID = Guid.NewGuid();
- soc.EducationMissionID = edu.EducationMissionID;
- soc.SchoolyearID = edu.SOCView.SchoolyearID;
- soc.CoursematerialID = edu.SOCView.CoursematerialID;
- soc.DepartmentID = edu.SOCView.DepartmentID;
- soc.Credit = edu.SOCView.Credit;
- soc.HandleModeID = edu.HandleModeID;
- soc.OptionalCourseTypeID = edu.OptionalCourseTypeID;
- this.SetNewStatus(soc);
- var edumassage = emquery.Distinct().Where(x => x.EducationMissionID == edu.EducationMissionID).ToList();
- foreach (var massage in edumassage)
- {
- foreach (var teacher in massage.MissionClassTeacherViewList)
- {
- DQP_SOCStaff staff = new DQP_SOCStaff();
- staff.SOCStaffID = Guid.NewGuid();
- staff.SOCID = soc.SOCID;
- staff.UserID = teacher.UserID.Value;
- staff.TeachingMethod = teacher.TeachingMethod;
- this.SetNewStatus(staff);
- foreach (var student in massage.StudentList)
- {
- staff.CF_Student.Add(student);
- }
- //soc.DQP_SOCStaff.Add(staff);
- staffList.Add(staff);
- }
- foreach (var classmajor in massage.ClassmajorList)
- {
- soc.CF_Classmajor.Add(classmajor);
- }
- foreach (var student in massage.StudentList)
- {
- soc.CF_Student.Add(student);
- }
- }
- var staffListIn = staffList.GroupBy(x => new { x.SOCID, x.UserID, x.TeachingMethod }).Select(x => new { x.Key.SOCID, x.Key.UserID, x.Key.TeachingMethod }).ToList();
- //staffList = new List<DQP_SOCStaff>();
- foreach (var i in staffListIn)
- {
- DQP_SOCStaff staff = new DQP_SOCStaff();
- staff.SOCStaffID = Guid.NewGuid();
- staff.SOCID = i.SOCID;
- staff.UserID = i.UserID;
- staff.TeachingMethod = i.TeachingMethod;
- this.SetNewStatus(staff);
- Expression<Func<EM_EducationMission, bool>> exp = x => x.EducationMissionID == edu.EducationMissionID;
- //查找老师对应的学生
- var studentList = SOCDAL.GetStudentByTeacher(exp, i.UserID, edu.SOCView.CoursematerialID).Distinct().ToList();
- foreach (var stu in studentList)
- {
- staff.CF_Student.Add(stu);
- }
- addStaffList.Add(staff);
- }
- socList.Add(soc);
- }
-
- }
- UnitOfWork.BulkInsert(socList);
- UnitOfWork.BulkInsert(socList, x => x.CF_Classmajor);
- UnitOfWork.BulkInsert(socList, x => x.CF_Student);
- UnitOfWork.BulkInsert(detailList);
- UnitOfWork.BulkInsert(attachmentList);
- UnitOfWork.BulkInsert(addStaffList);
- UnitOfWork.BulkInsert(addStaffList, x => x.CF_Student);
- //var socTemplatequery = SOCTemplateDAL.GetSOCTemplateViewQueryable(x => x.RecordStatus == (int)SYS_STATUS.USABLE, x => true);
- //var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- //var schoolYear = SchoolYearServices.GetSchoolYearIsCurrent(true);
- //var dbSOCViewList = SOCDAL.GetSOCViewQueryable(x => true, curUser.UserID).ToList();
- //var query = SOCDAL.GetSOCGenerateViewQueryble(schoolYear.SchoolyearID, curUser.UserID).ToList();
- //var CoursematerialIDList = query.Select(x => x.SOCView.CoursematerialID).ToList();
-
- ////var eduIDList = query.Select(x => x.EducationMissionID).ToList();
- //var soctemIDList = query.Select(x => x.SOCTemplateID).ToList();
- //var emquery = SOCDAL.GetEducationMissionMassageForSOCGenerate(x => x.SchoolyearID == schoolYear.SchoolyearID, CoursematerialIDList).ToList();
- //var socquery = SOCDAL.GetSOCTemplateForSOCGenerate(x => soctemIDList.Contains(x.SOCTemplateID)).ToList();
- //List<DQP_SOC> socList = new List<DQP_SOC>();
- //List<DQP_SOCDetail> detailList = new List<DQP_SOCDetail>();
- //List<DQP_SOCStaff> staffList = new List<DQP_SOCStaff>();
- //List<DQP_SOCStaff> addStaffList = new List<DQP_SOCStaff>();
- ////List<DQP_SOCStaff> staffListIn = new List<DQP_SOCStaff>();
- //List<DQP_SOCDetailAttachment> attachmentList = new List<DQP_SOCDetailAttachment>();
- //var queryList = query.GroupBy(x => x.SOCTemplateID).ToList();
- //var SOCGenerateList = new List<SOCGenerateView>();
- //foreach (var qu in query)
- //{
- // if (SOCGenerateList.Any(x => x.SOCView.CoursematerialID == qu.SOCView.CoursematerialID && x.SOCView.DepartmentID == qu.SOCView.DepartmentID))
- // {
- // continue;
- // }
- // if (query.Any(x => x.SOCTemplateID != qu.SOCTemplateID && x.SOCView.CoursematerialID == qu.SOCView.CoursematerialID && x.SOCView.DepartmentID == qu.SOCView.DepartmentID))
- // {
- // //if (qu.FacultymajorID != null && qu.SchoolcodeID != null && qu.SchoolyearNumID != null)
- // ////&& qu.HandleModeID != null
- // //{
- // // SOCGenerateList.Add(qu);
- // //}
- // //else
- // //{
- // Dictionary<Guid, int> dictionary = new Dictionary<Guid, int>();
- // var sameTemplate = query.Where(x => x.SOCView.CoursematerialID == qu.SOCView.CoursematerialID && x.SOCView.DepartmentID == qu.SOCView.DepartmentID);
- // if (sameTemplate.Any(x => x.FacultymajorID != null && x.SchoolcodeID != null && x.SchoolyearNumID != null))
- // //&& x.HandleModeID != null
- // {
- // SOCGenerateList.Add(sameTemplate.FirstOrDefault(x => x.FacultymajorID != null && x.SchoolcodeID != null && x.SchoolyearNumID != null));
- // //&& x.HandleModeID != null
- // }
- // else if (sameTemplate.Any(x => x.FacultymajorID != null))
- // {
- // SOCGenerateList.Add(sameTemplate.FirstOrDefault(x => x.FacultymajorID != null));
- // }
- // else if (sameTemplate.Any(x => x.SchoolyearNumID != null && x.SchoolcodeID != null))
- // {
- // SOCGenerateList.Add(sameTemplate.FirstOrDefault(x => x.SchoolyearNumID != null && x.SchoolcodeID != null));
- // }
- // else if (sameTemplate.Any(x => x.SchoolcodeID != null))
- // {
- // SOCGenerateList.Add(sameTemplate.FirstOrDefault(x => x.SchoolcodeID != null));
- // }
- // else if (sameTemplate.Any(x => x.SchoolyearNumID != null))
- // {
- // SOCGenerateList.Add(sameTemplate.FirstOrDefault(x => x.SchoolyearNumID != null));
- // }
- // else if (sameTemplate.Any(x => x.FacultymajorID == null && x.SchoolyearNumID == null && x.SchoolcodeID == null))
- // {
- // SOCGenerateList.Add(sameTemplate.FirstOrDefault(x => x.FacultymajorID == null && x.SchoolyearNumID == null && x.SchoolcodeID == null));
- // }
- // //}
- // }
- // else {
- // SOCGenerateList.Add(qu);
- // }
- //}
- //foreach (var edu in SOCGenerateList)
- //{
- // if (!dbSOCViewList.Any(x => x.SchoolyearID == edu.SOCView.SchoolyearID && x.CoursematerialID == edu.SOCView.CoursematerialID && x.DepartmentID == edu.SOCView.DepartmentID
- // && x.HandleModeID == edu.HandleModeID))
- // {
- // DQP_SOC soc = new DQP_SOC();
- // soc.SOCID = Guid.NewGuid();
- // soc.SchoolyearID = edu.SOCView.SchoolyearID;
- // soc.CoursematerialID = edu.SOCView.CoursematerialID;
- // soc.DepartmentID = edu.SOCView.DepartmentID;
- // soc.Credit = edu.SOCView.Credit;
- // soc.HandleModeID = edu.HandleModeID;
- // soc.OptionalCourseTypeID = edu.OptionalCourseTypeID;
- // this.SetNewStatus(soc);
- // var edumassage = emquery.Distinct().Where(x => x.SOCView.CoursematerialID == edu.SOCView.CoursematerialID
- // //&& x.MissionClassTeacherViewList.Any(y => x)
- // && x.SOCView.DepartmentID == edu.SOCView.DepartmentID
- // && (x.SOCView.SchoolyearID == edu.SOCView.SchoolyearID || edu.SOCView.SchoolyearID == null)).ToList();
-
- // var socmassage = socquery.Where(x => x.SOCTemplateID == edu.SOCTemplateID);
- // foreach(var massage in edumassage)
- // {
- // foreach (var teacher in massage.MissionClassTeacherViewList)
- // {
- // DQP_SOCStaff staff = new DQP_SOCStaff();
- // staff.SOCStaffID = Guid.NewGuid();
- // staff.SOCID = soc.SOCID;
- // staff.UserID = teacher.UserID.Value;
- // staff.TeachingMethod = teacher.TeachingMethod;
- // this.SetNewStatus(staff);
-
- // foreach (var student in massage.StudentList)
- // {
- // staff.CF_Student.Add(student);
- // }
- // //soc.DQP_SOCStaff.Add(staff);
- // staffList.Add(staff);
- // }
- // foreach (var classmajor in massage.ClassmajorList)
- // {
- // soc.CF_Classmajor.Add(classmajor);
- // }
- // foreach (var student in massage.StudentList)
- // {
- // soc.CF_Student.Add(student);
- // }
- // }
- // foreach (var socm in socmassage)
- // {
- // foreach (var detail in socm.SOCDetailViewList)
- // {
- // DQP_SOCDetail SOCdetail = new DQP_SOCDetail();
- // SOCdetail.SOCDetailID = Guid.NewGuid();
- // SOCdetail.SOCID = soc.SOCID;
- // SOCdetail.Name = detail.Name;
- // SOCdetail.Weight = detail.Weight;
- // SOCdetail.IsGroup = detail.IsGroup ?? false;
- // SOCdetail.Description = detail.Description;
- // SOCdetail.Credit = detail.Credit;
- // this.SetNewStatus(SOCdetail);
- // foreach (var att in detail.AttachmentList)
- // {
- // DQP_SOCDetailAttachment attachment = new DQP_SOCDetailAttachment();
- // attachment.SOCDetailAttachmentID = Guid.NewGuid();
- // attachment.SOCDetailID = SOCdetail.SOCDetailID;
- // attachment.Name = att.Name;
- // attachment.Url = att.Url;
- // this.SetNewStatus(attachment);
- // attachmentList.Add(attachment);
- // }
- // soc.DQP_SOCDetail.Add(SOCdetail);
- // detailList.Add(SOCdetail);
- // }
- // }
- // socList.Add(soc);
- // }
- // var staffListIn = staffList.GroupBy(x => new { x.SOCID, x.UserID, x.TeachingMethod }).Select(x => new { x.Key.SOCID, x.Key.UserID, x.Key.TeachingMethod }).ToList();
- // //staffList = new List<DQP_SOCStaff>();
- // foreach (var i in staffListIn)
- // {
- // DQP_SOCStaff staff = new DQP_SOCStaff();
- // staff.SOCStaffID = Guid.NewGuid();
- // staff.SOCID = i.SOCID;
- // staff.UserID = i.UserID;
- // staff.TeachingMethod = i.TeachingMethod;
- // this.SetNewStatus(staff);
- // Expression<Func<EM_EducationMission, bool>> exp = x => x.SchoolyearID == schoolYear.SchoolyearID;
- // //查找老师对应的学生
- // var studentList = SOCDAL.GetStudentByTeacher(exp, i.UserID, edu.SOCView.CoursematerialID).Distinct().ToList();
- // foreach (var stu in studentList)
- // {
- // staff.CF_Student.Add(stu);
- // }
- // addStaffList.Add(staff);
- // }
- //}
-
- //UnitOfWork.BulkInsert(socList);
- //UnitOfWork.BulkInsert(socList, x => x.CF_Classmajor);
- //UnitOfWork.BulkInsert(socList, x => x.CF_Student);
- ////UnitOfWork.BulkInsert(socList, x => x.DQP_SOCStaff);
- //UnitOfWork.BulkInsert(detailList);
- //UnitOfWork.BulkInsert(attachmentList);
- //UnitOfWork.BulkInsert(addStaffList);
- //UnitOfWork.BulkInsert(addStaffList, x => x.CF_Student);
- }
- catch (Exception)
- {
-
- throw;
- }
- }
- public void SOCEdit(SOCView SOCView, List<SOCDetailView> SOCDetailViewList, List<FileUploadView> fileList, List<Guid?> socIDList)
- {
- try
- {
- DQP_SOC SOC = new DQP_SOC();
- var dbAttachmentList = SOCDAL.SOCDetailAttachmentRepository.GetList(x => x.DQP_SOCDetail.DQP_SOC.SOCID == SOCView.SOCID).ToList();
- List<DQP_SOCDetail> updetailList = new List<DQP_SOCDetail>();
- //新增
- if (SOCView.SOCID == null || SOCView.SOCID == Guid.Empty)
- {
- SOC = SOCDAL.SOCRepository.GetSingle(x => x.SchoolyearID == SOCView.SchoolyearID && x.CoursematerialID == SOCView.CoursematerialID
- && x.DepartmentID == SOCView.DepartmentID && x.HandleModeID == SOCView.HandleModeID && x.OptionalCourseTypeID == SOCView.OptionalCourseTypeID);
- if (SOC != null)
- {
- throw new Exception("已存在相同的课程SOC设置信息");
- }
- SOC = new DQP_SOC();
- List<DQP_SOCDetail> SOCDetailList = new List<DQP_SOCDetail>();
- SOC.SOCID = Guid.NewGuid();
- SOC.SchoolyearID = SOCView.SchoolyearID;
- SOC.CoursematerialID = SOCView.CoursematerialID;
- SOC.Credit = SOCView.Credit;
- SOC.DepartmentID = SOCView.DepartmentID;
- SOC.HandleModeID = SOCView.HandleModeID;
- SOC.OptionalCourseTypeID = SOCView.OptionalCourseTypeID;
- this.SetNewStatus(SOC);
- foreach (var view in SOCDetailViewList)
- {
- if (view.Weight >= 0 && view.Weight <= 100)
- {
- DQP_SOCDetail detail = new DQP_SOCDetail();
- detail.SOCDetailID = view.SOCDetailID;
- detail.SOCID = SOC.SOCID;
- detail.Name = view.Name;
- detail.Credit = view.Credit;
- detail.Weight = view.Weight;
- detail.Description = view.Description;
- detail.IsGroup = view.IsGroup;
- detail.StartTime = view.StartTime;
- detail.EndTime = view.EndTime;
- this.SetNewStatus(detail);
- List<DQP_SOCDetailAttachment> attachmentList = new List<DQP_SOCDetailAttachment>();
- foreach (var file in fileList)
- {
- if (file.FormID == detail.SOCDetailID)
- {
- DQP_SOCDetailAttachment attachment = new DQP_SOCDetailAttachment();
- attachment.SOCDetailAttachmentID = Guid.NewGuid();
- attachment.SOCDetailID = file.FormID;
- attachment.Name = file.FileName;
- attachment.Url = file.FileUrl;
- this.SetNewStatus(attachment);
- detail.DQP_SOCDetailAttachment.Add(attachment);
- }
- }
- SOC.DQP_SOCDetail.Add(detail);
- }
- else
- {
- throw new Exception("权重只能是0-100之间的数字");
- }
- }
- UnitOfWork.Commit();
- }
- else
- {//修改
- if (socIDList.Count == 1)//单个修改
- {
- SOC = SOCDAL.SOCRepository.GetSingle(x => x.SOCID != SOCView.SOCID && x.EducationMissionID == SOCView.EducationMissionID && x.CoursematerialID == SOCView.CoursematerialID
- && x.SchoolyearID == SOCView.SchoolyearID && x.HandleModeID == SOCView.HandleModeID && x.OptionalCourseTypeID == SOCView.OptionalCourseTypeID
- && x.DepartmentID == SOCView.DepartmentID);
- if (SOC != null)
- {
- throw new Exception("已存在相同的课程SOC设置信息");
- }
- SOC = SOCDAL.SOCRepository.GetSingle(x => x.SOCID == SOCView.SOCID, (x => x.DQP_SOCDetail));
- List<DQP_SOCDetail> SOCTemplateDetailList = new List<DQP_SOCDetail>();
- List<DQP_SOCDetailAttachment> attachmentList = new List<DQP_SOCDetailAttachment>();
- SOC.Credit = SOCView.Credit;
- this.SetModifyStatus(SOC);
- var dbDetailIDList = SOC.DQP_SOCDetail.Select(x => x.SOCDetailID);
- var newDetailIDList = SOCDetailViewList.Select(x => x.SOCDetailID);
- var deleteDetailIDList = new List<Guid?>();
- foreach (var did in dbDetailIDList)
- {
- if (!newDetailIDList.Contains(did))
- {
- deleteDetailIDList.Add(did);
- }
- }
- UnitOfWork.Remove<DQP_SOCDetailAttachment>(x => dbDetailIDList.Contains(x.SOCDetailID.Value) && x.DQP_SOCDetail.SOCID == SOC.SOCID);
- UnitOfWork.Remove<DQP_SOCDetail>(x => deleteDetailIDList.Contains(x.SOCDetailID) && x.SOCID == SOC.SOCID);
- foreach (var view in SOCDetailViewList)
- {
- if (view.Weight >= 0 && view.Weight <= 100)
- {
- DQP_SOCDetail detail = new DQP_SOCDetail();
- if (SOC.DQP_SOCDetail.Any(x => x.SOCDetailID == view.SOCDetailID))
- {
- //修改原来存在的
- detail = SOC.DQP_SOCDetail.FirstOrDefault(x => x.SOCDetailID == view.SOCDetailID);
- //detail.SOCDetailID = view.SOCDetailID;
- detail.SOCID = SOC.SOCID;
- detail.Name = view.Name;
- detail.Credit = view.Credit;
- detail.Weight = view.Weight;
- detail.Description = view.Description;
- detail.IsGroup = view.IsGroupin;
- detail.StartTime = view.StartTime;
- detail.EndTime = view.EndTime;
- this.SetModifyStatus(detail);
- updetailList.Add(detail);
- }
- else
- {
- //新增
- detail.SOCDetailID = view.SOCDetailID;
- //Guid.NewGuid();
- detail.SOCID = SOC.SOCID;
- detail.Name = view.Name;
- detail.Credit = view.Credit;
- detail.Weight = view.Weight;
- detail.Description = view.Description;
- detail.IsGroup = view.IsGroupin;
- detail.StartTime = view.StartTime;
- detail.EndTime = view.EndTime;
- this.SetNewStatus(detail);
- SOC.DQP_SOCDetail.Add(detail);
- }
- var fileIDList = fileList.Select(x => x.FileID).ToList();
- //UnitOfWork.Remove<DQP_SOCDetailAttachment>(x => x.SOCDetailID == detail.SOCDetailID);
- foreach (var file in fileList)
- {
- if (file.FormID == detail.SOCDetailID)
- {
- DQP_SOCDetailAttachment attachment = new DQP_SOCDetailAttachment();
- attachment.SOCDetailAttachmentID = Guid.NewGuid();
- attachment.SOCDetailID = file.FormID;
- attachment.Name = file.FileName;
- attachment.Url = file.FileUrl;
- this.SetNewStatus(attachment);
- attachmentList.Add(attachment);
- }
- }
- }
- else
- {
- throw new Exception("权重只能是0-100之前的数字");
- }
- }
- UnitOfWork.BatchUpdate<DQP_SOCDetail>(updetailList);
- UnitOfWork.Commit();
- //UnitOfWork.BulkInsert(SOCTemplateDetailList);
- UnitOfWork.BulkInsert(attachmentList);
- }
- else if (socIDList.Count > 1)
- {
- foreach (var id in socIDList)
- {
- SOC = SOCDAL.SOCRepository.GetSingle(x => x.SOCID == id, (x => x.DQP_SOCDetail));
- List<DQP_SOCDetail> SOCTemplateDetailList = new List<DQP_SOCDetail>();
- List<DQP_SOCDetailAttachment> attachmentList = new List<DQP_SOCDetailAttachment>();
- SOC.Credit = SOCView.Credit;
- this.SetModifyStatus(SOC);
- var dbDetailIDList = SOC.DQP_SOCDetail.Select(x => x.SOCDetailID);
- UnitOfWork.Remove<DQP_SOCDetailStudentAttachment>(x => dbDetailIDList.Contains(x.DQP_SOCDetailStudent.SOCDetailID.Value));
- var socdetailGroup = SOCDAL.SOCDetailGroupRepository.GetList(x => dbDetailIDList.Contains(x.SOCDetailID.Value),x => x.CF_Student);
- foreach (var socdetail in socdetailGroup)
- {
- socdetail.CF_Student = new HashSet<CF_Student>();
- }
- UnitOfWork.Remove<DQP_SOCDetailGroup>(x => dbDetailIDList.Contains(x.SOCDetailID.Value));
- UnitOfWork.Remove<DQP_SOCDetailStudent>(x => dbDetailIDList.Contains(x.SOCDetailID.Value));
- UnitOfWork.Remove<DQP_SOCDetailStudentScore>(x => dbDetailIDList.Contains(x.SOCDetailID.Value));
- UnitOfWork.Remove<DQP_SOCDetailAttachment>(x => dbDetailIDList.Contains(x.SOCDetailID.Value));
- UnitOfWork.Remove<DQP_SOCDetail>(x => dbDetailIDList.Contains(x.SOCDetailID));
- SOC.DQP_SOCDetail = new HashSet<DQP_SOCDetail>();//删掉原来的明细再新加进去
- foreach (var view in SOCDetailViewList)
- {
- //UnitOfWork.Delete<DQP_SOCDetail>(x => x.SOCID == SOC.SOCID);
- if (view.Weight >= 0 && view.Weight <= 100)
- {
- //SOC.DQP_SOCDetail = new HashSet<DQP_SOCDetail>();
- DQP_SOCDetail detail = new DQP_SOCDetail();
- //新增
- detail.SOCDetailID = Guid.NewGuid();
- detail.SOCID = SOC.SOCID;
- detail.Name = view.Name;
- detail.Credit = view.Credit;
- detail.Weight = view.Weight;
- detail.Description = view.Description;
- detail.IsGroup = view.IsGroupin;
- detail.StartTime = view.StartTime;
- detail.EndTime = view.EndTime;
- this.SetNewStatus(detail);
- SOC.DQP_SOCDetail.Add(detail);
- var fileIDList = fileList.Select(x => x.FileID).ToList();
-
- foreach (var file in fileList)
- {
- if (file.FormID == view.SOCDetailID)
- {
- DQP_SOCDetailAttachment attachment = new DQP_SOCDetailAttachment();
- attachment.SOCDetailAttachmentID = Guid.NewGuid();
- attachment.SOCDetailID = detail.SOCDetailID;
- attachment.Name = file.FileName;
- attachment.Url = file.FileUrl;
- this.SetNewStatus(attachment);
- attachmentList.Add(attachment);
- //detail.DQP_SOCTemplateDetailAttachment.Add(attachment);
- }
- }
- //}
- //SOCTemplateDetailList.Add(detail);
- }
- else
- {
- throw new Exception("权重只能是0-100之前的数字");
- }
- }
- UnitOfWork.BatchUpdate<DQP_SOCDetail>(updetailList);
- UnitOfWork.Commit();
- //UnitOfWork.BulkInsert(SOCTemplateDetailList);
- UnitOfWork.BulkInsert(attachmentList);
- }
- }
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- public IGridResultSet<BaseStudentView> GetSOCStudent(Guid? SOCID, int pageIndex, int pageSize)
- {
- return SOCDAL.GetSOCStudentList(SOCID).OrderBy(x => x.ClassmajorCode).ThenBy(x => x.LoginID).ToGridResultSet<BaseStudentView>(pageIndex, pageSize);
- }
- public List<FileUploadView> GetFileList(Guid? formID)
- {
- //var socDetailAttachment = SOCDAL.SOCDetailAttachmentRepository.GetSingle(x => x.SOCDetailID == formID);
- var fileList = SOCDAL.GetSOCDetailAttachmentView(x => x.SOCDetailID == formID).ToList();
- return fileList;
- }
- public bool CheckDetailIsHaveMessage(List<Guid?> detailIDList)
- {
- var detail = SOCDAL.SOCDetailRepository.GetList(x => detailIDList.Contains(x.SOCDetailID), (x => x.DQP_SOCDetailGroup), (x => x.DQP_SOCDetailStudent), (x => x.DQP_SOCDetailStudentScore));
- if (detail.Any(x => x.DQP_SOCDetailGroup.Count > 0 || x.DQP_SOCDetailStudent.Count > 0 || x.DQP_SOCDetailStudentScore.Count > 0))
- {
- return true;
- }
- else {
- return false;
- }
- }
- public bool CheckSOCIsHaveMessage(List<Guid?> socIDList)
- {
- var detail = SOCDAL.SOCRepository.GetList(x => socIDList.Contains(x.SOCID), (x => x.DQP_SOCDetail));
- if (detail.Any(x => x.DQP_SOCDetail.Count > 0))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- public IGridResultSet<EducationMissionView> GetEducationMissionViewGrid(ConfiguretView configuretView, int pageIndex, int pageSize)
- {
- Expression<Func<EM_EducationMission, bool>> exp = x => true;
- var query = EducationMissionClassDAL.GetEducationMissionView(exp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- var result = query
- .OrderBy(x => x.SchoolyearCode.Length)
- .ThenByDescending(x => x.SchoolyearCode).ThenBy(x => x.ClassName)
- .ToGridResultSet<EducationMissionView>(pageIndex, pageSize);
- return result;
- }
- public IGridResultSet<CollegeView> GetTeacherCollegeViewGrid(ConfiguretView configuretView, Guid? schoolyearID, int pageIndex, int pageSize)
- {
- var userID = CustomPrincipal.Current.UserID;
- Expression<Func<DQP_SOC, bool>> exp = x => true;
- Expression<Func<CF_Staff, bool>> staffexp = x => true;
- if(schoolyearID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- }
- staffexp = staffexp.And(x => x.UserID == userID);
- var query = SOCDAL.GetCollegeViewList(exp, staffexp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- var result = query
- .OrderBy(x => x.Name)
- .ToGridResultSet<CollegeView>(pageIndex, pageSize);
- return result;
- }
- public IGridResultSet<ClassmajorView> GetTeacherClassmajorViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID, int? year, int? standardID, int pageIndex, int pageSize)
- {
- var userID = CustomPrincipal.Current.UserID;
- Expression<Func<DQP_SOC, bool>> exp = x => true;
- Expression<Func<CF_Staff, bool>> staffexp = x => true;
- Expression<Func<CF_Classmajor, bool>> classexp = x => true;
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (collegeID.HasValue)
- {
- classexp = classexp.And(x => x.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
- }
- if (year.HasValue)
- {
- classexp = classexp.And(x => x.CF_Grademajor.GradeID == year);
- }
- if (standardID.HasValue)
- {
- classexp = classexp.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
- }
- staffexp = staffexp.And(x => x.UserID == userID);
- var query = SOCDAL.GetClassmajorViewList(exp, staffexp, classexp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- var result = query
- .OrderBy(x => x.Name)
- .ToGridResultSet<ClassmajorView>(pageIndex, pageSize);
- return result;
- }
- }
- }
|