123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using Bowin.Common.Linq;
- using Bowin.Common.Data;
- using Bowin.Common.Linq.Entity;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.EvaluationManage.EvaluationTable;
- using EMIS.DataLogic.EvaluationManage.EvaluationTable;
- namespace EMIS.CommonLogic.EvaluationManage.EvaluationTable
- {
- public class EvaluationProjectServices : BaseServices, IEvaluationProjectServices
- {
- public EvaluationProjectDAL EvaluationProjectDAL { get; set; }
- /// <summary>
- /// 查询对应的评价项目信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="evaluationParticipateTypeID"></param>
- /// <param name="evaluationTypeID"></param>
- /// <param name="evaluationTableID"></param>
- /// <param name="evaluationTargetID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<EvaluationProjectView> GetEvaluationProjectViewGrid(ConfiguretView configuretView, Guid? evaluationParticipateTypeID, Guid? evaluationTypeID, Guid? evaluationTableID, Guid? evaluationTargetID, int pageIndex, int pageSize)
- {
- Expression<Func<EM_EvaluationProject, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (evaluationTargetID.HasValue)
- {
- exp = exp.And(x => x.EvaluationTargetID == evaluationTargetID);
- }
- var query = EvaluationProjectDAL.GetEvaluationProjectViewQueryable(exp);
- if (evaluationParticipateTypeID.HasValue)
- {
- query = query.Where(x => x.EvaluationParticipateTypeID == evaluationParticipateTypeID);
- }
- if (evaluationTypeID.HasValue)
- {
- query = query.Where(x => x.EvaluationTypeID == evaluationTypeID);
- }
- if (evaluationTableID.HasValue)
- {
- query = query.Where(x => x.EvaluationTableID == evaluationTableID);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.EvaluationTargetCode.Length).ThenBy(x => x.EvaluationTargetCode).ThenBy(x => x.EvaluationTargetOrderNo).ThenBy(x => x.OrderNo).ToGridResultSet<EvaluationProjectView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的评价项目信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="evaluationParticipateTypeID"></param>
- /// <param name="evaluationTypeID"></param>
- /// <param name="evaluationTableID"></param>
- /// <param name="evaluationTargetID"></param>
- /// <returns></returns>
- public IList<EvaluationProjectView> GetEvaluationProjectViewList(ConfiguretView configuretView, Guid? evaluationParticipateTypeID, Guid? evaluationTypeID, Guid? evaluationTableID, Guid? evaluationTargetID)
- {
- Expression<Func<EM_EvaluationProject, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (evaluationTargetID.HasValue)
- {
- exp = exp.And(x => x.EvaluationTargetID == evaluationTargetID);
- }
- var query = EvaluationProjectDAL.GetEvaluationProjectViewQueryable(exp);
- if (evaluationParticipateTypeID.HasValue)
- {
- query = query.Where(x => x.EvaluationParticipateTypeID == evaluationParticipateTypeID);
- }
- if (evaluationTypeID.HasValue)
- {
- query = query.Where(x => x.EvaluationTypeID == evaluationTypeID);
- }
- if (evaluationTableID.HasValue)
- {
- query = query.Where(x => x.EvaluationTableID == evaluationTableID);
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.EvaluationTargetCode.Length).ThenBy(x => x.EvaluationTargetCode).ThenBy(x => x.EvaluationTargetOrderNo).ThenBy(x => x.OrderNo).ToList();
- }
- /// <summary>
- /// 查询对应的评价项目信息List
- /// </summary>
- /// <param name="evaluationTargetID"></param>
- /// <returns></returns>
- public IList<EM_EvaluationProject> GetEvaluationProjectList(Guid? evaluationTargetID)
- {
- Expression<Func<EM_EvaluationProject, bool>> expEvaluationProject = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expEvaluationProject = expEvaluationProject.And(x => x.EvaluationTargetID == evaluationTargetID);
- var query = EvaluationProjectDAL.EvaluationProjectRepository.GetList(expEvaluationProject);
- return query.OrderBy(x => x.Code.Length).ThenBy(x => x.Code).ThenBy(x => x.OrderNo).ToList();
- }
- /// <summary>
- /// 查询对应的评价项目信息EvaluationProjectView
- /// </summary>
- /// <param name="evaluationProjectID"></param>
- /// <returns></returns>
- public EvaluationProjectView GetEvaluationProjectView(Guid? evaluationProjectID)
- {
- try
- {
- Expression<Func<EM_EvaluationProject, bool>> exp = (x => x.EvaluationProjectID == evaluationProjectID);
- var query = EvaluationProjectDAL.GetEvaluationProjectViewQueryable(exp).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="evaluationProjectView"></param>
- public void EvaluationProjectEdit(EvaluationProjectView evaluationProjectView)
- {
- try
- {
- var evaluationProjectVerify = EvaluationProjectDAL.EvaluationProjectRepository.GetList(x => x.EvaluationProjectID != evaluationProjectView.EvaluationProjectID && x.Code == evaluationProjectView.Code.Trim()).SingleOrDefault();
- if (evaluationProjectVerify == null)
- {
- if (evaluationProjectView.EvaluationProjectID != Guid.Empty)
- {
- var evaluationProject = EvaluationProjectDAL.EvaluationProjectRepository.GetList(x => x.EvaluationProjectID == evaluationProjectView.EvaluationProjectID).SingleOrDefault();
- if (evaluationProject == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- else
- {
- //表示修改
- evaluationProject.OrderNo = evaluationProjectView.OrderNo;
- evaluationProject.Code = evaluationProjectView.Code.Trim();
- evaluationProject.Name = evaluationProjectView.Name.Trim();
- evaluationProject.EvaluationTargetID = evaluationProjectView.EvaluationTargetID;
- evaluationProject.Weight = evaluationProjectView.Weight;
- evaluationProject.Remark = evaluationProjectView.Remark;
- SetModifyStatus(evaluationProject);
- }
- }
- else
- {
- //表示新增
- var newEvaluationProject = new EM_EvaluationProject();
- newEvaluationProject.EvaluationProjectID = Guid.NewGuid();
- newEvaluationProject.OrderNo = evaluationProjectView.OrderNo;
- newEvaluationProject.Code = evaluationProjectView.Code.Trim();
- newEvaluationProject.Name = evaluationProjectView.Name.Trim();
- newEvaluationProject.EvaluationTargetID = evaluationProjectView.EvaluationTargetID;
- newEvaluationProject.Weight = evaluationProjectView.Weight;
- newEvaluationProject.Remark = evaluationProjectView.Remark;
- SetNewStatus(newEvaluationProject);
- UnitOfWork.Add(newEvaluationProject);
- }
- }
- else
- {
- throw new Exception("已存在相同的评价项目信息(项目编号唯一),请核查。");
- }
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="evaluationProjectIDs"></param>
- /// <returns></returns>
- public bool EvaluationProjectDelete(List<Guid?> evaluationProjectIDs)
- {
- try
- {
- UnitOfWork.Delete<EM_EvaluationProject>(x => evaluationProjectIDs.Contains(x.EvaluationProjectID));
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|