Exemplo n.º 1
0
        private IEnumerable <Series> GetSeries(SeriesEntry criteria)
        {
            try
            {
                string studyInstanceUid = null;
                if (criteria != null && criteria.Series != null)
                {
                    studyInstanceUid = criteria.Series.StudyInstanceUid;
                }

                //This will throw when Uid parameter is empty.
                IStudy study = GetStudy(studyInstanceUid);
                if (study == null)
                {
                    return(new List <Series>());
                }

                //TODO (Marmot): make extended data queryable, too.
                var dicomCriteria = criteria.Series.ToDicomAttributeCollection();
                var filters       = new SeriesPropertyFilters(dicomCriteria);
                var results       = filters.FilterResults(study.GetSeries().Cast <Series>());
                return(results);
            }
            catch (Exception e)
            {
                throw new Exception("An error occurred while performing the series query.", e);
            }
        }
Exemplo n.º 2
0
        private CharadesEntry CreateAndAddCharadesEntry(SeriesEntry franchise)
        {
            var charadesEntry = CreateCharadesEntry(franchise);

            charades.Add(charadesEntry);
            return(charadesEntry);
        }
 public SeriesEntryInformationItem(GoodreadsClient client, SeriesEntry entry, Collection collection, IProgress <string> log, TaskScheduler scheduler)
 {
     this.client     = client;
     this.entry      = entry;
     this.collection = collection;
     this.log        = log;
     this.scheduler  = scheduler;
 }
Exemplo n.º 4
0
        private CharadesEntry CreateCharadesEntry(SeriesEntry franchise)
        {
            var charadesEntry = new CharadesEntry()
            {
                Series  = franchise,
                KnownBy = GetAllUsersForFranchise(franchise, entryProcessingStrategy.GetFranchiseIds(franchise))
            };

            return(charadesEntry);
        }
Exemplo n.º 5
0
        public async Task Update(SeriesEntry series)
        {
            var dbEntry = await Get(series.Id);

            dbEntry.Title          = series.Title;
            dbEntry.AnimePositions = series.AnimePositions;
            dbEntry.MangaPositions = series.MangaPositions;
            dbEntry.Translation    = series.Translation;
            dbEntry.ImageUrl       = series.ImageUrl;
            context.Update(dbEntry);
            context.SaveChanges();
        }
Exemplo n.º 6
0
        void SetupSeriesEntries(List <Series> seriesList)
        {
            SeriesEntries.Clear( );

            for (int i = 0; i < seriesList.Count; i++)
            {
                // add the entry to our list
                SeriesEntry entry = new SeriesEntry();
                SeriesEntries.Add(entry);

                // copy over the series and give it a placeholder image
                entry.Series = seriesList[i];


                // attempt to load / download images.

                // for billboards, we ONLY CARE about loading the first series' billboard.
                if (i == 0)
                {
                    bool imageExists = TryLoadImage(ref entry.mBillboard, NotesTask.FormatBillboardImageName(entry.Series.SeriesName));
                    if (imageExists == false)
                    {
                        FileCache.Instance.DownloadFileToCache(entry.Series.BillboardUrl, NotesTask.FormatBillboardImageName(entry.Series.SeriesName), null,
                                                               delegate
                        {
                            Rock.Mobile.Threading.Util.PerformOnUIThread(delegate {
                                if (IsVisible == true)
                                {
                                    TryLoadImage(ref entry.mBillboard, NotesTask.FormatBillboardImageName(entry.Series.SeriesName));
                                }
                            });
                        });
                    }
                }

                // for everything, we care about the thumbnails
                bool thumbExists = TryLoadImage(ref entry.mThumbnail, NotesTask.FormatThumbImageName(entry.Series.SeriesName));
                if (thumbExists == false)
                {
                    FileCache.Instance.DownloadFileToCache(entry.Series.ThumbnailUrl, NotesTask.FormatThumbImageName(entry.Series.SeriesName), null,
                                                           delegate
                    {
                        Rock.Mobile.Threading.Util.PerformOnUIThread(delegate {
                            if (IsVisible == true)
                            {
                                TryLoadImage(ref entry.mThumbnail, NotesTask.FormatThumbImageName(entry.Series.SeriesName));
                            }
                        });
                    });
                }
            }
        }
