Esempio n. 1
0
        public void DownloadAndReadMetadata(int imageId)
        {
            // Get scheduled image from db
            var image = _context.ScheduledImages.Find(imageId);

            // Download file
            var stream = _downloader.Download(image.DownloadUrl);

            // Read metadata
            var metadata = _reader.ReadFromStream(stream);

            // Save entities

            image.JobCompletedDate = DateTime.UtcNow;
            _context.MarkAsModified(image);

            metadata.ForEach(tag =>
            {
                tag.ScheduledImageId = imageId;
                _context.ImageMetadataTags.Add(tag);
            });
            _context.SaveChanges();

            // Schedule success notification
            _client.Enqueue(() => SendHttpSuccessNotification(image.Id));
        }
        private ScheduledImage SaveScheduleImageEndity(AssetApiModel assetApiModel)
        {
            var imageMetadata = new ScheduledImage()
            {
                FileName               = assetApiModel.FileName,
                DownloadUrl            = assetApiModel.Url,
                SuccessNotificationUrl = assetApiModel.SuccessNotificationUrl,
                CreatedDate            = DateTime.UtcNow
            };

            _context.ScheduledImages.Add(imageMetadata);

            _context.SaveChanges();
            return(imageMetadata);
        }