Ejemplo n.º 1
0
        private static void HandleCreate(HtmlDocument htmlDoc, HtmlNode row)
        {
            try
            {
                if (row.InnerHtml.Contains("href"))
                {
                    string       situacao;
                    string       quoteLink = row.ChildNodes[3].ChildNodes["a"].Attributes["href"].Value.ToString();
                    HtmlDocument htmlQuote = WebHandle.GetHtmlDocOfPage(string.Format(Constants.CN_COTACAO_LINK, quoteLink), Encoding.GetEncoding("ISO-8859-1"));
                    Licitacao    l         = CreateQuote(htmlQuote, quoteLink, out situacao);
                    //RandomSleep();
                    if (l != null && !repo.Exists(l.IdLicitacaoFonte.ToString()))
                    {
                        repo.Insert(l);
                        numCotacoes++;
                        RService.Log("Cotação " + l.IdLicitacaoFonte + " inserida com sucesso" + " at {0}", Path.GetTempPath() + Name + ".txt");

                        //SegmentarCotacao(l);
                    }
                    else if (l != null && repo.Exists(l.IdLicitacaoFonte.ToString()) && LicitacaoController.SituacaoAlterada(l.IdLicitacaoFonte.ToString(), situacao))
                    {
                        l          = repo.GetByIdLicitacaoFonte(l.IdLicitacaoFonte.ToString());
                        l.Situacao = situacao;

                        repo.Update(l);
                    }
                }
            }
            catch (Exception e)
            {
                RService.Log("Exception (HandleCreate) " + Name + ": " + e.Message + " / " + e.StackTrace + " / " + e.InnerException + " at {0}", Path.GetTempPath() + Name + ".txt");
            }
        }
Ejemplo n.º 2
0
        private static void Navigate()
        {
            int licitIndex = 0, rowCount = 0;

            try
            {
                do
                {
                    web.Navigate().GoToUrl(Constants.CRJ_HOST); //para obter o cookie do portal

                    if (licitIndex == 0)
                    {
                        RService.Log("(Navigate) " + Name + ": Acessando as licitações do dia... at {0}", LogPath);
                    }

                    web.FindElementById("pesquisarLicitacoesFuturas").Click();

                    Thread.Sleep(3000);

                    var select = new SelectElement(web.FindElementByName("dataTable_length"));

                    select.SelectByIndex(4);

                    Thread.Sleep(8000);

                    var rowArray = web.FindElements(By.TagName("tr")).Where(x => x.GetAttribute("class") == "odd" || x.GetAttribute("class") == "even").ToArray();

                    rowCount = rowArray.Count();

                    if (licitIndex == 0)
                    {
                        RService.Log("(Navigate) " + Name + ": Encontradas " + rowCount + " licitações hoje at {0}", LogPath);
                    }

                    web.FindElements(By.TagName("tr"))
                    .Where(x => x.GetAttribute("class") == "odd" || x.GetAttribute("class") == "even")
                    .ToArray()[licitIndex].Click();

                    Licitacao licitacao = GetLicitacao();

                    if (licitacao != null && !repo.Exists(licitacao.IdLicitacaoFonte.ToString()))
                    {
                        repo.Insert(licitacao);
                        NumLicitacoes++;
                        RService.Log("(GetLicitacoes) " + Name + ": Licitação " + licitacao.IdLicitacaoFonte + " inserida com sucesso at {0}", LogPath);

                        GetFiles(licitacao);
                    }
                    else
                    {
                        RService.Log("Exception (GetLicitacoes) " + Name + ": Licitação não inserida. Motivo(s): " +
                                     (string.IsNullOrEmpty(mensagemErro) ? "Licitação já inserida" : mensagemErro) + " at {0}", LogPath);
                    }

                    licitIndex++;
                } while (licitIndex < rowCount && rowCount != 0);
            }
            catch (Exception e)
            {
                RService.Log("Exception (Navigate): " + e.Message + " / " + e.StackTrace + " at {0}", LogPath);
            }
        }
Ejemplo n.º 3
0
        /*Busca a licitação item por item*/
        internal static bool Exists(string objeto, string valorMax, string observacaoes, string num, string processo, string linkSite)
        {
            LicitacaoRepository repo = new LicitacaoRepository();

            return(repo.Exists(objeto, valorMax, observacaoes, num, processo, linkSite));
        }
Ejemplo n.º 4
0
        internal static bool Exists(string idLicitacaoFonte)
        {
            LicitacaoRepository repo = new LicitacaoRepository();

            return(repo.Exists(idLicitacaoFonte));
        }