/// <summary> /// Возвращает список используемых в формуле конкретного расчета коэффициентов /// </summary> /// <param name="calcId"></param> /// <param name="methodId"></param> /// <returns></returns> public List <ChosenCoefModel> GetChosenCoefsList(MethodConditions conditions) { OMCalcMethod method = OMCalcMethod.Where(x => x.Id == conditions.MethodId).SelectAll().ExecuteFirstOrDefault(); //var coefTypes = GetCoefTypes(method.MethodType_Code, useMax, method.UseDopCoef ?? false, isDouble, false); conditions.MethodType = method.MethodType_Code; conditions.UseDopCoef = method.UseDopCoef ?? false; var coefTypes = GetUsedCoefType(conditions); var chosenCoefGrid = new List <ChosenCoefModel>(); var coefIds = OMCalcCoefConnection.Where(x => x.CalcId == conditions.CalcId).SelectAll().Execute().Select(x => x.CoefId).ToList(); foreach (var coefType in coefTypes) { OMCalcCoefs coef = null; if (coefIds.Count > 0) { coef = OMCalcCoefs.Where(x => x.CoefType_Code == coefType && coefIds.Contains(x.Id)).SelectAll().ExecuteFirstOrDefault(); } if (conditions.CalcId == -1 || coef == null) { chosenCoefGrid.Add(new ChosenCoefModel() { Id = -1, Name = "", Value = 1, Value2 = 1, CoefType_Code = coefType, CoefType = coefType.GetEnumDescription(), Mark = GetCoefTypeMark(coefType) }); } else { chosenCoefGrid.Add(new ChosenCoefModel() { Id = coef.Id, Name = coef.Name, Value = coef.Value, Value2 = coef.Value2, CoefType_Code = coefType, CoefType = coefType.GetEnumDescription(), Mark = GetCoefTypeMark(coefType), ActualS = coef.ActualS, ActualPo = coef.ActualPo }); } } return(chosenCoefGrid); }
/// <summary> /// Возвращает рассчитанную ГАП /// </summary> /// <param name="details"></param> /// <returns></returns> public decimal GetCalculatedGap(CalculationDetails details) { decimal res = 0; OMCalcMethod method = OMCalcMethod.Where(x => x.Id == details.MethodId).SelectAll().ExecuteFirstOrDefault(); if (method != null) { var implement = GetImplementation(method.MethodType_Code); if (implement == null) { return(res); } return(implement.GetCalculatedGap(details)); } return(res); }
/// <summary> /// Возвращает формулу /// </summary> /// <param name="methodId"></param> /// <param name="method"></param> /// <param name="useMax"></param> /// <param name="useDopCoef"></param> /// <returns></returns> public string GetFormula(MethodConditions conditions) { if (conditions.MethodId.HasValue) { OMCalcMethod met = OMCalcMethod.Where(x => x.Id == conditions.MethodId).SelectAll().ExecuteFirstOrDefault(); conditions.MethodType = met.MethodType_Code; conditions.UseDopCoef = met.UseDopCoef ?? false; } string res = ""; var implement = GetImplementation(conditions.MethodType); if (implement == null) { return(res); } res = implement.GetFormula(conditions.UseMaxFunction); if (conditions.UseDopCoef) { res += " x Kдоп"; } return(res); }