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

                UserDialogs.Instance.ShowLoading("Obteniendo lotes...", MaskType.Black);
                this.EventSelected = new PickerEventItem();
                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;
                            }
                        }
                    }
                    LogExecutionDelayLotQueryValues logExecutionDelayLotQueryValues = new LogExecutionDelayLotQueryValues()
                    {
                        IdLog = this.TemplateSelected.IdTemplate
                    };
                    Response resultGetLots = await ApiSrv.LogExecutionDelayGetLots(TokenGet.Key, logExecutionDelayLotQueryValues);

                    if (!resultGetLots.IsSuccess)
                    {
                        UserDialogs.Instance.HideLoading();
                        Toast.ShowError(AlertMessages.Error);
                        return;
                    }
                    else
                    {
                        LogExecutionDelayLots = JsonConvert.DeserializeObject <List <LogExecutionDelayLot> >(Crypto.DecodeString(resultGetLots.Data));
                        if (PickerLotItems == null)
                        {
                            PickerLotItems = new ObservableCollection <PickerLotItem>();
                        }
                        else
                        {
                            PickerLotItems.Clear();
                        }
                        foreach (LogExecutionDelayLot logExecutionDelayLot in LogExecutionDelayLots)
                        {
                            PickerLotItems.Add(new PickerLotItem()
                            {
                                IdLot   = logExecutionDelayLot.IdLot,
                                NameLot = logExecutionDelayLot.Lot
                            });
                        }
                        UserDialogs.Instance.HideLoading();
                    }
                }
            }
            catch //(Exception ex)
            {
                UserDialogs.Instance.HideLoading();
                Toast.ShowError(AlertMessages.Error);
            }
        }
Exemplo n.º 2
0
 public async Task <Response> LogExecutionDelayGetLots(string accessToken, LogExecutionDelayLotQueryValues QueryValues)
 {
     return(await HttpPost(accessToken, this.ApiControllerSet, ApiMethod.LogExecutionDelayGetLots, QueryValues));
 }