Exemple #1
0
 public static long GetTotalSystems()            // this is SLOW try not to use
 {
     using (SQLiteConnectionSystem cn = new SQLiteConnectionSystem(mode: SQLLiteExtensions.SQLExtConnection.AccessMode.Reader))
     {
         using (DbCommand cmd = cn.CreateCommand("select Count(1) from Systems"))
         {
             return((long)cmd.ExecuteScalar());
         }
     }
 }
Exemple #2
0
        private static void UpdateSchema()
        {
            bool id_edsm_isset = false;

            using (SQLiteConnectionSystem cn = new SQLiteConnectionSystem())
            {
                UpdateDbSchema(cn, Schema.EDDSystem);

                // Reset EDSM / EDDB update time if no systems have their id_edsm set
                using (DbCommand cmd = cn.CreateCommand("SELECT COUNT(EdsmId) FROM EdsmSystems"))
                {
                    id_edsm_isset = (long)cmd.ExecuteScalar() != 0;
                }

                if (!id_edsm_isset)
                {
                    System.Diagnostics.Trace.WriteLine("Resetting EDSM and EDDB last update time");
                    cn.PutSettingStringCN("EDSMLastSystems", "2010-01-01 00:00:00");        // force EDSM sync..
                    cn.PutSettingStringCN("EDDBSystemsTime", "0");                          // force EDDB
                    cn.PutSettingStringCN("EDSCLastDist", "2010-01-01 00:00:00");           // force distances
                }
            }

            using (SQLiteConnectionUser cn = new SQLiteConnectionUser())
            {
                UpdateDbSchema(cn, Schema.EDDUser);

                // Null out any coordinates where (x,y,z) = (0,0,0) and the system is not Sol

                /*
                 * using (DbCommand cmd = cn.CreateCommand("Update VisitedSystems set x=null, y=null, z=null where x=0 and y=0 and z=0 and name!=\"Sol\""))
                 * {
                 *  cmd.ExecuteNonQuery();
                 * }
                 */
            }
        }