Esempio n. 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");
            });
        }
Esempio n. 2
0
        //localhost:49850/home/WebScrapingArpenp
        //Arpensp
        public void WebScrapingArpenp()
        {
            using (IWebDriver driver = new ChromeDriver())
            {
                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.Manage().Window.Maximize();
                Actions builder = new Actions(driver);

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

                driver.FindElement(By.XPath("//*[@id='main']/div[2]/div[2]/div[2]/div/a/img")).Click();
                System.Threading.Thread.Sleep(500);
                driver.FindElement(By.ClassName("item3")).Click();
                System.Threading.Thread.Sleep(500);
                driver.FindElement(By.XPath("//*[@id='wrapper']/ul/li[2]/ul/li[1]/a")).Click();
                driver.FindElement(By.XPath("//*[@id='principal']/div/form/table/tbody/tr[9]/td[2]/input")).SendKeys("Teste");
                driver.FindElement(By.ClassName("botao")).SendKeys(Keys.Enter);

                var resultado = driver.FindElement(By.ClassName("principal")).Text;

                string[] entersplit = resultado.Split('\r', '\n');

                string[] strsplit = resultado.Split(':');

                string cartorioRegistro = strsplit[1];
                string numeroCNS        = strsplit[3];
                string uf            = strsplit[5];
                string nomeConj      = strsplit[7];
                string novoNomeConj  = strsplit[9];
                string nomeConj2     = strsplit[11];
                string novoNomeConj2 = strsplit[13];
                string dataCasamento = strsplit[15];
                string matricula     = strsplit[17];
                //string dataEntrada = strsplit[19];
                //string dataRegistro = strsplit[21];

                ArpenspModel objArp = new ArpenspModel();
                objArp.CartorioRegistro = cartorioRegistro;
                objArp.NumCNS           = numeroCNS;
                objArp.UF            = uf;
                objArp.NomeConj      = nomeConj;
                objArp.NovoNomeConj  = novoNomeConj;
                objArp.NomeConj2     = nomeConj2;
                objArp.NovoNomeConj2 = novoNomeConj2;
                objArp.DataCasamento = dataCasamento;
                objArp.Matricula     = matricula;
                //objArp.DataEntrada = dataEntrada;
                //objArp.DataRegistro = dataRegistro;

                string objjsonData = JsonConvert.SerializeObject(objArp);
                Response.Write(objjsonData);
                System.IO.File.WriteAllText(@"C:\Users\Nicolas PC\Desktop\teste\Arpensp.txt", objjsonData);
                //System.IO.File.WriteAllText(@"C:\Users\nperes\Desktop\Projeto\Arquivos\Arpensp.txt", objjsonData);
            }
        }
 public void Insert(ArpenspModel arpenspModel)
 {
     using (context)
     {
         context.Arpensp.Add(arpenspModel);
         context.SaveChanges();
     }
 }
Esempio n. 4
0
        public ArpenspModel Arpensp(int cpfcnpj)
        {
            var arpensp = new Service.PesquisaService().Arpensp(cpfcnpj);

            ArpenspModel arpenspModel = JsonConvert.DeserializeObject <ArpenspModel>(arpensp);

            //variavel global
            Global.Arpensp = arpenspModel;

            return(arpenspModel);
        }
Esempio n. 5
0
        public string Arpensp(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/arpensp/login.html");

                driver.FindElement(By.XPath("//*[@id='main']/div[2]/div[2]/div[2]/div/a/img")).Click();
                driver.FindElement(By.ClassName("item3")).Click();
                driver.FindElement(By.XPath("//*[@id='wrapper']/ul/li[2]/ul/li[1]/a")).Click();
                driver.FindElement(By.XPath("//*[@id='principal']/div/form/table/tbody/tr[10]/td[2]/input")).SendKeys(pesquisaCPFCNPJ.CPFCNPJ.ToString());
                driver.FindElement(By.ClassName("botao")).SendKeys(Keys.Enter);

                var resultado = driver.FindElement(By.ClassName("principal")).Text;

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

                string cartorioRegistro = strsplit[3].Trim();
                string numeroCNS        = strsplit[5].Replace("-", "").Trim();
                string uf            = strsplit[7].Trim();
                string nomeConj      = strsplit[10].Trim();
                string novoNomeConj  = strsplit[12].Trim();
                string nomeConj2     = strsplit[14].Trim();
                string novoNomeConj2 = strsplit[16].Trim();
                string dataCasamento = strsplit[18].Trim();
                string matricula     = strsplit[20].Trim();
                string dataEntrada   = strsplit[22].Trim();
                string dataRegistro  = strsplit[24].Trim();

                ArpenspModel objArp = new ArpenspModel();
                objArp.CNPJCPFArpensp   = pesquisaCPFCNPJ.CPFCNPJ;
                objArp.CartorioRegistro = cartorioRegistro;
                objArp.NumCNS           = numeroCNS;
                objArp.UF            = uf;
                objArp.NomeConj      = nomeConj;
                objArp.NovoNomeConj  = novoNomeConj;
                objArp.NomeConj2     = nomeConj2;
                objArp.NovoNomeConj2 = novoNomeConj2;
                objArp.DataCasamento = dataCasamento;
                objArp.Matricula     = matricula;
                objArp.DataEntrada   = dataEntrada;
                objArp.DataRegistro  = dataRegistro;


                arpenspRepository.Insert(objArp);

                string objjsonData = JsonConvert.SerializeObject(objArp, new JsonSerializerSettings {
                    Formatting = Formatting.Indented
                });

                //string arr = JsonConvert.DeserializeObject<string>(objjsonData);

                string bd = objjsonData as string;

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

                return(objjsonData);
            }
        }
