Пример #1
0
        private Utils.DBCon initDatabase()
        {
            Utils.DBCon dbcon = new Utils.DBConComSqlite(_databaseFile);
            object      o     = dbcon.ExecuteScalar("SELECT name FROM sqlite_master WHERE type='table' AND name='scripts'");

            if (o == null || o.GetType() == typeof(DBNull))
            {
                dbcon.ExecuteNonQuery("create table 'scripts' (id text, name text, scripttype text, content text)");
            }
            o = dbcon.ExecuteScalar("SELECT name FROM sqlite_master WHERE type='table' AND name='settings'");
            if (o == null || o.GetType() == typeof(DBNull))
            {
                dbcon.ExecuteNonQuery("create table 'settings' (scriptid text, enable integer, pos integer)");
            }
            return(dbcon);
        }
Пример #2
0
        private void PreLoadAreaInfo()
        {
            if (_cachedAreaInfo == null)
            {
                _cachedAreaInfo = new List <Framework.Data.AreaInfo>();

                try
                {
                    using (Utils.DBCon dbcon = new Utils.DBConComSqlite(_databaseFilename))
                    {
                        if (InitDatabase(dbcon))
                        {
                            DbDataReader dr = dbcon.ExecuteReader("select * from areainfo");
                            while (dr.Read())
                            {
                                Framework.Data.AreaInfo ai = new Framework.Data.AreaInfo();
                                ai.ID       = (int)dr["id"];
                                ai.ParentID = dr["parentid"] == DBNull.Value ? null : dr["parentid"];
                                ai.Level    = (Framework.Data.AreaType)(short)(int) dr["level"];
                                ai.Name     = (string)dr["name"];
                                ai.MinLat   = (double)dr["minlat"];
                                ai.MinLon   = (double)dr["minlon"];
                                ai.MaxLat   = (double)dr["maxlat"];
                                ai.MaxLon   = (double)dr["maxlon"];
                                _cachedAreaInfo.Add(ai);
                            }
                        }

                        object o = dbcon.ExecuteScalar("select Max(id) from areainfo");
                        if (o != null)
                        {
                            _maxAreaInfoId = (int)(long)o;
                        }
                        o = dbcon.ExecuteScalar("select Max(id) from poly");
                        if (o != null)
                        {
                            _maxPolyId = (int)(long)o;
                        }
                    }
                }
                catch
                {
                    //corrupt file
                    _cachedAreaInfo.Clear();
                }
            }
        }
Пример #3
0
 private Utils.DBCon initDatabase()
 {
     Utils.DBCon dbcon;
     try
     {
         dbcon = new Utils.DBConComSqlite(_databaseFile);
         object o = dbcon.ExecuteScalar("SELECT name FROM sqlite_master WHERE type='table' AND name='gallery'");
         if (o == null || o.GetType() == typeof(DBNull))
         {
             dbcon.ExecuteNonQuery("create table 'gallery' (ImageGuid text, ThumbUrl text, Description text, Name text, MobileUrl text, Url text, LogCacheCode text, LogCode text, LogUrl text, LogVisitDate text, ThumbFile text, ImgFile text)");
         }
     }
     catch
     {
         dbcon = null;
     }
     return(dbcon);
 }
Пример #4
0
 private Utils.DBCon initDatabase()
 {
     Utils.DBCon result = null;
     try
     {
         string fn = System.IO.Path.Combine(_core.PluginDataPath, "coordsav.db3");
         if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(fn)))
         {
             System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(fn));
         }
         result = new Utils.DBConComSqlite(fn);
         object o = result.ExecuteScalar("SELECT name FROM sqlite_master WHERE type='table' AND name='coord'");
         if (o == null || o.GetType() == typeof(DBNull))
         {
             result.ExecuteNonQuery("create table 'coord' (code text, lat real, lon real)");
             result.ExecuteNonQuery("create unique index idx_coord on coord (code)");
         }
     }
     catch
     {
     }
     return(result);
 }
Пример #5
0
 private Utils.DBCon initDatabase()
 {
     Utils.DBCon result = null;
     try
     {
         string fn = System.IO.Path.Combine(_core.PluginDataPath, "coordsav.db3" );
         if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(fn)))
         {
             System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(fn));
         }
         result = new Utils.DBConComSqlite(fn);
         object o = result.ExecuteScalar("SELECT name FROM sqlite_master WHERE type='table' AND name='coord'");
         if (o == null || o.GetType() == typeof(DBNull))
         {
             result.ExecuteNonQuery("create table 'coord' (code text, lat real, lon real)");
             result.ExecuteNonQuery("create unique index idx_coord on coord (code)");
         }
     }
     catch
     {
     }
     return result;
 }
