Exemple #1
0
    public bool CleanupDatabase()
    {
        var users  = db.SQLQuery <T>("SELECT id FROM users WHERE moderator='0'");
        var result = false;

        for (var i = ulong.MinValue; i < (ulong)users.Count; i++)
        {
            var _i = (T)Convert.ChangeType(i, typeof(T));
            if (db.Count("sendeplan", "uid", (T)Convert.ChangeType(users[_i]["id"], typeof(T))) != 0)
            {
                result = db.SQLInsert(string.Format("DELETE FROM sendeplan WHERE uid='{0}' AND spident='{1}'", users[_i]["id"], this.spident));
            }

            if (db.Count("sendeplan_replay", "uid", (T)Convert.ChangeType(users[_i]["id"], typeof(T))) != 0)
            {
                result = db.SQLInsert(string.Format("DELETE FROM sendeplan_replay WHERE uid='{0}' AND spident='{1}'", users[_i]["id"], this.spident));
            }
        }

        if ((int)DateTime.Now.DayOfWeek == 1 && DateTime.Now.Hour == 1 && DateTime.Now.Minute < 2)
        {
            var ts = GetMonday().Subtract(new DateTime(1970, 1, 1)).TotalSeconds + settings.Start * 3600;
            result = db.SQLInsert(string.Format("DELETE FROM sendeplan WHERE timestamp < '{0}' AND spident='{1}'", ts, spident));
        }

        return(result);
    }
Exemple #2
0
        public virtual int Count()
        {
            var dbname = Provider <T> .GetName();

            var count = 0;

            using (var db = new SQLDatabase <int>(dbname))
                count = db.Count(dbname, "id");

            return(count);
        }
Exemple #3
0
		public static async Task<string> GetContentType(string path, HttpListenerContext context)
		{
			using (var db = new SQLDatabase("channels.db"))
			{
				var ext = path.Contains(".") ? path.Split('.')[1] : string.Empty;
				var ctype = string.Empty;

				if (ext.Length > 1)
					if (await db.Count("content_types", "ext", ext[1]) != 0)
					{
						ctype = await db.SQLQuery(string.Format("SELECT type FROM content_types WHERE ext='{0}'",
							string.Concat(".", ext[ext.Length - 1])), "type");

						context.Response.ContentType = ctype;
					}
			}

			return path.ToLowerInvariant();
		}