예제 #1
0
 private void ImageGalleryForm_Shown(object sender, EventArgs e)
 {
     //get from database
     Utils.DBCon dbcon = initDatabase();
     if (dbcon != null)
     {
         DbDataReader dr = dbcon.ExecuteReader("select * from gallery");
         while (dr.Read())
         {
             ImageInfo ai = new ImageInfo();
             ai.Description  = dr["Description"] as string;
             ai.ImageGuid    = dr["ImageGuid"] as string;
             ai.ImgFile      = dr["ImgFile"] as string;
             ai.LogCacheCode = dr["LogCacheCode"] as string;
             ai.LogCode      = dr["LogCode"] as string;
             ai.LogUrl       = dr["LogUrl"] as string;
             ai.LogVisitDate = DateTime.Parse(dr["LogVisitDate"] as string);
             ai.MobileUrl    = dr["MobileUrl"] as string;
             ai.Name         = dr["Name"] as string;
             ai.ThumbFile    = dr["ThumbFile"] as string;
             ai.ThumbUrl     = dr["ThumbUrl"] as string;
             ai.Url          = dr["Url"] as string;
             _imageInfoList.Add(ai);
         }
         dbcon.Dispose();
         dbcon = null;
     }
     ShowImageThumbnails();
 }
예제 #2
0
파일: Repository.cs 프로젝트: RH-Code/GAPP
        public void Initialize(Framework.Interfaces.ICore core)
        {
            _core = core;
            _availableWaypoints = new Hashtable();

            try
            {
                _dbcon = new Utils.DBConComSqlite(Path.Combine(core.PluginDataPath,"gcvote.db3"));

                object o = _dbcon.ExecuteScalar("SELECT name FROM sqlite_master WHERE type='table' AND name='votes'");
                if (o == null || o.GetType() == typeof(DBNull))
                {
                    _dbcon.ExecuteNonQuery("create table 'votes' (Waypoint text, VoteMedian float, VoteAvg float, VoteCnt integer, VoteUser double)");
                    _dbcon.ExecuteNonQuery("create unique index idx_votess on votes (Waypoint)");
                }

                DbDataReader dr = _dbcon.ExecuteReader("select Waypoint from votes");
                while (dr.Read())
                {
                    _availableWaypoints.Add(dr[0], true);
                }
            }
            catch
            {
                _dbcon = null;
                _availableWaypoints.Clear();
            }
        }
예제 #3
0
        public void Initialize(Framework.Interfaces.ICore core)
        {
            _core = core;
            _availableWaypoints = new Hashtable();

            try
            {
                _dbcon = new Utils.DBConComSqlite(Path.Combine(core.PluginDataPath, "gcvote.db3"));

                object o = _dbcon.ExecuteScalar("SELECT name FROM sqlite_master WHERE type='table' AND name='votes'");
                if (o == null || o.GetType() == typeof(DBNull))
                {
                    _dbcon.ExecuteNonQuery("create table 'votes' (Waypoint text, VoteMedian float, VoteAvg float, VoteCnt integer, VoteUser double)");
                    _dbcon.ExecuteNonQuery("create unique index idx_votess on votes (Waypoint)");
                }

                DbDataReader dr = _dbcon.ExecuteReader("select Waypoint from votes");
                while (dr.Read())
                {
                    _availableWaypoints.Add(dr[0], true);
                }
            }
            catch
            {
                _dbcon = null;
                _availableWaypoints.Clear();
            }
        }
