public async Task <Boolean> TrocarPagina(int Pagina = 0) { try { if (Status) { throw new Exception("Já existe um pedido sendo realizado, favor aguardar..."); } if (EnviarParametrosSelect.Count == 0) { throw new Exception("A instrução select não foi utilizada ainda."); } Predicate <KeyValuePair <string, string> > FindExcluir = ExcluirChave; EnviarParametrosSelect.RemoveAll(FindExcluir); EnviarParametrosSelect.Add(new KeyValuePair <string, string>("sendPagina", Convert.ToString(Pagina))); FormUrlEncodedContent PacoteEnvio = new FormUrlEncodedContent(EnviarParametrosSelect); TokenCancel = new CancellationToken(); Status = true; //Bloqueia as outras operações que envolvem busca de dados no servidor. ChamadaREST = await PostAsync(Dados_Endereco, PacoteEnvio, TokenCancel); ResultSET = await ChamadaREST.Content.ReadAsStringAsync(); Status = false; //Desbloqueia o sistema para outras busca no servidor. ResultSETJSON = JObject.Parse(ResultSET); ResultSET = null; Boolean Errors = ResultSETJSON["Error"].Value <Boolean>(); if (Errors) { is_error = true; InfoError = new InforError { Modo = ResultSETJSON["Modo"].Value <string>(), Codigo = ResultSETJSON["Codigo"].Value <int>(), Error = ResultSETJSON["Error"].Value <Boolean>(), Mensagem = ResultSETJSON["Mensagem"].Value <string>(), File = ResultSETJSON["File"].Value <string>(), Tracer = ResultSETJSON["Tracer"].Value <string>() }; ResultSETJSON = null; return(false); } else { is_error = false; PacoteTBL = new PacoteSelecionarDados { Modo = ResultSETJSON.Property("Modo"), Error = ResultSETJSON.Property("Error"), NomeTabela = ResultSETJSON.Property("NomeTabela"), ResultadoDados = ResultSETJSON.Property("ResultDados"), Campos = ResultSETJSON.Property("Campos"), ChavesPrimarias = ResultSETJSON.Property("ChavesPrimarias"), Paginacao = ResultSETJSON.Property("Paginacao"), InfoPaginacao = ResultSETJSON.Property("InfoPaginacao"), Botoes = ResultSETJSON.Property("Botoes"), ContadorLinha = ResultSETJSON.Property("ContadorLinha"), OrdemBy = ResultSETJSON.Property("OrdemBy"), Filtros = ResultSETJSON.Property("Filtros"), ShowColumnsIcones = ResultSETJSON.Property("ShowColumnsIcones"), Formato = ResultSETJSON.Property("Formato"), Indexador = ResultSETJSON.Property("Indexador"), TempoTotal = ResultSETJSON.Property("TempoTotal") }; ResultSETJSON = null; return(true); } } catch (Exception ex) { is_error = true; InfoError = new InforError { Modo = "Local", Codigo = 1, Error = true, Mensagem = ex.Message, File = "CamadaDados.cs/SelectTabelaJson", Tracer = ex.StackTrace }; return(false); } }
/** * Busca os dados de uma tabela mapeada no sistema. */ public async Task <Boolean> SelectTabelaJSON() { /** * Limpa os parâmetros antes de adicionar outros */ EnviarParametrosSelect.Clear(); try { if (NomeTabela == null) { throw new Exception("Não foi definido nenhum nome de tabela."); } KeyValuePair <string, string> ChaveDaSessao = new KeyValuePair <string, string>("enviarChaves", Chave_Sessao); KeyValuePair <string, string> Tabelas = new KeyValuePair <string, string>("sendTabelas", NomeTabela); KeyValuePair <string, string> ModoOperacao = new KeyValuePair <string, string>("sendModoOperacao", Select); KeyValuePair <string, string> Dispositivo = new KeyValuePair <string, string>("sendDispositivo", "pc"); EnviarParametrosSelect.Add(ChaveDaSessao); EnviarParametrosSelect.Add(Tabelas); EnviarParametrosSelect.Add(ModoOperacao); EnviarParametrosSelect.Add(Dispositivo); /** * Copias os parâmentros gerais e mantem a variável EnviarParametrosSelect para ser usada pela instrução refreshDados() */ EnviarParametrosSelect.AddRange(EnviarParametros); FormUrlEncodedContent PacoteEnvio = new FormUrlEncodedContent(EnviarParametrosSelect); TokenCancel = new CancellationToken(); Status = true; //Bloqueia as outras operações que envolvem busca de dados no servidor. ChamadaREST = await PostAsync(Dados_Endereco, PacoteEnvio, TokenCancel); ResultSET = await ChamadaREST.Content.ReadAsStringAsync(); Status = false; //Desbloqueia o sistema para outras busca no servidor. ListaFiltrosPadroes.Clear(); EnviarParametros.Clear(); //Limpa todos os filtros. ResultSETJSON = JObject.Parse(ResultSET); ResultSET = null; Boolean Errors = ResultSETJSON["Error"].Value <Boolean>(); if (Errors) { is_error = true; InfoError = new InforError { Modo = ResultSETJSON["Modo"].Value <string>(), Codigo = ResultSETJSON["Codigo"].Value <int>(), Error = ResultSETJSON["Error"].Value <Boolean>(), Mensagem = ResultSETJSON["Mensagem"].Value <string>(), File = ResultSETJSON["File"].Value <string>(), Tracer = ResultSETJSON["Tracer"].Value <string>() }; ResultSETJSON = null; PacoteTBL = new PacoteSelecionarDados { Error = new JProperty("Error", true) }; return(false); } else { is_error = false; PacoteTBL = new PacoteSelecionarDados { Modo = ResultSETJSON.Property("Modo"), Error = ResultSETJSON.Property("Error"), NomeTabela = ResultSETJSON.Property("NomeTabela"), ResultadoDados = ResultSETJSON.Property("ResultDados"), Campos = ResultSETJSON.Property("Campos"), ChavesPrimarias = ResultSETJSON.Property("ChavesPrimarias"), Paginacao = ResultSETJSON.Property("Paginacao"), InfoPaginacao = ResultSETJSON.Property("InfoPaginacao"), Botoes = ResultSETJSON.Property("Botoes"), ContadorLinha = ResultSETJSON.Property("ContadorLinha"), OrdemBy = ResultSETJSON.Property("OrdemBy"), Filtros = ResultSETJSON.Property("Filtros"), ShowColumnsIcones = ResultSETJSON.Property("ShowColumnsIcones"), Formato = ResultSETJSON.Property("Formato"), Indexador = ResultSETJSON.Property("Indexador"), TempoTotal = ResultSETJSON.Property("TempoTotal") }; ResultSETJSON = null; return(true); } } catch (Exception ex) { is_error = true; InfoError = new InforError { Modo = "Local", Codigo = 1, Error = true, Mensagem = ex.Message, File = "CamadaDados.cs/SelectTabelaJson", Tracer = ex.StackTrace }; return(false); } }