コード例 #1
0
ファイル: MainForm.cs プロジェクト: coke802/Etihad
        private void RunLoopMainStep2()
        {
            UtilsLog.Log("RunLoopMainStep2 ENTER");

            HtmlElement eledxpdateselectionview = webBrowser1.Document.GetElementById("dxp-date-selection-view");

            if (eledxpdateselectionview != null)
            {
                List <HtmlElement> eledxpdateselectionviewItems = new List <HtmlElement>();
                UtilsHtml.FindElementHtmlElements(eledxpdateselectionview, ":div/:div/:div/:div/class:page-messages/:div/class:title-container/:div/class:title/:span", eledxpdateselectionviewItems);
                if (eledxpdateselectionviewItems.Count > 0)
                {
                    HtmlElement elemappItem = eledxpdateselectionviewItems[0];
                    if (elemappItem.InnerText.Contains("未找到航班"))
                    {
                        //失败
                        RunLoopSleep(5000);
                        step++;
                    }
                }
            }

            HtmlElement eledxpflighttablesection = webBrowser1.Document.GetElementById("dxp-flight-table-section");

            if (eledxpflighttablesection != null)
            {
                //成功
                RunLoopSleep(2000);
                step += 3;
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: coke802/Etihad
        private void RunLoopMainStep7()
        {
            UtilsLog.Log("RunLoopMainStep7 ENTER");

            HtmlElement elemFlight = elemFlights[0];

            List <HtmlElement> elemFlightItems = new List <HtmlElement>();

            UtilsHtml.FindElementHtmlElements(elemFlight, ":div/:div/class:shadow-box/:div/:div/class:brand-selection-button-container/:div/:button", elemFlightItems);
            UtilsLog.Log("RunLoopMainStep7 elemFlightItems.Count={0}", elemFlightItems.Count);
            if (elemFlightItems.Count > 0)
            {
                elemFlightItems[0].Focus();
                elemFlightItems[0].InvokeMember("click");
                RunLoopSleep(2000);
                step++;
            }
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: coke802/Etihad
        private void RunLoopMainStep6()
        {
            UtilsLog.Log("RunLoopMainStep6 ENTER");

            HtmlElement elemFlight = elemFlights[0];

            List <HtmlElement> elemFlightItems = new List <HtmlElement>();

            UtilsHtml.FindElementHtmlElements(elemFlight, ":div/:div/:div/class:itinerary-part-offer-price/class:price-content-wrapper/data-test-id:cabin-offer-button", elemFlightItems);
            UtilsLog.Log("RunLoopMainStep6 elemFlightItems.Count={0}", elemFlightItems.Count);
            if (elemFlightItems.Count > 0)
            {
                elemFlightItems[0].Focus();
                elemFlightItems[0].InvokeMember("click");
                RunLoopSleep(2000);
                step++;
            }
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: coke802/Etihad
        private void RunLoopMainStep5()
        {
            UtilsLog.Log("RunLoopMainStep5 ENTER");
            HtmlElement eledxpflighttablesection = webBrowser1.Document.GetElementById("dxp-flight-table-section");

            if (eledxpflighttablesection == null)
            {
                return;
            }

            elemFlights.Clear();
            foreach (HtmlElement eledxpflighttablesectionChild in eledxpflighttablesection.Children)
            {
                string eledxpflighttablesectionChildClassName = eledxpflighttablesectionChild.GetAttribute("className");
                if (eledxpflighttablesectionChildClassName.Contains("ducp-component-panel") &&
                    eledxpflighttablesectionChildClassName.Contains("spark-panel") &&
                    eledxpflighttablesectionChildClassName.Contains("itinerary-part-offer"))
                {
                    elemFlights.Add(eledxpflighttablesectionChild);
                }
            }

            if (elemFlights.Count > 0)
            {
                if (comboBox2.Text == "商务舱")
                {
                    HtmlElement        elemFlight      = elemFlights[0];
                    List <HtmlElement> elemFlightItems = new List <HtmlElement>();
                    UtilsHtml.FindElementHtmlElements(elemFlight, ":div/:div/:div/:button", elemFlightItems);
                    foreach (HtmlElement elemFlightItem in elemFlightItems)
                    {
                        if (elemFlightItem.InnerText.Contains("下一個"))
                        {
                            elemFlightItem.Focus();
                            elemFlightItem.InvokeMember("click");
                        }
                    }
                }

                RunLoopSleep(2000);
                step++;
            }
        }
コード例 #5
0
ファイル: MainForm.cs プロジェクト: coke802/Etihad
        private HtmlElement FindFlightContent()
        {
            HtmlElement elemapp = webBrowser1.Document.GetElementById("app");

            if (elemapp != null)
            {
                List <HtmlElement> elemappItems = new List <HtmlElement>();
                UtilsHtml.FindElementHtmlElements(elemapp, ":div/:div", elemappItems);
                foreach (HtmlElement elemappItem in elemappItems)
                {
                    string elemappItemClassName = elemappItem.GetAttribute("className");
                    if (elemappItemClassName != null && elemappItemClassName.Contains("flight-content"))
                    {
                        return(elemappItem);
                    }
                }
            }

            return(null);
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: coke802/Etihad
        private void RunLoopMainStep8()
        {
            UtilsLog.Log("RunLoopMainStep8 ENTER");

            HtmlElement eledxpsharedflightselection = webBrowser1.Document.GetElementById("dxp-shared-flight-selection");

            if (eledxpsharedflightselection != null)
            {
                List <HtmlElement> eledxpsharedflightselectionItems = new List <HtmlElement>();
                UtilsHtml.FindElementHtmlElements(eledxpsharedflightselection, ":div/:div/:button", eledxpsharedflightselectionItems);
                UtilsLog.Log("RunLoopMainStep8 eledxpsharedflightselection.Count={0}", eledxpsharedflightselectionItems.Count);
                foreach (HtmlElement eledxpsharedflightselectionItem in eledxpsharedflightselectionItems)
                {
                    if (eledxpsharedflightselectionItem.InnerText == "乘客")
                    {
                        eledxpsharedflightselectionItem.Focus();
                        eledxpsharedflightselectionItem.InvokeMember("click");
                        RunLoopSleep(2000);
                        step++;
                    }
                }
            }
        }