void client_CommandReceived(object sender, EvaluationEventArgs e) { if (e.Command != EvaluationCommand.Value) { return; } WPFUtil.UIProcess(() => ServerPoint = e.Value); }
private void OnEvaluationBegin(object sender, EvaluationEventArgs args) { //this event is called each time a population is evaluated therefore // this will be called after each operator has been invoked try { var stopwatch = new Stopwatch(); stopwatch.Start(); if (args.SolutionsToEvaluate.Count > 0) { //TODO: do this every few generations rather than every generation //refresh the endpoints available and update the evaluationClient accordingly. //EndPoints = _serviceDiscoveryClient.GetActiveServices (ServiceName); //if (this.EndPoints.Count == 0) { // throw new ServiceDiscoveryException ("No server endpoints detected. Check that servers are running and registered with the appropriate IServiceDiscovery service."); //} //Log.Info ("Updating Endpoints from Service Discovery."); //_evaluationClient.UpdateEndpoints (EndPoints); //LogEndpoints (EndPoints); var evaluations = _evaluationClient.Evaluate(args.SolutionsToEvaluate).Result; if (evaluations > 0) { args.Evaluations = evaluations; } else { throw new ApplicationException("No evaluations undertaken, check that a server exists."); } stopwatch.Stop(); Log.Debug(string.Format("Evaluation time = {0} ms.", stopwatch.ElapsedMilliseconds)); } } catch (Exception ex) { while (ex.InnerException != null) { ex = ex.InnerException; } Log.Error(ex); } finally { //prevent the normal evaluation process from taking place args.Cancel = true; } }
protected virtual void OnEvaluate(int questionNumber, string answer) { string userFeedBack = string.Empty; string summaryFeedBack = string.Empty; foreach (Answers a in Answers) { if (questionNumber == a.QuestionNumber) { if (answer == a.CorrectAnswer) { correctCount++; userFeedBack = $"{a.CorrectAnswer} is the correct answer"; summaryFeedBack = "Correct"; } else { wrongCount++; userFeedBack = $"{answer} is incorrect \n {a.CorrectAnswer} is the correct answer"; summaryFeedBack = "Incorrect"; } anwseredQuestionsCount++; successRate = (Convert.ToDouble(correctCount) / Convert.ToDouble(anwseredQuestionsCount)) * 100.00; Summarize s = new Summarize(a.QuestionNumber, a.CorrectAnswer, answer, summaryFeedBack); Summary.Add(s); break; } } EvaluationEventArgs e = new EvaluationEventArgs(correctCount, wrongCount, successRate, userFeedBack); AnswerEvaluated(this, e); if (questionNumber == this.questionNumber) { OnEnd(); } }
public void EvaluateAnswer(object sender, EvaluationEventArgs e) { UpdateStatusPanels(e.CorrectAnswers, e.WrongAnswers, e.SuccessRate); MessageBox.Show(e.Feedback, "Quiz Challenge", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public void Update(object sender, EvaluationEventArgs eventArgs) { Console.WriteLine(eventArgs.text); }