public void Save(AniDB_ReleaseGroup obj)
		{
			using (var session = JMMService.SessionFactory.OpenSession())
			{
				// populate the database
				using (var transaction = session.BeginTransaction())
				{
					session.SaveOrUpdate(obj);
					transaction.Commit();
				}
			}
		}
Beispiel #2
0
        public Contract_VideoDetailed ToContractDetailed(int userID)
        {
            Contract_VideoDetailed contract = new Contract_VideoDetailed();

            // get the cross ref episode
            List <CrossRef_File_Episode> xrefs = this.EpisodeCrossRefs;

            if (xrefs.Count == 0)
            {
                return(null);
            }

            contract.Percentage     = xrefs[0].Percentage;
            contract.EpisodeOrder   = xrefs[0].EpisodeOrder;
            contract.CrossRefSource = xrefs[0].CrossRefSource;
            contract.AnimeEpisodeID = xrefs[0].EpisodeID;

            contract.VideoLocal_FileName    = this.FileName;
            contract.VideoLocal_Hash        = this.Hash;
            contract.VideoLocal_FileSize    = this.FileSize;
            contract.VideoLocalID           = this.VideoLocalID;
            contract.VideoLocal_IsIgnored   = this.IsIgnored;
            contract.VideoLocal_IsVariation = this.IsVariation;
            contract.Places = Places.Select(a => a.ToContract()).ToList();

            contract.VideoLocal_MD5        = this.MD5;
            contract.VideoLocal_SHA1       = this.SHA1;
            contract.VideoLocal_CRC32      = this.CRC32;
            contract.VideoLocal_HashSource = this.HashSource;

            VideoLocal_User userRecord = this.GetUserRecord(userID);

            if (userRecord?.WatchedDate == null)
            {
                contract.VideoLocal_IsWatched      = 0;
                contract.VideoLocal_WatchedDate    = null;
                contract.VideoLocal_ResumePosition = 0;
            }
            else
            {
                contract.VideoLocal_IsWatched   = userRecord.WatchedDate.HasValue ? 1 : 0;
                contract.VideoLocal_WatchedDate = userRecord.WatchedDate;
            }
            if (userRecord != null)
            {
                contract.VideoLocal_ResumePosition = userRecord.ResumePosition;
            }
            contract.VideoInfo_AudioBitrate    = AudioBitrate;
            contract.VideoInfo_AudioCodec      = AudioCodec;
            contract.VideoInfo_Duration        = Duration;
            contract.VideoInfo_VideoBitrate    = VideoBitrate;
            contract.VideoInfo_VideoBitDepth   = VideoBitDepth;
            contract.VideoInfo_VideoCodec      = VideoCodec;
            contract.VideoInfo_VideoFrameRate  = VideoFrameRate;
            contract.VideoInfo_VideoResolution = VideoResolution;

            // AniDB File
            AniDB_File anifile = this.GetAniDBFile(); // to prevent multiple db calls

            if (anifile != null)
            {
                contract.AniDB_Anime_GroupName      = anifile.Anime_GroupName;
                contract.AniDB_Anime_GroupNameShort = anifile.Anime_GroupNameShort;
                contract.AniDB_AnimeID              = anifile.AnimeID;
                contract.AniDB_CRC                  = anifile.CRC;
                contract.AniDB_Episode_Rating       = anifile.Episode_Rating;
                contract.AniDB_Episode_Votes        = anifile.Episode_Votes;
                contract.AniDB_File_AudioCodec      = anifile.File_AudioCodec;
                contract.AniDB_File_Description     = anifile.File_Description;
                contract.AniDB_File_FileExtension   = anifile.File_FileExtension;
                contract.AniDB_File_LengthSeconds   = anifile.File_LengthSeconds;
                contract.AniDB_File_ReleaseDate     = anifile.File_ReleaseDate;
                contract.AniDB_File_Source          = anifile.File_Source;
                contract.AniDB_File_VideoCodec      = anifile.File_VideoCodec;
                contract.AniDB_File_VideoResolution = anifile.File_VideoResolution;
                contract.AniDB_FileID               = anifile.FileID;
                contract.AniDB_GroupID              = anifile.GroupID;
                contract.AniDB_MD5                  = anifile.MD5;
                contract.AniDB_SHA1                 = anifile.SHA1;
                contract.AniDB_File_FileVersion     = anifile.FileVersion;

                // languages
                contract.LanguagesAudio    = anifile.LanguagesRAW;
                contract.LanguagesSubtitle = anifile.SubtitlesRAW;
            }
            else
            {
                contract.AniDB_Anime_GroupName      = "";
                contract.AniDB_Anime_GroupNameShort = "";
                contract.AniDB_CRC                  = "";
                contract.AniDB_File_AudioCodec      = "";
                contract.AniDB_File_Description     = "";
                contract.AniDB_File_FileExtension   = "";
                contract.AniDB_File_Source          = "";
                contract.AniDB_File_VideoCodec      = "";
                contract.AniDB_File_VideoResolution = "";
                contract.AniDB_MD5                  = "";
                contract.AniDB_SHA1                 = "";
                contract.AniDB_File_FileVersion     = 1;

                // languages
                contract.LanguagesAudio    = "";
                contract.LanguagesSubtitle = "";
            }


            AniDB_ReleaseGroup relGroup = this.ReleaseGroup; // to prevent multiple db calls

            if (relGroup != null)
            {
                contract.ReleaseGroup = relGroup.ToContract();
            }
            else
            {
                contract.ReleaseGroup = null;
            }
            contract.Media = GetMediaFromUser(userID);
            return(contract);
        }
