示例#1
0
        public HtmlTag AddTag(string tagName, string textContent)
        {
            var tag = new HtmlTag(tagName);

            tag.SetInnerText(textContent);
            AddFrag(tag);
            return(this);
        }
示例#2
0
        public string ToHtml()
        {
            // return an html table

            var table = new HtmlTag("table style='xwidth: 1000px;	background-color: white ; border: 1px solid #CCC;'");

            //style='font-family: 'Open Sans', Trebuchet MS, sans-serif, Arial; font-weight: 300; font-size: 13px;color: #000;'

            var thStyle = "background-color: #e0e7a2;font-family: Open Sans, Trebuchet MS, sans-serif, Arial; font-weight: 300; font-size: 13px;color: #000;text-align:left;";
            var tdStyle = "font-family: Open Sans, Trebuchet MS, sans-serif, Arial; font-weight: 300; font-size: 12px;color: #000;border-bottom:1px solid #CCC;'";


            var     tr = new HtmlTag("tr");
            HtmlTag th;

            //var th = new HtmlTag("th style='width:100px;" + thStyle + "'");
            //th.SetInnerText("Status");
            //tr.AddTag(th);

            th = new HtmlTag("th width=20% style='" + thStyle + "'");
            th.SetInnerText("Title");
            tr.AddTag(th);

            th = new HtmlTag("th width=20% style='" + thStyle + "'");
            th.SetInnerText("Code");
            tr.AddTag(th);

            th = new HtmlTag("th width=50% style='" + thStyle + "'");
            th.SetInnerText("Description");
            tr.AddTag(th);

            th = new HtmlTag("th width=10% style='" + thStyle + "'");
            th.SetInnerText("Url");
            tr.AddTag(th);

            table.AddTag(tr);


            foreach (var line in ImportReportLines)
            {
                // tr
                tr = new HtmlTag("tr");
                HtmlTag td;

                var textColour = "";
                if (line.Status == StatusFailed)
                {
                    textColour = StatusFailed.DisplayName;
                }
                else if (line.Status == StatusWarning)
                {
                    textColour = StatusWarning.DisplayName;
                }
                else if (line.Status == StatusInfo)
                {
                    textColour = StatusInfo.DisplayName;
                }
                else if (line.Status == StatusSuccess)
                {
                    textColour = StatusSuccess.DisplayName;
                }
                else
                {
                    textColour = "";
                }
                //td = new HtmlTag("td style='" + textColour + "" + tdStyle + "'");
                //td.SetInnerText(line.Status);
                //tr.AddTag(td);

                if (line.LineType == LineTypeSubtitle)
                {
                    td = new HtmlTag("td colspan='4' style ='" + LineTypeSubtitle.DisplayName + "" + tdStyle + "'");
                    td.SetInnerText(line.Title);
                    tr.AddTag(td);
                }
                else if (line.LineType == LineTypeTitle)
                {
                    td = new HtmlTag("td colspan=4 style ='" + LineTypeTitle.DisplayName + "" + tdStyle + "'");
                    var spanTag = new HtmlTag("span style = '" + textColour + "'");
                    spanTag.SetInnerHtml(line.Title);
                    td.AddTag(spanTag);
                    tr.AddTag(td);
                }
                else
                {
                    td = new HtmlTag("td style ='" + textColour + "" + tdStyle + "'");
                    var spanTag = new HtmlTag("span style = '" + textColour + "'");
                    spanTag.SetInnerHtml(line.Title);
                    td.AddTag(spanTag);
                    tr.AddTag(td);
                }

                td = new HtmlTag("td style='" + tdStyle + "'");
                td.SetInnerText(line.Identifier);
                tr.AddTag(td);

                td = new HtmlTag("td style='" + tdStyle + "'");
                if (line.Description.IsBlank())
                {
                    td.SetInnerText("");
                }
                else
                {
                    td.SetInnerText(line.Description);
                }
                tr.AddTag(td);

                td = new HtmlTag("td style='" + tdStyle + "'");
                if (line.LinkUrl.IsNotBlank())
                {
                    td.AddRawHtml("<a href='" + Web.ResolveUrlFull(line.LinkUrl) + "' target='_blank'>" + line.UrlCaption.DefaultValue("View/edit") + "</a>");
                }
                tr.AddTag(td);

                table.AddTag(tr);
            }


            return(table.ToString());
        }