public void should_add_cells_to_rows_in_the_tbody() { var expected = getExpectedHtml(null, "<tr><td>cell 1</td><td>cell 2</td></tr><tr><td>cell 3</td><td>cell 4</td></tr>", null); var tag = new TableTag(); var bodyRow1 = tag.AddBodyRow(); bodyRow1.Cell().Text("cell 1"); bodyRow1.Cell("cell 2"); var bodyRow2 = tag.AddBodyRow(); bodyRow2.Cell("cell 3"); bodyRow2.Cell("cell 4"); tag.ToString().ShouldEqual(expected); }
private void writeProperties(Description description) { if (description.Properties.Any()) { var table = new TableTag(); table.AddClass("desc-properties"); description.Properties.Each((key, value) => { table.AddBodyRow(row => { row.Header(key); row.Cell(value); }); }); Append(table); } }
public static string WrapInNestedCenteringTable(string htmlString) { // ReSharper disable StringLiteralTypo var emailCenterTable = new TableTag(); emailCenterTable.Attr("width", "100%"); emailCenterTable.Attr("border", "0"); emailCenterTable.Attr("cellspacing", "0"); emailCenterTable.Attr("cellpadding", "0"); var emailCenterRow = emailCenterTable.AddBodyRow(); var emailCenterLeftCell = emailCenterRow.Cell(); emailCenterLeftCell.Attr("max-width", "1%"); emailCenterLeftCell.Attr("align", "center"); emailCenterLeftCell.Attr("valign", "top"); emailCenterLeftCell.Text(" ").Encoded(false); var emailCenterContentCell = emailCenterRow.Cell(); emailCenterContentCell.Attr("width", "100%"); emailCenterContentCell.Attr("align", "center"); emailCenterContentCell.Attr("valign", "top"); var emailCenterRightCell = emailCenterRow.Cell(); emailCenterRightCell.Attr("max-width", "1%"); emailCenterRightCell.Attr("align", "center"); emailCenterRightCell.Attr("valign", "top"); emailCenterRightCell.Text(" ").Encoded(false); // ReSharper restore StringLiteralTypo var outerTable = new TableTag(); emailCenterContentCell.Children.Add(outerTable); outerTable.Style("width", "100%"); outerTable.Style("max-width", "900px"); outerTable.TBody.Text(htmlString).Encoded(false); return(emailCenterTable.ToString()); }
public void smoke_test_document_with_tags() { var document = new HtmlDocument(); document.Body.Add("h1").Text("Hello"); var table = new TableTag(); table.AddHeaderRow(row => { row.Header("a"); row.Header("b"); }); table.AddBodyRow(row => { row.Cell("1"); row.Cell("2"); }); Console.WriteLine(document.ToString()); }
public static HtmlTag WriteBehaviorChainTable(IEnumerable <BehaviorChain> chains, params IColumn[] columns) { var table = new TableTag(); table.Attr("cellspacing", "0"); table.Attr("cellpadding", "0"); table.AddHeaderRow(row => { columns.Each(c => row.Header(c.Header())); }); chains.Each(chain => { table.AddBodyRow(row => { columns.Each(col => { col.WriteBody(chain, row, row.Cell()); }); }); }); return(table); }
public string ToHtml() { var table = new TableTag(); table.AddClass("table"); table.AddClass("table-striped"); table.AddHeaderRow(row => { row.Header("Details"); row.Header("Duration (ms)"); row.Header("Method"); row.Header("Endpoint"); row.Header("Status"); row.Header("Content Type"); }); _logs.Each(log => { var url = _runtime.BaseAddress.TrimEnd('/') + "/_fubu/#/fubumvc/request-details/" + log.Id; table.AddBodyRow(row => { row.Cell().Add("a").Text("Details").Attr("href", url).Attr("target", "_blank"); row.Cell(log.ExecutionTime.ToString()).Attr("align", "right"); var summary = new HttpRequestSummary(log); row.Cell(summary.method); row.Cell(log.Title()); row.Cell(summary.status.ToString()); row.Cell(summary.contentType); }); }); return(table.ToString()); }
private HtmlTag reportForSerializer(Type serializerType) { var timing = _timings[serializerType]; var div = new HtmlTag("div"); div.Add("h3").Text("Serializer: " + serializerType.Name); var table = new TableTag(); div.Append(table); table.AddHeaderRow(tr => { tr.Header("Where Type"); tr.Header("1K"); tr.Header("10K"); tr.Header("100K"); //tr.Header("1M"); }); table.AddBodyRow(tr => { tr.Header("JSON Locator Only"); var dict = timing.Timings[typeof(JsonLocatorOnly)]; tr.Cell(dict[1000].ToString()); tr.Cell(dict[10000].ToString()); tr.Cell(dict[100000].ToString()); //tr.Cell(dict[1000000].ToString()); }); table.AddBodyRow(tr => { tr.Header("jsonb_to_record + lateral join"); var dict = timing.Timings[typeof(JsonBToRecord)]; tr.Cell(dict[1000].ToString()); tr.Cell(dict[10000].ToString()); tr.Cell(dict[100000].ToString()); //tr.Cell(dict[1000000].ToString()); }); table.AddBodyRow(tr => { tr.Header("searching by duplicated field"); var dict = timing.Timings[typeof(DateIsSearchable)]; tr.Cell(dict[1000].ToString()); tr.Cell(dict[10000].ToString()); tr.Cell(dict[100000].ToString()); //tr.Cell(dict[1000000].ToString()); }); table.AddBodyRow(tr => { tr.Header("searching by containment operator"); var dict = timing.Timings[typeof(ContainmentOperator)]; tr.Cell(dict[1000].ToString()); tr.Cell(dict[10000].ToString()); tr.Cell(dict[100000].ToString()); //tr.Cell(dict[1000000].ToString()); }); return(div); }
public HtmlTag ToTableDetails() { var div = new HtmlTag("div"); var headers = new TableTag(); div.Add("h5").Text("Headers"); div.Append(headers); headers.AddClass("table").AddClass("table-striped"); headers.AddHeaderRow(row => { row.Header("Header Key"); row.Header("Header Value"); }); var envelope = Records[0].Envelope; headers.WriteEnvelopeProperty(envelope, x => x.Source); headers.WriteEnvelopeProperty(envelope, x => x.MessageType); headers.WriteEnvelopeProperty(envelope, x => x.ReplyUri); headers.WriteEnvelopeProperty(envelope, x => x.ContentType); headers.WriteEnvelopeProperty(envelope, x => x.CorrelationId); headers.WriteEnvelopeProperty(envelope, x => x.CausationId); // TODO -- come back and add saga id headers.WriteEnvelopeProperty(envelope, x => x.Destination); headers.WriteEnvelopeProperty(envelope, x => x.AcceptedContentTypes); headers.WriteEnvelopeProperty(envelope, x => x.ReplyRequested); headers.WriteEnvelopeProperty(envelope, x => x.AckRequested); headers.WriteEnvelopeProperty(envelope, x => x.ExecutionTime); headers.WriteEnvelopeProperty(envelope, x => x.DeliverBy); headers.WriteEnvelopeProperty(envelope, x => x.ReceivedAt); foreach (var pair in envelope.Headers) { headers.AddBodyRow(row => { row.Cell(pair.Key); row.Cell(pair.Value); }); } var table = new TableTag(); div.Add("h5").Text("Activity"); div.Append(table); table.AddClass("table").AddClass("table-striped"); table.AddHeaderRow(row => { row.Header("Time"); row.Header("Service"); row.Header("Message"); }); foreach (var record in Records) { table.AddBodyRow(row => { row.Cell(record.Time.ToString()).Style("text-align", "right"); row.Cell(record.ServiceName); row.Cell(record.Message); if (record.ExceptionText.IsNotEmpty()) { row.AddClass("bg-warning"); } }); if (record.ExceptionText.IsNotEmpty()) { table.AddBodyRow(row => { row.Attr("colSpan", "3"); row.Add("td/pre").Text(record.ExceptionText); }); } } return(div); }
public HtmlTag ToTableDetails() { var div = new HtmlTag("div"); var headers = new TableTag(); div.Add("h5").Text("Headers"); div.Append(headers); headers.AddClass("table").AddClass("table-striped"); headers.AddHeaderRow(row => { row.Header("Header Key"); row.Header("Header Value"); }); foreach (var pair in Records[0].Envelope.Headers) { headers.AddBodyRow(row => { row.Cell(pair.Key); row.Cell(pair.Value); }); } var table = new TableTag(); div.Add("h5").Text("Activity"); div.Append(table); table.AddClass("table").AddClass("table-striped"); table.AddHeaderRow(row => { row.Header("Time"); row.Header("Service"); row.Header("Message"); }); foreach (var record in Records) { table.AddBodyRow(row => { row.Cell(record.Time.ToString()).Style("text-align", "right"); row.Cell(record.ServiceName); row.Cell(record.Message); if (record.ExceptionText.IsNotEmpty()) { row.AddClass("bg-warning"); } }); if (record.ExceptionText.IsNotEmpty()) { table.AddBodyRow(row => { row.Attr("colSpan", "3"); row.Add("td/pre").Text(record.ExceptionText); }); } } return(div); }
public CommonResponse NeedsReorderEmail() { var response = new CommonResponse(); try { var ctx = context as MROContext; var needsReorderList = ctx.InventoryInputs .GroupBy(e => new { e.CatMaterial //, e.CatUnitOfMeasure }).Select(e => new { e.Key, e.Key.CatMaterial.Value, e.Key.CatMaterial.MaterialDescription, BalanceSum = e.Sum(b => b.Balance), id = e.Key.CatMaterial.CatMaterialKey }) .Where(e => e.BalanceSum < e.Key.CatMaterial.Min) .ToList(); var htmlReport = new TableTag(); htmlReport.Style("border", "solid 1px gray"); var headerRow = htmlReport.AddHeaderRow(); headerRow.Header().Text("Material"); headerRow.Header().Text("Description"); //headerRow.Header().Text("Unit of Measure"); headerRow.Header().Text("Balance"); headerRow.Header("Minimum"); foreach (var item in needsReorderList) { var row = htmlReport.AddBodyRow(); row.Cell(item.Value); row.Cell(item.MaterialDescription); //row.Cell(item.Key.CatUnitOfMeasure.Value); row.Cell(item.BalanceSum.ToString()); row.Cell(item.Key.CatMaterial.Min.ToString()); } EmailService emailService = new EmailService("", 25) { //EmailAddress = "", //Password = "", //From = "", //Subject = "Needs Reorder", EmailAddress = "", Password = "", From = "", Subject = "Needs Reorder", Body = needsReorderList.Count > 0 ? htmlReport.ToString() : "Inventario sin requerimientos minimos. " }; emailService.To.Add(""); emailService.To.Add(""); try { if (needsReorderList.Count > 0) { emailService.SendMail(); } } catch (Exception ex) { throw new KnownError("Error. Could not send email.\n" + ex.ToString()); } return(response.Success()); } catch (KnownError ke) { return(response.Error(ke)); } catch (Exception ex) { return(response.Error(ex.Message)); } }
public HtmlDocument Chain(ChainRequest chainRequest) { var title = "Chain " + chainRequest.Id; var behaviorChain = _graph.Behaviors.FirstOrDefault(chain => chain.UniqueId == chainRequest.Id); if (behaviorChain == null) { return(BuildDocument("Unknown chain", new HtmlTag("span").Text("No behavior chain registered with ID: " + chainRequest.Id))); } var content = new HtmlTag("div").AddClass("main-content"); var document = new HtmlTag("div"); var pattern = behaviorChain.RoutePattern; if (pattern == string.Empty) { pattern = "(default)"; } document.Append(new HtmlTag("div").Text("Route: " + pattern)); var nodeTable = new TableTag(); nodeTable.AddHeaderRow(header => { header.Header("Category"); header.Header("Description"); header.Header("Type"); }); foreach (var node in behaviorChain) { var description = node.ToString().HtmlEncode().ConvertCRLFToBreaks(); nodeTable.AddBodyRow(row => { row.Cell().Text(node.Category.ToString()); row.Cell().Encoded(false).Text(description); row.Cell().Text(node.GetType().FullName); if (description.Contains(_diagnosticsNamespace)) { row.AddClass(FUBU_INTERNAL_CLASS); } }); } var logDiv = new HtmlTag("div").AddClass("convention-log"); var ul = logDiv.Add("ul"); var observer = _graph.Observer; behaviorChain.Calls.Each( call => observer.GetLog(call).Each( entry => ul.Add("li").Text(entry))); content.Append(new[] { document, new HtmlTag("h3").Text("Nodes:"), nodeTable, new HtmlTag("h3").Text("Log:"), logDiv }); return(BuildDocument(title, content)); }
private HtmlTag EmailPhotoTableTag(PhotoContent dbEntry) { var emailCenterTable = new TableTag(); emailCenterTable.Attr("width", "94%"); emailCenterTable.Attr("margin", "20"); emailCenterTable.Attr("border", "0"); emailCenterTable.Attr("cellspacing", "0"); emailCenterTable.Attr("cellpadding", "0"); var topMarginRow = emailCenterTable.AddBodyRow(); topMarginRow.Attr("height", "10"); var topMarginCell = topMarginRow.Cell(); topMarginCell.Text(" ").Encoded(false); var emailImageRow = emailCenterTable.AddBodyRow(); var emailImageCenterLeftCell = emailImageRow.Cell(); emailImageCenterLeftCell.Attr("max-width", "1%"); emailImageCenterLeftCell.Attr("align", "center"); emailImageCenterLeftCell.Attr("valign", "top"); emailImageCenterLeftCell.Text(" ").Encoded(false); var emailCenterContentCell = emailImageRow.Cell(); emailCenterContentCell.Attr("width", "100%"); emailCenterContentCell.Attr("align", "center"); emailCenterContentCell.Attr("valign", "top"); emailCenterContentCell.Children.Add(Tags.PictureEmailImgTag(Pictures, true)); var emailCenterRightCell = emailImageRow.Cell(); emailCenterRightCell.Attr("max-width", "1%"); emailCenterRightCell.Attr("align", "center"); emailCenterRightCell.Attr("valign", "top"); emailCenterRightCell.Text(" ").Encoded(false); var captionImageRow = emailCenterTable.AddBodyRow(); var captionImageCenterLeftCell = captionImageRow.Cell(); captionImageCenterLeftCell.Attr("max-width", "1%"); captionImageCenterLeftCell.Attr("align", "center"); captionImageCenterLeftCell.Attr("valign", "top"); captionImageCenterLeftCell.Text(" ").Encoded(false); var captionCenterContentCell = captionImageRow.Cell(); captionCenterContentCell.Attr("width", "100%"); captionCenterContentCell.Attr("align", "center"); captionCenterContentCell.Attr("valign", "top"); captionCenterContentCell.Text(Tags.PhotoCaptionText(dbEntry)); var captionCenterRightCell = captionImageRow.Cell(); captionCenterRightCell.Attr("max-width", "1%"); captionCenterRightCell.Attr("align", "center"); captionCenterRightCell.Attr("valign", "top"); captionCenterRightCell.Text(" ").Encoded(false); var bottomMarginRow = emailCenterTable.AddBodyRow(); bottomMarginRow.Attr("height", "10"); var bottomMarginCell = bottomMarginRow.Cell(); bottomMarginCell.Text(" ").Encoded(false); return(emailCenterTable); }