public DbUtils.Core.Api.IDbServerConnection[] RestoreSessions(SqliteConnection connection)
        {
            InitializeStateDb(connection);

            IList <IDbServerConnection> sessions = new List <IDbServerConnection> ();

            using (SqliteCommand cmd = connection.CreateCommand()) {
                cmd.CommandText = "select * from dbstate";
                using (SqliteDataReader reader = cmd.ExecuteReader()) {
                    while (reader.Read())
                    {
                        string providerName = reader.GetString(reader.GetOrdinal("provider"));
                        string state        = reader.GetString(reader.GetOrdinal("state"));

                        try {
                            Type providerType = Type.GetType(providerName);
                            ISessionStateProvider sessionProvider = (ISessionStateProvider)providerType.GetConstructor(new Type[] {}).Invoke(new object[] {});
                            IDbServerConnection   session         = sessionProvider.restoreSessionFromState(state);
                            sessions.Add(session);
                        } catch (Exception e) {
                            // todo, log error and continue
                            throw e;
                        }
                    }
                }
            }

            return(sessions.ToArray());
        }
Example #2
0
        protected void OnOpenSqliteDb(object sender, EventArgs e)
        {
            SqliteConnectionLoader loader     = new SqliteConnectionLoader(false);
            IDbServerConnection    connection = loader.getConnection(this);

            if (connection != null)
            {
                loadConnection(connection);
            }
        }
Example #3
0
        public void TestSqliteSessionStateProvider()
        {
            SqliteConnectionStringBuilder conStrBuilder        = new SqliteConnectionStringBuilder();
            SqliteDbServerConnection      serverCon            = new SqliteDbServerConnection("test", conStrBuilder.ConnectionString);
            ISessionStateProvider         sessionStateProvider = new SqliteSessionStateProvider(serverCon);

            String state = sessionStateProvider.getSerializedState();

            IDbServerConnection restoredCon = sessionStateProvider.restoreSessionFromState(state);

            Assert.AreEqual(restoredCon, serverCon);
        }
Example #4
0
        private void loadConnectionRecursive(IDbServerConnection con, Nullable <TreeIter> parentIter, IFeature parentFeature)
        {
            IFeature[] features = con.GetFeatures(parentFeature);

            foreach (IFeature feature in features)
            {
                TreeIter   iter;
                Gdk.Pixbuf icon = string.IsNullOrEmpty(feature.Icon) ? new Gdk.Pixbuf(string.Format("Resources{0}Icons{0}folder.png", System.IO.Path.DirectorySeparatorChar)) : new Gdk.Pixbuf(feature.Icon);
                if (parentIter.HasValue)
                {
                    iter = objectBrowserTreeStore.AppendValues(parentIter.Value, icon, feature);
                }
                else
                {
                    iter = objectBrowserTreeStore.AppendValues(icon, feature);
                }
                loadConnectionRecursive(con, iter, feature);
            }

            objectBrowserTreeView.ExpandRow(new TreePath("0"), false);
        }
Example #5
0
 private void loadConnection(IDbServerConnection con)
 {
     loadConnectionRecursive(con, new Nullable <TreeIter>(), (IFeature)null);
     ApplicationState.Instance.Connections.Add(con);
 }
Example #6
0
 public DbServerConnectionEventArgs(IDbServerConnection dbServerConnection)
 {
     this.DbServerConnection = dbServerConnection;
 }
Example #7
0
        private void loadConnectionRecursive(IDbServerConnection con, Nullable<TreeIter> parentIter, IFeature parentFeature)
        {
            IFeature[] features = con.GetFeatures (parentFeature);

            foreach (IFeature feature in features) {
                TreeIter iter;
                Gdk.Pixbuf icon = string.IsNullOrEmpty( feature.Icon ) ? new Gdk.Pixbuf(string.Format("Resources{0}Icons{0}folder.png", System.IO.Path.DirectorySeparatorChar)) : new Gdk.Pixbuf (feature.Icon);
                if (parentIter.HasValue) {
                    iter = objectBrowserTreeStore.AppendValues (parentIter.Value, icon, feature);
                } else {
                    iter = objectBrowserTreeStore.AppendValues (icon, feature);
                }
                loadConnectionRecursive (con, iter, feature);
            }

            objectBrowserTreeView.ExpandRow (new TreePath ("0"), false);
        }
Example #8
0
 private void loadConnection(IDbServerConnection con)
 {
     loadConnectionRecursive (con, new Nullable<TreeIter>(), (IFeature)null);
     ApplicationState.Instance.Connections.Add (con);
 }
Example #9
0
 public SqlEditor(IDbServerConnection serverConnection)
 {
     this.ServerConnection = serverConnection;
     this.Build();
 }
 public DbServerConnectionEventArgs(IDbServerConnection dbServerConnection)
 {
     this.DbServerConnection = dbServerConnection;
 }
        public void SaveSessions(IDbServerConnection[] sessions, SqliteConnection connection)
        {
            using (SqliteCommand cmd = connection.CreateCommand ()) {
                cmd.CommandText = "delete from dbstate";
                cmd.ExecuteNonQuery ();
            }

            using (SqliteCommand cmd = connection.CreateCommand()) {

                cmd.CommandText = "insert into dbstate(provider, state) values (:provider, :state)";

                sessions.ToList ().ForEach ((s) => {
                    var stateProviderName = s.SessionStateProvider.GetType().AssemblyQualifiedName;
                    cmd.Parameters.Add("provider", System.Data.DbType.String).Value = stateProviderName;
                    cmd.Parameters.Add("state", System.Data.DbType.String).Value = s.SessionStateProvider.getSerializedState();
                    cmd.ExecuteNonQuery();
                });
            }
        }
Example #12
0
 public SqlEditor(IDbServerConnection serverConnection)
 {
     this.ServerConnection = serverConnection;
     this.Build ();
 }