public async Task <IActionResult> Index() { try { HttpResponseMessage response = await this._httpClient.GetAsync(urlGetStatistics); if (response.StatusCode == HttpStatusCode.OK) { string textResponse = await response.Content.ReadAsStringAsync(); var report = TextStatsReport.FromJson(textResponse); return(View(new TextStatisticsModel { Succeed = true, Report = report })); } return(View(new TextStatisticsModel { Succeed = false, ErrorText = "HTTP status code " + response.StatusCode })); } catch (Exception ex) { return(View(new TextStatisticsModel { Succeed = false, ErrorText = ex.ToString() })); } }
static void Main(string[] args) { var messages = new TextMessages(); var repo = new TextRepository(); var stats = new TextStatsReport(); Console.WriteLine("Listening for TextScoreTask event, press Ctrl+C to stop..."); messages.ConsumeMessagesInLoop(TextMessages.QueueTextStatistics, TextMessages.ExchangeTextRankCalculated, (model, json) => { TextRankCalculatedMessage message = TextRankCalculatedMessage.FromJson(json); stats.AddRankResult(message.Score); repo.SetStatsReport(stats.ToJson()); }); }