Exemplo n.º 7
0
        private SeriesEntry CreateFranchise(ICollection <IEntryInstance> animes, ICollection <IEntryInstance> mangas)
        {
            var entries = animes;

            if (CollectionUtils.IsCollectionNullOrEmpty(animes))
            {
                entries = mangas;
            }
            var mainEntry  = MainEntryFinder.GetMainEntry(entries);
            var allEntries = new List <IEntryInstance>();

            allEntries.AddRange(animes);
            allEntries.AddRange(mangas);
            var mainTitle = GetMainTitle(allEntries, mainEntry);
            var series    = new SeriesEntry();

            series.AnimePositions.AddRange(animes.Select(e => new AnimeEntry()
            {
                MalId = e.Id, Title = e.Title, Series = series
            }));
            series.MangaPositions.AddRange(mangas.Select(e => new MangaEntry()
            {
                MalId = e.Id, Title = e.Title, Series = series
            }));
            series.ImageUrl    = mainEntry.ImageUrl;
            series.Title       = mainTitle;
            series.Translation = new Translation()
            {
                Japanese = mainTitle
            };
            bool isTranslationEmpty = string.IsNullOrEmpty(mainEntry.Translation);

            if (!isTranslationEmpty)
            {
                bool isTranslationEqualTitle = mainEntry.Translation.ToLower().Equals(mainTitle.ToLower());
                if (!isTranslationEqualTitle)
                {
                    series.Translation.EnglishOfficial = mainEntry.Translation;
                }
            }
            if (mainEntry.Synonyms != null && mainEntry.Synonyms.Count != 0)
            {
                var synonyms = string.Join(", ", mainEntry.Synonyms);
                if (!synonyms.ToLower().Equals(mainTitle.ToLower()))
                {
                    series.Translation.EnglishLiteral = string.Join(", ", mainEntry.Synonyms);
                }
            }
            return(series);
        }
Exemplo n.º 8
0
        private CharadesEntry EnsureCreateAndAddToCharades(SeriesEntry franchise)
        {
            switch (adaptationStrategy)
            {
            case AdaptationIncluding.OnlyKnownInOthers:
                if (entryProcessingStrategy.HasAdaptations(franchise))
                {
                    return(CreateAndAddCharadesEntry(franchise));
                }
                return(null);

            default:
                return(CreateAndAddCharadesEntry(franchise));
            }
        }
Exemplo n.º 9
0
        private ICollection <string> GetAllUsersForFranchise(SeriesEntry franchise, ICollection <long> ids)
        {
            var usernames = new List <string>();

            foreach (var id in ids)
            {
                var existingEntry = currentMergedList.FirstOrDefault(x => x.Id == id);
                if (existingEntry != null)
                {
                    var newUsers = existingEntry.Users.Where(u => !usernames.Contains(u)).ToArray();
                    newUsers.ForEach(u => usernames.Add(u));
                }
            }
            return(usernames);
        }
