示例#1
0
        public Property(HtmlAgilityPack.HtmlNode node, HtmlAgilityPack.HtmlAttribute itemscopeAttr)
        {
            this.node = node;
            this.itemscopeAttr = itemscopeAttr;

            nodeType = XmlNodeType.Element;
        }
示例#2
0
        public Item(HtmlAgilityPack.HtmlNode node)
        {
            this.node = node;

            var typeAttr = node.GetAttributeItemType();
            if(typeAttr != null)
            {
                var typeString = typeAttr.Value;
                Uri typeUri;
                Uri.TryCreate(typeString, UriKind.Absolute, out typeUri);
                this.Type = typeUri;
            }

            this.properties = GetProperties(node).GetEnumerator();
        }
        public RowInterpreter(HtmlAgilityPack.HtmlNode row)
        {
            this.row = row;
            getColumnList();

            this.isNewCourseBool = isNewCourse();
            this.isNewCourseBoolSet = true;
            this.isCancelledBool = isCancelled();
            this.isCancelledBoolSet = true;
            this.hasSectionIDBool = hasSectionID();
            hasSectionIDBoolSet = true;

            if (columns[0].Attributes["align"].Value == "CENTER" || columns[0].Attributes["align"].Value == "center")
            {
                startFromMiddle = true;
            }
        }
