Пример #1
0
        public static async Task DeleteNicoHistory(this SQLiteControl command, string videoid)
        {
            var sql = new StringBuilder();

            sql.Clear();
            sql.AppendLine($"DELETE FROM t_nico_history WHERE video_id = ?");

            var parameters = new[]
            {
                Sqlite3Util.CreateParameter(DbType.String, videoid),
            };

            await command.ExecuteNonQueryAsync(sql.ToString(), parameters);
        }
Пример #2
0
        public static async Task MergeNicoFavorite(this SQLiteControl command, string mylistid, DateTime date)
        {
            var sql = new StringBuilder();

            sql.Clear();
            sql.AppendLine($"INSERT OR REPLACE INTO t_nico_favorite (");
            sql.AppendLine($"    mylist_id, tick");
            sql.AppendLine($")");
            sql.AppendLine($"VALUES (");
            sql.AppendLine($"    ?, ?");
            sql.AppendLine($")");

            var parameters = new[]
            {
                Sqlite3Util.CreateParameter(DbType.String, mylistid),
                Sqlite3Util.CreateParameter(DbType.Int64, date.Ticks),
            };

            await command.ExecuteNonQueryAsync(sql.ToString(), parameters);
        }
Пример #3
0
        public static async Task MergeNicoHistory(this SQLiteControl command, string videoid)
        {
            var sql = new StringBuilder();

            sql.Clear();
            sql.AppendLine($"INSERT OR REPLACE INTO t_nico_history (");
            sql.AppendLine($"    video_id, tick");
            sql.AppendLine($")");
            sql.AppendLine($"VALUES (");
            sql.AppendLine($"    ?, ?");
            sql.AppendLine($")");

            var parameters = new[]
            {
                Sqlite3Util.CreateParameter(DbType.String, videoid),
                Sqlite3Util.CreateParameter(DbType.Int64, DateTime.Now.Ticks),
            };

            await command.ExecuteNonQueryAsync(sql.ToString(), parameters);
        }
Пример #4
0
        public static async Task <TSetting> GetSetting(this IDbControl control, SettingKeys key)
        {
            var sql = new StringBuilder();

            sql.AppendLine($"SELECT cast(key as text), value");
            sql.AppendLine($"FROM   setting");
            sql.AppendLine($"WHERE  key = ?");

            using (var reader = await control.ExecuteReaderAsync(sql.ToString(), Sqlite3Util.CreateParameter(DbType.Int32, (int)key)))
            {
                if (await reader.ReadAsync())
                {
                    return(new TSetting(
                               (SettingKeys)Enum.Parse(typeof(SettingKeys), reader.GetString(0)), // key
                               reader.GetString(1)                                                // value
                               ));
                }
                else
                {
                    return(null);
                }
            }
        }