void View_ConfirmChanges(object sender, EventArgs e) { // Code below prevents the "configuration file has been changed by another program' exception // This happens when an addin that the server manager does not know about (i.e. Leadtools.Medical.Rules.Addin) saves its settings into 'advanced.config', which occurs in a different process // When the main process (server manager UI) saves the advanced.config without doing a RefreshSettings first, the exception occurs // // To prevent this: // Get a reference to the global copy of 'advanced.config' and refresh from disk (RefreshSettings) // All the presenters (i.e. _PatientUpdaterPresenter) have a reference to this, but it is the same reference // Now copy all settings into the reference to 'advanced.config' and save if (ServerState.Instance.ServerService != null) { AdvancedSettings settings = AdvancedSettings.Open(ServerState.Instance.ServerService.ServiceDirectory); settings.RefreshSettings(); } // These live in Leadtools.Medical.Winforms.dll __LoggingConfigPresenter.UpdateState( ); __PatientUpdaterPresenter.SaveOptions( ); __AutoCopyPresenter.SaveOptions( ); __ForwardPresenter.SaveOptions(); if (__SecurityOptionsPresenter.IsDirty) { __SecurityOptionsPresenter.SaveOptions(); } #if LEADTOOLS_V19_OR_LATER bool isStorageCommitDirty = __StorageCommitPresenter.IsDirty; if (isStorageCommitDirty) { __StorageCommitPresenter.SaveOptions(); // This fails if the service is not running // This is not a problem, because once the service starts it will read the options try { DicomUtilities.DebugString(DebugStringOptions.ShowCounter, "SendMessage(ExternalStoreMessage.SettingsChanged)"); // ServerState.Instance.ServerService.SendMessage(ExternalStoreMessage.SettingsChanged); } catch (Exception ex) { DicomUtilities.DebugString(DebugStringOptions.ShowCounter, "Exception: SendMessage(ExternalStoreMessage.SettingsChanged)" + ex.Message); } } #endif bool isSecurityOptionsDirty = __SecurityOptionsPresenter.IsDirty; if (isSecurityOptionsDirty) { __SecurityOptionsPresenter.SaveOptions(); // This fails if the service is not running // This is not a problem, because once the service starts it will read the options try { // DicomUtilities.DebugString(DebugStringOptions.ShowCounter, "SendMessage(SecurityOptionsMessage.SettingsChanged)"); // ServerState.Instance.ServerService.SendMessage(SecurityOptionsMessage.SettingsChanged); } catch (Exception) { // DicomUtilities.DebugString(DebugStringOptions.ShowCounter, "Exception: SendMessage(SecurityOptionsMessage.SettingsChanged)" + ex.Message); } } #if (LEADTOOLS_V19_OR_LATER_MEDICAL_EXTERNAL_STORE) || (LEADTOOLS_V19_OR_LATER) bool isExternalStoreDirty = __ExternalStorePresenter.IsDirty; DicomUtilities.DebugString(DebugStringOptions.ShowCounter, "__ExternalStorePresenter.IsDirty : " + isExternalStoreDirty.ToString()); if (isExternalStoreDirty) { __ExternalStorePresenter.SaveOptions(); // This fails if the service is not running // This is not a problem, because once the service starts it will read the options try { DicomUtilities.DebugString(DebugStringOptions.ShowCounter, "SendMessage(ExternalStoreMessage.SettingsChanged)"); ServerState.Instance.ServerService.SendMessage(ExternalStoreMessage.SettingsChanged); } catch (Exception ex) { DicomUtilities.DebugString(DebugStringOptions.ShowCounter, "Exception: SendMessage(ExternalStoreMessage.SettingsChanged)" + ex.Message); } } #endif // #if (LEADTOOLS_V19_OR_LATER_MEDICAL_EXTERNAL_STORE) || (LEADTOOLS_V19_OR_LATER) if (__StorageClassesPresenter.IsDirty) { StorageModuleConfigurationManager configManager; configManager = ServiceLocator.Retrieve <StorageModuleConfigurationManager> ( ); __StorageClassesPresenter.UpdateSettings(); if (configManager.IsLoaded) { configManager.SetPresentationContextsTimestamp( ); } } #if (LEADTOOLS_V19_OR_LATER_EXPORT) || (LEADTOOLS_V19_OR_LATER) if (__AnonymizeOptionsPresenter.IsDirty) { StorageModuleConfigurationManager configManager = ServiceLocator.Retrieve <StorageModuleConfigurationManager> ( ); __AnonymizeOptionsPresenter.UpdateSettings(); } #endif // #if (LEADTOOLS_V19_OR_LATER_EXPORT) || (LEADTOOLS_V19_OR_LATER) if (null != __StorageSettingsPresenter) { if (__StorageSettingsPresenter.IsDirty) { __StorageSettingsPresenter.UpdateState(); __StorageSettingsPresenter.SaveSettings(); } } if (__DatabaseManagerOptionsPresenter.IsDirty) { __DatabaseManagerOptionsPresenter.SaveOptions(); DatabaseManagerOptionsAppliedEventArgs args = new DatabaseManagerOptionsAppliedEventArgs(); EventBroker.Instance.PublishEvent <DatabaseManagerOptionsAppliedEventArgs> (this, args); } #if LEADTOOLS_V20_OR_LATER if (__ClientConfigurationOptionsPresenter.IsDirty) { __ClientConfigurationOptionsPresenter.SaveOptions(); ClientConfigurationOptionsAppliedEventArgs args = new ClientConfigurationOptionsAppliedEventArgs(); EventBroker.Instance.PublishEvent <ClientConfigurationOptionsAppliedEventArgs> (this, args); } #endif // #if LEADTOOLS_V20_OR_LATER // These live in the EXE EventBroker.Instance.PublishEvent <ApplyServerSettingsEventArgs> (this, new ApplyServerSettingsEventArgs( )); EventBroker.Instance.PublishEvent <ServerSettingsAppliedEventArgs> (this, new ServerSettingsAppliedEventArgs( )); if (null != __PasswordOptionsPresenter) { __PasswordOptionsPresenter.SaveOptions(); } LocalAuditLogQueue.FlushLogs(Logger.Global, UserManager.User.Name); View.CanApply = false; }
private void optionsToolStripMenuItem_Click(object sender, EventArgs e) { StorageModuleConfigurationManager configurationManager; AddInsConfigurationDialog addinsConfiguration; StorageSettingsPresenter storageSettingsPresenter; StorageClassesPresenter storageClassesPresenter; if (ServiceLocator.IsRegistered <StorageModuleConfigurationManager> ( )) { configurationManager = ServiceLocator.Retrieve <StorageModuleConfigurationManager> ( ); } else { return; } addinsConfiguration = new AddInsConfigurationDialog( ); storageSettingsPresenter = new StorageSettingsPresenter(configurationManager); storageClassesPresenter = new StorageClassesPresenter( ); #if (LEADTOOLS_V19_OR_LATER) DatabaseManagerOptionsPresenter databaseManagerOptionsPresenter = new DatabaseManagerOptionsPresenter(); databaseManagerOptionsPresenter.RunView(addinsConfiguration.AddInsConfiguration.DatabaseManagerOptionsView); AnonymizeOptionsPresenter anonymizePresenter = new AnonymizeOptionsPresenter(); anonymizePresenter.RunView(addinsConfiguration.AddInsConfiguration.AnonymizeOptionsView); #endif // #if (LEADTOOLS_V19_OR_LATER) storageSettingsPresenter.RunViews(addinsConfiguration.AddInsConfiguration.StorageOptionsView, addinsConfiguration.AddInsConfiguration.QueryOptionsView, false); storageClassesPresenter.RunView(addinsConfiguration.AddInsConfiguration.StorageClassesTabControl); addinsConfiguration.CanViewIodClasses = storageClassesPresenter.IsOptionsAgentRegistered(); if (DialogResult.OK == addinsConfiguration.ShowDialog(this)) { storageSettingsPresenter.UpdateState(); // Fix for 11446IDT -- StorageAddin for the CSLeadtools.Server.Manager.exe is not persisting IOD values for the LEADTOOLS Storage Server service storageClassesPresenter.UpdateSettings(); databaseManager1.DeleteAnnotationsOnImageDelete = addInsSettings.StoreAddIn.DeleteAnnotationsOnImageDelete; AddInsSettings = storageSettingsPresenter.Settings; #if (LEADTOOLS_V19_OR_LATER) databaseManagerOptionsPresenter.SaveOptions(); DatabaseManagerOptionsAppliedEventArgs args = new DatabaseManagerOptionsAppliedEventArgs(); EventBroker.Instance.PublishEvent <DatabaseManagerOptionsAppliedEventArgs> (this, args); anonymizePresenter.UpdateSettings(); #endif // #if (LEADTOOLS_V19_OR_LATER) storageSettingsPresenter.SaveSettings( ); } else { storageSettingsPresenter.ResetView( ); } }