public clsSnoTelStateTable(string url)
        {
            URL = url;

            WebClient client = new WebClient();

            byte[] data = client.DownloadData(URL);
            mshtml.HTMLDocumentClass Doc = new mshtml.HTMLDocumentClass();
            string sHtml = System.Text.Encoding.ASCII.GetString(data);

            mshtml.IHTMLDocument2 oDoc = (mshtml.IHTMLDocument2)Doc;
            oDoc.write(sHtml);

            bool tableFound = false;

            foreach (mshtml.IHTMLElement element in (mshtml.IHTMLElementCollection)oDoc.body.all)
            {
                if (element is mshtml.HTMLPhraseElement && element.innerText == "Status")
                {
                    tableFound = true;
                }
                else if (element is mshtml.HTMLTableClass && tableFound && element.innerText.Contains("Site Map"))
                {
                    tableFound = false;
                }
                else if (element is mshtml.HTMLTableRowClass && tableFound)
                {
                    Records.Add(new SnoTelRecord((mshtml.HTMLTableRowClass)element, Records.Count));
                }
            }
        }
 private string ReadWebPageSource()
 {
     //string html = mainPageWebBrowser.ExecuteJavascriptWithResult("document.getElementsByTagName('html')[0].innerHTML");
     //return html;
     //Refresh browser
     //mainPageWebBrowser.Refresh();
     mainPageWebBrowser.Refresh(true); //WebBrowserRefreshOption.Completely)
     //mainPageWebBrowser.Navigate(new Uri("https://sports.bovada.lv/live-betting"));
     mshtml.HTMLDocumentClass dom = (mshtml.HTMLDocumentClass)mainPageWebBrowser.Document;
     return(dom.body.innerHTML);
 }
Exemple #3
0
        private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            mshtml.HTMLDocumentClass doc = axWebBrowser1.Document as mshtml.HTMLDocumentClass;

            object empty = null;

            switch (e.Button.ImageIndex)
            {
            case 10:                                    // Open
                this.openFileDialog1.ShowDialog();
                break;

            case 0:                                     // Save
                this.saveFileDialog1.ShowDialog();
                break;

            case 2:                             // Cut
                doc.execCommand("Cut", false, empty);
                break;

            case 3:                             // Copy
                doc.execCommand("Copy", false, empty);
                break;

            case 4:                             // Paste
                doc.execCommand("Paste", false, empty);
                break;

            case 7:                             // Bold
                doc.execCommand("Bold", false, empty);
                break;

            case 8:                             // Italic
                doc.execCommand("Italic", false, empty);
                break;

            case 9:                             // Underline
                doc.execCommand("Underline", false, empty);
                break;

            case 6:                             // Undo
                doc.execCommand("Undo", false, empty);
                break;

            case 5:                             // Redo
                doc.execCommand("Redo", false, empty);
                break;
            }

            if (e.Button.Text != "")
            {
                doc.execCommand("FontSize", false, (object)e.Button.Text);
            }
        }
Exemple #4
0
 private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     try {
         if (this.tabControl1.SelectedIndex == 1)                        // Code View
         {
             mshtml.HTMLDocumentClass doc = (mshtml.HTMLDocumentClass) this.axWebBrowser1.Document;
             this.textBox1.Text = "<body>" + doc.IHTMLDocument2_body.innerHTML + "</body>";
         }
     } catch (Exception ex) {
         MessageBox.Show(ex.Message, "Error");
         return;
     }
 }
Exemple #5
0
 private void saveFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
 {
     try {
         string                   filename = this.saveFileDialog1.FileName;
         StreamWriter             file     = new StreamWriter(filename, false, System.Text.Encoding.Unicode);
         mshtml.HTMLDocumentClass doc      = (mshtml.HTMLDocumentClass) this.axWebBrowser1.Document;
         string                   str      = "<body>" + doc.IHTMLDocument2_body.innerHTML + "</body>";
         file.Write(str);
         file.Close();
     } catch (Exception ex) {
         MessageBox.Show(ex.Message, "Error");
         return;
     }
 }
