Exemple #1
0
        private async void SelectedTemplateItemChange()
        {
            try
            {
                if (this.TemplateSelected == null)
                {
                    return;
                }

                UserDialogs.Instance.ShowLoading("Obteniendo bitácoras...", 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;
                            }
                        }
                    }
                    LotAndCommandLogQueryValues lotAndCommandLogQueryValues = new LotAndCommandLogQueryValues()
                    {
                        IdTemplate = this.TemplateSelected.IdTemplate
                    };
                    Response resultGetLogs = await ApiSrv.LotAndCommandGetLogs(TokenGet.Key, lotAndCommandLogQueryValues);

                    if (!resultGetLogs.IsSuccess)
                    {
                        UserDialogs.Instance.HideLoading();
                        Toast.ShowError(AlertMessages.Error);
                        return;
                    }
                    else
                    {
                        LotAndCommandLogs = JsonConvert.DeserializeObject <List <LotAndCommandLog> >(Crypto.DecodeString(resultGetLogs.Data));
                        if (PickerLogItems == null)
                        {
                            PickerLogItems = new ObservableCollection <PickerLogItem>();
                        }
                        else
                        {
                            PickerLogItems.Clear();
                        }
                        foreach (LotAndCommandLog lotAndCommandLog in LotAndCommandLogs)
                        {
                            PickerLogItems.Add(new PickerLogItem()
                            {
                                IdLog   = lotAndCommandLog.IdLog,
                                NameLog = lotAndCommandLog.Log
                            });
                        }
                        UserDialogs.Instance.HideLoading();
                    }
                }
            }
            catch (Exception ex)
            {
                UserDialogs.Instance.HideLoading();
                Toast.ShowError(AlertMessages.Error);
            }
        }
Exemple #2
0
        private async void LogFinishedCheckedChange()
        {
            try
            {
                if (!this.LogFinished)
                {
                    UserDialogs.Instance.ShowLoading("Obteniendo bitácoras...", 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;
                                }
                            }
                        }
                        OperationsLogLogQueryValues operationsLogLogQueryValues = new OperationsLogLogQueryValues()
                        {
                            Finished = false
                        };
                        Response resultLogs = await ApiSrv.OperationsLogGetLogs(TokenGet.Key, operationsLogLogQueryValues);

                        if (!resultLogs.IsSuccess)
                        {
                            UserDialogs.Instance.HideLoading();
                            Toast.ShowError(AlertMessages.Error);
                            return;
                        }
                        else
                        {
                            OperationsLogLogs = JsonConvert.DeserializeObject <List <OperationsLogLog> >(Crypto.DecodeString(resultLogs.Data));
                            if (PickerLogItems == null)
                            {
                                PickerLogItems = new ObservableCollection <PickerLogItem>();
                            }
                            else
                            {
                                PickerLogItems.Clear();
                            }

                            foreach (OperationsLogLog item in OperationsLogLogs)
                            {
                                PickerLogItems.Add(new PickerLogItem()
                                {
                                    IdLog       = item.IdLog,
                                    NameDisplay = item.NameLog
                                });
                                UserDialogs.Instance.HideLoading();
                            }
                        }
                    }
                }
                else
                {
                    UserDialogs.Instance.ShowLoading("Obteniendo bitácoras...", 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;
                                }
                            }
                        }
                        OperationsLogLogQueryValues operationsLogLogQueryValues = new OperationsLogLogQueryValues()
                        {
                            Finished = true
                        };
                        Response resultLogs = await ApiSrv.OperationsLogGetLogs(TokenGet.Key, operationsLogLogQueryValues);

                        if (!resultLogs.IsSuccess)
                        {
                            UserDialogs.Instance.HideLoading();
                            Toast.ShowError(AlertMessages.Error);
                            return;
                        }
                        else
                        {
                            OperationsLogLogs = JsonConvert.DeserializeObject <List <OperationsLogLog> >(Crypto.DecodeString(resultLogs.Data));
                            if (PickerLogItems == null)
                            {
                                PickerLogItems = new ObservableCollection <PickerLogItem>();
                            }
                            else
                            {
                                PickerLogItems.Clear();
                            }

                            foreach (OperationsLogLog item in OperationsLogLogs)
                            {
                                PickerLogItems.Add(new PickerLogItem()
                                {
                                    IdLog       = item.IdLog,
                                    NameDisplay = item.NameLog
                                });
                                UserDialogs.Instance.HideLoading();
                            }
                        }
                    }
                }
            }
            catch //(Exception ex)
            {
                UserDialogs.Instance.HideLoading();
                Toast.ShowError(AlertMessages.Error);
            }
        }