public string ShareFeed(string fbAccesstoken, string FeedId, string pageId, string message, string fbUserId, string FbPageName)
        {
            string ret = "";

            try
            {
                MongoRepository mongorepo = new Helper.MongoRepository("SharethonPagePost");
                Domain.Socioboard.Models.Mongo.SharethonPagePost objshrpost = new Domain.Socioboard.Models.Mongo.SharethonPagePost();
                string link = "https://www.facebook.com/" + pageId + "/posts/" + FeedId;

                FacebookClient fb = new FacebookClient();
                fb.AccessToken = fbAccesstoken;
                var args = new Dictionary <string, object>();

                args["link"] = link;

                var ret1 = mongorepo.Find <Domain.Socioboard.Models.Mongo.SharethonPagePost>(t => t.Facebookaccountid == fbUserId && t.Facebookpageid == pageId && t.PostId == FeedId);
                var task = Task.Run(async() =>
                {
                    return(await ret1);
                });
                int count = task.Result.Count;

                try
                {
                    //if (pageapiHitsCount < pageMaxapiHitsCount)
                    //{
                    dynamic output  = fb.Post("v2.1/" + fbUserId + "/feed", args);
                    string  feed_id = output["id"].ToString();
                    if (!string.IsNullOrEmpty(feed_id))
                    {
                        pageapiHitsCount++;
                    }
                    if (count < 1)
                    {
                        objshrpost.Id = ObjectId.GenerateNewId();
                        objshrpost.Facebookaccountid = fbUserId;
                        objshrpost.Facebookpageid    = pageId;
                        objshrpost.PostId            = FeedId;
                        objshrpost.PostedTime        = SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow);
                        objshrpost.Facebookpagename  = FbPageName;
                        mongorepo.Add <Domain.Socioboard.Models.Mongo.SharethonPagePost>(objshrpost);
                        ret = "success";
                    }
                    // }
                }
                catch (Exception ex)
                {
                    Console.Write(ex.StackTrace);
                    pageapiHitsCount = pageMaxapiHitsCount;
                    return("");
                }

                // }
            }
            catch (Exception ex)
            {
            }
            return(ret);
        }
        public void ShareFeedonGroup(string fbAccesstoken, string FeedId, string pageId, string message, string fbgroupId, int time, string faceaccountId, double lastupdatetime, string Facebooknameid)
        {
            List <string> lstPost = new List <string>();
            int           lstCout = 0;

            string[] feedid = FeedId.TrimEnd(',').Split(',');
            string[] grpid  = Facebooknameid.TrimEnd(',').Split(',');
            Random   r      = new Random();
            int      length = feedid.Length;

            Domain.Socioboard.Models.Mongo.SharethonGroupPost objshrgrp = new Domain.Socioboard.Models.Mongo.SharethonGroupPost();
            MongoRepository mongorepo = new Helper.MongoRepository("SharethonGroupPost");

            while (length >= lstCout)
            {
                int i = r.Next(0, length - 1);
                if (!lstPost.Contains(feedid[i]))
                {
                    lstPost.Add(feedid[i]);
                    lstCout++;
                    foreach (var item in grpid)
                    {
                        string[] grpdata = Regex.Split(item, "<:>");
                        var      ret1    = mongorepo.Find <Domain.Socioboard.Models.Mongo.SharethonGroupPost>(t => t.Facebookgroupid == grpdata[1] && t.PostId == FeedId[i].ToString());
                        var      task    = Task.Run(async() =>
                        {
                            return(await ret1);
                        });
                        int count = task.Result.Count;


                        string         link = "https://www.facebook.com/" + pageId + "/posts/" + feedid[i];
                        FacebookClient fb   = new FacebookClient();
                        fb.AccessToken = fbAccesstoken;
                        var args = new Dictionary <string, object>();
                        args["link"] = link;
                        try
                        {
                            dynamic output = fb.Post("v2.7/" + grpdata[1] + "/feed", args);
                            try
                            {
                                string feed_id = output["id"].ToString();
                                if (!string.IsNullOrEmpty(feed_id))
                                {
                                    groupapiHitsCount++;
                                }
                            }
                            catch (Exception)
                            {
                                groupapiHitsCount = groupMaxapiHitsCount;
                            }
                            if (count < 1)
                            {
                                objshrgrp.Id = ObjectId.GenerateNewId();
                                objshrgrp.Facebookaccountid = faceaccountId;
                                objshrgrp.Facebookgroupid   = grpdata[1];
                                objshrgrp.Facebookgroupname = grpdata[0];
                                objshrgrp.PostId            = feedid[i];
                                objshrgrp.PostedTime        = SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow);
                                mongorepo.Add <Domain.Socioboard.Models.Mongo.SharethonGroupPost>(objshrgrp);
                            }
                        }
                        catch (Exception ex)
                        {
                            groupapiHitsCount = groupMaxapiHitsCount;
                        }
                    }
                    Thread.Sleep(1000 * 50);
                }
                Thread.Sleep(1000 * 60 * time);
            }
        }