Exemple #6
0
        public FunctionPage(string Filename)
        {
            this.Filename = Filename;

            // load the HTML file
            PageSource = File.ReadAllText(Filename);

            // find the handled information
            mshtml.IHTMLDocument2 doc = new mshtml.HTMLDocumentClass();
            doc.write(new object[] { PageSource });
            doc.close();

            foreach (mshtml.IHTMLElement el in (mshtml.IHTMLElementCollection)doc.body.all)
            {
                if (el.tagName.ToLower() == "attributes")
                {
                    // get the handled information
                    string attrname = el.getAttribute("name", 0).ToString();
                    string attrvalue = el.getAttribute("value", 0).ToString();
                    nvAttributes.Add(attrname, attrvalue);

                    if (attrname.ToLower()=="tagname" && attrvalue.ToLower()=="all")
                    {
                        ShowOnAll = true;
                    }
                }
                else if (el.tagName.ToLower() == "assembly")
                {
                    // get the assembly information
                    string path = el.getAttribute("path", 0).ToString();

                    if (File.Exists(path))
                    {
                        scAssemblies.Add(path);
                    }
                    else
                    {
                        scNotFoundAssemblies.Add(path);
                    }
                }
                else if (el.tagName.ToLower().Contains("languages"))
                {
                    Languages = el.getAttribute("value", 0).ToString();
                }
            }

            Title = doc.title;
        }
        public FunctionPage(string Filename)
        {
            this.Filename = Filename;

            // load the HTML file
            PageSource = File.ReadAllText(Filename);

            // find the handled information
            mshtml.IHTMLDocument2 doc = new mshtml.HTMLDocumentClass();
            doc.write(new object[] { PageSource });
            doc.close();

            foreach (mshtml.IHTMLElement el in (mshtml.IHTMLElementCollection)doc.body.all)
            {
                if (el.tagName.ToLower() == "attributes")
                {
                    // get the handled information
                    string attrname  = el.getAttribute("name", 0).ToString();
                    string attrvalue = el.getAttribute("value", 0).ToString();
                    nvAttributes.Add(attrname, attrvalue);

                    if (attrname.ToLower() == "tagname" && attrvalue.ToLower() == "all")
                    {
                        ShowOnAll = true;
                    }
                }
                else if (el.tagName.ToLower() == "assembly")
                {
                    // get the assembly information
                    string path = el.getAttribute("path", 0).ToString();

                    if (File.Exists(path))
                    {
                        scAssemblies.Add(path);
                    }
                    else
                    {
                        scNotFoundAssemblies.Add(path);
                    }
                }
                else if (el.tagName.ToLower().Contains("languages"))
                {
                    Languages = el.getAttribute("value", 0).ToString();
                }
            }

            Title = doc.title;
        }
Exemple #8
0
 private void RichDescFrame_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
 {
     mshtml.HTMLDocumentClass doc = (mshtml.HTMLDocumentClass)RichDescFrame.Document;
     if (doc.body.innerHTML.Contains("404:"))
     {
         Logger.ReportError("Rich Description Not Found.");
         RichDescFrame.Visibility = Visibility.Hidden;
     }
     else
     {
         if (pluginList.SelectedItem != null)
         {
             RichDescFrame.Visibility = Visibility.Visible;
         }
     }
 }
Exemple #9
0
        public List <CrmWebService.CompanyCmsData> GenerateCCDList(string html, out int totalCount)
        {
            List <CrmWebService.CompanyCmsData> ccdList = new List <CompanyCmsData>();

            mshtml.HTMLDocumentClass doc = new mshtml.HTMLDocumentClass();
            doc.designMode = "on";
            doc.IHTMLDocument2_write(html);

            mshtml.IHTMLElement           divcnt    = doc.getElementById("cnt");
            mshtml.IHTMLElementCollection childrens = (mshtml.IHTMLElementCollection)divcnt.children;
            mshtml.IHTMLTable             table     = (mshtml.IHTMLTable)childrens.item(2);
            for (int i = 1; i < table.rows.length; i++)
            {
                CompanyCmsData item = new CompanyCmsData();

                mshtml.IHTMLTableRow row  = (mshtml.IHTMLTableRow)table.rows.item(i);
                mshtml.IHTMLElement  cell = (mshtml.IHTMLElement)row.cells.item(0);
                item.CmsId         = int.Parse(cell.innerText.Trim());
                cell               = (mshtml.IHTMLElement)row.cells.item(1);
                item.CompanyName   = string.IsNullOrEmpty(cell.innerText) ? "" : cell.innerText.Trim();
                cell               = (mshtml.IHTMLElement)row.cells.item(2);
                item.TTSStatusDesp = string.IsNullOrEmpty(cell.innerText) ? "" : cell.innerText.Trim();
                cell               = (mshtml.IHTMLElement)row.cells.item(3);
                item.ContactPhone  = string.IsNullOrEmpty(cell.innerText) ? "" : cell.innerText.Trim();
                cell               = (mshtml.IHTMLElement)row.cells.item(5);
                item.SalesName     = string.IsNullOrEmpty(cell.innerText) ? "" : cell.innerText.Trim();

                ccdList.Add(item);
            }
            totalCount = 0;
            mshtml.IHTMLElementCollection eles = doc.getElementsByName("totalCount");
            if (eles != null && eles.length > 0)
            {
                totalCount = int.Parse(((mshtml.IHTMLElement)eles.item(0)).getAttribute("value").ToString());
            }

            return(ccdList);
        }
