public LogObservationsViewModel(bool IsReload, LotAndCommandObservation lotAndCommandData, LogItem logitem) { if (IsReload) { ApiSrv = new Services.ApiService(ApiConsult.ApiMenuB); this.LogItem = logitem; this.LotAndCommandData = lotAndCommandData; SelectedObservation = new ObservationItem(); GetInitialData(); //GetFakeData(); } }
public FitnessFunctions(RunItem runItem, bool singleRun, List <OptiParameter> ParamList, List <OptiObservation> ObservList, ObservationItem ObservItem) : this() { if (runItem == null) { throw new Exception("RunItem is empty: Select a run in the combobox"); } this.RunInfos = RunDefinitions(runItem, singleRun).ToList(); multiMultiYear = runItem.MultiMultiYear; multiFirstYear = runItem.MultiFirstYear; multiLastYear = runItem.MultiLastYear; observItem_ = ObservItem; observItem_.updateObservationDictionary(); observList_ = ObservList; foreach (var item in this.RunInfos) { item.Management = item.Management.Clone(); item.RunOptions = item.RunOptions.Clone(); item.Site = item.Site.Clone(); item.Soil = item.Soil.Clone(); item.Variety = item.Variety.Clone(); item.NonVariety = item.NonVariety.Clone(); this.Managements.Add(item.Management); this.RunOptions.Add(item.RunOptions); this.Sites.Add(item.Site); this.Soils.Add(item.Soil); this.Varieties.Add(item.Variety); this.NonVarieties.Add(item.NonVariety); } // Update of ParamSubModel foreach (var item in this.Varieties.First().ParamValue.Keys) { this.ParamSubModel.Add(item, "Variety"); } foreach (var item in this.NonVarieties.First().ParamValue.Keys) { this.ParamSubModel.Add(item, "NonVariety"); } // Initialisation of ParamList List <string> temp = new List <string>(); foreach (var item in ParamList) { switch (this.ParamSubModel[item.Name]) { case "Management": temp = Managements.Select(ii => ii.Name).ToList(); optimizeManagementParameter = true; break; case "Soil": temp = Soils.Select(ii => ii.Name).ToList(); optimizeSoilParameter = true; break; case "NonVariety": temp = NonVarieties.Select(ii => ii.Name).ToList(); optimizeNonVarietalParameter = true; break; case "Variety": temp = Varieties.Select(ii => ii.Name).ToList(); optimizeVarietalParameter = true; break; default: break; } while (temp.Count != 0) { if (!ParamValueDictio.ContainsKey(temp[0])) { ParamValueDictio.Add(temp[0], new Dictionary <string, double>()); } if (!ParamValueDictio[temp[0]].ContainsKey(item.Name))// should always be true { ParamValueDictio[temp[0]].Add(item.Name, 0); paramValueDictioSize++; } string typeToRemove = temp[0]; temp.RemoveAll(elem => elem == typeToRemove); } } }