Exemple #1
0
 public override bool CheckFavorite(PictureData data)
 {
     try
     {
         bool res = _cache.Exists(d => d.PageUrl == data.PageUrl);
         return res;
     }
     catch (Exception ex)
     {
         ExManager.Ex(ex);
         return false;
     }
 }
Exemple #2
0
 /// <summary>
 ///     path to database's location
 /// </summary>
 /// <summary>
 ///     uses default path (App data)
 /// </summary>
 public FavoritesSaver()
 {
     _currentPath = GetDefaultPath();
     try
     {
         // Get collection
         _db = new LiteDatabase(_currentPath);
         _collection = _db.GetCollection<FavoritePOCO>(CollectionName);
         FillData();
     }
     catch (Exception ex)
     {
         ExManager.Ex(ex);
     }
 }
Exemple #3
0
 public override bool Delete(PictureData data)
 {
     try
     {
         _cache.RemoveAt(_cache.FindIndex(d => d.PageUrl == data.PageUrl));
         int count = _Delete(data);
         RaiseRemovedFromFavorite(data);
         return count > 0;
     }
     catch (Exception ex)
     {
         ExManager.Ex(ex);
         return false;
     }
 }
Exemple #4
0
        //public void Dispose()
        //{
        //    db.Dispose();
        //}

        public override bool Save(PictureData data)
        {
            try
            {
                // Create new entry
                _cache.Add(data);
                var fav = new FavoritePOCO
                {
                    ScraperName = Fussy.EncryptString(data.Scraper.SiteName),
                    ThumbUrl = Fussy.EncryptString(data.ThumbUrl),
                    PageUrl = Fussy.EncryptString(data.PageUrl)
                };
                _collection.Insert(fav);
                _collection.EnsureIndex(x => x.PageUrl);
                RaiseAddedToFavorite(data);
            }
            catch (Exception ex)
            {
                ExManager.Ex(ex);
                return false;
            }
            return true;
        }
Exemple #5
0
 private void FillData()
 {
     try
     {
         foreach (var data in _collection.FindAll())
         {
             //remove invalid data
             if (!CheckValid(data))
             {
                 DeleteById(data.Id);
                 continue;
             }
             _cache.Add(new PictureData(Scraper.GetScraperByName(Fussy.DecryptString(data.ScraperName)))
             {
                 ThumbUrl = Fussy.DecryptString(data.ThumbUrl),
                 PageUrl = Fussy.DecryptString(data.PageUrl)
             });
         }
     }
     catch (Exception ex)
     {
         ExManager.Ex(ex);
     }
 }