Beispiel #3
0
		// NO LONGER USED
		/*public AniDB_Seiyuu GetCreatorInfoUDP(int creatorID)
		{
			if (!Login()) return null;

			enHelperActivityType ev = enHelperActivityType.NoSuchCreator;
			AniDBCommand_GetCreatorInfo getCreatorCmd = null;
			lock (lockAniDBConnections)
			{
				Pause();

				getCreatorCmd = new AniDBCommand_GetCreatorInfo();
				getCreatorCmd.Init(creatorID, true);
				ev = getCreatorCmd.Process(ref soUdp, ref remoteIpEndPoint, curSessionID, new UnicodeEncoding(true, false));
			}

			AniDB_Seiyuu chr = null;
			if (ev == enHelperActivityType.GotCreatorInfo && getCreatorCmd.CreatorInfo != null)
			{
				AniDB_CreatorRepository repCreator = new AniDB_CreatorRepository();
				chr = repCreator.GetByCreatorID(creatorID);
				if (chr == null) chr = new AniDB_Seiyuu();

				chr.Populate(getCreatorCmd.CreatorInfo);
				repCreator.Save(chr);
			}

			return chr;
		}*/

		public AniDB_ReleaseGroup GetReleaseGroupUDP(int groupID)
		{
			if (!Login()) return null;

			enHelperActivityType ev = enHelperActivityType.NoSuchGroup;
			AniDBCommand_GetGroup getCmd = null;
			lock (lockAniDBConnections)
			{
				Pause();

				getCmd = new AniDBCommand_GetGroup();
				getCmd.Init(groupID);
				SetWaitingOnResponse(true);
				ev = getCmd.Process(ref soUdp, ref remoteIpEndPoint, curSessionID, new UnicodeEncoding(true, false));
				SetWaitingOnResponse(false);
			}

			AniDB_ReleaseGroupRepository repRelGrp = new AniDB_ReleaseGroupRepository();
			AniDB_ReleaseGroup relGroup = null;
			if (ev == enHelperActivityType.GotGroup && getCmd.Group != null)
			{
				relGroup = repRelGrp.GetByGroupID(groupID);
				if (relGroup == null) relGroup = new AniDB_ReleaseGroup();

				relGroup.Populate(getCmd.Group);
				repRelGrp.Save(relGroup);
			}

			return relGroup;
		}
