Exemplo n.º 1
0
        private async void Report()
        {
            if (this.LogItemSelected == 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;
                            }
                        }
                    }
                    OperationsLogResultQueryValues operationsLogResultQueryValues = new OperationsLogResultQueryValues()
                    {
                        IdLog         = this.LogItemSelected.IdLog,
                        IdUser        = (this.OperatorItemSelected != null ? this.OperatorItemSelected.IdUser : ""),
                        IdStatus      = (this.StatusItemSelected != null ? this.StatusItemSelected.IdStatus : ""),
                        IdEnvironment = (this.EnvironmentItemSelected != null ? this.EnvironmentItemSelected.IdEnvironment : 0),
                        IdService     = (this.ServiceItemSelected != null ? this.ServiceItemSelected.IdService : 0),
                        IdLot         = (this.LotItemSelected != null ? this.LotItemSelected.IdLot : 0),
                        IdCommand     = (this.CommandItemSelected != null ? this.CommandItemSelected.IdCommand : 0),
                        StartDateFrom = (this.StartDateFromValue == null ? DateTime.Now : this.StartDateFromValue.SelectedDate),
                        StartDateTo   = (this.StartDateToValue == null ? DateTime.Now : this.StartDateToValue.SelectedDate),
                        EndDateFrom   = (this.EndDateFromValue == null ? DateTime.Now : this.EndDateFromValue.SelectedDate),
                        EndDateTo     = (this.EndDateToValue == null ? DateTime.Now : this.EndDateToValue.SelectedDate),
                    };
                    Response resultGetResults = await ApiSrv.OperationsLogGetResults(TokenGet.Key, operationsLogResultQueryValues);

                    if (!resultGetResults.IsSuccess)
                    {
                        UserDialogs.Instance.HideLoading();
                        Toast.ShowError(AlertMessages.Error);
                        return;
                    }
                    else
                    {
                        OperationsLogResults = JsonConvert.DeserializeObject <List <OperationsLogResult> >(Crypto.DecodeString(resultGetResults.Data));
                        if (OperationsLogResults.Count == 0)
                        {
                            UserDialogs.Instance.HideLoading();
                            Alert.Show("No hay datos para mostrar!");
                            return;
                        }
                        if (OperationsLogReportItems == null)
                        {
                            OperationsLogReportItems = new ObservableCollection <OperationsLogReportItem>();
                        }
                        else
                        {
                            OperationsLogReportItems.Clear();
                        }
                        foreach (OperationsLogResult item in OperationsLogResults)
                        {
                            OperationsLogReportItems.Add(new OperationsLogReportItem()
                            {
                                IdLog           = item.IdLog,
                                IdInstance      = item.IdInstance,
                                IdLot           = item.IdLot,
                                IdCommand       = item.IdCommand,
                                IdUser          = item.IdUser,
                                Environment     = item.Environment,
                                Service         = item.Service,
                                CodeCommand     = item.CodeCommand,
                                NameCommand     = item.NameCommand,
                                Product         = item.Product,
                                StartDate       = (item.StartDate != null) ? ((DateTime)item.StartDate) : new DateTime(),
                                EndDate         = (item.EndDate != null) ? ((DateTime)item.EndDate) : new DateTime(),
                                Duration        = item.Duration,
                                Status          = item.Status,
                                IPClient        = item.IPClient,
                                NameLog         = item.NameLog,
                                InstanceNumber  = item.InstanceNumber,
                                CodeLot         = item.CodeLot,
                                NameLot         = item.NameLot,
                                Source          = item.Source,
                                Critical        = item.Critical,
                                StartDateString = (item.StartDate != null) ? ((DateTime)item.StartDate).ToString(DateTimeFormatString.LatinDate24Hours) : "",
                                EndDateString   = (item.EndDate != null) ? ((DateTime)item.EndDate).ToString(DateTimeFormatString.LatinDate24Hours) : ""
                            });
                        }
                        UserDialogs.Instance.HideLoading();
                        MainViewModel.GetInstance().OperationsLogReport = new OperationsLogReportViewModel(true, OperationsLogReportItems);
                        await Application.Current.MainPage.Navigation.PushModalAsync(new OperationsLogReportPage());
                    }
                }
            }
            catch (Exception ex)
            {
                UserDialogs.Instance.HideLoading();
                Toast.ShowError("Ocurrió un error.");
            }
        }
Exemplo n.º 2
0
 private async void Status()
 {
     MainViewModel.GetInstance().StatusInfoLogInquiries = new StatusInfoLogInquiriesViewModel();
     await Application.Current.MainPage.Navigation.PushModalAsync(new StatusInfoLogInquiriesPage());
 }