예제 #4
0
파일: Repository.cs 프로젝트: RH-Code/GAPP
        public void Initialize(Framework.Interfaces.ICore core)
        {
            if (_bookmarks == null)
            {
                _bookmarks = new Hashtable();

                try
                {
                    _dbcon = new Utils.DBConComSqlite(Path.Combine(core.PluginDataPath, "gccollections.db3"));

                    object o = _dbcon.ExecuteScalar("SELECT name FROM sqlite_master WHERE type='table' AND name='bookmark'");
                    if (o == null || o.GetType() == typeof(DBNull))
                    {
                        _dbcon.ExecuteNonQuery("create table 'bookmark' (ID integer primary key autoincrement, Name text)");

                        _dbcon.ExecuteNonQuery("create table 'codes' (BookmarkID integer, Code text)");
                    }

                    DbDataReader dr = _dbcon.ExecuteReader("select ID, Name from bookmark");
                    while (dr.Read())
                    {
                        BookmarkInfo bmi = new BookmarkInfo();
                        bmi.ID = (int)dr["ID"];
                        bmi.Name = (string)dr["Name"];
                        _bookmarks.Add(bmi.Name.ToLower(), bmi);
                    }

                    dr = _dbcon.ExecuteReader("select BookmarkID, Code from codes");
                    while (dr.Read())
                    {
                        int id = (int)dr["BookmarkID"];
                        BookmarkInfo bmi = (from BookmarkInfo b in _bookmarks.Values where b.ID==id select b).FirstOrDefault();
                        if (bmi != null)
                        {
                            bmi.GeocacheCodes.Add(dr["Code"], true);
                        }
                    }
                }
                catch
                {
                }
            }
        }
예제 #5
0
        public void LoadGCVoteDataThreadMethod()
        {
            try
            {
                using (Utils.ProgressBlock prog = new Utils.ProgressBlock(_activePlugin, Import.STR_IMPORT, Import.STR_IMPORT, _availableWaypoints.Count, 0))
                {
                    int          pos = 0;
                    DbDataReader dr  = _dbcon.ExecuteReader("select Waypoint, VoteAvg, VoteCnt, VoteUser from votes");
                    while (dr.Read())
                    {
                        pos++;
                        string wp = (string)dr["Waypoint"];
                        Framework.Data.Geocache gc = Utils.DataAccess.GetGeocache(_core.Geocaches, wp);
                        if (gc != null)
                        {
                            double avg     = (double)dr["VoteAvg"];
                            double usrVote = (double)dr["VoteUser"];
                            int    cnt     = (int)dr["VoteCnt"];

                            bool saved = gc.Saved;
                            if (usrVote > 0.1)
                            {
                                gc.SetCustomAttribute(Import.CUSTOM_ATTRIBUTE, string.Format("{0:0.0}/{1} ({2:0.0})", avg, cnt, usrVote));
                            }
                            else
                            {
                                gc.SetCustomAttribute(Import.CUSTOM_ATTRIBUTE, string.Format("{0:0.0}/{1}", avg, cnt));
                            }
                            gc.Saved = saved;
                            if (pos % 500 == 0)
                            {
                                prog.UpdateProgress(Import.STR_IMPORT, Import.STR_IMPORT, _availableWaypoints.Count, pos);
                            }
                        }
                    }
                }
            }
            catch
            {
            }
        }
예제 #6
0
        public SqliteSettingsStorage()
        {
            _availableKeys = new Hashtable();
            try
            {
                string sf = Properties.Settings.Default.SettingsFolder;
                if (string.IsNullOrEmpty(sf))
                {
                    sf = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "GAPPSF");
                }
                if (!Directory.Exists(sf))
                {
                    Directory.CreateDirectory(sf);
                }
                Properties.Settings.Default.SettingsFolder = sf;
                Properties.Settings.Default.Save();

                sf = Path.Combine(sf, "settings.db3");
                _dbcon = new Utils.DBConComSqlite(sf);

                if (!_dbcon.TableExists("settings"))
                {
                    _dbcon.ExecuteNonQuery("create table 'settings' (item_name text, item_value text)");
                    _dbcon.ExecuteNonQuery("create index idx_key on settings (item_name)");
                }
                else
                {
                    DbDataReader dr = _dbcon.ExecuteReader("select item_name, item_value from settings");
                    while (dr.Read())
                    {
                        _availableKeys[dr[0] as string] = dr[1] as string;
                    }
                }
            }
            catch
            {
                _dbcon = null;
            }
        }
