/// <summary> /// Trains the next item, and handles the generations cost, callback, etc... /// </summary> /// <param name="i">The actual item id</param> /// <param name="genCallBack">The callback between each generations</param> /// <param name="randomizeTrainingData">Should the data be shuffled?</param> /// <param name="genLength">if the data is shuffled, how many items should there be in a generation?</param> async void TrainNext(int i, Action <int, double> genCallBack, bool randomizeTrainingData = false, int genLength = 50) { i = i == -1 ? 1 : (i + 1) % (randomizeTrainingData ? genLength : trainingData.Count); if (i == 0) { genCount++; cost /= (randomizeTrainingData ? genLength : trainingData.Count); // Generations costs list Costs.Add(cost); // Callback if (genCallBack != null) { genCallBack.Invoke(genCount, cost); } cost = 0; } // Launch next training item await Task.Run(() => Train((randomizeTrainingData ? RandomTrainingData : trainingData[i]), () => { if (isTraining == false) { return; } TrainNext(i, genCallBack, randomizeTrainingData, genLength); }, true)); }
public void Init() { IsInit = false; List <CategoryModel> categories = null; if (DbWorker.GetCategories().Count == 0) { categories = CategoryFactory.GetCategories().ToList(); foreach (var category in categories) { DbWorker.AddCategory(category); } } else { categories = DbWorker.GetCategories(); } foreach (var category in categories) { Categories.Add(new CategoryViewModel(category)); } foreach (var cost in DbWorker.GetCosts().Take(TOTAL_COUNT_COSTS)) { Costs.Add(new CostViewModel(cost)); } Accounts.Initialization(); IsInit = true; }
public virtual Cost AddCost() { var cost = new Cost { Price = this, Name = "Базовая", }; if (CostType == 0) { cost.PriceItem = Costs.Select(c => c.PriceItem).FirstOrDefault(); } if (cost.PriceItem == null) { cost.PriceItem = new PriceItem { FormRule = new FormRule(), Source = new PriceSource() }; } cost.CostFormRule = new CostFormRule { Cost = cost, FieldName = "" }; Costs.Add(cost); return(cost); }
public void addCost(decimal cost) { if (Costs == null) { Costs = new List <decimal>(); } Costs.Add(cost); }
public void AddCost(int[] ids, double[] valuesOnEachPurse, string title, double value, char curency) { costs.Add(ids, valuesOnEachPurse, title, value, curency); amountControl.Add("Cost", curency, value, true); int index = costs.CreateDates.Count - 1; costControl.Render(ids, valuesOnEachPurse, title, value, curency, DateTime.Parse(costs.CreateDates[index]), index); StartCoroutine(costControl.UpdateContentHeight()); }
internal async Task FetchCosts() { foreach (CostModel item in DbWorker.Current.GetCosts(Costs.Count)) { await Task.Delay(600); await App.RunUIAsync(() => { Costs.Add(new CostViewModel(item)); }); } }
public void Add(Cost costName, double amount) { var cost = Costs.Keys.FirstOrDefault(c => c.Name.Equals(costName)); if (cost == null) { Costs.Add(costName, amount); } else { Costs[cost] += amount; } }
public void Add(Cost cost, double amount) { var costs = Costs.SingleOrDefault(c => c.Name == cost.Name); if (costs == null) { Costs.Add(cost); } CostsList.Add(cost, amount); Save(Costs); Save(new List <CostsList>() { CostsList }); }
public void Add(Costs cost, double price) { var costs = Costs.SingleOrDefault(c => c.Name == cost.Name); if (costs == null) { Costs.Add(cost); Cost.Add(cost, price); Save(); } else { Cost.Add(costs, price); Save(); } }
private void Filter() { Costs.Clear(); var costs = _costs; if (costs == null) { costs = new List <InfoCost>(); } if (SelectedCostItem != null && SelectedCostItem.Name != null) { costs = costs.Where(c => c.DirectoryCostItem.Name == SelectedCostItem.Name).ToList(); } if (SelectedRC != null && SelectedRC.Name != null) { costs = costs.Where(c => c.DirectoryRC.Name == SelectedRC.Name).ToList(); } if (SelectedInOut != null && SelectedInOut != "") { costs = costs.Where(c => SelectedInOut == "Приход" ? c.IsIncoming : !c.IsIncoming).ToList(); } if (SelectedTransportCompany != null && SelectedTransportCompany.Name != null) { costs = costs.Where(c => c.DirectoryTransportCompany != null && c.DirectoryTransportCompany.Name == SelectedTransportCompany.Name).ToList(); } if (SelectedNote != null && SelectedNote.Description != null) { costs = costs.Where(c => c.CurrentNotes.Any(n => n.DirectoryNote.Description == SelectedNote.Description)).ToList(); } costs = costs.OrderByDescending(c => c.Date).ToList(); foreach (var cost in costs) { Costs.Add(cost); } SummChange(); }
public void EvaluateCostsAndProfits() { if (!Totals.Any()) // Totals need to be evaluated beforehand { EvaluateTotals(); } Costs.Clear(); Profits.Clear(); for (var index = 0; index <= _diffMonths; index++) { var period = _from.AddMonths(index); var ordersInMonth = _orders.Where(IsInMonth(period.Month)); Costs.Add(ordersInMonth.Sum(order => order.OrderTotalCost)); Profits.Add(Totals[index] - Costs[index]); } }
public void UpdateData() { if (!OneDrive.IsAuthenticated) { return; } List <CategoryModel> categories = DbWorker.GetCategories(); Categories.Clear(); foreach (var category in categories) { Categories.Add(new CategoryViewModel(category)); } Costs.Clear(); foreach (var cost in DbWorker.GetCosts().Take(TOTAL_COUNT_COSTS)) { Costs.Add(new CostViewModel(cost)); } Accounts.UpdateData(); }
protected void btnAdd_Click(Object Sender, EventArgs e) { if (Request.Form[hdnId.UniqueID] == "0") { oCost.Add(txtName.Text, (chkEnabled.Checked == true ? 1 : 0)); } else { oCost.Update(Int32.Parse(Request.Form[hdnId.UniqueID]), txtName.Text, (chkEnabled.Checked == true ? 1 : 0)); } if (Request.Form[hdnOrder.UniqueID] != "") { string strOrder = Request.Form[hdnOrder.UniqueID]; int intCount = 0; while (strOrder != "") { intCount++; int intId = Int32.Parse(strOrder.Substring(0, strOrder.IndexOf("&"))); strOrder = strOrder.Substring(strOrder.IndexOf("&") + 1); oCost.UpdateOrder(intId, intCount); } } Response.Redirect(Request.Path); }
/// <summary> /// Add new Value to the Column /// </summary> /// <param name="value">Value to be added.</param> public void Add(ushort value) { Costs.Add(new APValue(value)); }