private async void DoRequest() { _output = String.Empty; RaisePropertyChanged(nameof(Output)); Status.Message = "Request is Pending ...."; Status.IsSuccess = null; _requestCommand.RaiseCanExecuteChanged(); DateTime start = DateTime.Now; try { string json = await CDOService.StartRequestUrl(Url); Output = JToken.Parse(json).ToString(Newtonsoft.Json.Formatting.Indented); Status.IsSuccess = true; Status.Message = $"Request completed in {(DateTime.Now - start).TotalSeconds.ToString("F2")} seconds"; Settings.Default.ApiEx_Endpoint = _selectedEnpoint; Settings.Default.ApiEx_Parameters = _parameters; Settings.Default.Save(); SaveLastOutput(); } catch (Exception ex) { Status.IsSuccess = false; Status.Message = ex.Message; } _requestCommand.RaiseCanExecuteChanged(); }
private void UpdateUrl() { string endpoint = _selectedEnpoint.Replace(" ", string.Empty).ToLower(); string p = Parameters; if (p == null) { p = String.Empty; } if (p.StartsWith("?")) { p = p.Substring(1); // remove '?' if user typed it } if (IncludePaging) { p = CDOService.ApplyPaging(p, _pagingModel.Offset, _pagingModel.Limit); } Url = string.Concat(CDOService.BasePath, endpoint, "?", p); }
private async void ApplyYear() { Output = String.Empty; SetStatus("Request Pending ....", null); string ext = $"data?datasetid=GHCND&datatypeid=TMAX,TMIN&stationid={SelectedStation.Id}&startdate={SelectedYear}-01-01&enddate={SelectedYear}-12-31&limit=1000"; Url = ext; DateTime start = DateTime.Now; try { string json = await CDOService.StartRequest(ext); Output = JToken.Parse(json).ToString(Newtonsoft.Json.Formatting.Indented); SetStatus($"Request completed in {(DateTime.Now - start).TotalSeconds.ToString("F3")} seconds."); SaveState(); UpdatePlot(json); } catch (Exception ex) { SetStatus(ex.Message, true); } }