123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.DataLogic.DQPSystem;
- using EMIS.ViewModel.DQPSystem;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using EMIS.DataLogic.CultureplanManage.PlanManagement;
- namespace EMIS.CommonLogic.DQPSystem
- {
- public class SOCTemplateServices : BaseServices, ISOCTemplateServices, IFileUploadServices
- {
- public SOCTemplateDAL SOCTemplateDAL { get; set; }
- public SpecialtyCourseDAL specialtyCourseDAL { get; set; }
- public List<ViewModel.FileUploadView> GetFileList(Guid? formID)
- {
- return SOCTemplateDAL.GetFileUploadViewQueryable(x => x.SOCTemplateItemID == formID).ToList();
- }
- public void SaveFile(IList<ViewModel.FileUploadView> fileList)
- {
- throw new NotImplementedException();
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="standardID"></param>
- /// <param name="facultymajorID"></param>
- /// <param name="departmentID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="schoolyearNumID"></param>
- /// <param name="schoolcodeID"></param>
- /// <param name="recordStatus"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<SOCTemplateView> GetSOCTemplateViewGrid(ConfiguretView configuretView, int? standardID, Guid? facultymajorID, Guid? departmentID, int? educationID,
- int? learningformID, string learnSystem, Guid? coursematerialID, int? schoolyearNumID, int? schoolcodeID, int? recordStatus, int pageIndex, int pageSize)
- {
- Expression<Func<DQP_SOCTemplate, bool>> exp = x => true;
- Expression<Func<CF_Facultymajor, bool>> facexp = x => true;
- if (standardID.HasValue)
- {
- facexp = facexp.And(x => x.StandardID == standardID);
- }
- if (facultymajorID.HasValue)
- {
- exp = exp.And(x => x.FacultymajorID == facultymajorID);
- }
- if (educationID.HasValue)
- {
- facexp = facexp.And(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- facexp = facexp.And(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- //学制
- var LearnSystems = Convert.ToDecimal(learnSystem);
- facexp = facexp.And(x => x.LearnSystem == LearnSystems);
- }
- if (coursematerialID.HasValue)
- {
- exp = exp.And(x => x.CoursematerialID == coursematerialID);
- }
- if (schoolyearNumID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearNumID == schoolyearNumID);
- }
- if (schoolcodeID.HasValue)
- {
- exp = exp.And(x => x.SchoolcodeID == schoolcodeID);
- }
- if (recordStatus.HasValue)
- {
- exp = exp.And(x => x.RecordStatus == recordStatus);
- }
- if (departmentID.HasValue)
- {
- exp = exp.And(x => x.DepartmentID == departmentID);
- }
- var query = SOCTemplateDAL.GetSOCTemplateViewQueryable(exp, facexp);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- var result = this.GetQueryByDataRangeByDepartment(query)
- .OrderBy(x => x.StandardID)
- .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode)
- .ThenBy(x => x.SchoolyearNumID).ThenBy(x => x.SchoolcodeID)
- .ToGridResultSet<SOCTemplateView>(pageIndex, pageSize);
- return result;
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="standardID"></param>
- /// <param name="facultymajorID"></param>
- /// <param name="departmentID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="schoolyearNumID"></param>
- /// <param name="schoolcodeID"></param>
- /// <param name="recordStatus"></param>
- /// <param name="idList"></param>
- /// <returns></returns>
- public List<SOCTemplateView> GetSOCTemplateViewList(ConfiguretView configuretView, int? standardID, Guid? facultymajorID, Guid? departmentID, int? educationID,
- int? learningformID, string learnSystem, Guid? coursematerialID, int? schoolyearNumID, int? schoolcodeID, int? recordStatus, List<Guid?> idList)
- {
- Expression<Func<DQP_SOCTemplate, bool>> exp = x => true;
- Expression<Func<CF_Facultymajor, bool>> facexp = x => true;
- if (standardID.HasValue)
- {
- facexp = facexp.And(x => x.StandardID == standardID);
- }
- if (facultymajorID.HasValue)
- {
- exp = exp.And(x => x.FacultymajorID == facultymajorID);
- }
- if (educationID.HasValue)
- {
- facexp = facexp.And(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- facexp = facexp.And(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- //学制
- var LearnSystems = Convert.ToDecimal(learnSystem);
- facexp = facexp.And(x => x.LearnSystem == LearnSystems);
- }
- if (coursematerialID.HasValue)
- {
- exp = exp.And(x => x.CoursematerialID == coursematerialID);
- }
- if (schoolyearNumID.HasValue)
- {
- exp = exp.And(x => x.SchoolyearNumID == schoolyearNumID);
- }
- if (schoolcodeID.HasValue)
- {
- exp = exp.And(x => x.SchoolcodeID == schoolcodeID);
- }
- if (recordStatus.HasValue)
- {
- exp = exp.And(x => x.RecordStatus == recordStatus);
- }
- if (idList.Count > 0)
- {
- exp = exp.And(x => idList.Contains(x.SOCTemplateID));
- }
- var query = SOCTemplateDAL.GetSOCTemplateViewQueryable(exp, facexp);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- var result = this.GetQueryByDataRangeByDepartment(query)
- .OrderBy(x => x.StandardID)
- .ThenBy(x => x.SchoolyearNumID).ThenBy(x => x.SchoolcodeID)
- .ToList();
- return result;
- }
- public SOCTemplateView GetSOCTemplateViewByID(Guid? SOCTemplateID)
- {
- Expression<Func<DQP_SOCTemplate, bool>> exp = x => true;
- exp = exp.And(x => x.SOCTemplateID == SOCTemplateID);
- var query = SOCTemplateDAL.GetSOCTemplateViewQueryable(exp, x => true).FirstOrDefault();
- return query;
- }
- public void GenerateTemplate(Guid? collegeID, int? standardID, Guid? facultymajorID, Guid? coursematerialID)
- {
- try
- {
- Expression<Func<EM_SpecialtyCourse, bool>> exp = x => true;
- exp = exp.And(x => x.RecordStatus == (int)SYS_STATUS.USABLE);
- Expression<Func<CF_Facultymajor, bool>> facexp = x => true;
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.CF_Department.CollegeID == collegeID);
- }
- if (standardID.HasValue)
- {
- exp = exp.And(x => x.CF_Specialty.StandardID == standardID);
- }
- if (facultymajorID.HasValue)
- {
- facexp = facexp.And(x => x.FacultymajorID == facultymajorID);
- }
- if (coursematerialID.HasValue)
- {
- exp = exp.And(x => x.CoursematerialID == coursematerialID);
- }
- var query = SOCTemplateDAL.GetSpecialtyCourseViewQueryable(exp, facexp).ToList();
- Expression<Func<DQP_SOCTemplate, bool>> dbexp = x => true;
- Expression<Func<CF_Facultymajor, bool>> dbfacexp = x => true;
- var dbTemplate = SOCTemplateDAL.GetSOCTemplateViewQueryable(dbexp, dbfacexp).ToList();
- List<DQP_SOCTemplate> templList = new List<DQP_SOCTemplate>();
- foreach (var sc in query)
- {
- if (dbTemplate.Any(x => x.CoursematerialID == sc.CoursematerialID && x.FacultymajorID == sc.FacultymajorID && x.DepartmentID == sc.DepartmentID
- && x.SchoolyearNumID == sc.SchoolyearNumID && x.SchoolcodeID == sc.SchoolcodeID))
- {
- continue;
- }
- DQP_SOCTemplate templ = new DQP_SOCTemplate();
- templ.SOCTemplateID = Guid.NewGuid();
- templ.FacultymajorID = sc.FacultymajorID;
- templ.CoursematerialID = sc.CoursematerialID;
- templ.Credit = sc.Credit;
- templ.SchoolyearNumID = sc.SchoolyearNumID;
- templ.SchoolcodeID = sc.SchoolcodeID;
- templ.DepartmentID = sc.DepartmentID;
- templ.HandleModeID = (int)CF_HandleMode.RequiredCourse;
- this.SetNewStatus(templ);
- templ.RecordStatus = (int)SYS_STATUS.UNUSABLE;
- List<DQP_SOCTemplateDetail> detailList = new List<DQP_SOCTemplateDetail>();
- DQP_SOCTemplateDetail detail = new DQP_SOCTemplateDetail();
- detail.SOCTemplateItemID = Guid.NewGuid();
- detail.SOCTemplateID = templ.SOCTemplateID;
- detail.Name = "SOC0";
- detail.IsGroup = false;
- this.SetNewStatus(detail);
- detailList.Add(detail);
- templ.DQP_SOCTemplateDetail = new HashSet<DQP_SOCTemplateDetail>(detailList);
- templList.Add(templ);
- }
- UnitOfWork.BulkInsert(templList);
- UnitOfWork.BulkInsert(templList.SelectMany(x => x.DQP_SOCTemplateDetail).ToList());
- }
- catch (Exception)
- {
-
- throw;
- }
- }
- public IGridResultSet<SOCTemplateDetailView> GetSOCTemplateDetailViewGrid(Guid? SOCTemplateID, int pageIndex, int pageSize)
- {
- Expression<Func<DQP_SOCTemplateDetail, bool>> exp = x => true;
- //if (SOCTemplateID.HasValue)
- //{
- exp = exp.And(x => x.SOCTemplateID == SOCTemplateID);
- //}
- var query = SOCTemplateDAL.GetSOCTemplateDetailViewByIDQueryable(exp);
- return query.OrderBy(x => x.Name.Length).ThenBy(x => x.Name).ToGridResultSet<SOCTemplateDetailView>(pageIndex, pageSize);
- }
- public void SOCTemplateDelete(List<Guid?> idList)
- {
- try
- {
- if (idList.Count > 0)
- {
- UnitOfWork.Delete<DQP_SOCTemplateDetailAttachment>(x => idList.Contains(x.DQP_SOCTemplateDetail.SOCTemplateID));
- UnitOfWork.Delete<DQP_SOCTemplateDetail>(x => idList.Contains(x.SOCTemplateID));
- UnitOfWork.Delete<DQP_SOCTemplate>(x => idList.Contains(x.SOCTemplateID));
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- public void SOCTemplateEdit(SOCTemplateView SOCTemplateView, List<SOCTemplateDetailView> SOCTemplateDetailViewList, List<FileUploadView> fileList)
- {
- try
- {
- DQP_SOCTemplate SOCTemplate = new DQP_SOCTemplate();
- List<DQP_SOCTemplateDetailAttachment> attachmentList = new List<DQP_SOCTemplateDetailAttachment>();
- List<DQP_SOCTemplateDetail> SOCTemplateDetailList = new List<DQP_SOCTemplateDetail>();
- var totalWeight = SOCTemplateDetailViewList.Sum(x => x.Weight);
- var totalCredit = SOCTemplateDetailViewList.Sum(x => x.Credit);
- SOCTemplateView.HandleModeID = SOCTemplateView.HandleModeID == -1 ? null : SOCTemplateView.HandleModeID;
- SOCTemplateView.SchoolyearNumID = SOCTemplateView.SchoolyearNumID == -1 ? null : SOCTemplateView.SchoolyearNumID;
- SOCTemplateView.SchoolcodeID = SOCTemplateView.SchoolcodeID == -1 ? null : SOCTemplateView.SchoolcodeID;
- if (totalWeight != 100)
- {
- throw new Exception("SOC的权重之和必须是100");
- }
- if (SOCTemplateView.Credit != totalCredit)
- {
- throw new Exception("SOC的学分之和必须等于课程学分");
- }
- //新增
- if (SOCTemplateView.SOCTemplateID == null || SOCTemplateView.SOCTemplateID == Guid.Empty)
- {
- SOCTemplate = SOCTemplateDAL.SOCTemplateRepository.GetSingle(x => x.FacultymajorID == SOCTemplateView.FacultymajorID && x.CoursematerialID == SOCTemplateView.CoursematerialID
- && x.SchoolyearNumID == SOCTemplateView.SchoolyearNumID && x.SchoolcodeID == SOCTemplateView.SchoolcodeID && x.DepartmentID == SOCTemplateView.DepartmentID);
- if (SOCTemplate != null)
- {
- throw new Exception("已存在相同的课程SOC设置信息");
- }
- SOCTemplate = new DQP_SOCTemplate();
- SOCTemplate.SOCTemplateID = Guid.NewGuid();
- SOCTemplate.FacultymajorID = SOCTemplateView.FacultymajorID;
- SOCTemplate.CoursematerialID = SOCTemplateView.CoursematerialID;
- SOCTemplate.Credit = SOCTemplateView.Credit;
- SOCTemplate.HandleModeID = SOCTemplateView.HandleModeID;
- SOCTemplate.SchoolyearNumID = SOCTemplateView.SchoolyearNumID;
- SOCTemplate.SchoolcodeID = SOCTemplateView.SchoolcodeID;
- SOCTemplate.DepartmentID = SOCTemplateView.DepartmentID;
- this.SetNewStatus(SOCTemplate);
- SOCTemplate.RecordStatus = SOCTemplateView.IsEnable ? 1 : 0;
- foreach (var view in SOCTemplateDetailViewList)
- {
- var itemID = view.SOCTemplateItemID;
- DQP_SOCTemplateDetail detail = new DQP_SOCTemplateDetail();
- detail.SOCTemplateItemID = Guid.NewGuid();
- detail.SOCTemplateID = SOCTemplate.SOCTemplateID;
- detail.Name = view.Name;
- detail.Credit = view.Credit;
- detail.Weight = view.Weight;
- detail.Description = view.Description;
- detail.IsGroup = view.IsGroup == null ? false : view.IsGroup;
- this.SetNewStatus(detail);
- foreach (var file in fileList)
- {
- if (file.FormID == itemID)
- {
- DQP_SOCTemplateDetailAttachment attachment = new DQP_SOCTemplateDetailAttachment();
- attachment.SOCTemplateDetailAttachmentID = Guid.NewGuid();
- attachment.SOCTemplateItemID = detail.SOCTemplateItemID;
- attachment.Name = file.FileName;
- attachment.Url = file.FileUrl;
- this.SetNewStatus(attachment);
- detail.DQP_SOCTemplateDetailAttachment.Add(attachment);
- }
- }
- SOCTemplate.DQP_SOCTemplateDetail.Add(detail);
- }
- UnitOfWork.Add(SOCTemplate);
- UnitOfWork.Commit();
- }
- else
- {//修改
- SOCTemplate = SOCTemplateDAL.SOCTemplateRepository.GetSingle(x => x.SOCTemplateID != SOCTemplateView.SOCTemplateID && x.FacultymajorID == SOCTemplateView.FacultymajorID && x.CoursematerialID == SOCTemplateView.CoursematerialID
- && x.SchoolyearNumID == SOCTemplateView.SchoolyearNumID && x.SchoolcodeID == SOCTemplateView.SchoolcodeID && x.DepartmentID == SOCTemplateView.DepartmentID);
- if (SOCTemplate != null)
- {
- throw new Exception("已存在相同的课程SOC设置信息");
- }
- SOCTemplate = SOCTemplateDAL.SOCTemplateRepository.GetSingle(x => x.SOCTemplateID == SOCTemplateView.SOCTemplateID, x => x.DQP_SOCTemplateDetail);
-
-
- SOCTemplate.SOCTemplateID = SOCTemplateView.SOCTemplateID;
- SOCTemplate.FacultymajorID = SOCTemplateView.FacultymajorID;
- SOCTemplate.CoursematerialID = SOCTemplateView.CoursematerialID;
- SOCTemplate.RecordStatus = SOCTemplateView.IsEnable ? 1 : 0 ;
- SOCTemplate.Credit = SOCTemplateView.Credit;
- SOCTemplate.HandleModeID = SOCTemplateView.HandleModeID;
- SOCTemplate.SchoolyearNumID = SOCTemplateView.SchoolyearNumID;
- SOCTemplate.SchoolcodeID = SOCTemplateView.SchoolcodeID;
- SOCTemplate.DepartmentID = SOCTemplateView.DepartmentID;
- SOCTemplate.ModifyUserID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID;
- SOCTemplate.ModifyTime = DateTime.Now;
- //SOCTemplate.DQP_SOCTemplateDetail = new HashSet<DQP_SOCTemplateDetail>();
- //UnitOfWork.Remove<DQP_SOCTemplateDetail>(x => x.SOCTemplateID == SOCTemplate.SOCTemplateID);
- foreach (var view in SOCTemplateDetailViewList)
- {
- var itemID = view.SOCTemplateItemID;
- DQP_SOCTemplateDetail detail = new DQP_SOCTemplateDetail();
- if (SOCTemplate.DQP_SOCTemplateDetail.Any(x => x.SOCTemplateItemID == view.SOCTemplateItemID))
- {
- detail = SOCTemplateDAL.SOCTemplateDetailRepository.GetSingle(x => x.SOCTemplateItemID == view.SOCTemplateItemID);
- detail.SOCTemplateItemID = view.SOCTemplateItemID;
- detail.SOCTemplateID = SOCTemplate.SOCTemplateID;
- detail.Name = view.Name;
- detail.Credit = view.Credit;
- detail.Weight = view.Weight;
- detail.Description = view.Description;
- detail.IsGroup = view.IsGroup == null ? false : view.IsGroup;
- this.SetModifyStatus(detail);
- //UnitOfWork.Update<DQP_SOCTemplateDetail>(detail);
- SOCTemplateDetailList.Add(detail);
- }
- else
- {
- detail.SOCTemplateItemID = Guid.NewGuid();
- detail.SOCTemplateID = SOCTemplate.SOCTemplateID;
- detail.DQP_SOCTemplate = SOCTemplate;
- detail.Name = view.Name;
- detail.Credit = view.Credit;
- detail.Weight = view.Weight;
- detail.Description = view.Description;
- detail.IsGroup = view.IsGroup == null ? false : view.IsGroup;
- this.SetNewStatus(detail);
- SOCTemplate.DQP_SOCTemplateDetail.Add(detail);
- }
- //detail.DQP_SOCTemplateDetailAttachment = new HashSet<DQP_SOCTemplateDetailAttachment>();
- if (view.IsChangeAttachment == 1)
- {
- UnitOfWork.Remove<DQP_SOCTemplateDetailAttachment>(x => x.SOCTemplateItemID == detail.SOCTemplateItemID);
- foreach (var file in fileList)
- {
- if (file.FormID == itemID)
- {
- DQP_SOCTemplateDetailAttachment attachment = new DQP_SOCTemplateDetailAttachment();
- attachment.SOCTemplateDetailAttachmentID = Guid.NewGuid();
- attachment.SOCTemplateItemID = detail.SOCTemplateItemID;
- attachment.Name = file.FileName;
- attachment.Url = file.FileUrl;
- this.SetNewStatus(attachment);
- attachmentList.Add(attachment);
- //detail.DQP_SOCTemplateDetailAttachment.Add(attachment);
- }
- }
- }
- //SOCTemplateDetailList.Add(detail);
- //SOCTemplate.DQP_SOCTemplateDetail.Add(detail);
- }
- UnitOfWork.BatchUpdate<DQP_SOCTemplateDetail>(SOCTemplateDetailList);
- UnitOfWork.Commit();
- //UnitOfWork.BulkInsert(SOCTemplateDetailList);
- UnitOfWork.BulkInsert(attachmentList);
- }
-
- }
- catch (Exception)
- {
-
- throw;
- }
- }
- public void AttachmentUpload(List<FileUploadView> fileList)
- {
- List<DQP_SOCTemplateDetailAttachment> attachmentList = new List<DQP_SOCTemplateDetailAttachment>();
- foreach (var file in fileList)
- {
- //var detail = SOCTemplateDAL.SOCTemplateDetailRepository.GetSingle(x => x.SOCTemplateItemID == file.FormID, (x => x.DQP_SOCTemplateDetailAttachment));
- DQP_SOCTemplateDetailAttachment attachment = new DQP_SOCTemplateDetailAttachment();
- attachment.SOCTemplateDetailAttachmentID = Guid.NewGuid();
- attachment.Name = file.FileName;
- attachment.Url = file.FileUrl;
- attachment.SOCTemplateItemID = file.FormID;
- this.SetNewStatus(file);
- attachmentList.Add(attachment);
- }
- }
- }
- }
|