Exemplo n.º 10
0
        internal SeriesEntry ToStoreEntry()
        {
            var entry = new SeriesEntry
            {
                Series = new SeriesIdentifier(this)
                {
                    InstanceAvailability = "ONLINE",
                    RetrieveAE           = ServerDirectory.GetLocalServer(),
                    SpecificCharacterSet = SpecificCharacterSet
                },
                Data = new SeriesEntryData
                {
                    ScheduledDeleteTime    = GetScheduledDeleteTime(),
                    SourceAETitlesInSeries = SourceAETitlesInSeries
                }
            };

            return(entry);
        }
        public void SeriesCollectionShouldSerializeCorrectly()
        {
            // given
            var filePath = config["SeriesMockFile"];
            var series   = new SeriesEntry[]
            {
                new SeriesEntry
                {
                    AnimePositions =
                    {
                        new AnimeEntry {
                            MalId = 123, Title = "Bleach"
                        },
                        new AnimeEntry {
                            MalId = 234, Title = "Angel Beats!"
                        },
                    },
                    Id          = 12,
                    Translation = new Translation {
                        EnglishOfficial = "Bleach x AB!"
                    },
                    Title = "Bleach Beats!"
                }
            };

            // when
            Common.Serialization.SaveCollectionToJson(series, filePath);
            var json             = System.IO.File.ReadAllText(filePath);
            var seriesCollection = Common.Serialization.JsonToCollection <SeriesEntry>(json).ToArray();
            // then
            var bleachBeats = seriesCollection[0];

            Assert.Equal("Bleach Beats!", bleachBeats.Title);
            Assert.Equal("Bleach x AB!", bleachBeats.Translation.EnglishOfficial);
            Assert.Equal(123, bleachBeats.AnimePositions.First(x => x.Title == "Bleach").MalId);
            Assert.Equal("Angel Beats!", bleachBeats.AnimePositions.First(x => x.MalId == 234).Title);
        }
Exemplo n.º 12
0
        private void PrepareDateALiveFranchise(Mock <ISeriesRepository> seriesRepository)
        {
            var dateALiveFranchiseWithoutS3 = new SeriesEntry()
            {
                Title          = "Date A Live",
                AnimePositions = new List <AnimeEntry>()
                {
                    new AnimeEntry()
                    {
                        MalId = 15583, Title = "Date A Live"
                    },
                    new AnimeEntry()
                    {
                        MalId = 17641, Title = "Date A Live: Date to Date"
                    },
                    new AnimeEntry()
                    {
                        MalId = 19163, Title = "Date A Live II"
                    },
                    new AnimeEntry()
                    {
                        MalId = 22961, Title = "Date A Live: Kurumi Star Festival"
                    },
                    new AnimeEntry()
                    {
                        MalId = 24655, Title = "Date A Live: Mayuri Judgment"
                    }
                }
            };

            foreach (var dalEntryId in new[] { 15583, 17641, 19163, 22961, 24655 })
            {
                seriesRepository.Setup(r => r.GetByAnimeId(dalEntryId)).ReturnsAsync(dateALiveFranchiseWithoutS3);
                seriesRepository.Setup(r => r.SeriesExistsByAnimeId(dalEntryId)).ReturnsAsync(true);
            }
            seriesRepository.Setup(r => r.SeriesExistsByAnimeId(36633)).ReturnsAsync(false);
        }
Exemplo n.º 13
0
 public System.Collections.Generic.IList<SeriesIdentifier> SeriesQuery(SeriesIdentifier queryCriteria)
 {
     var criteria = new SeriesEntry {Series = queryCriteria};
     var result = Real.GetSeriesEntries(new GetSeriesEntriesRequest { Criteria = criteria });
     return result.SeriesEntries.Select(e => e.Series).ToList();
 }
Exemplo n.º 14
0
 public bool HasAdaptations(SeriesEntry franchise)
 {
     return(franchise.MangaPositions != null && franchise.MangaPositions.Count != 0);
 }
Exemplo n.º 15
0
 public ICollection <long> GetFranchiseIds(SeriesEntry franchise)
 {
     return(franchise.AnimePositions.Select(a => a.MalId).ToArray());
 }
Exemplo n.º 16
0
        public void AddEntryToCharadesEntry(CharadesEntry charadesEntry, IListEntry entry, SeriesEntry franchise)
        {
            charadesEntry.Series.AnimePositions.Add(new AnimeEntry()
            {
                MalId = entry.Id, Title = entry.Title, Series = charadesEntry.Series
            });
            var newUsers = entry.Users.Where(u => !charadesEntry.KnownBy.Contains(u)).ToArray();

            newUsers.ForEach(u => charadesEntry.KnownBy.Add(u));

            franchise.MangaPositions
            .Where(m => !charadesEntry.Series.MangaPositions.Any(a => a.MalId == m.MalId))
            .ForEach(m => charadesEntry.Series.MangaPositions.Add(m));
        }
