示例#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");
            });
        }
示例#2
0
 public void Insert(SivecModel sivecModel)
 {
     using (context)
     {
         context.Sivec.Add(sivecModel);
         context.SaveChanges();
     }
 }
示例#3
0
        public SivecModel Sivec(int cpfcnpj)
        {
            var sivec = new Service.PesquisaService().Sivec(cpfcnpj);

            SivecModel sivecModel = JsonConvert.DeserializeObject <SivecModel>(sivec);

            //variavel global
            Global.Sivec = sivecModel;

            return(sivecModel);
        }
示例#4
0
        public string Sivec(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);

                //Validação
                driver.Navigate().GoToUrl("http://ec2-18-231-116-58.sa-east-1.compute.amazonaws.com/ ");
                driver.FindElement(By.Id("username")).SendKeys("fiap");
                driver.FindElement(By.Id("password")).SendKeys("mpsp");
                driver.FindElement(By.Id("password")).SendKeys(Keys.Enter);

                driver.Navigate().GoToUrl("http://ec2-18-231-116-58.sa-east-1.compute.amazonaws.com/sivec/login.html");
                driver.FindElement(By.Id("nomeusuario")).SendKeys("fiap");
                driver.FindElement(By.Id("senhausuario")).SendKeys("mpsp");
                driver.FindElement(By.Id("Acessar")).Click();

                driver.FindElement(By.XPath("/html/body/nav/div[2]/ul/li[4]/a")).Click();
                driver.FindElement(By.XPath("/html/body/nav/div[2]/ul/li[4]/ul/li[2]/a")).Click();
                driver.FindElement(By.XPath("/html/body/nav/div[2]/ul/li[4]/ul/li[2]/ul/li[1]/a")).Click();

                driver.FindElement(By.Id("idValorPesq")).SendKeys(pesquisaCPFCNPJ.CPFCNPJ.ToString());
                driver.FindElement(By.Id("procurar")).Click();
                System.Threading.Thread.Sleep(2000);
                driver.FindElement(By.XPath("//*[@id='tabelaPesquisa']/tbody/tr[1]/td[1]/a")).Click();

                var tabela = driver.FindElement(By.XPath("/html/body/form[1]/div/div[5]/div[4]/table/tbody")).Text;

                string[] strsplit = tabela.Replace("\r\n", ":").Split(':');

                string dataEmissao        = strsplit[1].Replace(" Alcunha", "").Trim();
                string estadoCivil        = strsplit[4].Replace(" Naturalidade", "").Trim();
                string naturalizado       = strsplit[7].Replace(" Posto de Identificação", "").Trim();
                string postoIdentificacao = strsplit[8].Trim();
                string grauInstituicao    = strsplit[10].Replace(" Fórmula Fundamental", "").Trim();
                string corOlho            = strsplit[14].Trim();
                string corCabelo          = strsplit[17].Trim();
                string corPele            = strsplit[19].Replace(" Profissão", "").Trim();
                string profissao          = strsplit[20].Trim();

                SivecModel objSivec = new SivecModel();
                objSivec.CnpjSivec          = pesquisaCPFCNPJ.CPFCNPJ;
                objSivec.DataEmissao        = dataEmissao;
                objSivec.EstadoCivil        = estadoCivil;
                objSivec.Naturalizado       = naturalizado;
                objSivec.PostoIdentificacao = postoIdentificacao;
                objSivec.GrauInstituicao    = grauInstituicao;
                objSivec.CorOlho            = corOlho;
                objSivec.CorPele            = corPele;
                objSivec.CorCabelo          = corCabelo;
                objSivec.Profissao          = profissao;

                sivecRepository.Insert(objSivec);

                string objjsonData = JsonConvert.SerializeObject(objSivec);

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

                return(objjsonData);
            }
        }
