static void configChangedNotifier_SettingsChanged(object sender, EventArgs e) { _settings.RefreshSettings( ); if (ServiceLocator.IsRegistered <MediaServicesState> ( )) { MediaServicesState servicesState; servicesState = ServiceLocator.Retrieve <MediaServicesState> ( ); servicesState.MediaMaintenanceServiceEnabled = MaintenanceConfiguration.Enabled; servicesState.AutoCreationServiceEnabled = MediaAutoCreationConfiguration.EnableAutoMediaCreation; } if (CommandRequestValidationManager.IsRegistered <MediaCreationReferencedSopsValidator>()) { MediaCreationReferencedSopsValidator validator = CommandRequestValidationManager.GetValidator <MediaCreationReferencedSopsValidator>(); if (null != validator) { validator.Enabled = AddInConfiguration.ValidateReferencedSopInstances; } } }
internal static void RegisterServices(string serviceName) { if (!DataAccessServices.IsDataAccessServiceRegistered <IMediaCreationDataAccessAgent> ( )) { IMediaCreationDataAccessAgent mediaCreationService; System.Configuration.Configuration configuration = DicomDemoSettingsManager.GetGlobalPacsConfiguration(); mediaCreationService = DataAccessFactory.GetInstance(new MediaCreationDataAccessConfigurationView(configuration, null, serviceName)).CreateDataAccessAgent <IMediaCreationDataAccessAgent> ( ); DataAccessServices.RegisterDataAccessService <IMediaCreationDataAccessAgent> (mediaCreationService); } IStorageDataAccessAgent storageService; if (!DataAccessServices.IsDataAccessServiceRegistered <IStorageDataAccessAgent> ( )) { System.Configuration.Configuration configuration = DicomDemoSettingsManager.GetGlobalPacsConfiguration(); storageService = DataAccessFactory.GetInstance(new StorageDataAccessConfigurationView(configuration, null, serviceName)).CreateDataAccessAgent <IStorageDataAccessAgent>(); DataAccessServices.RegisterDataAccessService <IStorageDataAccessAgent> (storageService); } else { storageService = DataAccessServices.GetDataAccessService <IStorageDataAccessAgent> ( ); } if (!CommandRequestValidationManager.IsRegistered <CommandRequestDataSetValidator> ( )) { CommandRequestValidationManager.AddValidator(new CommandRequestDataSetValidator( )); } if (!CommandRequestValidationManager.IsRegistered <MediaCreationReferencedSopsValidator> ( )) { MediaCreationReferencedSopsValidator validator = new MediaCreationReferencedSopsValidator(storageService); validator.Enabled = AddInConfiguration.ValidateReferencedSopInstances; CommandRequestValidationManager.AddValidator(validator); } if (!DicomCommandFactory.IsCommandServiceRegistered(typeof(MediaNCreateCommand))) { DicomCommandFactory.RegisterCommandInitializationService(typeof(MediaNCreateCommand), new MediaNCreateCommandInitializationService( )); } if (!ServiceLocator.IsRegistered <MediaServicesState> ( )) { MediaServicesState servicesState; servicesState = new MediaServicesState( ); servicesState.AutoCreationServiceEnabled = MediaAutoCreationConfiguration.EnableAutoMediaCreation; servicesState.MediaMaintenanceServiceEnabled = MaintenanceConfiguration.Enabled; servicesState.AutoCreationServiceStateChanged += new EventHandler(servicesState_AutoCreationServiceStateChanged); servicesState.MediaMaintenanceServiceStateChanged += new EventHandler(servicesState_MediaMaintenanceServiceStateChanged); ServiceLocator.Register <MediaServicesState> (servicesState); } if (!ServiceLocator.IsRegistered <SettingsChangedNotifier> ( )) { SettingsChangedNotifier configChangedNotifier = new SettingsChangedNotifier(_settings); configChangedNotifier.SettingsChanged += new EventHandler(configChangedNotifier_SettingsChanged); configChangedNotifier.Enabled = true; ServiceLocator.Register <SettingsChangedNotifier> (configChangedNotifier); } }