123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- 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 EvaluationTableServices : BaseServices, IEvaluationTableServices
- {
- public EvaluationTableDAL EvaluationTableDAL { get; set; }
- /// <summary>
- /// 查询对应的评价表信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="evaluationParticipateTypeID"></param>
- /// <param name="evaluationTypeID"></param>
- /// <param name="isStudent"></param>
- /// <param name="isEnabled"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<EvaluationTableView> GetEvaluationTableViewGrid(ConfiguretView configuretView, Guid? evaluationParticipateTypeID, Guid? evaluationTypeID, int? isStudent, int? isEnabled, int pageIndex, int pageSize)
- {
- Expression<Func<EM_EvaluationTable, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (evaluationParticipateTypeID.HasValue)
- {
- exp = exp.And(x => x.EvaluationParticipateTypeID == evaluationParticipateTypeID);
- }
- if (evaluationTypeID.HasValue)
- {
- exp = exp.And(x => x.EvaluationIntTypeID == evaluationTypeID);
- }
- if (isEnabled.HasValue)
- {
- if (isEnabled.Value == (int)CF_GeneralPurpose.IsYes)
- {
- exp = exp.And(x => x.IsEnabled == true);
- }
- if (isEnabled.Value == (int)CF_GeneralPurpose.IsNo)
- {
- exp = exp.And(x => x.IsEnabled != true);
- }
- }
- var query = EvaluationTableDAL.GetEvaluationTableViewQueryable(exp);
- if (isStudent.HasValue)
- {
- if (isStudent.Value == (int)CF_GeneralPurpose.IsYes)
- {
- query = query.Where(x => x.IsStudent == true);
- }
- if (isStudent.Value == (int)CF_GeneralPurpose.IsNo)
- {
- query = query.Where(x => x.IsStudent != true);
- }
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.Code.Length).ThenBy(x => x.Code).ToGridResultSet<EvaluationTableView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的评价表信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="evaluationParticipateTypeID"></param>
- /// <param name="evaluationTypeID"></param>
- /// <param name="isStudent"></param>
- /// <param name="isEnabled"></param>
- /// <returns></returns>
- public IList<EvaluationTableView> GetEvaluationTableViewList(ConfiguretView configuretView, Guid? evaluationParticipateTypeID, Guid? evaluationTypeID, int? isStudent, int? isEnabled)
- {
- Expression<Func<EM_EvaluationTable, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (evaluationParticipateTypeID.HasValue)
- {
- exp = exp.And(x => x.EvaluationParticipateTypeID == evaluationParticipateTypeID);
- }
- if (evaluationTypeID.HasValue)
- {
- exp = exp.And(x => x.EvaluationIntTypeID == evaluationTypeID);
- }
- if (isEnabled.HasValue)
- {
- if (isEnabled.Value == (int)CF_GeneralPurpose.IsYes)
- {
- exp = exp.And(x => x.IsEnabled == true);
- }
- if (isEnabled.Value == (int)CF_GeneralPurpose.IsNo)
- {
- exp = exp.And(x => x.IsEnabled != true);
- }
- }
- var query = EvaluationTableDAL.GetEvaluationTableViewQueryable(exp);
- if (isStudent.HasValue)
- {
- if (isStudent.Value == (int)CF_GeneralPurpose.IsYes)
- {
- query = query.Where(x => x.IsStudent == true);
- }
- if (isStudent.Value == (int)CF_GeneralPurpose.IsNo)
- {
- query = query.Where(x => x.IsStudent != true);
- }
- }
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.Code.Length).ThenBy(x => x.Code).ToList();
- }
- /// <summary>
- /// 查询对应的评价表信息View(启用状态为是或已使用)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="evaluationTableID"></param>
- /// <param name="evaluationParticipateTypeID"></param>
- /// <param name="evaluationTypeID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<EvaluationTableView> GetEnabledAndUseEvaluationTableViewGrid(ConfiguretView configuretView, Guid? evaluationTableID, Guid? evaluationParticipateTypeID, Guid? evaluationTypeID, int pageIndex, int pageSize)
- {
- Expression<Func<EM_EvaluationTable, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (evaluationTableID.HasValue)
- {
- exp = exp.And(x => x.IsEnabled == true || x.EvaluationTableID == evaluationTableID);
- }
- else
- {
- exp = exp.And(x => x.IsEnabled == true);
- }
- if (evaluationParticipateTypeID.HasValue)
- {
- exp = exp.And(x => x.EvaluationParticipateTypeID == evaluationParticipateTypeID);
- }
- if (evaluationTypeID.HasValue)
- {
- exp = exp.And(x => x.EvaluationIntTypeID == evaluationTypeID);
- }
- var query = EvaluationTableDAL.GetEvaluationTableViewQueryable(exp);
-
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.Code.Length).ThenBy(x => x.Code).ToGridResultSet<EvaluationTableView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的评价表信息List(启用状态为是或已使用)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="evaluationTableID"></param>
- /// <param name="evaluationParticipateTypeID"></param>
- /// <param name="evaluationTypeID"></param>
- /// <returns></returns>
- public IList<EvaluationTableView> GetEnabledAndUseEvaluationTableViewList(ConfiguretView configuretView, Guid? evaluationTableID, Guid? evaluationParticipateTypeID, Guid? evaluationTypeID)
- {
- Expression<Func<EM_EvaluationTable, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (evaluationTableID.HasValue)
- {
- exp = exp.And(x => x.IsEnabled == true || x.EvaluationTableID == evaluationTableID);
- }
- else
- {
- exp = exp.And(x => x.IsEnabled == true);
- }
- if (evaluationParticipateTypeID.HasValue)
- {
- exp = exp.And(x => x.EvaluationParticipateTypeID == evaluationParticipateTypeID);
- }
- if (evaluationTypeID.HasValue)
- {
- exp = exp.And(x => x.EvaluationIntTypeID == evaluationTypeID);
- }
- var query = EvaluationTableDAL.GetEvaluationTableViewQueryable(exp);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.Code.Length).ThenBy(x => x.Code).ToList();
- }
- /// <summary>
- /// 查询对应的评价表信息EvaluationTableView
- /// </summary>
- /// <param name="evaluationTableID"></param>
- /// <returns></returns>
- public EvaluationTableView GetEvaluationTableView(Guid? evaluationTableID)
- {
- try
- {
- Expression<Func<EM_EvaluationTable, bool>> exp = (x => x.EvaluationTableID == evaluationTableID);
- var query = EvaluationTableDAL.GetEvaluationTableViewQueryable(exp).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑
- /// </summary>
- /// <param name="evaluationTableView"></param>
- public void EvaluationTableEdit(EvaluationTableView evaluationTableView)
- {
- try
- {
- var evaluationTableVerify = EvaluationTableDAL.EvaluationTableRepository.GetList(x => x.EvaluationTableID != evaluationTableView.EvaluationTableID && (x.Code == evaluationTableView.Code.Trim() || x.Name == evaluationTableView.Name.Trim())).SingleOrDefault();
- if (evaluationTableVerify == null)
- {
- if (evaluationTableView.EvaluationTableID != Guid.Empty)
- {
- var evaluationTable = EvaluationTableDAL.EvaluationTableRepository.GetList(x => x.EvaluationTableID == evaluationTableView.EvaluationTableID).SingleOrDefault();
- if (evaluationTable == null)
- {
- throw new Exception("数据有误,请核查。");
- }
- else
- {
- //表示修改
- evaluationTable.Code = evaluationTableView.Code.Trim();
- evaluationTable.Name = evaluationTableView.Name.Trim();
- evaluationTable.EvaluationParticipateTypeID = evaluationTableView.EvaluationParticipateTypeID;
- evaluationTable.EvaluationIntTypeID = evaluationTableView.EvaluationTypeID;
- evaluationTable.Weight = evaluationTableView.Weight;
- evaluationTable.IsEnabled = evaluationTableView.IsEnabled;
- evaluationTable.Remark = evaluationTableView.Remark;
- SetModifyStatus(evaluationTable);
- }
- }
- else
- {
- //表示新增
- var newEvaluationTable = new EM_EvaluationTable();
- newEvaluationTable.EvaluationTableID = Guid.NewGuid();
- newEvaluationTable.Code = evaluationTableView.Code.Trim();
- newEvaluationTable.Name = evaluationTableView.Name.Trim();
- newEvaluationTable.EvaluationParticipateTypeID = evaluationTableView.EvaluationParticipateTypeID;
- newEvaluationTable.EvaluationIntTypeID = evaluationTableView.EvaluationTypeID;
- newEvaluationTable.Weight = evaluationTableView.Weight;
- newEvaluationTable.IsEnabled = evaluationTableView.IsEnabled;
- newEvaluationTable.Remark = evaluationTableView.Remark;
- SetNewStatus(newEvaluationTable);
- UnitOfWork.Add(newEvaluationTable);
- }
- }
- else
- {
- throw new Exception("已存在相同的评价表信息(编号或评价表名唯一),请核查。");
- }
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="evaluationTableIDs"></param>
- /// <returns></returns>
- public bool EvaluationTableDelete(List<Guid?> evaluationTableIDs)
- {
- try
- {
- UnitOfWork.Delete<EM_EvaluationTable>(x => evaluationTableIDs.Contains(x.EvaluationTableID));
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|