Esempio n. 1
0
        private async void Graph()
        {
            if (this.TemplateSelected == null)
            {
                Alert.Show("Debe seleccionar una plantilla!");
                return;
            }
            if (this.LogSelected == null)
            {
                Alert.Show("Debe seleccionar una bitácora!");
                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;
                            }
                        }
                    }
                    LotAndCommandResultQueryValues lotAndCommandResultQueryValues = new LotAndCommandResultQueryValues()
                    {
                        IdTemplate = this.TemplateSelected.IdTemplate,
                        IdLog      = this.LogSelected.IdLog,
                        IdLot      = (this.LotSelected != null ? this.LotSelected.IdLot : 0),
                        IdCommand  = (this.CommandSelected != null ? this.CommandSelected.IdCommand : 0),
                        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.LotAndCommandGetResults(TokenGet.Key, lotAndCommandResultQueryValues);

                    if (!resultGetResults.IsSuccess)
                    {
                        UserDialogs.Instance.HideLoading();
                        Toast.ShowError(AlertMessages.Error);
                        return;
                    }
                    else
                    {
                        LotAndCommandResults = JsonConvert.DeserializeObject <List <LotAndCommandResult> >(Crypto.DecodeString(resultGetResults.Data));
                        if (LotAndCommandResults.Count == 0)
                        {
                            UserDialogs.Instance.HideLoading();
                            Alert.Show("No hay datos para mostrar!");
                            return;
                        }
                        UserDialogs.Instance.HideLoading();
                        MainViewModel.GetInstance().LotAndCommandChart = new LotAndCommandChartViewModel(true, LotAndCommandResults);
                        await Application.Current.MainPage.Navigation.PushModalAsync(new LotAndCommandChartPage());
                    }
                }
            }
            catch //(Exception ex)
            {
                UserDialogs.Instance.HideLoading();
                Toast.ShowError("Ocurrió un error.");
            }
        }
Esempio n. 2
0
 public async Task <Response> LotAndCommandGetResults(string accessToken, LotAndCommandResultQueryValues QueryValues)
 {
     return(await HttpPost(accessToken, this.ApiControllerSet, ApiMethod.LotAndCommandGetResults, QueryValues));
 }