public AuditViewModel( IFileSystemStoreService fileSystemStoreService, IShareAuditService shareAuditService, ISmbUtilitiesService smbUtilitiesService) { _fileSystemStoreService = fileSystemStoreService ?? throw new ArgumentNullException(nameof(fileSystemStoreService)); _shareAuditService = shareAuditService ?? throw new ArgumentNullException(nameof(shareAuditService)); _smbUtilitiesService = smbUtilitiesService ?? throw new ArgumentNullException(nameof(smbUtilitiesService)); _shareAuditService.Started += (sender, e) => { IsRunning = true; IsBusy = false; }; _shareAuditService.Stopped += async(sender, e) => { IsRunning = false; await _fileSystemStoreService.SaveProjectAsync(Project, ProjectPath); if (_runningInitialAutomaticAudit) { MessageBox.Show("The initial audit is now complete, you may proceed to review the results", "Initial Audit Complete", MessageBoxButton.OK, MessageBoxImage.Information); _runningInitialAutomaticAudit = false; } IsBusy = false; }; Export = new DelegateCommand(OnExport, CanExport).ObservesProperty(() => IsBusy).ObservesProperty(() => IsRunning); StartAudit = new DelegateCommand(OnStartAudit, CanStartAudit).ObservesProperty(() => IsBusy).ObservesProperty(() => IsRunning); StopAudit = new DelegateCommand(OnStopAudit, CanStopAudit).ObservesProperty(() => IsBusy).ObservesProperty(() => IsRunning); AuditFolder = new DelegateCommand(OnAuditFolder, CanAuditFolder).ObservesProperty(() => IsBusy).ObservesProperty(() => IsRunning).ObservesProperty(() => SelectedItem); RevealInExplorer = new DelegateCommand(OnRevealInExplorer, CanRevealInExplorer).ObservesProperty(() => IsBusy).ObservesProperty(() => SelectedItem); }
public ShareAuditService( IScopeExpansionService scopeExpansionService, IDnsUtilitiesService dnsUtilitiesService, IPortScanService portScanService, ISmbUtilitiesService smbUtilitiesService, IFileSystemOperationService fileSystemOperationService) { _scopeExpansionService = scopeExpansionService ?? throw new ArgumentNullException(nameof(scopeExpansionService)); _dnsUtilitiesService = dnsUtilitiesService ?? throw new ArgumentNullException(nameof(dnsUtilitiesService)); _portScanService = portScanService ?? throw new ArgumentNullException(nameof(portScanService)); _smbUtilitiesService = smbUtilitiesService ?? throw new ArgumentNullException(nameof(smbUtilitiesService)); _fileSystemOperationService = fileSystemOperationService ?? throw new ArgumentNullException(nameof(fileSystemOperationService)); _backgroundWorker = new BackgroundWorker { WorkerSupportsCancellation = true }; _backgroundWorker.DoWork += DoWork; _backgroundWorker.RunWorkerCompleted += RunWorkerCompleted; }