private MarkdownContainer BuildMultipleTable(ReferenceViolations violations, string title, ISampler <KeyCollection> keyCollectionSampler, ISampler <DataRow> dataRowSampler) { var tableBuilder = new TableHelper(EngineStyle.ByIndex); var container = new MarkdownContainer(); keyCollectionSampler.Build(violations.Keys); container.Append($"{violations.Keys.Count} missing reference{(violations.Keys.Count>1 ? "s" : string.Empty)}".ToMarkdownHeader()); if (keyCollectionSampler.GetIsSampled()) { container.Append($"{keyCollectionSampler.GetExcludedRowCount()} (of {violations.Keys.Count}) rows have been skipped for display purpose.".ToMarkdownParagraph()); } foreach (var keyCollection in keyCollectionSampler.GetResult()) { var rows = violations[keyCollection]; container.Append($"Following reference is missing ({rows.Count} occurence{(rows.Count > 1 ? "s" : string.Empty)}):".ToMarkdownParagraph()); container.Append(new BulletedList(keyCollection.Members.Cast <string>())); dataRowSampler.Build(rows); var table = tableBuilder.Build(dataRowSampler.GetResult()); container.Append(BuildRowCount(rows.Count())); container.Append(table); if (dataRowSampler.GetIsSampled()) { var rowsSkipped = $"{dataRowSampler.GetExcludedRowCount()} (of {rows.Count()}) rows have been skipped for display purpose."; container.Append(rowsSkipped.ToMarkdownParagraph()); } } return(container); }
public void Execute(IEnumerable <DataRow> rows, ISampler <DataRow> sampler, JsonWriter writer) { rows = rows ?? new List <DataRow>(); sampler.Build(rows); var sampled = sampler.GetResult(); writer.WriteStartObject(); writer.WritePropertyName("total-rows"); writer.WriteValue(rows.Count()); if (sampler.GetIsSampled()) { writer.WritePropertyName("sampled-rows"); writer.WriteValue(rows.Count() - sampler.GetExcludedRowCount()); } if (sampled.Count() > 0) { writer.WritePropertyName("table"); writer.WriteStartObject(); writer.WritePropertyName("columns"); writer.WriteStartArray(); var formatters = new List <CellFormatter>(); foreach (DataColumn column in sampled.ElementAt(0).Table.Columns) { writer.WriteStartObject(); writer.WritePropertyName("position"); writer.WriteValue(column.Ordinal); writer.WritePropertyName("name"); writer.WriteValue(column.ColumnName); var cpFormatter = new ColumnPropertiesFormatter(); writer.WritePropertyName("role"); writer.WriteValue(cpFormatter.GetRoleText((ColumnRole)(column.ExtendedProperties["NBi::Role"] ?? ColumnRole.Key))); writer.WritePropertyName("type"); writer.WriteValue(cpFormatter.GetTypeText((ColumnType)(column.ExtendedProperties["NBi::Type"] ?? ColumnType.Text))); formatters.Add(new CellFormatterFactory().GetObject((ColumnType)(column.ExtendedProperties["NBi::Type"] ?? ColumnType.Text))); var tolerance = (Tolerance)(column.ExtendedProperties["NBi::Tolerance"]); if (!Tolerance.IsNullOrNone(tolerance)) { writer.WritePropertyName("tolerance"); writer.WriteValue(cpFormatter.GetToleranceText(tolerance).Trim()); } var rounding = (Rounding)(column.ExtendedProperties["NBi::Rounding"]); if (rounding != null) { writer.WritePropertyName("rounding"); writer.WriteValue(cpFormatter.GetRoundingText(rounding)); } writer.WriteEndObject(); } writer.WriteEndArray(); //columns BuildRows(sampled, formatters, writer); writer.WriteEndObject(); //table } writer.WriteEndObject(); }
private MarkdownContainer BuildTable(TableHelper tableBuilder, IEnumerable <DataRow> rows, string title, ISampler <DataRow> sampler) { rows = rows ?? new List <DataRow>(); sampler.Build(rows); var table = tableBuilder.Build(sampler.GetResult()); var container = new MarkdownContainer(); if (!String.IsNullOrEmpty(title)) { var titleText = string.Format($"{title} rows:"); container.Append(titleText.ToMarkdownSubHeader()); } container.Append(BuildRowCount(rows.Count())); container.Append(table); if (sampler.GetIsSampled()) { var rowsSkipped = string.Format($"{sampler.GetExcludedRowCount()} (of {rows.Count()}) rows have been skipped for display purpose."); container.Append(rowsSkipped.ToMarkdownParagraph()); } return(container); }
protected override void RenderStandardTable(IEnumerable <DataRow> rows, IEnumerable <ColumnMetadata> metadata, ISampler <DataRow> sampler, string title, JsonWriter writer) { sampler.Build(rows); var tableHelper = new StandardTableHelperJson(rows, metadata, sampler); tableHelper.Render(writer); }
protected override void RenderStandardTable(IEnumerable <DataRow> rows, IEnumerable <ColumnMetadata> metadata, ISampler <DataRow> sampler, string title, MarkdownContainer container) { sampler.Build(rows); var tableHelper = new StandardTableHelperMarkdown(rows, metadata, sampler); tableHelper.Render(container); }
protected override void RenderAnalysis(LookupViolationCollection violations, IEnumerable <ColumnMetadata> metadata, ISampler <DataRow> sampler, ColumnMappingCollection keyMappings, ColumnMappingCollection valueMappings, JsonWriter writer) { writer.WriteStartObject(); writer.WritePropertyName("missing"); var rows = violations.Values.Where(x => x is LookupExistsViolationInformation) .Cast <LookupExistsViolationInformation>() .SelectMany(x => x.CandidateRows); sampler.Build(rows); var tableHelper = new StandardTableHelperJson(rows, metadata, sampler); tableHelper.Render(writer); writer.WriteEndObject(); }
protected override void RenderAnalysis(LookupViolationCollection violations, IEnumerable <ColumnMetadata> metadata, ISampler <DataRow> sampler, ColumnMappingCollection keyMappings, ColumnMappingCollection valueMappings, MarkdownContainer container) { container.Append("Analysis".ToMarkdownHeader()); var state = violations.Values.Select(x => x.State).First(); container.Append(GetExplanationText(violations, state).ToMarkdownParagraph()); var rows = violations.Values.Where(x => x is LookupExistsViolationInformation) .Cast <LookupExistsViolationInformation>() .SelectMany(x => x.CandidateRows); sampler.Build(rows); var tableHelper = new StandardTableHelperMarkdown(rows, metadata, sampler); tableHelper.Render(container); }
private MarkdownContainer BuildList(IEnumerable <string> items, ISampler <string> sampler) { sampler.Build(items); var sampledItems = sampler.GetResult(); var container = new MarkdownContainer(); if (items.Count() > 0) { container.Append($"Set of {items.Count()} item{(items.Count() > 1 ? "s" : string.Empty)}".ToMarkdownParagraph()); container.Append(sampledItems.ToMarkdownBulletedList()); } else { container.Append("An empty set.".ToMarkdownParagraph()); } if (sampler.GetIsSampled()) { container.Append($"... and {sampler.GetExcludedRowCount()} others not displayed.".ToMarkdownParagraph()); } return(container); }
public void Execute(IEnumerable <DataRow> rows, ISampler <DataRow> sampler, IEnumerable <ColumnMetadata> metadata, JsonWriter writer) { rows = rows ?? new List <DataRow>(); sampler.Build(rows); var sampled = sampler.GetResult(); writer.WriteStartObject(); writer.WritePropertyName("total-rows"); writer.WriteValue(rows.Count()); if (sampler.GetIsSampled()) { writer.WritePropertyName("sampled-rows"); writer.WriteValue(rows.Count() - sampler.GetExcludedRowCount()); } if (sampled.Count() > 0) { writer.WritePropertyName("table"); writer.WriteStartObject(); writer.WritePropertyName("columns"); writer.WriteStartArray(); var formatters = new List <IPresenter>(); var columns = sampled.ElementAt(0).Table.Columns; for (var i = 0; i < columns.Count; i++) { var meta = metadata.ElementAt(i); writer.WriteStartObject(); writer.WritePropertyName("position"); writer.WriteValue(columns[i].Ordinal); writer.WritePropertyName("name"); writer.WriteValue(columns[i].ColumnName); var cpFormatter = new ColumnPropertiesFormatter(); writer.WritePropertyName("role"); writer.WriteValue(cpFormatter.GetRoleText(meta.Role)); writer.WritePropertyName("type"); writer.WriteValue(cpFormatter.GetTypeText(meta.Type)); if (!Tolerance.IsNullOrNone(meta.Tolerance)) { writer.WritePropertyName("tolerance"); writer.WriteValue(cpFormatter.GetToleranceText(meta.Tolerance).Trim()); } if (meta.Rounding != null) { writer.WritePropertyName("rounding"); writer.WriteValue(cpFormatter.GetRoundingText(meta.Rounding)); } formatters.Add(new PresenterFactory().Instantiate(metadata.ElementAt(i).Type)); writer.WriteEndObject(); } writer.WriteEndArray(); //columns BuildRows(sampled, formatters, writer); writer.WriteEndObject(); //table } writer.WriteEndObject(); }