Example #1
0
        public PesquisaViewModel()
        {
            // _pesquisaCPFCNPJ = Global.Investidor;
            pesquisaBusiness = new PesquisaBusiness();

            PesquisaCPFCNPJ = new PesquisaCPFCNPJModel();

            PesquisarClickedCommand = new Command(() => {
                var mensagem = "Consulta Realizada com Sucesso";
                try
                {
                    ArpenspModel arpenspModel = pesquisaBusiness.Arpensp(PesquisaCPFCNPJ.CPFCNPJ);
                    CagedModel cagedModel     = pesquisaBusiness.Caged(PesquisaCPFCNPJ.CPFCNPJ);
                    JucespModel jucespModel   = pesquisaBusiness.Jucesp(PesquisaCPFCNPJ.CPFCNPJ);
                    CensecModel censecModel   = pesquisaBusiness.Censec(PesquisaCPFCNPJ.CPFCNPJ);
                    SielModel sielModel       = pesquisaBusiness.Siel(PesquisaCPFCNPJ.CPFCNPJ);
                    SivecModel sivecModel     = pesquisaBusiness.Sivec(PesquisaCPFCNPJ.CPFCNPJ);
                    DetranModel detranModel   = pesquisaBusiness.Detran(PesquisaCPFCNPJ.CPFCNPJ);
                } catch (Exception ex) {
                    mensagem = "Não foi possível consultar os dados. Verifique sua conexão! \n Detalhe: " +
                               ex.Message;
                }

                DependencyService.Get <IMessage>().ShortAlert(mensagem);
                MessagingCenter.Send <PesquisaViewModel>(this, "PesquisaSucesso");
            });
        }
 public void Insert(CensecModel censecModel)
 {
     using (context)
     {
         context.Censec.Add(censecModel);
         context.SaveChanges();
     }
 }
Example #3
0
        public CensecModel Censec(int cpfcnpj)
        {
            var censec = new Service.PesquisaService().Censec(cpfcnpj);

            CensecModel censecModel = JsonConvert.DeserializeObject <CensecModel>(censec);

            //variavel global
            Global.Censec = censecModel;

            return(censecModel);
        }
