Exemplo n.º 1
0
 private string GetGeocachePostion(string code)
 {
     string result = "";
     if (!string.IsNullOrEmpty(code)
         && !string.IsNullOrEmpty(Settings.Settings.Default.DatabaseFolderPath)
         && !string.IsNullOrEmpty(Settings.Settings.Default.SelectedDatabase)
         )
     {
         try
         {
             var fn = System.IO.Path.Combine(Settings.Settings.Default.DatabaseFolderPath, Settings.Settings.Default.SelectedDatabase, "sqlite.db3");
             if (System.IO.File.Exists(fn))
             {
                 using (var temp = new Database.DBConSqlite(fn))
                 using (var db = new NPoco.Database(temp.Connection, NPoco.DatabaseType.SQLite))
                 {
                     var wp = db.FirstOrDefault<DataTypes.GSAKCaches>("select * from Caches where Code=@0", code);
                     var wpc = db.FirstOrDefault<DataTypes.GSAKCorrected>("select * from Corrected where kCode=@0", code);
                     if (wpc != null && !string.IsNullOrEmpty(wpc.kAfterLat) && !string.IsNullOrEmpty(wpc.kAfterLon))
                     {
                         result = Utils.Conversion.GetCoordinatesPresentation(Utils.Conversion.StringToDouble(wpc.kAfterLat), Utils.Conversion.StringToDouble(wpc.kAfterLon));
                     }
                     else if (!string.IsNullOrEmpty(wp.Latitude) && !string.IsNullOrEmpty(wp.Longitude))
                     {
                         result = Utils.Conversion.GetCoordinatesPresentation(Utils.Conversion.StringToDouble(wp.Latitude), Utils.Conversion.StringToDouble(wp.Longitude));
                     }
                 }
             }
         }
         catch
         {
         }
     }
     return result;
 }