Esempio n. 6
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/arpensp/login.html");

                    // page 1
                    driver.FindElement(By.CssSelector("#main > div.container > div:nth-child(2) > div:nth-child(2) > div > a")).Click();


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


                    // page 3
                    driver.FindElement(By.CssSelector("#principal > div > form > table > tbody > tr:nth-child(2) > td:nth-child(2) > input[name='numero_processo']")).SendKeys(_numeroProcesso);

                    var campoVara = new SelectElement(driver.FindElement(By.Id("vara_juiz_id")));
                    campoVara.SelectByValue("297");

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


                    // page 4 - Capturar dados
                    #region Objeto com os dados capturados
                    var resultado = new ArpenspModel
                    {
                        CartorioRegistro =
                            driver.FindElement(By.CssSelector(
                                                   "#principal > div > form > table:nth-child(3) > tbody > tr:nth-child(1) > td:nth-child(2)"))
                            .Text.Trim(),
                        NumeroCNS = driver
                                    .FindElement(By.CssSelector(
                                                     "#principal > div > form > table:nth-child(3) > tbody > tr:nth-child(2) > td:nth-child(2)"))
                                    .Text.Trim(),
                        UF = driver.FindElement(By.CssSelector(
                                                    "#principal > div > form > table:nth-child(3) > tbody > tr:nth-child(3) > td:nth-child(2)"))
                             .Text.Trim(),
                        NomeConjugeA1 = driver
                                        .FindElement(By.CssSelector(
                                                         "#principal > div > form > table:nth-child(15) > tbody > tr:nth-child(2) > td:nth-child(2)"))
                                        .Text.Trim(),
                        NovoNomeConjugeA2 =
                            driver.FindElement(By.CssSelector(
                                                   "#principal > div > form > table:nth-child(15) > tbody > tr:nth-child(3) > td:nth-child(2)"))
                            .Text.Trim(),
                        NomeConjugeB1 = driver
                                        .FindElement(By.CssSelector(
                                                         "#principal > div > form > table:nth-child(15) > tbody > tr:nth-child(4) > td:nth-child(2)"))
                                        .Text.Trim(),
                        NovoNomeConjugeB2 =
                            driver.FindElement(By.CssSelector(
                                                   "#principal > div > form > table:nth-child(15) > tbody > tr:nth-child(5) > td:nth-child(2)"))
                            .Text.Trim(),
                        DataCasamento = driver
                                        .FindElement(By.CssSelector(
                                                         "#principal > div > form > table:nth-child(15) > tbody > tr:nth-child(6) > td:nth-child(2)"))
                                        .Text.Trim(),
                        Matricula = driver
                                    .FindElement(By.CssSelector(
                                                     "#principal > div > form > table:nth-child(15) > tbody > tr:nth-child(8) > td:nth-child(2)"))
                                    .Text.Trim(),
                        DataEntrada = driver
                                      .FindElement(By.CssSelector(
                                                       "#principal > div > form > table:nth-child(15) > tbody > tr:nth-child(9) > td:nth-child(2)"))
                                      .Text.Trim(),
                        DataRegistro = driver
                                       .FindElement(By.CssSelector(
                                                        "#principal > div > form > table:nth-child(15) > tbody > tr:nth-child(10) > td:nth-child(2)"))
                                       .Text.Trim(),
                        Acervo = driver
                                 .FindElement(By.CssSelector(
                                                  "#principal > div > form > table:nth-child(15) > tbody > tr:nth-child(11) > td:nth-child(2)"))
                                 .Text.Trim(),
                        NumeroLivro = driver
                                      .FindElement(By.CssSelector(
                                                       "#principal > div > form > table:nth-child(15) > tbody > tr:nth-child(12) > td:nth-child(2)"))
                                      .Text.Trim(),
                        NumeroFolha = driver
                                      .FindElement(By.CssSelector(
                                                       "#principal > div > form > table:nth-child(15) > tbody > tr:nth-child(13) > td:nth-child(2)"))
                                      .Text.Trim(),
                        NumeroRegistro =
                            driver.FindElement(By.CssSelector(
                                                   "#principal > div > form > table:nth-child(15) > tbody > tr:nth-child(14) > td:nth-child(2)"))
                            .Text.Trim(),
                        TipoLivro = driver
                                    .FindElement(By.CssSelector(
                                                     "#principal > div > form > table:nth-child(15) > tbody > tr:nth-child(15) > td:nth-child(2)"))
                                    .Text.Trim()
                    };
                    #endregion

                    result = resultado;

                    driver.Close();
                    Console.WriteLine("ArpenspCrawler OK");
                    return(CrawlerStatus.Success);
                }
            }
            catch (NotSupportedException e)
            {
                Console.WriteLine("Fail loading browser caught: {0}", e.Message);
                SetErrorMessage(typeof(ArpenspCrawler), e.Message);
                result = null;
                return(CrawlerStatus.Skipped);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception caught: {0}", e.Message);
                SetErrorMessage(typeof(ArpenspCrawler), e.Message);
                result = null;
                return(CrawlerStatus.Error);
            }
        }
 public void Update(ArpenspModel arpenspModel)
 {
     context.Arpensp.Update(arpenspModel);
     context.SaveChanges();
 }
Esempio n. 8
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 ArpenspModel SimplesArpensp(string arpensp)
        {
            ArpenspModel arpenspModel = JsonConvert.DeserializeObject <ArpenspModel>(arpensp);

            return(arpenspModel);
        }