Beispiel #4
0
        public Contract_VideoDetailed ToContractDetailed(int userID)
        {
            Contract_VideoDetailed contract = new Contract_VideoDetailed();

            // get the cross ref episode
            List <CrossRef_File_Episode> xrefs = this.EpisodeCrossRefs;

            if (xrefs.Count == 0)
            {
                return(null);
            }

            contract.Percentage     = xrefs[0].Percentage;
            contract.EpisodeOrder   = xrefs[0].EpisodeOrder;
            contract.CrossRefSource = xrefs[0].CrossRefSource;
            contract.AnimeEpisodeID = xrefs[0].EpisodeID;

            contract.VideoLocal_FilePath    = this.FilePath;
            contract.VideoLocal_Hash        = this.Hash;
            contract.VideoLocal_FileSize    = this.FileSize;
            contract.VideoLocalID           = this.VideoLocalID;
            contract.VideoLocal_IsIgnored   = this.IsIgnored;
            contract.VideoLocal_IsVariation = this.IsVariation;

            contract.VideoLocal_MD5        = this.MD5;
            contract.VideoLocal_SHA1       = this.SHA1;
            contract.VideoLocal_CRC32      = this.CRC32;
            contract.VideoLocal_HashSource = this.HashSource;

            VideoLocal_User userRecord = this.GetUserRecord(userID);

            if (userRecord == null)
            {
                contract.VideoLocal_IsWatched = 0;
            }
            else
            {
                contract.VideoLocal_IsWatched = 1;
            }

            // Import Folder
            ImportFolder ns = this.ImportFolder;             // to prevent multiple db calls

            if (ns != null)
            {
                contract.ImportFolderID       = ns.ImportFolderID;
                contract.ImportFolderLocation = ns.ImportFolderLocation;
                contract.ImportFolderName     = ns.ImportFolderName;
            }

            // video info
            VideoInfo vi = this.VideoInfo;             // to prevent multiple db calls

            if (vi != null)
            {
                contract.VideoInfo_AudioBitrate    = vi.AudioBitrate;
                contract.VideoInfo_AudioCodec      = vi.AudioCodec;
                contract.VideoInfo_Duration        = vi.Duration;
                contract.VideoInfo_VideoBitrate    = vi.VideoBitrate;
                contract.VideoInfo_VideoBitDepth   = vi.VideoBitDepth;
                contract.VideoInfo_VideoCodec      = vi.VideoCodec;
                contract.VideoInfo_VideoFrameRate  = vi.VideoFrameRate;
                contract.VideoInfo_VideoResolution = vi.VideoResolution;
                contract.VideoInfo_VideoInfoID     = vi.VideoInfoID;
            }

            // AniDB File
            AniDB_File anifile = this.GetAniDBFile();             // to prevent multiple db calls

            if (anifile != null)
            {
                contract.AniDB_Anime_GroupName      = anifile.Anime_GroupName;
                contract.AniDB_Anime_GroupNameShort = anifile.Anime_GroupNameShort;
                contract.AniDB_AnimeID              = anifile.AnimeID;
                contract.AniDB_CRC                  = anifile.CRC;
                contract.AniDB_Episode_Rating       = anifile.Episode_Rating;
                contract.AniDB_Episode_Votes        = anifile.Episode_Votes;
                contract.AniDB_File_AudioCodec      = anifile.File_AudioCodec;
                contract.AniDB_File_Description     = anifile.File_Description;
                contract.AniDB_File_FileExtension   = anifile.File_FileExtension;
                contract.AniDB_File_LengthSeconds   = anifile.File_LengthSeconds;
                contract.AniDB_File_ReleaseDate     = anifile.File_ReleaseDate;
                contract.AniDB_File_Source          = anifile.File_Source;
                contract.AniDB_File_VideoCodec      = anifile.File_VideoCodec;
                contract.AniDB_File_VideoResolution = anifile.File_VideoResolution;
                contract.AniDB_FileID               = anifile.FileID;
                contract.AniDB_GroupID              = anifile.GroupID;
                contract.AniDB_MD5                  = anifile.MD5;
                contract.AniDB_SHA1                 = anifile.SHA1;
                contract.AniDB_File_FileVersion     = anifile.FileVersion;

                // languages
                contract.LanguagesAudio    = anifile.LanguagesRAW;
                contract.LanguagesSubtitle = anifile.SubtitlesRAW;
            }
            else
            {
                contract.AniDB_Anime_GroupName      = "";
                contract.AniDB_Anime_GroupNameShort = "";
                contract.AniDB_CRC                  = "";
                contract.AniDB_File_AudioCodec      = "";
                contract.AniDB_File_Description     = "";
                contract.AniDB_File_FileExtension   = "";
                contract.AniDB_File_Source          = "";
                contract.AniDB_File_VideoCodec      = "";
                contract.AniDB_File_VideoResolution = "";
                contract.AniDB_MD5                  = "";
                contract.AniDB_SHA1                 = "";
                contract.AniDB_File_FileVersion     = 1;

                // languages
                contract.LanguagesAudio    = "";
                contract.LanguagesSubtitle = "";
            }



            AniDB_ReleaseGroup relGroup = this.ReleaseGroup;             // to prevent multiple db calls

            if (relGroup != null)
            {
                contract.ReleaseGroup = relGroup.ToContract();
            }
            else
            {
                contract.ReleaseGroup = null;
            }

            return(contract);
        }
