private void Answer(ReadyAnswer result, bool isNewAnswer) { CheckMode = false; MessageAnsver.Clear(); foreach (var res in result.ListResultAndCF) { MessageAnsver.Add(res.Key + " КД=" + res.Value); } if (isNewAnswer) { User.AddResult(CurrentPurpose, result); TreeAns.RefreshTree(User.ListReadyAnswers); } }
public void Change(string currentUserPurpose, Dictionary <string, string> listOfEqualities) { if (listOfEqualities.Keys.Contains(currentUserPurpose)) { ReadyAnswer Ans = new ReadyAnswer(); Ans.ListResultAndCF.Add(listOfEqualities[currentUserPurpose], 100); EventAnswerIsReady?.Invoke(Ans, true); } else { ListOfEqualities = listOfEqualities; FlagForChange = true; CurrentUserPurpose = currentUserPurpose; int i; for (i = LastRule; i < ListRules.Count; i++) { ListRules[i].EvetNotEnoughData += NotEnoughDataForRule; if (currentUserPurpose == ListRules[i].Purpose) { if (ListRules[i].Change(ListOfEqualities) == true) { NumbersTrueRules.Add(i); } } ListRules[i].EvetNotEnoughData -= NotEnoughDataForRule; if (FlagForChange == false) { break; } else { LastRule = i + 1; } } if (i == ListRules.Count) { LastRule = 0; Answer(currentUserPurpose); } } }
private void Answer(string purpose) { ReadyAnswer Ans = new ReadyAnswer(); if (NumbersTrueRules.Count == 0) { Ans.ListEquals = ListOfEqualities; Ans.ListResultAndCF.Add("Таких правил не существует", 100); } else { foreach (int numberTrueRule in NumbersTrueRules) { foreach (var equals in ListRules[numberTrueRule].ListOfEqualitiesForRule) { if (!Ans.ListEquals.Keys.Contains(equals.Key)) { Ans.ListEquals.Add(equals.Key, equals.Value); } } foreach (var ResultAndCF in ListRules[numberTrueRule].ListResultAndCF) { if (Ans.ListResultAndCF.Keys.Contains(ResultAndCF.Key)) { Ans.ListResultAndCF[ResultAndCF.Key] = CalculateCF(Ans.ListResultAndCF[ResultAndCF.Key], ResultAndCF.Value); } else { Ans.ListResultAndCF.Add(ResultAndCF.Key, ResultAndCF.Value); } } } } NumbersTrueRules.Clear(); EventAnswerIsReady?.Invoke(Ans, true); }
public void AddResult(string currentPurpose, ReadyAnswer result) { ListReadyAnswers.Add(currentPurpose, result); AddResultToListOfCurrentEqualities(currentPurpose, result.ListResultAndCF); }