示例#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/sivec/login.html");

                    // page 1
                    driver.FindElement(By.Id("nomeusuario")).SendKeys(_usuario);
                    driver.FindElement(By.Id("senhausuario")).SendKeys(_senha);

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


                    // page 2
                    driver.FindElement(By.CssSelector("#navbar-collapse-1 > ul > li:nth-child(4) > a")).Click();
                    driver.FindElement(By.Id("1")).Click();

                    if (!string.IsNullOrEmpty(_rg))
                    {
                        driver.FindElement(By.CssSelector("li.open:nth-child(2) > ul:nth-child(2) > li:nth-child(1) > a:nth-child(1)")).Click();
                    }
                    else if (!string.IsNullOrEmpty(_nomeCompleto))
                    {
                        driver.FindElement(By.CssSelector("li.open:nth-child(2) > ul:nth-child(2) > li:nth-child(1) > a:nth-child(2)")).Click();
                    }
                    else if (!string.IsNullOrEmpty(_matriculaSap))
                    {
                        driver.FindElement(By.CssSelector("li.open:nth-child(2) > ul:nth-child(2) > li:nth-child(1) > a:nth-child(3)")).Click();
                    }


                    // page 3
                    if (!string.IsNullOrEmpty(_rg))
                    {
                        driver.FindElement(By.Id("idValorPesq")).SendKeys(_rg);
                        driver.FindElement(By.Id("procurar")).Click();
                    }
                    else if (!string.IsNullOrEmpty(_nomeCompleto))
                    {
                        driver.FindElement(By.Id("idNomePesq")).SendKeys(_nomeCompleto);
                        driver.FindElement(By.Id("procura")).Click();
                    }
                    else if (!string.IsNullOrEmpty(_matriculaSap))
                    {
                        driver.FindElement(By.Id("idValorPesq")).SendKeys(_matriculaSap);
                        driver.FindElement(By.Id("procurar")).Click();
                    }


                    // page 4
                    var personFind = driver.FindElement(By.CssSelector("#tabelaPesquisa > tbody > tr:nth-child(1) > td.textotab1.text-center.sorting_1 > a"));
                    ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", personFind);
                    personFind.Click();


                    // page 5 - Capturar dados
                    const string caminhoTabela = "body > form:nth-child(13) > div > ";

                    #region Objeto com os dados capturados
                    var outrasInfo = new OutrosModel
                    {
                        Nome = driver
                               .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(10) > div.col-md-9")).Text.Trim(),
                        RG = driver
                             .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(11) > div:nth-child(2)")).Text.Trim(),
                        DataNascimento = driver
                                         .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(12) > div.col-md-5")).Text.Trim(),
                        Naturalidade = driver
                                       .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(13) > div.col-md-7")).Text.Trim(),
                        NomePai = driver
                                  .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(14) > div.col-md-9")).Text.Trim(),
                        NomeMae = driver
                                  .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(15) > div.col-md-9")).Text.Trim()
                    };

                    var resultado = new SivecModel
                    {
                        Nome = driver
                               .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(5) > div.col-md-11 > table > tbody > tr:nth-child(1) > td:nth-child(2)")).Text.Trim(),
                        Sexo = driver
                               .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(5) > div.col-md-11 > table > tbody > tr:nth-child(1) > td:nth-child(5)")).Text.Trim(),
                        DataNascimento = driver
                                         .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(5) > div.col-md-11 > table > tbody > tr:nth-child(2) > td:nth-child(2)")).Text.Trim(),
                        RG = driver
                             .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(5) > div.col-md-11 > table > tbody > tr:nth-child(2) > td:nth-child(5)")).Text.Trim(),
                        NumControle = driver
                                      .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(5) > div.col-md-11 > table > tbody > tr:nth-child(3) > td:nth-child(2)")).Text.Trim(),
                        TipoRG = driver
                                 .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(5) > div.col-md-11 > table > tbody > tr:nth-child(3) > td:nth-child(5)")).Text.Trim(),
                        DataEmissaoRG = driver
                                        .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(5) > div.col-md-12.top-buffer25 > table > tbody > tr:nth-child(1) > td:nth-child(2)")).Text.Trim(),
                        Alcunha = driver
                                  .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(5) > div.col-md-12.top-buffer25 > table > tbody > tr:nth-child(1) > td:nth-child(5)")).Text.Trim(),
                        EstadoCivil = driver
                                      .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(5) > div.col-md-12.top-buffer25 > table > tbody > tr:nth-child(2) > td:nth-child(2)")).Text.Trim(),
                        Naturalidade = driver
                                       .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(5) > div.col-md-12.top-buffer25 > table > tbody > tr:nth-child(2) > td:nth-child(5)")).Text.Trim(),
                        Naturalizado = driver
                                       .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(5) > div.col-md-12.top-buffer25 > table > tbody > tr:nth-child(3) > td:nth-child(2)")).Text.Trim(),
                        PostoIdentificacao = driver
                                             .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(5) > div.col-md-12.top-buffer25 > table > tbody > tr:nth-child(3) > td:nth-child(5)")).Text.Trim(),
                        GrauInstrucao = driver
                                        .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(5) > div.col-md-12.top-buffer25 > table > tbody > tr:nth-child(4) > td:nth-child(2)")).Text.Trim(),
                        FormulaFundamental = driver
                                             .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(5) > div.col-md-12.top-buffer25 > table > tbody > tr:nth-child(4) > td:nth-child(5)")).Text.Trim(),
                        NomePai = driver
                                  .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(5) > div.col-md-12.top-buffer25 > table > tbody > tr:nth-child(5) > td:nth-child(2)")).Text.Trim(),
                        CorOlhos = driver
                                   .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(5) > div.col-md-12.top-buffer25 > table > tbody > tr:nth-child(5) > td:nth-child(5)")).Text.Trim(),
                        NomeMae = driver
                                  .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(5) > div.col-md-12.top-buffer25 > table > tbody > tr:nth-child(6) > td:nth-child(2)")).Text.Trim(),
                        Cabelo = driver
                                 .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(5) > div.col-md-12.top-buffer25 > table > tbody > tr:nth-child(6) > td:nth-child(5)")).Text.Trim(),
                        CorPele = driver
                                  .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(5) > div.col-md-12.top-buffer25 > table > tbody > tr:nth-child(7) > td:nth-child(2)")).Text.Trim(),
                        Profissao = driver
                                    .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(5) > div.col-md-12.top-buffer25 > table > tbody > tr:nth-child(7) > td:nth-child(5)")).Text.Trim(),
                        EnderecoResidencial = driver
                                              .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(7) > div.col-md-7")).Text.Trim(),
                        EnderecoTrabalho = driver
                                           .FindElement(By.CssSelector($"{caminhoTabela}div:nth-child(8) > div.col-md-7")).Text.Trim(),
                        Outros = outrasInfo
                    };
                    #endregion

                    result = resultado;

                    driver.Close();
                    Console.WriteLine("SivecCrawler OK");
                    return(CrawlerStatus.Success);
                }
            }
            catch (NotSupportedException e)
            {
                Console.WriteLine("Fail loading browser caught: {0}", e.Message);
                SetErrorMessage(typeof(SivecCrawler), e.Message);
                result = null;
                return(CrawlerStatus.Skipped);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception caught: {0}", e.Message);
                SetErrorMessage(typeof(SivecCrawler), e.Message);
                result = null;
                return(CrawlerStatus.Error);
            }
        }
示例#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 SivecModel SimplesSivec(string sivec)
        {
            SivecModel sivecModel = JsonConvert.DeserializeObject <SivecModel>(sivec);

            return(sivecModel);
        }