示例#1
0
        internal static void Init()
        {
            RService.Log("(Init) " + Name + ": Começando o processamento.. at {0}", Path.GetTempPath() + Name + ".txt");

            try
            {
                //Inicializa as listas e variáveis que serão usadas pelo robô
                CurrentPage      = 1;
                Lote             = LoteController.CreateLote(43, 1249);
                repo             = new LicitacaoRepository();
                Cidades          = CidadeController.GetNameToCidade(Constants.TCMCE_UF);
                NameToOrgao      = OrgaoController.GetNomeUfToOrgao();
                NameToModalidade = ModalidadeController.GetNameToModalidade();

                HtmlDocument htmlDoc = WebHandle.GetHtmlDocOfPage(string.Format(Constants.TCMCE_PAGE, CurrentPage, DateTime.Today.ToString("dd-MM-yyyy"), DateTime.Today.AddYears(1).ToString("dd-MM-yyyy")), Encoding.GetEncoding("UTF-8"));

                //O GetLastPage pega o código Html e o vasculha para encontrar o valor da última página
                int lastPage = GetLastPage(htmlDoc);

                while (CurrentPage != lastPage)
                {
                    RService.Log("(Init) " + Name + ": Percorrendo os links da página.. " + CurrentPage + " at {0}", Path.GetTempPath() + Name + ".txt");

                    HtmlNode licList = htmlDoc.DocumentNode.Descendants("table").SingleOrDefault(x => x.Id.Equals("table"));

                    foreach (var lic in licList.Descendants("tr"))
                    {
                        if (!lic.InnerHtml.Contains("Licitação"))
                        {
                            HandleCreate(lic);
                        }
                    }

                    CurrentPage++;
                    htmlDoc = WebHandle.GetHtmlDocOfPage(string.Format(Constants.TCMCE_PAGE, CurrentPage, DateTime.Today.ToString("dd-MM-yyyy"), DateTime.Today.AddYears(1).ToString("dd-MM-yyyy")), Encoding.GetEncoding("ISO-8859-1"));
                }
            }
            catch (Exception e)
            {
                RService.Log("Exception (Init) " + Name + ": " + e.Message + " / " + e.StackTrace + " / " + e.InnerException + " at {0}", Path.GetTempPath() + Name + ".txt");
            }
        }
示例#2
0
        private static void Init()
        {
            RService.Log(name + ": Começando o processamento... at {0}", logPath);

            try
            {
                //Inicializa as listas e variáveis que serão usadas pelo robô
                currentPage      = 1;
                lote             = LoteController.CreateLote(43, 1442);
                Cidades          = CidadeController.GetNameToCidade(Constants.TCEPI_UF);
                NameToOrgao      = OrgaoController.GetNomeUfToOrgao();
                NameToModalidade = ModalidadeController.GetNameToModalidade();
                alreadyInserted  = LicitacaoController.GetAlreadyInserted(1442, DateTime.Today.AddMonths(-3));

                GetLicitacoes();
            }
            catch (Exception e)
            {
                RService.Log("Exception (Init) " + name + ": " + e.Message + " / " + e.StackTrace + " / " + e.InnerException + " at {0}", logPath);
            }
        }
        private static void Init()
        {
            RService.Log("(Init) " + Name + ": Começando o processamento... " + "at {0}", Path.GetTempPath() + Name + ".txt");

            try
            {
                nameToModalidade         = ModalidadeController.GetNameToModalidade();
                nameToOrgao              = OrgaoController.GetNomeUfToOrgao();
                ufToCapital              = CityUtil.GetUfToCapital();
                ufToNomeCidadeToIdCidade = CidadeController.GetUfToNameCidadeToIdCidade();
                lote = LoteController.CreateLote(43, 508);
                repo = new LicitacaoRepository();

                HtmlDocument htmlDoc = WebHandle.GetHtmlDocOfPage(Constants.CN_COTACOES, Encoding.GetEncoding("ISO-8859-1"));

                RService.Log("(Init) " + Name + ": Percorrendo as cotações do dia " + DateTime.Today.ToShortDateString() + " at {0}", Path.GetTempPath() + Name + ".txt");

                foreach (var row in htmlDoc.DocumentNode.Descendants("tr").Where(x => x.Attributes.Contains("class") && x.Attributes["class"].Value.Contains("estiloLinhaTabela")).ToList())
                {
                    if (row.ChildNodes[5].InnerText == "Sim")
                    {
                        icms = true;
                    }
                    else
                    {
                        icms = false;
                    }

                    HandleCreate(htmlDoc, row);
                }
            }
            catch (Exception e)
            {
                RService.Log("Exception (Init) " + Name + ": " + e.Message + " / " + e.StackTrace + " / " + e.InnerException + " at {0}", Path.GetTempPath() + Name + ".txt");
            }
        }
示例#4
0
        private static void Init()
        {
            RService.Log("(Init) " + name + ": Começando o processamento.. at {0}", logPath);

            try
            {
                Lote             = LoteController.CreateLote(43, 1250);
                Cidades          = CidadeController.GetNameToCidade(Constants.TCESE_UF);
                NameToOrgao      = OrgaoController.GetNomeUfToOrgao();
                NameToModalidade = ModalidadeController.GetNameToModalidade();

                for (int i = 0; i < Constants.TCESE_MUN_CODE.Count; i++)
                {
                    HandleLicitacoes(i);
                }

                //repo = new LicitacaoRepository();
                //repo.Insert(licitacoes);
            }
            catch (Exception e)
            {
                RService.Log("Exception (Init) " + name + ": " + e.Message + " / " + e.StackTrace + " / " + e.InnerException + " at {0}", logPath);
            }
        }
