コード例 #1
0
        /// <summary>
        /// Submits an uploaded video to the catalog.
        /// </summary>
        public async Task SubmitUploadedVideo(SubmitUploadedVideo uploadedVideo)
        {
            var timestamp = DateTimeOffset.UtcNow;

            // Store the information we have now in Cassandra
            PreparedStatement[] prepared = await _statementCache.NoContext.GetOrAddAllAsync(
                "INSERT INTO videos (videoid, userid, name, description, tags, location_type, added_date) VALUES (?, ?, ?, ?, ?, ?, ?) USING TIMESTAMP ?",
                "INSERT INTO user_videos (userid, added_date, videoid, name) VALUES (?, ?, ?, ?) USING TIMESTAMP ?"
            );

            var batch = new BatchStatement();

            batch.Add(prepared[0].Bind(uploadedVideo.VideoId, uploadedVideo.UserId, uploadedVideo.Name, uploadedVideo.Description,
                                       uploadedVideo.Tags, VideoCatalogConstants.UploadedVideoType, timestamp,
                                       timestamp.ToMicrosecondsSinceEpoch()));
            batch.Add(prepared[1].Bind(uploadedVideo.UserId, timestamp, uploadedVideo.VideoId, uploadedVideo.Name,
                                       timestamp.ToMicrosecondsSinceEpoch()));

            await _session.ExecuteAsync(batch).ConfigureAwait(false);

            // Tell the world we've accepted an uploaded video (it hasn't officially been added until we get a location for the
            // video playback and thumbnail)
            await _bus.Publish(new UploadedVideoAccepted
            {
                VideoId = uploadedVideo.VideoId,
                UploadUrl = uploadedVideo.UploadUrl,
                Timestamp = timestamp
            }).ConfigureAwait(false);
        }
コード例 #2
0
        /// <summary>
        /// Submits an uploaded video to the catalog.
        /// </summary>
        public async Task SubmitUploadedVideo(SubmitUploadedVideo uploadedVideo)
        {
            var timestamp = DateTimeOffset.UtcNow;

            // Store the information we have now in Cassandra
            PreparedStatement[] prepared = await _statementCache.NoContext.GetOrAddAllAsync(
                "INSERT INTO videos (videoid, userid, name, description, tags, location_type, added_date) VALUES (?, ?, ?, ?, ?, ?, ?) USING TIMESTAMP ?",
                "INSERT INTO user_videos (userid, added_date, videoid, name) VALUES (?, ?, ?, ?) USING TIMESTAMP ?"
                );

            var batch = new BatchStatement();

            batch.Add(prepared[0].Bind(uploadedVideo.VideoId, uploadedVideo.UserId, uploadedVideo.Name, uploadedVideo.Description,
                                       uploadedVideo.Tags, VideoCatalogConstants.UploadedVideoType, timestamp,
                                       timestamp.ToMicrosecondsSinceEpoch()));
            batch.Add(prepared[1].Bind(uploadedVideo.UserId, timestamp, uploadedVideo.VideoId, uploadedVideo.Name,
                                       timestamp.ToMicrosecondsSinceEpoch()));

            await _session.ExecuteAsync(batch).ConfigureAwait(false);

            // Tell the world we've accepted an uploaded video (it hasn't officially been added until we get a location for the
            // video playback and thumbnail)
            await _bus.Publish(new UploadedVideoAccepted
            {
                VideoId   = uploadedVideo.VideoId,
                UploadUrl = uploadedVideo.UploadUrl,
                Timestamp = timestamp
            }).ConfigureAwait(false);
        }