示例#4
0
        //자유게시판 파싱
        private void parsingSLRfree(HtmlAgilityPack.HtmlDocument doc)
        {
            string itemBaseURL = "http://www.slrclub.com/bbs/vx2.php?id=free&no=";
            string num         = "";
            string title;
            string filepath = textBox1.Text + System.DateTime.Now.ToString("yyMMdd") + "\\";
            bool   saveHTML;
            int    i;
            int    j;

            bool isSkip = false;

            HtmlAgilityPack.HtmlNode obj = doc.GetElementbyId("slrct");
            if (obj == null)
            {
                //사이트 접속 불가
            }
            else
            {
                for (i = 0; i < obj.SelectNodes("table").Count; i++)
                {
                    if (isSkip)
                    {
                        break;
                    }

                    HtmlAgilityPack.HtmlNode table = obj.SelectNodes("table")[i];

                    for (j = 0; j < table.SelectNodes("tr").Count; j++)
                    {
                        HtmlAgilityPack.HtmlNode tr = table.SelectNodes("tr")[j];

                        if (tr.SelectNodes("td").Count == 6)
                        {
                            if (!tr.SelectNodes("td")[0].InnerText.Equals("공지"))
                            {
                                num   = tr.SelectNodes("td")[0].InnerText;
                                title = tr.SelectNodes("td")[1].InnerText;
                                title = title.Substring(title.IndexOf("-->") + 3).Replace("&nbsp;", "");

                                //기존 게시물인지 검사
                                if (chkQueue(num))
                                {
                                    //검색어 검사
                                    if (chkSrchWrd(title, srchWrd_arr).Length > 0)
                                    {
                                        //제외단어 검사
                                        if (chkSrchWrd(title, exceptWrd_arr).Length == 0)
                                        {
                                            //날짜와 토픽으로 폴더 생성
                                            libMyUtil.clsFile.MakeDir(filepath + chkSrchWrd(title, srchWrd_arr) + "\\");
                                            saveHTML = false;

                                            if (radioButton1.Checked)
                                            {
                                                if (chkSrchWrd(title, captureWrd_arr).Length > 0)
                                                {
                                                    string captureServerAddress = objUtil.getAppCfg("captureServerAddress");
                                                    if (captureServerAddress == null)
                                                    {
                                                        captureServerAddress = "";
                                                    }
                                                    if (captureServerAddress.Length > 0)
                                                    {
                                                        //웹 호출로 캡쳐
                                                        using (WebClient forCapture = new WebClient())
                                                        {
                                                            string urlParam1  = "url=" + libMyUtil.clsWeb.encURL(itemBaseURL + num, "UTF-8");
                                                            string urlParam2  = "downloadPath=" + libMyUtil.clsWeb.encURL(filepath + chkSrchWrd(title, srchWrd_arr) + "\\" + num + ".png", "UTF-8");
                                                            string captureURL = "http://" + objUtil.getAppCfg("captureServerAddress") + "/capture/Capture.aspx?" + urlParam1 + "&" + urlParam2;

                                                            forCapture.DownloadStringAsync(new Uri(captureURL));
                                                        }
                                                    }
                                                    else
                                                    {
                                                        //libMyUtil.clsWeb.WebpageCapture_noReturn(itemBaseURL + num, filepath + chkSrchWrd(title, srchWrd_arr) + "\\" + num + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                                                    }
                                                    saveHTML = true;
                                                }

                                                clsSrchContents objSrchContents = new clsSrchContents(itemBaseURL, num, title, filepath + chkSrchWrd(title, srchWrd_arr) + "\\", saveHTML);
                                                objSrchContents.DoIt();
                                            }
                                            else if (radioButton2.Checked)
                                            {
                                                //캡쳐
                                                libMyUtil.clsWeb.WebpageCapture_noReturn(itemBaseURL + num, filepath + chkSrchWrd(title, srchWrd_arr) + "\\" + num + ".png", System.Drawing.Imaging.ImageFormat.Png);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    isSkip = true;
                                    break;//이전에 처리한 게시물이므로 다음 과정은 스킵
                                }
                            }
                        }
                    }

                    if (num.Length > 0)
                    {
                        break;//게시물 검색 완료 후 루프 탈출
                    }
                }
            }
        }
示例#5
0
 /// <summary>
 /// Returns a collection of all children nodes by given name of this element.
 /// </summary>
 public static IEnumerable <HtmlAgilityPack.HtmlNode> SelectChildren(this HtmlAgilityPack.HtmlNode source, string elementName)
 {
     return(source.ChildrenSelector(elementName));
 }
示例#6
0
 /// <summary>
 /// Gets the collection of attributes of matching elements.
 /// </summary>
 /// <param name="elementName">Use wildcards(*) to match all elements</param>
 public static IEnumerable <HtmlAgilityPack.HtmlAttribute> SelectChildrenAttributes(this HtmlAgilityPack.HtmlNode source, string elementName, string attributeName, string attributeValue)
 {
     return(source.ChildrenSelector(elementName).Where(w => w.HasAttribute(attributeName, attributeValue)).Select(s => s.Attributes[attributeName]));
 }
示例#7
0
 /// <summary>
 /// Gets the collection of attributes of matching elements.
 /// </summary>
 /// <param name="elementName">Use wildcards(*) to match all elements</param>
 public static IEnumerable <HtmlAgilityPack.HtmlAttribute> SelectDescendantsAttributesWithSelf(this HtmlAgilityPack.HtmlNode source, string elementName, string attributeName, string attributeValue)
 {
     return(source.DescendantsSelector(elementName, true).Where(w => w.HasAttribute(attributeName, attributeValue)).Select(s => s.Attributes[attributeName]));
 }
示例#8
0
 /// <summary>
 /// Gets the single descendant node or self that have attribute by given name and value of this element.
 /// </summary>
 /// <param name="elementName">Use wildcards(*) to search in all elements</param>
 public static HtmlAgilityPack.HtmlNode SelectSingleDescendantWithSelf(this HtmlAgilityPack.HtmlNode source, string elementName, string attributeName, string attributeValue)
 {
     return(source.DescendantsSelector(elementName, true).SingleOrDefault(s => s.HasAttribute(attributeName, attributeValue)));
 }
示例#9
0
 /// <summary>
 /// Checks whether the element has any attributes.
 /// </summary>
 public static bool HasAnyAttribute(this HtmlAgilityPack.HtmlNode source) => source.HasAttributes;
示例#10
0
 /// <summary>
 /// Gets the first descendant node that have attribute by given name and value of this element.
 /// </summary>
 /// <param name="elementName">Use wildcards(*) to search in all elements</param>
 public static HtmlAgilityPack.HtmlNode SelectFirstDescendant(this HtmlAgilityPack.HtmlNode source, string elementName, string attributeName, string attributeValue)
 {
     return(source.DescendantsSelector(elementName, false).FirstOrDefault(s => s.HasAttribute(attributeName, attributeValue)));
 }
        private void UpdateGridBDDThread()
        {
            List <string> _gatherableItemNames = new List <string>();
            List <string> _gridOKItemNames     = new List <string>();

            Service_Misc.LogText(_logTextBox, "Updating database...");

            MiqoCraftCore.MiqoCraftCore.DownloadGrids();

            try
            {
                List <MiqoItemPage> result            = new List <MiqoItemPage>();
                CookieCollection    logMiqobotCookies = Miqobot.LogInForum();

                CookieCollection             oCookies = new CookieCollection();
                HttpStatusCode               oCode    = HttpStatusCode.NotFound;
                HtmlAgilityPack.HtmlDocument answer   = Service_Misc.GetWebPageFromRequest("GET https://miqobot.com/forum/forums/topic/index-gathering-grids/ HTTP/1.1|Host: miqobot.com|Connection: keep-alive|Cache-Control: max-age=0|Upgrade-Insecure-Requests: 1|User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36|Sec-Fetch-Mode: navigate|Sec-Fetch-User: ?1|Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3|Sec-Fetch-Site: same-origin|Referer: https://miqobot.com/forum/forums/forum/grids-and-presets/|Accept-Encoding: gzip, deflate, br|Accept-Language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7|Cookie: wordpress_test_cookie=WP+Cookie+check; _ga=GA1.2.1771485810.1566089776||",
                                                                                           logMiqobotCookies, ref oCookies, ref oCode);
                if (null == answer)
                {
                    Service_Misc.LogText(_logTextBox, "Failed to update database. No answer from miqobot forum.");
                    return;
                }

                HtmlAgilityPack.HtmlNode firstAnswerNode = Service_Misc.GetFirstChildNode(answer.DocumentNode, "div", "topic-tag-gathering");

                List <HtmlAgilityPack.HtmlNode> listItemNodes = firstAnswerNode.Descendants("li").ToList();

                DirectoryInfo exeDirectory   = new DirectoryInfo(Service_Misc.GetExecutionPath());
                DirectoryInfo cacheDirectory = new DirectoryInfo(Path.Combine(exeDirectory.FullName, "CacheGrid"));
                if (!cacheDirectory.Exists)
                {
                    Service_Misc.LogText(_logTextBox, "Failed to compute database status, CacheGrid directory does not exist.");
                    return;
                }

                foreach (HtmlAgilityPack.HtmlNode node in listItemNodes)
                {
                    if (null == node)
                    {
                        continue;
                    }

                    string nodeInnerTextLower = node.InnerText.ToLower();
                    if (nodeInnerTextLower.Contains("Mining Your Own Business".ToLower()))
                    {
                        break;
                    }
                    if (nodeInnerTextLower.Contains("lv."))
                    {
                        //Found node !
                        string level    = nodeInnerTextLower.Split(new string[] { "  " }, StringSplitOptions.RemoveEmptyEntries)[0].Trim();
                        string itemName = nodeInnerTextLower.Split(new string[] { "  " }, StringSplitOptions.RemoveEmptyEntries)[1].Trim().Replace("(hidden)", "").Trim();

                        _gatherableItemNames.Add(itemName);
                        if (File.Exists(Path.Combine(cacheDirectory.FullName, itemName + " Grid.txt")))
                        {
                            _gridOKItemNames.Add(itemName);
                        }
                    }
                }

                lock (_locker)
                {
                    MiqoCraftOptions options = new MiqoCraftOptions();
                    options.Load(OptionLocation.GlobalOption);
                    options.ListGatherableItems = _gatherableItemNames;
                    options.ListGridOKItems     = _gridOKItemNames;
                    options.Save();
                }

                UpdateBDDStatusFromOptions();

                {
                    Service_Misc.LogText(_logTextBox, "Database updated !");
                    return;
                }
            }
            catch
            {
                Service_Misc.LogText(_logTextBox, "Failed to compute database status, CacheGrid directory does not exist.");
                return;
            }
        }
        private static void GetBottomInheritageAndReleventInfo(HtmlAgilityPack.HtmlNode containerNode, BsonDocument bsonDocument, bool continueReptile)
        {
            var inheritageNode = containerNode.SelectNodes(".//div[@class='inherit_xx2']/div/div");

            if (inheritageNode != null)
            {
                for (int i = 0; i < inheritageNode.Count; i += 2)
                {
                    var node = inheritageNode[i];
                    if (node.Attributes["class"].Value == "tit")
                    {
                        var nextNode  = inheritageNode[i + 1];
                        var tableRows = nextNode.SelectNodes(".//tr");

                        if (tableRows != null)
                        {
                            var rowArray = new BsonArray();
                            foreach (var row in tableRows)
                            {
                                var colums = row.SelectNodes(".//td");
                                if (colums == null)
                                {
                                    continue;
                                }
                                //抽出每一行的数据
                                var columnBsonDocument = new BsonDocument();
                                var columnArray        = new BsonArray();
                                foreach (var column in colums)
                                {
                                    BsonDocument columnBson = new BsonDocument();
                                    var          name       = column.SelectSingleNode(".//div").InnerText;
                                    columnBson.Add("key", name);
                                    columnBson.Add("value", column.InnerText.Replace(name, string.Empty));
                                    var link = column.SelectSingleNode(".//a"); //找到哪一行出现了对应项目的链接
                                    if (link != null)
                                    {
                                        columnBsonDocument.Add("link", link.Attributes["href"].Value);
                                    }
                                    columnArray.Add(columnBson);
                                }
                                columnBsonDocument.Add("content", columnArray);
                                rowArray.Add(columnBsonDocument);
                            }
                            if (rowArray != null)
                            {
                                if (node.InnerText.Trim().Contains("传承人"))
                                {
                                    if (continueReptile)
                                    {
                                        foreach (var column in rowArray)
                                        {
                                            var link = column.AsBsonDocument.GetValue("link");
                                            if (link != null && link.ToString().Trim().Length > 0)
                                            {
                                                GenerateCCRDetail(link.ToString().Trim());
                                            }
                                        }
                                    }
                                    bsonDocument.Add("inheritate", rowArray);
                                }
                                else
                                {
                                    bsonDocument.Add("ralevant", rowArray);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#13
0
 public static string value(this HtmlAgilityPack.HtmlNode htmlNode)
 {
     return(htmlNode.innerHtml());
 }
示例#14
0
 public static HtmlAgilityPack.HtmlNode FindElement(HtmlAgilityPack.HtmlNode elm, string name, bool recursive = true)
 {
     return(FindElement(elm, name, null, recursive));
 }
示例#15
0
 public static string innerHtml(this HtmlAgilityPack.HtmlNode htmlNode)
 {
     return(htmlNode.InnerHtml);
 }
示例#16
0
 public static string outerHtml(this HtmlAgilityPack.HtmlNode htmlNode)
 {
     return(htmlNode.OuterHtml);
 }
示例#17
0
        public static ascx_SourceCodeEditor showHtmlNodeLocation(this ascx_SourceCodeEditor codeEditor, HtmlAgilityPack.HtmlNode htmlNode)
        {
            var startLine   = htmlNode.Line;
            var startColumn = htmlNode.LinePosition;

            var endLine   = startLine;
            var endColumn = startColumn;

            if (htmlNode.NextSibling != null)
            {
                endLine   = htmlNode.NextSibling.Line;
                endColumn = htmlNode.NextSibling.LinePosition;
            }
            else
            {
                endColumn += htmlNode.html().size();
            }
            "selecting CodeEditor location: {0}:{1} -> {2}:{3}".info(startLine, startColumn, endLine, endColumn);
            codeEditor.clearMarkers();
            codeEditor.selectTextWithColor(startLine, startColumn, endLine, endColumn);
            codeEditor.caret_Line(startLine);
            codeEditor.refresh();

            return(codeEditor);
        }
示例#18
0
 /// <summary>
 /// Creates a new HtmlNode from the content provided
 /// </summary>
 internal HtmlNode(HtmlAgilityPack.HtmlNode node)
 {
     this._Container = node ?? HtmlAgilityPack.HtmlNode.CreateNode(" ");
 }
示例#19
0
 /// <summary>
 /// Detatches a node from the document (but doesn't delete it)
 /// </summary>
 public void Detatch()
 {
     HtmlAgilityPack.HtmlNode clone = this._Container.Clone();
     this._Container.Remove();
     this._Container = clone;
 }
示例#20
0
        private static void TransformXrefLink(HtmlAgilityPack.HtmlNode node, IDocumentBuildContext context)
        {
            var convertedNode = XRefDetails.ConvertXrefLinkNodeToXrefNode(node);

            node.ParentNode.ReplaceChild(convertedNode, node);
        }
示例#21
0
 public SictAuswertGbsAgentDialogueMissionObjectiveElementAusHtmlNodeTr(HtmlAgilityPack.HtmlNode HtmlNodeTr)
 {
     this.HtmlNodeTr = HtmlNodeTr;
 }
示例#22
0
        public static string ReplaceSliderAndAddons(ControllerContext controllerContext, string activeThemePath, string ContentText)
        {
            var context = getDbContextObject();

            string HTMLContent = HttpUtility.HtmlDecode(ContentText);

            HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();

            doc.OptionFixNestedTags = false;
            doc.OptionCheckSyntax   = false;
            doc.LoadHtml(HTMLContent);

            var Sliders = doc.DocumentNode.SelectNodes("//slider");

            if (Sliders != null)
            {
                foreach (var item in Sliders)
                {
                    var HTMLSlider = "";
                    int sliderid   = 0;
                    if (Int32.TryParse(item.InnerText, out sliderid))
                    {
                        List <CL_Slide> slides = context.Slides.Where(x => x.SliderId == sliderid).Select(x =>
                                                                                                          new CL_Slide {
                            Image = x.Image, Link = x.Link, Text = x.Text, Title = x.Title, DisplayOrder = x.DisplayOrder
                        }
                                                                                                          ).ToList();
                        HTMLSlider = RenderRazorViewToString(controllerContext, activeThemePath + "slider.cshtml", slides);
                    }
                    //HtmlAgilityPack.HtmlNode newNode = HtmlAgilityPack.HtmlNode.CreateNode(HTMLSlider);
                    //item.ParentNode.ReplaceChild(newNode, item);

                    HtmlAgilityPack.HtmlNode newNode = doc.CreateElement("div");
                    newNode.Attributes.Add("class", "divNTS");
                    newNode.InnerHtml = HTMLSlider;
                    item.ParentNode.ReplaceChild(newNode, item);
                }
            }
            var Addons = doc.DocumentNode.SelectNodes("//addon");

            if (Addons != null)
            {
                foreach (var addonTag in Addons)
                {
                    var            HTMLAddon  = "";
                    string         strAddonId = addonTag.InnerText.ToLower();
                    List <Content> addonsList = new List <Content>();
                    if (strAddonId == "all")
                    {
                        string addonType = addonTag.Attributes["name"].Value.ToLower();
                        addonsList = context.Content.Where(x => x.Type.ToLower() == addonType && x.isPublished == true && x.IsDeleted == false).OrderBy(x => x.ContentOrder).ToList();
                    }
                    else
                    {
                        int addonid = 0;
                        if (Int32.TryParse(strAddonId, out addonid))
                        {
                            Content addon = context.Content.Where(x => x.ID == addonid && x.isPublished == true && x.IsDeleted == false).FirstOrDefault();
                            if (addon != null)
                            {
                                addonsList.Add(addon);
                            }
                        }
                    }
                    foreach (var item in addonsList)
                    {
                        string itemHTMLAddon = item.AddonSubLayout;
                        itemHTMLAddon = itemHTMLAddon.Replace("{{Title}}", item.Title);
                        itemHTMLAddon = itemHTMLAddon.Replace("{{URL}}", (string.IsNullOrEmpty(item.URL) ? "#" : item.URL));
                        itemHTMLAddon = itemHTMLAddon.Replace("{{Description}}", item.Description);

                        HTMLAddon += itemHTMLAddon;
                    }

                    //var newNode = HtmlAgilityPack.HtmlNode.CreateNode(HTMLAddon);
                    //addonTag.ParentNode.ReplaceChild(newNode, addonTag);
                    HtmlAgilityPack.HtmlNode newNode = doc.CreateElement("div");
                    newNode.Attributes.Add("class", "divNTS");
                    newNode.InnerHtml = HTMLAddon;
                    addonTag.ParentNode.ReplaceChild(newNode, addonTag);
                }
            }
            HTMLContent = doc.DocumentNode.OuterHtml;
            return(HTMLContent);
        }
示例#23
0
 public SictAuswertGbsAgentDialogueMissionObjectiveAusHtmlNodeCaption(HtmlAgilityPack.HtmlNode HtmlNodeCaption)
 {
     this.HtmlNodeCaption = HtmlNodeCaption;
 }
示例#24
0
        public HttpResponseMessage Comunicazione(FormDataCollection formsValues)
        {
            string      regexMail = RegexUtils.EMAIL_REGEX.ToString();
            TitoliModel model     = new TitoliModel();

            try
            {
                List <ComAllegato> allegati = new List <ComAllegato>();
                SendMail.Model.ComunicazioniMapping.Comunicazioni comun = new SendMail.Model.ComunicazioniMapping.Comunicazioni();
                string destinatario = formsValues["Destinatario"];
                string conoscenza   = formsValues["Conoscenza"];
                string bcc          = formsValues["BCC"];
                string oggetto      = formsValues["Oggetto"];
                string testoMail    = formsValues["TestoMail"];
                string titolo       = formsValues["Titolo"];
                string sottotitolo  = formsValues["SottoTitolo"];
                string userid       = formsValues["SenderMail"];
                if (SessionManager <Dictionary <string, DTOFileUploadResult> > .exist(SessionKeys.DTO_FILE))
                {
                    Dictionary <string, DTOFileUploadResult> dictDto = SessionManager <Dictionary <string, DTOFileUploadResult> > .get(SessionKeys.DTO_FILE);

                    List <DTOFileUploadResult> dto = (List <DTOFileUploadResult>)dictDto.Values.ToList();
                    foreach (DTOFileUploadResult d in dto)
                    {
                        SendMail.Model.ComunicazioniMapping.ComAllegato allegato = new SendMail.Model.ComunicazioniMapping.ComAllegato();
                        allegato.AllegatoExt  = d.Extension;
                        allegato.AllegatoFile = d.CustomData;
                        allegato.AllegatoName = d.FileName;
                        allegato.AllegatoTpu  = "";
                        allegato.FlgInsProt   = AllegatoProtocolloStatus.FALSE;
                        allegato.FlgProtToUpl = AllegatoProtocolloStatus.FALSE;
                        allegati.Add(allegato);
                    }
                }
                comun.ComAllegati = allegati;
                string[] destinatari = destinatario.Split(';');
                for (int i = 0; i < destinatari.Length; i++)
                {
                    var match = Regex.Match(destinatari[i], regexMail, RegexOptions.IgnoreCase);
                    if (!match.Success)
                    {
                        model.success = "false";
                        model.message = "Attenzione mail destinatario non valida";
                        return(this.Request.CreateResponse <TitoliModel>(HttpStatusCode.OK, model));
                    }
                }
                // gestione destinatari
                ContactsApplicationMapping c = new ContactsApplicationMapping
                {
                    Mail          = destinatario,
                    IdSottotitolo = long.Parse(sottotitolo),
                    IdTitolo      = long.Parse(titolo)
                };
                Collection <ContactsApplicationMapping> en = new Collection <ContactsApplicationMapping>();
                en.Add(c);
                if (conoscenza != string.Empty)
                {
                    string[] conoscenze = conoscenza.Split(';');
                    for (int i = 0; i < conoscenze.Length; i++)
                    {
                        var match = Regex.Match(conoscenze[i], regexMail, RegexOptions.IgnoreCase);
                        if (!match.Success)
                        {
                            model.success = "false";
                            model.message = "Attenzione mail conoscenza non valida";
                            return(this.Request.CreateResponse <TitoliModel>(HttpStatusCode.OK, model));
                        }
                    }
                    ContactsApplicationMapping c1 = new ContactsApplicationMapping
                    {
                        Mail          = conoscenza,
                        IdSottotitolo = long.Parse(sottotitolo),
                        IdTitolo      = long.Parse(titolo)
                    };
                    Collection <ContactsApplicationMapping> en1 = new Collection <ContactsApplicationMapping>();
                    en1.Add(c1);
                    comun.SetMailDestinatari(en1, AddresseeType.CC);
                }
                if (bcc != string.Empty)
                {
                    string[] bccs = bcc.Split(';');
                    for (int i = 0; i < bcc.Length; i++)
                    {
                        var match = Regex.Match(bccs[i], regexMail, RegexOptions.IgnoreCase);
                        if (!match.Success)
                        {
                            model.success = "false";
                            model.message = "Attenzione mail destinatario nascosto non valido";
                            return(this.Request.CreateResponse <TitoliModel>(HttpStatusCode.OK, model));
                        }
                    }

                    ContactsApplicationMapping c2 = new ContactsApplicationMapping
                    {
                        Mail          = bcc,
                        IdSottotitolo = long.Parse(sottotitolo),
                        IdTitolo      = long.Parse(titolo)
                    };
                    Collection <ContactsApplicationMapping> en2 = new Collection <ContactsApplicationMapping>();
                    en2.Add(c2);
                    comun.SetMailDestinatari(en2, AddresseeType.CCN);
                }
                comun.SetMailDestinatari(en, AddresseeType.TO);
                // gestione body email
                MailContent content = new MailContent();
                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                string html = testoMail;
                HtmlAgilityPack.HtmlNode body = null;
                if (string.IsNullOrEmpty(html) == false)
                {
                    doc.LoadHtml(html);
                    doc.OptionAutoCloseOnEnd = true;
                    doc.OptionFixNestedTags  = true;
                    body = doc.DocumentNode.Descendants()
                           .Where(n => n.Name.Equals("body", StringComparison.InvariantCultureIgnoreCase))
                           .FirstOrDefault();
                }
                var ele = new HtmlAgilityPack.HtmlNode(HtmlAgilityPack.HtmlNodeType.Element, doc, 0);
                ele.Name            = "div";
                ele.InnerHtml       = testoMail;
                content.MailSubject = oggetto;
                content.MailText    = ele.OuterHtml;
                // gestione sender
                MailServerConfigFacade mailSCF = MailServerConfigFacade.GetInstance();
                MailUser mailuser = mailSCF.GetUserByUserId(decimal.Parse(userid));
                content.MailSender      = mailuser.EmailAddress;
                c.IdTitolo              = long.Parse(titolo);
                c.IdSottotitolo         = long.Parse(sottotitolo);
                comun.UtenteInserimento = MySecurityProvider.CurrentPrincipal.MyIdentity.UserName;
                comun.MailComunicazione = content;
                // da scommentare
                comun.FolderTipo = "O";
                comun.FolderId   = 2;
                ComunicazioniService com = new ComunicazioniService();
                com.InsertComunicazione(comun);
                model.success = "true";
                SessionManager <Dictionary <string, DTOFileUploadResult> > .del(SessionKeys.DTO_FILE);
            }
            catch (Exception ex)
            {
                if (ex.GetType() != typeof(ManagedException))
                {
                    ManagedException mEx = new ManagedException("Errore invio nuova mail. Dettaglio: " + ex.Message +
                                                                "StackTrace: " + ((ex.StackTrace != null) ? ex.StackTrace.ToString() : " vuoto "),
                                                                "ERR317",
                                                                string.Empty,
                                                                string.Empty,
                                                                ex.InnerException);
                    ErrorLogInfo err = new ErrorLogInfo(mEx);
                    log.Error(err);
                    model.success = "false";
                    model.message = ex.Message;
                    return(this.Request.CreateResponse <TitoliModel>(HttpStatusCode.OK, model));
                }
            }
            return(this.Request.CreateResponse <TitoliModel>(HttpStatusCode.OK, model));
        }
示例#25
0
        public override string Build(string domain)
        {
            string result = domain;

            try
            {
                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                string html = GetHTML(_baseurl + domain);
                if (html == null)
                {
                    result += ";-;;;;;;;;;;;;;;;;";
                }
                else
                {
                    doc.LoadHtml(html);

                    HtmlAgilityPack.HtmlNode node = doc.DocumentNode.SelectSingleNode("//span[@class=\'span8\']//h1[@class=\'h3\']");
                    if (node != null)
                    {
                        result = node.InnerText.Split(' ')[0].Trim();// Url
                    }
                    else
                    {
                        return(result + ";-;;;;;;;;;;;;;;;;");
                    }

                    node = doc.DocumentNode.SelectSingleNode("//section[@id=\'rank-panel-content\']//span[@class=\'globleRank\']//strong[@class=\'metrics-data align-vmiddle\']");
                    string Rank = node.InnerText.Trim();
                    if (Rank != "-")
                    {
                        result += ";" + Rank; //rank
                    }
                    else
                    {
                        return(result + ";-;;;;;;;;;;;;;;;;");
                    }


                    decimal firstvisitors = 0, addvisitors = 0;
                    node =
                        doc.DocumentNode.SelectSingleNode("//section[@id=\'keyword-content\']//strong[@class=\'metrics-data align-vmiddle\']");
                    string Organic_Search = "-";
                    string Overall_Visits = "-";
                    if (node != null)
                    {
                        Organic_Search = node.InnerText.Trim();
                        if (Organic_Search != "-")
                        {
                            string s = Organic_Search.Remove(node.InnerText.Trim().Length - 2);
                            s = s.Replace('.', ',');
                            try
                            {
                                firstvisitors = Convert.ToDecimal(s);
                            }
                            catch (Exception)
                            {
                                firstvisitors = 0;
                            }
                            node =
                                doc.DocumentNode.SelectSingleNode("//section[@id=\'keyword-content\']//span[@class=\'align-vmiddle change-wrapper change-down color-gen2 \']");
                            if (node == null)
                            {
                                node =
                                    doc.DocumentNode.SelectSingleNode("//section[@id=\'keyword-content\']//span[@class=\'align-vmiddle change-wrapper change-up \']");
                            }
                            if (node != null)
                            {
                                s = node.InnerText.Trim().Remove(node.InnerText.Trim().Length - 2);
                                s = s.Replace('.', ',');
                                try { addvisitors = Convert.ToDecimal(s); }
                                catch (Exception)
                                {
                                    addvisitors = 0;
                                }
                            }
                            Overall_Visits = (firstvisitors + addvisitors).ToString();
                            Overall_Visits.Remove(Overall_Visits.Length - 1);
                            Overall_Visits  = Overall_Visits.Replace(',', '.');
                            Overall_Visits  = Overall_Visits.TrimEnd('0').TrimEnd('.');
                            Overall_Visits += "K";
                        }
                    }
                    result += ";" + Overall_Visits; //Overall_Visits

                    HtmlAgilityPack.HtmlNodeCollection nc = doc.DocumentNode.SelectNodes("//section[@id=\'engagement-content\']//strong[@class=\'metrics-data align-vmiddle\']");
                    if (nc != null)
                    {
                        result += ";" + nc[2].InnerText.Trim();                   //Time_On_Site
                        result += ";" + nc[1].InnerText.Trim().Replace('.', ','); //Pages_per_Visit
                        result += ";" + nc[0].InnerText.Trim();                   //Bounce_Rate
                    }
                    else
                    {
                        result += ";;;";
                    }

                    result += ";" + Organic_Search.Remove(Organic_Search.IndexOf('.'));  // Organic_Search

                    HtmlAgilityPack.HtmlNodeCollection htmlNodes =
                        doc.DocumentNode.SelectNodes("//table[@id=\'demographics_div_country_table\']/tbody//tr");
                    if (htmlNodes != null & htmlNodes.Count > 1)
                    {
                        //Countres
                        int i = 1;
                        foreach (HtmlAgilityPack.HtmlNode row in htmlNodes)
                        {
                            string country = row.SelectSingleNode("td[1]").InnerText.Split(';')[1].Trim();
                            string procent = row.SelectSingleNode("td[2]").InnerText.Trim();
                            result += ";" + country + ";" + procent;
                            i++;
                        }
                        while (i < 5)
                        {
                            i++; result += ";;";
                        }
                    }
                    else
                    {
                        result += ";;;;;;;;;;";
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.ToString());
                return(domain + ";-;;;;;;;;;;;;;;;;");
            }
        }
示例#26
0
 /// <summary>
 /// Gets the single attribute of descendant node that have attribute by given name and value of this element.
 /// </summary>
 /// <param name="elementName">Use wildcards(*) to search in all elements</param>
 public static HtmlAgilityPack.HtmlAttribute SelectSingleDescendantAttribute(this HtmlAgilityPack.HtmlNode source, string elementName, string attributeName, string attributeValue)
 {
     return(source.DescendantsSelector(elementName, false).SingleOrDefault(s => s.HasAttribute(attributeName, attributeValue))?.Attributes[attributeName]);
 }
 private void extractTimetableNode()
 {
     timetableNode = timetableDocument.DocumentNode.SelectSingleNode(".//table");
 }
示例#28
0
 /// <summary>
 /// Checks whether the element has any attributes with the specified name.
 /// </summary>
 /// <param name="attributeName">Use wildcards at the beginning or the end, or both, for any value.</param>
 public static bool HasAttribute(this HtmlAgilityPack.HtmlNode source, string attributeName) => source.HasAttribute(attributeName, "*", "");
示例#29
0
        /* Parsing of all sets currenlty in Modern */

        /* http://stackoverflow.com/questions/293342/htmlagilitypack-drops-option-end-tags
         * Apparently <option> tags are expected to have end tags, but HTMLAgilityPack
         *  thinks they shouldn't and so causes errors. So there is a change of option to my_option to get around this.
         */
        private List <string> ParseModern(string HTMLIn)
        {
            HTMLIn = HTMLIn.Replace("<option", "<my_option");
            HTMLIn = HTMLIn.Replace("</option>", "</my_option>");

            // Clean Up setnames to match mtgprice sitenames.
            HTMLIn = HTMLIn.Replace("&nbsp;", "");                    // Remove this char
            HTMLIn = HTMLIn.Replace("Magic 20", "M");                 // 'Magic 20XX' to 'MXX'
            HTMLIn = HTMLIn.Replace("Dragon's Maze", "Dragons Maze"); // 'Dragons Maze' not 'Dragon's Maze'
            HTMLIn = HTMLIn.Replace(": City of Guilds", "");          // 'Ravnica' not 'Ravnica: City of Guilds'
            HTMLIn = HTMLIn.Replace("Tenth", "10th");
            HTMLIn = HTMLIn.Replace("Ninth", "9th");
            HTMLIn = HTMLIn.Replace("Eighth", "8th");


            // Double check formatting
            if (HTMLIn.Contains("<ul class=\"list\">") == false)
            {
                log.Error(ModernURL + " formatting has been changed. Need to update the application.");
                return(null);
            }

            List <string> ret = new List <string>();

            HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
            htmlDoc.LoadHtml(HTMLIn.ToString());

            if (htmlDoc.ParseErrors != null && htmlDoc.ParseErrors.Count() > 0)
            {
                foreach (HtmlAgilityPack.HtmlParseError err in htmlDoc.ParseErrors)
                {
                    log.Error("HTMLAgilityPack Error: " + err.Code + " " + err.Reason + " " + err.SourceText + " " + err.Line);
                }
                return(null);
            }

            if (htmlDoc.DocumentNode == null)
            {
                log.Error("FormatParser::ParseStandard(): DocumentNode is null");
                return(null);
            }
            HtmlAgilityPack.HtmlNode bodyNode = htmlDoc.DocumentNode.SelectSingleNode("//ul[@class = 'list']");

            if (bodyNode == null)
            {
                log.Error("FormatParser::ParseStandard(): bodyNode is null");
                return(null);
            }

            foreach (HtmlAgilityPack.HtmlNode childNode in bodyNode.ChildNodes)
            {
                if (childNode == null)
                {
                    continue;
                }
                foreach (HtmlAgilityPack.HtmlNode emNode in childNode.ChildNodes)
                {
                    if (emNode.Name == "em")
                    {
                        ret.Add(emNode.InnerText);
                    }
                }
            }

            return(ret);
        }
示例#30
0
 /// <summary>
 /// Checks whether the element has any attributes with the specified name and value.
 /// </summary>
 /// <param name="attributeName">Use wildcards at the beginning or the end, or both, for any value.</param>
 /// <param name="attributeValue">Use wildcards at the beginning or the end, or both, for any value.</param>
 public static bool HasAttribute(this HtmlAgilityPack.HtmlNode source, string attributeName, string attributeValue)
 {
     return(source.HasAttribute(attributeName, attributeValue, ""));
 }
        public override ParsedResult Parse(string domain, string proxy = null)
        {
            try
            {
                ParsedResult result = new ParsedResult();
                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                string html = getHTML(domain, proxy);

                if (html == null)
                {
                    result.Url  = domain;
                    result.Rank = "-";
                    return(result);
                }
                doc.LoadHtml(html);

                HtmlAgilityPack.HtmlNode node = doc.DocumentNode.SelectSingleNode("//h1[@class=\"domain text-center-xs text-left-not-xs\"]");
                if (node != null)
                {
                    result.Url = node.InnerText.Trim().ToLower();
                }
                else
                {
                    result.Url  = domain;
                    result.Rank = "-";
                    return(result);
                }
                node = doc.DocumentNode.SelectSingleNode("//div[@id=\"worldRanking-item\"]//div[@class=\"rankValue\"]");
                if (node != null)
                {
                    var rg = new Regex(@"#(.*?)<");
                    result.Rank = rg.Match(node.InnerHtml.TrimEnd()).Groups[1].Value;
                }

                HtmlAgilityPack.HtmlNodeCollection nc = doc.DocumentNode.SelectNodes("//td[@class=\"text-right\"]");
                if (nc != null)
                {
                    result.Overall_Visits  = nc[0].InnerText;
                    result.Time_On_Site    = nc[1].InnerText;
                    result.Pages_per_Visit = nc[2].InnerText;
                    result.Pages_per_Visit = result.Pages_per_Visit.Replace('.', ',');
                    result.Bounce_Rate     = nc[3].InnerText;
                }

                node = doc.DocumentNode.SelectSingleNode("//div[@id=\"review\"]");
                if (node != null)
                {
                    var rg = new Regex("\"Organic Search\" [(](.*?)%");
                    result.Organic_Search = rg.Match(node.InnerText).Groups[1].Value.TrimEnd();
                    if (result.Organic_Search.Contains('.'))
                    {
                        result.Organic_Search = result.Organic_Search.Remove(result.Organic_Search.IndexOf('.'));
                    }
                }

                HtmlAgilityPack.HtmlNodeCollection htmlNodes =
                    doc.DocumentNode.SelectNodes("//table[@id=\"countriesBreakdownTable\"]//tr");
                if (htmlNodes != null)
                {
                    foreach (HtmlAgilityPack.HtmlNode row in htmlNodes)
                    {
                        string country = row.SelectSingleNode("td").InnerText;
                        string procent = row.SelectSingleNode("td/div[@class=\"shareValue\"]").InnerText;
                        result.CountresAdd(country, procent);
                    }
                }
                result.CountraseRelease();
                return(result);
            }
            catch (Exception ex)  { MessageBox.Show(ex.ToString()); return(new ParsedResult {
                    Url = domain, Rank = "-"
                }); }
        }
示例#32
0
 /// <summary>
 /// Gets the first attribute of descendant node or self that have attribute by given name and value of this element.
 /// </summary>
 /// <param name="elementName">Use wildcards(*) to search in all elements</param>
 public static HtmlAgilityPack.HtmlAttribute SelectFirstDescendantAttributeWithSelf(this HtmlAgilityPack.HtmlNode source, string elementName, string attributeName, string attributeValue)
 {
     return(source.DescendantsSelector(elementName, true).FirstOrDefault(s => s.HasAttribute(attributeName, attributeValue))?.Attributes[attributeName]);
 }
示例#33
0
        public static IEElement[] GetElementsWithuiSelector(IESelector selector, IElement fromElement = null, int maxresults = 1)
        {
            IEElement iefromElement = fromElement as IEElement;
            Browser   browser;

            if (iefromElement != null)
            {
                browser = iefromElement.Browser;
            }
            else
            {
                browser = Browser.GetBrowser(false);
            }
            if (browser == null)
            {
                Log.Warning("Failed locating an Internet Explore instance");
                return(new IEElement[] { });
            }

            var sw = new System.Diagnostics.Stopwatch();

            sw.Start();

            IEElement _fromElement = fromElement as IEElement;
            var       selectors    = selector.Where(x => x.Enabled == true && x.Selector == null).ToList();

            var current = new List <IEElement>();

            IEElement[] result = null;

            int startIndex = 1;

            if (!string.IsNullOrEmpty(selector.xpath))
            {
                // https://stackoverflow.com/questions/6953553/is-there-a-js-library-to-provide-xpath-capacities-to-ie

                var _results = new List <IEElement>();

                try
                {
                    string body = null;
                    Log.Selector(string.Format("Create IHTMLDocument3 {0:mm\\:ss\\.fff}", sw.Elapsed));
                    MSHTML.IHTMLDocument3 sourceDoc = (MSHTML.IHTMLDocument3)browser.Document;
                    body = sourceDoc.documentElement.outerHTML;

                    HtmlAgilityPack.HtmlDocument targetDoc = new HtmlAgilityPack.HtmlDocument();
                    Log.SelectorVerbose(string.Format("targetDoc.LoadHtml {0:mm\\:ss\\.fff}", sw.Elapsed));
                    targetDoc.LoadHtml(body);


                    if (fromElement != null && fromElement is IEElement fromie)
                    {
                        HtmlAgilityPack.HtmlNode from = targetDoc.DocumentNode.SelectSingleNode(fromie.xpath);
                        if (from == null)
                        {
                            throw new Exception("Failed locating from node, by xpath '" + fromie.xpath + "'");
                        }
                        Log.Selector(string.Format("SelectNodes {0:mm\\:ss\\.fff}", sw.Elapsed));
                        var xpath = selector.xpath;
                        if (xpath.StartsWith("//"))
                        {
                            xpath = "." + xpath;
                        }
                        var nodes = from.SelectNodes(xpath);
                        if (nodes != null)
                        {
                            foreach (var node in nodes)
                            {
                                Log.SelectorVerbose(string.Format("new IEElement {0:mm\\:ss\\.fff}", sw.Elapsed));
                                var ele = new IEElement(browser, node);
                                _results.Add(ele);
                                if (_results.Count >= maxresults)
                                {
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        Log.Selector(string.Format("SelectNodes {0:mm\\:ss\\.fff}", sw.Elapsed));
                        var nodes = targetDoc.DocumentNode.SelectNodes(selector.xpath);
                        if (nodes != null)
                        {
                            foreach (var node in nodes)
                            {
                                Log.SelectorVerbose(string.Format("new IEElement {0:mm\\:ss\\.fff}", sw.Elapsed));
                                var ele = new IEElement(browser, node);
                                _results.Add(ele);
                                if (_results.Count >= maxresults)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    browser = Browser.GetBrowser(true);
                }
                Log.Selector(string.Format("GetElementsWithuiSelector::end {0:mm\\:ss\\.fff}", sw.Elapsed));
                return(_results.ToArray());
            }
            if (iefromElement != null)
            {
                startIndex = 0;
                current.Add(iefromElement);
            }
            else
            {
                MSHTML.IHTMLElement startfrom = null;
                startfrom = browser.Document.documentElement;
                current.Add(new IEElement(browser, startfrom));
            }
            for (var i = startIndex; i < selectors.Count; i++)
            {
                var s        = new IESelectorItem(selectors[i]);
                var elements = new List <IEElement>();
                elements.AddRange(current);
                current.Clear();
                int failcounter = 0;
                do
                {
                    foreach (var _element in elements)
                    {
                        MSHTML.IHTMLElement[] matches;
                        if (frameTags.Contains(_element.TagName.ToUpper()))
                        {
                            if (s.tagName.ToUpper() == "HTML")
                            {
                                i++; s = new IESelectorItem(selectors[i]);
                            }
                            var _f = _element.RawElement as MSHTML.HTMLFrameElement;
                            MSHTML.DispHTMLDocument doc = (MSHTML.DispHTMLDocument)((SHDocVw.IWebBrowser2)_f).Document;
                            var _doc = doc.documentElement as MSHTML.IHTMLElement;
                            matches = ((IESelectorItem)s).matches(_doc);

                            browser.elementx     += _f.offsetLeft;
                            browser.elementy     += _f.offsetTop;
                            browser.frameoffsetx += _f.offsetLeft;
                            browser.frameoffsety += _f.offsetTop;
                        }
                        else
                        {
                            matches = ((IESelectorItem)s).matches(_element.RawElement);
                        }
                        var uimatches = new List <IEElement>();
                        foreach (var m in matches)
                        {
                            var ui = new IEElement(browser, m);
                            uimatches.Add(ui);
                        }
                        current.AddRange(uimatches.ToArray());
                        Log.Selector("add " + uimatches.Count + " matches to current");
                    }
                    if (current.Count == 0)
                    {
                        ++failcounter;
                        string message = string.Format("Failer # " + failcounter + " finding any hits for selector # " + i + " {0:mm\\:ss\\.fff}", sw.Elapsed) + "\n";
                        message += "lookin for \n" + s.ToString() + "\n";
                        foreach (var _element in elements)
                        {
                            MSHTML.IHTMLElementCollection children = (MSHTML.IHTMLElementCollection)_element.RawElement.children;
                            foreach (MSHTML.IHTMLElement elementNode in children)
                            {
                                var ui = new IEElement(browser, elementNode);
                                message += ui.ToString() + "\n";
                            }
                            var matches = ((IESelectorItem)s).matches(_element.RawElement);
                        }
                        Log.Selector(message);
                    }
                    else
                    {
                        Log.Selector(string.Format("Found " + current.Count + " hits for selector # " + i + " {0:mm\\:ss\\.fff}", sw.Elapsed));
                    }
                } while (failcounter < 2 && current.Count == 0);

                if (i == (selectors.Count - 1))
                {
                    result = current.ToArray();
                }
                if (current.Count == 0 && Config.local.log_selector)
                {
                    var message = "needed to find " + Environment.NewLine + selectors[i].ToString() + Environment.NewLine + "but found only: " + Environment.NewLine;
                    foreach (var element in elements)
                    {
                        MSHTML.IHTMLElementCollection children = (MSHTML.IHTMLElementCollection)element.RawElement.children;
                        foreach (MSHTML.IHTMLElement c in children)
                        {
                            try
                            {
                                // message += automationutil.getSelector(c, (i == selectors.Count - 1)) + Environment.NewLine;
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                    Log.Selector(message);
                    return(new IEElement[] { });
                }
            }
            if (result == null)
            {
                return new IEElement[] { }
            }
            ;
            Log.Selector(string.Format("GetElementsWithuiSelector::end {0:mm\\:ss\\.fff}", sw.Elapsed));
            return(result);
        }
    }
示例#34
0
 /// <summary>
 /// Returns a collection of all children nodes that have attribute by given name of this element.
 /// </summary>
 /// <param name="elementName">Use wildcards(*) to match all elements</param>
 public static IEnumerable <HtmlAgilityPack.HtmlNode> SelectChildren(this HtmlAgilityPack.HtmlNode source, string elementName, string attributeName)
 {
     return(source.ChildrenSelector(elementName).Where(w => w.HasAttribute(attributeName)));
 }
示例#35
0
        public static XRefDetails From(HtmlAgilityPack.HtmlNode node)
        {
            if (node.Name != "xref")
            {
                throw new NotSupportedException("Only xref node is supported!");
            }
            var xref    = new XRefDetails();
            var uid     = node.GetAttributeValue("uid", null);
            var rawHref = node.GetAttributeValue("href", null);
            NameValueCollection queryString = null;

            if (!string.IsNullOrEmpty(rawHref))
            {
                if (!string.IsNullOrEmpty(uid))
                {
                    Logger.LogWarning($"Both href and uid attribute are defined for {node.OuterHtml}, use href instead of uid.");
                }

                string others;
                var    anchorIndex = rawHref.IndexOf("#");
                if (anchorIndex == -1)
                {
                    xref.Anchor = string.Empty;
                    others      = rawHref;
                }
                else
                {
                    xref.Anchor = rawHref.Substring(anchorIndex);
                    others      = rawHref.Remove(anchorIndex);
                }
                var queryIndex = others.IndexOf("?");
                if (queryIndex == -1)
                {
                    xref.Uid = HttpUtility.UrlDecode(others);
                }
                else
                {
                    xref.Uid    = HttpUtility.UrlDecode(others.Remove(queryIndex));
                    queryString = HttpUtility.ParseQueryString(others.Substring(queryIndex));
                }
            }
            else
            {
                xref.Uid = uid;
            }

            xref.InnerHtml       = node.InnerHtml;
            xref.DisplayProperty = node.GetAttributeValue("displayProperty", queryString?.Get("displayProperty") ?? XRefSpec.NameKey);
            xref.AltProperty     = node.GetAttributeValue("altProperty", queryString?.Get("altProperty") ?? "fullName");
            xref.Text            = node.GetAttributeValue("text", node.GetAttributeValue("name", StringHelper.HtmlEncode(queryString?.Get("text"))));
            xref.Alt             = node.GetAttributeValue("alt", node.GetAttributeValue("fullname", StringHelper.HtmlEncode(queryString?.Get("alt"))));

            xref.Title                 = node.GetAttributeValue("title", queryString?.Get("title"));
            xref.SourceFile            = node.GetAttributeValue("sourceFile", null);
            xref.SourceStartLineNumber = node.GetAttributeValue("sourceStartLineNumber", 0);
            xref.SourceEndLineNumber   = node.GetAttributeValue("sourceEndLineNumber", 0);

            // Both `data-raw-html` and `data-raw-source` are html encoded. Use `data-raw-html` with higher priority.
            // `data-raw-html` will be decoded then displayed, while `data-raw-source` will be displayed directly.
            xref.RawSource = node.GetAttributeValue("data-raw-source", null);
            var raw = node.GetAttributeValue("data-raw-html", null);

            if (!string.IsNullOrEmpty(raw))
            {
                xref.Raw = StringHelper.HtmlDecode(raw);
            }
            else
            {
                xref.Raw = xref.RawSource;
            }

            xref.ThrowIfNotResolved = node.GetAttributeValue("data-throw-if-not-resolved", false);

            return(xref);
        }
示例#36
0
        /// <summary>
        /// Creates textboxes with labels
        /// TODO: textboxes are not copy-pastable, not even selectable
        /// </summary>
        /// <param name="element">Module element</param>
        /// <returns></returns>
        public bool SetContent(HtmlAgilityPack.HtmlNode element)
        {
            // Save element (<div class='modulecontainer'><module ....)
            this.activeElem = element;

            // Create module
            module = CXMLParser.Instance.GetModuleFromNode(element.FirstChild);

            // Clear Properties
            tableLayoutPanel1.Controls.Clear();
            tableLayoutPanel1.RowStyles.Clear();
            textboxList.Clear();

            // Create row for each setup_ property in moduleSetup class
            int row = 0;
            foreach (HtmlAgilityPack.HtmlAttribute attribute in element.FirstChild.Attributes)
            {
                if (attribute.Name.Length > 6 && attribute.Name.StartsWith("setup_"))
                {

                    tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 30));

                    Label label = new Label();
                    label.Text = attribute.Name.Substring(6);
                    tableLayoutPanel1.Controls.Add(label, 0, row);

                    TextBox textbox = new TextBox();
                    textbox.Width = 200;
                    textbox.Name = attribute.Name;
                    textbox.Text = attribute.Value;
                    textbox.KeyDown += new KeyEventHandler(textbox_KeyDown);
                    textboxList.Add(textbox);
                    tableLayoutPanel1.Controls.Add(textbox, 1, row++);
                }
            }

            this.Text = element.FirstChild.Attributes["name"].Value + " properties";
            return true;
        }
示例#37
0
        public static String GetElementInnerHtml(HtmlAgilityPack.HtmlNode elm, string name, bool recursive = true)
        {
            var find = FindElement(elm, name, recursive);

            return(find == null ? String.Empty : find.InnerHtml);
        }