예제 #1
0
		//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);
		}
예제 #2
0
        //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);
        }
예제 #3
0
		public EnsureConnectionState (DatabaseConnectionContext context, DatabaseConnectionContextCallback callback, object state)
		{
			ConnectionContext = context;
			Callback = callback;
			State = state;
		}
예제 #4
0
 public EnsureConnectionState(DatabaseConnectionContext context, DatabaseConnectionContextCallback callback, object state)
 {
     ConnectionContext = context;
     Callback          = callback;
     State             = state;
 }