Exemple #1
0
 private void DoClick()
 {
     if (IsFocusable())
     {
         underlying.Focus();
     }
     mshtml.IHTMLElement element = (mshtml.IHTMLElement)underlying.DomElement;
     element.click();
 }
Exemple #2
0
        public override System.Xml.XmlDocument doAction()
        {
            logger.Debug("Trying to retrieve Details for EAN code " + eanCode);

            // Search for EAN search field in the currently loaded page
            XmlDocument doc = getBrowserContents();

            // If not present (we are not on catalog page), load the catalog page until EAN search field appears.
            if (doc == null || doc.SelectSingleNode(eanFieldXPath) == null)
            {
                navigate(catalogueUrl, eanFieldXPath);
                // Wait also for the search button to appear
                navigate(null, XPath.get("bouton_rechercher"));
            }

            // Input EAN code & Press Search
            HtmlDocument          document     = getBrowserDocument();
            HtmlElementCollection inputs       = document.GetElementsByTagName("INPUT");
            HtmlElement           submitButton = null;

            foreach (HtmlElement elt in inputs)
            {
                if (XPath.get("id_champ_ean").Equals(elt.Id, StringComparison.InvariantCultureIgnoreCase))
                {
                    elt.SetAttribute("value", eanCode);
                }
                if ("submit".Equals(elt.GetAttribute("type"), StringComparison.InvariantCultureIgnoreCase))
                {
                    submitButton = elt;
                }
            }

            if (submitButton == null)
            {
                logger.Error("Can't find Search EAN button in the following catalog page HTML: " + getBrowserContents().InnerXml);
                throw new ConnectionFailedException("Le Bouton de recherche de la page du catalogue n'a pas été trouvé.");
            }

            // Press Search button
            mshtml.IHTMLElement iButton = (mshtml.IHTMLElement)submitButton.DomElement;
            iButton.click();

            // Wait for search result to be loaded.
            navigate(null, XPath.get("code_ean_html").Replace(Aide_Dilicom3.Properties.Settings.Default.EanToken, eanCode));

            // Return Document object for further parsing.
            return(getBrowserContents());
        }
