Report Module¶
The purpose of the Report Manager is to allow users to generate reports based on data that is stored in the MIKE Workbench system. Reports combine static content that is defined in report templates and dynamic content that is generated from system data and formatted according to user preferences (e.g. time series plots, maps, spreadsheet content, indicator values).
The central point of the Report Manager is a report definition which always consists of:
- a report template (a document for a given report type containing combination of static content and placeholders for a dynamic content, e.g. MS Word document).
- content configuration (definition of content generated from MIKE Workbench for each dynamic content item in the report template).
- report properties (properties of the generated report specific for a given report type).
Install the NuGet package DHI.MikeOperations.ReportManager to get access to the Report module API.
Install content provider NuGet packages depending on the source data required, and a report writer for the type of report to generate.
The sample below shows how to generate a report defined in MIKE Workbench.
// Get the Report module.
var module = application.Modules.Get("Report Manager") as DHI.Solutions.ReportManager.Interfaces.IReportModule;
// Get the report to generate, from the path of the report in the report explorer of MIKE Workbench.
module.ReportList.Fetch("/MyReport");
// Get the report settings of the a report to generate and update settings if required.
var settings = module.GetReportGenerationSettings(report);
// Set path in the document manager where the report should be stored (if needed).
settings.DocumentManagerPath = "/Reports";
// Set the output folder of the Microsoft Word file.
((DHI.Solutions.ReportManager.WordReportWriter.WordReportWriterSettings)settings.ReportWriterSettings).OutputFolder = "c:/temp/";
// Generate the report. The report handle returned contains report location and information.
var reportHandle = module.GenerateReport(report, settings);
# Get the Report module.
module = app.Modules.Get("Report Manager")
# Get the report to generate, from the path of the report in the report explorer of MIKE Workbench.
module.ReportList.Fetch("/MyReport")
# Get the report settings of the a report to generate and update settings if required.
settings = module.GetReportGenerationSettings(report)
# Set path in the document manager where the report should be stored (if needed).
settings.DocumentManagerPath = "/Reports"
# Set the output folder of the Microsoft Word file.
settings.ReportWriterSettings.OutputFolder = "c:/temp/"
# Generate the report. The report handle returned contains report location and information.
reportHandle = module.GenerateReport(report, settings)
# Get the Report module.
module = DHI.Solutions.ReportManager.Interfaces.IReportModule(app.Modules.Get("Report Manager"))
# Get the report to generate, from the path of the report in the report explorer of MIKE Workbench.
module.ReportList.Fetch("/MyReport")
# Get the report settings of the a report to generate and update settings if required.
settings = module.GetReportGenerationSettings(report)
# Set path in the document manager where the report should be stored (if needed).
settings.DocumentManagerPath = "/Reports"
# Set the output folder of the Microsoft Word file.
settings.ReportWriterSettings.OutputFolder = "c:/temp/"
# Generate the report. The report handle returned contains report location and information.
reportHandle = module.GenerateReport(report, settings)
Content Providers¶
Reports can contain contents from different sources defined by content providers.
Favorite¶
This content source returns an image based on a saved favorite (gis map or time series plot).
NuGet package DHI.MikeOperations.ReportManager.ContentProvider.Favorite.
GIS¶
This content source returns a table of all feature attributes in a given feature class.
NuGet package DHI.MikeOperations.ReportManager.ContentProvider.GIS.
Indicator¶
This content source returns a value that is represented by an indicator.
NuGet package DHI.MikeOperations.ReportManager.ContentProvider.Indicator.
Script¶
This content source returns text, an image or a table that is produced by a script.
NuGet package DHI.MikeOperations.ReportManager.ContentProvider.Script.
Spreadsheet¶
This content source returns an image or a table based on a spreadsheet cell range.
NuGet package DHI.MikeOperations.ReportManager.ContentProvider.Spreadsheet.
Time series¶
This content source returns a time series plot image or a table of time series values.
NuGet package DHI.MikeOperations.ReportManager.ContentProvider.TimeSeries.
Report Writers¶
When generating reports, they are written using report writers. Currently one report writer is available for writing reports into a Microsoft Word document (.docx).
Word¶
Report writer for generating Microsoft Word documents (.docx).
NuGet package DHI.MikeOperations.ReportManager.Writer.Word.
Tools¶
When using the API for running tools, every tool are following the concept show below.
// Get the tool from the tool name.
var tool = application.Tools.CreateNew("Generate Report") as DHI.Solutions.ReportManager.Tools.GenerateReport.IGenerateReportTool;
// Add input items to the tool if required.
tool.InputItems.Add(report);
// Execute the tool.
tool.Execute();
// Get the output of the tool (if any).
var output = tool.OutputItems[0];
# Get the tool from the tool name.
var tool = app.Tools.CreateNew("Generate Report")
# Add input items to the tool if required.
tool.InputItems.Add(document)
# Execute the tool.
tool.Execute()
# Get the output of the tool (if any).
output = tool.OutputItems[0]
# Get the tool from the tool name.
var tool = DHI.Solutions.ReportManager.Tools.GenerateReport.IGenerateReportTool(app.Tools.CreateNew("Generate Report"))
# Add input items to the tool if required.
tool.InputItems.Add(document)
# Execute the tool.
tool.Execute()
# Get the output of the tool (if any).
output = tool.OutputItems[0]
Generate Report¶
Tool for generating a report.
| Tool Info | Generate Report |
|---|---|
| NuGet Package | DHI.MikeOperations.ReportManager.Tools.GenerateReport |
| API Reference | DHI.Solutions.ReportManager.Tools.GenerateReport.IGenerateReportTool |
| Input Items | A single report |
| Output Items | A generated report handle containing report location and information |
Tool Properties
- OutputFolder: Gets or sets the folder where the generated report is saved.
- SaveInDocumentManager: Gets or sets a value indicating whether the report should be saved in the document manager
- DocumentManagerPath: Gets or sets the path in the document manager where the report is saved.
Code Sample
// Get the tool.
var tool = application.Tools.CreateNew("Generate Report") as DHI.Solutions.ReportManager.Tools.GenerateReport.IGenerateReportTool;
# Get the tool.
tool = app.Tools.CreateNew("Generate Report")
# Get the tool.
tool = DHI.Solutions.ReportManager.Tools.GenerateReport.IGenerateReportTool(app.Tools.CreateNew("Generate Report"))