Skip to content

Commit

Permalink
rdlcreator, Refactor report configuration methods
Browse files Browse the repository at this point in the history
Updated `GenerateTestData` and `SmallTestData` in `ManualFluentChainedReportDefinitionTest.cs` to use new method names for configuring the report body and table. Removed methods from `Body.cs` and `Table.cs` that are now handled in `Report.cs`. Modified `WithBody()` in `Report.cs` to accept a `height` parameter and return a `Report` object. Added new methods to `Report.cs` for table configuration. Updated `using` directives in `Report.cs`.
  • Loading branch information
majorsilence committed Feb 11, 2025
1 parent 0c202e7 commit d219266
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 99 deletions.
22 changes: 8 additions & 14 deletions RdlCreator.Tests/ManualFluentChainedReportDefinitionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,12 @@ private RdlCreator.Report GenerateTestData()
// Add a body to the report

report
.WithBody()
.WithHeight("36pt")
.WithReportTable()
.WithBody("36pt")
.WithTable()
.WithTableName("Table1")
.WithDataSetName("Data")
.WithNoRows("Query returned no rows!")
.WithHeader(new TableRow
.WithTableDataSetName("Data")
.WithTableNoRows("Query returned no rows!")
.WithTableHeader(new TableRow
{
Height = "12pt",
TableCells = new TableCells()
Expand Down Expand Up @@ -212,7 +211,7 @@ private RdlCreator.Report GenerateTestData()
new TableColumn { Width = "1.375in" }
}
})
.WithDetails(new TableRow
.WithTableDetails(new TableRow
{
Height = "12pt",
TableCells = new TableCells()
Expand Down Expand Up @@ -379,13 +378,8 @@ private RdlCreator.Report SmallTestData()
},
PrintOnFirstPage = "true",
PrintOnLastPage = "true"
});

// Add a body to the report

report
.WithBody()
.WithHeight("36pt")
})
.WithBody("36pt")
.WithReportText(new Textbox
{
Name = "Textbox1",
Expand Down
35 changes: 0 additions & 35 deletions RdlCreator/Body.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,5 @@ public class Body

[XmlElement(ElementName = "Height")]
public string Height { get; set; }

public Table WithReportTable()
{
this.ReportItems = new ReportItemsBody()
{
Table = new Table(),
Text = new List<Textbox>()
};
return ReportItems.Table;
}

public Body WithReportText(Textbox textbox)
{
if (this.ReportItems == null)
{
this.ReportItems = new ReportItemsBody()
{
Text = new List<Textbox>()
};

this.ReportItems.Text.Add(textbox);
}
else
{
this.ReportItems.Text.Add(textbox);
}

return this;
}

public Body WithHeight(string height)
{
this.Height = height;
return this;
}
}
}
89 changes: 85 additions & 4 deletions RdlCreator/Report.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace Majorsilence.Reporting.RdlCreator
{
Expand Down Expand Up @@ -121,16 +122,96 @@ public Report WithPageHeader(PageHeader pageHeader)
return this;
}

public Body WithBody()
public Report WithBody(string height)
{
Body = new Body();
return Body;
Body = new Body()
{
Height = height
};
return this;
}

public Report WithPageFooter(PageFooter pageFooter)
{
PageFooter = pageFooter;
return this;
}

public Report WithTable()
{
this.Body.ReportItems = new ReportItemsBody()
{
Table = new Table(),
Text = new List<Textbox>()
};
return this;
}

public Report WithReportText(Textbox textbox)
{
if (this.Body.ReportItems == null)
{
this.Body.ReportItems = new ReportItemsBody()
{
Text = new List<Textbox>()
};

this.Body.ReportItems.Text.Add(textbox);
}
else
{
this.Body.ReportItems.Text.Add(textbox);
}

return this;
}

public Report WithTableColumns(TableColumns tableColumns)
{
this.Body.ReportItems.Table.TableColumns = tableColumns;
return this;
}

public Report WithTableHeader(TableRow header, string repeatOnNewPage = "true")
{
this.Body.ReportItems.Table.Header = new Header()
{
TableRows = new TableRows()
{
TableRow = header
},
RepeatOnNewPage = repeatOnNewPage
};
return this;
}

public Report WithTableDetails(TableRow row)
{
this.Body.ReportItems.Table.Details = new Details();
this.Body.ReportItems.Table.Details.TableRows = new TableRows()
{
TableRow = row
};
return this;
}

public Report WithTableDataSetName(string dataSetName)
{
this.Body.ReportItems.Table.DataSetName = dataSetName;
return this;
}

public Report WithTableNoRows(string noRows)
{
this.Body.ReportItems.Table.NoRows = noRows;
return this;
}

public Report WithTableName(string tableName)
{
this.Body.ReportItems.Table.TableName = tableName;
return this;
}

}
}
46 changes: 0 additions & 46 deletions RdlCreator/Table.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,51 +23,5 @@ public class Table
[XmlAttribute(AttributeName = "Name")]
public string TableName { get; set; }

public Table WithTableColumns(TableColumns tableColumns)
{
this.TableColumns = tableColumns;
return this;
}

public Table WithHeader(TableRow header, string repeatOnNewPage="true")
{
this.Header = new Header()
{
TableRows = new TableRows()
{
TableRow = header
},
RepeatOnNewPage = repeatOnNewPage
};
return this;
}

public Table WithDetails(TableRow row)
{
this.Details = new Details();
this.Details.TableRows = new TableRows()
{
TableRow = row
};
return this;
}

public Table WithDataSetName(string dataSetName)
{
this.DataSetName = dataSetName;
return this;
}

public Table WithNoRows(string noRows)
{
this.NoRows = noRows;
return this;
}

public Table WithTableName(string tableName)
{
this.TableName = tableName;
return this;
}
}
}

0 comments on commit d219266

Please sign in to comment.