Exemple #3
0
        /// <summary>
        /// Log in on Dilicom Web Site.
        ///
        /// We don't need to return one document, we just need to log in successfully.
        /// </summary>
        public override XmlDocument doAction()
        {
            // Display login page
            navigate(connectionUrl, Aide_Dilicom3.Config.XPath.get("detection_de_chargement_de_la_page_de_connexion"));

            // Input log & pass fields
            // Populating the forum to try the current login/password
            HtmlDocument          document     = getBrowserDocument();
            HtmlElementCollection inputs       = document.GetElementsByTagName("INPUT");
            HtmlElement           submitButton = null;

            foreach (HtmlElement elt in inputs)
            {
                if (elt.Id.Equals(XPath.get("id_champ_code"), StringComparison.InvariantCultureIgnoreCase))
                {
                    elt.SetAttribute("value", login);
                }
                if (elt.Id.Equals(XPath.get("id_champ_mot_de_passe"), StringComparison.InvariantCultureIgnoreCase))
                {
                    elt.SetAttribute("value", password);
                }
                if (elt.Id.Equals(XPath.get("id_bouton_ok"), StringComparison.InvariantCultureIgnoreCase))
                {
                    submitButton = elt;
                }
            }

            if (submitButton == null)
            {
                logger.Error("Can't find OK button to login (id = '" + XPath.get("id_bouton_ok") + "') in the following HTML: " + getBrowserContents().InnerXml);
                throw new ConnectionFailedException("Le Bouton OK du login et mot de passe n'a pas été trouvé.");
            }

            // Press login
            mshtml.IHTMLElement iButton = (mshtml.IHTMLElement)submitButton.DomElement;
            iButton.click();

            // Wait until the "connected" html token appears. If login & password are not correct, it's up to the end user to do something...
            navigate(null, XPath.get("detection_de_connexion"));


            // We don't do anything special.
            return(null);
        }
        private void webBrowser1_LoadCompleted(object sender, NavigationEventArgs e)
        {
            if (i == 0)
            {
                mshtml.HTMLDocument document = (mshtml.HTMLDocument)webBrowser1.Document;
                var elems = document.getElementsByName("commit");
                foreach (mshtml.IHTMLElement button in elems)
                {
                    mshtml.IHTMLElement k = button;
                    k.click();
                    i = 1;
                }
                webBrowser1.Navigate("https://www.supremenewyork.com/checkout");
            }
            else if (i == 1)
            {
                mshtml.HTMLDocument      document2 = (mshtml.HTMLDocument)webBrowser1.Document;
                mshtml.IHTMLInputElement input     = (mshtml.IHTMLInputElement)document2.getElementById("order_billing_name");
                input.value = name_textbox.Text;

                input       = (mshtml.IHTMLInputElement)document2.getElementById("order_email");
                input.value = email_textbox.Text;

                input       = (mshtml.IHTMLInputElement)document2.getElementById("order_tel");
                input.value = tel_textbox.Text;

                input       = (mshtml.IHTMLInputElement)document2.getElementById("bo");
                input.value = add1_textbox.Text;

                input       = (mshtml.IHTMLInputElement)document2.getElementById("oba3");
                input.value = add2_textbox.Text;

                input       = (mshtml.IHTMLInputElement)document2.getElementById("order_billing_zip");
                input.value = zip_textbox.Text;

                input       = (mshtml.IHTMLInputElement)document2.getElementById("order_billing_city");
                input.value = city_textbox.Text;

                input       = (mshtml.IHTMLInputElement)document2.getElementById("cnb");
                input.value = number_textbox.Text;

                input       = (mshtml.IHTMLInputElement)document2.getElementById("vval");
                input.value = cvv_textbox.Text;

                mshtml.IHTMLSelectElement select = (mshtml.IHTMLSelectElement)document2.getElementById("order_billing_state");
                select.value = state_combobox.Text;

                select = (mshtml.IHTMLSelectElement)document2.getElementById("credit_card_type");
                if (type_combobox.Text == "Visa")
                {
                    select.value = "visa";
                }
                if (type_combobox.Text == "American Express")
                {
                    select.value = "american_express";
                }
                if (type_combobox.Text == "Master Card")
                {
                    select.value = "master";
                }

                select       = (mshtml.IHTMLSelectElement)document2.getElementById("credit_card_month");
                select.value = month_combobox.Text;

                select       = (mshtml.IHTMLSelectElement)document2.getElementById("credit_card_year");
                select.value = year_combobox.Text;

                var elems = document2.getElementsByName("order[terms]");
                foreach (mshtml.IHTMLElement button in elems)
                {
                    mshtml.IHTMLElement k = button;
                    k.click();
                }

                elems = document2.getElementsByName("commit");
                foreach (mshtml.IHTMLElement button in elems)
                {
                    mshtml.IHTMLElement k = button;
                    k.click();
                }

                i = 2;
            }
        }
Exemple #5
0
 public static void MakeClick(this HtmlElement element)
 {
     mshtml.IHTMLElement el = (mshtml.IHTMLElement)element.DomElement;
     el.click();
 }
Exemple #6
0
 //委托函数--提交表单
 private void Submit()
 {
     mshtml.IHTMLDocument2 doc    = (mshtml.IHTMLDocument2)web1.Document;
     mshtml.IHTMLElement   submit = (mshtml.IHTMLElement)doc.all.item("login_button", 0);
     submit.click();
 }
Exemple #7
0
 //委托函数--切换登录方式
 private void SwitchToPlogin()
 {
     mshtml.IHTMLDocument2 doc    = (mshtml.IHTMLDocument2)web1.Document;
     mshtml.IHTMLElement   plogin = (mshtml.IHTMLElement)doc.all.item("switcher_plogin", 0);
     plogin.click();
 }
