Exemple #1
0
        private string[] SearchWebPage()
        {
            if (wb1.Document == null)
            {
                return(null);
            }
            System.Windows.Forms.HtmlElementCollection elemColl = null;
            System.Windows.Forms.HtmlDocument          doc      = wb1.Document;
            if (doc != null)
            {
                AddTextStr("--- Start ---");
            }
            string strText = "";

            foreach (System.Windows.Forms.HtmlElement elem in elemColl)
            {
                if (elem.InnerHtml.Contains("row quotebox"))
                {
                    strText = elem.InnerText;
                    strText = Regex.Replace(strText, "[\x00-\x1F]+", "/");
                    string[] strarr = strText.Split('/');
                    Console.WriteLine("In 'row quotebox' Children: {0,2} elem.InnerHtml.Length: {1,5}", elem.Children.Count, elem.InnerHtml.Length);
                    int nn = 0;
                    foreach (string split in strarr)
                    {
                        if (split.StartsWith("Kurs"))
                        {
                            Console.WriteLine("{0,3} split:{1}", ++nn, split);
                            AddTextStr(split);
                        }
                    }
                    Console.WriteLine("---------------------------------------------------------------");
                    return(strarr);
                }            // end if
            }                // foreach HtmlElement
            return(null);    // Wenn kein 'row quotebox' gefunden.
        }
Exemple #2
0
        private void toggle_popup()
        {
            if (this.FormBorderStyle == System.Windows.Forms.FormBorderStyle.None)
            {
                normal_mode();
            }
            else
            {
                popup_mode();
            }

            if (Document != null)
            {
                System.Windows.Forms.HtmlElement elt = Document.GetElementById("messages");
                if (elt != null)
                {
                    System.Windows.Forms.HtmlElementCollection msg = elt.Children;
                    if (msg.Count > 0)
                    {
                        msg[msg.Count - 1].ScrollIntoView(false);
                    }
                }
            }
        }
Exemple #3
0
        void document_MouseDown(object sender, System.Windows.Forms.HtmlElementEventArgs e)
        {
            System.Windows.Forms.HtmlElement element = this.automation_browser.Document.GetElementFromPoint(e.ClientMousePosition);

            string className = element.GetAttribute("className");
            string tagName   = element.TagName;


            if (e.MouseButtonsPressed == System.Windows.Forms.MouseButtons.Right)
            {
                //string innerhtml = element.InnerHtml;
                if (!Element.Contains(element))
                {
                    List <string> AttributeName = new List <string>()
                    {
                        "name", "id", "value", "href", "src", "title", "type", "text", "class"
                    };


                    System.Windows.Forms.HtmlElementCollection links = automation_browser.Document.GetElementsByTagName(tagName);



                    //MessageBox.Show( tagName+" "+ className);



                    string           msgtext = "Select this Element?";
                    string           txt     = Application.Current.MainWindow.Title;
                    MessageBoxButton button  = MessageBoxButton.YesNoCancel;
                    MessageBoxResult result  = MessageBox.Show(msgtext, txt, button);

                    switch (result)
                    {
                    case MessageBoxResult.Yes:
                        Element.Add(element);
                        if (className != "")
                        {
                            foreach (System.Windows.Forms.HtmlElement link in links)
                            {
                                if (link.GetAttribute("className") == className)
                                {
                                    DataList.Add(link.InnerText);
                                    HtmlList.Add(link.OuterHtml);
                                }
                            }
                        }
                        else
                        {
                            foreach (System.Windows.Forms.HtmlElement link in links)
                            {
                                if (link.TagName == tagName)
                                {
                                    DataList.Add(link.InnerText);
                                    HtmlList.Add(link.OuterHtml);
                                }
                            }
                        }



                        break;

                    case MessageBoxResult.No:



                        break;

                    case MessageBoxResult.Cancel:

                        break;
                    }
                }
            }
        }
