Ejemplo n.º 1
0
        public async Task <bool> UpdateVideoIndexStatusAsync(Common.Global.Enums.VideoIndexStatus videoIndexStatus,
                                                             CancellationToken cancellationToken,
                                                             params string[] videoIds)
        {
            var query = this.FairplaytubeDatabaseContext.VideoInfo
                        .Include(p => p.ApplicationUser).Where(p => videoIds.Contains(p.VideoId));

            foreach (var singleVideoEntity in query)
            {
                var singleVideoIndex = await this.AzureVideoIndexerService
                                       .GetVideoIndexAsync(singleVideoEntity.VideoId, cancellationToken);

                singleVideoEntity.VideoIndexSourceClass  = this.GetType().FullName;
                singleVideoEntity.VideoIndexStatusId     = (short)videoIndexStatus;
                singleVideoEntity.VideoDurationInSeconds = singleVideoIndex.summarizedInsights.duration.seconds;
            }
            await this.FairplaytubeDatabaseContext.SaveChangesAsync(cancellationToken : cancellationToken);

            foreach (var singleVideoEntity in query)
            {
                await NotifyVideoOwnerAsync(singleVideoEntity);

                if (singleVideoEntity.VideoVisibilityId == (short)Common.Global.Enums.VideoVisibility.Public)
                {
                    //await NotifyFollowersAsync(singleVideoEntity);
                    await NotifyAllUsersAsync(singleVideoEntity, cancellationToken);
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        private static void SeedDefaultVideoIndexStatuses(FairplaytubeDatabaseContext fairplaytubeDatabaseContext,
                                                          Common.Global.Enums.VideoIndexStatus videoIndexStatus)
        {
            var videoIndexStatusEntity = fairplaytubeDatabaseContext.VideoIndexStatus
                                         .SingleOrDefault(p => p.Name == videoIndexStatus.ToString());

            if (videoIndexStatusEntity == null)
            {
                videoIndexStatusEntity = new VideoIndexStatus()
                {
                    Name = videoIndexStatus.ToString(),
                    VideoIndexStatusId = (short)videoIndexStatus
                };
                fairplaytubeDatabaseContext.VideoIndexStatus.Add(videoIndexStatusEntity);
                fairplaytubeDatabaseContext.SaveChanges();
            }
        }