Exemplo n.º 17
0
                bool TryLoadThumbImage( SeriesEntry entry, string filename )
                {
                    // does the file exist?
                    if ( FileCache.Instance.FileExists( filename ) == true )
                    {
                        AsyncLoader.LoadImage( filename, false, false,
                            delegate( Bitmap loadedBmp )
                            {
                                if ( FragmentActive == true )
                                {
                                    // if for some reason it loaded corrupt, remove it.
                                    if ( loadedBmp == null )
                                    {
                                        FileCache.Instance.RemoveFile( filename );
                                        return false;
                                    }
                                    else
                                    {
                                        if( entry.Thumbnail != null )
                                        {
                                            entry.Thumbnail.Dispose( );
                                            entry.Thumbnail = null;
                                        }

                                        entry.Thumbnail = loadedBmp;

                                        RefreshList( );

                                        return true;
                                    }
                                }

                                return false;
                            } );

                        return true;
                    }

                    return false;
                }
Exemplo n.º 18
0
        public async Task Add(SeriesEntry series)
        {
            await context.Series.AddAsync(series);

            context.SaveChanges();
        }
Exemplo n.º 19
0
 public SeriesTableItem(SeriesEntry entry)
 {
     _entry = entry;
 }
Exemplo n.º 20
0
 public IList<SeriesEntry> GetSeriesEntries(SeriesEntry criteria)
 {
     var series = GetSeries(criteria);
     return series.Select(s => s.ToStoreEntry()).ToList();
 }
Exemplo n.º 21
0
                void SetupSeriesEntries( List<Series> seriesList )
                {
                    SeriesEntries.Clear( );

                    for( int i = 0; i < seriesList.Count; i++ )
                    {
                        // add the entry to our list
                        SeriesEntry entry = new SeriesEntry();
                        SeriesEntries.Add( entry );

                        // copy over the series and give it a placeholder image
                        entry.Series = seriesList[ i ];


                        // attempt to load / download images.
                        //string widthParam = string.Format( "&width={0}", NavbarFragment.GetContainerDisplayWidth_Landscape( ) );

                        // for billboards, we ONLY CARE about loading the first series' billboard.
                        if ( i == 0 )
                        {
                            bool imageExists = TryLoadBillboardImage( entry, NotesTask.FormatBillboardImageName( entry.Series.Name ) );
                            if ( imageExists == false )
                            {
                                FileCache.Instance.DownloadFileToCache( entry.Series.BillboardUrl, NotesTask.FormatBillboardImageName( entry.Series.Name ), delegate
                                    {
                                        TryLoadBillboardImage( entry, NotesTask.FormatBillboardImageName( entry.Series.Name ) );
                                    } );
                            }
                        }

                        // for everything, we care about the thumbnails
                        bool thumbExists = TryLoadThumbImage( entry, NotesTask.FormatThumbImageName( entry.Series.Name ) );
                        if ( thumbExists == false )
                        {
                            FileCache.Instance.DownloadFileToCache( entry.Series.ThumbnailUrl, NotesTask.FormatThumbImageName( entry.Series.Name ), delegate
                                {
                                    TryLoadThumbImage( entry, NotesTask.FormatThumbImageName( entry.Series.Name ) );
                                } );
                        }
                    }
                }
Exemplo n.º 22
0
 public SeriesTableItem(SeriesEntry entry)
 {
     _entry = entry;
 }
Exemplo n.º 23
0
        public IList <SeriesEntry> GetSeriesEntries(SeriesEntry criteria)
        {
            var series = GetSeries(criteria);

            return(series.Select(s => s.ToStoreEntry()).ToList());
        }
