コード例 #1
0
        public async Task EnviarComandoCancelar(ComandoLog paramComando,
                                                Boolean paramEnvia
                                                )
        {
            ModelComando _modelComandos = new ModelComando();

            _tokensource = new CancellationTokenSource();

            if (!_tokensource.IsCancellationRequested)
            {
                ServiceResult <Boolean> comando = new ServiceResult <Boolean>();
                try
                {
                    if (paramEnvia)
                    {
                        comando = await _modelComandos.ComandoCancelar(
                            paramComando.IdComandoLog
                            , _tokensource.Token
                            );
                    }
                }
                catch
                {
                    comando.MessageError = "Exception";
                }
                finally
                {
                    await _messageService.ShowAlertAsync(AppResources.CancelarComandoSucesso);
                }
            }
        }
コード例 #2
0
        //TODO: Refazer Metodo
        public override void ListRefresh(object obj)
        {
            ModelComando _modelComandos = new ModelComando();

            this.List_IsRefreshing = true;

            try
            {
                _tokensource = new CancellationTokenSource();
                Task.Run(async() =>
                {
                    try
                    {
                        ListEndRefresh = false;

                        ServiceResult <List <ComandoLog> > resultComandos =
                            await _modelComandos.ListComandosEnviadosAsync(
                                _tokensource.Token
                                );

                        if (!_tokensource.IsCancellationRequested)
                        {
                            App.ListComandosSource = resultComandos.Data;

                            UpdateToken(resultComandos.RefreshToken);

                            Device.BeginInvokeOnMainThread(() =>
                            {
                                try
                                {
                                    if (!String.IsNullOrWhiteSpace(resultComandos.MessageError))
                                    {
                                        ShowErrorAlert(resultComandos.MessageError);
                                    }
                                    _list_SourceCompleta   = resultComandos.Data;
                                    this.List_Source       = _list_SourceCompleta;
                                    this.List_IsRefreshing = false;
                                    Buscar();
                                }
                                catch (Exception)
                                {
                                    ShowErrorAlert("Exception");
                                    this.List_IsRefreshing = false;
                                }
                            });
                        }
                    }
                    catch (Exception)
                    {
                        ShowErrorAlert("Exception");
                        this.List_IsRefreshing = false;
                    }
                }, _tokensource.Token);
            }
            catch (Exception)
            {
                ShowErrorAlert("Exception");
                this.List_IsRefreshing = false;
            }
        }
コード例 #3
0
        public void ListRefreshAction()
        {
            ModelComando _modelComandos = new ModelComando();

            this.List_IsRefreshing = true;

            _viewComandos.ExibirLoad();

            ServiceResult <HistoricoComandoRespost> resultComandos = new ServiceResult <HistoricoComandoRespost>();

            try
            {
                _tokensource = new CancellationTokenSource();
                Task.Run(async() =>
                {
                    try
                    {
                        ListEndRefresh = false;

                        resultComandos = await _modelComandos.ListCommandHistory(
                            _actualPage
                            , _pageSize
                            , _tokensource.Token
                            );
                    }
                    catch (Exception)
                    {
                        resultComandos.MessageError = "Exception";
                        resultComandos.IsValid      = false;
                    }

                    ListRefresh_Finish(resultComandos);
                }, _tokensource.Token);
            }
            catch (Exception)
            {
                resultComandos.MessageError = "Exception";
                resultComandos.IsValid      = false;
                ListRefresh_Finish(resultComandos);
            }
        }
コード例 #4
0
        public async Task <Boolean> ExibeMenuComandos()
        {
            ModelComando _modelComandos = new ModelComando();

            Boolean retorno = false;

            ServiceResult <List <ComandoDto> > result = new ServiceResult <List <ComandoDto> >();

            try
            {
                _tokensource = new CancellationTokenSource();

                try
                {
                    result = await _modelComandos.ListComandoRastreador(
                        PainelResumoListViewSource.IdRastreador
                        , _tokensource.Token
                        );

                    if (result.Data != null && result.Data.Count > 0)
                    {
                        retorno = true;
                    }
                }
                catch
                {
                    retorno = false;
                }
            }
            catch
            {
                retorno = false;
            }

            return(retorno);
        }