本文整理汇总了C#中JMMServer.Repositories.AnimeSeriesRepository.Save方法的典型用法代码示例。如果您正苦于以下问题:C# AnimeSeriesRepository.Save方法的具体用法?C# AnimeSeriesRepository.Save怎么用?C# AnimeSeriesRepository.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JMMServer.Repositories.AnimeSeriesRepository
的用法示例。
在下文中一共展示了AnimeSeriesRepository.Save方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessFile_AniDB
private void ProcessFile_AniDB(VideoLocal vidLocal)
{
logger.Trace("Checking for AniDB_File record for: {0} --- {1}", vidLocal.Hash, vidLocal.FilePath);
// check if we already have this AniDB_File info in the database
AniDB_FileRepository repAniFile = new AniDB_FileRepository();
AniDB_EpisodeRepository repAniEps = new AniDB_EpisodeRepository();
AniDB_AnimeRepository repAniAnime = new AniDB_AnimeRepository();
AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
VideoLocalRepository repVidLocals = new VideoLocalRepository();
AnimeEpisodeRepository repEps = new AnimeEpisodeRepository();
CrossRef_File_EpisodeRepository repXrefFE = new CrossRef_File_EpisodeRepository();
AniDB_File aniFile = null;
if (!ForceAniDB)
{
aniFile = repAniFile.GetByHashAndFileSize(vidLocal.Hash, vlocal.FileSize);
if (aniFile == null)
logger.Trace("AniDB_File record not found");
}
int animeID = 0;
if (aniFile == null)
{
// get info from AniDB
logger.Debug("Getting AniDB_File record from AniDB....");
Raw_AniDB_File fileInfo = JMMService.AnidbProcessor.GetFileInfo(vidLocal);
if (fileInfo != null)
{
// check if we already have a record
aniFile = repAniFile.GetByHashAndFileSize(vidLocal.Hash, vlocal.FileSize);
if (aniFile == null)
aniFile = new AniDB_File();
aniFile.Populate(fileInfo);
//overwrite with local file name
string localFileName = Path.GetFileName(vidLocal.FilePath);
aniFile.FileName = localFileName;
repAniFile.Save(aniFile, false);
aniFile.CreateLanguages();
aniFile.CreateCrossEpisodes(localFileName);
if (!string.IsNullOrEmpty(fileInfo.OtherEpisodesRAW))
{
string[] epIDs = fileInfo.OtherEpisodesRAW.Split(',');
foreach (string epid in epIDs)
{
int id = 0;
if (int.TryParse(epid, out id))
{
CommandRequest_GetEpisode cmdEp = new CommandRequest_GetEpisode(id);
cmdEp.Save();
}
}
}
animeID = aniFile.AnimeID;
}
}
bool missingEpisodes = false;
// if we still haven't got the AniDB_File Info we try the web cache or local records
if (aniFile == null)
{
// check if we have any records from previous imports
List<CrossRef_File_Episode> crossRefs = repXrefFE.GetByHash(vidLocal.Hash);
if (crossRefs == null || crossRefs.Count == 0)
{
// lets see if we can find the episode/anime info from the web cache
if (ServerSettings.WebCache_XRefFileEpisode_Get)
{
crossRefs = XMLService.Get_CrossRef_File_Episode(vidLocal);
if (crossRefs == null || crossRefs.Count == 0)
{
logger.Debug("Cannot find AniDB_File record or get cross ref from web cache record so exiting: {0}", vidLocal.ED2KHash);
return;
}
else
{
foreach (CrossRef_File_Episode xref in crossRefs)
{
// in this case we need to save the cross refs manually as AniDB did not provide them
repXrefFE.Save(xref);
}
}
}
else
{
logger.Debug("Cannot get AniDB_File record so exiting: {0}", vidLocal.ED2KHash);
return;
}
}
//.........这里部分代码省略.........
示例2: 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;
}
}
示例3: workerMyAnime2_DoWork
void workerMyAnime2_DoWork(object sender, DoWorkEventArgs e)
{
MA2Progress ma2Progress = new MA2Progress();
ma2Progress.CurrentFile = 0;
ma2Progress.ErrorMessage = "";
ma2Progress.MigratedFiles = 0;
ma2Progress.TotalFiles = 0;
try
{
string databasePath = e.Argument as string;
string connString = string.Format(@"data source={0};useutf16encoding=True", databasePath);
SQLiteConnection myConn = new SQLiteConnection(connString);
myConn.Open();
// get a list of unlinked files
VideoLocalRepository repVids = new VideoLocalRepository();
AniDB_EpisodeRepository repAniEps = new AniDB_EpisodeRepository();
AniDB_AnimeRepository repAniAnime = new AniDB_AnimeRepository();
AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
AnimeEpisodeRepository repEps = new AnimeEpisodeRepository();
List<VideoLocal> vids = repVids.GetVideosWithoutEpisode();
ma2Progress.TotalFiles = vids.Count;
foreach (VideoLocal vid in vids)
{
ma2Progress.CurrentFile = ma2Progress.CurrentFile + 1;
workerMyAnime2.ReportProgress(0, ma2Progress);
// search for this file in the XrossRef table in MA2
string sql = string.Format("SELECT AniDB_EpisodeID from CrossRef_Episode_FileHash WHERE Hash = '{0}' AND FileSize = {1}", vid.ED2KHash, vid.FileSize);
SQLiteCommand sqCommand = new SQLiteCommand(sql);
sqCommand.Connection = myConn;
SQLiteDataReader myReader = sqCommand.ExecuteReader();
while (myReader.Read())
{
int episodeID = 0;
if (!int.TryParse(myReader.GetValue(0).ToString(), out episodeID)) continue;
if (episodeID <= 0) continue;
sql = string.Format("SELECT AnimeID from AniDB_Episode WHERE EpisodeID = {0}", episodeID);
sqCommand = new SQLiteCommand(sql);
sqCommand.Connection = myConn;
SQLiteDataReader myReader2 = sqCommand.ExecuteReader();
while (myReader2.Read())
{
int animeID = myReader2.GetInt32(0);
// so now we have all the needed details we can link the file to the episode
// as long as wehave the details in JMM
AniDB_Anime anime = null;
AniDB_Episode ep = repAniEps.GetByEpisodeID(episodeID);
if (ep == null)
{
logger.Debug("Getting Anime record from AniDB....");
anime = JMMService.AnidbProcessor.GetAnimeInfoHTTP(animeID, true, ServerSettings.AutoGroupSeries);
}
else
anime = repAniAnime.GetByAnimeID(animeID);
// create the group/series/episode records if needed
AnimeSeries ser = null;
if (anime == null) continue;
logger.Debug("Creating groups, series and episodes....");
// check if there is an AnimeSeries Record associated with this AnimeID
ser = repSeries.GetByAnimeID(animeID);
if (ser == null)
{
// create a new AnimeSeries record
ser = anime.CreateAnimeSeriesAndGroup();
}
ser.CreateAnimeEpisodes();
// check if we have any group status data for this associated anime
// if not we will download it now
AniDB_GroupStatusRepository repStatus = new AniDB_GroupStatusRepository();
if (repStatus.GetByAnimeID(anime.AnimeID).Count == 0)
{
CommandRequest_GetReleaseGroupStatus cmdStatus = new CommandRequest_GetReleaseGroupStatus(anime.AnimeID, false);
cmdStatus.Save();
}
// update stats
ser.EpisodeAddedDate = DateTime.Now;
repSeries.Save(ser);
AnimeGroupRepository repGroups = new AnimeGroupRepository();
foreach (AnimeGroup grp in ser.AllGroupsAbove)
{
grp.EpisodeAddedDate = DateTime.Now;
repGroups.Save(grp);
}
//.........这里部分代码省略.........
示例4: 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;
}
}
示例5: RecreateAllGroups
public void RecreateAllGroups()
{
try
{
// pause queues
JMMService.CmdProcessorGeneral.Paused = true;
JMMService.CmdProcessorHasher.Paused = true;
JMMService.CmdProcessorImages.Paused = true;
AnimeGroupRepository repGroups = new AnimeGroupRepository();
AnimeGroup_UserRepository repGroupUser = new AnimeGroup_UserRepository();
AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
// get all the old groups
List<AnimeGroup> oldGroups = repGroups.GetAll();
List<AnimeGroup_User> oldGroupUsers = repGroupUser.GetAll();
// create a new group, where we will place all the series temporarily
AnimeGroup tempGroup = new AnimeGroup();
tempGroup.GroupName = "AAA Migrating Groups AAA";
tempGroup.Description = "AAA Migrating Groups AAA";
tempGroup.SortName = "AAA Migrating Groups AAA";
tempGroup.DateTimeUpdated = DateTime.Now;
tempGroup.DateTimeCreated = DateTime.Now;
repGroups.Save(tempGroup);
// move all series to the new group
foreach (AnimeSeries ser in repSeries.GetAll())
{
ser.AnimeGroupID = tempGroup.AnimeGroupID;
repSeries.Save(ser, false);
}
// delete all the old groups
foreach (AnimeGroup grp in oldGroups)
repGroups.Delete(grp.AnimeGroupID);
// delete all the old group user records
foreach (AnimeGroup_User grpUser in oldGroupUsers)
repGroupUser.Delete(grpUser.AnimeGroupID);
// recreate groups
foreach (AnimeSeries ser in repSeries.GetAll())
{
bool createNewGroup = true;
if (ServerSettings.AutoGroupSeries)
{
List<AnimeGroup> grps = AnimeGroup.GetRelatedGroupsFromAnimeID(ser.AniDB_ID);
// only use if there is just one result
if (grps != null && grps.Count > 0 && !grps[0].GroupName.Equals("AAA Migrating Groups AAA"))
{
ser.AnimeGroupID = grps[0].AnimeGroupID;
createNewGroup = false;
}
}
if (createNewGroup)
{
AnimeGroup anGroup = new AnimeGroup();
anGroup.Populate(ser);
repGroups.Save(anGroup);
ser.AnimeGroupID = anGroup.AnimeGroupID;
}
repSeries.Save(ser, false);
}
// delete the temp group
if (tempGroup.GetAllSeries().Count == 0)
repGroups.Delete(tempGroup.AnimeGroupID);
// create group user records and update group stats
foreach (AnimeGroup grp in repGroups.GetAll())
grp.UpdateStatsFromTopLevel(true, true);
// un-pause queues
JMMService.CmdProcessorGeneral.Paused = false;
JMMService.CmdProcessorHasher.Paused = false;
JMMService.CmdProcessorImages.Paused = false;
}
catch (Exception ex)
{
logger.ErrorException(ex.ToString(), ex);
}
}
示例6: CreateSeriesFromAnime
public Contract_AnimeSeries_SaveResponse CreateSeriesFromAnime(int animeID, int? animeGroupID, int userID)
{
Contract_AnimeSeries_SaveResponse response = new Contract_AnimeSeries_SaveResponse();
response.AnimeSeries = null;
response.ErrorMessage = "";
try
{
using (var session = JMMService.SessionFactory.OpenSession())
{
AnimeGroupRepository repGroups = new AnimeGroupRepository();
if (animeGroupID.HasValue)
{
AnimeGroup grp = repGroups.GetByID(session, animeGroupID.Value);
if (grp == null)
{
response.ErrorMessage = "Could not find the specified group";
return response;
}
}
// make sure a series doesn't already exists for this anime
AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
AnimeSeries ser = repSeries.GetByAnimeID(session, animeID);
if (ser != null)
{
response.ErrorMessage = "A series already exists for this anime";
return response;
}
// make sure the anime exists first
AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();
AniDB_Anime anime = repAnime.GetByAnimeID(session, animeID);
if (anime == null)
anime = JMMService.AnidbProcessor.GetAnimeInfoHTTP(session, animeID, false, false);
if (anime == null)
{
response.ErrorMessage = "Could not get anime information from AniDB";
return response;
}
if (animeGroupID.HasValue)
{
ser = new AnimeSeries();
ser.Populate(anime);
ser.AnimeGroupID = animeGroupID.Value;
repSeries.Save(ser);
}
else
{
ser = anime.CreateAnimeSeriesAndGroup(session);
}
ser.CreateAnimeEpisodes(session);
// check if we have any group status data for this associated anime
// if not we will download it now
AniDB_GroupStatusRepository repStatus = new AniDB_GroupStatusRepository();
if (repStatus.GetByAnimeID(anime.AnimeID).Count == 0)
{
CommandRequest_GetReleaseGroupStatus cmdStatus = new CommandRequest_GetReleaseGroupStatus(anime.AnimeID, false);
cmdStatus.Save(session);
}
ser.QueueUpdateStats();
// check for TvDB associations
CommandRequest_TvDBSearchAnime cmd = new CommandRequest_TvDBSearchAnime(anime.AnimeID, false);
cmd.Save(session);
if (ServerSettings.Trakt_IsEnabled && !string.IsNullOrEmpty(ServerSettings.Trakt_AuthToken))
{
// check for Trakt associations
CommandRequest_TraktSearchAnime cmd2 = new CommandRequest_TraktSearchAnime(anime.AnimeID, false);
cmd2.Save(session);
}
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();
response.AnimeSeries = ser.ToContract(anime, xrefs, xrefMovie, ser.GetUserRecord(userID),
sers, xrefMAL, false, null, null, null, null,movie);
return response;
}
}
catch (Exception ex)
{
logger.ErrorException(ex.ToString(), ex);
response.ErrorMessage = ex.Message;
}
return response;
}
示例7: AssociateSingleFileWithMultipleEpisodes
public string AssociateSingleFileWithMultipleEpisodes(int videoLocalID, int animeSeriesID, int startEpNum, int endEpNum)
{
try
{
VideoLocalRepository repVids = new VideoLocalRepository();
VideoLocal vid = repVids.GetByID(videoLocalID);
if (vid == null)
return "Could not find video record";
AnimeEpisodeRepository repEps = new AnimeEpisodeRepository();
AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
AniDB_EpisodeRepository repAniEps = new AniDB_EpisodeRepository();
CrossRef_File_EpisodeRepository repXRefs = new CrossRef_File_EpisodeRepository();
AnimeSeries ser = repSeries.GetByID(animeSeriesID);
if (ser == null)
return "Could not find anime series record";
for (int i = startEpNum; i <= endEpNum; i++)
{
List<AniDB_Episode> anieps = repAniEps.GetByAnimeIDAndEpisodeNumber(ser.AniDB_ID, i);
if (anieps.Count == 0)
return "Could not find the AniDB episode record";
AniDB_Episode aniep = anieps[0];
List<AnimeEpisode> eps = repEps.GetByAniEpisodeIDAndSeriesID(aniep.EpisodeID, ser.AnimeSeriesID);
if (eps.Count == 0)
return "Could not find episode record";
AnimeEpisode ep = eps[0];
CrossRef_File_Episode xref = new CrossRef_File_Episode();
xref.PopulateManually(vid, ep);
repXRefs.Save(xref);
CommandRequest_WebCacheSendXRefFileEpisode cr = new CommandRequest_WebCacheSendXRefFileEpisode(xref.CrossRef_File_EpisodeID);
cr.Save();
}
vid.RenameIfRequired();
vid.MoveFileIfRequired();
ser.QueueUpdateStats();
// update epidsode added stats
ser.EpisodeAddedDate = DateTime.Now;
repSeries.Save(ser);
AnimeGroupRepository repGroups = new AnimeGroupRepository();
foreach (AnimeGroup grp in ser.AllGroupsAbove)
{
grp.EpisodeAddedDate = DateTime.Now;
repGroups.Save(grp);
}
return "";
}
catch (Exception ex)
{
logger.ErrorException(ex.ToString(), ex);
}
return "";
}
示例8: AssociateSingleFile
public string AssociateSingleFile(int videoLocalID, int animeEpisodeID)
{
try
{
VideoLocalRepository repVids = new VideoLocalRepository();
VideoLocal vid = repVids.GetByID(videoLocalID);
if (vid == null)
return "Could not find video record";
AnimeEpisodeRepository repEps = new AnimeEpisodeRepository();
AnimeEpisode ep = repEps.GetByID(animeEpisodeID);
if (ep == null)
return "Could not find episode record";
CrossRef_File_EpisodeRepository repXRefs = new CrossRef_File_EpisodeRepository();
CrossRef_File_Episode xref = new CrossRef_File_Episode();
try
{
xref.PopulateManually(vid, ep);
}
catch (Exception ex)
{
string msg = string.Format("Error populating XREF: {0}", vid.ToStringDetailed());
throw;
}
repXRefs.Save(xref);
vid.RenameIfRequired();
vid.MoveFileIfRequired();
CommandRequest_WebCacheSendXRefFileEpisode cr = new CommandRequest_WebCacheSendXRefFileEpisode(xref.CrossRef_File_EpisodeID);
cr.Save();
AnimeSeries ser = ep.GetAnimeSeries();
ser.QueueUpdateStats();
// update epidsode added stats
AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
ser.EpisodeAddedDate = DateTime.Now;
repSeries.Save(ser);
AnimeGroupRepository repGroups = new AnimeGroupRepository();
foreach (AnimeGroup grp in ser.AllGroupsAbove)
{
grp.EpisodeAddedDate = DateTime.Now;
repGroups.Save(grp);
}
CommandRequest_AddFileToMyList cmdAddFile = new CommandRequest_AddFileToMyList(vid.Hash);
cmdAddFile.Save();
return "";
}
catch (Exception ex)
{
logger.ErrorException(ex.ToString(), ex);
}
return "";
}
示例9: AssociateMultipleFiles
public string AssociateMultipleFiles(List<int> videoLocalIDs, int animeSeriesID, int startingEpisodeNumber, bool singleEpisode)
{
try
{
CrossRef_File_EpisodeRepository repXRefs = new CrossRef_File_EpisodeRepository();
AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
VideoLocalRepository repVids = new VideoLocalRepository();
AniDB_EpisodeRepository repAniEps = new AniDB_EpisodeRepository();
AnimeEpisodeRepository repEps = new AnimeEpisodeRepository();
AnimeSeries ser = repSeries.GetByID(animeSeriesID);
if (ser == null)
return "Could not find anime series record";
int epNumber = startingEpisodeNumber;
int count = 1;
foreach (int videoLocalID in videoLocalIDs)
{
VideoLocal vid = repVids.GetByID(videoLocalID);
if (vid == null)
return "Could not find video local record";
List<AniDB_Episode> anieps = repAniEps.GetByAnimeIDAndEpisodeNumber(ser.AniDB_ID, epNumber);
if (anieps.Count == 0)
return "Could not find the AniDB episode record";
AniDB_Episode aniep = anieps[0];
List<AnimeEpisode> eps = repEps.GetByAniEpisodeIDAndSeriesID(aniep.EpisodeID, ser.AnimeSeriesID);
if (eps.Count == 0)
return "Could not find episode record";
AnimeEpisode ep = eps[0];
CrossRef_File_Episode xref = new CrossRef_File_Episode();
xref.PopulateManually(vid, ep);
// TODO do this properly
if (singleEpisode)
{
xref.EpisodeOrder = count;
if (videoLocalIDs.Count > 5)
xref.Percentage = 100;
else
xref.Percentage = GetEpisodePercentages(videoLocalIDs.Count)[count - 1];
}
repXRefs.Save(xref);
vid.RenameIfRequired();
vid.MoveFileIfRequired();
CommandRequest_WebCacheSendXRefFileEpisode cr = new CommandRequest_WebCacheSendXRefFileEpisode(xref.CrossRef_File_EpisodeID);
cr.Save();
count++;
if (!singleEpisode) epNumber++;
}
ser.QueueUpdateStats();
// update epidsode added stats
ser.EpisodeAddedDate = DateTime.Now;
repSeries.Save(ser);
AnimeGroupRepository repGroups = new AnimeGroupRepository();
foreach (AnimeGroup grp in ser.AllGroupsAbove)
{
grp.EpisodeAddedDate = DateTime.Now;
repGroups.Save(grp);
}
}
catch (Exception ex)
{
logger.ErrorException(ex.ToString(), ex);
}
return "";
}
示例10: CreateAnimeSeriesAndGroup
public AnimeSeries CreateAnimeSeriesAndGroup(ISession session)
{
// create a new AnimeSeries record
AnimeSeriesRepository repSeries = new AnimeSeriesRepository();
AnimeGroupRepository repGroups = new AnimeGroupRepository();
AnimeSeries ser = new AnimeSeries();
ser.Populate(this);
JMMUserRepository repUsers = new JMMUserRepository();
List<JMMUser> allUsers = repUsers.GetAll(session);
// create the AnimeGroup record
// check if there are any existing groups we could add this series to
bool createNewGroup = true;
if (ServerSettings.AutoGroupSeries)
{
List<AnimeGroup> grps = AnimeGroup.GetRelatedGroupsFromAnimeID(session, ser.AniDB_ID);
// only use if there is just one result
if (grps != null && grps.Count > 0)
{
ser.AnimeGroupID = grps[0].AnimeGroupID;
createNewGroup = false;
}
}
if (createNewGroup)
{
AnimeGroup anGroup = new AnimeGroup();
anGroup.Populate(ser);
repGroups.Save(anGroup);
ser.AnimeGroupID = anGroup.AnimeGroupID;
}
repSeries.Save(ser);
// check for TvDB associations
CommandRequest_TvDBSearchAnime cmd = new CommandRequest_TvDBSearchAnime(this.AnimeID, false);
cmd.Save();
// check for Trakt associations
if (ServerSettings.Trakt_IsEnabled && !string.IsNullOrEmpty(ServerSettings.Trakt_AuthToken))
{
CommandRequest_TraktSearchAnime cmd2 = new CommandRequest_TraktSearchAnime(this.AnimeID, false);
cmd2.Save();
}
return ser;
}