Exemple #1
0
        public DBModule() : base("/DB")
        {
            Get["/latest/{count}/{page}"] = p =>
            {
                return(Response.AsHTML(RinDB.GetLatest((int)p.count, (int)p.page)));
            };

            Get["/search/{query}/{count}/{page}"] = p =>
            {
                return(Response.AsHTML(RinDB.GetSearch((string)p.query, (int)p.count, (int)p.page)));
            };

            Get["/tags/description/{tag}"] = p =>
            {
                return(RinDB.GetTag(((string)p.tag).ToBase60()).description);
            };
        }
Exemple #2
0
 public ImageModule() : base("/image")
 {
     Get["/dl/{id}"] = p =>
     {
         ImageModel img = RinDB.GetImage((string)p.id);
         if (img == null)
         {
             return($"{(string)p.id} Not found");
         }
         else
         {
             return(Response.FromImage(img.fileUri));
         }
     };
     Get["/thumb/{id}"] = p =>
     {
         ImageModel img = RinDB.GetImage((string)p.id);
         if (img == null)
         {
             return($"{(string)p.id} Not found");
         }
         else
         {
             return(GetOrGenerateThumb(img));
         }
     };
     Get["/{id}"] = p =>
     {
         ImageModel img = RinDB.GetImage((string)p.id);
         if (img == null)
         {
             return($"{(string)p.id} Not Found");
         }
         else
         {
             return(View["image", new { img = img, user = UserStateModel.DEFAULT }]);
         }
     };
 }
 internal static void Start()
 {
     StartTimer("RinDB.DatabaseQueue", i =>
     {
         if (_IS_RUNNING)
         {
             return;
         }
         if (_DB_UPDATE_QUEUE.Count == 0)
         {
             return;
         }
         if (_CONNECTION == null)
         {
             _CONNECTION = RinDB.GetConnection();
             _CONNECTION.Open();
             _COMMAND = _CONNECTION.CreateCommand();
         }
         //_CONNECTION.Open();
         _IS_RUNNING  = true;
         string query = "";
         while (_DB_UPDATE_QUEUE.Count != 0 && query.Length <= 5000)
         {
             query += $"{_DB_UPDATE_QUEUE.Dequeue()};";
             COMPLEDTED_COUNT++;
         }
         _COMMAND.CommandText = query;
         _COMMAND.ExecuteNonQuery();
         if (!_JOB_DONE && _DB_UPDATE_QUEUE.Count == 0)
         {
             _JOB_DONE = true;
             Write("DB Updates Done!");
         }
         _IS_RUNNING = false;
     }, 0, 500);
 }
Exemple #4
0
 public List <TagModel> GetTags() => RinDB.GetTags(id);
Exemple #5
0
 public bool HasTag(TagModel tag) => RinDB.HasTag(id, tag.id);
Exemple #6
0
 public bool HasTag(string tagid) => RinDB.HasTag(id, tagid);
Exemple #7
0
 public ImageModel AddTag(TagModel tag)
 {
     RinDB.AddTag(id, tag.id);
     return(this);
 }
Exemple #8
0
 public ImageModel AddTag(string tagID)
 {
     RinDB.AddTag(id, tagID);
     return(this);
 }