Difference between revisions of "How Reports are Displayed"
Jump to navigation
Jump to search
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
This page documents how the Reports in Truxton are displayed, or how the View of the report is created. | This page documents how the Reports in Truxton are displayed, or how the View of the report is created. | ||
| + | |||
== UI Guide Menu == | == UI Guide Menu == | ||
:* [[ UI - Truxton Analyst - Dev Guide ]] | :* [[ UI - Truxton Analyst - Dev Guide ]] | ||
| Line 9: | Line 10: | ||
:# [[ Truxton CLI options ]] | :# [[ Truxton CLI options ]] | ||
:# [[ How Reports are Displayed ]] | :# [[ How Reports are Displayed ]] | ||
| + | :# [[ How Dialog Forms Work ]] | ||
| + | :# [[ Forms with Images ]] | ||
| + | :# [[ Images ]] | ||
| + | :# [[ Bookmarks ]] | ||
== Overview == | == Overview == | ||
| Line 90: | Line 95: | ||
</div> | </div> | ||
| − | :: | + | ::For quick reference, the databinding can be found in <b>ReportSection.xaml</b>. |
<div style="display:flex;justify-content:center;"> | <div style="display:flex;justify-content:center;"> | ||
| Line 98: | Line 103: | ||
| | | | ||
<controls:WebBrowser x:Name="WebBrowser" Stream="{Binding <b>HTMLReport.Stream</b>}" /> | <controls:WebBrowser x:Name="WebBrowser" Stream="{Binding <b>HTMLReport.Stream</b>}" /> | ||
| + | |- | ||
| + | |} | ||
| + | </div> | ||
| + | |||
| + | ::Here's the full snippet of loadReportConent with the relevant code.</b>. | ||
| + | |||
| + | <div style="display:flex;justify-content:center;"> | ||
| + | {| class="wikitable" | ||
| + | ! loadReportContent | ||
| + | |- | ||
| + | | | ||
| + | var reportFactory = _ctx.ReportService.GetReportFactory(req.ReporterID); | ||
| + | if (reportFactory != null) | ||
| + | { | ||
| + | var report = await reportFactory.GenerateAsync(req.ReportConfig, req.CTS.Token); | ||
| + | report.ReportFormatter = ReportFormatter; | ||
| + | string reportContent = await report.GetReportContentAsync(req.CTS.Token); | ||
| + | if (!req.CTS.Token.IsCancellationRequested) | ||
| + | { | ||
| + | var bytes = Encoding.UTF8.GetBytes(reportContent); | ||
| + | req.Stream = new CancellableStream(bytes); | ||
| + | Stream = req.Stream; | ||
| + | |||
| + | string message = getActionMessage(req, reportFactory.Name); | ||
| + | await _ctx.InvestigationContext.AddActionAsync(message, CancellationToken.None); | ||
| + | } | ||
| + | } | ||
|- | |- | ||
|} | |} | ||
</div> | </div> | ||
Latest revision as of 11:29, 30 November 2021
This page documents how the Reports in Truxton are displayed, or how the View of the report is created.
UI Guide Menu
Overview
- Most of the UI app is in C# and WPF. Typically, when you load a page, a View is made and rendered on screen using C# and WPF magic. This is not the case for Reports. The report is generated using HTML. Eventually, that HTML-report is loaded into an existing view.
- I assume this is the case for multi-platform report generation as well as ease of printing. I'll update this as it's discovered.
Main Files
File Summary Path ReportSection.xaml This view has a WebBrowser element that displays the HTML. It's loaded using the Binding HTMLReport.Stream \Truxton\Client\TruxtonClient\TruxtonClient\Templates\ReportSection.xaml ReportSectionViewModel.cs This is the ViewModel for the ReportSection \Truxton\Client\TruxtonClient\TruxtonClient\ViewModels\Reports\ReportSectionViewModel.cs HTMLReportViewModel.cs This is where the report-generating functions are called in loadReportContent \Truxton\Client\TruxtonClient\TruxtonClient\ViewModels\Reports\HTMLReportViewModel.cs
HTMLReportViewModel.cs
- In the loadReportContent function,
- the relevant reportFactory is selected.
| loadReportContent |
|---|
var reportFactory = _ctx.ReportService.GetReportFactory(req.ReporterID); |
- Then, the report is generated resulting in a ITruxtonReport.
| loadReportContent |
|---|
var report = await reportFactory.GenerateAsync(req.ReportConfig, req.CTS.Token); |
- Next, the reportContent(HTML) is generated resulting in a string that contains the HTML.
| loadReportContent |
|---|
string reportContent = await report.GetReportContentAsync(req.CTS.Token); |
- Eventually, the string is converted into a stream then assigned so that it's available for dataBinding.
| loadReportContent |
|---|
Stream = req.Stream; |
- For quick reference, the databinding can be found in ReportSection.xaml.
| ReportSection.xaml |
|---|
<controls:WebBrowser x:Name="WebBrowser" Stream="{Binding HTMLReport.Stream}" />
|
- Here's the full snippet of loadReportConent with the relevant code..
| loadReportContent |
|---|
var reportFactory = _ctx.ReportService.GetReportFactory(req.ReporterID);
if (reportFactory != null)
{
var report = await reportFactory.GenerateAsync(req.ReportConfig, req.CTS.Token);
report.ReportFormatter = ReportFormatter;
string reportContent = await report.GetReportContentAsync(req.CTS.Token);
if (!req.CTS.Token.IsCancellationRequested)
{
var bytes = Encoding.UTF8.GetBytes(reportContent);
req.Stream = new CancellableStream(bytes);
Stream = req.Stream;
string message = getActionMessage(req, reportFactory.Name);
await _ctx.InvestigationContext.AddActionAsync(message, CancellationToken.None);
}
}
|