/// <summary> /// Populate the data set for an 'Asset Register' format report where there are only 3 columns /// in the report - Asset Name , Field and Value and the rows are the fields and values listed /// vertically grouped beneath their asset. /// </summary> protected void PopulateAssetRegisterReport() { // Get the Table from the DataSet DataTable dataTable = _reportDataSet.Tables["AuditData"]; // OK - this report is ASSET based so we loop through each asset listing the field and value // for each in turn. foreach (Asset asset in _cachedAssetList) { // Loop through each field in the report and create a row containing the // asset name ,field name and value foreach (AuditDataReportColumn reportColumn in _auditDataReportColumns) { // Get the value of this column for this asset AuditDataReportColumnValue columnValue = reportColumn.GetValueForAsset(asset.AssetID); if (columnValue != null) { // In an ASSET REGISTER report we have special handling for APPLICATIONS in that we do NOT // include them at all if the application is determined to not be installed on this asset if ((reportColumn.FieldType != AuditDataReportColumn.eFieldType.applications) || ((string)columnValue.DataValue != AuditDataReportColumn.ApplicationNotInstalled)) { // Create a new row in the report dataTable.Rows.Add(new object[] { asset.Name, reportColumn.ShortFieldName, (string)columnValue.DataValue }); } } } } }
/// <summary> /// Populate the data set for a 'Standard' format report where the fields in the report /// are the columns and the values for those fields form the rows /// </summary> protected void PopulateStandardReport() { // Get the Table from the DataSet DataTable dataTable = _reportDataSet.Tables["AuditData"]; // Count of rows is number of assets int rowCount = _cachedAssetList.Count - 1; // Loop for each row for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) { // Create a new row DataRow newRow = dataTable.NewRow(); // ...and add the columns to that row taking the values from the report columns int columnIndex = 0; foreach (AuditDataReportColumn reportColumn in _auditDataReportColumns) { AuditDataReportColumnValue columnValue = reportColumn.Values[rowIndex]; try { newRow[columnIndex] = columnValue.DataValue; } catch (Exception ex) { logger.Error(ex.Message); } columnIndex++; } // Add the row to the table dataTable.Rows.Add(newRow); } }