Exemple #4
0
        //private void FindAllButtonsInHtml( System.Windows.Forms.HtmlDocument doc )
        //{
        //    Debug.Assert(null != doc);

        //    System.Windows.Forms.HtmlElement body = doc.Body;
        //    if ( null == body )
        //    {
        //        return;
        //    }

        //    m_listButtons.Clear();

        //    System.Windows.Forms.HtmlElementCollection elementCollection = body.All;
        //    Debug.Assert(null != elementCollection);
        //    string valueOfAttri = null;
        //    foreach ( System.Windows.Forms.HtmlElement element in elementCollection )
        //    {
        //        valueOfAttri = element.GetAttribute(s_typeAttri);
        //        if ( string.IsNullOrEmpty (valueOfAttri) )
        //        {
        //            continue;
        //        }

        //        if ( 0 == string.Compare( valueOfAttri, s_buttonValue, true ) )
        //        {
        //            m_listButtons.Add(element);
        //        }
        //    }
        //}

        private void ExtractAllScreenElements(System.Windows.Forms.HtmlDocument argDoc)
        {
            Debug.Assert(null != argDoc);

            System.Windows.Forms.HtmlElement body = argDoc.Body;
            if (null == body)
            {
                return;
            }

            m_listBindingExpresses.Clear();
            ClearScreenElements();

            System.Windows.Forms.HtmlElementCollection elementCollection = body.All;
            Debug.Assert(null != elementCollection);
            HtmlScreenElementBase screenElement = null;
            string           idsValue           = null;
            string           valueOfAttri       = null;
            IResourceService iCurrentUIResource = null;

            if (null != m_application.ResourceManager)
            {
                iCurrentUIResource = m_application.ResourceManager.CurrentUIResource;
            }
            string text         = null;
            string replaceAttri = null;
            int    replaceValue = 0;
            string imagePath    = null;
            string srcPath      = null;

            foreach (System.Windows.Forms.HtmlElement element in elementCollection)
            {
                //replace ids
                idsValue = element.GetAttribute(s_UITextKey);
                if (null != iCurrentUIResource &&
                    !string.IsNullOrEmpty(idsValue))
                {
                    if (iCurrentUIResource.LoadString(idsValue, TextCategory.s_UI, out text))
                    {
                        element.InnerHtml = ConvertText(text);
                    }
                }
                //replace image
                if (null != iCurrentUIResource &&
                    s_imgName.Equals(element.TagName, StringComparison.OrdinalIgnoreCase))
                {
                    replaceAttri = element.GetAttribute(s_replaceAttri);
                    srcPath      = element.GetAttribute("src");
                    if (!string.IsNullOrEmpty(replaceAttri) &&
                        !string.IsNullOrEmpty(srcPath) &&
                        int.TryParse(replaceAttri, out replaceValue) &&
                        replaceValue == 1)
                    {
                        if (iCurrentUIResource.QueryImagePath(srcPath, out imagePath))
                        {
                            element.SetAttribute("src", imagePath);
                        }
                    }
                }

                if (string.IsNullOrEmpty(element.Id))
                {
                    continue;
                }

                valueOfAttri = element.GetAttribute(s_typeAttri);
                if (string.IsNullOrEmpty(valueOfAttri))
                {
                    continue;
                }

                valueOfAttri = valueOfAttri.ToLowerInvariant();
                if (m_dicScreenElementCreator.ContainsKey(valueOfAttri))
                {
                    try
                    {
                        screenElement = m_dicScreenElementCreator[valueOfAttri].Invoke(element);
                        if (null != screenElement)
                        {
                            m_dicScreenElements.Add(element.Id.ToLowerInvariant(), screenElement);
                        }
                    }
                    catch (System.Exception ex)
                    {
                        LogProcessorService.Log.UIService.LogWarn(string.Format("Failed to create a screen element[{0}]", element.Id), ex);
                    }
                }
            }
        }