Пример #6
0
        private void initDatabase()
        {
            string xmlFileContents;
            Assembly assembly = Assembly.GetExecutingAssembly();
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.LanguageEng.LookupDictionary.xml")))
            {
                xmlFileContents = textStreamReader.ReadToEnd();
            }
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xmlFileContents);
            XmlElement root = doc.DocumentElement;
            XmlNodeList strngs = root.SelectNodes("string");
            if (strngs != null)
            {
                foreach (XmlNode sn in strngs)
                {
                    if (!string.IsNullOrEmpty(sn.Attributes["value"].InnerText))
                    {
                        _fixedLookupTable[sn.Attributes["name"].InnerText.ToLower()] = sn.Attributes["value"].InnerText;
                    }
                }
            }

            try
            {
                using (Utils.DBCon dbcon = new Utils.DBConComSqlite(_customDictionaryDatabaseFile))
                {
                    object o = dbcon.ExecuteScalar("SELECT name FROM sqlite_master WHERE type='table' AND name='translation'");
                    if (o == null || o.GetType() == typeof(DBNull))
                    {
                        dbcon.ExecuteNonQuery("create table 'translation' (item_name text, item_value text)");
                    }
                    DbDataReader dr = dbcon.ExecuteReader("select * from translation");
                    while (dr.Read())
                    {
                        _customLookupTable[dr["item_name"].ToString().ToLower()] = dr["item_value"].ToString();
                    }
                }
            }
            catch
            {
            }
        }
Пример #7
0
        private void PreLoadAreaInfo()
        {
            if (_cachedAreaInfo == null)
            {
                _cachedAreaInfo = new List<Framework.Data.AreaInfo>();

                try
                {
                    using (Utils.DBCon dbcon = new Utils.DBConComSqlite(_databaseFilename))
                    {
                        if (InitDatabase(dbcon))
                        {
                            DbDataReader dr = dbcon.ExecuteReader("select * from areainfo");
                            while (dr.Read())
                            {
                                Framework.Data.AreaInfo ai = new Framework.Data.AreaInfo();
                                ai.ID = (int)dr["id"];
                                ai.ParentID = dr["parentid"] == DBNull.Value ? null : dr["parentid"];
                                ai.Level = (Framework.Data.AreaType)(short)(int)dr["level"];
                                ai.Name = (string)dr["name"];
                                ai.MinLat = (double)dr["minlat"];
                                ai.MinLon = (double)dr["minlon"];
                                ai.MaxLat = (double)dr["maxlat"];
                                ai.MaxLon = (double)dr["maxlon"];
                                _cachedAreaInfo.Add(ai);
                            }
                        }

                        object o = dbcon.ExecuteScalar("select Max(id) from areainfo");
                        if (o != null)
                        {
                            _maxAreaInfoId = (int)(long)o;
                        }
                        o = dbcon.ExecuteScalar("select Max(id) from poly");
                        if (o != null)
                        {
                            _maxPolyId = (int)(long)o;
                        }
                    }
                }
                catch
                {
                    //corrupt file
                    _cachedAreaInfo.Clear();
                }
            }
        }
Пример #8
0
 private void InitDatabase()
 {
     try
     {
         if (!string.IsNullOrEmpty(_databaseFile))
         {
             Utils.DBCon dbcon = new Utils.DBConComSqlite(_databaseFile);
             object o = dbcon.ExecuteScalar("SELECT name FROM sqlite_master WHERE type='table' AND name='filterfields'");
             if (o == null || o.GetType() == typeof(DBNull))
             {
                 dbcon.ExecuteNonQuery("create table 'filterfields' (field text, filter text)");
             }
         }
     }
     catch
     {
     }
 }
Пример #9
0
 private Utils.DBCon initDatabase()
 {
     Utils.DBCon dbcon;
     try
     {
         dbcon = new Utils.DBConComSqlite(_databaseFile);
         object o = dbcon.ExecuteScalar("SELECT name FROM sqlite_master WHERE type='table' AND name='gallery'");
         if (o == null || o.GetType() == typeof(DBNull))
         {
             dbcon.ExecuteNonQuery("create table 'gallery' (ImageGuid text, ThumbUrl text, Description text, Name text, MobileUrl text, Url text, LogCacheCode text, LogCode text, LogUrl text, LogVisitDate text, ThumbFile text, ImgFile text)");
         }
     }
     catch
     {
         dbcon = null;
     }
     return dbcon;
 }
Пример #10
0
 private Utils.DBCon initDatabase()
 {
     Utils.DBCon dbcon = new Utils.DBConComSqlite(_databaseFile);
     object o = dbcon.ExecuteScalar("SELECT name FROM sqlite_master WHERE type='table' AND name='scripts'");
     if (o == null || o.GetType() == typeof(DBNull))
     {
         dbcon.ExecuteNonQuery("create table 'scripts' (id text, name text, scripttype text, content text)");
     }
     o = dbcon.ExecuteScalar("SELECT name FROM sqlite_master WHERE type='table' AND name='settings'");
     if (o == null || o.GetType() == typeof(DBNull))
     {
         dbcon.ExecuteNonQuery("create table 'settings' (scriptid text, enable integer, pos integer)");
     }
     return dbcon;
 }