示例#5
0
        /*Metodo que inicia o processamento de dados*/
        private static void Init()
        {
            RService.Log("(Init) " + Name + ": Começando o processamento... " + "at {0}", Path.GetTempPath() + Name + ".txt");
            try
            {
                Repo = new LicitacaoRepository();

                /*Realiza a atualização das situações das licitações já inseridas*/
                //UpdateLicitacoes();

                /*Inicia listas e dictionary's com informações necessárias*/
                NameToOrgao              = OrgaoController.GetNomeUfToOrgao();
                NameToModalidade         = ModalidadeController.GetNameToModalidade();
                UfToCapital              = CityUtil.GetUfToCapital();
                UfToNomeCidadeToIdCidade = CidadeController.GetUfToNameCidadeToIdCidade();
                Lote = LoteController.CreateLote(43, IdFonte);

                TryReload = true;
                if (DoSearch())
                {
                    /*Percorre cada licitação encontrada*/
                    foreach (var numUf in numUFs)
                    {
                        /*Acessa a página da licitação*/
                        try
                        {
                            if (!LicitacaoController.Exists(numUf.Split(':')[0]))
                            {
                                /*Cria o objeto licitação com as informações da página*/
                                Licitacao licitacao = CreateLicitacao(numUf);

                                if (licitacao != null)
                                {
                                    Repo.Insert(licitacao);
                                    NumLicitacoes++;
                                    RService.Log("(Init) " + Name + ": Licitação inserida com sucesso at {0}", Path.GetTempPath() + Name + ".txt");

                                    /*Segmenta a licitação recém criada*/
                                    //SegmentarLicitacao(licitacao);
                                    DownloadEdAndCreatLicArq(licitacao);
                                }
                                else
                                {
                                    if (licitacao != null && licitacao.Orgao != null)
                                    {
                                        RService.Log("Exception (CreateLicitacao) " + Name + ": A licitação de nº " + licitacao.Num + " e órgão " + licitacao.Orgao.Nome + " - " + licitacao.Orgao.Estado + " não foi salva - Motivo(s): " + mensagemErro + " at {0}", Path.GetTempPath() + Name + ".txt");
                                    }
                                    else
                                    {
                                        RService.Log("Exception (CreateLicitacao) " + Name + ": A licitação de nº " + numUf.Split(':')[0] + " não foi salva - Motivo(s): " + mensagemErro + " at {0}", Path.GetTempPath() + Name + ".txt");
                                    }
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            RService.Log("Exception (Init - CreateLicitacao) " + Name + ": " + e.Message + " / " + e.StackTrace + " / " + e.InnerException + " at {0}", Path.GetTempPath() + Name + ".txt");
                        }
                    }
                }
            }
            catch (Exception e)
            {
                RService.Log("Exception (Init) " + Name + ": " + e.Message + " / " + e.StackTrace + " / " + e.InnerException + " at {0}", Path.GetTempPath() + Name + ".txt");
            }
        }
示例#6
0
        /*Inicia a busca*/
        private static void Init()
        {
            RService.Log("(Init) " + Name + ": Começando o processamento.." + " at {0}", Path.GetTempPath() + Name + ".txt");
            try
            {
                /*Inicia navegador fantasma*/
                LoadDriver();

                /*Acessa o site do TCE*/
                web.Navigate().GoToUrl(Constants.TCEPR_SITE);

                /*Busca os itens do filtro por cidades*/
                GetCidades();

                /*Configura os parametros da busca e inicia demais componentes necessários*/
                if (config.PreTypedDate != null)
                {
                    CurrentDay          = config.PreTypedDate.Value.AddDays(-2);
                    FinalDay            = config.PreTypedDate.Value;
                    config.PreTypedDate = null;
                    ConfigRobotController.Update(config);
                }
                else
                {
                    CurrentDay = DateTime.Now.AddDays(-2);
                    FinalDay   = DateTime.Now;
                }

                NameToModalidade = ModalidadeController.GetNameToModalidade();
                NameToOrgao      = OrgaoController.GetNomeUfToOrgao();
                Lote             = LoteController.CreateLote(43, 510);
                Repo             = new LicitacaoRepository();

                CurrentPg = 1;
                TotalLic  = 0;

                /*Procura licitacoes por cidade pra ointervalo de dias indicado*/
                foreach (var cidade in dicCidades)
                {
                    CidadeAtualKey = cidade.Key;
                    CidadeAtual    = cidade.Value;
                    /*Pesquisa licitações com base nos parametros (ano; dtAbertura)*/
                    if (DoSearch(CurrentDay, FinalDay))
                    {
                        /*Pra cada pag que a pesquisa retornar*/
                        do
                        {
                            /*Percorre licitações de uma pag*/
                            if (!GetLicitacoes())
                            {
                                //Segunda e ultima tentativa, se não conseguir continua com a pesquisa para a proxima cidade
                                DoSearch(CurrentDay, FinalDay);
                                GetLicitacoes();
                            }
                        } while (HasNextPage());
                    }

                    Tens = new List <int>()
                    {
                        11
                    };
                    CurrentPg = 1;
                }

                //Repo.Insert(licitacoes);
            }
            catch (Exception e)
            {
                RService.Log("Exception (Init) " + Name + ": " + e.Message + " / " + e.StackTrace + " / " + e.InnerException + " at {0}", Path.GetTempPath() + Name + ".txt");
            }
            finally
            {
                if (TotalLic <= 0)
                {
                    LoteController.Delete(Lote);
                }
                if (web != null)
                {
                    web.Close();
                }
            }
        }