Exemplo n.º 24
0
        private IEnumerable<Series> GetSeries(SeriesEntry criteria)
        {
            try
            {
                string studyInstanceUid = null;
                if (criteria != null && criteria.Series != null)
                    studyInstanceUid = criteria.Series.StudyInstanceUid;

                //This will throw when Uid parameter is empty.
                IStudy study = GetStudy(studyInstanceUid);
                if (study == null)
                    return new List<Series>();
                
                //TODO (Marmot): make extended data queryable, too.
                var dicomCriteria = criteria.Series.ToDicomAttributeCollection();
                var filters = new SeriesPropertyFilters(dicomCriteria);
                var results = filters.FilterResults(study.GetSeries().Cast<Series>());
                return results;
            }
            catch (Exception e)
            {
                throw new Exception("An error occurred while performing the series query.", e);
            }
        }
Exemplo n.º 25
0
	    internal SeriesEntry ToStoreEntry()
        {
            var entry = new SeriesEntry
            {
                Series = new SeriesIdentifier(this)
                {
                    InstanceAvailability = "ONLINE",
                    RetrieveAE = ServerDirectory.GetLocalServer(),
                    SpecificCharacterSet = SpecificCharacterSet
                },
                Data = new SeriesEntryData
                {
                    ScheduledDeleteTime = GetScheduledDeleteTime(),
                    SourceAETitlesInSeries = SourceAETitlesInSeries
                }
            };
            return entry;
        }
        void SetupSeriesEntries( List<Series> seriesList )
        {
            SeriesEntries.Clear( );

            for( int i = 0; i < seriesList.Count; i++ )
            {
                // add the entry to our list
                SeriesEntry entry = new SeriesEntry();
                SeriesEntries.Add( entry );

                // copy over the series and give it a placeholder image
                entry.Series = seriesList[ i ];


                // attempt to load / download images.

                // for billboards, we ONLY CARE about loading the first series' billboard.
                if ( i == 0 )
                {
                    bool imageExists = TryLoadImage( ref entry.mBillboard, NotesTask.FormatBillboardImageName( entry.Series.Name ) );
                    if ( imageExists == false )
                    {
                        FileCache.Instance.DownloadFileToCache( entry.Series.BillboardUrl, NotesTask.FormatBillboardImageName( entry.Series.Name ), 
                            delegate
                            {
                                Rock.Mobile.Threading.Util.PerformOnUIThread( delegate {
                                    if( IsVisible == true )
                                    {
                                        TryLoadImage( ref entry.mBillboard, NotesTask.FormatBillboardImageName( entry.Series.Name ) );
                                    }
                                });
                            } );
                    }
                }

                // for everything, we care about the thumbnails
                bool thumbExists = TryLoadImage( ref entry.mThumbnail, NotesTask.FormatThumbImageName( entry.Series.Name ) );
                if ( thumbExists == false )
                {
                    FileCache.Instance.DownloadFileToCache( entry.Series.ThumbnailUrl, NotesTask.FormatThumbImageName( entry.Series.Name ), delegate
                        {
                            Rock.Mobile.Threading.Util.PerformOnUIThread( delegate {
                                if( IsVisible == true )
                                {
                                    TryLoadImage( ref entry.mThumbnail, NotesTask.FormatThumbImageName( entry.Series.Name ) );
                                }
                            });
                        } );
                }
            }
        }
Exemplo n.º 27
0
        public CharadesEntry GetIndirectExistingRelation(ICollection <CharadesEntry> charades, SeriesEntry franchise)
        {
            var indirectExistingRelation = charades
                                           .FirstOrDefault(c =>
            {
                bool hasAnime = c.Series.AnimePositions != null && c.Series.AnimePositions.Any(a => franchise.AnimePositions.Any(f => f.MalId == a.MalId));
                if (hasAnime)
                {
                    return(true);
                }
                bool hasManga = c.Series.MangaPositions != null && c.Series.MangaPositions.Any(a => franchise.MangaPositions.Any(f => f.MalId == a.MalId));
                return(hasManga);
            });

            return(indirectExistingRelation);
        }