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; } /// /// 查询对应的重修条件信息View /// /// /// public RetakeConditionView GetRetakeConditionView(ER_RetakeConditionType conditionType) { var query = RetakeConditionDAL.GetRetakeConditionView(x => x.RetakeConditionTypeID == (int)conditionType); return query.FirstOrDefault(); } /// /// 查询对应的重修条件参数值 /// /// /// /// public Nullable GetParameter(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); } } /// /// 重修条件参数保存 /// /// /// 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); } } } }