Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
MachineReportViewModel.cs
1using CommunityToolkit.Mvvm.ComponentModel;
4
6{
10 public partial class MachineReportViewModel : BaseViewModel, IDisposable
11 {
12 private bool isDisposed;
13
19 : base()
20 {
21 this.TokenReport = Args?.Report;
22 }
23
25 protected override async Task OnInitialize()
26 {
27 await base.OnInitialize();
28
29 if (this.TokenReport is null)
30 this.Title = string.Empty;
31 else
32 {
33 this.Title = await this.TokenReport.GetTitle();
34 await this.TokenReport.GenerateReport(this);
35 }
36
37 ServiceRef.XmppService.NeuroFeatureVariablesUpdated += this.Wallet_VariablesUpdated;
38 ServiceRef.XmppService.NeuroFeatureStateUpdated += this.Wallet_StateUpdated;
39 }
40
42 protected override Task OnDispose()
43 {
44 ServiceRef.XmppService.NeuroFeatureVariablesUpdated -= this.Wallet_VariablesUpdated;
45 ServiceRef.XmppService.NeuroFeatureStateUpdated -= this.Wallet_StateUpdated;
46
47 this.DeleteTemporaryFiles();
48
49 return base.OnDispose();
50 }
51
52 private Task Wallet_StateUpdated(object? Sender, NeuroFeatures.NewStateEventArgs e)
53 {
54 return this.UpdateReport();
55 }
56
57 private Task Wallet_VariablesUpdated(object? Sender, NeuroFeatures.VariablesUpdatedEventArgs e)
58 {
59 return this.UpdateReport();
60 }
61
62 private Task UpdateReport()
63 {
64 return this.TokenReport?.GenerateReport(this) ?? Task.CompletedTask;
65 }
66
67 #region Properties
68
72 [ObservableProperty]
73 private string? title;
74
78 [ObservableProperty]
79 private object? report;
80
84 [ObservableProperty]
85 private TokenReport? tokenReport;
86
90 public void Dispose()
91 {
92 this.Dispose(true);
93 GC.SuppressFinalize(this);
94 }
95
99 protected virtual void Dispose(bool Disposing)
100 {
101 if (this.isDisposed)
102 return;
103
104 if (Disposing)
105 this.DeleteTemporaryFiles();
106
107 this.isDisposed = true;
108 }
109
110 private void DeleteTemporaryFiles()
111 {
113 }
114
115 #endregion
116
117 }
118}
A base class for all view models, inheriting from the BindableObject. NOTE: using this class requir...
Holds navigation parameters specific to a report from a state-machine.
The view model to bind to for when displaying information about the current state of a state-machine.
override Task OnDispose()
Method called when the view is disposed, and will not be used more. Use this method to unregister eve...
override async Task OnInitialize()
Method called when view is initialized for the first time. Use this method to implement registration ...
MachineReportViewModel(MachineReportNavigationArgs? Args)
The view model to bind to for when displaying information about the current state of a state-machine.
abstract Task< string > GetTitle()
Gets the title of report.
async Task GenerateReport(MachineReportViewModel ReportView)
Generates the report.
Definition: TokenReport.cs:220