Exemple #10
0
        public clsSnoTelStateList(string url)
        {
            URL = url;

            WebClient client = new WebClient();

            byte[] data = client.DownloadData(URL);
            mshtml.HTMLDocumentClass Doc = new mshtml.HTMLDocumentClass();
            string sHtml = System.Text.Encoding.ASCII.GetString(data);

            mshtml.IHTMLDocument2 oDoc = (mshtml.IHTMLDocument2)Doc;
            oDoc.write(sHtml);

            bool tableFound = false;

            foreach (mshtml.IHTMLElement element in (mshtml.IHTMLElementCollection)oDoc.body.all)
            {
                //if(element is mshtml.HTMLTableCellClass && element.innerText.Contains("SNOTEL Site List")) { tableFound=true;}
                if (element is mshtml.HTMLPhraseElement && element.innerText == "SNOTEL Site List")
                {
                    tableFound = true;
                }
                //if (element is mshtml.HTMLHeaderElementClass && element.innerText=="SNOTEL Site List") { tableFound = true; }
                else if (element is mshtml.HTMLTableClass && tableFound && element.innerText.Contains("Site Map"))
                {
                    tableFound = false;
                }
                else if (element is mshtml.HTMLParaElementClass && tableFound)
                {
                    if (!element.innerText.Contains("Please select"))
                    {
                        stateList.Add(new SnoTelState(element.innerText, element.innerHTML));
                    }
                }
            }
        }
Exemple #11
0
        public CompanyCmsData GenerateCCD(string html)
        {
            CompanyCmsData item = new CompanyCmsData();

            mshtml.HTMLDocumentClass doc = new mshtml.HTMLDocumentClass();
            doc.designMode = "on";
            doc.IHTMLDocument2_write(html);

            mshtml.IHTMLElement noteEle = doc.getElementById("note");   //公司简介
            if (noteEle != null)
            {
                item.CompanyDesp = string.IsNullOrEmpty(noteEle.innerText) ? "" : noteEle.innerText.Trim();
            }
            else
            {
                return(null);
            }
            mshtml.IHTMLElement ele = doc.getElementById("registeredAddress"); //注册地址
            if (ele.getAttribute("value") != null)
            {
                item.RegisterAddress = string.IsNullOrEmpty(ele.getAttribute("value").ToString()) ? "" : ele.getAttribute("value").ToString();
            }
            ele = doc.getElementById("address"); //地址
            if (ele.getAttribute("value") != null)
            {
                item.RealAddress = string.IsNullOrEmpty(ele.getAttribute("value").ToString()) ? "" : ele.getAttribute("value").ToString();
            }
            ele = doc.getElementById("businessLicense"); //营业执照号
            if (ele.getAttribute("value") != null)
            {
                item.CompanyIdNo = string.IsNullOrEmpty(ele.getAttribute("value").ToString()) ? "" : ele.getAttribute("value").ToString();
            }
            ele = doc.getElementById("email"); //营业执照号
            if (ele.getAttribute("value") != null)
            {
                item.CompanyEmail = string.IsNullOrEmpty(ele.getAttribute("value").ToString()) ? "" : ele.getAttribute("value").ToString();
            }
            ele = doc.getElementById("legalRepresentative"); //法人
            if (ele.getAttribute("value") != null)
            {
                item.LegalPerson = string.IsNullOrEmpty(ele.getAttribute("value").ToString()) ? "" : ele.getAttribute("value").ToString();
            }
            ele = doc.getElementById("contact"); //联系人
            if (ele.getAttribute("value") != null)
            {
                item.ContactPerson = string.IsNullOrEmpty(ele.getAttribute("value").ToString()) ? "" : ele.getAttribute("value").ToString();
            }
            ele = doc.getElementById("phone"); //电话
            if (ele.getAttribute("value") != null)
            {
                item.ContactPhone = string.IsNullOrEmpty(ele.getAttribute("value").ToString()) ? "" : ele.getAttribute("value").ToString();
            }
            ele = doc.getElementById("accountName"); //tts的admin账号
            if (ele.getAttribute("value") != null)
            {
                item.TTSAdminAccount = string.IsNullOrEmpty(ele.getAttribute("value").ToString()) ? "" : ele.getAttribute("value").ToString();
            }

            mshtml.IHTMLElementCollection eles = doc.getElementsByName("promotionNameDomestic");
            if (eles != null && eles.length > 0)
            {
                ele = (mshtml.IHTMLElement)eles.item(0);
                if (ele.getAttribute("value") != null)
                {
                    item.GuoneiWebName = string.IsNullOrEmpty(ele.getAttribute("value").ToString()) ? "" : ele.getAttribute("value").ToString();
                }
            }
            eles = doc.getElementsByName("promotionNameInternational");
            if (eles != null && eles.length > 0)
            {
                ele = (mshtml.IHTMLElement)eles.item(0);
                if (ele.getAttribute("value") != null)
                {
                    item.GuojiWebName = string.IsNullOrEmpty(ele.getAttribute("value").ToString()) ? "" : ele.getAttribute("value").ToString();
                }
            }
            ele = doc.getElementById("bossBackgrouds");   //公司简介
            item.BossBackground = string.IsNullOrEmpty(ele.innerText) ? "" : ele.innerText.Trim();

            return(item);
        }