Example #1
0
        public void SynchronizeWithServiceDB()
        {
            if (!InternetService.IsInternetConnected())
            {
                return;
            }

            try
            {
                List <PhotoItem> photos = new List <PhotoItem>();
                foreach (PhotoItem item in GetImagesFromServiceDB())
                {
                    photos.Add(item);
                }

                DeletePhotosFromServiceDB(photos);

                ImageDatabaseService imgDbService = new ImageDatabaseService();
                foreach (ImageModel image in ImageHelperService.ParsePhotoItemsToImageModels(photos))
                {
                    image.IsProcessed = false;
                    imgDbService.SaveImageToDatabase(image);
                }
            }
            catch (Exception)
            {
                throw new Exception("Cannot synch with service DB");
            }
        }
Example #2
0
        private IEnumerable <string> GetImagesFromFolder(string folderPath)
        {
            HashSet <string> imageFiles = new HashSet <string>();

            foreach (string file in Directory.EnumerateFiles(folderPath))
            {
                if (ImageHelperService.IsImageFile(file))
                {
                    imageFiles.Add(file);
                }
            }

            return(imageFiles);
        }