Example #4
0
        public string Censec(PesquisaCPFCNPJ pesquisaCPFCNPJ)
        {
            var options = new ChromeOptions();

            options.AddArguments("headless");
            using (IWebDriver driver = new ChromeDriver("C:/inetpub/wwwroot/wwwroot", options))
            //using (IWebDriver driver = new ChromeDriver(options))
            {
                Actions builder = new Actions(driver);

                driver.Navigate().GoToUrl("http://ec2-18-231-116-58.sa-east-1.compute.amazonaws.com/censec/login.html");

                driver.FindElement(By.Id("EntrarButton")).Click();
                driver.FindElement(By.Id("menucentrais")).Click();
                driver.FindElement(By.XPath("//*[@id='ctl00_CESDILi']/a")).Click();
                driver.FindElement(By.XPath("//*[@id='ctl00_CESDIConsultaAtoHyperLink']")).Click();
                driver.FindElement(By.Id("ctl00_ContentPlaceHolder1_DocumentoTextBox")).SendKeys(pesquisaCPFCNPJ.CPFCNPJ.ToString());
                driver.FindElement(By.ClassName("BT_Buscar")).SendKeys(Keys.Enter);

                driver.FindElement(By.XPath("//*[@id='ctl00_ContentPlaceHolder1_ResultadoBuscaGeralPanel']/div[2]/div[1]/div/table/tbody/tr[2]/td[1]/input")).Click();
                driver.FindElement(By.ClassName("BT_Buscar")).SendKeys(Keys.Enter);

                string carga  = driver.FindElement(By.XPath("/html/body/form/div[5]/div/div[3]/div[2]/div[3]/div[1]/div/input")).GetAttribute("value");
                string mes    = driver.FindElement(By.Id("ctl00_ContentPlaceHolder1_MesReferenciaDropDownList")).Text;
                string ano    = driver.FindElement(By.Id("ctl00_ContentPlaceHolder1_AnoReferenciaDropDownList")).Text;
                string ato    = driver.FindElement(By.Id("ctl00_ContentPlaceHolder1_TipoAtoDropDownList")).GetAttribute("value");
                string diaAto = driver.FindElement(By.XPath("/html/body/form/div[5]/div/div[3]/div[2]/div[3]/div[6]/div/input[1]")).GetAttribute("value");
                string mesAto = driver.FindElement(By.XPath("/html/body/form/div[5]/div/div[3]/div[2]/div[3]/div[6]/div/input[3]")).GetAttribute("value");
                string anoAto = driver.FindElement(By.XPath("/html/body/form/div[5]/div/div[3]/div[2]/div[3]/div[6]/div/input[4]")).GetAttribute("value");
                string livro  = driver.FindElement(By.XPath("/html/body/form/div[5]/div/div[3]/div[2]/div[3]/div[7]/div/input[1]")).GetAttribute("value");
                string folha  = driver.FindElement(By.XPath("/html/body/form/div[5]/div/div[3]/div[2]/div[3]/div[9]/div/input[1]")).GetAttribute("value");

                string tabelaPartes = driver.FindElement(By.XPath("/html/body/form/div[5]/div/div[3]/div[2]/div[6]/div[1]/div/div/table/tbody")).Text;

                string uf        = driver.FindElement(By.Id("ctl00_ContentPlaceHolder1_DadosCartorio_CartorioUFTextBox")).GetAttribute("value");
                string municipio = driver.FindElement(By.Id("ctl00_ContentPlaceHolder1_DadosCartorio_CartorioMunicipioTextBox")).GetAttribute("value");
                string cartorio  = driver.FindElement(By.Id("ctl00_ContentPlaceHolder1_DadosCartorio_CartorioNomeTextBox")).GetAttribute("value");
                string tabela    = driver.FindElement(By.XPath("//*[@id='ctl00_ContentPlaceHolder1_DadosCartorio_DivTelefonesCartorioListView']/div/table")).Text;

                string[] strsplit = tabelaPartes.Replace("\r\n", ":").Replace("  ", ":").Split(':');
                var      nomes    = "";
                var      cpfCnpj  = "";
                var      quali    = "";
                var      table    = driver.FindElement(By.XPath("/html/body/form/div[5]/div/div[3]/div[2]/div[6]/div[1]/div/div/table/tbody"));
                var      rows     = table.FindElements(By.TagName("tr"));
                var      count    = rows.Count;

                //For para pegar os nomes
                for (int i = 0; i < count * 3; i += 3)
                {
                    nomes = nomes + " |" + strsplit[i];
                }

                //For para pegar os CPFs/CNPJs
                for (int i = 1; i < count * 3; i += 3)
                {
                    cpfCnpj = cpfCnpj + " | " + strsplit[i];
                }

                //For para pegar as qualidades
                for (int i = 2; i < count * 3; i += 3)
                {
                    quali = quali + " | " + strsplit[i];
                }

                string[] strsplit2 = tabela.Replace("\r\n", ":").Replace("  ", ":").Split(':');
                var      telefones = "";
                var      tipos     = "";
                var      contatos  = "";
                var      status    = "";
                var      table2    = driver.FindElement(By.XPath("/html/body/form/div[5]/div/div[3]/div[2]/div[7]/div[2]/div[2]/div/table/tbody"));
                var      rows2     = table2.FindElements(By.TagName("tr"));
                var      count2    = rows2.Count;

                //For para pegar os telefones
                for (int i = 0; i < count2 * 5; i += 5)
                {
                    telefones = telefones + " |" + strsplit2[i];
                }

                //For para pegar os tipos
                for (int i = 1; i < count2 * 5; i += 5)
                {
                    tipos = tipos + " |" + strsplit2[i];
                }

                //For para pegar os contatos
                for (int i = 3; i < count2 * 5; i += 5)
                {
                    contatos = contatos + " |" + strsplit2[i];
                }

                //For para pegar os status
                for (int i = 4; i < count2 * 5; i += 5)
                {
                    status = status + " |" + strsplit2[i];
                }

                CensecModel objCen = new CensecModel();
                objCen.CNPJCensec      = long.Parse(pesquisaCPFCNPJ.CPFCNPJ.ToString());
                objCen.Carga           = carga.Trim();
                objCen.Mes             = mes.Trim();
                objCen.Ano             = ano.Trim();
                objCen.Ato             = ato.Replace("\r\n", "").Trim();
                objCen.DiaAto          = diaAto.Trim();
                objCen.MesAto          = mesAto.Trim();
                objCen.AnoAto          = anoAto.Trim();
                objCen.Livro           = livro.Trim();
                objCen.Folha           = folha.Trim();
                objCen.NomesPartes     = nomes.Trim();
                objCen.CpfCnpjPartes   = cpfCnpj.Trim();
                objCen.QualidadePartes = quali.Trim();
                objCen.UF                   = uf.Trim();
                objCen.Municipio            = municipio.Trim();
                objCen.Cartorio             = cartorio.Trim();
                objCen.TelefoneCartorio     = telefones.Replace("_", "").Trim();
                objCen.TipoTelefoneCartorio = tipos.Trim();
                objCen.ContatoCartorio      = contatos.Trim();
                objCen.StatusCartorio       = status.Trim();

                censecRepository.Insert(objCen);

                string objjsonData = JsonConvert.SerializeObject(objCen);

                //System.IO.File.WriteAllText(@"C:\Users\favar\Desktop\Texto\Censec.txt", objjsonData);

                return(objjsonData);
            }
        }
