Exemple #1
0
 private void ClearItem(Guid Id)
 {
     lock ( ImgThumbs )
     {
         IIllusUpdate Item = ImgThumbs.FirstOrDefault(x => x.ImgThumb.Id.Equals(Id));
         if (Item != null)
         {
             Item.Update();
             ImgThumbs.Remove(Item);
         }
     }
 }
Exemple #2
0
        public async void RegisterImage(IIllusUpdate Item)
        {
            lock ( ImgThumbs )
            {
                if (ImgThumbs.Contains(Item))
                {
                    return;
                }
                ImgThumbs.Add(Item);
            }

            ImageThumb Thumb;

            if (Item.ImgThumb == null)
            {
                string url = Item.SrcUrl;

                // Use filename as <id>.<format> since format maybe <id>.png or <id>.jpg
                string fileName      = url.Substring(url.LastIndexOf('/') + 1);
                string imageLocation = FileLinks.ROOT_IMAGE + fileName;

                Thumb           = new ImageThumb(imageLocation, 200, null);
                Thumb.Reference = url;

                Item.ImgThumb = Thumb;
            }
            else
            {
                Thumb = Item.ImgThumb;
            }

            await Thumb.Set();

            if (Thumb.IsDownloadNeeded)
            {
                Guid G = await Transfer.RegisterImage(Thumb.Reference, Thumb.Location);

                Thumb.Id = G;
            }
            else
            {
                lock (ImgThumbs) ImgThumbs.Remove(Item);
                Item.Update();
            }
        }