public static void ResetPassword(string userName, SecureString password) { PasswordOptions options; DateTime? expires = null; options = optionsAgent.Get <PasswordOptions>(PasswordOptionsPresenter.PasswordOptions, new PasswordOptions()); if (options.DaysToExpire > 0) { expires = DateTime.Now.AddDays(options.DaysToExpire); } userAgent.SetUserPassword(userName, password, expires, options.MaxPasswordHistory); }
public PresentationContextList LoadSettings( ) { PresentationContextList list; if (null == _optionsAgent) { _optionsAgent = GetOptionsDataAccessAgent( ); } if (null != _optionsAgent && _optionsAgent.OptionExits(_settingsKeyName)) { list = _optionsAgent.Get <PresentationContextList>(_settingsKeyName, null, new Type[0]); } else { list = new PresentationContextList(); list.Default(); if (null != _optionsAgent) { _optionsAgent.Set <PresentationContextList> (_settingsKeyName, list, new Type[0]); } } return(list); }
public void RunView(ClientViewerControl view) { // view.ServerSecure = false; if (ServerState.Instance.ServerService != null && ServerState.Instance.ServerService.Settings != null) { view.ServerSecure = ServerState.Instance.ServerService.Settings.Secure; } EventBroker.Instance.Subscribe <ApplyServerSettingsEventArgs>(OnUpdateServerSettings); EventBroker.Instance.Subscribe <CancelServerSettingsEventArgs>(OnCancelServerSettings); EventBroker.Instance.Subscribe <ServerSettingsSecureChangedEventArgs>(OnServerSettingsSecureChanged); // store the view _view = view; _view.SettingsChanged += new EventHandler(View_SettingsChanged); _view_LoadClients(_view, EventArgs.Empty); _view.LoadClients += new EventHandler <EventArgs>(_view_LoadClients); #if LEADTOOLS_V20_OR_LATER IOptionsDataAccessAgent optionsAgent = DataAccessServices.GetDataAccessService <IOptionsDataAccessAgent>(); if (optionsAgent != null) { ClientConfigurationOptions clientConfigurationOptions = optionsAgent.Get <ClientConfigurationOptions>(ClientConfigurationOptionsKeyName, new ClientConfigurationOptions()); if (clientConfigurationOptions != null) { _view.Options = clientConfigurationOptions; } } #endif // #if LEADTOOLS_V20_OR_LATER }
public AnonymizeScripts LoadSettings() { AnonymizeScripts scripts; if (null == _optionsAgent) { _optionsAgent = GetOptionsDataAccessAgent(); } if (null != _optionsAgent && _optionsAgent.OptionExits(AnonymizeOptionsKey)) { scripts = _optionsAgent.Get <AnonymizeScripts>(AnonymizeOptionsKey, null, new Type[0]); } else { scripts = new AnonymizeScripts(true); if (null != _optionsAgent) { _optionsAgent.Set <AnonymizeScripts>(AnonymizeOptionsKey, scripts, new Type[0]); } } return(scripts); }
public static bool AddDicomServiceNameToGlobalPacsConfig() { bool success = true; try { OptionsDataAccessConfigurationView optionsConfigView = new OptionsDataAccessConfigurationView(DicomDemoSettingsManager.GetGlobalPacsConfiguration(), DicomDemoSettingsManager.ProductNameStorageServer, null); IOptionsDataAccessAgent optionsAgent = DataAccessFactory.GetInstance(optionsConfigView).CreateDataAccessAgent <IOptionsDataAccessAgent>(); if (optionsAgent != null) { StorageServerInformation serverInfo = null; string name = typeof(StorageServerInformation).Name; if (optionsAgent.OptionExits(name)) { serverInfo = optionsAgent.Get <StorageServerInformation>(name, null, new Type[0]); if (serverInfo != null && !string.IsNullOrEmpty(serverInfo.ServiceName)) { GlobalPacsUpdater.ModifyGlobalPacsConfiguration(DicomDemoSettingsManager.ProductNameStorageServer, serverInfo.ServiceName, GlobalPacsUpdater.ModifyConfigurationType.Add); } } } } catch (Exception) { success = false; } return(success); }
public void RunView(DatabaseManagerOptionsView view) { // EventBroker.Instance.Subscribe<BackgroundProcessEventAgs>(OnBackgroundProcess); View = view; _Options = DataAccessServices.GetDataAccessService <IOptionsDataAccessAgent>(); View.Options = _Options.Get <DatabaseManagerOptions>(DatabaseManagerOptions, new DatabaseManagerOptions()); View.SettingsChanged += new EventHandler(View_SettingsChanged); // Administration: View.PageSizeChanged += new EventHandler(View_PageSizeChanged); View.PaginationDisplayOptionChanged += new EventHandler(View_PaginationDisplayOptionChanged); }
public static bool Login(string info, bool relogin) { try { IOptionsDataAccessAgent optionsAgent = DataAccessServices.GetDataAccessService <IOptionsDataAccessAgent>(); PasswordOptions passwordOptions = optionsAgent.Get <PasswordOptions>("PasswordOptions", new PasswordOptions()); LoginDialog dlgLogin = new LoginDialog(passwordOptions.LoginType); Process process = Process.GetCurrentProcess(); string lastUser = optionsAgent.Get <string>("LastUser", string.Empty); bool lastLoginUseCardReader = optionsAgent.Get <bool>("LastLoginUseCardReader", false); dlgLogin.Text = Shell.storageServerName + " Login"; dlgLogin.Info = info; dlgLogin.RegularUsername = lastUser; if (passwordOptions.LoginType == LoginType.Both) { dlgLogin.UseCardReaderCheckBox = lastLoginUseCardReader; } dlgLogin.CanSetUserName = !relogin; dlgLogin.AuthenticateUser += new EventHandler <AuthenticateUserEventArgs>(dlgLogin_AuthenticateUser); if (dlgLogin.ShowDialog(new WindowWrapper(process.MainWindowHandle)) == DialogResult.OK) { UserManager.User = new ManagerUser(dlgLogin.GetUserName(), dlgLogin.GetFriendlyName(), UserManager.GetUserPermissions(dlgLogin.GetUserName())); optionsAgent.Set <bool>("LastLoginUseCardReader", dlgLogin.UseCardReaderCheckBox); LoadSplash(); return(true); } return(false); } catch (Exception ex) { Messager.ShowError(null, ex); return(false); } }
public void RunView(PasswordOptionsView view) { ServerEventBroker.Instance.Subscribe <ApplyServerSettingsEventArgs>(OnUpdateServerSettings); ServerEventBroker.Instance.Subscribe <CancelServerSettingsEventArgs>(OnCancelServerSettings); ServerEventBroker.Instance.Subscribe <ActivateIdleMonitorEventArgs>(UpdateIdleMonitor); View = view; _Options = DataAccessServices.GetDataAccessService <IOptionsDataAccessAgent>(); View.Options = _Options.Get <PasswordOptions>(PasswordOptions, new PasswordOptions()); if (View.Options.EnableIdleTimeout) { StartIdleMonitor(); } }
public void RunView(ClientConfigurationOptionsView view) { // EventBroker.Instance.Subscribe<BackgroundProcessEventAgs>(OnBackgroundProcess); View = view; _Options = DataAccessServices.GetDataAccessService <IOptionsDataAccessAgent>(); View.Options = _Options.Get <ClientConfigurationOptions>(ClientConfigurationOptions, new ClientConfigurationOptions()); View.SettingsChanged += new EventHandler(View_SettingsChanged); // Administration: View.PageSizeChanged += new EventHandler(View_PageSizeChanged); View.PaginationDisplayOptionChanged += new EventHandler(View_PaginationDisplayOptionChanged); View.LastViewDisplayOptionChanged += View_LastAccessDateDisplayOptionChanged; }
private CommandAsyncProcessor RegisterAutoSaveLogService(LoggingState logState) { AutoSaveLogCommand autoSaveCommand; CommandAsyncProcessor service = null; IOptionsDataAccessAgent optionsDataAccess = null; optionsDataAccess = DataAccessServices.GetDataAccessService <IOptionsDataAccessAgent>(); if (optionsDataAccess != null) { autoSaveCommand = new AutoSaveLogCommand(logState); service = new CommandAsyncProcessor(); if (logState.EnableAutoSaveLog) { string nextLogDate; nextLogDate = optionsDataAccess.Get <string>(NextLogDateSettingsName, null, new Type[0]); if (!string.IsNullOrEmpty(nextLogDate)) { DateTime nextLog = DateTime.Parse(nextLogDate); if (DateTime.Now > nextLog) { autoSaveCommand.Execute(); } } } service.Commands.Add(autoSaveCommand); ConfigureServiceIntervals(logState, service, optionsDataAccess); service.CommandsExecuted += new EventHandler(service_CommandsExecuted); ServiceLocator.Register <CommandAsyncProcessor>(service); } return(service); }
public static void LogMessage(string description, LogType logType) { DicomLogEntry logEntry = new DicomLogEntry( ); logEntry.LogType = logType; if (UserManager.User != null) { logEntry.ClientAETitle = UserManager.User.FriendlyName; } else { IOptionsDataAccessAgent optionsAgent = DataAccessServices.GetDataAccessService <IOptionsDataAccessAgent>(); string lastUser = optionsAgent.Get <string>("LastUser", string.Empty); logEntry.ClientAETitle = lastUser; } logEntry.Description = description; Logger.Global.Log(logEntry); }
public void RunView(PasswordOptionsView view) { EventBroker.Instance.Subscribe <BackgroundProcessEventAgs>(OnBackgroundProcess); View = view; #if LEADTOOLS_V19_OR_LATER _userAgent3 = DataAccessServices.GetDataAccessService <IUserManagementDataAccessAgent4>(); _userAgent2 = DataAccessServices.GetDataAccessService <IUserManagementDataAccessAgent2>(); #else _userAgent2 = DataAccessServices.GetDataAccessService <IUserManagementDataAccessAgent2>(); #endif _permissionAgent = DataAccessServices.GetDataAccessService <IPermissionManagementDataAccessAgent2>(); #if LEADTOOLS_V19_OR_LATER UpdateUsersList(); #endif _optionsAgent = DataAccessServices.GetDataAccessService <IOptionsDataAccessAgent>(); View.Options = _optionsAgent.Get <PasswordOptions>(PasswordOptions, new PasswordOptions()); View.SettingsChanged += new EventHandler(View_SettingsChanged); // Administration: Password Options View.ComplexityLowerCaseChanged += new EventHandler(View_ComplexityLowerCaseChanged); View.ComplexityUpperCaseChanged += new EventHandler(View_ComplexityUpperCaseChanged); View.ComplexitySymbolChanged += new EventHandler(View_ComplexitySymbolChanged); View.ComplexityNumberChanged += new EventHandler(View_ComplexityNumberChanged); View.MinimumLengthChanged += new EventHandler(View_MinimumLengthChanged); View.DaysToExpirationChanged += new EventHandler(View_DaysToExpirationChanged); View.MaximumRememberedChanged += new EventHandler(View_MaximumRememberedChanged); View.IdleTimeoutEnableChanged += new EventHandler(View_IdleTimeoutEnableChanged); View.IdleTimeoutChanged += new EventHandler(View_IdleTimeoutChanged); View.LoginTypeChanged += new EventHandler(View_LoginTypeChanged); if (View.Options.EnableIdleTimeout) { StartIdleMonitor(); } }
public void ResetView() { View.Options = _Options.Get <DatabaseManagerOptions>(DatabaseManagerOptions, new DatabaseManagerOptions()); }
void OnUpdateServerSettings(object sender, EventArgs e) { if (_view != null) { IAeManagementDataAccessAgent agent = DataAccessServices.GetDataAccessService <IAeManagementDataAccessAgent>(); IPermissionManagementDataAccessAgent permissionsAgent = DataAccessServices.GetDataAccessService <IPermissionManagementDataAccessAgent>(); #if LEADTOOLS_V20_OR_LATER IOptionsDataAccessAgent optionsAgent = DataAccessServices.GetDataAccessService <IOptionsDataAccessAgent>(); if (optionsAgent != null) { ClientConfigurationOptions clientConfigurationOptions = optionsAgent.Get <ClientConfigurationOptions>(ClientConfigurationOptionsKeyName, new ClientConfigurationOptions()); if (clientConfigurationOptions != null) { View.Options = clientConfigurationOptions; } } #endif // #if LEADTOOLS_V20_OR_LATER AeInfoExtended[] aeInfoExtendedArray = agent.GetAeTitles(); List <string> aeTitlesInDB = new List <string>(); foreach (AeInfoExtended ae in aeInfoExtendedArray) { ClientInformation info = (from i in ServerState.Instance.ClientList.Items where i.Client.AETitle == ae.AETitle select i).FirstOrDefault(); // // Only add items that existed when the database was first queried. If an ae title was added outside of this dialog // it will be ignored. // if (info != null) { aeTitlesInDB.Add(ae.AETitle.ToUpper()); } } // Updates and adds foreach (ClientInformation ci in _view.ClientInformationList.Items) { string aeTitle = ci.Client.AETitle; if (aeTitlesInDB.Contains(aeTitle, StringComparer.InvariantCultureIgnoreCase)) { // update ClientInformation ciPrevious = null; ServerState.Instance.ClientList.ClientDictionary.TryGetValue(aeTitle, out ciPrevious); if (!ciPrevious.Equals(ci)) { agent.Update(aeTitle, ci.Client); } aeTitlesInDB.Remove(aeTitle.ToUpper()); try { EventBroker.Instance.PublishEvent <ClientUpdatedEventArgs>(this, new ClientUpdatedEventArgs(aeTitle, ci.Client)); } catch { } } else { // insert agent.Add(ci.Client); try { EventBroker.Instance.PublishEvent <ClientAddedEventArgs>(this, new ClientAddedEventArgs(ci.Client)); } catch { } } permissionsAgent.DeleteUserPermission(null, aeTitle); foreach (string permissionName in ci.Permissions) { permissionsAgent.AddUserPermission(permissionName, aeTitle); } } // Finally, remove the deleted AE titles from the database foreach (string aeTitle in aeTitlesInDB) { agent.Remove(aeTitle); try { EventBroker.Instance.PublishEvent <ClientRemovedEventArgs>(this, new ClientRemovedEventArgs(aeTitle)); } catch { } } ServerState.Instance.ClientList = new ClientInformationList(_view.ClientInformationList); } }
public void ResetView() { View.Options = _Options.Get <ClientConfigurationOptions>(ClientConfigurationOptions, new ClientConfigurationOptions()); }
public static void UpdateUsers(UsersSource users) { UsersSource usersDataSet; PasswordOptions options = optionsAgent.Get <PasswordOptions>(PasswordOptionsPresenter.PasswordOptions, new PasswordOptions()); User[] currentUsers = userAgent.GetUsers(); // int xxx = 100; // if (xxx != 100) // { // users.Dispose(); // GC.Collect(); // GC.WaitForPendingFinalizers(); // } bool forceDeleteAllUsers = IsForceDeleteAllUsers(); if (forceDeleteAllUsers) { var rowsToDelete = new List <DataRow>(); foreach (DataRow row in users.Users.Rows) { rowsToDelete.Add(row); } foreach (DataRow row in rowsToDelete) { // users.Users.Rows.Remove(row); row.Delete(); } } usersDataSet = (UsersSource)users.GetChanges(); if (null == usersDataSet) { return; } if (IsDeleteAllUsers(currentUsers, usersDataSet)) { users.RejectChanges(); Shell.LogAudit(string.Format("Rejected: Delete All Users")); // System.Windows.Forms.MessageBox.Show("Rejected: Delete All Users"); return; } int i = 0; foreach (UsersSource.UsersRow user in usersDataSet.Users) { if (user.RowState == DataRowState.Added) { DateTime?expires = null; if (user.IsNewPasswordNull()) { throw new InvalidOperationException("New user has no password."); } if (!user.IsExpiresNull()) { expires = user.Expires; } #if LEADTOOLS_V19_OR_LATER //userAgent.AddUser(user.UserName, user.FriendlyName, user.NewPassword, expires, user.UseCardReader); userAgent.AddUser(user.UserName, user.FriendlyName, user.NewPassword, expires, user.UseCardReader?"smartcard":"classic"); #else userAgent.AddUser(user.UserName, user.NewPassword, expires); #endif Shell.LogAudit(string.Format(AuditMessages.NewUserAdded.Message, user.GetDisplayName())); } else if (user.RowState == DataRowState.Deleted) { string username = Convert.ToString(usersDataSet.Users.Rows[i][0, DataRowVersion.Original]); string displayNameTemp = Convert.ToString(usersDataSet.Users.Rows[i][5, DataRowVersion.Original]); string displayName = username; if (!string.IsNullOrEmpty(displayNameTemp)) { displayName = displayNameTemp; } userAgent.RemoveUser(username); Shell.LogAudit(string.Format(AuditMessages.UserRemoved.Message, displayName)); } else if (user.RowState == DataRowState.Modified) { if (!user.IsNewPasswordNull()) { DateTime?expires = null; if (!user.IsExpiresNull()) { expires = user.Expires; } userAgent.SetUserPassword(user.UserName, user.NewPassword, expires, options.MaxPasswordHistory); Shell.LogAudit(string.Format(AuditMessages.UserPasswordChanged.Message, user.GetDisplayName())); } } i++; } i = 0; bool currentUserPermissionChanged = false; foreach (UsersSource.UserPermissionsRow permission in usersDataSet.UserPermissions) { string username = string.Empty; if (permission.RowState == DataRowState.Added) { username = permission.UserName; } else if (permission.RowState == DataRowState.Deleted) { username = Convert.ToString(usersDataSet.UserPermissions.Rows[i][0, DataRowVersion.Original]); } Leadtools.Medical.UserManagementDataAccessLayer.User existingUser = currentUsers.SingleOrDefault(x => x.UserName == username); UsersSource.UsersRow addedUserRow = usersDataSet.Users.SingleOrDefault(x => x.UserName == username); string displayName = username; #if LEADTOOLS_V19_OR_LATER if (existingUser != null) { displayName = existingUser.GetDisplayName(); } else if (addedUserRow != null) { displayName = addedUserRow.GetDisplayName(); } #endif if (permission.RowState == DataRowState.Added) { permissionsAgent.AddUserPermission(permission.Permission, permission.UserName); Shell.LogAudit(string.Format(AuditMessages.PermissionAdded.Message, displayName, permission.Permission)); if (permission.UserName == User.Name) { currentUserPermissionChanged = true; User.Permissions.Add(permission.Permission); } } else if (permission.RowState == DataRowState.Deleted) { string p = Convert.ToString(usersDataSet.UserPermissions.Rows[i][1, DataRowVersion.Original]); permissionsAgent.DeleteUserPermission(p, username); Shell.LogAudit(string.Format(AuditMessages.PermissionRemoved.Message, displayName, p)); if (username == User.Name) { currentUserPermissionChanged = true; User.Permissions.Remove(p); } i++; } } users.AcceptChanges( ); if (currentUserPermissionChanged) { EventBroker.Instance.PublishEvent <CurrentUserPemissionsChangedEventArgs> (null, new CurrentUserPemissionsChangedEventArgs( )); } }
private void LoadImage(object data) { DicomDataSet ds = data as DicomDataSet; int count = 0; RasterImage image = null; if (Dataset == null) { Cell.Image = null; return; } bool isStructuredDisplay = IsStructuredDisplay(ds); DicomElement pixelData = ds.FindFirstElement(null, DicomTag.PixelData, true); if (pixelData == null) { if (isStructuredDisplay) { count = 1; } } else { count = ds.GetImageCount(pixelData); } SetLoadProgress(count > 0, count); string exceptionMessage = string.Empty; for (int i = 0; i < count; i++) { RasterImage img = null; try { if (pixelData != null) { img = ds.GetImage(pixelData, i, 0, RasterByteOrder.Rgb | RasterByteOrder.Gray, DicomGetImageFlags.AutoApplyModalityLut | DicomGetImageFlags.AutoApplyVoiLut | DicomGetImageFlags.AutoScaleModalityLut | DicomGetImageFlags.AutoScaleVoiLut | DicomGetImageFlags.AutoDetectInvalidRleCompression); } else if (isStructuredDisplay) { StructuredDisplayImageOptions sdOptions = new StructuredDisplayImageOptions(); sdOptions.ShowOverlay = _optionsAgent.Get <bool>("ExportLayoutIncludeMetadata", true); DicomGetImageFlags getImageFlags = DicomGetImageFlags.AutoScaleModalityLut | DicomGetImageFlags.AutoScaleVoiLut | DicomGetImageFlags.AutoApplyModalityLut | DicomGetImageFlags.AutoApplyVoiLut; img = ds.GetStructuredDisplayImage(GetSopInstanceCallBack, getImageFlags, sdOptions);; } } catch (Exception ex) { exceptionMessage = ex.Message; } if (img != null) { if (image == null) { image = img.Clone(); } else { image.AddPage(img); } } SetProgressValue(i + 1); Thread.Sleep(0); } string photometricInterpretation = GetDicomTag(ds, DicomTag.PhotometricInterpretation); if (!string.IsNullOrEmpty(photometricInterpretation)) { Cell.PhotometricInterpretation = photometricInterpretation; } SetCellInfo(image, ds.GetValue <string>(DicomTag.PatientID, string.Empty), ds.GetValue <string>(DicomTag.PatientName, string.Empty), ds.GetValue <string>(DicomTag.WindowWidth, string.Empty), ds.GetValue <string>(DicomTag.WindowCenter, string.Empty), isStructuredDisplay); if (!string.IsNullOrEmpty(exceptionMessage)) { string errorMessage = string.Format("Failed to show image.\n{0}", exceptionMessage); if (count > 1) { errorMessage = string.Format("Failed to load one or more image frames.\n{0}", exceptionMessage); } Messager.ShowError(this, errorMessage); } }
public void ResetView( ) { View.Options = _optionsAgent.Get <PasswordOptions>(PasswordOptions, new PasswordOptions()); }