/*Inicia o processamento do robot*/ private static void Init() { RService.Log("(Init) " + Name + ": Começando o processamento..." + " at {0}", Path.GetTempPath() + Name + ".txt"); try { NumAlteracoes = 0; repo = new FontePesquisaRepository(); //fontePesquisa = repo.FindByActiveRobot(); fontePesquisa = repo.FindByRegex(); //Para debug descomentar o código abaixo /*FontePesquisa fp = repo.FindById(1750); * fontePesquisa = new List<FontePesquisa>(); * fontePesquisa.Add(fp);*/ foreach (FontePesquisa f in fontePesquisa) { RService.Log("(Init) " + Name + ": Consultando fonte: " + f.Nome + " at {0}", Path.GetTempPath() + Name + ".txt"); try { HtmlDocument html = new HtmlDocument(); html = SitesComCodigoFrame(f); if (string.IsNullOrEmpty(html.DocumentNode.InnerText)) { html = WebHandle.HtmlParaObjeto(f.Link, Encoding.UTF8); if (html.DocumentNode.InnerHtml.Contains("�")) { html = WebHandle.HtmlParaObjeto(f.Link, Encoding.GetEncoding("ISO-8859-1")); } } RegistrarConsulta(html, f); } catch (Exception e) { RService.Log("Exception (Init)" + 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"); } }
private static void Init() { RService.Log("(Init) " + Name + ": Começando o processamento... at {0}", Path.GetTempPath() + Name + ".txt"); try { NumAlteracoes = 0; repo = new FontePesquisaRepository(); fontePesquisa = repo.FindByElement(); //FontePesquisa f = repo.FindById(1750); //fontePesquisa = new List<FontePesquisa>(); //fontePesquisa.Add(f); foreach (var fp in fontePesquisa) { RService.Log("(Init) " + Name + ": Consultando fonte: " + fp.Nome + " at {0}", Path.GetTempPath() + Name + ".txt"); try { LoadChromeDriver(); RegistrarConsulta(fp); } catch (Exception) { } finally { if (web != null) { web.Quit(); } } } } catch (Exception e) { RService.Log("Exception (Init) " + Name + ": " + e.Message + " / " + e.StackTrace + " / " + e.InnerException + " at {0}", Path.GetTempPath() + Name + ".txt"); } }
public static void Atualizar(FontePesquisa fp) { FontePesquisaRepository fprepo = new FontePesquisaRepository(); fprepo.Update(fp); }