Exemplo n.º 2
0
        public GeocacheCollection GetCollection(string name, bool createIfNotExists = false)
        {
            GeocacheCollection result = null;

            if (!string.IsNullOrEmpty(name))
            {
                lock (this)
                {
                    if (_dbcon != null)
                    {
                        using (var db = new NPoco.Database(_dbcon.Connection, NPoco.DatabaseType.SQLite))
                        {
                            result = db.FirstOrDefault <GeocacheCollection>("where Name like @0", name);
                            if (result == null && createIfNotExists)
                            {
                                //just the lazy way
                                var record = db.FirstOrDefault <GeocacheCollection>("order by CollectionID desc limit 1");
                                result              = new GeocacheCollection();
                                result.Name         = name;
                                result.CollectionID = record == null ? 1 : record.CollectionID + 1;
                                db.Insert(result);
                            }
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 3
0
            //----------------------------------------------------------------------------------------------------------------
            public static Breach CheckIfBreachExistsInDatabase(string Title)
            {
                //Check database to see if Title passed in exists in the Breach table
                Breach breach = db.FirstOrDefault <Breach>("SELECT * FROM Breach WHERE Title= @0 ", Title);

                return(breach);
            }
Exemplo n.º 4
0
            //----------------------------------------------------------------------------------------------------------------
            public static Breached_Emails CheckIfEmailExistsInDatabase(Breached_Emails breachedEmailsObj)
            {
                Breached_Emails breachedEmails = db.FirstOrDefault <Breached_Emails>("SELECT * FROM Breached_Emails WHERE ID= @0 AND Email= @1"
                                                                                     , breachedEmailsObj.ID, breachedEmailsObj.Email);

                return(breachedEmails);
            }
Exemplo n.º 5
0
        private object GetWaypointPostion(string wpt)
        {
            string result = "";

            if (!string.IsNullOrEmpty(Settings.Settings.Default.ActiveGeocacheCode) &&
                !string.IsNullOrEmpty(Settings.Settings.Default.DatabaseFolderPath) &&
                !string.IsNullOrEmpty(Settings.Settings.Default.SelectedDatabase)
                )
            {
                try
                {
                    var fn = System.IO.Path.Combine(Settings.Settings.Default.DatabaseFolderPath, Settings.Settings.Default.SelectedDatabase, "sqlite.db3");
                    if (System.IO.File.Exists(fn))
                    {
                        using (var temp = new Database.DBConSqlite(fn))
                            using (var db = new NPoco.Database(temp.Connection, NPoco.DatabaseType.SQLite))
                            {
                                var wp = db.FirstOrDefault <DataTypes.GSAKWaypoints>("select * from Waypoints where cCode=@0", wpt);
                                if (!string.IsNullOrEmpty(wp.cLat) && !string.IsNullOrEmpty(wp.cLon))
                                {
                                    result = Utils.Conversion.GetCoordinatesPresentation(Utils.Conversion.StringToDouble(wp.cLat), Utils.Conversion.StringToDouble(wp.cLon));
                                }
                            }
                    }
                }
                catch
                {
                }
            }
            return(result);
        }
Exemplo n.º 6
0
        public DTO.Database.CurrencyExchangeRateDto CurrencyExchangeRate(DateTime date, string currencyCode)
        {
            DTO.Database.CurrencyExchangeRateDto result;

            using (NPoco.IDatabase dbContext = new NPoco.Database(DTO.Global.SQLConnectionString, NPoco.DatabaseType.SqlServer2012))
            {
                result = dbContext.FirstOrDefault <DTO.Database.CurrencyExchangeRateDto>("SELECT * FROM tbl_CurrencyExchangeRate WHERE CurrencyExchangeRateShortDate = " + Helper.DateHelper.ShortDate(date) + " AND CurrencyCode = '" + currencyCode + "'");
            }

            return(result);
        }
Exemplo n.º 7
0
        private string GetGeocachePostion(string code)
        {
            string result = "";

            if (!string.IsNullOrEmpty(code) &&
                !string.IsNullOrEmpty(Settings.Settings.Default.DatabaseFolderPath) &&
                !string.IsNullOrEmpty(Settings.Settings.Default.SelectedDatabase)
                )
            {
                try
                {
                    var fn = System.IO.Path.Combine(Settings.Settings.Default.DatabaseFolderPath, Settings.Settings.Default.SelectedDatabase, "sqlite.db3");
                    if (System.IO.File.Exists(fn))
                    {
                        using (var temp = new Database.DBConSqlite(fn))
                            using (var db = new NPoco.Database(temp.Connection, NPoco.DatabaseType.SQLite))
                            {
                                var wp  = db.FirstOrDefault <DataTypes.GSAKCaches>("select * from Caches where Code=@0", code);
                                var wpc = db.FirstOrDefault <DataTypes.GSAKCorrected>("select * from Corrected where kCode=@0", code);
                                if (wpc != null && !string.IsNullOrEmpty(wpc.kAfterLat) && !string.IsNullOrEmpty(wpc.kAfterLon))
                                {
                                    result = Utils.Conversion.GetCoordinatesPresentation(Utils.Conversion.StringToDouble(wpc.kAfterLat), Utils.Conversion.StringToDouble(wpc.kAfterLon));
                                }
                                else if (!string.IsNullOrEmpty(wp.Latitude) && !string.IsNullOrEmpty(wp.Longitude))
                                {
                                    result = Utils.Conversion.GetCoordinatesPresentation(Utils.Conversion.StringToDouble(wp.Latitude), Utils.Conversion.StringToDouble(wp.Longitude));
                                }
                            }
                    }
                }
                catch
                {
                }
            }
            return(result);
        }
Exemplo n.º 8
0
        public ScriptItem GetScriptItem(string name)
        {
            ScriptItem result = null;

            lock (this)
            {
                if (_dbcon != null)
                {
                    using (var db = new NPoco.Database(_dbcon.Connection, NPoco.DatabaseType.SQLite))
                    {
                        result = db.FirstOrDefault <ScriptItem>("select * from Scripts where Name=@0", name);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 9
0
 public void StoreScriptItem(ScriptItem item)
 {
     lock (this)
     {
         if (_dbcon != null)
         {
             using (var db = new NPoco.Database(_dbcon.Connection, NPoco.DatabaseType.SQLite))
             {
                 if (db.FirstOrDefault <ScriptItem>("select * from Scripts where Name=@0", item.Name) == null)
                 {
                     db.Insert("Scripts", null, item);
                 }
                 else
                 {
                     db.Update("Scripts", "Name", item);
                 }
             }
         }
     }
 }
Exemplo n.º 10
0
 private object GetWaypointPostion(string wpt)
 {
     string result = "";
     if (!string.IsNullOrEmpty(Settings.Settings.Default.ActiveGeocacheCode)
         && !string.IsNullOrEmpty(Settings.Settings.Default.DatabaseFolderPath)
         && !string.IsNullOrEmpty(Settings.Settings.Default.SelectedDatabase)
         )
     {
         try
         {
             var fn = System.IO.Path.Combine(Settings.Settings.Default.DatabaseFolderPath, Settings.Settings.Default.SelectedDatabase, "sqlite.db3");
             if (System.IO.File.Exists(fn))
             {
                 using (var temp = new Database.DBConSqlite(fn))
                 using (var db = new NPoco.Database(temp.Connection, NPoco.DatabaseType.SQLite))
                 {
                     var wp = db.FirstOrDefault<DataTypes.GSAKWaypoints>("select * from Waypoints where cCode=@0", wpt);
                     if (!string.IsNullOrEmpty(wp.cLat) && !string.IsNullOrEmpty(wp.cLon))
                     {
                         result = Utils.Conversion.GetCoordinatesPresentation(Utils.Conversion.StringToDouble(wp.cLat), Utils.Conversion.StringToDouble(wp.cLon));
                     }
                 }
             }
         }
         catch
         {
         }
     }
     return result;
 }