コード例 #1
0
        public static bool LoadBookmarks()
        {
            System.Diagnostics.Debug.Assert(gbl == null);       // no double instancing!
            gbl = new GlobalBookMarkList();

            try
            {
                using (SQLiteConnectionUser cn = new SQLiteConnectionUser(mode: EDDbAccessMode.Reader))
                {
                    using (DbCommand cmd = cn.CreateCommand("select * from Bookmarks"))
                    {
                        DataSet ds = null;

                        ds = SQLiteDBClass.SQLQueryText(cn, cmd);

                        if (ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                        {
                            return(false);
                        }

                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            BookmarkClass bc = new BookmarkClass(dr);
                            gbl.globalbookmarks.Add(bc);
                        }

                        return(true);
                    }
                }
            }
            catch
            {
                return(false);
            }
        }
コード例 #2
0
        public static bool LoadBookmarks()
        {
            System.Diagnostics.Debug.Assert(gbl == null);       // no double instancing!
            gbl = new GlobalBookMarkList();

            try
            {
                List <BookmarkClass> bookmarks = new List <BookmarkClass>();

                UserDatabase.Instance.ExecuteWithDatabase(cn =>
                {
                    using (DbCommand cmd = cn.Connection.CreateCommand("select * from Bookmarks"))
                    {
                        using (DbDataReader rdr = cmd.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                bookmarks.Add(new BookmarkClass(rdr));
                            }
                        }
                    }
                });


                if (bookmarks.Count == 0)
                {
                    return(false);
                }
                else
                {
                    foreach (var bc in bookmarks)
                    {
                        gbl.globalbookmarks.Add(bc);
                    }
                    return(true);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception " + ex.ToString());
                return(false);
            }
        }