in src/MIMConfigDocumenter/Documenter.cs [1723:1809]
protected void WriteRows(DataRow[] rows, int currentTableIndex, ref int currentCellIndex)
{
Logger.Instance.WriteMethodEntry("Current Table Index: '{0}'. Current Cell Index: '{1}'.", currentTableIndex, currentCellIndex);
try
{
if (rows == null)
{
throw new ArgumentNullException("rows");
}
else if (rows.Count() == 0)
{
return;
}
var printTable = this.DiffgramDataSet.Tables["PrintSettings"];
var maxCellCount = printTable.Select("Hidden = false").Count();
var rowCount = rows.Length;
for (var i = 0; i < rowCount; ++i)
{
var row = rows[i];
var cellClass = (string)row[Documenter.RowStateColumn];
if (currentCellIndex == 0)
{
// Start the new row
this.ReportWriter.WriteBeginTag("tr");
if (row[Documenter.HtmlTableRowVisibilityStatusColumn] as string == Documenter.CanHide)
{
this.ReportWriter.WriteAttribute("class", cellClass + " " + Documenter.CanHide);
}
else
{
this.ReportWriter.WriteAttribute("class", cellClass);
}
this.ReportWriter.Write(HtmlTextWriter.TagRightChar);
}
currentCellIndex = printTable.Select("Hidden = false AND TableIndex < " + currentTableIndex).Count();
var rowSpan = this.GetRowSpan(row, currentTableIndex) + 1;
var printColumns = printTable.Select("Hidden = false AND TableIndex = " + currentTableIndex).Select(rowX => rowX["ColumnIndex"]);
foreach (var column in row.Table.Columns.Cast<DataColumn>().Where(column => printColumns.Contains(column.Ordinal)))
{
this.WriteCell(row, column, rowSpan, currentTableIndex);
++currentCellIndex;
}
// child rows
var childTableIndex = currentTableIndex + 1;
var dataRelationName = string.Format(CultureInfo.InvariantCulture, "DataRelation{0}{1}", childTableIndex, childTableIndex + 1);
var childRows = row.GetChildRows(dataRelationName);
var childRowsCount = childRows.Count();
if (childRowsCount == 0)
{
// complete the row if required
for (; currentCellIndex < maxCellCount; ++currentCellIndex)
{
this.ReportWriter.WriteBeginTag("td");
this.ReportWriter.WriteAttribute("class", cellClass);
this.ReportWriter.WriteAttribute("rowspan", "1");
this.ReportWriter.Write(HtmlTextWriter.TagRightChar);
this.ReportWriter.Write("-");
this.ReportWriter.WriteEndTag("td");
}
this.ReportWriter.WriteEndTag("tr");
this.ReportWriter.WriteLine();
currentCellIndex = 0; // reset the current cell index
}
else
{
currentCellIndex = currentCellIndex == maxCellCount ? 0 : currentCellIndex;
this.WriteRows(childRows, childTableIndex, ref currentCellIndex);
}
}
}
finally
{
Logger.Instance.WriteMethodExit("Current Table Index: '{0}'. Current Cell Index: '{1}'.", currentTableIndex, currentCellIndex);
}
}