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 GetSOCViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? coursematerialID, Guid? collegeID, int pageIndex, int pageSize) { Expression> 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(pageIndex, pageSize); return result; } public IGridResultSet GetSOCViewByTeacherIDGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? userID, int pageIndex, int pageSize) { Expression> 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(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 GetSOCDetailViewGridByID(Guid? SOCID) { Expression> 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(); } 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 socList = new List(); List detailList = new List(); //List staffList = new List(); List addStaffList = new List(); List attachmentList = new List(); 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 staffList = new List(); 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(); 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> 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 socList = new List(); //List detailList = new List(); //List staffList = new List(); //List addStaffList = new List(); ////List staffListIn = new List(); //List attachmentList = new List(); //var queryList = query.GroupBy(x => x.SOCTemplateID).ToList(); //var SOCGenerateList = new List(); //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 dictionary = new Dictionary(); // 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(); // 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> 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 SOCDetailViewList, List fileList, List socIDList) { try { DQP_SOC SOC = new DQP_SOC(); var dbAttachmentList = SOCDAL.SOCDetailAttachmentRepository.GetList(x => x.DQP_SOCDetail.DQP_SOC.SOCID == SOCView.SOCID).ToList(); List updetailList = new List(); //新增 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 SOCDetailList = new List(); 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 attachmentList = new List(); 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 SOCTemplateDetailList = new List(); List attachmentList = new List(); 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(); foreach (var did in dbDetailIDList) { if (!newDetailIDList.Contains(did)) { deleteDetailIDList.Add(did); } } UnitOfWork.Remove(x => dbDetailIDList.Contains(x.SOCDetailID.Value) && x.DQP_SOCDetail.SOCID == SOC.SOCID); UnitOfWork.Remove(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(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(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 SOCTemplateDetailList = new List(); List attachmentList = new List(); SOC.Credit = SOCView.Credit; this.SetModifyStatus(SOC); var dbDetailIDList = SOC.DQP_SOCDetail.Select(x => x.SOCDetailID); UnitOfWork.Remove(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(); } UnitOfWork.Remove(x => dbDetailIDList.Contains(x.SOCDetailID.Value)); UnitOfWork.Remove(x => dbDetailIDList.Contains(x.SOCDetailID.Value)); UnitOfWork.Remove(x => dbDetailIDList.Contains(x.SOCDetailID.Value)); UnitOfWork.Remove(x => dbDetailIDList.Contains(x.SOCDetailID.Value)); UnitOfWork.Remove(x => dbDetailIDList.Contains(x.SOCDetailID)); SOC.DQP_SOCDetail = new HashSet();//删掉原来的明细再新加进去 foreach (var view in SOCDetailViewList) { //UnitOfWork.Delete(x => x.SOCID == SOC.SOCID); if (view.Weight >= 0 && view.Weight <= 100) { //SOC.DQP_SOCDetail = new HashSet(); 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(updetailList); UnitOfWork.Commit(); //UnitOfWork.BulkInsert(SOCTemplateDetailList); UnitOfWork.BulkInsert(attachmentList); } } } } catch (Exception) { throw; } } public IGridResultSet GetSOCStudent(Guid? SOCID, int pageIndex, int pageSize) { return SOCDAL.GetSOCStudentList(SOCID).OrderBy(x => x.ClassmajorCode).ThenBy(x => x.LoginID).ToGridResultSet(pageIndex, pageSize); } public List 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 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 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 GetEducationMissionViewGrid(ConfiguretView configuretView, int pageIndex, int pageSize) { Expression> 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(pageIndex, pageSize); return result; } public IGridResultSet GetTeacherCollegeViewGrid(ConfiguretView configuretView, Guid? schoolyearID, int pageIndex, int pageSize) { var userID = CustomPrincipal.Current.UserID; Expression> exp = x => true; Expression> 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(pageIndex, pageSize); return result; } public IGridResultSet GetTeacherClassmajorViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID, int? year, int? standardID, int pageIndex, int pageSize) { var userID = CustomPrincipal.Current.UserID; Expression> exp = x => true; Expression> staffexp = x => true; Expression> 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(pageIndex, pageSize); return result; } } }