public async Task <IEnumerable <ChartLookup> > GetLookups(ChartSetting item) { try { using (HttpClient client = new HttpClient()) { var msg = await client.GetStringAsync($"{connection}/Owner={item.Id}"); return(JsonConvert.DeserializeObject <IEnumerable <ChartLookup> >(msg)); } } catch (Exception x) { _errorInfo.ShowError(x); } return(await Task.FromResult(new ChartLookup[] { new ChartLookup { Id = 1, Date = DateTime.Now - TimeSpan.FromDays(1), Value = 250 }, new ChartLookup { Id = 2, Date = DateTime.Now, Value = 350 }, new ChartLookup { Id = 3, Date = DateTime.Now + TimeSpan.FromDays(1), Value = 150 } })); }
public async Task LoadAsync(ChartViewItem item) { try { using (var col = Items.LockChangedEvent()) { StopTicker(); CreateSeries(item); Items.Clear(); IEnumerable <ChartLookup> values = await _service.GetLookups(item.Model); foreach (var val in values) { Series[0].Values.Add(val.Value); Labels.Add(val.Date.ToShortDateString()); Items.Add(val); } } if (Items.Count > _ItemsCount) { ProcessTicker(); } } catch (Exception x) { _errorInfo.ShowError(x); } }
public async Task DeleteAsync(ChartSetting model) { try { using (HttpClient client = new HttpClient()) { var msg = await client.DeleteAsync($"{connection}/{model.Id}"); var md = JsonConvert.DeserializeObject <ChartSetting>(await msg.Content.ReadAsStringAsync()); } } catch (Exception x) { _infoService.ShowError(x); } }
private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { var error = "Unexpected error occured. Please inform the admin." + Environment.NewLine + e.Exception.Message; errorInfoService.ShowError(error, "Unexpected error"); e.Handled = true; }