feat(11-03): inject IBrandingService into all 5 export ViewModels and assemble branding in ExportHtmlAsync
- Add IBrandingService field and DI constructor parameter to all 5 ViewModels - Add optional IBrandingService? parameter to test constructors (PermissionsViewModel, StorageViewModel, UserAccessAuditViewModel) - Assemble ReportBranding from GetMspLogoAsync + _currentProfile.ClientLogo before each WriteAsync call - Pass branding as last parameter to WriteAsync in all ExportHtmlAsync methods - Guard clause: branding assembly skipped (branding = null) when _brandingService is null (test constructors) - Build: 0 warnings, 0 errors; tests: 254 passed / 0 failed / 26 skipped
This commit is contained in:
@@ -31,6 +31,7 @@ public partial class DuplicatesViewModel : FeatureViewModelBase
|
||||
private readonly IDuplicatesService _duplicatesService;
|
||||
private readonly ISessionManager _sessionManager;
|
||||
private readonly DuplicatesHtmlExportService _htmlExportService;
|
||||
private readonly IBrandingService _brandingService;
|
||||
private readonly ILogger<FeatureViewModelBase> _logger;
|
||||
private TenantProfile? _currentProfile;
|
||||
private IReadOnlyList<DuplicateGroup> _lastGroups = Array.Empty<DuplicateGroup>();
|
||||
@@ -64,12 +65,14 @@ public partial class DuplicatesViewModel : FeatureViewModelBase
|
||||
IDuplicatesService duplicatesService,
|
||||
ISessionManager sessionManager,
|
||||
DuplicatesHtmlExportService htmlExportService,
|
||||
IBrandingService brandingService,
|
||||
ILogger<FeatureViewModelBase> logger)
|
||||
: base(logger)
|
||||
{
|
||||
_duplicatesService = duplicatesService;
|
||||
_sessionManager = sessionManager;
|
||||
_htmlExportService = htmlExportService;
|
||||
_brandingService = brandingService;
|
||||
_logger = logger;
|
||||
|
||||
ExportHtmlCommand = new AsyncRelayCommand(ExportHtmlAsync, CanExport);
|
||||
@@ -168,7 +171,15 @@ public partial class DuplicatesViewModel : FeatureViewModelBase
|
||||
if (dialog.ShowDialog() != true) return;
|
||||
try
|
||||
{
|
||||
await _htmlExportService.WriteAsync(_lastGroups, dialog.FileName, CancellationToken.None);
|
||||
ReportBranding? branding = null;
|
||||
if (_brandingService is not null)
|
||||
{
|
||||
var mspLogo = await _brandingService.GetMspLogoAsync();
|
||||
var clientLogo = _currentProfile?.ClientLogo;
|
||||
branding = new ReportBranding(mspLogo, clientLogo);
|
||||
}
|
||||
|
||||
await _htmlExportService.WriteAsync(_lastGroups, dialog.FileName, CancellationToken.None, branding);
|
||||
Process.Start(new ProcessStartInfo(dialog.FileName) { UseShellExecute = true });
|
||||
}
|
||||
catch (Exception ex) { StatusMessage = $"Export failed: {ex.Message}"; _logger.LogError(ex, "HTML export failed."); }
|
||||
|
||||
Reference in New Issue
Block a user