예제 #1
0
        public bool InitDatabase(Utils.DBCon dbcon)
        {
            /*
             * database:
             * areainfo -> id, parentid, level, name, minlat, minlon, maxlat, maxlon
             * poly -> id, areainfoid, position, lat, lon
             */
            bool result = false;

            try
            {
                object o = dbcon.ExecuteScalar("SELECT name FROM sqlite_master WHERE type='table' AND name='areainfo'");
                if (o == null || o.GetType() == typeof(DBNull))
                {
                    dbcon.ExecuteNonQuery("create table 'areainfo' (id integer, parentid integer, level integer, name text, minlat real, minlon real, maxlat real, maxlon real)");
                }

                o = dbcon.ExecuteScalar("SELECT name FROM sqlite_master WHERE type='table' AND name='poly'");
                if (o == null || o.GetType() == typeof(DBNull))
                {
                    dbcon.ExecuteNonQuery("create table 'poly' (id integer, areainfoid integer, position integer, lat real, lon real)");
                    dbcon.ExecuteNonQuery("create index idx_poly on poly (areainfoid)");
                }

                result = true;
            }
            catch
            {
            }
            return(result);
        }
예제 #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 ClearAllData()
 {
     try
     {
         _dbcon.ExecuteNonQuery("delete from votes");
         _availableWaypoints.Clear();
     }
     catch
     {
     }
     if (_gcVoteActivated)
     {
         _core.Geocaches.BeginUpdate();
         try
         {
             foreach (Framework.Data.Geocache gc in _core.Geocaches)
             {
                 bool saved = gc.Saved;
                 gc.SetCustomAttribute(Import.CUSTOM_ATTRIBUTE, "");
                 gc.Saved = saved;
             }
         }
         catch
         {
         }
         _core.Geocaches.EndUpdate();
     }
 }
예제 #4
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();
            }
        }
예제 #5
0
 private void backupThreadMethod()
 {
     try
     {
         using (Utils.DBCon dbcon = initDatabase())
         {
             int index = 0;
             foreach (Framework.Data.Geocache gc in _core.Geocaches)
             {
                 if (Math.Abs(gc.Lat) > 0.0001 || Math.Abs(gc.Lon) > 0.0001)
                 {
                     if (dbcon.ExecuteNonQuery(string.Format("update coord set lat={0}, lon={1} where code='{2}'", gc.Lat.ToString().Replace(',', '.'), gc.Lon.ToString().Replace(',', '.'), gc.Code.Replace("'", "''"))) == 0)
                     {
                         dbcon.ExecuteNonQuery(string.Format("insert into coord (lat, lon, code) values ({0}, {1}, '{2}')", gc.Lat.ToString().Replace(',', '.'), gc.Lon.ToString().Replace(',', '.'), gc.Code.Replace("'", "''")));
                     }
                     index++;
                     if (index % 1000 == 0)
                     {
                         _context.Send(new SendOrPostCallback(delegate(object state)
                         {
                             toolStripProgressBar1.Value = index;
                         }), null);
                     }
                 }
             }
         }
     }
     catch
     {
     }
     _actionReady.Set();
 }
예제 #6
0
 private void button1_Click(object sender, EventArgs e)
 {
     this.Cursor = Cursors.WaitCursor;
     try
     {
         using (Utils.DBCon dbcon = initDatabase())
         {
             Framework.Data.Location l = Utils.Conversion.StringToLocation(textBox1.Text);
             if (l != null && listView1.SelectedItems.Count > 0)
             {
                 Framework.Data.Geocache gc = listView1.SelectedItems[0].Tag as Framework.Data.Geocache;
                 if (dbcon.ExecuteNonQuery(string.Format("update coord set lat={0}, lon={1} where code='{2}'", l.SLat, l.SLon, gc.Code.Replace("'", "''"))) == 0)
                 {
                     dbcon.ExecuteNonQuery(string.Format("insert into coord (lat, lon, code) values ({0}, {1}, '{2}')", l.SLat, l.SLon, gc.Code.Replace("'", "''")));
                 }
                 gc.BeginUpdate();
                 gc.Lat = l.Lat;
                 gc.Lon = l.Lon;
                 gc.EndUpdate();
                 listView1.Items.Remove(listView1.SelectedItems[0]);
             }
         }
     }
     catch
     {
     }
     this.Cursor = Cursors.Default;
 }
