Esempio n. 1
0
 public Processor()
 {
     Bootstrapper.Initialise();
     //UnityContainerSetup.SetUp();
     _zapService = new ZapImoveisService();
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            ZapImoveisService _zapService = new ZapImoveisService();
            TipoExecucao      tipo        = TipoExecucao.Processamento;

            if (args != null && args.Count() > 0)
            {
                tipo = EnumHelper.TryParse <TipoExecucao>(args[0]);
            }

            log.Info("Carregando");
            string[] states = new string[]
            {
                "AC",
                "AL",
                "AP",
                "AM",
                "BA",
                "CE",
                "DF",
                "ES",
                "GO",
                "MA",
                "MT",
                "MS",
                "MG",
                "PA",
                "PB",
                "PR",
                "PE",
                "PI",
                "RJ",
                "RN",
                "RS",
                "RO",
                "RR",
                "SC",
                "SP",
                "SE",
                "TO"
            };

            foreach (var state in states)
            {
                if (tipo == TipoExecucao.Importacao)
                {
                    ExecutionResult result = null;
                    while (result == null || !result.GotoNext)
                    {
                        if (result == null)
                        {
                            //if (state == "RS")
                            //    result = new ExecutionResult() { GotoNext = false, Page = 3132, State = state };
                            //else
                            result = new ExecutionResult()
                            {
                                GotoNext = false, Page = 1, State = state
                            };
                        }

                        using (Processor proc = new Processor())
                        {
                            result = proc.ImportFromSite(result.State, result.Page);
                        }
                    }
                }
                else
                {
                    using (Processor proc = new Processor())
                    {
                        //proc.UpdateElementAttributes("http://www.zapimoveis.com.br/oferta/venda+casa-de-condominio+3-quartos+ponta-de-baixo+sao-jose+sc+103m2+RS395000/ID-7873567/?paginaoferta=1", 0);
                        //proc.UpdateElementAttributes("http://www.zapimoveis.com.br/lancamento/casa-de-condominio+venda+lagoa-da-conceicao+florianopolis+sc+lagoa-village+alamo-construtora+121m2/ID-11640/?contato=0", 0);

                        int  rec   = 10;
                        long pages = _zapService.Collection.Count(new BsonDocument()) / rec;
                        if (pages % rec > 0)
                        {
                            pages++;
                        }

                        log.Info(string.Format("Paginas identificadas [{0}]", pages));

                        for (int i = 1; i < pages; i++)
                        {
                            log.Info(string.Format("Processando página: {0} de [{1}]", i + 1, pages));
                            foreach (var item in _zapService.Collection.Find("{ }").Skip(i * rec).Limit(rec).ToList())
                            {
                                proc.Execute(item);
                            }
                        }

                        Console.ReadKey();
                    }
                }
            }
        }
Esempio n. 3
0
 public void Dispose()
 {
     _zapService = null;
     GC.Collect();
 }