123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.Utility;
- using EMIS.ViewModel.RetakeManage;
- using EMIS.DataLogic.RetakeManage;
- using EMIS.ViewModel;
- using EMIS.Utility;
- namespace EMIS.CommonLogic.RetakeManage
- {
- public class RetakeConditionServices : BaseServices, IRetakeConditionServices
- {
- public RetakeConditionDAL RetakeConditionDAL { get; set; }
- /// <summary>
- /// 查询对应的重修条件信息View
- /// </summary>
- /// <param name="conditionType"></param>
- /// <returns></returns>
- public RetakeConditionView GetRetakeConditionView(ER_RetakeConditionType conditionType)
- {
- var query = RetakeConditionDAL.GetRetakeConditionView(x => x.RetakeConditionTypeID == (int)conditionType);
- return query.FirstOrDefault();
- }
- /// <summary>
- /// 查询对应的重修条件参数值
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="parameterType"></param>
- /// <returns></returns>
- public Nullable<T> GetParameter<T>(ER_RetakeParameterType parameterType) where T : struct
- {
- try
- {
- var parameterTypeEntity = RetakeConditionDAL.RetakeConditionParameterRepository
- .GetSingle(x => x.RetakeParameterTypeID == (int)parameterType);
- if (parameterTypeEntity == null || string.IsNullOrEmpty(parameterTypeEntity.Value))
- {
- return null;
- }
- T result;
- if (parameterTypeEntity.Value.TryParseTo(out result))
- {
- return result;
- }
- return null;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 重修条件参数保存
- /// </summary>
- /// <param name="parameterType"></param>
- /// <param name="value"></param>
- public void SetParameter(ER_RetakeParameterType parameterType, object value)
- {
- try
- {
- //查询重修条件信息View
- var retakeCondition = RetakeConditionDAL.GetRetakeConditionView(x => x.RetakeConditionTypeID == (int)ER_RetakeConditionType.NotPassCount)
- .SingleOrDefault();
- if (retakeCondition == null)
- {
- throw new Exception("重修条件未配置,请配置。");
- }
- else
- {
- var parameterTypeEntity = RetakeConditionDAL.RetakeConditionParameterRepository
- .GetSingle(x => x.RetakeParameterTypeID == (int)parameterType);
- if (parameterTypeEntity == null)
- {
- parameterTypeEntity = new Entities.ER_RetakeConditionParameter
- {
- RetakeConditionParameterID = Guid.NewGuid(),
- RetakeParameterTypeID = (int)parameterType
- };
- this.SetNewStatus(parameterTypeEntity);
- this.UnitOfWork.Add(parameterTypeEntity);
- }
- else
- {
- this.SetModifyStatus(parameterTypeEntity);
- }
- parameterTypeEntity.Value = value.ToString();
- this.UnitOfWork.Commit();
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- }
- }
|