123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.DQPSystem;
- using EMIS.ViewModel;
- using EMIS.DataLogic.DQPSystem;
- using EMIS.Entities;
- using EMIS.DataLogic.Repositories;
- using System.Web;
- namespace EMIS.CommonLogic.DQPSystem
- {
- public class SOCDocServices : BaseServices, ISOCDocServices
- {
- public RoleRepository RoleRepository { get; set; }
- public CollegeRepository CollegeRepository { get; set; }
- public DepartmentRepository DepartmentRepository { get; set; }
- public SOCDocDAL SOCDocDAL { get; set; }
- public IGridResultSet<SOCDocView> GetSOCDocViewList(ConfiguretView socDocConditionView, int? socDocTypeID, Guid? createCollegeID,
- Guid? targetRoleID, Guid? targetCollegeID, int? pageIndex, int? pageSize)
- {
- Expression<Func<DQP_Document, bool>> exp = (x => true);
- Expression<Func<CF_Staff, bool>> staffExp = (x => true);
- if (socDocTypeID.HasValue)
- {
- exp = exp.And(x => x.SOCDocTypeID == socDocTypeID);
- }
- if (createCollegeID.HasValue)
- {
- staffExp = staffExp.And(x => x.CollegeID == createCollegeID);
- }
- if (targetRoleID.HasValue)
- {
- exp = exp.And(x => x.Sys_Role.Any(w => w.RoleID == targetRoleID));
- }
- if (targetCollegeID.HasValue)
- {
- exp = exp.And(x => x.CF_Department.Any(w => w.CollegeID == targetCollegeID));
- }
- var query = SOCDocDAL.GetSOCDocViewQueryable(exp, staffExp);
- if (!string.IsNullOrEmpty(socDocConditionView.ConditionValue) && !string.IsNullOrEmpty(socDocConditionView.Attribute))
- query = query.DynamicWhere(socDocConditionView.Attribute, socDocConditionView.Condition, socDocConditionView.ConditionValue);
- query = this.GetQueryByDataRangeByCollege(query, (x => x.CreateCollegeID));
- query = query.OrderBy(x => x.SOCDocTypeID).ThenByDescending(x => x.CreateTime);
- return query.ToGridResultSet(pageIndex, pageSize);
- }
- public List<SOCDocView> GetSOCDocViewList(ConfiguretView socDocConditionView, int? socDocTypeID, Guid? createCollegeID, Guid? targetRoleID, Guid? targetCollegeID)
- {
- Expression<Func<DQP_Document, bool>> exp = (x => true);
- Expression<Func<CF_Staff, bool>> staffExp = (x => true);
- if (socDocTypeID.HasValue)
- {
- exp = exp.And(x => x.SOCDocTypeID == socDocTypeID);
- }
- if (createCollegeID.HasValue)
- {
- staffExp = staffExp.And(x => x.CollegeID == createCollegeID);
- }
- if (targetRoleID.HasValue)
- {
- exp = exp.And(x => x.Sys_Role.Any(w => w.RoleID == targetRoleID));
- }
- if (targetCollegeID.HasValue)
- {
- exp = exp.And(x => x.CF_Department.Any(w => w.CollegeID == targetCollegeID));
- }
- var query = SOCDocDAL.GetSOCDocViewQueryable(exp, staffExp);
- if (!string.IsNullOrEmpty(socDocConditionView.ConditionValue) && !string.IsNullOrEmpty(socDocConditionView.Attribute))
- query = query.DynamicWhere(socDocConditionView.Attribute, socDocConditionView.Condition, socDocConditionView.ConditionValue);
- query = this.GetQueryByDataRangeByCollege(query, (x => x.CreateCollegeID));
- query = query.OrderBy(x => x.SOCDocTypeID).ThenByDescending(x => x.CreateTime);
- return query.ToList();
- }
- public IGridResultSet<SOCDocView> GetUserSOCDocViewList(ConfiguretView socDocConditionView, Guid roleID, int? socDocTypeID,
- Guid? createCollegeID, Guid? targetRoleID, Guid? targetCollegeID, int? pageIndex, int? pageSize)
- {
- Expression<Func<DQP_Document, bool>> exp = (x => x.RecordStatus == (int)CF_GeneralPurpose.IsYes);
- Expression<Func<CF_Staff, bool>> staffExp = (x => true);
- var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
- var DepartmentID=SOCDocDAL.StaffRepository.GetList(x=>x.UserID==curUser.UserID).Select(x=>x.DepartmentID).FirstOrDefault();
- exp=exp.And(x=>(x.CF_Department.Count()==0||x.CF_Department.Any(w=>w.DepartmentID==DepartmentID)));
- exp = exp.And(x => (x.CF_College.Count() == 0 || x.CF_College.AsQueryable().Any(this.GetDataRageExpressionByCollege<CF_College>(w => w.CollegeID))));
- exp = exp.And(x => (x.Sys_Role.Count() == 0 || x.Sys_Role.Any(w => w.RoleID == roleID)));
- if (socDocTypeID.HasValue)
- {
- exp = exp.And(x => x.SOCDocTypeID == socDocTypeID);
- }
- if (createCollegeID.HasValue)
- {
- staffExp = staffExp.And(x => x.CollegeID == createCollegeID);
- }
- if (targetRoleID.HasValue)
- {
- exp = exp.And(x => x.Sys_Role.Any(w => w.RoleID == targetRoleID));
- }
- if (targetCollegeID.HasValue)
- {
- exp = exp.And(x => x.CF_Department.Any(w => w.CollegeID == targetCollegeID));
- }
- var query = SOCDocDAL.GetSOCDocViewQueryable(exp, staffExp);
- if (!string.IsNullOrEmpty(socDocConditionView.ConditionValue) && !string.IsNullOrEmpty(socDocConditionView.Attribute))
- query = query.DynamicWhere(socDocConditionView.Attribute, socDocConditionView.Condition, socDocConditionView.ConditionValue);
- query = query.OrderBy(x => x.SOCDocTypeID).ThenByDescending(x => x.CreateTime);
- return query.ToGridResultSet(pageIndex, pageSize);
- }
- public List<SOCDocView> GetUserSOCDocViewList(ConfiguretView socDocConditionView, Guid roleID, int? socDocTypeID,
- Guid? createCollegeID, Guid? targetRoleID, Guid? targetCollegeID)
- {
- Expression<Func<DQP_Document, bool>> exp = (x => x.RecordStatus == (int)CF_GeneralPurpose.IsYes);
- Expression<Func<CF_Staff, bool>> staffExp = (x => true);
- exp = exp.And(x => (x.CF_College.Count() == 0 || x.CF_College.AsQueryable().Any(this.GetDataRageExpressionByCollege<CF_College>(w => w.CollegeID))));
- exp = exp.And(x => (x.Sys_Role.Count() == 0 || x.Sys_Role.Any(w => w.RoleID == roleID)));
- if (socDocTypeID.HasValue)
- {
- exp = exp.And(x => x.SOCDocTypeID == socDocTypeID);
- }
- if (createCollegeID.HasValue)
- {
- staffExp = staffExp.And(x => x.CollegeID == createCollegeID);
- }
- if (targetRoleID.HasValue)
- {
- exp = exp.And(x => x.Sys_Role.Any(w => w.RoleID == targetRoleID));
- }
- if (targetCollegeID.HasValue)
- {
- exp = exp.And(x => x.CF_Department.Any(w => w.CollegeID == targetCollegeID));
- }
- var query = SOCDocDAL.GetSOCDocViewQueryable(exp, staffExp);
- if (!string.IsNullOrEmpty(socDocConditionView.ConditionValue) && !string.IsNullOrEmpty(socDocConditionView.Attribute))
- query = query.DynamicWhere(socDocConditionView.Attribute, socDocConditionView.Condition, socDocConditionView.ConditionValue);
- query = query.OrderBy(x => x.SOCDocTypeID).ThenByDescending(x => x.CreateTime);
- return query.ToList();
- }
- public void Save(SOCDocView documentView, IList<Guid?> targetRoleIDList, IList<Guid?> targetDepartmentIDList)
- {
- var document = new DQP_Document();
- var targetRoleList = this.RoleRepository.GetList(x => targetRoleIDList.Contains(x.RoleID)).ToList();
- var targetDepartmentList = this.DepartmentRepository.GetList(x => targetDepartmentIDList.Contains(x.DepartmentID)).ToList();
- if (documentView.DocumentID != Guid.Empty)
- {
- document = this.SOCDocDAL.DocumentRepository.GetSingle(x => x.DocumentID == documentView.DocumentID, (x => x.Sys_Role), (x => x.CF_College));
- this.SetModifyStatus(document);
- }
- else
- {
- document.DocumentID = Guid.NewGuid();
- this.SetNewStatus(document);
- this.UnitOfWork.Add(document);
- }
- document.SOCDocTypeID = documentView.SOCDocTypeID;
- document.Title = documentView.Title;
- document.Content = documentView.Content;
- document.Sys_Role = new HashSet<Sys_Role>();
- document.Sys_Role = new HashSet<Sys_Role>(targetRoleList);
- document.CF_Department = new HashSet<CF_Department>();
- document.CF_Department = new HashSet<CF_Department>(targetDepartmentList);
- document.RecordStatus = (int)(documentView.IsShow ? CF_GeneralPurpose.IsYes : CF_GeneralPurpose.IsNo);
- UnitOfWork.Commit();
- }
- public void Delete(IList<Guid?> documentIDList)
- {
- var documentList = this.SOCDocDAL.DocumentRepository.GetList(x => documentIDList.Contains(x.DocumentID), (x => x.Sys_Role), (x => x.CF_College)).ToList();
- this.UnitOfWork.Delete(documentList, (x => x.Sys_Role));
- this.UnitOfWork.Delete(documentList, (x => x.CF_College));
- this.UnitOfWork.Delete(documentList, (x => x.CF_Department));
- this.UnitOfWork.Delete(documentList);
- }
- public SOCDocView GetSOCDocView(Guid documentID)
- {
- var documentView = SOCDocDAL.GetSOCDocViewQueryable((x => x.DocumentID == documentID), (x => true)).FirstOrDefault();
- return documentView;
- }
- }
- }
|