public void abrirLoginOlx() { _TipoPagina = TipoPaginaEnum.OLXLogin; oBrowser.Stop(); edtUrl.Text = "https://www3.olx.com.br/account/form_login"; oBrowser.Navigate(edtUrl.Text); }
public void abrirInserirOlx() { _TipoPagina = TipoPaginaEnum.OLXInserir; oBrowser.Stop(); //cBrowser.Stop(); edtUrl.Text = "http://www2.olx.com.br/ai"; //cBrowser.Source = new Uri("http://www2.olx.com.br/ai"); oBrowser.Navigate(edtUrl.Text); }
private void doLoginOlx() { StringBuilder js = new StringBuilder(); js.AppendLine("if (document.getElementById('login_email'))"); js.AppendLine("document.getElementById('login_email').value = '" + _Usuario + "';"); js.AppendLine("if (document.getElementById('login_password'))"); js.AppendLine("document.getElementById('login_password').value = '" + _Senha + "';"); oBrowser.StringByEvaluatingJavaScriptFromString(js.ToString()); //cBrowser.ExecuteJavascript(js.ToString()); //browser.StringByEvaluatingJavaScriptFromString(js.ToString()); _TipoPagina = TipoPaginaEnum.Nenhum; }
private void doOlxInserir(ImovelDTO imovel, bool Automatico = true) { Thread thread = new Thread(() => { if (Automatico) { this.BeginInvoke((MethodInvoker) delegate { string idTipo = "1000"; StringBuilder js = new StringBuilder(); js.AppendLine("if (document.getElementById('" + idTipo + "')) {"); js.AppendLine(" var cn = document.getElementById('" + idTipo + "').className;"); js.AppendLine(" if (!(cn == 'item item-has-children selected' || cn == 'item item-has-children active'))"); js.AppendLine(" document.getElementById('" + idTipo + "').click();"); js.AppendLine("}"); oBrowser.StringByEvaluatingJavaScriptFromString(js.ToString()); }); Thread.Sleep(3000); //js.Clear(); this.BeginInvoke((MethodInvoker) delegate { string idTipo = null; StringBuilder js = new StringBuilder(); if (string.Compare(_Imovel.Tipo, "Apartamento", true) == 0) { idTipo = "1020"; } else if (string.Compare(_Imovel.Tipo, "Casa", true) == 0) { idTipo = "1040"; } if (idTipo != null) { js.AppendLine("if (document.getElementById('" + idTipo + "')) {"); js.AppendLine(" var cn = document.getElementById('" + idTipo + "').className;"); js.AppendLine(" if (!(cn == 'item item-has-children selected' || cn == 'item item-has-children active'))"); js.AppendLine(" document.getElementById('" + idTipo + "').click();"); js.AppendLine("}"); oBrowser.StringByEvaluatingJavaScriptFromString(js.ToString()); } }); Thread.Sleep(7000); this.BeginInvoke((MethodInvoker) delegate { string idTipo = "1"; StringBuilder js = new StringBuilder(); js.AppendLine("if (document.getElementById('" + idTipo + "')) {"); js.AppendLine(" var cn = document.getElementById('" + idTipo + "').className;"); js.AppendLine(" if (!(cn == 'item item-has-children selected' || cn == 'item item-has-children active'))"); js.AppendLine(" document.getElementById('" + idTipo + "').click();"); js.AppendLine("}"); oBrowser.StringByEvaluatingJavaScriptFromString(js.ToString()); }); Thread.Sleep(3000); } this.BeginInvoke((MethodInvoker) delegate { StringBuilder js = new StringBuilder(); if (imovel.Quartos > 0) { js.AppendLine("if (document.getElementById('rooms'))"); switch (imovel.Quartos) { case 1: js.AppendLine("document.getElementById('rooms').selectedIndex = 1;"); break; case 2: js.AppendLine("document.getElementById('rooms').selectedIndex = 2;"); break; case 3: js.AppendLine("document.getElementById('rooms').selectedIndex = 3;"); break; case 4: js.AppendLine("document.getElementById('rooms').selectedIndex = 4;"); break; default: js.AppendLine("document.getElementById('rooms').selectedIndex = 5;"); break; } } //if (!string.IsNullOrEmpty(GaragensText.Text)) // js.AppendLine("document.getElementById('garage_spaces').value = '" + GaragensText.Text + "';"); //if (!string.IsNullOrEmpty(PrecoText.Text)) // js.AppendLine("document.getElementById('price').value = '" + PrecoText.Text + "';"); if (!string.IsNullOrEmpty(imovel.Titulo)) { string titulo = imovel.Titulo; if (IsAllUpper(titulo)) { CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; titulo = textInfo.ToTitleCase(titulo.ToLower()); } if (!string.IsNullOrEmpty(imovel.Codigo)) { titulo = titulo + " - " + imovel.Codigo; } js.AppendLine("if (document.getElementById('subject'))"); js.AppendLine("document.getElementById('subject').value = " + JsonConvert.SerializeObject(titulo) + ";"); } if (imovel.AreaUtil > 0) { js.AppendLine("if (document.getElementById('size'))"); js.AppendLine("document.getElementById('size').value = '" + imovel.AreaUtil.ToString() + "';"); } if (imovel.Preco > 0) { js.AppendLine("if (document.getElementById('price'))"); js.AppendLine("document.getElementById('price').value = '" + imovel.Preco.ToString() + "';"); } /* * if (!string.IsNullOrEmpty(EnderecoText.Text)) * { * js.AppendLine("if (document.getElementById('address'))"); * js.AppendLine("document.getElementById('address').value = '" + EnderecoText.Text + "';"); * } */ if (imovel.Garagens > 0) { js.AppendLine("if (document.getElementById('garage_spaces'))"); js.AppendLine("document.getElementById('garage_spaces').value = '" + imovel.Garagens.ToString() + "';"); } if (!string.IsNullOrEmpty(CEPText.Text)) { js.AppendLine("if (document.getElementById('zipcode'))"); js.AppendLine("document.getElementById('zipcode').value = '" + formatarCep(CEPText.Text) + "';"); js.AppendLine("document.getElementById('zipcode').focus();"); js.AppendLine("document.getElementById('zipcode').blur();"); } oBrowser.StringByEvaluatingJavaScriptFromString(js.ToString()); }); if (!string.IsNullOrEmpty(DescricaoText.Text)) { this.BeginInvoke((MethodInvoker) delegate { StringBuilder js = new StringBuilder(); js.AppendLine("if (document.getElementById('body'))"); js.Append("document.getElementById('body').value = " + JsonConvert.SerializeObject(DescricaoText.Text) + ";"); oBrowser.StringByEvaluatingJavaScriptFromString(js.ToString()); }); } _TipoPagina = TipoPaginaEnum.Nenhum; }); thread.Start(); }