예제 #7
0
        private void restoreThreadMethod()
        {
            try
            {
                var gcList = (from Framework.Data.Geocache g in _core.Geocaches where Math.Abs(g.Lat) < 0.0001 && Math.Abs(g.Lon) < 0.0001 select g).ToArray();
                _context.Send(new SendOrPostCallback(delegate(object state)
                {
                    toolStripProgressBar1.Maximum = gcList.Length;
                }), null);

                using (Utils.DBCon dbcon = initDatabase())
                {
                    int index = 0;
                    foreach (Framework.Data.Geocache gc in gcList)
                    {
                        DbDataReader dr = dbcon.ExecuteReader(string.Format("select lat, lon from coord where code='{0}'", gc.Code.Replace("'", "''")));
                        if (dr.Read())
                        {
                            gc.Lat = (double)dr["lat"];
                            gc.Lon = (double)dr["lon"];
                        }
                        index++;
                        if (index % 100 == 0)
                        {
                            _context.Send(new SendOrPostCallback(delegate(object state)
                            {
                                toolStripProgressBar1.Value = index;
                            }), null);
                        }
                    }
                }
            }
            catch
            {
            }
            _actionReady.Set();
        }
예제 #8
0
        public SqliteSettingsStorage()
        {
            _availableKeys = new Hashtable();
            _ignoredGeocacheCodes = new Hashtable();
            _ignoredGeocacheNames = new Hashtable();
            _ignoredGeocacheOwners = new Hashtable();
            try
            {
                string sf = Properties.Settings.Default.SettingsFolder;
                if (string.IsNullOrEmpty(sf))
                {
                    sf = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "GAPPSF");
                }
                if (!Directory.Exists(sf))
                {
                    Directory.CreateDirectory(sf);
                }
                Properties.Settings.Default.SettingsFolder = sf;
                Properties.Settings.Default.Save();

                sf = Path.Combine(sf, "settings.db3");

                _dbcon = new Utils.DBConComSqlite(sf);

                if (!_dbcon.TableExists("settings"))
                {
                    _dbcon.ExecuteNonQuery("create table 'settings' (item_name text, item_value text)");
                    _dbcon.ExecuteNonQuery("create index idx_key on settings (item_name)");
                }
                else
                {
                    DbDataReader dr = _dbcon.ExecuteReader("select item_name, item_value from settings");
                    while (dr.Read())
                    {
                        _availableKeys[dr[0] as string] = dr[1] as string;
                    }
                }
                if (!_dbcon.TableExists("ignoregc"))
                {
                    _dbcon.ExecuteNonQuery("create table 'ignoregc' (item_name text, item_value text)");
                }
                else
                {
                    DbDataReader dr = _dbcon.ExecuteReader("select item_name, item_value from ignoregc");
                    while (dr.Read())
                    {
                        string item = dr[0] as string;
                        if (item == "code")
                        {
                            _ignoredGeocacheCodes[dr[1] as string] = true;
                        }
                        else if (item == "name")
                        {
                            _ignoredGeocacheNames[dr[1] as string] = true;
                        }
                        else if (item == "owner")
                        {
                            _ignoredGeocacheOwners[dr[1] as string] = true;
                        }
                    }
                }
                if (!_dbcon.TableExists("gccombm"))
                {
                    _dbcon.ExecuteNonQuery("create table 'gccombm' (bm_id text, bm_name text, bmguid text)");
                    _dbcon.ExecuteNonQuery("create index idx_bmid on gccombm (bm_id)");
                }
                if (!_dbcon.TableExists("gccomgc"))
                {
                    _dbcon.ExecuteNonQuery("create table 'gccomgc' (bm_id text, gccode text)");
                    _dbcon.ExecuteNonQuery("create index idx_bmgcid on gccomgc (bm_id)");
                }
                if (!_dbcon.TableExists("attachm"))
                {
                    _dbcon.ExecuteNonQuery("create table 'attachm' (gccode text, filename text, comments text)");
                    _dbcon.ExecuteNonQuery("create index idx_att on attachm (gccode)");
                }
                if (!_dbcon.TableExists("formulasolv"))
                {
                    _dbcon.ExecuteNonQuery("create table 'formulasolv' (gccode text, formula text)");
                    _dbcon.ExecuteNonQuery("create index idx_form on formulasolv (gccode)");
                }
                if (!_dbcon.TableExists("gcnotes"))
                {
                    _dbcon.ExecuteNonQuery("create table 'gcnotes' (gccode text, notes text)");
                    _dbcon.ExecuteNonQuery("create index idx_note on gcnotes (gccode)");
                }
                if (!_dbcon.TableExists("gccollection"))
                {
                    _dbcon.ExecuteNonQuery("create table 'gccollection' (col_id integer primary key autoincrement, name text)");
                    //_dbcon.ExecuteNonQuery("create index idx_col on gccollection (name)");
                }
                if (!_dbcon.TableExists("gcincol"))
                {
                    _dbcon.ExecuteNonQuery("create table 'gcincol' (col_id integer, gccode text)");
                    _dbcon.ExecuteNonQuery("create index idx_gccol on gcincol (col_id)");
                }
                if (!_dbcon.TableExists("gcdist"))
                {
                    _dbcon.ExecuteNonQuery("create table 'gcdist' (gccode text, dist float)");
                    _dbcon.ExecuteNonQuery("create index idx_dist on gcdist (gccode)");
                }
                if (!_dbcon.TableExists("gcvotes"))
                {
                    _dbcon.ExecuteNonQuery("create table 'gcvotes' (gccode text, VoteMedian float, VoteAvg float, VoteCnt integer, VoteUser float)");
                    _dbcon.ExecuteNonQuery("create unique index idx_gcvotes on gcvotes (gccode)");
                }

                object o = _dbcon.ExecuteScalar("PRAGMA integrity_check");
                if (o as string == "ok")
                {
                    //what is expected
                }
                else
                {
                    //oeps?
                    _dbcon.Dispose();
                    _dbcon = null;
                }
            }
            catch//(Exception e)
            {
                //Core.ApplicationData.Instance.Logger.AddLog(this, e);
                _dbcon = null;
            }
        }