Exemple #8
0
        private void _webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            _count--;

            if (_count > 0)
            {
                return;
            }

            try
            {
                //mshtml.IHTMLDocument2 htmlDoc = _webBrowser.Document as mshtml.IHTMLDocument2;
                HtmlDocument doc = _webBrowser.Document;
                HtmlElement  movieItemListRegion = doc.GetElementById("movieItemListRegion");
                if (movieItemListRegion == null)
                {
                    return;
                }

                MovieTimesBundle bundle = new MovieTimesBundle();

                _nextDate = null;

                HtmlElement           valueDateRegion  = doc.GetElementById("valueDateRegion");
                HtmlElementCollection dateLiCollection = valueDateRegion.GetElementsByTagName("li");
                for (int i = 0; i < dateLiCollection.Count; i++)
                {
                    HtmlElement dateLiItem = dateLiCollection[i];
                    if (dateLiItem.OuterHtml.Contains("class=curr"))
                    {
                        //20160304
                        string dateStr = dateLiItem.GetAttribute("_date");
                        if (_dateList.Contains(dateStr))
                        {
                            return;
                        }

                        _dateList.Add(dateStr);

                        bundle.Date = new DateTime(
                            int.Parse(dateStr.Substring(0, 4)), int.Parse(dateStr.Substring(4, 2)), int.Parse(dateStr.Substring(6, 2)));

                        if (i < dateLiCollection.Count - 1)
                        {
                            _nextDate = dateLiCollection[i + 1].GetElementsByTagName("a")[0].GetAttribute("href");
                        }
                        break;
                    }
                }

                HtmlElementCollection listBCollection = movieItemListRegion.GetElementsByTagName("b");
                foreach (HtmlElement listBItem in listBCollection)
                {
                    MovieEntity movie = new MovieEntity();
                    movie.MtimeId = int.Parse(listBItem.GetAttribute("_movieid"));
                    movie.Name    = listBItem.GetElementsByTagName("a")[0].GetAttribute("title");
                    movie.Image   = listBItem.GetElementsByTagName("img")[0].GetAttribute("src");

                    //模拟点击
                    mshtml.IHTMLElement movieItem = (mshtml.IHTMLElement)listBItem.DomElement;
                    movieItem.click();

                    //详情
                    HtmlElement           movieDetailRegion = doc.GetElementById("movieDetailRegion");
                    HtmlElementCollection detailPCollection = movieDetailRegion.GetElementsByTagName("p");

                    HtmlElementCollection detailSpan = detailPCollection[0].GetElementsByTagName("span");
                    if (detailSpan.Count == 1)
                    {
                        movie.Director = detailSpan[0].InnerText.Replace("导演:", "");
                    }
                    else if (detailSpan.Count == 2)
                    {
                        movie.Director = detailSpan[0].InnerText.Replace("导演:", "");
                        movie.Actor    = detailSpan[1].InnerText.Replace("主演:", ""); //主演有可能没有,如动画片
                    }

                    detailSpan = detailPCollection[1].GetElementsByTagName("span");
                    if (detailSpan.Count == 1)
                    {
                        movie.Type = detailSpan[0].InnerText.Replace("类型:", "");
                    }
                    else if (detailSpan.Count == 2)
                    {
                        movie.Time = detailSpan[0].InnerText.Replace("时长:", ""); //时长有可能没有
                        movie.Type = detailSpan[1].InnerText.Replace("类型:", "");
                    }

                    //场次
                    HtmlElement           showtimesRegion      = doc.GetElementById("showtimesRegion");
                    HtmlElementCollection showtimeTRCollection =
                        showtimesRegion.GetElementsByTagName("tr");
                    foreach (HtmlElement trItem in showtimeTRCollection)
                    {
                        MovieTimesEntity timesEntity = new MovieTimesEntity();
                        timesEntity.Movie = movie.Id;

                        HtmlElementCollection tdList = trItem.GetElementsByTagName("td");

                        HtmlElementCollection pList = tdList[0].GetElementsByTagName("p");

                        //0点首映的片子,排片表第一行是“次日场”三个字
                        if (pList.Count == 0)
                        {
                            continue;
                        }

                        timesEntity.Time    = DateTime.Parse(bundle.Date.ToShortDateString() + " " + pList[0].InnerText);
                        timesEntity.EndTime = pList[1].InnerText;

                        pList = tdList[1].GetElementsByTagName("p");
                        timesEntity.ShowType = pList[0].InnerText;
                        timesEntity.Language = pList[1].InnerText;

                        pList = tdList[2].GetElementsByTagName("p");
                        timesEntity.ScreeningRoom = pList[0].InnerText;

                        movie.TimesList.Add(timesEntity);
                    }

                    bundle.MovieList.Add(movie);
                }

                _bundleList.Add(bundle);
            }
            catch (Exception ex)
            {
                _exceptionHandling.HandleException(ex);
                return;
            }

            if (String.IsNullOrEmpty(_nextDate) == false)
            {
                _webBrowser.Navigate(_nextDate);
            }
            else
            {
                _webBrowser.DocumentCompleted -= _webBrowser_DocumentCompleted;

                if (Complete != null)
                {
                    CinemaSpiderCompleteEventArgs args = new CinemaSpiderCompleteEventArgs()
                    {
                        Settings             = _settings,
                        MovieTimesBundleList = _bundleList
                    };
                    Complete(this, args);
                }
            }
        }
