コード例 #1
0
        public static void updateMongoDbYtGroupsChildComments(Domain.Socioboard.Models.Mongo.MongoYoutubeComments item)
        {
            try
            {
                Helper.DatabaseRepository     dbr               = new Helper.DatabaseRepository();
                Domain.Socioboard.Models.User _SBGrpMember      = dbr.Single <Domain.Socioboard.Models.User>(t => t.Id == Convert.ToInt64(item.sbGrpMemberUserid));
                Domain.Socioboard.Models.User _CmntReviewedById = dbr.Single <Domain.Socioboard.Models.User>(t => t.Id == Convert.ToInt64(item.reviewedBysbUserId));

                if (_SBGrpMember != null)
                {
                    item.sbGrpMemberName  = _SBGrpMember.FirstName + " " + _SBGrpMember.LastName;
                    item.sbGrpMemberEmail = _SBGrpMember.EmailId;
                }
                if (_CmntReviewedById != null)
                {
                    item.reviewedBy = _CmntReviewedById.FirstName + " " + _CmntReviewedById.LastName;
                }

                MongoRepository mongorepo = new MongoRepository("YoutubeVideosCommentsReply");
                try
                {
                    FilterDefinition <BsonDocument> filter = new BsonDocument("commentId", item.commentId);
                    var update = Builders <BsonDocument> .Update.Set("sbGrpMemberName", item.sbGrpMemberName).Set("sbGrpMemberEmail", item.sbGrpMemberEmail).Set("reviewedBy", item.reviewedBy);

                    mongorepo.Update <MongoYoutubeComments>(update, filter);
                }
                catch
                {
                }
            }
            catch
            {
            }
            Console.WriteLine(count++);
        }
コード例 #2
0
        public void CommentsReplies(Domain.Socioboard.Models.Mongo.MongoYoutubeComments itemMainComments)
        {
            string            apiKey = AppSettings.googleApiKey_TestApp;
            oAuthTokenYoutube ObjoAuthTokenYtubes = new oAuthTokenYoutube(AppSettings.googleClientId, AppSettings.googleClientSecret, AppSettings.googleRedirectionUrl);
            oAuthToken        objToken            = new oAuthToken(AppSettings.googleClientId, AppSettings.googleClientSecret, AppSettings.googleRedirectionUrl);
            Video             objVideo            = new Video(AppSettings.googleClientId, AppSettings.googleClientSecret, AppSettings.googleRedirectionUrl);

            try
            {
                string  commentsReply  = objVideo.Get_CommentsRepliesBy_CmParentId(itemMainComments.commentId, apiKey);
                JObject jCommentsReply = JObject.Parse(commentsReply);
                MongoYoutubeComments _ObjMongoYtCommentsReply;
                foreach (var itemReply in jCommentsReply["items"])
                {
                    _ObjMongoYtCommentsReply    = new MongoYoutubeComments();
                    _ObjMongoYtCommentsReply.Id = ObjectId.GenerateNewId();
                    try
                    {
                        _ObjMongoYtCommentsReply.ChannelId = itemMainComments.ChannelId;
                    }
                    catch { }
                    try
                    {
                        _ObjMongoYtCommentsReply.videoId = itemMainComments.videoId;
                    }
                    catch { }
                    try
                    {
                        _ObjMongoYtCommentsReply.commentId = itemReply["id"].ToString();
                    }
                    catch { }
                    try
                    {
                        _ObjMongoYtCommentsReply.authorDisplayName = itemReply["snippet"]["authorDisplayName"].ToString();
                    }
                    catch { }
                    try
                    {
                        _ObjMongoYtCommentsReply.authorProfileImageUrl = itemReply["snippet"]["authorProfileImageUrl"].ToString().Replace(".jpg", "");
                    }
                    catch { }
                    try
                    {
                        _ObjMongoYtCommentsReply.authorChannelUrl = itemReply["snippet"]["authorChannelUrl"].ToString();
                    }
                    catch { }
                    try
                    {
                        _ObjMongoYtCommentsReply.authorChannelId = itemReply["snippet"]["authorChannelId"]["value"].ToString();
                    }
                    catch { }
                    try
                    {
                        _ObjMongoYtCommentsReply.commentDisplay = itemReply["snippet"]["textDisplay"].ToString();
                    }
                    catch { }
                    try
                    {
                        _ObjMongoYtCommentsReply.commentOriginal = itemReply["snippet"]["textOriginal"].ToString();
                    }
                    catch { }
                    try
                    {
                        _ObjMongoYtCommentsReply.viewerRating = itemReply["snippet"]["viewerRating"].ToString();
                    }
                    catch { }
                    try
                    {
                        _ObjMongoYtCommentsReply.likesCount = itemReply["snippet"]["likeCount"].ToString();
                    }
                    catch { }
                    try
                    {
                        _ObjMongoYtCommentsReply.publishTime = itemReply["snippet"]["publishedAt"].ToString();
                    }
                    catch { }
                    try
                    {
                        _ObjMongoYtCommentsReply.publishTimeUnix = UnixTimeFromDatetime(Convert.ToDateTime(_ObjMongoYtCommentsReply.publishTime));
                    }
                    catch { }
                    try
                    {
                        _ObjMongoYtCommentsReply.updatedTime = itemReply["snippet"]["updatedAt"].ToString();
                    }
                    catch { }
                    try
                    {
                        _ObjMongoYtCommentsReply.totalReplyCount = "ReplyType";
                    }
                    catch { }
                    try
                    {
                        _ObjMongoYtCommentsReply.parentIdforReply = itemReply["snippet"]["parentId"].ToString();
                    }
                    catch { }
                    _ObjMongoYtCommentsReply.active          = true;
                    _ObjMongoYtCommentsReply.review          = false;
                    _ObjMongoYtCommentsReply.sbGrpTaskAssign = false;
                    try
                    {
                        _lstGlobalCom.Add(_ObjMongoYtCommentsReply);//Global Type

                        MongoRepository _mongoRepo   = new MongoRepository("YoutubeVideosCommentsReply");
                        var             ret          = _mongoRepo.Find <MongoYoutubeComments>(t => t.commentId.Equals(_ObjMongoYtCommentsReply.commentId));
                        var             task_Reports = Task.Run(async() =>
                        {
                            return(await ret);
                        });
                        int count_Reports = task_Reports.Result.Count;
                        if (count_Reports < 1)
                        {
                            try
                            {
                                _mongoRepo.Add(_ObjMongoYtCommentsReply);
                            }
                            catch { }
                        }
                        else
                        {
                            try
                            {
                                FilterDefinition <BsonDocument> filter = new BsonDocument("commentId", _ObjMongoYtCommentsReply.commentId);
                                var update = Builders <BsonDocument> .Update.Set("commentDisplay", _ObjMongoYtCommentsReply.commentDisplay).Set("commentOriginal", _ObjMongoYtCommentsReply.commentOriginal).Set("publishTimeUnix", _ObjMongoYtCommentsReply.publishTimeUnix);

                                _mongoRepo.Update <MongoYoutubeComments>(update, filter);
                            }
                            catch { }
                        }
                    }
                    catch (Exception ex) { }
                }
            }
            catch
            {
            }
        }