123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- 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.SystemServices;
- namespace EMIS.CommonLogic.DQPSystem
- {
- public class SOCDetailServices : BaseServices, ISOCDetailServices, IFileUploadServices
- {
- public SOCDetailDAL SOCDetailDAL { get; set; }
- public SOCDAL SOCDAL { get; set; }
- public IRoleServices RoleServices { get; set; }
- public IGridResultSet<SOCDetailView> GetSOCDetailViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? coursematerialID, Guid? collegeID, Guid? staffID, int pageIndex, int pageSize)
- {
- Expression<Func<DQP_SOCDetail, bool>> exp = x => true;
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.DQP_SOC.SchoolyearID == schoolyearID);
- }
- if (coursematerialID.HasValue)
- {
- exp = exp.And(x => x.DQP_SOC.CoursematerialID == coursematerialID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.DQP_SOC.CF_Department.CollegeID == collegeID);
- }
- if (staffID.HasValue)
- {
- exp = exp.And(x => x.DQP_SOC.DQP_SOCStaff.Any(y => y.UserID == staffID));
- }
-
- var role = RoleServices.GetEnabledTeacherRoleViewList();
- var teacherRole = role.Where(x => x.RoleName == "教师");
- var query = SOCDetailDAL.GetSOCDetailViewQueryable(exp);
- if (curUser.RoleID == teacherRole.FirstOrDefault().RoleID)
- {
- exp = exp.And(x => x.CreateUserID == curUser.UserID);
- exp = exp.And(x => x.DQP_SOC.DQP_SOCStaff.Any(y => y.UserID == curUser.UserID));
- query = SOCDetailDAL.GetSOCDetailViewQueryable(exp);
- }
- else
- {
- query = this.GetQueryByDataRangeByDepartment(query);
- }
-
-
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- //query = this.GetQueryByDataRangeByDepartment(query);
- var result = query
- .OrderBy(x => x.SchoolyearCode.Length)
- .ThenByDescending(x => x.SchoolyearCode).ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ThenBy(x => x.Name.Length).ThenBy(x => x.Name)
- .ToGridResultSet<SOCDetailView>(pageIndex, pageSize);
- return result;
- }
- public IGridResultSet<SOCDetailView> GetSOCDetailViewByIDGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? socID, Guid? userID, int pageIndex, int pageSize)
- {
- Expression<Func<DQP_SOCDetail, bool>> exp = x => true;
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.DQP_SOC.SchoolyearID == schoolyearID);
- }
- if (socID.HasValue)
- {
- exp = exp.And(x => x.SOCID == socID);
- }
- if (userID.HasValue)
- {
- exp = exp.And(x => x.DQP_SOC.DQP_SOCStaff.Any(y => y.UserID == userID));
- exp = exp.And(x => x.CreateUserID == userID);
- }
- var query = SOCDetailDAL.GetSOCDetailViewQueryable(exp);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- //query = this.GetQueryByDataRangeByDepartment(query);
- var result = query
- .OrderBy(x => x.SchoolyearCode.Length)
- .ThenByDescending(x => x.SchoolyearCode).ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ThenBy(x => x.Name.Length).ThenBy(x => x.Name)
- .ToGridResultSet<SOCDetailView>(pageIndex, pageSize);
- return result;
- }
- public List<SOCDetailView> GetSOCDetailViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? coursematerialID, Guid? collegeID, Guid? staffID, List<Guid?> idList)
- {
- Expression<Func<DQP_SOCDetail, bool>> exp = x => true;
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.DQP_SOC.SchoolyearID == schoolyearID);
- }
- if (coursematerialID.HasValue)
- {
- exp = exp.And(x => x.DQP_SOC.CoursematerialID == coursematerialID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.DQP_SOC.CF_Department.CollegeID == collegeID);
- }
- if (staffID.HasValue)
- {
- exp = exp.And(x => x.DQP_SOC.DQP_SOCStaff.Any(y => y.UserID == staffID));
- }
- if (idList.Count > 0)
- {
- exp = exp.And(x => idList.Contains(x.SOCDetailID));
- }
- var role = RoleServices.GetEnabledTeacherRoleViewList();
- var teacherRole = role.Where(x => x.RoleName == "教师");
- var query = SOCDetailDAL.GetSOCDetailViewQueryable(exp);
- if (curUser.RoleID == teacherRole.FirstOrDefault().RoleID)
- {
- exp = exp.And(x => x.CreateUserID == curUser.UserID);
- exp = exp.And(x => x.DQP_SOC.DQP_SOCStaff.Any(y => y.UserID == curUser.UserID));
- query = SOCDetailDAL.GetSOCDetailViewQueryable(exp);
- }
- else
- {
- query = this.GetQueryByDataRangeByDepartment(query);
- }
-
- //var query = SOCDetailDAL.GetSOCDetailViewQueryable(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.CourseCode.Length).ThenBy(x => x.CourseCode)
- .ToList();
- return result;
- }
- public SOCDetailView GetSOCDetailView(Guid? SOCDetailID)
- {
- Expression<Func<DQP_SOCDetail, bool>> exp = x => true;
- if (SOCDetailID.HasValue)
- {
- exp = exp.And(x => x.SOCDetailID == SOCDetailID);
- }
- var query = SOCDetailDAL.GetSOCDetailViewQueryable(exp).FirstOrDefault();
- return query;
- }
- public void SOCDetailEdit(SOCDetailView SOCDetailView, List<FileUploadView> fileList)
- {
- try
- {
- var detail = SOCDetailDAL.SOCDetailRepository.GetSingle(x => x.SOCDetailID == SOCDetailView.SOCDetailID, x => x.DQP_SOCDetailAttachment);
- if (detail != null)
- {
- detail.Name = SOCDetailView.Name;
- //detail.Credit = SOCDetailView.Credit;
- detail.Description = SOCDetailView.Description;
- detail.IsGroup = SOCDetailView.IsGroupin;
- detail.StartTime = SOCDetailView.StartTime;
- detail.EndTime = SOCDetailView.EndTime;
- this.SetModifyStatus(detail);
- if (SOCDetailView.IsChangeAttachment == 1)
- {
- UnitOfWork.Remove<DQP_SOCDetailAttachment>(x => x.SOCDetailID == SOCDetailView.SOCDetailID);
- foreach (var file in fileList)
- {
- DQP_SOCDetailAttachment attachment = new DQP_SOCDetailAttachment();
- if (!detail.DQP_SOCDetailAttachment.Any(x => x.SOCDetailAttachmentID == file.FileID))
- {
- //新增
- attachment.SOCDetailAttachmentID = file.FileID;
- attachment.SOCDetailID = file.FormID;
- attachment.Name = file.FileName;
- attachment.Url = file.FileUrl;
- this.SetNewStatus(attachment);
- detail.DQP_SOCDetailAttachment.Add(attachment);
- }
- }
- }
-
- }
- UnitOfWork.Commit();
- }
- catch (Exception)
- {
-
- throw;
- }
- }
- public void SOCDetailAttachmentSave(Guid? SOCDetailID, List<FileUploadView> fileList)
- {
- var detail = SOCDetailDAL.SOCDetailRepository.GetSingle(x => x.SOCDetailID == SOCDetailID, x => x.DQP_SOCDetailAttachment);
-
- if (detail != null)
- {
- UnitOfWork.Delete<DQP_SOCDetailAttachment>(x => x.SOCDetailID == SOCDetailID);
- foreach (var file in fileList)
- {
- 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);
- }
- }
- UnitOfWork.Commit();
- }
- public void SOCDetailDelete(List<Guid?> idList)
- {
- UnitOfWork.Delete<DQP_SOCDetail>(w => idList.Contains(w.SOCDetailID));
- }
- 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 IGridResultSet<FileUploadView> GetSOCDetailAttachmentViewList(ConfiguretView studentAttachmentConditionView, Guid? socDetailID, int? pageIndex, int? pageSize)
- {
- if (!socDetailID.HasValue)
- {
- return new GridResultSet<FileUploadView>();
- }
- Expression<Func<DQP_SOCDetail, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
- && x.SOCDetailID == socDetailID);
- var query = SOCDetailDAL.GetSOCDetailAttachmentView(exp);
- return query.ToGridResultSet(pageIndex, pageSize);
- }
- }
- }
|