示例#1
0
 public static void SetEnabled(Recipe recipe)
 {
     using (DAC dac = new DAC())
     {
         string statement = string.Format("UPDATE Recipe SET IsEnabled = {0} WHERE Name = '{1}';", recipe.IsEnabled ? 1 : 0, recipe.Name);
         dac.ExecuteCommand(statement);
     }
 }
示例#2
0
 public static void Update(Position pos)
 {
     using (DAC dac = new DAC())
     {
         string statement = string.Format("UPDATE Location SET Latitude = {0}, Longitude = {1}, FetchedOn = '{2}' WHERE Key = '{3}';", pos.Latitude, pos.Longitude, pos.FetchedOn, pos.Key);
         dac.ExecuteCommand(statement);
     }
 }
示例#3
0
 public static void Clear()
 {
     using (DAC dac = new DAC())
     {
         string statement = string.Format("DELETE FROM News;");
         dac.ExecuteCommand(statement);
     }
 }
示例#4
0
 public static void Insert(LocationEntry entry)
 {
     using (DAC dac = new DAC())
     {
         string statement = string.Format("INSERT INTO LocationHistory (Latitude, Longitude, VisitedOn, IsKnown, KnownKey) VALUES ({0}, {1}, '{2}', {3}, '{4}');", entry.Latitude, entry.Longitude, entry.VisitedOn, entry.IsKnown ? 1 : 0, entry.KnownKey);
         dac.ExecuteCommand(statement);
     }
 }
示例#5
0
 public static void Insert(WeatherEntry entry)
 {
     using (DAC dac = new DAC())
     {
         string statement = string.Format("INSERT INTO WeatherHistory (Latitude, Longitude, Temperature, Forecast, FetchedOn) VALUES ({0}, {1}, {2}, '{3}', '{4}');", entry.Latitude, entry.Longitude, entry.Temperature, entry.Forecast, entry.FetchedOn);
         dac.ExecuteCommand(statement);
     }
 }
示例#6
0
        public static int Set(string key, string value)
        {
            value = value.Replace("'", "''");

            string statement = string.Format("UPDATE Settings SET SettingValue = '{0}', UpdatedOn = '{1}' WHERE [SettingKey] = '{2}';", value, DateTime.Now.ToString(), key);

            using (DAC dac = new DAC())
            {
                return(dac.ExecuteCommand(statement));
            }
        }
示例#7
0
 public static bool IsDuplicate(NewsEntry entry)
 {
     using (DAC dac = new DAC())
     {
         string query = string.Format("SELECT Title FROM News WHERE Provider = '{0}' AND Title = '{1}' AND EmailId = '{2}';", entry.Provider, entry.Title, entry.EmailId);
         using (DbDataReader reader = dac.FetchRecords(query))
         {
             return(reader.HasRows);
         }
     }
 }
示例#8
0
        public static void Insert(NewsEntry entry)
        {
            entry.Title   = entry.Title.Replace("'", "''");
            entry.Summary = entry.Summary.Replace("'", "''");

            using (DAC dac = new DAC())
            {
                string statement = string.Format("INSERT INTO News (Provider, Title, Url, EmailId, EmailSent) VALUES ('{0}', '{1}', '{2}', '{3}', {4});", entry.Provider, entry.Title, entry.Url, entry.EmailId, entry.EmailSent ? 1 : 0);
                dac.ExecuteCommand(statement);
            }
        }
示例#9
0
 public static string Get(string key)
 {
     try
     {
         string statement = string.Format("SELECT SettingValue FROM Settings WHERE SettingKey = '{0}';", key);
         using (DAC dac = new DAC())
         {
             return(dac.ExecuteScalar(statement).ToString());
         }
     }
     catch (Exception exception)
     {
         return(exception.Message);
     }
 }
示例#10
0
        public static List <Recipe> FetchByGroupUid(long groupUid)
        {
            List <Recipe> recipeList = new List <Recipe>();

            using (DAC dac = new DAC())
            {
                using (DbDataReader reader = dac.FetchRecords("SELECT * FROM Recipe WHERE GroupUID = " + groupUid + ";"))
                {
                    while (reader.Read())
                    {
                        recipeList.Add(Fetch(reader));
                    }
                }
            }
            return(recipeList);
        }
示例#11
0
        public static List <Position> FetchAll()
        {
            List <Position> all = new List <Position>();

            using (DAC dac = new DAC())
            {
                using (DbDataReader reader = dac.FetchRecords("SELECT * FROM Location;"))
                {
                    while (reader.Read())
                    {
                        all.Add(Fetch(reader));
                    }
                }
            }
            return(all);
        }
示例#12
0
        public static List <RecipeGroup> FetchAll()
        {
            List <RecipeGroup> all = new List <RecipeGroup>();

            using (DAC dac = new DAC())
            {
                using (DbDataReader reader = dac.FetchRecords("SELECT * FROM RecipeGroup ORDER BY UID;"))
                {
                    while (reader.Read())
                    {
                        all.Add(Fetch(reader));
                    }
                }
            }
            return(all);
        }
示例#13
0
        public static RecipeGroup FetchByUid(int uid)
        {
            RecipeGroup group = null;

            using (DAC dac = new DAC())
            {
                using (DbDataReader reader = dac.FetchRecords("SELECT * FROM RecipeGrou] WHERE UID = " + uid + ";"))
                {
                    if (reader.Read())
                    {
                        group = Fetch(reader);
                    }
                }
            }
            return(group);
        }
示例#14
0
        public static List <NewsEntry> FetchAll()
        {
            List <NewsEntry> all = new List <NewsEntry>();

            using (DAC dac = new DAC())
            {
                using (DbDataReader reader = dac.FetchRecords("SELECT * FROM News;"))
                {
                    while (reader.Read())
                    {
                        all.Add(Fetch(reader));
                    }
                }
            }
            return(all);
        }