Пример #1
0
        public static bool LoadLog()
        {
            System.Diagnostics.Debug.Assert(gbl == null);       // no double instancing!
            gbl = new GlobalCaptainsLogList();

            try
            {
                using (SQLiteConnectionUser cn = new SQLiteConnectionUser(mode: SQLLiteExtensions.SQLExtConnection.AccessMode.Reader))
                {
                    using (DbCommand cmd = cn.CreateCommand("select * from CaptainsLog"))
                    {
                        List <CaptainsLogClass> logs = new List <CaptainsLogClass>();

                        using (DbDataReader rdr = cmd.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                logs.Add(new CaptainsLogClass(rdr));
                            }
                        }

                        if (logs.Count == 0)
                        {
                            return(false);
                        }
                        else
                        {
                            foreach (var bc in logs)
                            {
                                gbl.globallog.Add(bc);
                            }

                            return(true);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception " + ex.ToString());
                return(false);
            }
        }
        public static bool LoadLog()
        {
            System.Diagnostics.Debug.Assert(gbl == null);       // no double instancing!
            gbl = new GlobalCaptainsLogList();

            try
            {
                return(UserDatabase.Instance.ExecuteWithDatabase <bool>(cn =>
                {
                    using (DbCommand cmd = cn.Connection.CreateCommand("select * from CaptainsLog"))
                    {
                        List <CaptainsLogClass> logs = new List <CaptainsLogClass>();

                        using (DbDataReader rdr = cmd.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                logs.Add(new CaptainsLogClass(rdr));
                            }
                        }

                        if (logs.Count == 0)
                        {
                            return false;
                        }
                        else
                        {
                            foreach (var bc in logs)
                            {
                                gbl.globallog.Add(bc);
                            }

                            return true;
                        }
                    }
                }));
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception " + ex.ToString());
                return(false);
            }
        }
Пример #3
0
        public static bool LoadLog()
        {
            System.Diagnostics.Debug.Assert(gbl == null);       // no double instancing!
            gbl = new GlobalCaptainsLogList();

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

                        ds = cn.SQLQueryText(cmd);

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

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

                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception " + ex.ToString());
                return(false);
            }
        }