public void deleteSelection(Entity selection) { List <Entity> listForDelete = new List <Entity>(); int templateId = ((Selection)selection).TaskTemplateID; TaskTemplate template = ((TaskTemplate)services.DatabaseManager.SharedManager.entityById(templateId, typeof(TaskTemplate))); List <Entity> taskTemplates = TaskTemplate.where (new Query("TaskTemplate").addTypeQuery(TypeQuery.select) .addCondition("TaskID", "=", template.TaskID.ToString()), typeof(TaskTemplate)); List <Entity> selections = new List <Entity>(); foreach (Entity entity in taskTemplates) { List <Entity> sels = TaskTemplate.where (new Query("Selection").addTypeQuery(TypeQuery.select) .addCondition("TaskTemplateId", "=", entity.ID.ToString()) .addCondition("Name", "=", ((Selection)selection).Name), typeof(Selection)); if (sels.Count == 0) { continue; } else { listForDelete = listForDelete.Concat(sels).ToList(); selections = selections.Concat(sels).ToList(); } } foreach (Entity sel in selections) { List <Entity> selectionRows = SelectionRow.where (new Query("SelectionRow").addTypeQuery(TypeQuery.select) .addCondition("SelectionID", "=", sel.ID.ToString()), typeof(SelectionRow)); listForDelete = listForDelete.Concat(selectionRows).ToList(); for (int i = 0; i < selectionRows.Count; i++) { List <Entity> values = ValueParameter.where (new Query("ValueParameter").addTypeQuery(TypeQuery.select) .addCondition("SelectionRowID", "=", selectionRows[i].ID.ToString()), typeof(ValueParameter)); listForDelete = listForDelete.Concat(values).ToList(); } List <Entity> learnedSolverList = LearnedSolver.where (new Query("LearnedSolver").addTypeQuery(TypeQuery.select) .addCondition("SelectionID", "=", sel.ID.ToString()), typeof(LearnedSolver)); listForDelete = listForDelete.Concat(learnedSolverList).ToList(); foreach (Entity lSolver in learnedSolverList) { List <Entity> learningQualityList = LearningQuality.where (new Query("LearningQuality").addTypeQuery(TypeQuery.select) .addCondition("LearnedSolverID", "=", lSolver.ID.ToString()), typeof(LearningQuality)); listForDelete = listForDelete.Concat(learningQualityList).ToList(); } } DatabaseManager.SharedManager.deleteMultipleEntities(listForDelete); }
public void deleteTask(Entity task) { List <Entity> listForDelete = new List <Entity>(); listForDelete.Add(task); List <Entity> templates = TaskTemplate.where (new Query("TaskTemplate").addTypeQuery(TypeQuery.select) .addCondition("TaskID", "=", task.ID.ToString()), typeof(TaskTemplate)); listForDelete = listForDelete.Concat(templates).ToList(); foreach (Entity template in templates) { List <Entity> parameters = models.Parameter.where (new Query("Parameter").addTypeQuery(TypeQuery.select) .addCondition("TaskTemplateID", "=", template.ID.ToString()), typeof(models.Parameter)); listForDelete = listForDelete.Concat(parameters).ToList(); List <Entity> selections = Selection.where (new Query("Selection").addTypeQuery(TypeQuery.select) .addCondition("TaskTemplateID", "=", template.ID.ToString()), typeof(Selection)); listForDelete = listForDelete.Concat(selections).ToList(); foreach (Entity selection in selections) { List <Entity> selectionRows = SelectionRow.where (new Query("SelectionRow").addTypeQuery(TypeQuery.select) .addCondition("SelectionID", "=", selection.ID.ToString()), typeof(SelectionRow)); listForDelete = listForDelete.Concat(selectionRows).ToList(); for (int i = 0; i < selectionRows.Count; i++) { List <Entity> values = ValueParameter.where (new Query("ValueParameter").addTypeQuery(TypeQuery.select) .addCondition("SelectionRowID", "=", selectionRows[i].ID.ToString()), typeof(ValueParameter)); listForDelete = listForDelete.Concat(values).ToList(); } List <Entity> learnedSolverList = LearnedSolver.where (new Query("LearnedSolver").addTypeQuery(TypeQuery.select) .addCondition("SelectionID", "=", selection.ID.ToString()), typeof(LearnedSolver)); listForDelete = listForDelete.Concat(learnedSolverList).ToList(); foreach (Entity lSolver in learnedSolverList) { List <Entity> learningQualityList = LearningQuality.where (new Query("LearningQuality").addTypeQuery(TypeQuery.select) .addCondition("LearnedSolverID", "=", lSolver.ID.ToString()), typeof(LearningQuality)); listForDelete = listForDelete.Concat(learningQualityList).ToList(); } } } DatabaseManager.SharedManager.deleteMultipleEntities(listForDelete); }
public SelectionLearnStatisticViewModel(Selection selection, string taskName) { CurSelection = selection; List <Entity> selections = Selection.where (new Query("Selection").addTypeQuery(TypeQuery.select) .addCondition("Name", "=", selection.Name), typeof(Selection)); List <Entity> learnedSolvers = new List <Entity>(); foreach (Selection sel in selections) { learnedSolvers.AddRange(LearnedSolver.where (new Query("LearnedSolver").addTypeQuery(TypeQuery.select) .addCondition("SelectionID", "=", sel.ID.ToString()), typeof(LearnedSolver))); } List <LearnedSolverViewModel> listLearnedSolverViewModel = new List <LearnedSolverViewModel>(); ISet <string> nameLearnedSolver = new HashSet <string>(); Dictionary <string, List <LearnedSolver> > dictionarytaskSolverToLearnedSolver = new Dictionary <string, List <LearnedSolver> >(); foreach (LearnedSolver learnedSolver in learnedSolvers) { TaskSolver taskSolver = (TaskSolver)TaskSolver.getById(learnedSolver.TaskSolverID, typeof(TaskSolver)); List <LearnedSolver> learnedSolverForCurSolver; if (dictionarytaskSolverToLearnedSolver.TryGetValue(taskSolver.Name, out learnedSolverForCurSolver)) { learnedSolverForCurSolver.Add(learnedSolver); dictionarytaskSolverToLearnedSolver[taskSolver.Name] = learnedSolverForCurSolver; } else { learnedSolverForCurSolver = new List <LearnedSolver>() { learnedSolver }; dictionarytaskSolverToLearnedSolver.Add(taskSolver.Name, learnedSolverForCurSolver); } } foreach (KeyValuePair <string, List <LearnedSolver> > pair in dictionarytaskSolverToLearnedSolver) { listLearnedSolverViewModel.Add(new LearnedSolverViewModel(pair.Value) { Name = pair.Key }); } LearnedSolvers = listLearnedSolverViewModel.ToArray(); SolversToLearn = new ObservableCollection <SolverLearnRowViewModel> { new SolverLearnRowViewModel(this) { SelectedName = "Персептрон 1" } }; TaskName = taskName; SelectionName = selection.Name; addHandler = new ActionHandler( () => { SolversToLearn.Add(new SolverLearnRowViewModel(this) { SelectedName = "Персептрон " + (SolversToLearn.Count + 1) }); }, e => true); learnCommand = new ActionHandler(learnSolver, e => true); }