public void GetPostCommentGraphApi(string html, ref GlobusHttpHelper objGlobusHttpHelper, string pageid, string UserId)
        {
            #region variables region
            string posthtml = string.Empty;
            string posturl = string.Empty;
            string post = string.Empty;
            int like = 0;
            int comment = 0;
            int share = 0;
            string commentid = string.Empty;
            string commentmsg = string.Empty;
            string commentfrom_id = string.Empty;
            string commentfrom_name = string.Empty;
            string commentcreated_time = string.Empty;
            string commentlike_count = string.Empty;
            string user_likes = string.Empty;
            string like_id = string.Empty;
            string like_name = string.Empty;
            DateTime postdate = new DateTime();
            string linkurl = string.Empty;
            string pictureurl = string.Empty;
            string statustype = string.Empty;
            string type = string.Empty;
            string fromname = string.Empty;
            //string pageid = string.Empty;
            string fromid = string.Empty;
            string getlikecomment = string.Empty;
            string postid = string.Empty;
            string iconurl = string.Empty;
            #endregion
            try 
	        {
                Domain.Myfashion.Domain.FbPagePost _fbpagepost = new Domain.Myfashion.Domain.FbPagePost();
		        getlikecomment = socioHelper.getBetween(html, "[{\"actorforpost\":", "{\"value\":\"filtered\"");
                postid = socioHelper.getBetween(html, "targetfbid\":\"", "\",\"viewercanlike\":");
                string grafurl = "http://graph.facebook.com/" + postid;
                posthtml = objGlobusHttpHelper.getHtmlfromUrl(new Uri(grafurl));
                try
                {
                    like = Int32.Parse(socioHelper.getBetween(html, "likecount\":", ",\"likecountreduced"));
                    comment = Int32.Parse(socioHelper.getBetween(html, "commentcount\":", ",\"commentcountreduced"));
                    share = Int32.Parse(socioHelper.getBetween(html, "sharecount\":", ",\"sharecountreduced"));
                    //posturl = socioHelper.getBetween(html, "permalink\":\"", "/?").Replace(@"\", "");
                    posturl = socioHelper.getBetween(html, "permalink\":\"", "\"").Replace(@"\", "");
                    if(posturl=="")
                    {
                        posturl = socioHelper.getBetween(html, "permalink\":\"", "\"").Replace(@"\", "");
                    }
                    _fbpagepost.UserId = Guid.Parse(UserId);
                    _fbpagepost.Id = Guid.NewGuid();
                    _fbpagepost.PageId = pageid;
                    _fbpagepost.Likes = like;
                    _fbpagepost.Comments = comment;
                    _fbpagepost.Shares = share;
                    _fbpagepost.PostId = postid;
                    _fbpagepost.StatusType = "shared_story";
                }
                catch (Exception ex)
                {
                    posturl = "https://www.facebook.com/"+postid;
                }
                if (posthtml != "")
                {
                    JObject JData = JObject.Parse(posthtml);
                    try
                    {
                        fromid = JData["from"]["id"].ToString().Replace("\"", string.Empty).Trim();
                        _fbpagepost.FromId = fromid;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        iconurl = JData["icon"].ToString().Replace("\"", string.Empty).Trim();
                        _fbpagepost.IconUrl = iconurl;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        linkurl = JData["link"].ToString().Replace("\"", string.Empty).Trim();
                        if (linkurl.Contains("album"))
                        {
                            _fbpagepost.Type = "album";
                        }
                      _fbpagepost.LinkUrl = linkurl;
                    }
                    catch { }
                    try
                    {
                        post = JData["name"].ToString().Replace("\"", string.Empty).Trim();
                        _fbpagepost.Post = post;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        post = "";
                    }
                    try
                    {
                        fromname = JData["from"]["name"].ToString().Replace("\"", string.Empty).Trim();
                        _fbpagepost.FromName = fromname;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        pictureurl = JData["source"].ToString().Replace("\"", string.Empty).Trim();
                        if (pictureurl != "")
                        {
                            _fbpagepost.Type = "photo";
                            _fbpagepost.StatusType = "added_photos";
                        }
                        _fbpagepost.PictureUrl = pictureurl;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        string pdate = (JData["created_time"].ToString().Replace("\"", string.Empty).Replace("T", " ").Trim());
                        if (pdate.Contains("+"))
                        {
                            pdate = pdate.Substring(0, pdate.IndexOf("+"));
                        }
                        postdate = DateTime.Parse(pdate);
                        _fbpagepost.PostDate = postdate;
                        _fbpagepost.EntryDate = DateTime.Now;
                    }
                    catch { }
                    string JsonObjectOfFbPagePostWithValue = new JavaScriptSerializer().Serialize(_fbpagepost);
                    Api.FbPagePost.FbPagePost objApiFbPagePost = new Api.FbPagePost.FbPagePost();
                    if (!objApiFbPagePost.IsPostExist(JsonObjectOfFbPagePostWithValue))
                    {
                        bool IspostAdd = objApiFbPagePost.AddPostDetails(JsonObjectOfFbPagePostWithValue);
                    }
                    else
                    {
                        int isPostUpdate = objApiFbPagePost.UpdateFbPagePostStatus(JsonObjectOfFbPagePostWithValue);
                    }
                    if (comment != 0)
                    {
                        #region GetComments
                        try
                        {
                            
                            var Comments = JData["comments"]["data"];
                            string Comment_next = string.Empty;
                            try
                            {
                                Comment_next = JData["comments"]["paging"]["next"].ToString().Replace("\"", string.Empty);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.StackTrace);
                                Comment_next = "";
                            }
                        getComments:
                            foreach (var _Commentitem in Comments)
                            {
                                try
                                {
                                    Domain.Myfashion.Domain.FbPageComment _FbPageComment = new Domain.Myfashion.Domain.FbPageComment();
                                    int isuserlike=0;
                                    commentid = _Commentitem["id"].ToString().Replace("\"", string.Empty).Trim();
                                    commentmsg = _Commentitem["message"].ToString().Replace("\"", string.Empty).Trim();
                                    commentfrom_id = _Commentitem["from"]["id"].ToString().Replace("\"", string.Empty).Trim();
                                    commentfrom_name = _Commentitem["from"]["name"].ToString().Replace("\"", string.Empty).Trim();
                                    commentcreated_time = _Commentitem["created_time"].ToString().Replace("\"", string.Empty).Trim();
                                    try
                                    {
                                        if (commentcreated_time.Contains("+"))
                                        {
                                            commentcreated_time = commentcreated_time.Substring(0, commentcreated_time.IndexOf("+"));
                                        }
                                        DateTime comment_date = DateTime.Parse(commentcreated_time);
                                        _FbPageComment.Commentdate = comment_date;
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.Write(ex.StackTrace);
                                    }
                                    commentlike_count = _Commentitem["like_count"].ToString().Replace("\"", string.Empty).Trim();
                                    user_likes = _Commentitem["user_likes"].ToString().Replace("\"", string.Empty).Trim();
                                    if(user_likes=="False")
                                    {
                                        isuserlike=0;
                                    }
                                    else{ isuserlike=1; }
                                    _FbPageComment.Id = Guid.NewGuid();
                                    _FbPageComment.UserId =Guid.Parse(UserId);
                                    _FbPageComment.PostId = postid;
                                    _FbPageComment.Likes =Int32.Parse(commentlike_count);
                                    _FbPageComment.UserLikes = isuserlike;
                                    
                                    _FbPageComment.CommentId = commentid;
                                    _FbPageComment.FromId = commentfrom_id;
                                    _FbPageComment.FromName = commentfrom_name;
                                    _FbPageComment.PictureUrl = commentid;
                                    _FbPageComment.Comment = commentmsg;
                                    _FbPageComment.EntryDate = DateTime.Now;
                                    string JsonObjectOfFbPageCommentWithValue = new JavaScriptSerializer().Serialize(_FbPageComment);
                                    Api.FbPageComment.FbPageComment objApiFbPageComment = new Api.FbPageComment.FbPageComment();
                                    if (!objApiFbPageComment.IsCommentExist(JsonObjectOfFbPageCommentWithValue))
                                    {
                                        bool iscmtAdd = objApiFbPageComment.AddCommentDetails(JsonObjectOfFbPageCommentWithValue);
                                    }
                                    else
                                    {
                                        int isCmtUpdate = objApiFbPageComment.UpdateFbPageCommentStatus(JsonObjectOfFbPageCommentWithValue);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.StackTrace);
                                }

                            }

                            if (!string.IsNullOrEmpty(Comment_next))
                            {
                                string commentpagesrc = objGlobusHttpHelper.getHtmlfromUrl(new Uri(Comment_next));
                                JObject JData_Comment_next = JObject.Parse(commentpagesrc);
                                Comments = JData_Comment_next["data"];
                                try
                                {
                                    Comment_next = JData_Comment_next["paging"]["next"].ToString().Replace("\"", string.Empty).Trim();
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.StackTrace);
                                    Comment_next = "";
                                }
                                goto getComments;
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        #endregion
                    }
                    if (like != 0)
                    {
                        #region GetLikes
                        try
                        {
                            
                            var Likes = JData["likes"]["data"];
                            string Likes_next = string.Empty;
                            try
                            {
                                Likes_next = JData["likes"]["paging"]["next"].ToString().Replace("\"", string.Empty);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.StackTrace);
                                Likes_next = "";
                            }
                        getLikes:
                            foreach (var _Likeitem in Likes)
                            {
                                try
                                {
                                    Domain.Myfashion.Domain.FbPageLiker _FbPageLiker = new Domain.Myfashion.Domain.FbPageLiker();
                                    like_id = _Likeitem["id"].ToString().Replace("\"", string.Empty).Trim();
                                    like_name = _Likeitem["name"].ToString().Replace("\"", string.Empty).Trim();
                                    _FbPageLiker.Id = Guid.NewGuid();
                                    _FbPageLiker.UserId = Guid.Parse(UserId);
                                    _FbPageLiker.PostId = postid;
                                    _FbPageLiker.FromId = like_id;
                                    _FbPageLiker.FromName = like_name;
                                    string JsonObjectOfFbPageLikerWithValue = new JavaScriptSerializer().Serialize(_FbPageLiker);
                                    Api.FbPageLiker.FbPageLiker objApiFbPageLiker = new Api.FbPageLiker.FbPageLiker();
                                    if (!objApiFbPageLiker.IsLikeExist(JsonObjectOfFbPageLikerWithValue))
                                    {
                                        bool IslikeAdd = objApiFbPageLiker.AddLikeDetails(JsonObjectOfFbPageLikerWithValue);
                                    }
                                }
                                catch { };
                            }
                            if (!string.IsNullOrEmpty(Likes_next))
                            {
                                string likepagesrc = objGlobusHttpHelper.getHtmlfromUrl(new Uri(Likes_next));
                                JObject JData_Like_next = JObject.Parse(likepagesrc);
                                Likes = JData_Like_next["data"];
                                try
                                {
                                    Likes_next = JData_Like_next["paging"]["next"].ToString().Replace("\"", string.Empty).Trim();
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.StackTrace);
                                    Likes_next = "";
                                }
                                goto getLikes;
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        #endregion
                    }
                }
                else
                {
                    GetPostCommentParsing(posturl, ref objGlobusHttpHelper,pageid,UserId);

                } 
	}
	catch (Exception ex)
	{
        Console.WriteLine(ex.StackTrace);
	}
   }
        public void GetPostCommentParsing(string posturl, ref GlobusHttpHelper objGlobusHttpHelper, string pageid, string UserId)
        {
            #region Variables resion
            string posthtml = string.Empty;
            string posturl1 = string.Empty;
            string post = string.Empty;
            int like = 0;
            string like_id = string.Empty;
            string like_name = string.Empty;
            int comment = 0;
            string commentid = string.Empty;
            string commentmsg = string.Empty;
            string commentcreated_time = string.Empty;
            string commentlike_count = string.Empty;
            string user_likes = string.Empty;
            int share = 0;
            string post_date = string.Empty;
            string linkurl = string.Empty;
            string pictureurl = string.Empty;
            string statustype = string.Empty;
            string type = string.Empty;
            string fromname = string.Empty;
            string postid = posturl.Split('/')[posturl.Split('/').Count() - 1].ToString();
            //string postid = string.Empty;
            string userid = string.Empty;
            string fromid = string.Empty;
            string getlikecomment = string.Empty;
            DateTime comment_date = new DateTime();
            #endregion
            if (posturl.Contains("https:"))
            {
                posturl1 = posturl;
            }
            else
            {
                posturl1 = "https://www.facebook.com" + posturl;
            }
            try
            {
                Domain.Myfashion.Domain.FbPagePost _fbpagepost = new Domain.Myfashion.Domain.FbPagePost();
                _fbpagepost.Type = "status";
                _fbpagepost.StatusType = "shared_story";
                posthtml = objGlobusHttpHelper.getHtmlfromUrl(new Uri(posturl1));
                //post = socioHelper.getBetween(posthtml, "class=\"hasCaption\">", "<i class=\"_4-k1 img sp_LWp1MpKGrs1 sx_35a5d8").Replace("<br />", " ");
                string post1 = socioHelper.getBetween(posthtml, "<p>", "<form rel=\"async").Replace("See Translation","");
                post = Regex.Replace(post1, "<[^>]+>|&nbsp;", "");
                try
                {
                    pictureurl = socioHelper.getBetween(posthtml, "scaledImageFitWidth img\" src=\"", "\" alt=\"").Replace("amp;", "");
                    if (pictureurl != "")
                    {
                        _fbpagepost.Type = "photo";
                        _fbpagepost.StatusType = "added_photos";
                    }
                    if (post == "" && pictureurl == "")
                    {
                        pictureurl = socioHelper.getBetween(posthtml, "scaledImageFitHeight img\" src=\"", "\" style=").Replace("amp;", "");
                        _fbpagepost.Type = "link";
                    }
                    if (post1.Contains("LinkshimAsyncLink"))
                    {
                        _fbpagepost.Type = "link";
                    }
                }
                catch (Exception ex)
                {

                }
                getlikecomment = socioHelper.getBetween(posthtml, "feedbacktargets\":", "mentionsdatasource\":");
                like = Int32.Parse(socioHelper.getBetween(getlikecomment, "likecount\":", ",\"likecountreduce"));
                comment = Int32.Parse(socioHelper.getBetween(getlikecomment, "commentcount\":", ",\"commentcountreduce"));
                share = Int32.Parse(socioHelper.getBetween(posthtml, "sharecount\":", ",\"sharecountreduced"));
                try
                {
                    post_date = socioHelper.getBetween(posthtml, "<abbr title=\"", "\" data-utime=").Replace(" at","").Trim();
                    DateTime post_date1 = DateTime.Parse(post_date);
                    _fbpagepost.PostDate = post_date1;
                }
                catch { }
                fromid = socioHelper.getBetween(posthtml, "actorid\":\"", "\",\"");
                if (!string.IsNullOrEmpty(fromid))
                {
                    try
                    {
                        var _FromDetails = JObject.Parse(objGlobusHttpHelper.getHtmlfromUrl(new Uri("http://graph.facebook.com/" + fromid)));
                        fromname = _FromDetails["name"].ToString().ToString().Replace("\"", string.Empty).Trim(); ;
                        _fbpagepost.FromName = fromname;
                        string from_Username = _FromDetails["username"].ToString().ToString().Replace("\"", string.Empty).Trim();
                    }
                    catch { };
                }
                _fbpagepost.UserId = Guid.Parse(UserId);
                _fbpagepost.Id = Guid.NewGuid();
                _fbpagepost.PageId = pageid;
                _fbpagepost.Likes = like;
                _fbpagepost.Comments = comment;
                _fbpagepost.Shares = share;
                _fbpagepost.FromId = fromid;
                
                _fbpagepost.Post = post;
                _fbpagepost.PostId = postid;
                _fbpagepost.PictureUrl = pictureurl;
                _fbpagepost.LinkUrl = posturl1;
                _fbpagepost.EntryDate = DateTime.Now;
                
                string JsonObjectOfFbPagePostWithValue =new JavaScriptSerializer().Serialize(_fbpagepost);
                Api.FbPagePost.FbPagePost objApiFbPagePost = new Api.FbPagePost.FbPagePost();
                if (!objApiFbPagePost.IsPostExist(JsonObjectOfFbPagePostWithValue))
                {
                    bool IspostAdd = objApiFbPagePost.AddPostDetails(JsonObjectOfFbPagePostWithValue);
                }
                else
                {
                    int isPostUpdate = objApiFbPagePost.UpdateFbPagePostStatus(JsonObjectOfFbPagePostWithValue);
                }
                JObject jobjectdata = JObject.Parse("{\"comments\":" + socioHelper.getBetween(posthtml, ",\"comments\":", ",\"actions\":[]") + "}");
                try
                {
                    var Comments = jobjectdata["comments"];
                    foreach (var _Commentitem in Comments)
                    {
                        int isuserlike = 0;
                        Domain.Myfashion.Domain.FbPageComment _FbPageComment = new Domain.Myfashion.Domain.FbPageComment();
                        string commentfrom_id = string.Empty;
                        string commentfrom_name = string.Empty;
                        commentid = _Commentitem["id"].ToString().Replace("\"", string.Empty).Trim();
                        commentmsg = _Commentitem["body"]["text"].ToString().Replace("\"", string.Empty).Trim();
                        commentfrom_id = _Commentitem["author"].ToString().Replace("\"", string.Empty).Trim();
                        if (!string.IsNullOrEmpty(commentfrom_id))
                        {
                            try
                            {
                                var _autherDetails = JObject.Parse(objGlobusHttpHelper.getHtmlfromUrl(new Uri("http://graph.facebook.com/" + commentfrom_id)));
                                commentfrom_name = _autherDetails["name"].ToString().ToString().Replace("\"", string.Empty).Trim(); ;
                                string commentfrom_Username = _autherDetails["username"].ToString().ToString().Replace("\"", string.Empty).Trim();
                            }
                            catch { };
                        }
                        try
                        {
                            commentcreated_time = _Commentitem["timestamp"]["verbose"].ToString().Replace("\"", string.Empty).Replace("at ", string.Empty).Trim();
                            comment_date = DateTime.Parse(commentcreated_time);
                        }
                        catch { };
                        commentlike_count = _Commentitem["likecount"].ToString().Replace("\"", string.Empty).Trim();
                        user_likes = _Commentitem["hasviewerliked"].ToString().Replace("\"", string.Empty).Trim();
                        if (user_likes == "False")
                        {
                            isuserlike = 0;
                        }
                        else { isuserlike = 1; }
                        _FbPageComment.Id = Guid.NewGuid();
                        _FbPageComment.UserId = Guid.Parse(UserId);
                        _FbPageComment.PostId = postid;
                        _FbPageComment.Likes = Int32.Parse(commentlike_count);
                        _FbPageComment.UserLikes = isuserlike;
                        _FbPageComment.Commentdate = comment_date;
                        _FbPageComment.CommentId = commentid;
                        _FbPageComment.FromId = commentfrom_id;
                        _FbPageComment.FromName = commentfrom_name;
                        _FbPageComment.PictureUrl = commentid;
                        _FbPageComment.Comment = commentmsg;
                        _FbPageComment.EntryDate = DateTime.Now;
                        string JsonObjectOfFbPageCommentWithValue =new JavaScriptSerializer().Serialize(_FbPageComment);
                        Api.FbPageComment.FbPageComment objApiFbPageComment = new Api.FbPageComment.FbPageComment();
                        if (!objApiFbPageComment.IsCommentExist(JsonObjectOfFbPageCommentWithValue))
                        {
                            bool iscmtAdd = objApiFbPageComment.AddCommentDetails(JsonObjectOfFbPageCommentWithValue);
                        }
                        else 
                        {
                            int isCmtUpdate = objApiFbPageComment.UpdateFbPageCommentStatus(JsonObjectOfFbPageCommentWithValue);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }

                try
                {
                    
                    //string likerurl = "https://www.facebook.com/ajax/browser/dialog/likes?id=" + postid + "&actorid=" + pageid + "&__asyncDialog=1&__user="******"&__a=1&__dyn=7n8ajEBQ9FoBZypQ9UoHFaeFDzECiq78hACF3pqzCC-C26m6oKezpUgDyQqUgF5BzEy6E&__req=28&__rev=1461180";
                    string likerurl = "https://www.facebook.com/ajax/browser/dialog/likes?id=" + postid + "&actorid=" + pageid + "&__asyncDialog=1&__user="******"&__a=1&__dyn=7nmajEyl2lm9o-t2u59G85ku699Esx6iqAdy9VQC-C26m6oKezob4q68K5Uc-dwIxbxjyV8izaG8Czrw&__req=1r&__rev=1696458&ft[tn]=]&ft[fbfeed_location]=5";
                    string likerhtml = objGlobusHttpHelper.getHtmlfromUrl(new Uri(likerurl));
                    string[] splitliker = Regex.Split(likerhtml, "_s0 _rw img");
                    foreach (string liker_item in splitliker)
                    {
                        if (!liker_item.Contains("for (;;);"))
                        {
                            Domain.Myfashion.Domain.FbPageLiker _FbPageLiker = new Domain.Myfashion.Domain.FbPageLiker();
                            like_id = socioHelper.getBetween(liker_item, "data-hovercard=\\\"\\/ajax\\/hovercard\\/user.php?id=", "&amp;extragetparams");
                            string[] splitliker1 = Regex.Split(liker_item, "hc_location=profile_browser");
                            like_name = socioHelper.getBetween(splitliker1[1], "\\\">", "\\u003C");
                            _FbPageLiker.Id = Guid.NewGuid();
                            _FbPageLiker.UserId = Guid.Parse(UserId);
                            _FbPageLiker.PostId = postid;
                            _FbPageLiker.FromId = like_id;
                            _FbPageLiker.FromName = like_name;
                            string JsonObjectOfFbPageLikerWithValue = new JavaScriptSerializer().Serialize(_FbPageLiker);
                            Api.FbPageLiker.FbPageLiker objApiFbPageLiker = new Api.FbPageLiker.FbPageLiker();
                            if (!objApiFbPageLiker.IsLikeExist(JsonObjectOfFbPageLikerWithValue))
                            {
                                bool IslikeAdd = objApiFbPageLiker.AddLikeDetails(JsonObjectOfFbPageLikerWithValue);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }

        }