//Bootstrap helper function string CreateTableRow(BaseRecord record, ResultPrimarySecondary primarySecondary) { WeakHTMLTag tr = new WeakHTMLTag("tr"); //If the conclusion is MAJOR or FATAL, add a class to the TR so the entire row is colored if ((record.Conclusion == ConclusionEnum.Major) || (record.Conclusion == ConclusionEnum.Fatal)) { tr.CSSClass = ConclusionToCSSModifier(record.Conclusion); } //Add parameter for script details modal tr.Attributes["data-toggle"] = "modal"; tr.Attributes["data-target"] = "#modalDetails"; tr.Attributes["data-modal-title"] = WeakHTMLTag.HTMLEncode(record.ScriptFilename); tr.Attributes["data-modal-content"] = ConvertProcessMessagesToHTML(record.ProcessMessages); //Create <td> for Status string tdStatus = CreateHTMLElement_TdGlyphSpan(record.Conclusion); //Create <td> for Name and Script file string tdName = CreateHTMLElement_TdTextSmallText(record.Name, record.ScriptFilename); string tdValue = CreateHTMLElement_TdTextSmallText(primarySecondary.Primary, primarySecondary.Secondary); tr.HTML = tdStatus + tdName + tdValue; return(tr.ToString() + "\r\n"); }
string CreateHTMLElement_EmSmallText(string text) { WeakHTMLTag em = new WeakHTMLTag("em"); em.Text = text; WeakHTMLTag small = new WeakHTMLTag("small", em); return(small.ToString()); }
string CreateHTMLElement_SpanGlyphicon(ConclusionEnum conclusion) { //<span class="glyphicon glyphicon-ok" aria-hidden="true"> string glyphicon = ConclusionToGlyphicon(conclusion); WeakHTMLTag span = new WeakHTMLTag("span"); span.CSSClass = "glyphicon " + glyphicon; span.Attributes["aria-hidden"] = "true"; return(span.ToString()); }
string ConvertProcessMessagesToHTML(string processMessages) { string htmlEncoded = WeakHTMLTag.HTMLEncode(processMessages); StringBuilder sb = new StringBuilder(htmlEncoded); sb.Replace("\r\n", "<br/>"); sb.Replace("\n", "<br/>"); return(sb.ToString()); }
string CreateHTMLElement_TdTextSmallText(string text, string smallText) { //<td>NAME<br><small><em>SMALLTEXT</em></small></td> string smalltext = CreateHTMLElement_EmSmallText(smallText); WeakHTMLTag td = new WeakHTMLTag("td"); td.Text = text; td.HTML += "<br/>"; td.HTML += smalltext; return(td.ToString()); }
string CreateHTMLElement_TdGlyphSpan(ConclusionEnum conclusion) { //<td class="success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></td> WeakHTMLTag td = new WeakHTMLTag("td"); string cssClass = ConclusionToCSSModifier(conclusion); if (string.IsNullOrWhiteSpace(cssClass) == false) { td.Attributes["class"] = cssClass; } td.HTML = CreateHTMLElement_SpanGlyphicon(conclusion); return(td.ToString()); }
string CreateRecordDetails(string tagName, BaseRecord record, ResultPrimarySecondary resultPrimSecond) { //Yes, this somewhat cheating.... WeakHTMLTag tag = new WeakHTMLTag(tagName); WeakHTMLTag name = new WeakHTMLTag("Name"); name.Text = record.Name; WeakHTMLTag filename = new WeakHTMLTag("Filename"); filename.Text = record.ScriptFilename; WeakHTMLTag conclusion = new WeakHTMLTag("Conclusion"); conclusion.Text = ((int)record.Conclusion).ToString(); WeakHTMLTag conclusionString = new WeakHTMLTag("ConclusionString"); conclusionString.Text = record.Conclusion.ToString(); //Create sub tag "result" WeakHTMLTag primary = new WeakHTMLTag("Primary"); primary.Text = resultPrimSecond.Primary; WeakHTMLTag secondary = new WeakHTMLTag("Secondary"); secondary.Text = resultPrimSecond.Secondary; WeakHTMLTag result = new WeakHTMLTag("Result"); result.HTML = primary.ToString() + secondary.ToString(); //Construct the final XML tag.HTML = name.ToString() + filename.ToString() + conclusion.ToString() + conclusionString.ToString() + result.ToString(); return(tag.ToString()); }
//Bootstrap helper function string CreateTableRow(BaseRecord record, ResultPrimarySecondary primarySecondary) { WeakHTMLTag tr = new WeakHTMLTag("tr"); //If the conclusion is MAJOR or FATAL, add a class to the TR so the entire row is colored if ((record.Conclusion == ConclusionEnum.Major) || (record.Conclusion == ConclusionEnum.Fatal)) { tr.CSSClass = ConclusionToCSSModifier(record.Conclusion); } //Add parameter for script details modal tr.Attributes["data-toggle"] = "modal"; tr.Attributes["data-target"] = "#modalDetails"; tr.Attributes["data-modal-title"] = WeakHTMLTag.HTMLEncode(record.ScriptFilename); tr.Attributes["data-modal-content"] = ConvertProcessMessagesToHTML(record.ProcessMessages); //Create <td> for Status string tdStatus = CreateHTMLElement_TdGlyphSpan(record.Conclusion); //Create <td> for Name and Script file string tdName = CreateHTMLElement_TdTextSmallText(record.Name, record.ScriptFilename); string tdValue = CreateHTMLElement_TdTextSmallText(primarySecondary.Primary, primarySecondary.Secondary); tr.HTML = tdStatus + tdName + tdValue; return tr.ToString() + "\r\n"; }
string CreateHTMLElement_TdTextSmallText(string text, string smallText) { //<td>NAME<br><small><em>SMALLTEXT</em></small></td> string smalltext = CreateHTMLElement_EmSmallText(smallText); WeakHTMLTag td = new WeakHTMLTag("td"); td.Text = text; td.HTML += "<br/>"; td.HTML += smalltext; return td.ToString(); }
string CreateHTMLElement_TdGlyphSpan(ConclusionEnum conclusion) { //<td class="success"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></td> WeakHTMLTag td = new WeakHTMLTag("td"); string cssClass = ConclusionToCSSModifier(conclusion); if (string.IsNullOrWhiteSpace(cssClass) == false) { td.Attributes["class"] = cssClass; } td.HTML = CreateHTMLElement_SpanGlyphicon(conclusion); return td.ToString(); }
string CreateHTMLElement_SpanGlyphicon(ConclusionEnum conclusion) { //<span class="glyphicon glyphicon-ok" aria-hidden="true"> string glyphicon = ConclusionToGlyphicon(conclusion); WeakHTMLTag span = new WeakHTMLTag("span"); span.CSSClass = "glyphicon " + glyphicon; span.Attributes["aria-hidden"] = "true"; return span.ToString(); }
string CreateHTMLElement_EmSmallText(string text) { WeakHTMLTag em = new WeakHTMLTag("em"); em.Text = text; WeakHTMLTag small = new WeakHTMLTag("small", em); return small.ToString(); }
private void Replace(string valueName, string value) { _content.Replace("@@" + valueName + "@@", WeakHTMLTag.HTMLEncode(value)); }