Example #5
0
        public override CrawlerStatus Execute(out object result)
        {
            try
            {
                using (var driver = WebDriverService.CreateWebDriver(WebBrowser.Firefox))
                {
                    driver.Navigate().GoToUrl(@"http://ec2-18-231-116-58.sa-east-1.compute.amazonaws.com/censec/login.html");

                    // page 1
                    driver.FindElement(By.Id("LoginTextBox")).SendKeys(_usuario);
                    driver.FindElement(By.Id("LoginTextBox")).SendKeys(_usuario);
                    driver.FindElement(By.Id("SenhaTextBox")).SendKeys(_senha);
                    driver.FindElement(By.Id("EntrarButton")).Click();


                    // page 2
                    Actions builder = new Actions(driver);

                    //desfazer o menu ja aberto
                    var saifora = driver.FindElement(By.Id("menuadministrativo"));
                    builder.MoveToElement(saifora).Build().Perform();

                    var menuDropDown = driver.FindElement(By.Id("menucentrais"));
                    builder.MoveToElement(menuDropDown).Build().Perform();

                    var menuDropDown2 = driver.FindElement(By.Id("ctl00_CESDILi"));
                    builder.MoveToElement(menuDropDown2).Build().Perform();

                    driver.FindElement(By.Id("ctl00_CESDIConsultaAtoHyperLink")).Click();

                    // page 3
                    driver.FindElement(By.Id("ctl00_ContentPlaceHolder1_DocumentoTextBox")).SendKeys(_cpf);
                    driver.FindElement(By.Id("ctl00_ContentPlaceHolder1_BuscarButton")).Click();


                    // page 4
                    driver.FindElement(By.CssSelector("tr.linha1Tabela:nth-child(2) > td:nth-child(1) > input:nth-child(1)")).Click();
                    driver.FindElement(By.Id("ctl00_ContentPlaceHolder1_VisualizarButton")).Click();


                    // page 5
                    //recuperar dados
                    var nome      = "";
                    var cpfCnpj   = "";
                    var qualidade = "";
                    var telefone  = "";
                    var tipoTel   = "";
                    var ramal     = "";
                    var contato   = "";
                    var status    = "";

                    //dados dos campos

                    var resultadoCarga            = driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_CodigoTextBox")).GetAttribute("value");
                    var resultadoMes              = driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_MesReferenciaDropDownList")).Text;
                    var resultadoAno              = driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_AnoReferenciaDropDownList")).Text;
                    var resultadoAto              = driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_TipoAtoDropDownList")).Text;
                    var resultadoDiaAto           = driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_DiaAtoTextBox")).GetAttribute("value");
                    var resultadoMesAto           = driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_MesAtoTextBox")).GetAttribute("value");
                    var resultadoAnoAto           = driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_AnoAtoTextBox")).GetAttribute("value");
                    var resultadoLivro            = driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_LivroTextBox")).GetAttribute("value");
                    var resultadoComplementoLivro = driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_LivroComplementoTextBox")).GetAttribute("value");
                    var resultadoFolha            = driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_FolhaTextBox")).GetAttribute("value");
                    var resultadoComplementoFolha = driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_FolhaComplementoTextBox")).GetAttribute("value");

                    //dados da tabela
                    var resultados = driver.FindElements(By.CssSelector("#ctl00_ContentPlaceHolder1_PartesUpdatePanel > table > tbody > tr"));
                    for (int i = 1; i <= resultados.Count; i++)
                    {
                        nome      += driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_PartesUpdatePanel > table > tbody > tr:nth-child(" + i + ") > td:nth-child(2)")).Text + "\n";
                        cpfCnpj   += driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_PartesUpdatePanel > table > tbody > tr:nth-child(" + i + ") > td:nth-child(3)")).Text + "\n";
                        qualidade += driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_PartesUpdatePanel > table > tbody > tr:nth-child(" + i + ") > td:nth-child(4)")).Text + "\n";
                    }

                    var resultadoUf        = driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_DadosCartorio_CartorioUFTextBox")).GetAttribute("value");
                    var resultadoMunicipio = driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_DadosCartorio_CartorioMunicipioTextBox")).GetAttribute("value");
                    var resultadoCartorio  = driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_DadosCartorio_CartorioNomeTextBox")).GetAttribute("value");

                    var resultados2 = driver.FindElements(By.CssSelector("#ctl00_ContentPlaceHolder1_DadosCartorio_DivTelefonesCartorioListView > div > table > tbody > tr"));
                    for (int i = 1; i <= resultados2.Count; i++)
                    {
                        telefone += driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_DadosCartorio_DivTelefonesCartorioListView > div > table > tbody > tr:nth-child(" + i + ") > td:nth-child(1)")).Text + "\n";
                        tipoTel  += driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_DadosCartorio_DivTelefonesCartorioListView > div > table > tbody > tr:nth-child(" + i + ") > td:nth-child(2)")).Text + "\n";
                        ramal    += driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_DadosCartorio_DivTelefonesCartorioListView > div > table > tbody > tr:nth-child(" + i + ") > td:nth-child(3)")).Text + "\n";
                        contato  += driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_DadosCartorio_DivTelefonesCartorioListView > div > table > tbody > tr:nth-child(" + i + ") > td:nth-child(4)")).Text + "\n";
                        status   += driver.FindElement(By.CssSelector("#ctl00_ContentPlaceHolder1_DadosCartorio_DivTelefonesCartorioListView > div > table > tbody > tr:nth-child(" + i + ") > td:nth-child(5)")).Text + "\n";
                    }

                    #region Objeto com os dados capturados
                    var resultado = new CensecModel
                    {
                        Carga     = resultadoCarga,
                        Data      = resultadoMes + "/" + resultadoAno,
                        Ato       = resultadoAto,
                        DataAto   = resultadoDiaAto + "/" + resultadoMesAto + "/" + resultadoAnoAto,
                        Livro     = resultadoLivro + "-" + resultadoComplementoLivro,
                        Folha     = resultadoFolha + "-" + resultadoComplementoFolha,
                        Nomes     = nome,
                        CpfsCnpjs = cpfCnpj,
                        Qualidads = qualidade,
                        Uf        = resultadoUf,
                        Municipio = resultadoMunicipio,
                        Cartorio  = resultadoCartorio,
                        Telefones = telefone,
                        TipoTel   = tipoTel,
                        Ramal     = ramal,
                        Contato   = contato,
                        Status    = status,
                    };
                    #endregion

                    result = resultado;

                    driver.Close();
                    Console.WriteLine("CensecCrawler OK");
                    return(CrawlerStatus.Success);
                }
            }
            catch (NotSupportedException e)
            {
                Console.WriteLine("Fail loading browser caught: {0}", e.Message);
                SetErrorMessage(typeof(CensecCrawler), e.Message);
                result = null;
                return(CrawlerStatus.Skipped);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception caught: {0}", e.Message);
                SetErrorMessage(typeof(CensecCrawler), e.Message);
                result = null;
                return(CrawlerStatus.Error);
            }
        }
