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); } }
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; }
private CharadesEntry CreateCharadesEntry(SeriesEntry franchise) { var charadesEntry = new CharadesEntry() { Series = franchise, KnownBy = GetAllUsersForFranchise(franchise, entryProcessingStrategy.GetFranchiseIds(franchise)) }; return(charadesEntry); }
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(); }
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)); } }); }); } } }
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); }
private CharadesEntry EnsureCreateAndAddToCharades(SeriesEntry franchise) { switch (adaptationStrategy) { case AdaptationIncluding.OnlyKnownInOthers: if (entryProcessingStrategy.HasAdaptations(franchise)) { return(CreateAndAddCharadesEntry(franchise)); } return(null); default: return(CreateAndAddCharadesEntry(franchise)); } }
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); }
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); }
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); }
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(); }
public bool HasAdaptations(SeriesEntry franchise) { return(franchise.MangaPositions != null && franchise.MangaPositions.Count != 0); }
public ICollection <long> GetFranchiseIds(SeriesEntry franchise) { return(franchise.AnimePositions.Select(a => a.MalId).ToArray()); }
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)); }
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; }
public async Task Add(SeriesEntry series) { await context.Series.AddAsync(series); context.SaveChanges(); }
public SeriesTableItem(SeriesEntry entry) { _entry = entry; }
public IList<SeriesEntry> GetSeriesEntries(SeriesEntry criteria) { var series = GetSeries(criteria); return series.Select(s => s.ToStoreEntry()).ToList(); }
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 ) ); } ); } } }
public IList <SeriesEntry> GetSeriesEntries(SeriesEntry criteria) { var series = GetSeries(criteria); return(series.Select(s => s.ToStoreEntry()).ToList()); }
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); } }
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 ) ); } }); } ); } } }
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); }