public void WhenViaApi(string leftNumber, string doOperation, string rightNumber) { var operation = ""; switch (doOperation) { case "adding": operation = "+"; break; case "subtracting": operation = "-"; break; case "multiplying": operation = "*"; break; case "dividing": operation = "/"; break; default: break; } var calcPayload = new CalculationFormula { LeftNumber = decimal.Parse(leftNumber), RightNumber = decimal.Parse(rightNumber), Operator = operation }; var headers = new Dictionary <string, string> { { "Accept", "*/*" }, { "Host", $"{Properties.Test.Default.AzureCalculatorHost}" }, { "Origin", $"https://{Properties.Test.Default.AzureCalculatorHost}" }, { "Referer", $"https://{Properties.Test.Default.AzureCalculatorHost}/" }, { "Sec-Fetch-Dest", "empty" }, { "Sec-Fetch-Mode", "cors" }, { "Sec-Fetch-Site", "cross-site" }, { "x-functions-key", Utils.GetAppSettings("CalcApiKey") } }; _response = RequestHelper.ExecuteJson( Properties.Test.Default.AzureCalculatorHost, Properties.Test.Default.AzureCalculatorPath, Method.POST, true, headers, null, calcPayload ); }
public clValue(decimal value, Well well, Pollution pollution, ValueNorm valueNorm = null, CalculationFormula calculationFormula = null, CoefficientValue coefficientValue = null, PriceNorm priceNorm = null) { this.Value = Math.Round(value, pollution.Round, MidpointRounding.AwayFromZero); this.Pollution = pollution; this.Well = well; this.ValueNorm = valueNorm; this.CoefficientValue = coefficientValue; this.CalculationFormula = calculationFormula; this.PriceNorm = priceNorm; }
public FormulaCreator_Window(CalculationFormula CalcFormula) { CalcFormula = Helpers.LogicHelper.CalculationFormulaLogic.FirstModel(CalcFormula.ID); InitializeComponent(); this.GetSetting(); Helper.Text = "Фактическая концентрация = \"FK\"\n" + "Допустимая концентрация(НОРМА) = \"DK\"\n" + "Тариф = \"T\"\n" + "Тариф загрязнения = \"TP\"\n" + "Объём = \"Q\"\n" + "Коэффициент = \"K\""; Formula.Text = CalcFormula.Formula; this.Closed += (sender, e) => { CalcFormula.SetValue(C.CalculationFormula.Formula, Formula.Text); }; }
/// <summary>Сбор значений == значения собираются в одно значение "ФК"</summary> protected IEnumerable <clValue> Compilation(IEnumerable <clValue> Values) { List <clValue> result = new List <clValue>(); var group = Values.GroupBy(x => x.Pollution.ID); foreach (var one in group) { CalculationFormula CalcFormula = PollutionBase_Class.AllCalculationFormul.FirstOrDefault (x => x.ResolutionClarifyID == one.First().ValueNorm.ResolutionClarifyID && x.PollutionID == one.First().Pollution.ID && x.YM <= DateControl_Class.SelectMonth ); if (CalcFormula != null) { decimal val = Math.Round(GettingValue(CalcFormula.GettingValueFormula, one.Select(x => x.Value).ToArray()), one.First().Pollution.Round, MidpointRounding.AwayFromZero); result.Add(new clValue(val, one.First().Well, one.First().Pollution, one.First().ValueNorm, CalcFormula)); } } return(result.ToArray()); }