//TODO: show errors public static void EnsureConnection (DatabaseConnectionContext context, DatabaseConnectionContextCallback callback, object state) { if (context == null) throw new ArgumentNullException ("context"); if (callback == null) throw new ArgumentNullException ("callback"); IConnectionPool pool = context.ConnectionPool; if (pool.IsInitialized) { callback (context, true, state); return; } IDbFactory fac = DbFactoryService.GetDbFactory (context.ConnectionSettings); bool requiresPassword = fac.GetCapabilities ("ConnectionSettings", SchemaActions.Schema) == (int)ConnectionSettingsCapabilities.Password; if (!context.ConnectionSettings.SavePassword && String.IsNullOrEmpty (context.ConnectionSettings.Password) && requiresPassword) { string password = Services.MessageService.GetPassword ( GettextCatalog.GetString ("Please enter the password for connection '{0}'", context.ConnectionSettings.Name), GettextCatalog.GetString ("Enter Password") ); if (String.IsNullOrEmpty (password)) { callback (context, false, state); return; } else { context.ConnectionSettings.Password = password; } } EnsureConnectionState internalState = new EnsureConnectionState (context, callback, state); ThreadPool.QueueUserWorkItem (new WaitCallback (EnsureConnectionThreaded), internalState); }
//TODO: show errors public static void EnsureConnection(DatabaseConnectionContext context, DatabaseConnectionContextCallback callback, object state) { if (context == null) { throw new ArgumentNullException("context"); } if (callback == null) { throw new ArgumentNullException("callback"); } IConnectionPool pool = context.ConnectionPool; if (pool.IsInitialized) { callback(context, true, state); return; } IDbFactory fac = DbFactoryService.GetDbFactory(context.ConnectionSettings); //FIXME: connection settings dialog //bool requiresPassword = fac.GetCapabilities ("ConnectionSettings", SchemaActions.Schema) == (int)ConnectionSettingsCapabilities.Password; bool requiresPassword = true; if (!context.ConnectionSettings.SavePassword && String.IsNullOrEmpty(context.ConnectionSettings.Password) && requiresPassword) { string password = MessageService.GetPassword( AddinCatalog.GetString("Please enter the password for connection '{0}'", context.ConnectionSettings.Name), AddinCatalog.GetString("Enter Password") ); if (password == null) { callback(context, false, state); return; } else { context.ConnectionSettings.Password = password; } } EnsureConnectionState internalState = new EnsureConnectionState(context, callback, state); ThreadPool.QueueUserWorkItem(new WaitCallback(EnsureConnectionThreaded), internalState); }
public EnsureConnectionState (DatabaseConnectionContext context, DatabaseConnectionContextCallback callback, object state) { ConnectionContext = context; Callback = callback; State = state; }
public EnsureConnectionState(DatabaseConnectionContext context, DatabaseConnectionContextCallback callback, object state) { ConnectionContext = context; Callback = callback; State = state; }