public override decimal GetCalculatedGap(CalculationDetails details) { var res = (details.SCoef ?? 0) * (details.BaseAP ?? 0) * GetValueForCoefType(CoefType.SpecialEco7, details.Coefs) * GetValueForCoefType(CoefType.DopCoef, details.Coefs); return(res); }
public static CalculationDetails GetCalculationDetails(int calculationId) { IDalSession session = NHSessionFactory.CreateSession(); INavCalculation calc = NavCalculationMapper.GetNavCalculation(session, calculationId); CalculationDetails calcdetails = new CalculationDetails(calc); session.Close(); return calcdetails; }
public override decimal GetCalculatedGap(CalculationDetails details) { decimal res = GetValueForCoefType(CoefType.Vri, details.Coefs) * GetValueForCoefType(CoefType.Correct, details.Coefs) * GetValueForCoefType(CoefType.Location, details.Coefs) * (details.SCoef ?? 0) * GetValueForCoefType(CoefType.DopCoef, details.Coefs); if (details.UseMax ?? false) { res *= Math.Max(GetValueForCoefType(CoefType.BaseAp, details.Coefs) * GetValueForCoefType(CoefType.K1, details.Coefs), GetValueForCoefType(CoefType.K1, details.Coefs, true)); } else { res *= GetValueForCoefType(CoefType.BaseAp, details.Coefs); } return(res); }
/// <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); }
public void LogCalculationToFile(CalculationDetails calculationDetails) { string logFilePath = ConfigurationManager.AppSettings["LogFilePath"].ToString(); calculationDetails.LogDate = DateTime.Now; try { using (StreamWriter writer = new StreamWriter(logFilePath, append: true)) { foreach (var calculationProperty in calculationDetails.GetType().GetProperties()) { writer.Write(calculationProperty.GetValue(calculationDetails) + "\t"); } writer.WriteLine(); } } catch (Exception ex) { throw new ArgumentException("Error occured during logging: " + ex.Message); } }
public ActionResult CalculationForm(CalculationDetails calculationDetails) { if (ModelState.IsValid) { var firstNo = calculationDetails.FirstNumber; var secondNo = calculationDetails.SecondNumber; var multipliedValue = Multiply(firstNo, secondNo); if (calculationDetails.Operation == OperationType.CombinedWith) { calculationDetails.OperationOutput = multipliedValue; } else if (calculationDetails.Operation == OperationType.Either) { calculationDetails.OperationOutput = Add(firstNo, secondNo) - multipliedValue; } LogCalculationToFile(calculationDetails); ViewBag.Output = calculationDetails.OperationOutput; } return(View("Index", calculationDetails)); }
/// <summary> /// Возвращает рассчитанный по формуле ГАП /// </summary> /// <param name="details"></param> /// <returns></returns> public abstract decimal GetCalculatedGap(CalculationDetails details);