本文整理汇总了C#中JMMServer.Repositories.VideoLocalRepository.GetMostRecentlyAddedForAnime方法的典型用法代码示例。如果您正苦于以下问题:C# VideoLocalRepository.GetMostRecentlyAddedForAnime方法的具体用法?C# VideoLocalRepository.GetMostRecentlyAddedForAnime怎么用?C# VideoLocalRepository.GetMostRecentlyAddedForAnime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JMMServer.Repositories.VideoLocalRepository
的用法示例。
在下文中一共展示了VideoLocalRepository.GetMostRecentlyAddedForAnime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetEpisodesRecentlyAddedSummary
public List<Contract_AnimeEpisode> GetEpisodesRecentlyAddedSummary(int maxRecords, int jmmuserID)
{
List<Contract_AnimeEpisode> retEps = new List<Contract_AnimeEpisode>();
try
{
AnimeEpisodeRepository repEps = new AnimeEpisodeRepository();
AnimeEpisode_UserRepository repEpUser = new AnimeEpisode_UserRepository();
AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
JMMUserRepository repUsers = new JMMUserRepository();
VideoLocalRepository repVids = new VideoLocalRepository();
using (var session = JMMService.SessionFactory.OpenSession())
{
JMMUser user = repUsers.GetByID(session, jmmuserID);
if (user == null) return retEps;
DateTime start = DateTime.Now;
string sql = "Select ae.AnimeSeriesID, max(vl.DateTimeCreated) as MaxDate " +
"From VideoLocal vl " +
"INNER JOIN CrossRef_File_Episode xref ON vl.Hash = xref.Hash " +
"INNER JOIN AnimeEpisode ae ON ae.AniDB_EpisodeID = xref.EpisodeID " +
"GROUP BY ae.AnimeSeriesID " +
"ORDER BY MaxDate desc ";
ArrayList results = DatabaseHelper.GetData(sql);
TimeSpan ts2 = DateTime.Now - start; logger.Info("GetEpisodesRecentlyAddedSummary:RawData in {0} ms", ts2.TotalMilliseconds); start = DateTime.Now;
int numEps = 0;
foreach (object[] res in results)
{
int animeSeriesID = int.Parse(res[0].ToString());
AnimeSeries ser = repSeries.GetByID(session, animeSeriesID);
if (ser == null) continue;
if (!user.AllowedSeries(ser)) continue;
List<VideoLocal> vids = repVids.GetMostRecentlyAddedForAnime(session, 1, ser.AniDB_ID);
if (vids.Count == 0) continue;
List<AnimeEpisode> eps = vids[0].GetAnimeEpisodes(session);
if (eps.Count == 0) continue;
Contract_AnimeEpisode epContract = eps[0].ToContract(session, jmmuserID);
if (epContract != null)
{
retEps.Add(epContract);
numEps++;
// Lets only return the specified amount
if (retEps.Count == maxRecords)
{
ts2 = DateTime.Now - start; logger.Info("GetEpisodesRecentlyAddedSummary:Episodes in {0} ms", ts2.TotalMilliseconds); start = DateTime.Now;
return retEps;
}
}
}
ts2 = DateTime.Now - start; logger.Info("GetEpisodesRecentlyAddedSummary:Episodes in {0} ms", ts2.TotalMilliseconds); start = DateTime.Now;
}
}
catch (Exception ex)
{
logger.ErrorException(ex.ToString(), ex);
}
return retEps;
}
示例2: GetAnimeWithNewEpisodes
public List<MetroContract_Anime_Summary> GetAnimeWithNewEpisodes(int maxRecords, int jmmuserID)
{
List<MetroContract_Anime_Summary> retAnime = new List<MetroContract_Anime_Summary>();
try
{
using (var session = JMMService.SessionFactory.OpenSession())
{
AnimeEpisodeRepository repEps = new AnimeEpisodeRepository();
AnimeEpisode_UserRepository repEpUser = new AnimeEpisode_UserRepository();
AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
JMMUserRepository repUsers = new JMMUserRepository();
VideoLocalRepository repVids = new VideoLocalRepository();
JMMUser user = repUsers.GetByID(session, jmmuserID);
if (user == null) return retAnime;
string sql = "Select ae.AnimeSeriesID, max(vl.DateTimeCreated) as MaxDate " +
"From VideoLocal vl " +
"INNER JOIN CrossRef_File_Episode xref ON vl.Hash = xref.Hash " +
"INNER JOIN AnimeEpisode ae ON ae.AniDB_EpisodeID = xref.EpisodeID " +
"GROUP BY ae.AnimeSeriesID " +
"ORDER BY MaxDate desc ";
ArrayList results = DatabaseHelper.GetData(sql);
int numEps = 0;
foreach (object[] res in results)
{
int animeSeriesID = int.Parse(res[0].ToString());
AnimeSeries ser = repSeries.GetByID(session, animeSeriesID);
if (ser == null) continue;
if (!user.AllowedSeries(session, ser)) continue;
AnimeSeries_User serUser = ser.GetUserRecord(session, jmmuserID);
List<VideoLocal> vids = repVids.GetMostRecentlyAddedForAnime(session, 1, ser.AniDB_ID);
if (vids.Count == 0) continue;
List<AnimeEpisode> eps = vids[0].GetAnimeEpisodes(session);
if (eps.Count == 0) continue;
Contract_AnimeEpisode epContract = eps[0].ToContract(session, jmmuserID);
if (epContract != null)
{
AniDB_Anime anidb_anime = ser.GetAnime(session);
MetroContract_Anime_Summary summ = new MetroContract_Anime_Summary();
summ.AnimeID = ser.AniDB_ID;
summ.AnimeName = ser.GetSeriesName(session);
summ.AnimeSeriesID = ser.AnimeSeriesID;
summ.BeginYear = anidb_anime.BeginYear;
summ.EndYear = anidb_anime.EndYear;
//summ.PosterName = anidb_anime.GetDefaultPosterPathNoBlanks(session);
if (serUser != null)
summ.UnwatchedEpisodeCount = serUser.UnwatchedEpisodeCount;
else
summ.UnwatchedEpisodeCount = 0;
ImageDetails imgDet = anidb_anime.GetDefaultPosterDetailsNoBlanks(session);
summ.ImageType = (int)imgDet.ImageType;
summ.ImageID = imgDet.ImageID;
retAnime.Add(summ);
numEps++;
// Lets only return the specified amount
if (retAnime.Count == maxRecords) return retAnime;
}
}
}
}
catch (Exception ex)
{
logger.ErrorException(ex.ToString(), ex);
}
return retAnime;
}