Ejemplo n.º 1
0
        private void Initialize()
        {
            dao04       = DAO_Pesquisa04.Instance;
            dao02       = DAO_Pesquisa02.Instance;
            dao03       = DAO_Pesquisa03.Instance;
            daoFiltro   = DAO_Filtro.Instance;
            daoDownload = DAO_Download.Instance;
            //dao07 = DAO_Pesquisa07.Instance;

            MessagingCenter.Subscribe <String>(this, "VerificarExibirDetalhes", (s) =>
            {
                VerificarExibirDetalhes();
            });

            CmdBaixar = new Command(() => {
                DownloadDados();
            });

            CmdDetalhes = new Command(() => {
                VisualizarDetalhes();
            });

            pesquisador = Utils.ObterPesquisadorLogado();

            Title    = pesquisador.razaosocial;
            SubTitle = pesquisador.nome;

            AdicionarControles();

            ObterItensFormulario();
        }
Ejemplo n.º 2
0
        public async Task DownloadRespostas(Int32 idpesquisa06, Int32 idpesquisa01)
        {
            try
            {
                JObject obj = new JObject();
                obj["idpesquisa06"] = idpesquisa06;

                var pesquisador = Utils.ObterPesquisadorLogado();

                obj["idcliente"] = pesquisador.idcliente;

                List <CE_Filtro> filtros = daoFiltro.ObterFiltrosPorPesquisa(idpesquisa01);

                var groupPergunta = filtros.GroupBy(o => o.idpesquisa04);

                JArray jFiltros = new JArray();

                foreach (var item in groupPergunta)
                {
                    List <CE_Filtro> filtrosPergunta = filtros.Where(o => o.idpesquisa04 == item.Key).ToList();

                    JObject objPergunta = new JObject();
                    objPergunta["idpesquisa04"] = item.Key;
                    objPergunta["temopcoes"]    = filtrosPergunta[0].idpesquisa03 != 0;

                    JArray jValores = new JArray();

                    if (filtrosPergunta[0].idpesquisa03 != 0)
                    {
                        foreach (var fp in filtrosPergunta)
                        {
                            JObject objValor = new JObject();
                            objValor["vlresposta"] = fp.vlresposta;

                            jValores.Add(objValor);
                        }
                    }
                    else
                    {
                        JObject objValor = new JObject();
                        objValor["vlresposta"] = filtrosPergunta[0].vlrde;

                        jValores.Add(objValor);

                        objValor = new JObject();
                        objValor["vlresposta"] = filtrosPergunta[0].vlrate;

                        jValores.Add(objValor);
                    }

                    objPergunta["valores"] = jValores;

                    jFiltros.Add(objPergunta);
                }

                obj["filtros"] = jFiltros;

                HttpResponseMessage resposta = await ws.Post("obterRespostasAgrupadasPorOnda", obj);

                String message = await resposta.Content.ReadAsStringAsync();

                if (resposta.IsSuccessStatusCode)
                {
                    DAO_Download daoDownload = DAO_Download.Instance;
                    daoDownload.InserirDownload(new CE_Download()
                    {
                        data = DateTime.Now, idpesquisa01 = idpesquisa01
                    });
                    Utils.SalvarArquivo("onda_" + idpesquisa06 + ".json", message);
                }
                else
                {
                    throw new Exception(message);
                }
            }
            catch (Exception)
            {
                throw new Exception("Não foi possível efetuar o download dos dados.");
            }
        }
Ejemplo n.º 3
0
        public async Task DownloadRespostas(List <Int32> ids, Int32 idpesquisa01)
        {
            try
            {
                String  idsPesquisas06   = "";
                String  strIdsPesquisa06 = "";
                JObject obj = new JObject();


                if (ids.Count == 1)
                {
                    idsPesquisas06 = "(" + ids[0] + ")";
                }
                else
                {
                    idsPesquisas06 = "(";

                    for (int i = 0; i < ids.Count; i++)
                    {
                        if (i != ids.Count - 1)
                        {
                            idsPesquisas06   += ids[i].ToString() + ",";
                            strIdsPesquisa06 += ids[i].ToString() + "_";
                        }
                        else
                        {
                            idsPesquisas06   += ids[i].ToString();
                            strIdsPesquisa06 += ids[i].ToString();
                        }
                    }

                    idsPesquisas06 += ")";
                }

                obj["idsPesquisas06"] = idsPesquisas06;

                List <CE_Filtro> filtros = daoFiltro.ObterFiltrosPorPesquisa(idpesquisa01);

                var groupPergunta = filtros.GroupBy(o => o.idpesquisa04);

                JArray jFiltros = new JArray();

                foreach (var item in groupPergunta)
                {
                    List <CE_Filtro> filtrosPergunta = filtros.Where(o => o.idpesquisa04 == item.Key).ToList();

                    JObject objPergunta = new JObject();
                    objPergunta["idpesquisa04"] = item.Key;
                    objPergunta["temopcoes"]    = filtrosPergunta[0].idpesquisa03 != 0;

                    JArray jValores = new JArray();

                    if (filtrosPergunta[0].idpesquisa03 != 0)
                    {
                        foreach (var fp in filtrosPergunta)
                        {
                            JObject objValor = new JObject();
                            objValor["vlresposta"] = fp.vlresposta;

                            jValores.Add(objValor);
                        }
                    }
                    else
                    {
                        JObject objValor = new JObject();
                        objValor["vlresposta"] = filtrosPergunta[0].vlrde;

                        jValores.Add(objValor);

                        objValor = new JObject();
                        objValor["vlresposta"] = filtrosPergunta[0].vlrate;

                        jValores.Add(objValor);
                    }

                    objPergunta["valores"] = jValores;

                    jFiltros.Add(objPergunta);
                }

                obj["filtros"] = jFiltros;

                HttpResponseMessage resposta = await ws.Post("obterRespostasAgrupadasEntreOndas", obj);

                String message = await resposta.Content.ReadAsStringAsync();

                if (resposta.IsSuccessStatusCode)
                {
                    DAO_Download daoDownload = DAO_Download.Instance;
                    daoDownload.InserirDownload(new CE_Download()
                    {
                        data = DateTime.Now, idpesquisa01 = idpesquisa01
                    });
                    Utils.SalvarArquivo("ondas_" + strIdsPesquisa06 + ".json", message);
                }
                else
                {
                    throw new Exception(message);
                }
            }
            catch (Exception)
            {
                throw new Exception("Não foi possível efetuar o download dos dados.");
            }
        }