Beispiel #5
0
        public List <Contract_VideoDetailed> GetVideoDetailedContracts(int userID)
        {
            VideoLocalRepository          repVids   = new VideoLocalRepository();
            List <Contract_VideoDetailed> contracts = new List <Contract_VideoDetailed>();

            // get all the cross refs
            foreach (CrossRef_File_Episode xref in FileCrossRefs)
            {
                Contract_VideoDetailed contract = new Contract_VideoDetailed();
                contract.Percentage     = xref.Percentage;
                contract.EpisodeOrder   = xref.EpisodeOrder;
                contract.CrossRefSource = xref.CrossRefSource;
                contract.AnimeEpisodeID = this.AnimeEpisodeID;

                // get the video file
                // we will assume that it is unique by hash/episodeid
                VideoLocal vid = repVids.GetByHash(xref.Hash);
                if (vid != null)
                {
                    contract.VideoLocal_FilePath = vid.FilePath;
                    contract.VideoLocal_Hash     = vid.Hash;
                    contract.VideoLocal_FileSize = vid.FileSize;
                    contract.VideoLocalID        = vid.VideoLocalID;

                    contract.VideoLocal_MD5        = vid.MD5;
                    contract.VideoLocal_SHA1       = vid.SHA1;
                    contract.VideoLocal_CRC32      = vid.CRC32;
                    contract.VideoLocal_HashSource = vid.HashSource;

                    VideoLocal_User vidUser = vid.GetUserRecord(userID);
                    //AnimeEpisode_User userRecord = this.GetUserRecord(userID);
                    if (vidUser == null)
                    {
                        contract.VideoLocal_IsWatched   = 0;
                        contract.VideoLocal_WatchedDate = null;
                    }
                    else
                    {
                        contract.VideoLocal_IsWatched   = 1;
                        contract.VideoLocal_WatchedDate = vidUser.WatchedDate;
                    }
                    contract.VideoLocal_IsIgnored   = vid.IsIgnored;
                    contract.VideoLocal_IsVariation = vid.IsVariation;

                    // Import Folder
                    ImportFolder ns = vid.ImportFolder;                     // to prevent multiple db calls
                    contract.ImportFolderID       = ns.ImportFolderID;
                    contract.ImportFolderLocation = ns.ImportFolderLocation;
                    contract.ImportFolderName     = ns.ImportFolderName;

                    // video info
                    VideoInfo vi = vid.VideoInfo;                     // to prevent multiple db calls
                    contract.VideoInfo_AudioBitrate    = vi.AudioBitrate;
                    contract.VideoInfo_AudioCodec      = vi.AudioCodec;
                    contract.VideoInfo_Duration        = vi.Duration;
                    contract.VideoInfo_VideoBitrate    = vi.VideoBitrate;
                    contract.VideoInfo_VideoBitDepth   = vi.VideoBitDepth;
                    contract.VideoInfo_VideoCodec      = vi.VideoCodec;
                    contract.VideoInfo_VideoFrameRate  = vi.VideoFrameRate;
                    contract.VideoInfo_VideoResolution = vi.VideoResolution;
                    contract.VideoInfo_VideoInfoID     = vi.VideoInfoID;

                    // AniDB File
                    AniDB_File anifile = vid.GetAniDBFile();                     // to prevent multiple db calls
                    if (anifile != null)
                    {
                        contract.AniDB_Anime_GroupName      = anifile.Anime_GroupName;
                        contract.AniDB_Anime_GroupNameShort = anifile.Anime_GroupNameShort;
                        contract.AniDB_AnimeID              = anifile.AnimeID;
                        contract.AniDB_CRC                  = anifile.CRC;
                        contract.AniDB_Episode_Rating       = anifile.Episode_Rating;
                        contract.AniDB_Episode_Votes        = anifile.Episode_Votes;
                        contract.AniDB_File_AudioCodec      = anifile.File_AudioCodec;
                        contract.AniDB_File_Description     = anifile.File_Description;
                        contract.AniDB_File_FileExtension   = anifile.File_FileExtension;
                        contract.AniDB_File_LengthSeconds   = anifile.File_LengthSeconds;
                        contract.AniDB_File_ReleaseDate     = anifile.File_ReleaseDate;
                        contract.AniDB_File_Source          = anifile.File_Source;
                        contract.AniDB_File_VideoCodec      = anifile.File_VideoCodec;
                        contract.AniDB_File_VideoResolution = anifile.File_VideoResolution;
                        contract.AniDB_FileID               = anifile.FileID;
                        contract.AniDB_GroupID              = anifile.GroupID;
                        contract.AniDB_MD5                  = anifile.MD5;
                        contract.AniDB_SHA1                 = anifile.SHA1;
                        contract.AniDB_File_FileVersion     = anifile.FileVersion;
                        contract.AniDB_File_IsCensored      = anifile.IsCensored;
                        contract.AniDB_File_IsDeprecated    = anifile.IsDeprecated;
                        contract.AniDB_File_InternalVersion = anifile.InternalVersion;

                        // languages
                        contract.LanguagesAudio    = anifile.LanguagesRAW;
                        contract.LanguagesSubtitle = anifile.SubtitlesRAW;
                    }
                    else
                    {
                        contract.AniDB_Anime_GroupName      = "";
                        contract.AniDB_Anime_GroupNameShort = "";
                        contract.AniDB_CRC                  = "";
                        contract.AniDB_File_AudioCodec      = "";
                        contract.AniDB_File_Description     = "";
                        contract.AniDB_File_FileExtension   = "";
                        contract.AniDB_File_Source          = "";
                        contract.AniDB_File_VideoCodec      = "";
                        contract.AniDB_File_VideoResolution = "";
                        contract.AniDB_MD5                  = "";
                        contract.AniDB_SHA1                 = "";
                        contract.AniDB_File_FileVersion     = 1;

                        // languages
                        contract.LanguagesAudio    = "";
                        contract.LanguagesSubtitle = "";
                    }



                    AniDB_ReleaseGroup relGroup = vid.ReleaseGroup;                     // to prevent multiple db calls
                    if (relGroup != null)
                    {
                        contract.ReleaseGroup = relGroup.ToContract();
                    }
                    else
                    {
                        contract.ReleaseGroup = null;
                    }

                    contracts.Add(contract);
                }
            }


            return(contracts);
        }