Example #6
0
        public ActionResult RelatorioSimplificado(PesquisaCPFCNPJ pesquisaCPFCNPJ)
        {
            string arpensp = "";
            string cadesp  = "";
            string caged   = "";
            string censec  = "";
            string detran  = "";
            string juscesp = "";
            string siel    = "";
            string sivec   = "";

            if (pesquisaCPFCNPJ.Arpensp == "on")
            {
                arpensp = webScraping.Arpensp(pesquisaCPFCNPJ);
            }
            if (pesquisaCPFCNPJ.Cadesp == "on")
            {
                cadesp = webScraping.Cadesp(pesquisaCPFCNPJ);
            }
            if (pesquisaCPFCNPJ.Caged == "on")
            {
                caged = webScraping.Caged(pesquisaCPFCNPJ);
            }
            if (pesquisaCPFCNPJ.Censec == "on")
            {
                censec = webScraping.Censec(pesquisaCPFCNPJ);
            }
            if (pesquisaCPFCNPJ.Jucesp == "on")
            {
                juscesp = webScraping.Jucesp(pesquisaCPFCNPJ);
            }
            if (pesquisaCPFCNPJ.Detran == "on")
            {
                detran = webScraping.Detran(pesquisaCPFCNPJ);
            }
            if (pesquisaCPFCNPJ.Siel == "on")
            {
                siel = webScraping.Siel(pesquisaCPFCNPJ);
            }
            if (pesquisaCPFCNPJ.Sivec == "on")
            {
                sivec = webScraping.Sivec(pesquisaCPFCNPJ);
            }



            ArpenspModel arpenspModel = relatorioSimplificadoRepository.SimplesArpensp(arpensp);
            CadespModel  cadespModel  = relatorioSimplificadoRepository.SimplesCadesp(cadesp);
            JucespModel  jucespModel  = relatorioSimplificadoRepository.SimplesJucesp(juscesp);
            CagedModel   cagedModel   = relatorioSimplificadoRepository.SimplesCaged(caged);
            DetranModel  detranModel  = relatorioSimplificadoRepository.SimplesDetran(detran);
            CensecModel  censecModel  = relatorioSimplificadoRepository.SimplesCensec(censec);
            SielModel    sielModel    = relatorioSimplificadoRepository.SimplesSiel(siel);
            SivecModel   sivecModel   = relatorioSimplificadoRepository.SimplesSivec(sivec);

            consultaAnteriorRepository.Insert(pesquisaCPFCNPJ);

            return(View(new PesquisaCPFCNPJ()
            {
                ArpenspModel = arpenspModel, CadespModel = cadespModel, JucespModel = jucespModel, CagedModel = cagedModel, DetranModel = detranModel, CensecModel = censecModel, SielModel = sielModel, SivecModel = sivecModel
            }));
        }
        public CensecModel SimplesCensec(string censec)
        {
            CensecModel censecModel = JsonConvert.DeserializeObject <CensecModel>(censec);

            return(censecModel);
        }