예제 #9
0
        private void TrackableGroupsForm_Shown(object sender, EventArgs e)
        {
            PluginSettings.Instance.DatabaseFileName = System.IO.Path.Combine(Core.PluginDataPath, "TrkGroup.db3" );

            try
            {
                _dbcon = new Utils.DBConComSqlite(PluginSettings.Instance.DatabaseFileName);
                initDatabase(_dbcon);
                DbDataReader dr = _dbcon.ExecuteReader("select * from groups");
                while (dr.Read())
                {
                    TrackableGroup tg = new TrackableGroup();
                    tg.ID = (int)dr["id"];
                    tg.Name = (string)dr["name"];
                    _trackableGroups.Add(tg);
                }
                initImageList();
                comboBoxGroup.Items.AddRange(_trackableGroups.ToArray());
            }
            catch
            {
                _dbcon = null;
            }

            comboBoxGroup_SelectedValueChanged(this, EventArgs.Empty);
            SelectedLanguageChanged(this, EventArgs.Empty);
        }
예제 #10
0
        public SqliteSettingsStorage()
        {
            _availableKeys = new Hashtable();
            _ignoredGeocacheCodes = new Hashtable();
            _ignoredGeocacheNames = new Hashtable();
            _ignoredGeocacheOwners = new Hashtable();
            try
            {
                string sf = Properties.Settings.Default.SettingsFolder;
                if (string.IsNullOrEmpty(sf))
                {
                    sf = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "GAPPSF");
                }
                if (!Directory.Exists(sf))
                {
                    Directory.CreateDirectory(sf);
                }
                Properties.Settings.Default.SettingsFolder = sf;
                Properties.Settings.Default.Save();

                sf = Path.Combine(sf, "settings.db3");
                //if (!DesignerProperties.GetIsInDesignMode(new DependencyObject()))
                {
                    _dbcon = new Utils.DBConComSqlite(sf);

                    if (!_dbcon.TableExists("settings"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'settings' (item_name text, item_value text)");
                        _dbcon.ExecuteNonQuery("create index idx_key on settings (item_name)");
                    }
                    else
                    {
                        DbDataReader dr = _dbcon.ExecuteReader("select item_name, item_value from settings");
                        while (dr.Read())
                        {
                            _availableKeys[dr[0] as string] = dr[1] as string;
                        }
                    }
                    if (!_dbcon.TableExists("ignoregc"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'ignoregc' (item_name text, item_value text)");
                    }
                    else
                    {
                        DbDataReader dr = _dbcon.ExecuteReader("select item_name, item_value from ignoregc");
                        while (dr.Read())
                        {
                            string item = dr[0] as string;
                            if (item == "code")
                            {
                                _ignoredGeocacheCodes[dr[1] as string] = true;
                            }
                            else if (item == "name")
                            {
                                _ignoredGeocacheNames[dr[1] as string] = true;
                            }
                            else if (item == "owner")
                            {
                                _ignoredGeocacheOwners[dr[1] as string] = true;
                            }
                        }
                    }
                    if (!_dbcon.TableExists("gccombm"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'gccombm' (bm_id text, bm_name text, bmguid text)");
                        _dbcon.ExecuteNonQuery("create index idx_bmid on gccombm (bm_id)");
                    }
                    if (!_dbcon.TableExists("gccomgc"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'gccomgc' (bm_id text, gccode text)");
                        _dbcon.ExecuteNonQuery("create index idx_bmgcid on gccomgc (bm_id)");
                    }
                    if (!_dbcon.TableExists("attachm"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'attachm' (gccode text, filename text, comments text)");
                        _dbcon.ExecuteNonQuery("create index idx_att on attachm (gccode)");
                    }
                    if (!_dbcon.TableExists("formulasolv"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'formulasolv' (gccode text, formula text)");
                        _dbcon.ExecuteNonQuery("create index idx_form on formulasolv (gccode)");
                    }
                    if (!_dbcon.TableExists("gcnotes"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'gcnotes' (gccode text, notes text)");
                        _dbcon.ExecuteNonQuery("create index idx_note on gcnotes (gccode)");
                    }
                    if (!_dbcon.TableExists("gccollection"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'gccollection' (col_id integer primary key autoincrement, name text)");
                        //_dbcon.ExecuteNonQuery("create index idx_col on gccollection (name)");
                    }
                    if (!_dbcon.TableExists("gcincol"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'gcincol' (col_id integer, gccode text)");
                        _dbcon.ExecuteNonQuery("create index idx_gccol on gcincol (col_id)");
                    }
                    if (!_dbcon.TableExists("gcdist"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'gcdist' (gccode text, dist float)");
                        _dbcon.ExecuteNonQuery("create index idx_dist on gcdist (gccode)");
                    }
                    if (!_dbcon.TableExists("gcvotes"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'gcvotes' (gccode text, VoteMedian float, VoteAvg float, VoteCnt integer, VoteUser float)");
                        _dbcon.ExecuteNonQuery("create unique index idx_gcvotes on gcvotes (gccode)");
                    }

                    if (!_dbcon.TableExists("trkgroups"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'trkgroups' (id integer, name text)");
                    }
                    if (!_dbcon.TableExists("trkimages"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'trkimages' (url text, imagedata blob)");
                    }
                    if (!_dbcon.TableExists("trktrackables"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'trktrackables' (groupid integer, AllowedToBeCollected integer, Archived integer, BugTypeID integer, Code text, CurrentGeocacheCode text, CurrentGoal text, DateCreated text, Description text, IconUrl text, Id integer, InCollection integer, Name text, TBTypeName text, Url text, WptTypeID integer, Owner text, HopCount integer, DiscoverCount integer, InCacheCount integer, DistanceKm real, Lat real, Lon real)");
                        _dbcon.ExecuteNonQuery("create index idx_trackablesgroup on trktrackables (groupid)");
                        _dbcon.ExecuteNonQuery("create index idx_trackablescode on trktrackables (code)");
                    }
                    if (!_dbcon.TableExists("trktravels"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'trktravels' (pos integer, TrackableCode text, GeocacheCode text, lat real, lon real, DateLogged text)");
                        _dbcon.ExecuteNonQuery("create index idx_travels on trktravels (TrackableCode)");
                    }
                    if (!_dbcon.TableExists("trklogs"))
                    {
                        _dbcon.ExecuteNonQuery("create table 'trklogs' (TrackableCode text, ID integer, LogCode text, GeocacheCode text, IsArchived integer, LoggedBy text, LogGuid text, LogIsEncoded integer, LogText text, WptLogTypeId integer, Url text, UTCCreateDate text, VisitDate text)");
                        _dbcon.ExecuteNonQuery("create index idx_logstb on trklogs (TrackableCode)");
                        _dbcon.ExecuteNonQuery("create index idx_logsid on trklogs (ID)");
                    }


                    object o = _dbcon.ExecuteScalar("PRAGMA integrity_check");
                    if (o as string == "ok")
                    {
                        //what is expected
                    }
                    else
                    {
                        //oeps?
                        _dbcon.Dispose();
                        _dbcon = null;
                    }
                }
            }
            catch//(Exception e)
            {
                //Core.ApplicationData.Instance.Logger.AddLog(this, e);
                _dbcon = null;
            }
        }
예제 #11
0
        private void StatisticsGeneratorForm_Shown(object sender, EventArgs e)
        {
            _scriptFile = new TemporaryFile(true);

            _templatesNode          = new TreeNode("Templates");
            _templatesNode.Checked  = true;
            _extensionsNode         = new TreeNode("Extensions");
            _extensionsNode.Checked = true;
            _skinsNode         = new TreeNode("Skins");
            _skinsNode.Checked = true;
            _statsNode         = new TreeNode("Statistics");
            _statsNode.Checked = true;

            treeView1.Nodes.Add(_templatesNode);
            treeView1.Nodes.Add(_extensionsNode);
            treeView1.Nodes.Add(_skinsNode);
            treeView1.Nodes.Add(_statsNode);

            Assembly assembly = Assembly.GetExecutingAssembly();

            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.StatsGen.Scripts.DefaultTemplate.txt")))
            {
                ScriptInfo si = new ScriptInfo();
                si.Content    = textStreamReader.ReadToEnd();
                si.ID         = "templ_1";
                si.Name       = "Default Template";
                si.ReadOnly   = true;
                si.Order      = 1;
                si.ScriptType = ScriptType.Template;
                si.Enabled    = true;
                _scripts.Add(si);
            }
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.StatsGen.Scripts.DefaultExtension.txt")))
            {
                ScriptInfo si = new ScriptInfo();
                si.Content    = textStreamReader.ReadToEnd();
                si.ID         = "ext_1";
                si.Name       = "Default Extension";
                si.ReadOnly   = true;
                si.Order      = 1;
                si.ScriptType = ScriptType.Extension;
                si.Enabled    = true;
                _scripts.Add(si);
            }
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.StatsGen.Scripts.DefaultSkin.txt")))
            {
                ScriptInfo si = new ScriptInfo();
                si.Content    = textStreamReader.ReadToEnd();
                si.ID         = "skin_1";
                si.Name       = "Default Skin";
                si.ReadOnly   = true;
                si.Order      = 1;
                si.ScriptType = ScriptType.Skin;
                si.Enabled    = true;
                _scripts.Add(si);
            }
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.StatsGen.Scripts.GoogleChartAPI.txt")))
            {
                ScriptInfo si = new ScriptInfo();
                si.Content    = textStreamReader.ReadToEnd();
                si.ID         = "ext_2";
                si.Name       = "Google Chart API";
                si.ReadOnly   = true;
                si.Order      = 1;
                si.ScriptType = ScriptType.Extension;
                si.Enabled    = true;
                _scripts.Add(si);
            }
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.StatsGen.Scripts.foundCaches.txt")))
            {
                ScriptInfo si = new ScriptInfo();
                si.Content    = textStreamReader.ReadToEnd();
                si.ID         = "FoundCaches";
                si.Name       = "Found caches";
                si.ReadOnly   = true;
                si.Order      = 1;
                si.ScriptType = ScriptType.Statistics;
                si.Enabled    = true;
                _scripts.Add(si);
            }
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.StatsGen.Scripts.DaysCached.txt")))
            {
                ScriptInfo si = new ScriptInfo();
                si.Content    = textStreamReader.ReadToEnd();
                si.ID         = "DaysCached";
                si.Name       = "Days cached";
                si.ReadOnly   = true;
                si.Order      = 1;
                si.ScriptType = ScriptType.Statistics;
                si.Enabled    = true;
                _scripts.Add(si);
            }
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.StatsGen.Scripts.History.txt")))
            {
                ScriptInfo si = new ScriptInfo();
                si.Content    = textStreamReader.ReadToEnd();
                si.ID         = "History";
                si.Name       = "History";
                si.ReadOnly   = true;
                si.Order      = 1;
                si.ScriptType = ScriptType.Statistics;
                si.Enabled    = true;
                _scripts.Add(si);
            }
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.StatsGen.Scripts.DTMatrix.txt")))
            {
                ScriptInfo si = new ScriptInfo();
                si.Content    = textStreamReader.ReadToEnd();
                si.ID         = "DTMatrix";
                si.Name       = "DT Matrix";
                si.ReadOnly   = true;
                si.Order      = 1;
                si.ScriptType = ScriptType.Statistics;
                si.Enabled    = true;
                _scripts.Add(si);
            }
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.StatsGen.Scripts.DiffTerr.txt")))
            {
                ScriptInfo si = new ScriptInfo();
                si.Content    = textStreamReader.ReadToEnd();
                si.ID         = "DiffTerr";
                si.Name       = "Difficulty and terrain";
                si.ReadOnly   = true;
                si.Order      = 1;
                si.ScriptType = ScriptType.Statistics;
                si.Enabled    = true;
                _scripts.Add(si);
            }
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.StatsGen.Scripts.Milestones.txt")))
            {
                ScriptInfo si = new ScriptInfo();
                si.Content    = textStreamReader.ReadToEnd();
                si.ID         = "Milestones";
                si.Name       = "Milestones";
                si.ReadOnly   = true;
                si.Order      = 1;
                si.ScriptType = ScriptType.Statistics;
                si.Enabled    = true;
                _scripts.Add(si);
            }
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.StatsGen.Scripts.CacheSizeAndType.txt")))
            {
                ScriptInfo si = new ScriptInfo();
                si.Content    = textStreamReader.ReadToEnd();
                si.ID         = "CacheST";
                si.Name       = "Cache size and type";
                si.ReadOnly   = true;
                si.Order      = 2;
                si.ScriptType = ScriptType.Statistics;
                si.Enabled    = true;
                _scripts.Add(si);
            }
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.StatsGen.Scripts.LocationsTable.txt")))
            {
                ScriptInfo si = new ScriptInfo();
                si.Content    = textStreamReader.ReadToEnd();
                si.ID         = "LocationsTable";
                si.Name       = "Locations table";
                si.ReadOnly   = true;
                si.Order      = 3;
                si.ScriptType = ScriptType.Statistics;
                si.Enabled    = true;
                _scripts.Add(si);
            }
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.StatsGen.Scripts.LogLengthTable.txt")))
            {
                ScriptInfo si = new ScriptInfo();
                si.Content    = textStreamReader.ReadToEnd();
                si.ID         = "LogLengthTable";
                si.Name       = "Log length table";
                si.ReadOnly   = true;
                si.Order      = 3;
                si.ScriptType = ScriptType.Statistics;
                si.Enabled    = false;
                _scripts.Add(si);
            }
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.StatsGen.Scripts.myGeoToolsBadges.txt")))
            {
                ScriptInfo si = new ScriptInfo();
                si.Content    = textStreamReader.ReadToEnd();
                si.ID         = "myGeoToolsBadges";
                si.Name       = "myGeoTools Badges";
                si.ReadOnly   = true;
                si.Order      = 10;
                si.ScriptType = ScriptType.Statistics;
                si.Enabled    = false;
                _scripts.Add(si);
            }
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.StatsGen.Scripts.WorldMap66.txt")))
            {
                ScriptInfo si = new ScriptInfo();
                si.Content    = textStreamReader.ReadToEnd();
                si.ID         = "WorldMap66";
                si.Name       = "World map";
                si.ReadOnly   = true;
                si.Order      = 4;
                si.ScriptType = ScriptType.Statistics;
                si.Enabled    = true;
                _scripts.Add(si);
            }
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.StatsGen.Scripts.EuropeMap66.txt")))
            {
                ScriptInfo si = new ScriptInfo();
                si.Content    = textStreamReader.ReadToEnd();
                si.ID         = "EuropeMap66";
                si.Name       = "Europe map";
                si.ReadOnly   = true;
                si.Order      = 5;
                si.ScriptType = ScriptType.Statistics;
                si.Enabled    = true;
                _scripts.Add(si);
            }
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.StatsGen.Scripts.TotalFoundsPerMonthGraph.txt")))
            {
                ScriptInfo si = new ScriptInfo();
                si.Content    = textStreamReader.ReadToEnd();
                si.ID         = "TotalFoundsPerMonthGraph";
                si.Name       = "Total founds per month graph";
                si.ReadOnly   = true;
                si.Order      = 50;
                si.ScriptType = ScriptType.Statistics;
                si.Enabled    = true;
                _scripts.Add(si);
            }
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.StatsGen.Scripts.DiffTerrPie.txt")))
            {
                ScriptInfo si = new ScriptInfo();
                si.Content    = textStreamReader.ReadToEnd();
                si.ID         = "DiffTerrPie";
                si.Name       = "Difficulty and terrain pie";
                si.ReadOnly   = true;
                si.Order      = 51;
                si.ScriptType = ScriptType.Statistics;
                si.Enabled    = true;
                _scripts.Add(si);
            }
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.StatsGen.Scripts.CacheTypeRatioGraph.txt")))
            {
                ScriptInfo si = new ScriptInfo();
                si.Content    = textStreamReader.ReadToEnd();
                si.ID         = "CacheTypeRatioGraph";
                si.Name       = "Cache type ratio graph";
                si.ReadOnly   = true;
                si.Order      = 52;
                si.ScriptType = ScriptType.Statistics;
                si.Enabled    = true;
                _scripts.Add(si);
            }
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.StatsGen.Scripts.CacheTravelDistanceGraph.txt")))
            {
                ScriptInfo si = new ScriptInfo();
                si.Content    = textStreamReader.ReadToEnd();
                si.ID         = "CacheTravelDistanceGraph";
                si.Name       = "Cache travel distance graph";
                si.ReadOnly   = true;
                si.Order      = 53;
                si.ScriptType = ScriptType.Statistics;
                si.Enabled    = true;
                _scripts.Add(si);
            }

            try
            {
                using (Utils.DBCon dbcon = initDatabase())
                {
                    DbDataReader dr = dbcon.ExecuteReader("select * from scripts");
                    while (dr.Read())
                    {
                        ScriptInfo si = new ScriptInfo();
                        si.Content    = dr["content"] as string;
                        si.ID         = dr["id"] as string;
                        si.Name       = dr["name"] as string;
                        si.ReadOnly   = false;
                        si.ScriptType = (ScriptType)Enum.Parse(typeof(ScriptType), dr["scripttype"] as string);
                        _scripts.Add(si);
                    }
                    dr = dbcon.ExecuteReader("select * from settings");
                    while (dr.Read())
                    {
                        ScriptInfo si = (from s in _scripts where s.ID == (string)dr["scriptid"] select s).FirstOrDefault();
                        if (si != null)
                        {
                            si.Order   = (int)dr["pos"];
                            si.Enabled = (int)dr["enable"] != 0;
                        }
                    }
                }
            }
            catch
            {
            }

            addNodes(ScriptType.Template, _templatesNode);
            addNodes(ScriptType.Extension, _extensionsNode);
            addNodes(ScriptType.Skin, _skinsNode);
            addNodes(ScriptType.Statistics, _statsNode);

            treeView1.ExpandAll();

            GenerateScript();
        }