Пример #1
0
        private async void Graph()
        {
            if (this.TemplateSelected == null)
            {
                Alert.Show("Debe seleccionar una plantilla!");
                return;
            }

            try
            {
                UserDialogs.Instance.ShowLoading("Obteniendo datos del reporte...", MaskType.Black);
                if (!await ApiIsOnline())
                {
                    UserDialogs.Instance.HideLoading();
                    Toast.ShowError(AlertMessages.Error);
                    return;
                }
                else
                {
                    if (!TokenValidator.IsValid(TokenGet))
                    {
                        if (!await ApiIsOnline())
                        {
                            UserDialogs.Instance.HideLoading();
                            Toast.ShowError(AlertMessages.Error);
                            return;
                        }
                        else
                        {
                            if (!await GetTokenSuccess())
                            {
                                UserDialogs.Instance.HideLoading();
                                Toast.ShowError(AlertMessages.Error);
                                return;
                            }
                        }
                    }
                    LogExecutionResultQueryValues logExecutionResultQueryValues = new LogExecutionResultQueryValues()
                    {
                        IdTemplate = this.TemplateSelected.IdTemplate,
                        StartDate  = (this.StartDateValue == null ? DateTime.Now : this.StartDateValue.SelectedDate),
                        EndDate    = (this.EndDateValue == null ? DateTime.Now : this.EndDateValue.SelectedDate),
                        Executions = (string.IsNullOrEmpty(this.Executions) ? 100 : Convert.ToInt32(this.Executions)),
                        Monday     = this.WeekDays.Monday,
                        Tuesday    = this.WeekDays.Tuesday,
                        Wednesday  = this.WeekDays.Wednesday,
                        Thursday   = this.WeekDays.Thursday,
                        Friday     = this.WeekDays.Friday,
                        Saturday   = this.WeekDays.Saturday,
                        Sunday     = this.WeekDays.Sunday
                    };
                    Response resultGetResults = await ApiSrv.LogExecutionGetResults(TokenGet.Key, logExecutionResultQueryValues);

                    if (!resultGetResults.IsSuccess)
                    {
                        UserDialogs.Instance.HideLoading();
                        Toast.ShowError(AlertMessages.Error);
                        return;
                    }
                    else
                    {
                        LogExecutionResults = JsonConvert.DeserializeObject <List <LogExecutionResult> >(Crypto.DecodeString(resultGetResults.Data));
                        if (LogExecutionResults.Count == 0)
                        {
                            UserDialogs.Instance.HideLoading();
                            Alert.Show("No hay datos para mostrar!");
                            return;
                        }
                        UserDialogs.Instance.HideLoading();
                        MainViewModel.GetInstance().LogExecutionChart = new LogExecutionChartViewModel(true, LogExecutionResults);
                        await Application.Current.MainPage.Navigation.PushModalAsync(new LogExecutionChartPage());
                    }
                }
            }
            catch //(Exception ex)
            {
                UserDialogs.Instance.HideLoading();
                Toast.ShowError("Ocurrió un error.");
            }
        }
Пример #2
0
 public async Task <Response> LogExecutionGetResults(string accessToken, LogExecutionResultQueryValues QueryValues)
 {
     return(await HttpPost(accessToken, this.ApiControllerSet, ApiMethod.LogExecutionGetResults, QueryValues));
 }