예제 #7
0
 private void deleteScriptData(ScriptInfo si)
 {
     try
     {
         using (Utils.DBCon dbcon = initDatabase())
         {
             dbcon.ExecuteNonQuery(string.Format("delete from scripts where id='{0}'", si.ID));
             dbcon.ExecuteNonQuery(string.Format("delete from settings where scriptid='{0}'", si.ID));
         }
     }
     catch
     {
     }
 }
예제 #8
0
 private void saveScriptData(ScriptInfo si)
 {
     try
     {
         using (Utils.DBCon dbcon = initDatabase())
         {
             if (dbcon.ExecuteNonQuery(string.Format("update scripts set name='{1}', content='{2}' where id='{0}'", si.ID, si.Name.Replace("'", "''"), si.Content.Replace("'", "''"))) == 0)
             {
                 dbcon.ExecuteNonQuery(string.Format("insert into scripts (id, name, scripttype, content) values ('{0}', '{1}', '{2}', '{3}')", si.ID, si.Name.Replace("'", "''"), si.ScriptType.ToString(), si.Content.Replace("'", "''")));
             }
         }
     }
     catch
     {
     }
 }
예제 #9
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
                {
                }
            }
        }
예제 #10
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;
            }
        }
예제 #11
0
 private void saveSettingsData()
 {
     try
     {
         using (Utils.DBCon dbcon = initDatabase())
         {
             foreach (ScriptInfo si in _scripts)
             {
                 if (si.ScriptType == ScriptType.Statistics)
                 {
                     if (dbcon.ExecuteNonQuery(string.Format("update settings set enable={1}, pos={0} where scriptid='{2}'", si.Order, si.Enabled ? 1 : 0, si.ID)) == 0)
                     {
                         dbcon.ExecuteNonQuery(string.Format("insert into settings (scriptid, enable, pos) values ('{2}', {1}, {0})", si.Order, si.Enabled ? 1 : 0, si.ID));
                     }
                 }
             }
         }
     }
     catch
     {
     }
 }
예제 #12
0
 private Utils.DBCon initDatabase()
 {
     if (_dbcon == null)
     {
         try
         {
             _dbcon = new Utils.DBConComSqlite(_databaseFile);
             object o = _dbcon.ExecuteScalar("SELECT name FROM sqlite_master WHERE type='table' AND name='attachements'");
             if (o == null || o.GetType() == typeof(DBNull))
             {
                 _dbcon.ExecuteNonQuery("create table 'attachements' (code text, filepath text, comment text)");
                 _dbcon.ExecuteNonQuery("create unique index idx_attachements on attachements (code)");
             }
         }
         catch
         {
             _dbcon = null;
         }
     }
     return _dbcon;
 }
예제 #13
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;
            }
        }
예제 #14
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;
            }
        }
