private void ProcessUpdatedExhibits(IProgressListener listener, FetchedMediaData fetchedMedia, ITransactionDataAccess dataAccess)
        {
            var exhibits = dataAccess.Exhibits().GetExhibits().ToDictionary(x => x.IdForRestApi);

            foreach (var exhibitDto in updatedExhibits)
            {
                var dbExhibit = exhibits[exhibitDto.Id];

                ExhibitConverter.Convert(exhibitDto, dbExhibit);

                AddImageToExhibit(dbExhibit, exhibitDto.Image, fetchedMedia);
                //TODO: Check if exhibit was already downloaded
                //if(dbExhibit.DetailsDataLoaded)
                //{
                //    IoCManager.Resolve<INewDataCenter>().AddExhibitToBeUpdated(dbExhibit);
                //}

                var removedPages = dbExhibit.Pages.Where(x => !exhibitDto.Pages.Contains(x.IdForRestApi));
                foreach (var page in removedPages)
                {
                    dbExhibit.Pages.Remove(page);
                }

                listener.ProgressOneStep();
            }
        }
        private void ProcessNewExhibits(IProgressListener listener, FetchedMediaData fetchedMedia, ITransactionDataAccess dataAccess)
        {
            foreach (var exhibitDto in newExhibits)
            {
                var dbExhibit = ExhibitConverter.Convert(exhibitDto);

                AddImageToExhibit(dbExhibit, exhibitDto.Image, fetchedMedia);
                dataAccess.Exhibits().AddExhibit(dbExhibit);
                listener.ProgressOneStep();
            }
        }
Exemple #3
0
        private void ProcessNewRoutes(IProgressListener listener, ITransactionDataAccess dataAccess)
        {
            foreach (var routeDto in newRoutes)
            {
                var dbRoute = RouteConverter.Convert(routeDto);

                AddImageToRoute(dbRoute, routeDto.Image, fetchedMedia);
                AddTagsToRoute(dbRoute, routeDto, fetchedMedia);
                AddExhibitsToRoute(dbRoute, routeDto, dataAccess);

                dataAccess.Routes().AddRoute(dbRoute);
                listener.ProgressOneStep();
            }
        }
Exemple #4
0
        private void ProcessUpdatedRoutes(IProgressListener listener, ITransactionDataAccess dataAccess)
        {
            var routes = dataAccess.Routes().GetRoutes().ToList();

            foreach (var routeDto in updatedRoutes)
            {
                var dbRoute = routes.First(x => x.IdForRestApi == routeDto.Id);

                RouteConverter.Convert(routeDto, dbRoute);

                AddImageToRoute(dbRoute, routeDto.Image, fetchedMedia);
                AddTagsToRoute(dbRoute, routeDto, fetchedMedia);
                AddExhibitsToRoute(dbRoute, routeDto, dataAccess);

                if (dbRoute.DetailsDataLoaded)
                {
                    IoCManager.Resolve <INewDataCenter>().AddRouteToBeUpdated(dbRoute);
                }

                listener.ProgressOneStep();
            }
        }
Exemple #5
0
        private async Task <IList <FileDto> > FetchFileDtos(IList <MediaDto> mediaDtos, CancellationToken token, [CanBeNull] IProgressListener progressListener)
        {
            var fileManager = IoCManager.Resolve <IMediaFileManager>();
            var files       = new List <FileDto>();

            foreach (var mediaDto in mediaDtos)
            {
                if (token.IsCancellationRequested)
                {
                    break;
                }

                var mediaId        = mediaDto.Id;
                var mediaTimestamp = mediaDto.Timestamp;
                if (await fileManager.ContainsMedia(mediaId, mediaTimestamp))
                {
                    Debug.WriteLine($"Skipped download of already present file with id {mediaId}");
                    continue;
                }

                FileDto file;
                try
                {
                    file = await fileApiAccess.GetFile(mediaId);
                }
                catch (NotFoundException)
                {
                    file = new FileDto {
                        Data = BackupData.BackupImageData, MediaId = mediaId
                    };
                }

                files.Add(file);
                progressListener?.ProgressOneStep();
            }

            return(files);
        }