protected virtual void RefreshClickedThreaded (object state) { DatabaseConnectionSettings settings = state as DatabaseConnectionSettings; DatabaseConnectionContext context = new DatabaseConnectionContext (settings); IDbFactory fac = DbFactoryService.GetDbFactory (settings.ProviderIdentifier); try { FakeConnectionPool pool = new FakeConnectionPool (fac, fac.ConnectionProvider, context); pool.Initialize (); ISchemaProvider prov = fac.CreateSchemaProvider (pool); DatabaseSchemaCollection databases = prov.GetDatabases (); foreach (DatabaseSchema db in databases) { DispatchService.GuiDispatch (delegate () { storeDatabases.AppendValues (db.Name); }); } isDatabaseListEmpty = databases.Count == 0; } catch {} if (isDatabaseListEmpty) { DispatchService.GuiDispatch (delegate () { storeDatabases.AppendValues (GettextCatalog.GetString ("No databases found!")); }); } else { DispatchService.GuiDispatch (delegate () { TreeIter iter; if (storeDatabases.GetIterFirst (out iter)) comboDatabase.SetActiveIter (iter); }); } }
protected virtual void TestClickedThreaded (object state) { DatabaseConnectionSettings settings = state as DatabaseConnectionSettings; DatabaseConnectionContext context = new DatabaseConnectionContext (settings); IDbFactory fac = DbFactoryService.GetDbFactory (settings.ProviderIdentifier); bool success = false; string error = null; FakeConnectionPool pool = null; IPooledDbConnection conn = null; try { pool = new FakeConnectionPool (fac, fac.ConnectionProvider, context); success = pool.Initialize (); error = pool.Error; } catch (System.Data.DataException ex) { error = ex.Message; success = false; } finally { if (conn != null) { conn.Release (); conn.Dispose (); } if (pool != null) pool.Close (); } DispatchService.GuiDispatch (delegate () { buttonTest.Sensitive = true; if (success) labelTest.Text = AddinCatalog.GetString ("Test Succeeded."); else labelTest.Text = AddinCatalog.GetString ("Test Failed: {0}.", error); }); }