예제 #15
0
        private void getImagesThreadMethod()
        {
            try
            {
                using (Utils.ProgressBlock blockprogress = new Utils.ProgressBlock(OwnerPlugin as Utils.BasePlugin.Plugin, STR_IMPORTINGMYF, STR_IMPORTINGMYF, 1, 0))
                {
                    try
                    {
                        Utils.DBCon dbcon = initDatabase();

                        var logs = new List <Utils.API.LiveV6.GeocacheLog>();

                        using (System.Net.WebClient wc = new System.Net.WebClient())
                            using (var api = new Utils.API.GeocachingLiveV6(Core))
                            {
                                using (Utils.ProgressBlock progress = new Utils.ProgressBlock(OwnerPlugin as Utils.BasePlugin.Plugin, STR_IMPORTINGMYF, STR_IMPORTINGLOGS, 100, 0, true))
                                {
                                    var req = new Utils.API.LiveV6.GetUsersGeocacheLogsRequest();
                                    req.AccessToken     = api.Token;
                                    req.ExcludeArchived = false;
                                    req.MaxPerPage      = 50;
                                    req.StartIndex      = 0;
                                    req.LogTypes        = (from a in Core.LogTypes select(long) a.ID).ToArray();
                                    var resp = api.Client.GetUsersGeocacheLogs(req);
                                    while (resp.Status.StatusCode == 0)
                                    {
                                        logs.AddRange(resp.Logs);
                                        foreach (var log in resp.Logs)
                                        {
                                            if (log.Images != null && !log.IsArchived)
                                            {
                                                foreach (var li in log.Images)
                                                {
                                                    string    imgGuid = li.ImageGuid.ToString("N");
                                                    ImageInfo ii      = (from a in _imageInfoList where a.ImageGuid == imgGuid select a).FirstOrDefault();
                                                    if (ii == null)
                                                    {
                                                        ii              = new ImageInfo();
                                                        ii.Description  = li.Description;
                                                        ii.ImageGuid    = imgGuid;
                                                        ii.MobileUrl    = li.MobileUrl ?? "";
                                                        ii.Name         = li.Name ?? "";
                                                        ii.ThumbUrl     = li.ThumbUrl;
                                                        ii.Url          = li.Url;
                                                        ii.LogCacheCode = log.CacheCode;
                                                        ii.LogCode      = log.Code;
                                                        ii.LogUrl       = log.Url;
                                                        ii.LogVisitDate = log.VisitDate;

                                                        ii.ThumbFile = Path.Combine(_thumbFolder, Path.GetFileName(li.ThumbUrl));
                                                        ii.ImgFile   = Path.Combine(_imgFolder, Path.GetFileName(li.Url));

                                                        _imageInfoList.Add(ii);

                                                        dbcon.ExecuteNonQuery(string.Format("insert into gallery (ImageGuid, ThumbUrl, Description, Name, MobileUrl, Url, LogCacheCode, LogCode, LogUrl, LogVisitDate, ThumbFile, ImgFile) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')", ii.ImageGuid.Replace("'", "''"), ii.ThumbUrl.Replace("'", "''"), ii.Description.Replace("'", "''"), ii.Name.Replace("'", "''"), ii.MobileUrl.Replace("'", "''"), ii.Url.Replace("'", "''"), ii.LogCacheCode.Replace("'", "''"), ii.LogCode.Replace("'", "''"), ii.LogUrl.Replace("'", "''"), ii.LogVisitDate.ToString("s").Replace("'", "''"), ii.ThumbFile.Replace("'", "''"), ii.ImgFile.Replace("'", "''")));
                                                    }
                                                    //check if local file(s) exist(s)
                                                    //not fail on img download!
                                                    try
                                                    {
                                                        if (!File.Exists(ii.ThumbFile))
                                                        {
                                                            wc.DownloadFile(li.ThumbUrl, ii.ThumbFile);
                                                        }
                                                        if (!File.Exists(ii.ImgFile))
                                                        {
                                                            wc.DownloadFile(li.Url, ii.ImgFile);
                                                        }
                                                    }
                                                    catch
                                                    {
                                                    }
                                                }
                                            }
                                        }

                                        if (resp.Logs.Count() >= req.MaxPerPage)
                                        {
                                            req.StartIndex = logs.Count;
                                            if (!progress.UpdateProgress(STR_IMPORTINGMYF, STR_IMPORTINGLOGS, logs.Count + req.MaxPerPage, logs.Count))
                                            {
                                                break;
                                            }
                                            Thread.Sleep(1500);
                                            resp = api.Client.GetUsersGeocacheLogs(req);
                                        }
                                        else
                                        {
                                            break;
                                        }
                                    }
                                    if (resp.Status.StatusCode != 0)
                                    {
                                        _errormessage = resp.Status.StatusMessage;
                                    }
                                }
                            }
                        if (dbcon != null)
                        {
                            dbcon.Dispose();
                            dbcon = null;
                        }
                    }
                    catch (Exception e)
                    {
                        _errormessage = e.Message;
                    }
                }
            }
            catch
            {
            }
            _actionReady.Set();
        }