// List of Default priorities for commands // Pri 1 //------ // Reserved for commands user manually initiates from UI //------ // Pri 2 //------ // CommandRequest_GetAnimeHTTP //------ // Pri 3 //------ // CommandRequest_ProcessFile // CommandRequest_GetFile //------ // Pri 4 //------ // CommandRequest_GetUpdated // CommandRequest_ReadMediaInfo // CommandRequest_GetEpsode //------ // Pri 5 //------ // CommandRequest_GetReleaseGroupStatus //------ // Pri 6 //------ // CommandRequest_SyncMyList // CommandRequest_SyncMyVotes //------ // Pri 7 //------ // CommandRequest_GetCalendar //------ // Pri 8 //------ // CommandRequest_UpdateMyListFileStatus // CommandRequest_GetCharactersCreators // CommandRequest_TraktSyncCollection // CommandRequest_TvDBUpdateSeriesAndEpisodes // CommandRequest_TvDBDownloadImages // CommandRequest_TvDBSearchAnime // CommandRequest_MovieDBSearchAnime // CommandRequest_TraktSearchAnime // CommandRequest_MALSearchAnime //------ // Pri 9 //------ // CommandRequest_WebCacheSendFileHash // CommandRequest_GetReviews // CommandRequest_GetReleaseGroup // CommandRequest_WebCacheSendXRefFileEpisode // CommandRequest_WebCacheDeleteXRefFileEpisode // CommandRequest_AddFileToMyList // CommandRequest_DeleteFileFromMyList // CommandRequest_VoteAnime // CommandRequest_WebCacheDeleteXRefAniDBTvDB // CommandRequest_WebCacheDeleteXRefAniDBTvDBAll // CommandRequest_WebCacheSendXRefAniDBTvDB // CommandRequest_WebCacheSendXRefAniDBOther // CommandRequest_WebCacheDeleteXRefAniDBOther // CommandRequest_WebCacheDeleteXRefAniDBTrakt // CommandRequest_WebCacheSendXRefAniDBTrakt // CommandRequest_TraktUpdateInfoAndImages // CommandRequest_TraktSyncCollectionSeries // CommandRequest_TraktShowEpisodeUnseen // CommandRequest_DownloadImage // CommandRequest_TraktUpdateAllSeries // CommandRequest_MALUpdatedWatchedStatus // CommandRequest_MALUploadStatusToMAL // CommandRequest_MALDownloadStatusFromMAL // CommandRequest_WebCacheSendAniDB_File // CommandRequest_Azure_SendAnimeFull //------ // Pri 10 //------ // CommandRequest_UpdateMylistStats // CommandRequest_Azure_SendAnimeXML //------ // Pri 11 //------ // CommandRequest_Azure_SendAnimeTitle public static ICommandRequest GetCommand(CommandRequest crdb) { CommandRequestType crt = (CommandRequestType)crdb.CommandType; switch (crt) { case CommandRequestType.Trakt_SyncCollectionSeries: CommandRequest_TraktSyncCollectionSeries cr_CommandRequest_TraktSyncCollectionSeries = new CommandRequest_TraktSyncCollectionSeries(); cr_CommandRequest_TraktSyncCollectionSeries.LoadFromDBCommand(crdb); return((ICommandRequest)cr_CommandRequest_TraktSyncCollectionSeries); case CommandRequestType.AniDB_GetEpisodeUDP: CommandRequest_GetEpisode cr_CommandRequest_GetEpisode = new CommandRequest_GetEpisode(); cr_CommandRequest_GetEpisode.LoadFromDBCommand(crdb); return((ICommandRequest)cr_CommandRequest_GetEpisode); case CommandRequestType.Azure_SendAnimeTitle: CommandRequest_Azure_SendAnimeTitle cr_CommandRequest_Azure_SendAnimeTitle = new CommandRequest_Azure_SendAnimeTitle(); cr_CommandRequest_Azure_SendAnimeTitle.LoadFromDBCommand(crdb); return((ICommandRequest)cr_CommandRequest_Azure_SendAnimeTitle); case CommandRequestType.AniDB_GetTitles: CommandRequest_GetAniDBTitles cr_CommandRequest_GetAniDBTitles = new CommandRequest_GetAniDBTitles(); cr_CommandRequest_GetAniDBTitles.LoadFromDBCommand(crdb); return((ICommandRequest)cr_CommandRequest_GetAniDBTitles); case CommandRequestType.Azure_SendAnimeXML: CommandRequest_Azure_SendAnimeXML cr_CommandRequest_Azure_SendAnimeXML = new CommandRequest_Azure_SendAnimeXML(); cr_CommandRequest_Azure_SendAnimeXML.LoadFromDBCommand(crdb); return((ICommandRequest)cr_CommandRequest_Azure_SendAnimeXML); case CommandRequestType.Azure_SendAnimeFull: CommandRequest_Azure_SendAnimeFull cr_CommandRequest_Azure_SendAnimeFull = new CommandRequest_Azure_SendAnimeFull(); cr_CommandRequest_Azure_SendAnimeFull.LoadFromDBCommand(crdb); return((ICommandRequest)cr_CommandRequest_Azure_SendAnimeFull); case CommandRequestType.Azure_SendUserInfo: CommandRequest_Azure_SendUserInfo cr_CommandRequest_Azure_SendUserInfo = new CommandRequest_Azure_SendUserInfo(); cr_CommandRequest_Azure_SendUserInfo.LoadFromDBCommand(crdb); return((ICommandRequest)cr_CommandRequest_Azure_SendUserInfo); case CommandRequestType.AniDB_UpdateMylistStats: CommandRequest_UpdateMylistStats cr_AniDB_UpdateMylistStats = new CommandRequest_UpdateMylistStats(); cr_AniDB_UpdateMylistStats.LoadFromDBCommand(crdb); return((ICommandRequest)cr_AniDB_UpdateMylistStats); case CommandRequestType.MAL_DownloadWatchedStates: CommandRequest_MALDownloadStatusFromMAL cr_MAL_DownloadWatchedStates = new CommandRequest_MALDownloadStatusFromMAL(); cr_MAL_DownloadWatchedStates.LoadFromDBCommand(crdb); return((ICommandRequest)cr_MAL_DownloadWatchedStates); case CommandRequestType.MAL_UploadWatchedStates: CommandRequest_MALUploadStatusToMAL cr_MAL_UploadWatchedStates = new CommandRequest_MALUploadStatusToMAL(); cr_MAL_UploadWatchedStates.LoadFromDBCommand(crdb); return((ICommandRequest)cr_MAL_UploadWatchedStates); case CommandRequestType.MAL_UpdateStatus: CommandRequest_MALUpdatedWatchedStatus cr_MAL_UpdateStatus = new CommandRequest_MALUpdatedWatchedStatus(); cr_MAL_UpdateStatus.LoadFromDBCommand(crdb); return((ICommandRequest)cr_MAL_UpdateStatus); case CommandRequestType.MAL_SearchAnime: CommandRequest_MALSearchAnime cr_MAL_SearchAnime = new CommandRequest_MALSearchAnime(); cr_MAL_SearchAnime.LoadFromDBCommand(crdb); return((ICommandRequest)cr_MAL_SearchAnime); case CommandRequestType.WebCache_SendXRefAniDBMAL: CommandRequest_WebCacheSendXRefAniDBMAL cr_WebCacheSendXRefAniDBMAL = new CommandRequest_WebCacheSendXRefAniDBMAL(); cr_WebCacheSendXRefAniDBMAL.LoadFromDBCommand(crdb); return((ICommandRequest)cr_WebCacheSendXRefAniDBMAL); case CommandRequestType.WebCache_DeleteXRefAniDBMAL: CommandRequest_WebCacheDeleteXRefAniDBMAL cr_WebCacheDeleteXRefAniDBMAL = new CommandRequest_WebCacheDeleteXRefAniDBMAL(); cr_WebCacheDeleteXRefAniDBMAL.LoadFromDBCommand(crdb); return((ICommandRequest)cr_WebCacheDeleteXRefAniDBMAL); case CommandRequestType.AniDB_GetFileUDP: CommandRequest_GetFile cr_AniDB_GetFileUDP = new CommandRequest_GetFile(); cr_AniDB_GetFileUDP.LoadFromDBCommand(crdb); return((ICommandRequest)cr_AniDB_GetFileUDP); case CommandRequestType.ReadMediaInfo: CommandRequest_ReadMediaInfo cr_ReadMediaInfo = new CommandRequest_ReadMediaInfo(); cr_ReadMediaInfo.LoadFromDBCommand(crdb); return((ICommandRequest)cr_ReadMediaInfo); case CommandRequestType.Trakt_UpdateAllSeries: CommandRequest_TraktUpdateAllSeries cr_Trakt_UpdateAllSeries = new CommandRequest_TraktUpdateAllSeries(); cr_Trakt_UpdateAllSeries.LoadFromDBCommand(crdb); return((ICommandRequest)cr_Trakt_UpdateAllSeries); case CommandRequestType.Trakt_EpisodeCollection: CommandRequest_TraktCollectionEpisode cr_TraktCollectionEpisode = new CommandRequest_TraktCollectionEpisode(); cr_TraktCollectionEpisode.LoadFromDBCommand(crdb); return((ICommandRequest)cr_TraktCollectionEpisode); case CommandRequestType.Trakt_SyncCollection: CommandRequest_TraktSyncCollection cr_Trakt_SyncCollection = new CommandRequest_TraktSyncCollection(); cr_Trakt_SyncCollection.LoadFromDBCommand(crdb); return((ICommandRequest)cr_Trakt_SyncCollection); case CommandRequestType.Trakt_EpisodeHistory: CommandRequest_TraktHistoryEpisode cr_Trakt_EpisodeHistory = new CommandRequest_TraktHistoryEpisode(); cr_Trakt_EpisodeHistory.LoadFromDBCommand(crdb); return((ICommandRequest)cr_Trakt_EpisodeHistory); case CommandRequestType.Trakt_UpdateInfoImages: CommandRequest_TraktUpdateInfoAndImages cr_Trakt_UpdateInfoImages = new CommandRequest_TraktUpdateInfoAndImages(); cr_Trakt_UpdateInfoImages.LoadFromDBCommand(crdb); return((ICommandRequest)cr_Trakt_UpdateInfoImages); case CommandRequestType.WebCache_SendXRefAniDBTrakt: CommandRequest_WebCacheSendXRefAniDBTrakt cr_WebCache_SendXRefAniDBTrakt = new CommandRequest_WebCacheSendXRefAniDBTrakt(); cr_WebCache_SendXRefAniDBTrakt.LoadFromDBCommand(crdb); return((ICommandRequest)cr_WebCache_SendXRefAniDBTrakt); case CommandRequestType.WebCache_DeleteXRefAniDBTrakt: CommandRequest_WebCacheDeleteXRefAniDBTrakt cr_WebCache_DeleteXRefAniDBTrakt = new CommandRequest_WebCacheDeleteXRefAniDBTrakt(); cr_WebCache_DeleteXRefAniDBTrakt.LoadFromDBCommand(crdb); return((ICommandRequest)cr_WebCache_DeleteXRefAniDBTrakt); case CommandRequestType.Trakt_SearchAnime: CommandRequest_TraktSearchAnime cr_Trakt_SearchAnime = new CommandRequest_TraktSearchAnime(); cr_Trakt_SearchAnime.LoadFromDBCommand(crdb); return((ICommandRequest)cr_Trakt_SearchAnime); case CommandRequestType.MovieDB_SearchAnime: CommandRequest_MovieDBSearchAnime cr_MovieDB_SearchAnime = new CommandRequest_MovieDBSearchAnime(); cr_MovieDB_SearchAnime.LoadFromDBCommand(crdb); return((ICommandRequest)cr_MovieDB_SearchAnime); case CommandRequestType.WebCache_DeleteXRefAniDBOther: CommandRequest_WebCacheDeleteXRefAniDBOther cr_SendXRefAniDBOther = new CommandRequest_WebCacheDeleteXRefAniDBOther(); cr_SendXRefAniDBOther.LoadFromDBCommand(crdb); return((ICommandRequest)cr_SendXRefAniDBOther); case CommandRequestType.WebCache_SendXRefAniDBOther: CommandRequest_WebCacheSendXRefAniDBOther cr_WebCacheSendXRefAniDBOther = new CommandRequest_WebCacheSendXRefAniDBOther(); cr_WebCacheSendXRefAniDBOther.LoadFromDBCommand(crdb); return((ICommandRequest)cr_WebCacheSendXRefAniDBOther); case CommandRequestType.AniDB_DeleteFileUDP: CommandRequest_DeleteFileFromMyList cr_AniDB_DeleteFileUDP = new CommandRequest_DeleteFileFromMyList(); cr_AniDB_DeleteFileUDP.LoadFromDBCommand(crdb); return((ICommandRequest)cr_AniDB_DeleteFileUDP); case CommandRequestType.ImageDownload: CommandRequest_DownloadImage cr_ImageDownload = new CommandRequest_DownloadImage(); cr_ImageDownload.LoadFromDBCommand(crdb); return((ICommandRequest)cr_ImageDownload); case CommandRequestType.WebCache_DeleteXRefAniDBTvDB: CommandRequest_WebCacheDeleteXRefAniDBTvDB cr_DeleteXRefAniDBTvDB = new CommandRequest_WebCacheDeleteXRefAniDBTvDB(); cr_DeleteXRefAniDBTvDB.LoadFromDBCommand(crdb); return((ICommandRequest)cr_DeleteXRefAniDBTvDB); case CommandRequestType.WebCache_SendXRefAniDBTvDB: CommandRequest_WebCacheSendXRefAniDBTvDB cr_SendXRefAniDBTvDB = new CommandRequest_WebCacheSendXRefAniDBTvDB(); cr_SendXRefAniDBTvDB.LoadFromDBCommand(crdb); return((ICommandRequest)cr_SendXRefAniDBTvDB); case CommandRequestType.TvDB_SearchAnime: CommandRequest_TvDBSearchAnime cr_TvDB_SearchAnime = new CommandRequest_TvDBSearchAnime(); cr_TvDB_SearchAnime.LoadFromDBCommand(crdb); return((ICommandRequest)cr_TvDB_SearchAnime); case CommandRequestType.TvDB_DownloadImages: CommandRequest_TvDBDownloadImages cr_TvDB_DownloadImages = new CommandRequest_TvDBDownloadImages(); cr_TvDB_DownloadImages.LoadFromDBCommand(crdb); return((ICommandRequest)cr_TvDB_DownloadImages); case CommandRequestType.TvDB_SeriesEpisodes: CommandRequest_TvDBUpdateSeriesAndEpisodes cr_TvDB_Episodes = new CommandRequest_TvDBUpdateSeriesAndEpisodes(); cr_TvDB_Episodes.LoadFromDBCommand(crdb); return((ICommandRequest)cr_TvDB_Episodes); case CommandRequestType.AniDB_SyncVotes: CommandRequest_SyncMyVotes cr_SyncVotes = new CommandRequest_SyncMyVotes(); cr_SyncVotes.LoadFromDBCommand(crdb); return((ICommandRequest)cr_SyncVotes); case CommandRequestType.AniDB_VoteAnime: CommandRequest_VoteAnime cr_VoteAnime = new CommandRequest_VoteAnime(); cr_VoteAnime.LoadFromDBCommand(crdb); return((ICommandRequest)cr_VoteAnime); case CommandRequestType.AniDB_GetCalendar: CommandRequest_GetCalendar cr_GetCalendar = new CommandRequest_GetCalendar(); cr_GetCalendar.LoadFromDBCommand(crdb); return((ICommandRequest)cr_GetCalendar); case CommandRequestType.AniDB_GetReleaseGroup: CommandRequest_GetReleaseGroup cr_GetReleaseGroup = new CommandRequest_GetReleaseGroup(); cr_GetReleaseGroup.LoadFromDBCommand(crdb); return((ICommandRequest)cr_GetReleaseGroup); case CommandRequestType.AniDB_GetAnimeHTTP: CommandRequest_GetAnimeHTTP cr_geth = new CommandRequest_GetAnimeHTTP(); cr_geth.LoadFromDBCommand(crdb); return((ICommandRequest)cr_geth); case CommandRequestType.AniDB_GetReleaseGroupStatus: CommandRequest_GetReleaseGroupStatus cr_GetReleaseGroupStatus = new CommandRequest_GetReleaseGroupStatus(); cr_GetReleaseGroupStatus.LoadFromDBCommand(crdb); return((ICommandRequest)cr_GetReleaseGroupStatus); case CommandRequestType.HashFile: CommandRequest_HashFile cr_HashFile = new CommandRequest_HashFile(); cr_HashFile.LoadFromDBCommand(crdb); return((ICommandRequest)cr_HashFile); case CommandRequestType.ProcessFile: CommandRequest_ProcessFile cr_pf = new CommandRequest_ProcessFile(); cr_pf.LoadFromDBCommand(crdb); return((ICommandRequest)cr_pf); case CommandRequestType.AniDB_AddFileUDP: CommandRequest_AddFileToMyList cr_af = new CommandRequest_AddFileToMyList(); cr_af.LoadFromDBCommand(crdb); return((ICommandRequest)cr_af); case CommandRequestType.AniDB_UpdateWatchedUDP: CommandRequest_UpdateMyListFileStatus cr_umlf = new CommandRequest_UpdateMyListFileStatus(); cr_umlf.LoadFromDBCommand(crdb); return((ICommandRequest)cr_umlf); case CommandRequestType.WebCache_DeleteXRefFileEpisode: CommandRequest_WebCacheDeleteXRefFileEpisode cr_DeleteXRefFileEpisode = new CommandRequest_WebCacheDeleteXRefFileEpisode(); cr_DeleteXRefFileEpisode.LoadFromDBCommand(crdb); return((ICommandRequest)cr_DeleteXRefFileEpisode); case CommandRequestType.WebCache_SendXRefFileEpisode: CommandRequest_WebCacheSendXRefFileEpisode cr_SendXRefFileEpisode = new CommandRequest_WebCacheSendXRefFileEpisode(); cr_SendXRefFileEpisode.LoadFromDBCommand(crdb); return((ICommandRequest)cr_SendXRefFileEpisode); case CommandRequestType.AniDB_GetReviews: CommandRequest_GetReviews cr_GetReviews = new CommandRequest_GetReviews(); cr_GetReviews.LoadFromDBCommand(crdb); return((ICommandRequest)cr_GetReviews); case CommandRequestType.AniDB_GetUpdated: CommandRequest_GetUpdated cr_GetUpdated = new CommandRequest_GetUpdated(); cr_GetUpdated.LoadFromDBCommand(crdb); return((ICommandRequest)cr_GetUpdated); case CommandRequestType.AniDB_SyncMyList: CommandRequest_SyncMyList cr_SyncMyList = new CommandRequest_SyncMyList(); cr_SyncMyList.LoadFromDBCommand(crdb); return((ICommandRequest)cr_SyncMyList); case CommandRequestType.Refresh_AnimeStats: CommandRequest_RefreshAnime cr_refreshAnime = new CommandRequest_RefreshAnime(); cr_refreshAnime.LoadFromDBCommand(crdb); return(cr_refreshAnime); case CommandRequestType.LinkAniDBTvDB: CommandRequest_LinkAniDBTvDB cr_linkAniDBTvDB = new CommandRequest_LinkAniDBTvDB(); cr_linkAniDBTvDB.LoadFromDBCommand(crdb); return(cr_linkAniDBTvDB); } return(null); }
void workerFileEvents_DoWork(object sender, DoWorkEventArgs e) { logger.Info("Started thread for processing file creation events"); foreach (FileSystemEventArgs evt in queueFileEvents) { try { // this is a message to stop processing if (evt == null) return; logger.Info("New file created: {0}: {1}", evt.FullPath, evt.ChangeType); if (evt.ChangeType == WatcherChangeTypes.Created) { if (Directory.Exists(evt.FullPath)) { // When the path that was created represents a directory we need to manually get the contained files to add. // The reason for this is that when a directory is moved into a source directory (from the same drive) we will only recieve // an event for the directory and not the contained files. However, if the folder is copied from a different drive then // a create event will fire for the directory and each file contained within it (As they are all treated as separate operations) string[] files = Directory.GetFiles(evt.FullPath, "*.*", SearchOption.AllDirectories); foreach (string file in files) { if (FileHashHelper.IsVideo(file)) { logger.Info("Found file {0} under folder {1}", file, evt.FullPath); CommandRequest_HashFile cmd = new CommandRequest_HashFile(file, false); cmd.Save(); } } } else if (FileHashHelper.IsVideo(evt.FullPath)) { CommandRequest_HashFile cmd = new CommandRequest_HashFile(evt.FullPath, false); cmd.Save(); } } queueFileEvents.Remove(evt); } catch (Exception ex) { logger.ErrorException(ex.Message, ex); queueFileEvents.Remove(evt); Thread.Sleep(1000); } } }
// List of Default priorities for commands // Pri 1 //------ // Reserved for commands user manually initiates from UI //------ // Pri 2 //------ // CommandRequest_GetAnimeHTTP //------ // Pri 3 //------ // CommandRequest_ProcessFile // CommandRequest_GetFile //------ // Pri 4 //------ // CommandRequest_GetUpdated // CommandRequest_ReadMediaInfo // CommandRequest_GetEpsode //------ // Pri 5 //------ // CommandRequest_GetReleaseGroupStatus //------ // Pri 6 //------ // CommandRequest_SyncMyList // CommandRequest_SyncMyVotes //------ // Pri 7 //------ // CommandRequest_GetCalendar //------ // Pri 8 //------ // CommandRequest_UpdateMyListFileStatus // CommandRequest_GetCharactersCreators // CommandRequest_TraktSyncCollection // CommandRequest_TvDBUpdateSeriesAndEpisodes // CommandRequest_TvDBDownloadImages // CommandRequest_TvDBSearchAnime // CommandRequest_MovieDBSearchAnime // CommandRequest_TraktSearchAnime // CommandRequest_MALSearchAnime //------ // Pri 9 //------ // CommandRequest_WebCacheSendFileHash // CommandRequest_GetReviews // CommandRequest_GetReleaseGroup // CommandRequest_WebCacheSendXRefFileEpisode // CommandRequest_WebCacheDeleteXRefFileEpisode // CommandRequest_AddFileToMyList // CommandRequest_DeleteFileFromMyList // CommandRequest_VoteAnime // CommandRequest_WebCacheDeleteXRefAniDBTvDB // CommandRequest_WebCacheDeleteXRefAniDBTvDBAll // CommandRequest_WebCacheSendXRefAniDBTvDB // CommandRequest_WebCacheSendXRefAniDBOther // CommandRequest_WebCacheDeleteXRefAniDBOther // CommandRequest_WebCacheDeleteXRefAniDBTrakt // CommandRequest_WebCacheSendXRefAniDBTrakt // CommandRequest_TraktUpdateInfoAndImages // CommandRequest_TraktSyncCollectionSeries // CommandRequest_TraktShowEpisodeUnseen // CommandRequest_DownloadImage // CommandRequest_TraktUpdateAllSeries // CommandRequest_MALUpdatedWatchedStatus // CommandRequest_MALUploadStatusToMAL // CommandRequest_MALDownloadStatusFromMAL // CommandRequest_WebCacheSendAniDB_File // CommandRequest_Azure_SendAnimeFull //------ // Pri 10 //------ // CommandRequest_UpdateMylistStats // CommandRequest_Azure_SendAnimeXML //------ // Pri 11 //------ // CommandRequest_Azure_SendAnimeTitle public static ICommandRequest GetCommand(CommandRequest crdb) { CommandRequestType crt = (CommandRequestType)crdb.CommandType; switch (crt) { case CommandRequestType.Trakt_SyncCollectionSeries: CommandRequest_TraktSyncCollectionSeries cr_CommandRequest_TraktSyncCollectionSeries = new CommandRequest_TraktSyncCollectionSeries(); cr_CommandRequest_TraktSyncCollectionSeries.LoadFromDBCommand(crdb); return (ICommandRequest)cr_CommandRequest_TraktSyncCollectionSeries; case CommandRequestType.AniDB_GetEpisodeUDP: CommandRequest_GetEpisode cr_CommandRequest_GetEpisode = new CommandRequest_GetEpisode(); cr_CommandRequest_GetEpisode.LoadFromDBCommand(crdb); return (ICommandRequest)cr_CommandRequest_GetEpisode; case CommandRequestType.Azure_SendAnimeTitle: CommandRequest_Azure_SendAnimeTitle cr_CommandRequest_Azure_SendAnimeTitle = new CommandRequest_Azure_SendAnimeTitle(); cr_CommandRequest_Azure_SendAnimeTitle.LoadFromDBCommand(crdb); return (ICommandRequest)cr_CommandRequest_Azure_SendAnimeTitle; case CommandRequestType.AniDB_GetTitles: CommandRequest_GetAniDBTitles cr_CommandRequest_GetAniDBTitles = new CommandRequest_GetAniDBTitles(); cr_CommandRequest_GetAniDBTitles.LoadFromDBCommand(crdb); return (ICommandRequest)cr_CommandRequest_GetAniDBTitles; case CommandRequestType.Azure_SendAnimeXML: CommandRequest_Azure_SendAnimeXML cr_CommandRequest_Azure_SendAnimeXML = new CommandRequest_Azure_SendAnimeXML(); cr_CommandRequest_Azure_SendAnimeXML.LoadFromDBCommand(crdb); return (ICommandRequest)cr_CommandRequest_Azure_SendAnimeXML; case CommandRequestType.Azure_SendAnimeFull: CommandRequest_Azure_SendAnimeFull cr_CommandRequest_Azure_SendAnimeFull = new CommandRequest_Azure_SendAnimeFull(); cr_CommandRequest_Azure_SendAnimeFull.LoadFromDBCommand(crdb); return (ICommandRequest)cr_CommandRequest_Azure_SendAnimeFull; case CommandRequestType.Azure_SendUserInfo: CommandRequest_Azure_SendUserInfo cr_CommandRequest_Azure_SendUserInfo = new CommandRequest_Azure_SendUserInfo(); cr_CommandRequest_Azure_SendUserInfo.LoadFromDBCommand(crdb); return (ICommandRequest)cr_CommandRequest_Azure_SendUserInfo; case CommandRequestType.AniDB_UpdateMylistStats: CommandRequest_UpdateMylistStats cr_AniDB_UpdateMylistStats = new CommandRequest_UpdateMylistStats(); cr_AniDB_UpdateMylistStats.LoadFromDBCommand(crdb); return (ICommandRequest)cr_AniDB_UpdateMylistStats; case CommandRequestType.MAL_DownloadWatchedStates: CommandRequest_MALDownloadStatusFromMAL cr_MAL_DownloadWatchedStates = new CommandRequest_MALDownloadStatusFromMAL(); cr_MAL_DownloadWatchedStates.LoadFromDBCommand(crdb); return (ICommandRequest)cr_MAL_DownloadWatchedStates; case CommandRequestType.MAL_UploadWatchedStates: CommandRequest_MALUploadStatusToMAL cr_MAL_UploadWatchedStates = new CommandRequest_MALUploadStatusToMAL(); cr_MAL_UploadWatchedStates.LoadFromDBCommand(crdb); return (ICommandRequest)cr_MAL_UploadWatchedStates; case CommandRequestType.MAL_UpdateStatus: CommandRequest_MALUpdatedWatchedStatus cr_MAL_UpdateStatus = new CommandRequest_MALUpdatedWatchedStatus(); cr_MAL_UpdateStatus.LoadFromDBCommand(crdb); return (ICommandRequest)cr_MAL_UpdateStatus; case CommandRequestType.MAL_SearchAnime: CommandRequest_MALSearchAnime cr_MAL_SearchAnime = new CommandRequest_MALSearchAnime(); cr_MAL_SearchAnime.LoadFromDBCommand(crdb); return (ICommandRequest)cr_MAL_SearchAnime; case CommandRequestType.WebCache_SendXRefAniDBMAL: CommandRequest_WebCacheSendXRefAniDBMAL cr_WebCacheSendXRefAniDBMAL = new CommandRequest_WebCacheSendXRefAniDBMAL(); cr_WebCacheSendXRefAniDBMAL.LoadFromDBCommand(crdb); return (ICommandRequest)cr_WebCacheSendXRefAniDBMAL; case CommandRequestType.WebCache_DeleteXRefAniDBMAL: CommandRequest_WebCacheDeleteXRefAniDBMAL cr_WebCacheDeleteXRefAniDBMAL = new CommandRequest_WebCacheDeleteXRefAniDBMAL(); cr_WebCacheDeleteXRefAniDBMAL.LoadFromDBCommand(crdb); return (ICommandRequest)cr_WebCacheDeleteXRefAniDBMAL; case CommandRequestType.AniDB_GetFileUDP: CommandRequest_GetFile cr_AniDB_GetFileUDP = new CommandRequest_GetFile(); cr_AniDB_GetFileUDP.LoadFromDBCommand(crdb); return (ICommandRequest)cr_AniDB_GetFileUDP; case CommandRequestType.ReadMediaInfo: CommandRequest_ReadMediaInfo cr_ReadMediaInfo = new CommandRequest_ReadMediaInfo(); cr_ReadMediaInfo.LoadFromDBCommand(crdb); return (ICommandRequest)cr_ReadMediaInfo; case CommandRequestType.Trakt_UpdateAllSeries: CommandRequest_TraktUpdateAllSeries cr_Trakt_UpdateAllSeries = new CommandRequest_TraktUpdateAllSeries(); cr_Trakt_UpdateAllSeries.LoadFromDBCommand(crdb); return (ICommandRequest)cr_Trakt_UpdateAllSeries; case CommandRequestType.Trakt_EpisodeCollection: CommandRequest_TraktCollectionEpisode cr_TraktCollectionEpisode = new CommandRequest_TraktCollectionEpisode(); cr_TraktCollectionEpisode.LoadFromDBCommand(crdb); return (ICommandRequest)cr_TraktCollectionEpisode; case CommandRequestType.Trakt_SyncCollection: CommandRequest_TraktSyncCollection cr_Trakt_SyncCollection = new CommandRequest_TraktSyncCollection(); cr_Trakt_SyncCollection.LoadFromDBCommand(crdb); return (ICommandRequest)cr_Trakt_SyncCollection; case CommandRequestType.Trakt_EpisodeHistory: CommandRequest_TraktHistoryEpisode cr_Trakt_EpisodeHistory = new CommandRequest_TraktHistoryEpisode(); cr_Trakt_EpisodeHistory.LoadFromDBCommand(crdb); return (ICommandRequest)cr_Trakt_EpisodeHistory; case CommandRequestType.Trakt_UpdateInfoImages: CommandRequest_TraktUpdateInfoAndImages cr_Trakt_UpdateInfoImages = new CommandRequest_TraktUpdateInfoAndImages(); cr_Trakt_UpdateInfoImages.LoadFromDBCommand(crdb); return (ICommandRequest)cr_Trakt_UpdateInfoImages; case CommandRequestType.WebCache_SendXRefAniDBTrakt: CommandRequest_WebCacheSendXRefAniDBTrakt cr_WebCache_SendXRefAniDBTrakt = new CommandRequest_WebCacheSendXRefAniDBTrakt(); cr_WebCache_SendXRefAniDBTrakt.LoadFromDBCommand(crdb); return (ICommandRequest)cr_WebCache_SendXRefAniDBTrakt; case CommandRequestType.WebCache_DeleteXRefAniDBTrakt: CommandRequest_WebCacheDeleteXRefAniDBTrakt cr_WebCache_DeleteXRefAniDBTrakt = new CommandRequest_WebCacheDeleteXRefAniDBTrakt(); cr_WebCache_DeleteXRefAniDBTrakt.LoadFromDBCommand(crdb); return (ICommandRequest)cr_WebCache_DeleteXRefAniDBTrakt; case CommandRequestType.Trakt_SearchAnime: CommandRequest_TraktSearchAnime cr_Trakt_SearchAnime = new CommandRequest_TraktSearchAnime(); cr_Trakt_SearchAnime.LoadFromDBCommand(crdb); return (ICommandRequest)cr_Trakt_SearchAnime; case CommandRequestType.MovieDB_SearchAnime: CommandRequest_MovieDBSearchAnime cr_MovieDB_SearchAnime = new CommandRequest_MovieDBSearchAnime(); cr_MovieDB_SearchAnime.LoadFromDBCommand(crdb); return (ICommandRequest)cr_MovieDB_SearchAnime; case CommandRequestType.WebCache_DeleteXRefAniDBOther: CommandRequest_WebCacheDeleteXRefAniDBOther cr_SendXRefAniDBOther = new CommandRequest_WebCacheDeleteXRefAniDBOther(); cr_SendXRefAniDBOther.LoadFromDBCommand(crdb); return (ICommandRequest)cr_SendXRefAniDBOther; case CommandRequestType.WebCache_SendXRefAniDBOther: CommandRequest_WebCacheSendXRefAniDBOther cr_WebCacheSendXRefAniDBOther = new CommandRequest_WebCacheSendXRefAniDBOther(); cr_WebCacheSendXRefAniDBOther.LoadFromDBCommand(crdb); return (ICommandRequest)cr_WebCacheSendXRefAniDBOther; case CommandRequestType.AniDB_DeleteFileUDP: CommandRequest_DeleteFileFromMyList cr_AniDB_DeleteFileUDP = new CommandRequest_DeleteFileFromMyList(); cr_AniDB_DeleteFileUDP.LoadFromDBCommand(crdb); return (ICommandRequest)cr_AniDB_DeleteFileUDP; case CommandRequestType.ImageDownload: CommandRequest_DownloadImage cr_ImageDownload = new CommandRequest_DownloadImage(); cr_ImageDownload.LoadFromDBCommand(crdb); return (ICommandRequest)cr_ImageDownload; case CommandRequestType.WebCache_DeleteXRefAniDBTvDB: CommandRequest_WebCacheDeleteXRefAniDBTvDB cr_DeleteXRefAniDBTvDB = new CommandRequest_WebCacheDeleteXRefAniDBTvDB(); cr_DeleteXRefAniDBTvDB.LoadFromDBCommand(crdb); return (ICommandRequest)cr_DeleteXRefAniDBTvDB; case CommandRequestType.WebCache_SendXRefAniDBTvDB: CommandRequest_WebCacheSendXRefAniDBTvDB cr_SendXRefAniDBTvDB = new CommandRequest_WebCacheSendXRefAniDBTvDB(); cr_SendXRefAniDBTvDB.LoadFromDBCommand(crdb); return (ICommandRequest)cr_SendXRefAniDBTvDB; case CommandRequestType.TvDB_SearchAnime: CommandRequest_TvDBSearchAnime cr_TvDB_SearchAnime = new CommandRequest_TvDBSearchAnime(); cr_TvDB_SearchAnime.LoadFromDBCommand(crdb); return (ICommandRequest)cr_TvDB_SearchAnime; case CommandRequestType.TvDB_DownloadImages: CommandRequest_TvDBDownloadImages cr_TvDB_DownloadImages = new CommandRequest_TvDBDownloadImages(); cr_TvDB_DownloadImages.LoadFromDBCommand(crdb); return (ICommandRequest)cr_TvDB_DownloadImages; case CommandRequestType.TvDB_SeriesEpisodes: CommandRequest_TvDBUpdateSeriesAndEpisodes cr_TvDB_Episodes = new CommandRequest_TvDBUpdateSeriesAndEpisodes(); cr_TvDB_Episodes.LoadFromDBCommand(crdb); return (ICommandRequest)cr_TvDB_Episodes; case CommandRequestType.AniDB_SyncVotes: CommandRequest_SyncMyVotes cr_SyncVotes = new CommandRequest_SyncMyVotes(); cr_SyncVotes.LoadFromDBCommand(crdb); return (ICommandRequest)cr_SyncVotes; case CommandRequestType.AniDB_VoteAnime: CommandRequest_VoteAnime cr_VoteAnime = new CommandRequest_VoteAnime(); cr_VoteAnime.LoadFromDBCommand(crdb); return (ICommandRequest)cr_VoteAnime; case CommandRequestType.AniDB_GetCalendar: CommandRequest_GetCalendar cr_GetCalendar = new CommandRequest_GetCalendar(); cr_GetCalendar.LoadFromDBCommand(crdb); return (ICommandRequest)cr_GetCalendar; case CommandRequestType.AniDB_GetReleaseGroup: CommandRequest_GetReleaseGroup cr_GetReleaseGroup = new CommandRequest_GetReleaseGroup(); cr_GetReleaseGroup.LoadFromDBCommand(crdb); return (ICommandRequest)cr_GetReleaseGroup; case CommandRequestType.AniDB_GetAnimeHTTP: CommandRequest_GetAnimeHTTP cr_geth = new CommandRequest_GetAnimeHTTP(); cr_geth.LoadFromDBCommand(crdb); return (ICommandRequest)cr_geth; case CommandRequestType.AniDB_GetReleaseGroupStatus: CommandRequest_GetReleaseGroupStatus cr_GetReleaseGroupStatus = new CommandRequest_GetReleaseGroupStatus(); cr_GetReleaseGroupStatus.LoadFromDBCommand(crdb); return (ICommandRequest)cr_GetReleaseGroupStatus; case CommandRequestType.HashFile: CommandRequest_HashFile cr_HashFile = new CommandRequest_HashFile(); cr_HashFile.LoadFromDBCommand(crdb); return (ICommandRequest)cr_HashFile; case CommandRequestType.ProcessFile: CommandRequest_ProcessFile cr_pf = new CommandRequest_ProcessFile(); cr_pf.LoadFromDBCommand(crdb); return (ICommandRequest)cr_pf; case CommandRequestType.AniDB_AddFileUDP: CommandRequest_AddFileToMyList cr_af = new CommandRequest_AddFileToMyList(); cr_af.LoadFromDBCommand(crdb); return (ICommandRequest)cr_af; case CommandRequestType.AniDB_UpdateWatchedUDP: CommandRequest_UpdateMyListFileStatus cr_umlf = new CommandRequest_UpdateMyListFileStatus(); cr_umlf.LoadFromDBCommand(crdb); return (ICommandRequest)cr_umlf; case CommandRequestType.WebCache_DeleteXRefFileEpisode: CommandRequest_WebCacheDeleteXRefFileEpisode cr_DeleteXRefFileEpisode = new CommandRequest_WebCacheDeleteXRefFileEpisode(); cr_DeleteXRefFileEpisode.LoadFromDBCommand(crdb); return (ICommandRequest)cr_DeleteXRefFileEpisode; case CommandRequestType.WebCache_SendXRefFileEpisode: CommandRequest_WebCacheSendXRefFileEpisode cr_SendXRefFileEpisode = new CommandRequest_WebCacheSendXRefFileEpisode(); cr_SendXRefFileEpisode.LoadFromDBCommand(crdb); return (ICommandRequest)cr_SendXRefFileEpisode; case CommandRequestType.AniDB_GetReviews: CommandRequest_GetReviews cr_GetReviews = new CommandRequest_GetReviews(); cr_GetReviews.LoadFromDBCommand(crdb); return (ICommandRequest)cr_GetReviews; case CommandRequestType.AniDB_GetUpdated: CommandRequest_GetUpdated cr_GetUpdated = new CommandRequest_GetUpdated(); cr_GetUpdated.LoadFromDBCommand(crdb); return (ICommandRequest)cr_GetUpdated; case CommandRequestType.AniDB_SyncMyList: CommandRequest_SyncMyList cr_SyncMyList = new CommandRequest_SyncMyList(); cr_SyncMyList.LoadFromDBCommand(crdb); return (ICommandRequest)cr_SyncMyList; case CommandRequestType.Refresh_AnimeStats: CommandRequest_RefreshAnime cr_refreshAnime=new CommandRequest_RefreshAnime(); cr_refreshAnime.LoadFromDBCommand(crdb); return cr_refreshAnime; } return null; }
public void RehashFile(int videoLocalID) { VideoLocalRepository repVidLocals = new VideoLocalRepository(); VideoLocal vl = repVidLocals.GetByID(videoLocalID); if (vl != null) { CommandRequest_HashFile cr_hashfile = new CommandRequest_HashFile(vl.FullServerPath, true); cr_hashfile.Save(); } }
public void RehashFile(int videoLocalID) { VideoLocal vl = RepoFactory.VideoLocal.GetByID(videoLocalID); if (vl != null) { VideoLocal_Place pl = vl.GetBestVideoLocalPlace(); if (pl == null) { logger.Error("Unable to hash videolocal with id = {videoLocalID}, it has no assigned place"); return; } CommandRequest_HashFile cr_hashfile = new CommandRequest_HashFile(pl.FullServerPath, true); cr_hashfile.Save(); } }
void workerFileEvents_DoWork(object sender, DoWorkEventArgs e) { logger.Info("Started thread for processing file events"); foreach (FileSystemEventArgs evt in queueFileEvents) { try { // this is a message to stop processing if (evt == null) { return; } if (evt.ChangeType == WatcherChangeTypes.Created || evt.ChangeType == WatcherChangeTypes.Renamed) { if (evt.FullPath.StartsWith("|CLOUD|")) { int shareid = int.Parse(evt.Name); Importer.RunImport_ImportFolderNewFiles(RepoFactory.ImportFolder.GetByID(shareid)); } else { // When the path that was created represents a directory we need to manually get the contained files to add. // The reason for this is that when a directory is moved into a source directory (from the same drive) we will only recieve // an event for the directory and not the contained files. However, if the folder is copied from a different drive then // a create event will fire for the directory and each file contained within it (As they are all treated as separate operations) FileAttributes attr = File.GetAttributes(evt.FullPath); if (attr.HasFlag(FileAttributes.Directory)) { logger.Info("New folder detected: {0}: {1}", evt.FullPath, evt.ChangeType); string[] files = Directory.GetFiles(evt.FullPath, "*.*", SearchOption.AllDirectories); foreach (string file in files) { if (FileHashHelper.IsVideo(file)) { logger.Info("Found file {0} under folder {1}", file, evt.FullPath); CommandRequest_HashFile cmd = new CommandRequest_HashFile(file, false); cmd.Save(); } } } else if (File.Exists(evt.FullPath)) { logger.Info("New file detected: {0}: {1}", evt.FullPath, evt.ChangeType); if (FileHashHelper.IsVideo(evt.FullPath)) { logger.Info("Found file {0}", evt.FullPath); CommandRequest_HashFile cmd = new CommandRequest_HashFile(evt.FullPath, false); cmd.Save(); } } } } queueFileEvents.Remove(evt); } catch (Exception ex) { logger.Error( ex,ex.ToString()); queueFileEvents.Remove(evt); Thread.Sleep(1000); } } }
public static void RunImport_NewFiles() { VideoLocalRepository repVidLocals = new VideoLocalRepository(); // first build a list of files that we already know about, as we don't want to process them again List<VideoLocal> filesAll = repVidLocals.GetAll(); Dictionary<string, VideoLocal> dictFilesExisting = new Dictionary<string, VideoLocal>(); foreach (VideoLocal vl in filesAll) { try { dictFilesExisting[vl.FullServerPath] = vl; } catch (Exception ex) { string msg = string.Format("Error RunImport_NewFiles XREF: {0} - {1}", vl.ToStringDetailed(), ex.ToString()); logger.Info(msg); //throw; } } // Steps for processing a file // 1. Check if it is a video file // 2. Check if we have a VideoLocal record for that file // ......... // get a complete list of files List<string> fileList = new List<string>(); ImportFolderRepository repNetShares = new ImportFolderRepository(); foreach (ImportFolder share in repNetShares.GetAll()) { logger.Debug("ImportFolder: {0} || {1}", share.ImportFolderName, share.ImportFolderLocation); try { Utils.GetFilesForImportFolder(share.ImportFolderLocation, ref fileList); } catch (Exception ex) { logger.ErrorException(ex.ToString(), ex); } } // get a list fo files that we haven't processed before List<string> fileListNew = new List<string>(); foreach (string fileName in fileList) { if (!dictFilesExisting.ContainsKey(fileName)) fileListNew.Add(fileName); } // get a list of all the shares we are looking at int filesFound = 0, videosFound = 0; int i = 0; // get a list of all files in the share foreach (string fileName in fileListNew) { i++; filesFound++; logger.Info("Processing File {0}/{1} --- {2}", i, fileList.Count, fileName); if (!FileHashHelper.IsVideo(fileName)) continue; videosFound++; CommandRequest_HashFile cr_hashfile = new CommandRequest_HashFile(fileName, false); cr_hashfile.Save(); } logger.Debug("Found {0} files", filesFound); logger.Debug("Found {0} videos", videosFound); }
public static void RunImport_IntegrityCheck() { VideoLocalRepository repVidLocals = new VideoLocalRepository(); AniDB_FileRepository repAniFile = new AniDB_FileRepository(); AniDB_EpisodeRepository repAniEps = new AniDB_EpisodeRepository(); AniDB_AnimeRepository repAniAnime = new AniDB_AnimeRepository(); // files which don't have a valid import folder List<VideoLocal> filesToDelete = repVidLocals.GetVideosWithoutImportFolder(); foreach (VideoLocal vl in filesToDelete) repVidLocals.Delete(vl.VideoLocalID); // files which have not been hashed yet // or files which do not have a VideoInfo record List<VideoLocal> filesToHash = repVidLocals.GetVideosWithoutHash(); Dictionary<int, VideoLocal> dictFilesToHash = new Dictionary<int, VideoLocal>(); foreach (VideoLocal vl in filesToHash) { dictFilesToHash[vl.VideoLocalID] = vl; CommandRequest_HashFile cmd = new CommandRequest_HashFile(vl.FullServerPath, false); cmd.Save(); } List<VideoLocal> filesToRehash = repVidLocals.GetVideosWithoutVideoInfo(); Dictionary<int, VideoLocal> dictFilesToRehash = new Dictionary<int, VideoLocal>(); foreach (VideoLocal vl in filesToHash) { dictFilesToRehash[vl.VideoLocalID] = vl; // don't use if it is in the previous list if (!dictFilesToHash.ContainsKey(vl.VideoLocalID)) { try { CommandRequest_HashFile cmd = new CommandRequest_HashFile(vl.FullServerPath, false); cmd.Save(); } catch (Exception ex) { string msg = string.Format("Error RunImport_IntegrityCheck XREF: {0} - {1}", vl.ToStringDetailed(), ex.ToString()); logger.Info(msg); } } } // files which have been hashed, but don't have an associated episode List<VideoLocal> filesWithoutEpisode = repVidLocals.GetVideosWithoutEpisode(); Dictionary<int, VideoLocal> dictFilesWithoutEpisode = new Dictionary<int, VideoLocal>(); foreach (VideoLocal vl in filesWithoutEpisode) dictFilesWithoutEpisode[vl.VideoLocalID] = vl; // check that all the episode data is populated List<VideoLocal> filesAll = repVidLocals.GetAll(); Dictionary<string, VideoLocal> dictFilesAllExisting = new Dictionary<string, VideoLocal>(); foreach (VideoLocal vl in filesAll) { try { dictFilesAllExisting[vl.FullServerPath] = vl; } catch (Exception ex) { string msg = string.Format("Error RunImport_IntegrityCheck XREF: {0} - {1}", vl.ToStringDetailed(), ex.ToString()); logger.Error(msg); continue; } // check if it has an episode if (dictFilesWithoutEpisode.ContainsKey(vl.VideoLocalID)) { CommandRequest_ProcessFile cmd = new CommandRequest_ProcessFile(vl.VideoLocalID, false); cmd.Save(); continue; } // if the file is not manually associated, then check for AniDB_File info AniDB_File aniFile = repAniFile.GetByHash(vl.Hash); foreach (CrossRef_File_Episode xref in vl.EpisodeCrossRefs) { if (xref.CrossRefSource != (int)CrossRefSource.AniDB) continue; if (aniFile == null) { CommandRequest_ProcessFile cmd = new CommandRequest_ProcessFile(vl.VideoLocalID, false); cmd.Save(); continue; } } if (aniFile == null) continue; // the cross ref is created before the actually episode data is downloaded // so lets check for that bool missingEpisodes = false; foreach (CrossRef_File_Episode xref in aniFile.EpisodeCrossRefs) { AniDB_Episode ep = repAniEps.GetByEpisodeID(xref.EpisodeID); if (ep == null) missingEpisodes = true; } if (missingEpisodes) { // this will then download the anime etc CommandRequest_ProcessFile cmd = new CommandRequest_ProcessFile(vl.VideoLocalID, false); cmd.Save(); continue; } } }
public static void RunImport_DropFolders() { // get a complete list of files List<string> fileList = new List<string>(); ImportFolderRepository repNetShares = new ImportFolderRepository(); foreach (ImportFolder share in repNetShares.GetAll()) { if (!share.FolderIsDropSource) continue; logger.Debug("ImportFolder: {0} || {1}", share.ImportFolderName, share.ImportFolderLocation); Utils.GetFilesForImportFolder(share.ImportFolderLocation, ref fileList); } // get a list of all the shares we are looking at int filesFound = 0, videosFound = 0; int i = 0; // get a list of all files in the share foreach (string fileName in fileList) { i++; filesFound++; logger.Info("Processing File {0}/{1} --- {2}", i, fileList.Count, fileName); if (!FileHashHelper.IsVideo(fileName)) continue; videosFound++; CommandRequest_HashFile cr_hashfile = new CommandRequest_HashFile(fileName, false); cr_hashfile.Save(); } logger.Debug("Found {0} files", filesFound); logger.Debug("Found {0} videos", videosFound); }
public static void RunImport_ScanFolder(int importFolderID) { // get a complete list of files List<string> fileList = new List<string>(); ImportFolderRepository repFolders = new ImportFolderRepository(); int filesFound = 0, videosFound = 0; int i = 0; try { ImportFolder fldr = repFolders.GetByID(importFolderID); if (fldr == null) return; VideoLocalRepository repVidLocals = new VideoLocalRepository(); // first build a list of files that we already know about, as we don't want to process them again List<VideoLocal> filesAll = repVidLocals.GetAll(); Dictionary<string, VideoLocal> dictFilesExisting = new Dictionary<string, VideoLocal>(); foreach (VideoLocal vl in filesAll) { try { dictFilesExisting[vl.FullServerPath] = vl; } catch (Exception ex) { string msg = string.Format("Error RunImport_ScanFolder XREF: {0} - {1}", vl.ToStringDetailed(), ex.ToString()); logger.Info(msg); } } logger.Debug("ImportFolder: {0} || {1}", fldr.ImportFolderName, fldr.ImportFolderLocation); Utils.GetFilesForImportFolder(fldr.ImportFolderLocation, ref fileList); // get a list of all files in the share foreach (string fileName in fileList) { i++; if (dictFilesExisting.ContainsKey(fileName)) continue; filesFound++; logger.Info("Processing File {0}/{1} --- {2}", i, fileList.Count, fileName); if (!FileHashHelper.IsVideo(fileName)) continue; videosFound++; CommandRequest_HashFile cr_hashfile = new CommandRequest_HashFile(fileName, false); cr_hashfile.Save(); } logger.Debug("Found {0} new files", filesFound); logger.Debug("Found {0} videos", videosFound); } catch (Exception ex) { logger.ErrorException(ex.ToString(), ex); } }
public static void RunImport_ImportFolderNewFiles(ImportFolder fldr) { List<string> fileList = new List<string>(); int filesFound = 0, videosFound = 0; int i = 0; List<VideoLocal_Place> filesAll = RepoFactory.VideoLocalPlace.GetByImportFolder(fldr.ImportFolderID); Utils.GetFilesForImportFolder(fldr.BaseDirectory, ref fileList); HashSet<string> fs = new HashSet<string>(fileList); foreach (VideoLocal_Place v in filesAll) { if (fs.Contains(v.FullServerPath)) fileList.Remove(v.FullServerPath); } // get a list of all files in the share foreach (string fileName in fileList) { i++; filesFound++; logger.Info("Processing File {0}/{1} --- {2}", i, fileList.Count, fileName); if (!FileHashHelper.IsVideo(fileName)) continue; videosFound++; CommandRequest_HashFile cr_hashfile = new CommandRequest_HashFile(fileName, false); cr_hashfile.Save(); } logger.Debug("Found {0} files", filesFound); logger.Debug("Found {0} videos", videosFound); }