Exemple #5
0
        private void LoginDocumentCompleted(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
        {
            if (IsManual && WebWindow == null)
            {
                return;
            }
            if (LogManager != null)
            {
                LogManager.InfoFormat("Document requested: {0}", e.Url.OriginalString);
            }
            switch (e.Url.AbsolutePath)
            {
            //loginning
            case "/dialog/oauth":
            {
                bool isFound = true;
                try {
                    if (!string.IsNullOrEmpty(UserId))
                    {
                        Browser.Document.GetElementById("edit-id").SetAttribute("value", UserId);
                        Browser.Document.GetElementById("edit-pass").SetAttribute("value", PassEncrypt.ConvertToUnsecureString(Password));
                    }
                } catch {
                    isFound = false;
                }
                if (!IsManual)
                {
                    if (LoginAttemptNum >= 1)
                    {
                        OnCompleted(LoginCode.WRONG_USER, string.Empty, UserId);
                        return;
                    }
                    LoginAttemptNum++;

                    if (isFound)
                    {
                        System.Windows.Forms.HtmlElement form = Browser.Document.GetElementById("account_login");
                        if (form != null)
                        {
                            form.InvokeMember("submit");
                        }
                    }
                    else
                    {
                        OnCompleted(LoginCode.WRONG_PAGE, string.Empty, UserId);
                        return;
                    }
                }

                break;
            }

            case "/dialog/oauth/authorize":
            {
                if (!IsManual)
                {
                    System.Windows.Forms.HtmlElementCollection links = Browser.Document.GetElementsByTagName("a");
                    foreach (System.Windows.Forms.HtmlElement link in links)
                    {
                        if (link.InnerText.Trim().ToLower().Equals("authorize"))
                        {
                            link.InvokeMember("click");
                            break;
                        }
                    }
                    OnCompleted(LoginCode.UNKNOWN_URL, string.Empty, UserId);
                }
                break;
            }

            //logged
            case "/code2token.html":
            {
                OnCompleted(LoginCode.SUCCESS, string.Format("{0} {1} {2}", "Aeria", HttpUtility.ParseQueryString(e.Url.Query).Get("code"), UserId), UserId);
                break;
            }

            default:
            {
                if (!IsManual && !e.Url.Host.Contains("facebook"))
                {
                    OnCompleted(LoginCode.UNKNOWN_URL, string.Empty, UserId);
                }
                break;
            }
            }
        }
Exemple #6
0
        void AI()
        {
            HtmlAgilityPack.HtmlDocument Doc = null;
            HtmlAgilityPack.HtmlDocument Tmp = null;

            List <int> Items          = Enumerable.Range(0, Proposal.Count).ToList();
            List <int> PurchasedItems = new List <int>();

            while (Heartbeat)
            {
                foreach (int Item in Items.Reverse <int>())
                {
                    #region Artificial Intelligence

                    try
                    {
                        #region Propsal & Supreme - Tag value verifiction comparer navigator

                        SupremeList List = null;

                        if (!string.IsNullOrEmpty(Proposal[Item].Tag))
                        {
                            List = new SupremeList(0);

                            if (!List.Executed)
                            {
                                continue;
                            }

                            Doc = null;

                            for (int a = 0; a < List.Count; a++)
                            {
                                if (Compute(Proposal[Item].Tag, List[a].Name) < 4 || List[a].Name.Contains(Proposal[Item].Tag))
                                {
                                    Doc = new HtmlAgilityPack.HtmlDocument();
                                    Doc.LoadHtml(new WebClient().DownloadString("http://www.supremenewyork.com" + List[a].Href));

                                    Form1.webBrowser1.Navigate(new Uri("about:blank"));
                                    Form1.webBrowser1.Navigate("http://www.supremenewyork.com" + List[a].Href);

                                    break;
                                }
                            }

                            if (Doc == null)
                            {
                                continue;
                            }
                        }

                        #endregion

                        #region Propsal & Supreme - Design value verification comparer navigator

                        SupremeList Design = null;

                        if (!string.IsNullOrEmpty(Proposal[Item].Design))
                        {
                            Design = new SupremeList(Doc.DocumentNode.SelectNodes("//div[@id='details'] //li"));

                            if (!Design.Executed)
                            {
                                continue;
                            }

                            Tmp = null;

                            for (int s = 0; s < Design.Count; s++)
                            {
                                if (Compute(Proposal[Item].Design, Design[s].Design) < 1 || Design[s].Design.Contains(Proposal[Item].Design))
                                {
                                    if (!Design[s].Sold)
                                    {
                                        Tmp = new HtmlAgilityPack.HtmlDocument();
                                        Tmp.LoadHtml(new WebClient().DownloadString("http://www.supremenewyork.com" + Design[s].Href));

                                        Form1.webBrowser1.Navigate(new Uri("about:blank"));
                                        Form1.webBrowser1.Navigate("http://www.supremenewyork.com" + Design[s].Href);

                                        break;
                                    }
                                }
                            }

                            if (Tmp == null)
                            {
                                continue;
                            }
                        }

                        #endregion

                        Thread.Sleep(3000);

                        #region Proposal & Supreme - Size value verification event

                        #region List value event

                        System.Windows.Forms.HtmlElement SupremeSize = null;

                        if (!string.IsNullOrEmpty(Proposal[Item].Size))
                        {
                            SupremeSize = Form1.SupremeSize;

                            System.Windows.Forms.HtmlElementCollection Options = SupremeSize.Children;

                            foreach (System.Windows.Forms.HtmlElement element in Options)
                            {
                                if (Compute(Proposal[Item].Size, element.InnerText) < 1)
                                {
                                    SupremeSize.SetAttribute("value", GetSubstringByString("=", ">", element.OuterHtml));
                                    SupremeSize.InvokeMember("onchange");
                                    SupremeSize.InvokeMember("click");

                                    break;
                                }
                            }
                        }

                        #endregion

                        #endregion

                        Thread.Sleep(3000);

                        #region Supreme - Add to cart button event

                        #region Button event

                        System.Windows.Forms.HtmlElement SupremeAddButton = null;

                        SupremeAddButton = Form1.SupremeAddButton;

                        System.Windows.Forms.HtmlElementCollection AddButton = SupremeAddButton.Children;

                        foreach (System.Windows.Forms.HtmlElement element in AddButton)
                        {
                            if (element.GetAttribute("value").Equals("add to cart"))
                            {
                                element.InvokeMember("submit");
                                element.InvokeMember("click");

                                break;
                            }
                        }

                        #endregion

                        #endregion

                        Thread.Sleep(3000);

                        Form1.webBrowser1.Navigate("https://www.supremenewyork.com/checkout");

                        Thread.Sleep(3000);

                        #region Supreme - Billing/Shipping information event

                        #region Textbox value event

                        System.Windows.Forms.HtmlElement SupremeCartAddress = null;

                        SupremeCartAddress = Form1.SupremeCartAddress;

                        SupremeCartAddress.Document.GetElementById("order_billing_name").SetAttribute("value", Information[0].Name);
                        SupremeCartAddress.Document.GetElementById("order_email").SetAttribute("value", Information[0].Email);
                        SupremeCartAddress.Document.GetElementById("order_tel").SetAttribute("value", Information[0].Tel);
                        SupremeCartAddress.Document.GetElementById("bo").SetAttribute("value", Information[0].Address);
                        SupremeCartAddress.Document.GetElementById("order_billing_zip").SetAttribute("value", Information[0].Zip);
                        SupremeCartAddress.Document.GetElementById("order_billing_city").SetAttribute("value", Information[0].City);

                        #endregion

                        #region List value event

                        mshtml.HTMLSelectElement SupremeCountry = null;

                        if (Information[0].Country != "USA")
                        {
                            SupremeCountry = Form1.SupremeCountry;

                            SupremeCountry.selectedIndex = 1;

                            SupremeCountry.click();

                            SupremeCountry.FireEvent("onchange");
                        }

                        // you can copy the format below to select any EUROPEAN country here...as of right now this code only works for the NORTH AMERICAN shipping

                        System.Windows.Forms.HtmlElement SupremeState = null;

                        SupremeState = Form1.SupremeState;

                        System.Windows.Forms.HtmlElementCollection State = SupremeState.Children;

                        foreach (System.Windows.Forms.HtmlElement element in State)
                        {
                            if (element.InnerText == Information[0].State)
                            {
                                SupremeState.SetAttribute("value", Information[0].State);
                                SupremeState.InvokeMember("onchange");
                                SupremeState.InvokeMember("click");

                                break;
                            }
                        }

                        #endregion

                        #endregion

                        Thread.Sleep(3000);

                        #region Supreme - Credit card information event

                        #region List value event

                        System.Windows.Forms.HtmlElement SupremeType = null;

                        SupremeType = Form1.SupremeType;

                        System.Windows.Forms.HtmlElementCollection Type = SupremeType.Children;

                        foreach (System.Windows.Forms.HtmlElement element in Type)
                        {
                            if (element.InnerText == Information[0].Type)
                            {
                                SupremeType.SetAttribute("value", FormatType(Information[0].Type));
                                SupremeType.InvokeMember("onchange");
                                SupremeType.InvokeMember("click");

                                break;
                            }
                        }

                        System.Windows.Forms.HtmlElement SupremeMonth = null;

                        SupremeMonth = Form1.SupremeMonth;

                        System.Windows.Forms.HtmlElementCollection Month = SupremeMonth.Children;

                        foreach (System.Windows.Forms.HtmlElement element in Month)
                        {
                            if (element.InnerText == Information[0].Expiry.Substring(0, 2))
                            {
                                SupremeMonth.SetAttribute("value", Information[0].Expiry.Substring(0, 2));
                                SupremeMonth.InvokeMember("onchange");
                                SupremeMonth.InvokeMember("click");

                                break;
                            }
                        }

                        System.Windows.Forms.HtmlElement SupremeYear = null;

                        SupremeYear = Form1.SupremeYear;

                        System.Windows.Forms.HtmlElementCollection Year = SupremeYear.Children;

                        foreach (System.Windows.Forms.HtmlElement element in Year)
                        {
                            if (element.InnerText == Information[0].Expiry.Substring(2, 5).Trim())
                            {
                                SupremeYear.SetAttribute("value", Information[0].Expiry.Substring(2, 5).Trim());
                                SupremeYear.InvokeMember("onchange");
                                SupremeYear.InvokeMember("click");

                                break;
                            }
                        }

                        #endregion

                        #region Textbox value event

                        System.Windows.Forms.HtmlElement SupremeCartCC = null;

                        SupremeCartCC = Form1.SupremeCartCC;

                        SupremeCartCC.Document.GetElementById("cnb").SetAttribute("value", Information[0].Number);
                        SupremeCartCC.Document.GetElementById("vval").SetAttribute("value", Information[0].Cvv);

                        #endregion

                        #region Checkbox event

                        System.Windows.Forms.HtmlElementCollection Term = null;

                        Term = Form1.SupremeTerm;

                        foreach (System.Windows.Forms.HtmlElement element in Term)
                        {
                            if (element.GetAttribute("className") == "icheckbox_minimal")
                            {
                                if (element.FirstChild.Id == "order_terms")
                                {
                                    element.SetAttribute("className", "icheckbox_minimal checked");

                                    break;
                                }
                            }
                        }

                        #endregion

                        #region Button event

                        System.Windows.Forms.HtmlElement SupremeProcessButton = null;

                        SupremeProcessButton = Form1.SupremeProcessButton;

                        System.Windows.Forms.HtmlElementCollection Pay = SupremeProcessButton.Children;

                        foreach (System.Windows.Forms.HtmlElement element in Pay)
                        {
                            if (element.GetAttribute("value").Equals("process payment"))
                            {
                                element.InvokeMember("click");

                                break;
                            }
                        }

                        #endregion

                        #endregion

                        Thread.Sleep(5000);

                        Form1.BotBuddha(2);

                        Thread.Sleep(3000);

                        PurchasedItems.Add(Item);

                        Items.Remove(Item);

                        if (PurchasedItems.Count != Proposal.Count)
                        {
                            Form1.BotBuddha(3);
                        }
                        else
                        {
                            Form1.BotBuddha(0);
                        }
                    }
                    catch (Exception) { }

                    #endregion
                }
            }
        }