本文整理汇总了C#中JMMServer.Repositories.AnimeSeriesRepository.GetByID方法的典型用法代码示例。如果您正苦于以下问题:C# AnimeSeriesRepository.GetByID方法的具体用法?C# AnimeSeriesRepository.GetByID怎么用?C# AnimeSeriesRepository.GetByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JMMServer.Repositories.AnimeSeriesRepository
的用法示例。
在下文中一共展示了AnimeSeriesRepository.GetByID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPosterFilenames
private List<string> GetPosterFilenames(ISession session)
{
List<string> allPosters = new List<string>();
// check if user has specied a fanart to always be used
if (DefaultAnimeSeriesID.HasValue)
{
AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
AnimeSeries defaultSeries = repSeries.GetByID(session, DefaultAnimeSeriesID.Value);
if (defaultSeries != null)
{
AniDB_Anime anime = defaultSeries.GetAnime(session);
string defPosterPathNoBlanks = anime.GetDefaultPosterPathNoBlanks(session);
if (!string.IsNullOrEmpty(defPosterPathNoBlanks) && File.Exists(defPosterPathNoBlanks))
{
allPosters.Add(defPosterPathNoBlanks);
return allPosters;
}
}
}
foreach (AnimeSeries ser in GetAllSeries(session))
{
AniDB_Anime anime = ser.GetAnime(session);
string defPosterPathNoBlanks = anime.GetDefaultPosterPathNoBlanks(session);
if (!string.IsNullOrEmpty(defPosterPathNoBlanks) && File.Exists(defPosterPathNoBlanks))
allPosters.Add(defPosterPathNoBlanks);
}
return allPosters;
}
示例2: ProcessCommand
public override void ProcessCommand()
{
logger.Info("Processing CommandRequest_TraktSyncCollectionSeries");
try
{
AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
AnimeSeries series = repSeries.GetByID(AnimeSeriesID);
if (series == null)
{
logger.Error("Could not find anime series: {0}", AnimeSeriesID);
return;
}
TraktTVHelper.SyncCollectionToTrakt_Series(series);
}
catch (Exception ex)
{
logger.Error("Error processing CommandRequest_TraktSyncCollectionSeries: {0}", ex.ToString());
return;
}
}
示例3: 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;
}
示例4: GetEpisodesForSeriesOld
public List<Contract_AnimeEpisode> GetEpisodesForSeriesOld(int animeSeriesID)
{
List<Contract_AnimeEpisode> eps = new List<Contract_AnimeEpisode>();
try
{
DateTime start = DateTime.Now;
AnimeEpisodeRepository repEps = new AnimeEpisodeRepository();
AnimeSeriesRepository repAnimeSer = new AnimeSeriesRepository();
CrossRef_File_EpisodeRepository repCrossRefs = new CrossRef_File_EpisodeRepository();
// get all the data first
// we do this to reduce the amount of database calls, which makes it a lot faster
AnimeSeries series = repAnimeSer.GetByID(animeSeriesID);
if (series == null) return eps;
List<AnimeEpisode> epList = repEps.GetBySeriesID(animeSeriesID);
AniDB_EpisodeRepository repAniEps = new AniDB_EpisodeRepository();
List<AniDB_Episode> aniEpList = repAniEps.GetByAnimeID(series.AniDB_ID);
Dictionary<int, AniDB_Episode> dictAniEps = new Dictionary<int, AniDB_Episode>();
foreach (AniDB_Episode aniep in aniEpList)
dictAniEps[aniep.EpisodeID] = aniep;
List<CrossRef_File_Episode> crossRefList = repCrossRefs.GetByAnimeID(series.AniDB_ID);
TimeSpan ts = DateTime.Now - start;
logger.Info("GetEpisodesForSeries: {0} (Database) in {1} ms", series.GetAnime().MainTitle, ts.TotalMilliseconds);
start = DateTime.Now;
foreach (AnimeEpisode ep in epList)
{
List<CrossRef_File_Episode> xrefs = new List<CrossRef_File_Episode>();
foreach (CrossRef_File_Episode xref in crossRefList)
{
if (ep.AniDB_EpisodeID == xref.EpisodeID)
xrefs.Add(xref);
}
if (dictAniEps.ContainsKey(ep.AniDB_EpisodeID))
eps.Add(ep.ToContractOld(dictAniEps[ep.AniDB_EpisodeID]));
}
ts = DateTime.Now - start;
logger.Info("GetEpisodesForSeries: {0} (Contracts) in {1} ms", series.GetAnime().MainTitle, ts.TotalMilliseconds);
}
catch (Exception ex)
{
logger.ErrorException(ex.ToString(), ex);
}
return eps;
}
示例5: VoteAnime
public void VoteAnime(string userid, string seriesid, string votevalue, string votetype)
{
int serid = 0;
int usid = 0;
int vt = 0;
double vvalue = 0;
if (!int.TryParse(seriesid, out serid))
return;
if (!int.TryParse(userid, out usid))
return;
if (!int.TryParse(votetype, out vt))
return;
if (!double.TryParse(votevalue, NumberStyles.Any, CultureInfo.InvariantCulture, out vvalue))
return;
using (var session = JMMService.SessionFactory.OpenSession())
{
AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
AnimeSeries ser = repSeries.GetByID(session, serid);
AniDB_Anime anime = ser?.GetAnime();
if (anime == null)
return;
string msg = string.Format("Voting for anime: {0} - Value: {1}", anime.AnimeID, vvalue);
logger.Info(msg);
// lets save to the database and assume it will work
AniDB_VoteRepository repVotes = new AniDB_VoteRepository();
List<AniDB_Vote> dbVotes = repVotes.GetByEntity(anime.AnimeID);
AniDB_Vote thisVote = null;
foreach (AniDB_Vote dbVote in dbVotes)
{
// we can only have anime permanent or anime temp but not both
if (vt == (int) enAniDBVoteType.Anime || vt == (int) enAniDBVoteType.AnimeTemp)
{
if (dbVote.VoteType == (int) enAniDBVoteType.Anime ||
dbVote.VoteType == (int) enAniDBVoteType.AnimeTemp)
{
thisVote = dbVote;
}
}
else
{
thisVote = dbVote;
}
}
if (thisVote == null)
{
thisVote = new AniDB_Vote();
thisVote.EntityID = anime.AnimeID;
}
thisVote.VoteType = vt;
int iVoteValue = 0;
if (vvalue > 0)
iVoteValue = (int) (vvalue*100);
else
iVoteValue = (int) vvalue;
msg = string.Format("Voting for anime Formatted: {0} - Value: {1}", anime.AnimeID, iVoteValue);
logger.Info(msg);
thisVote.VoteValue = iVoteValue;
repVotes.Save(thisVote);
CommandRequest_VoteAnime cmdVote = new CommandRequest_VoteAnime(anime.AnimeID, vt, Convert.ToDecimal(vvalue));
cmdVote.Save();
}
}
示例6: SaveSeries
public Contract_AnimeSeries_SaveResponse SaveSeries(Contract_AnimeSeries_Save contract, int userID)
{
Contract_AnimeSeries_SaveResponse contractout = new Contract_AnimeSeries_SaveResponse();
contractout.ErrorMessage = "";
contractout.AnimeSeries = null;
try
{
AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
AnimeSeries ser = null;
int? oldGroupID = null;
if (contract.AnimeSeriesID.HasValue)
{
ser = repSeries.GetByID(contract.AnimeSeriesID.Value);
if (ser == null)
{
contractout.ErrorMessage = "Could not find existing series with ID: " + contract.AnimeSeriesID.Value.ToString();
return contractout;
}
// check if we are moving a series
oldGroupID = ser.AnimeGroupID;
}
else
{
ser = new AnimeSeries();
ser.DateTimeCreated = DateTime.Now;
ser.DefaultAudioLanguage = "";
ser.DefaultSubtitleLanguage = "";
ser.MissingEpisodeCount = 0;
ser.MissingEpisodeCountGroups = 0;
ser.LatestLocalEpisodeNumber = 0;
ser.SeriesNameOverride = "";
}
ser.AnimeGroupID = contract.AnimeGroupID;
ser.AniDB_ID = contract.AniDB_ID;
ser.DefaultAudioLanguage = contract.DefaultAudioLanguage;
ser.DefaultSubtitleLanguage = contract.DefaultSubtitleLanguage;
ser.DateTimeUpdated = DateTime.Now;
ser.SeriesNameOverride = contract.SeriesNameOverride;
ser.DefaultFolder = contract.DefaultFolder;
AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
AniDB_Anime anime = repAnime.GetByAnimeID(ser.AniDB_ID);
if (anime == null)
{
contractout.ErrorMessage = string.Format("Could not find anime record with ID: {0}", ser.AniDB_ID);
return contractout;
}
repSeries.Save(ser);
// update stats for groups
//ser.TopLevelAnimeGroup.UpdateStatsFromTopLevel(true ,true, true);
ser.QueueUpdateStats();
if (oldGroupID.HasValue)
{
AnimeGroupRepository repGroups = new AnimeGroupRepository();
AnimeGroup grp = repGroups.GetByID(oldGroupID.Value);
if (grp != null)
{
grp.TopLevelAnimeGroup.UpdateStatsFromTopLevel(true, true, true);
}
}
List<CrossRef_AniDB_TvDBV2> xrefs = ser.GetCrossRefTvDBV2();
List<CrossRef_AniDB_MAL> xrefMAL = ser.CrossRefMAL;
List<TvDB_Series> sers = new List<TvDB_Series>();
foreach (CrossRef_AniDB_TvDBV2 xref in xrefs)
sers.Add(xref.GetTvDBSeries());
CrossRef_AniDB_Other xrefMovie = ser.CrossRefMovieDB;
MovieDB_Movie movie = null;
if (xrefMovie != null)
movie = xrefMovie.GetMovieDB_Movie();
contractout.AnimeSeries = ser.ToContract(anime, xrefs, ser.CrossRefMovieDB, ser.GetUserRecord(userID),
sers, xrefMAL, false, null, null, null, null,movie);
return contractout;
}
catch (Exception ex)
{
logger.ErrorException(ex.ToString(), ex);
contractout.ErrorMessage = ex.Message;
return contractout;
}
}
示例7: MoveSeries
public Contract_AnimeSeries_SaveResponse MoveSeries(int animeSeriesID, int newAnimeGroupID, int userID)
{
Contract_AnimeSeries_SaveResponse contractout = new Contract_AnimeSeries_SaveResponse();
contractout.ErrorMessage = "";
contractout.AnimeSeries = null;
try
{
AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
AnimeSeries ser = null;
ser = repSeries.GetByID(animeSeriesID);
if (ser == null)
{
contractout.ErrorMessage = "Could not find existing series with ID: " + animeSeriesID.ToString();
return contractout;
}
// make sure the group exists
AnimeGroupRepository repGroups = new AnimeGroupRepository();
AnimeGroup grpTemp = repGroups.GetByID(newAnimeGroupID);
if (grpTemp == null)
{
contractout.ErrorMessage = "Could not find existing group with ID: " + newAnimeGroupID.ToString();
return contractout;
}
int oldGroupID = ser.AnimeGroupID;
ser.AnimeGroupID = newAnimeGroupID;
ser.DateTimeUpdated = DateTime.Now;
repSeries.Save(ser);
// update stats for new groups
//ser.TopLevelAnimeGroup.UpdateStatsFromTopLevel(true, true, true);
ser.QueueUpdateStats();
// update stats for old groups
AnimeGroup grp = repGroups.GetByID(oldGroupID);
if (grp != null)
{
grp.TopLevelAnimeGroup.UpdateStatsFromTopLevel(true, true, true);
}
AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
AniDB_Anime anime = repAnime.GetByAnimeID(ser.AniDB_ID);
if (anime == null)
{
contractout.ErrorMessage = string.Format("Could not find anime record with ID: {0}", ser.AniDB_ID);
return contractout;
}
List<CrossRef_AniDB_TvDBV2> xrefs = ser.GetCrossRefTvDBV2();
List<CrossRef_AniDB_MAL> xrefMAL = ser.CrossRefMAL;
List<TvDB_Series> sers = new List<TvDB_Series>();
foreach (CrossRef_AniDB_TvDBV2 xref in xrefs)
sers.Add(xref.GetTvDBSeries());
CrossRef_AniDB_Other xrefMovie = ser.CrossRefMovieDB;
MovieDB_Movie movie=null;
if (xrefMovie != null)
movie = xrefMovie.GetMovieDB_Movie();
contractout.AnimeSeries = ser.ToContract(anime, xrefs, xrefMovie,
ser.GetUserRecord(userID), sers, xrefMAL, false, null, null, null, null,movie);
return contractout;
}
catch (Exception ex)
{
logger.ErrorException(ex.ToString(), ex);
contractout.ErrorMessage = ex.Message;
return contractout;
}
}
示例8: GetTopLevelGroupForSeries
public Contract_AnimeGroup GetTopLevelGroupForSeries(int animeSeriesID, int userID)
{
try
{
AnimeGroupRepository repGroups = new AnimeGroupRepository();
AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
AnimeSeries ser = repSeries.GetByID(animeSeriesID);
if (ser == null) return null;
AnimeGroup grp = ser.TopLevelAnimeGroup;
if (grp == null) return null;
return grp.ToContract(grp.GetUserRecord(userID));
}
catch (Exception ex)
{
logger.ErrorException(ex.ToString(), ex);
}
return null;
}
示例9: GetPreviousEpisodeForUnwatched
/// <summary>
/// Finds the previous episode for use int the next unwatched episode
/// </summary>
/// <param name="animeSeriesID"></param>
/// <param name="userID"></param>
/// <returns></returns>
public Contract_AnimeEpisode GetPreviousEpisodeForUnwatched(int animeSeriesID, int userID)
{
try
{
Contract_AnimeEpisode nextEp = GetNextUnwatchedEpisode(animeSeriesID, userID);
if (nextEp == null) return null;
int epType = nextEp.EpisodeType;
int epNum = nextEp.EpisodeNumber - 1;
if (epNum <= 0) return null;
AniDB_EpisodeRepository repAniEps = new AniDB_EpisodeRepository();
AnimeSeriesRepository repAnimeSer = new AnimeSeriesRepository();
AnimeSeries series = repAnimeSer.GetByID(animeSeriesID);
if (series == null) return null;
List<AniDB_Episode> anieps = repAniEps.GetByAnimeIDAndEpisodeTypeNumber(series.AniDB_ID, (enEpisodeType)epType, epNum);
if (anieps.Count == 0) return null;
AnimeEpisodeRepository repEps = new AnimeEpisodeRepository();
AnimeEpisode ep = repEps.GetByAniDBEpisodeID(anieps[0].EpisodeID);
if (ep == null) return null;
return ep.ToContract(true, userID, null);
}
catch (Exception ex)
{
logger.ErrorException(ex.ToString(), ex);
return null;
}
}
示例10: 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;
}
示例11: GetAnimeSeries
public AnimeSeries GetAnimeSeries(ISession session)
{
AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
return repSeries.GetByID(session, this.AnimeSeriesID);
}
示例12: UpdateUsingSeries
public void UpdateUsingSeries(ISession session, int animeSeriesID)
{
try
{
DateTime start = DateTime.Now;
AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
AnimeSeries ser = repSeries.GetByID(session, animeSeriesID);
if (ser == null) return;
foreach (AnimeGroup grp in ser.AllGroupsAbove)
{
UpdateUsingGroup(session, grp.AnimeGroupID);
}
TimeSpan ts = DateTime.Now - start;
logger.Info("Updated cached stats series ({0}) in {1} ms", ser.GetAnime().MainTitle, ts.TotalMilliseconds);
}
catch (Exception ex)
{
logger.ErrorException(ex.ToString(), ex);
}
}
示例13: VoteAnime
public System.IO.Stream VoteAnime(string userid, string objectid, string votevalue, string votetype)
{
Respond rsp = new Respond();
rsp.code = 500;
int objid = 0;
int usid = 0;
int vt = 0;
double vvalue = 0;
if (!int.TryParse(objectid, out objid))
return KodiHelper.GetStreamFromXmlObject(rsp);
if (!int.TryParse(userid, out usid))
return KodiHelper.GetStreamFromXmlObject(rsp);
if (!int.TryParse(votetype, out vt))
return KodiHelper.GetStreamFromXmlObject(rsp);
if (!double.TryParse(votevalue, NumberStyles.Any, CultureInfo.InvariantCulture, out vvalue))
return KodiHelper.GetStreamFromXmlObject(rsp);
using (var session = JMMService.SessionFactory.OpenSession())
{
if (vt == (int)enAniDBVoteType.Episode)
{
AnimeEpisodeRepository repEpisodes = new AnimeEpisodeRepository();
AnimeEpisode ep = repEpisodes.GetByID(session, objid);
AniDB_Anime anime = ep.GetAnimeSeries().GetAnime();
if (anime == null)
{
rsp.code = 404;
return KodiHelper.GetStreamFromXmlObject(rsp);
}
string msg = string.Format("Voting for anime episode: {0} - Value: {1}", ep.AnimeEpisodeID, vvalue);
logger.Info(msg);
// lets save to the database and assume it will work
AniDB_VoteRepository repVotes = new AniDB_VoteRepository();
List<AniDB_Vote> dbVotes = repVotes.GetByEntity(ep.AnimeEpisodeID);
AniDB_Vote thisVote = null;
foreach (AniDB_Vote dbVote in dbVotes)
{
if (dbVote.VoteType == (int)enAniDBVoteType.Episode)
{
thisVote = dbVote;
}
}
if (thisVote == null)
{
thisVote = new AniDB_Vote();
thisVote.EntityID = ep.AnimeEpisodeID;
}
thisVote.VoteType = vt;
int iVoteValue = 0;
if (vvalue > 0)
iVoteValue = (int)(vvalue * 100);
else
iVoteValue = (int)vvalue;
msg = string.Format("Voting for anime episode Formatted: {0} - Value: {1}", ep.AnimeEpisodeID, iVoteValue);
logger.Info(msg);
thisVote.VoteValue = iVoteValue;
repVotes.Save(thisVote);
CommandRequest_VoteAnime cmdVote = new CommandRequest_VoteAnime(anime.AnimeID, vt, Convert.ToDecimal(vvalue));
cmdVote.Save();
}
if (vt == (int)enAniDBVoteType.Anime)
{
AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
AnimeSeries ser = repSeries.GetByID(session, objid);
AniDB_Anime anime = ser.GetAnime();
if (anime == null)
{
rsp.code = 404;
return KodiHelper.GetStreamFromXmlObject(rsp);
}
string msg = string.Format("Voting for anime: {0} - Value: {1}", anime.AnimeID, vvalue);
logger.Info(msg);
// lets save to the database and assume it will work
AniDB_VoteRepository repVotes = new AniDB_VoteRepository();
List<AniDB_Vote> dbVotes = repVotes.GetByEntity(anime.AnimeID);
AniDB_Vote thisVote = null;
foreach (AniDB_Vote dbVote in dbVotes)
{
// we can only have anime permanent or anime temp but not both
if (vt == (int)enAniDBVoteType.Anime || vt == (int)enAniDBVoteType.AnimeTemp)
{
if (dbVote.VoteType == (int)enAniDBVoteType.Anime ||
dbVote.VoteType == (int)enAniDBVoteType.AnimeTemp)
{
thisVote = dbVote;
}
}
else
{
thisVote = dbVote;
}
}
if (thisVote == null)
//.........这里部分代码省略.........
示例14: GetItemsFromSerie
public System.IO.Stream GetItemsFromSerie(int userid, string SerieId)
{
KodiObject ret = new KodiObject(KodiHelper.NewMediaContainer("Series", true));
if (!ret.Init())
return new MemoryStream();
enEpisodeType? eptype = null;
int serieID ;
if (SerieId.Contains("_"))
{
int ept ;
string[] ndata = SerieId.Split('_');
if (!int.TryParse(ndata[0], out ept))
return new MemoryStream();
eptype = (enEpisodeType) ept;
if (!int.TryParse(ndata[1], out serieID))
return new MemoryStream();
}
else
{
if (!int.TryParse(SerieId, out serieID))
return new MemoryStream();
}
using (var session = JMMService.SessionFactory.OpenSession())
{
if (serieID == -1)
return new MemoryStream();
AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
AnimeSeries ser = repSeries.GetByID(session, serieID);
if (ser == null)
return new MemoryStream();
AniDB_Anime anime = ser.GetAnime();
if (anime == null)
return new MemoryStream();
ImageDetails fanart = anime.GetDefaultFanartDetailsNoBlanks(session);
if (fanart != null)
ret.MediaContainer.Art = fanart.GenArt();
ret.MediaContainer.Title2 = ret.MediaContainer.Title1 = anime.MainTitle;
List<AnimeEpisode> episodes = ser.GetAnimeEpisodes(session).Where(a => a.GetVideoLocals(session).Count > 0).ToList();
if (eptype.HasValue)
{
episodes = episodes.Where(a => a.EpisodeTypeEnum == eptype.Value).ToList();
}
else
{
List<enEpisodeType> types = episodes.Select(a => a.EpisodeTypeEnum).Distinct().ToList();
if (types.Count > 1)
{
List<KodiEpisodeType> eps = new List<KodiEpisodeType>();
foreach (enEpisodeType ee in types)
{
KodiEpisodeType k2 = new KodiEpisodeType();
KodiEpisodeType.EpisodeTypeTranslated(k2, ee, (AnimeTypes)anime.AnimeType, episodes.Count(a => a.EpisodeTypeEnum == ee));
eps.Add(k2);
}
List<SortPropOrFieldAndDirection> sortCriteria = new List<SortPropOrFieldAndDirection>();
sortCriteria.Add(new SortPropOrFieldAndDirection("Name", SortType.eString));
eps = Sorting.MultiSort(eps, sortCriteria);
List<Video> dirs= new List<Video>();
bool isCharacterSetup_ = false;
foreach (KodiEpisodeType ee in eps)
{
Video v = new Directory();
v.Title = ee.Name;
v.Type = "season";
v.LeafCount = ee.Count.ToString();
v.ViewedLeafCount = "0";
v.Key = KodiHelper.ServerUrl(int.Parse(ServerSettings.JMMServerPort), MainWindow.PathAddressKodi + "/GetMetadata/" + userid + "/" + (int)JMMType.Serie + "/" + ee.Type + "_" + ser.AnimeSeriesID);
v.Thumb = KodiHelper.ServerUrl(int.Parse(ServerSettings.JMMServerPort),
MainWindow.PathAddressKodi + "/GetSupportImage/" + ee.Image);
if ((ee.AnimeType==AnimeTypes.Movie) || (ee.AnimeType==AnimeTypes.OVA))
{
v = KodiHelper.MayReplaceVideo((Directory)v, ser,anime, JMMType.File, userid, false);
}
//proper naming
v.OriginalTitle = "";
foreach (AniDB_Anime_Title title in anime.GetTitles())
{
if (title.TitleType == "official" || title.TitleType == "main")
{
v.OriginalTitle += "{" + title.TitleType + ":" + title.Language + "}" + title.Title + "|";
}
}
v.OriginalTitle = v.OriginalTitle.Substring(0, v.OriginalTitle.Length - 1);
//proper naming end
//experiment
if (!isCharacterSetup_)
{
Characters ch = new Characters();
ch.CharactersList = new List<Character>();
ch.CharactersList = GetCharactersFromAniDB(anime);
v.CharactersList = new List<Characters>();
v.CharactersList.Add(ch);
isCharacterSetup_ = true;
}
//.........这里部分代码省略.........
示例15: GetEpisodesToWatch_RecentlyWatched
/// <summary>
/// Gets a list of episodes watched based on the most recently watched series
/// It will return the next episode to watch in the most recent 10 series
/// </summary>
/// <returns></returns>
public List<Contract_AnimeEpisode> GetEpisodesToWatch_RecentlyWatched(int maxRecords, int jmmuserID)
{
List<Contract_AnimeEpisode> retEps = new List<Contract_AnimeEpisode>();
try
{
using (var session = JMMService.SessionFactory.OpenSession())
{
AnimeEpisodeRepository repEps = new AnimeEpisodeRepository();
AnimeSeriesRepository repAnimeSer = new AnimeSeriesRepository();
AnimeSeries_UserRepository repSeriesUser = new AnimeSeries_UserRepository();
JMMUserRepository repUsers = new JMMUserRepository();
DateTime start = DateTime.Now;
JMMUser user = repUsers.GetByID(session, jmmuserID);
if (user == null) return retEps;
// get a list of series that is applicable
List<AnimeSeries_User> allSeriesUser = repSeriesUser.GetMostRecentlyWatched(session, jmmuserID);
TimeSpan ts = DateTime.Now - start;
logger.Info(string.Format("GetEpisodesToWatch_RecentlyWatched:Series: {0}", ts.TotalMilliseconds));
start = DateTime.Now;
foreach (AnimeSeries_User userRecord in allSeriesUser)
{
AnimeSeries series = repAnimeSer.GetByID(session, userRecord.AnimeSeriesID);
if (series == null) continue;
if (!user.AllowedSeries(series)) continue;
Contract_AnimeEpisode ep = GetNextUnwatchedEpisode(session, userRecord.AnimeSeriesID, jmmuserID);
if (ep != null)
{
retEps.Add(ep);
// Lets only return the specified amount
if (retEps.Count == maxRecords)
{
ts = DateTime.Now - start;
logger.Info(string.Format("GetEpisodesToWatch_RecentlyWatched:Episodes: {0}", ts.TotalMilliseconds));
return retEps;
}
}
}
ts = DateTime.Now - start;
logger.Info(string.Format("GetEpisodesToWatch_RecentlyWatched:Episodes: {0}", ts.TotalMilliseconds));
}
}
catch (Exception ex)
{
logger.ErrorException(ex.ToString(), ex);
}
return retEps;
}