Exemple #9
0
        //Step 2 (WHILE)
        public bool DoStep2_Set(int startIdx = 0)
        {
            mshtml.HTMLDocument           Doc  = default(mshtml.HTMLDocument);
            mshtml.IHTMLElementCollection eles = default(mshtml.IHTMLElementCollection);
            Doc = (mshtml.HTMLDocument)Ie.Document;
            mshtml.HTMLWindow2 fra = Pub_Com.GetFrameWait(ref Ie, "fraHyou");

            while (ReferenceEquals(fra, null))
            {
                Com.Sleep5(1000);
                fra = Pub_Com.GetFrameWait(ref Ie, "fraHyou");
            }
            Pub_Com.SleepAndWaitComplete(Ie);
            Doc  = (mshtml.HTMLDocument)fra.document;
            eles = Doc.getElementsByTagName("input");

            Pub_Com.SleepAndWaitComplete(Ie);
            Com.Sleep5(1000);
            if (eles.length == 0)
            {
                MessageBox.Show("明細がありません、多分発注した件数多いです");

                Ie.Visible = true;
                System.Environment.Exit(0);
                return(false);
            }

            for (int i = startIdx; i <= eles.length - 1; i++)
            {
                mshtml.IHTMLElement ele = (mshtml.IHTMLElement)(eles.item(i));

                if (ReferenceEquals(ele, null))
                {
                    continue;
                }

                try
                {
                    if (ele.getAttribute("name").ToString() == "strMitKbnHen")
                    {
                        mshtml.IHTMLTableRow tr = (mshtml.IHTMLTableRow)ele.parentElement.parentElement;
                        mshtml.HTMLTableCell td = (mshtml.HTMLTableCell)(tr.cells.item(4));

                        if (td.innerText == "作成中")
                        {
                            ele.click();
                            Pub_Com.GetElementBy(ref Ie, "fraHead", "input", "value", "発注納期非表示").click();
                            Pub_Com.SleepAndWaitComplete(Ie);


                            mshtml.HTMLDocument Doc1 = (mshtml.HTMLDocument)Ie.Document;
                            mshtml.HTMLWindow2  fra1 = Pub_Com.GetFrameWait(ref Ie, "fraMitBody");
                            Doc1 = (mshtml.HTMLDocument)fra1.document;

                            if (Doc1.body.innerText.IndexOf("発注可能な見積ではありません") > 0)
                            {
                                Ie.GoBack();
                                Pub_Com.SleepAndWaitComplete(Ie);
                                return(DoStep2_Set(i + 1));
                            }
                            else
                            {
                                return(true);
                            }
                        }
                    }
                }
                catch (Exception)
                {
                }
            }

            return(false);
        }