Ejemplo n.º 1
0
        private void fnc_DoTestEvent()
        {
            HtmlElementCollection all = this.pTargetWebBrowser.Document.All;
            HtmlElementCollection forms;

            forms = all.GetElementsByName("q");
            forms[0].InnerText = txt_input_value.Text.Trim(); // テキストボックスに「C#」を入力

            forms = all.GetElementsByName("f");
            forms[0].InvokeMember("submit"); // フォームのサブミット

            //HtmlElementCollection forms3 = all.GetElementsByName("btnG");
            //forms3[0].InvokeMember("click"); // ボタンのクリック
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds "Pay" links to the list of invoices.
        /// </summary>
        private void AddPayLinks()
        {
            HtmlElementCollection payActions = webBrowser.Document.GetElementsByTagName("td");

            if (payActions == null)
            {
                return;
            }
            payActions  = payActions.GetElementsByName("payAction");
            button      = new HtmlElement[payActions.Count];
            paymentInfo = new PaymentInfo[payActions.Count];

            for (int i = 0; i < payActions.Count; i++)
            {
                paymentInfo[i] = PaymentInfo.ValueOf(webBrowser.Document, payActions[i].Id);
                if (paymentInfo[i].Id != null && paymentInfoIndexMap.ContainsKey(paymentInfo[i].Id) == false)
                {
                    paymentInfoIndexMap.Add(paymentInfo[i].Id, i);
                }
                if (payActions[i] != null && (payActions[i].GetAttribute("changed") == null || "".Equals(payActions[i].GetAttribute("changed"))))
                {
                    button[i]    = webBrowser.Document.CreateElement("a");
                    button[i].Id = "plugin_payButton_" + i;
                    button[i].SetAttribute("index", i.ToString());
                    button[i].SetAttribute("class", "link");
                    payActions[i].AppendChild(button[i]);
                    payActions[i].SetAttribute("changed", "true");
                }
            }
            AddPayButtonHandlers();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// ログイン処理
 /// </summary>
 private void login()
 {
     txtLoginUser.Text = userPass[loopCnt];
     txtUserCount.Text = loopCnt.ToString();
     if (txtCurrentUrl.Text == LOGINURL)
     {
         currentUrl = webBrowser1.Url.ToString();
         // ユーザID
         webBrowser1.Document.GetElementById("input_wearid").Focus();
         webBrowser1.Document.GetElementById("input_wearid").InnerText = txtLoginUser.Text;
         // パスワード
         HtmlElementCollection all   = webBrowser1.Document.All;
         HtmlElementCollection forms = all.GetElementsByName("Password");
         forms[0].Focus();
         forms[0].Enabled   = true;
         forms[0].InnerText = txtLoginUser.Text;
         webBrowser1.Document.GetElementById("input_wearid").Focus();
         SendKeys.Send("{ENTER}");
         loopCnt++;
         waitFlg    = false;
         flgFvGdCp  = true;
         viewFlg    = true;
         refreshCnt = 0;
     }
 }
Ejemplo n.º 4
0
        protected HtmlElement GetElementByName(HtmlDocument doc, string name)
        {
            HtmlElementCollection alltags   = doc.All;
            HtmlElementCollection validtags = alltags.GetElementsByName(name);

            if (validtags.Count < 1)
            {
                return(null);
            }
            else
            {
                return(validtags[0]);
            }
        }
        public void TextToAddAction()
        {
            HtmlElementCollection collection = GetInputElements();

            collection = collection.GetElementsByName("textinput1");

            var element = (IHTMLInputElement)collection[0].DomElement;

            element.value = "Testing Text";

            var action = _mgr.AddText("normalWindow", element, "");

            Assert.AreEqual(1, _mgr.ActionCount, "Action Not Added");
            Assert.AreEqual("Testing Text", action.TextToType, "Text value did not match");
        }
Ejemplo n.º 6
0
        //Admin
        private bool obtenerFoliosYLinks()
        {
            bool result = false;

            try
            {
                urls     = new Dictionary <string, string>();
                document = webbrowser.Document;
                links    = document.GetElementsByTagName("span");
                folios   = document.GetElementsByTagName("input");
                links    = links.GetElementsByName("BtnDescarga");
                folios   = folios.GetElementsByName("ListaFolios");
                result   = true;
            }
            catch (Exception)
            {
                throw;
            }
            return(result);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Evento de carga completa del webbrowser
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            //clsBaseLog.cs_pxRegistarAdd(numeroDoc);
            //SI ES la primera carga  y se presiono verificar
            try
            {
                HtmlDocument documentBrowser = webBrowser.Document;
                HtmlElement  bodyDocument    = documentBrowser.Body;
                if (bodyDocument.InnerText != null)
                {
                    if (bodyDocument.InnerText.Contains("refrescando") && verificarDocs == true)
                    {
                        clsBaseLog.cs_pxRegistarAdd(bodyDocument.InnerText + " - " + numeroDoc);
                        cargoPagina++;
                    }
                    else if (bodyDocument.InnerText.Contains("Resultado") && verificarDocs == true)
                    {
                        cargoPagina++;
                        string comentario = "";
                        //System.Windows.Forms.MessageBox.Show(bodyDocument.InnerText);
                        HtmlElementCollection html_nodo_lista_tables = webBrowser.Document.GetElementsByTagName("table");
                        if (html_nodo_lista_tables.Count > 0)
                        {
                            HtmlElementCollection col = html_nodo_lista_tables[4].Document.GetElementsByTagName("td");
                            comentario = col[4].InnerText;
                        }
                        clsEntidadDocument doc = new clsEntidadDocument(localDB).cs_fxObtenerUnoPorId(idDoc);
                        doc.Cs_pr_ComentarioSUNAT = comentario;
                        if (comentario.Contains("válido"))
                        {
                            doc.Cs_pr_EstadoValidar = "0";
                        }
                        else if (comentario.Contains("BAJA"))
                        {
                            doc.Cs_pr_EstadoValidar = "2";
                        }
                        else
                        {
                            doc.Cs_pr_EstadoValidar = "3";
                        }

                        if (tipoDoc == "2" || tipoDoc == "4" || tipoDoc == "5")
                        {
                            if (!comentario.Contains("no"))
                            {
                                //buscar si esta de baja
                                if (comentario.Contains("BAJA"))
                                {
                                    doc.Cs_pr_EstadoValidar = "2";
                                }
                                else
                                {
                                    doc.Cs_pr_EstadoValidar = "0";
                                }
                            }
                            else
                            {
                                doc.Cs_pr_EstadoValidar = "3";
                            }
                        }

                        doc.cs_pxActualizar(false, false);
                        docsValidados++;
                    }
                    else if (webBrowser.DocumentText.Contains("lista") && verificarDocs == true)
                    {
                        cargoPagina++;
                        HtmlElementCollection html_nodo_lista        = webBrowser.Document.GetElementsByTagName("form");
                        HtmlElementCollection html_nodo_lista_tables = html_nodo_lista[0].Document.GetElementsByTagName("table");
                        if (html_nodo_lista_tables.Count > 0)
                        {
                            HtmlElementCollection col = html_nodo_lista_tables[4].Document.GetElementsByTagName("input");

                            HtmlElement rucEmisor = col.GetElementsByName("num_ruc")[0];
                            rucEmisor.SetAttribute("value", rucEmisorDoc);

                            HtmlElementCollection selects = html_nodo_lista_tables[4].Document.GetElementsByTagName("select");
                            HtmlElement           selectTipoComprobante = selects.GetElementsByName("tipocomprobante")[0];
                            selectTipoComprobante.Children[Convert.ToInt32(tipoDoc)].SetAttribute("selected", "selected");

                            HtmlElement numSerie = col.GetElementsByName("num_serie")[0];
                            numSerie.SetAttribute("value", serieDoc);

                            HtmlElement numComprob = col.GetElementsByName("num_comprob")[0];
                            numComprob.SetAttribute("value", numeroDoc);

                            HtmlElement fecEmision = col.GetElementsByName("fec_emision")[0];
                            fecEmision.SetAttribute("value", fechaEmisionDoc);

                            if (tipoDoc != "2" && tipoDoc != "4" && tipoDoc != "5")
                            {
                                HtmlElement montoDocumento = col.GetElementsByName("cantidad")[0];
                                montoDocumento.SetAttribute("value", montoDoc);
                            }
                            string nombreRandom  = RandomString(5);
                            var    testImagePath = Directory.GetCurrentDirectory() + "\\imageCaptcha.png";

                            string s = GetGlobalCookies(webBrowser.Document.Url.AbsoluteUri);
                            //clsBaseLog.cs_pxRegistarAdd(s + " - " + numeroDoc);
                            WebClient Client1 = new WebClient();
                            Client1.Headers.Add(HttpRequestHeader.Cookie, s);
                            Client1.DownloadFile("http://www.sunat.gob.pe/ol-ti-itconsvalicpe/captcha?accion=image&nmagic=0", testImagePath);
                            Client1.Dispose();

                            string textoCaptchaIngresar = textoCaptcha("imageCaptcha");
                            if (textoCaptchaIngresar.Contains("'"))
                            {
                                textoCaptchaIngresar = textoCaptchaIngresar.Replace("'", "I");
                            }
                            if (textoCaptchaIngresar.Contains(" "))
                            {
                                textoCaptchaIngresar = textoCaptchaIngresar.Replace(" ", "");
                            }
                            if (textoCaptchaIngresar.Trim().Length < 4)
                            {
                                //VOLVER A DESCARGAR
                                WebClient Client2 = new WebClient();
                                Client2.Headers.Add(HttpRequestHeader.Cookie, s);
                                Client2.DownloadFile("http://www.sunat.gob.pe/ol-ti-itconsvalicpe/captcha?accion=image&nmagic=0", testImagePath);
                                Client2.Dispose();
                                textoCaptchaIngresar = textoCaptcha("imageCaptcha");
                                if (textoCaptchaIngresar.Contains("'"))
                                {
                                    textoCaptchaIngresar = textoCaptchaIngresar.Replace("'", "I");
                                }
                                if (textoCaptchaIngresar.Contains(" "))
                                {
                                    textoCaptchaIngresar = textoCaptchaIngresar.Replace(" ", "");
                                }
                                if (textoCaptchaIngresar.Trim().Length < 4)
                                {
                                    textoCaptchaIngresar = "AAAA";
                                }
                            }
                            // clsBaseLog.cs_pxRegistarAdd("uno"+textoCaptchaIngresar);
                            HtmlElement codigoCaptcha = col.GetElementsByName("codigo")[0];
                            codigoCaptcha.SetAttribute("value", textoCaptchaIngresar.ToUpper());
                            Thread.Sleep(400);
                            string elementValue = codigoCaptcha.GetAttribute("value");
                            if (elementValue.Length < 4)
                            {
                                codigoCaptcha.SetAttribute("value", textoCaptchaIngresar.ToUpper());
                                string elementValue2 = codigoCaptcha.GetAttribute("value");
                                if (elementValue2.Length <= 0)
                                {
                                    codigoCaptcha.SetAttribute("value", textoCaptchaIngresar.ToUpper());
                                }
                            }
                            //clsBaseLog.cs_pxRegistarAdd(textoCaptchaIngresar);
                            //end Codigo captcha
                            HtmlElementCollection html_nodo_lista_inputenviar = html_nodo_lista.GetElementsByName("wacepta");
                            HtmlElementCollection html_nodo_lista_inputs      = html_nodo_lista[0].Document.GetElementsByTagName("input");

                            if (html_nodo_lista_inputs.Count > 8)
                            {
                                HtmlElement inputEnviar = html_nodo_lista_inputs[8];
                                // timer2.Interval = 900; // 'Give it a few seconds to make sure the OpenFileDialog is open
                                // timer2.Elapsed += new ElapsedEventHandler(runWorkerTimerMessageBox);
                                // timer2.Start();
                                inputEnviar.InvokeMember("click");
                            }
                            string elementValue2s = codigoCaptcha.GetAttribute("value");
                            // clsBaseLog.cs_pxRegistarAdd("dos"+elementValue2s);
                            //File.Delete(testImagePath);
                        }
                        // ClickOKButton();
                    }
                    else
                    {
                        if (verificarDocs == true)
                        {
                            clsBaseLog.cs_pxRegistarAdd(bodyDocument.InnerText);
                        }
                    }
                }
                else
                {
                    clsBaseLog.cs_pxRegistarAdd("browser null");
                    cargoPagina = 2;
                }

                //  Mostrar_Formulario_Detalle_Mensaje = false;
            }
            catch (Exception ex)
            {
                clsBaseLog.cs_pxRegistarAdd(ex.ToString());
                cargoPagina = 2;

                /*No se ejecuta nada para que no detenga el proceso de busqueda de mensajes, ya que esta función
                 * es invocada mas de tres veces*/
            }
        }