public static bool addGplusContentfeedsdata(string keywords, string userId)
        {
            MongoRepository mongorepo = new MongoRepository("RssNewsContentsFeeds");
            bool            output    = false;

            try
            {
                string  searchResultObj = GplusTagSearch.GooglePlusgetUserRecentActivitiesByHashtag(keywords);
                JObject GplusActivities = JObject.Parse(GplusTagSearch.GooglePlusgetUserRecentActivitiesByHashtag(keywords));

                foreach (JObject obj in JArray.Parse(GplusActivities["items"].ToString()))
                {
                    RssNewsContentsFeeds contentGFeedsDet = new RssNewsContentsFeeds();
                    contentGFeedsDet.Id = ObjectId.GenerateNewId();

                    try
                    {
                        foreach (JObject att in JArray.Parse(obj["object"]["attachments"].ToString()))
                        {
                            contentGFeedsDet.Image = att["fullImage"]["url"].ToString();

                            contentGFeedsDet.Link = att["url"].ToString();

                            contentGFeedsDet.Title = att["displayName"].ToString();
                        }
                    }
                    catch { }
                    try
                    {
                        contentGFeedsDet.PublishingDate = Domain.Socioboard.Helpers.SBHelper.ConvertToUnixTimestamp(DateTime.Parse(obj["published"].ToString())).ToString();
                    }
                    catch { }


                    contentGFeedsDet.UserId   = userId;
                    contentGFeedsDet.keywords = keywords;
                    var ret  = mongorepo.Find <RssNewsContentsFeeds>(t => t.Title == contentGFeedsDet.Title);
                    var task = Task.Run(async() =>
                    {
                        return(await ret);
                    });
                    int count = task.Result.Count;
                    if (count < 1)
                    {
                        try
                        {
                            mongorepo.Add <RssNewsContentsFeeds>(contentGFeedsDet);
                            output = true;
                        }
                        catch { }
                    }
                }
                return(output);
            }
            catch { }

            return(output);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="GplusTagId"></param>
        /// <param name="BoardId"></param>
        /// <param name="_redisCache"></param>
        /// <param name="settings"></param>
        /// <param name="_logger"></param>
        /// <returns></returns>
        public static List <MongoBoardGplusFeeds> AddBoardGplusTagFeeds(string GplusTagId, string BoardId, Helper.AppSettings settings, ILogger _logger)
        {
            MongoRepository             boardrepo  = new MongoRepository("MongoBoardGplusFeeds", settings);
            List <MongoBoardGplusFeeds> GplusFeeds = new List <MongoBoardGplusFeeds>();

            try
            {
                JObject RecentActivities = JObject.Parse(GplusTagSearch.GooglePlusgetUserRecentActivitiesByHashtag(GplusTagId, settings.GoogleApiKey));
                foreach (JObject obj in RecentActivities["items"])
                {
                    MongoBoardGplusFeeds bgpfeed = new MongoBoardGplusFeeds();
                    bgpfeed.Id = ObjectId.GenerateNewId();
                    bgpfeed.Gplusboardaccprofileid = BoardId;
                    try
                    {
                        bgpfeed.Feedlink = obj["url"].ToString();
                    }
                    catch { }
                    try
                    {
                        foreach (JObject att in JArray.Parse(obj["object"]["attachments"].ToString()))
                        {
                            if (att["objectType"].ToString().Equals("photo"))
                            {
                                bgpfeed.Imageurl = att["fullImage"]["url"].ToString() + ",";
                            }
                        }
                    }
                    catch { }
                    try
                    {
                        bgpfeed.Publishedtime = Domain.Socioboard.Helpers.SBHelper.ConvertToUnixTimestamp(DateTime.Parse(obj["published"].ToString()));
                    }
                    catch { }
                    try
                    {
                        bgpfeed.Title = obj["title"].ToString();
                    }
                    catch { }
                    try
                    {
                        bgpfeed.Feedid = obj["id"].ToString();
                    }
                    catch { }
                    try
                    {
                        bgpfeed.FromId = obj["actor"]["id"].ToString();
                    }
                    catch { }
                    try
                    {
                        bgpfeed.FromName = obj["actor"]["displayName"].ToString();
                    }
                    catch { }
                    try
                    {
                        bgpfeed.FromPicUrl = obj["actor"]["image"]["url"].ToString();
                    }
                    catch { }
                    GplusFeeds.Add(bgpfeed);
                }
                try
                {
                    boardrepo.AddList <MongoBoardGplusFeeds>(GplusFeeds);
                }
                catch { }
            }
            catch { }
            return(GplusFeeds);
        }
Example #3
0
        public bool AddBoardGplusTagFeeds(string GplusTagId, string BoardId)
        {
            MongoRepository boardrepo = new MongoRepository("MongoBoardGplusFeeds");
            bool            output    = false;

            try
            {
                JObject RecentActivities = JObject.Parse(GplusTagSearch.GooglePlusgetUserRecentActivitiesByHashtag(GplusTagId));
                foreach (JObject obj in RecentActivities["items"])
                {
                    MongoBoardGplusFeeds bgpfeed = new MongoBoardGplusFeeds();
                    bgpfeed.Id = ObjectId.GenerateNewId();
                    bgpfeed.Gplusboardaccprofileid = BoardId;
                    try
                    {
                        bgpfeed.Feedlink = obj["url"].ToString();
                    }
                    catch { }
                    try
                    {
                        foreach (JObject att in JArray.Parse(obj["object"]["attachments"].ToString()))
                        {
                            if (att["objectType"].ToString().Equals("photo"))
                            {
                                bgpfeed.Imageurl = att["fullImage"]["url"].ToString() + ",";
                            }
                        }
                    }
                    catch { }
                    try
                    {
                        bgpfeed.Publishedtime = Domain.Socioboard.Helpers.SBHelper.ConvertToUnixTimestamp(DateTime.Parse(obj["published"].ToString()));
                    }
                    catch { }
                    try
                    {
                        bgpfeed.Title = obj["title"].ToString();
                    }
                    catch { }
                    try
                    {
                        bgpfeed.Feedid = obj["id"].ToString();
                    }
                    catch { }
                    try
                    {
                        bgpfeed.FromId = obj["actor"]["id"].ToString();
                    }
                    catch { }
                    try
                    {
                        bgpfeed.FromName = obj["actor"]["displayName"].ToString();
                    }
                    catch { }
                    try
                    {
                        bgpfeed.FromPicUrl = obj["actor"]["image"]["url"].ToString();
                    }
                    catch { }

                    var ret  = boardrepo.Find <MongoBoardGplusFeeds>(t => t.Feedid == bgpfeed.Feedid);
                    var task = Task.Run(async() =>
                    {
                        return(await ret);
                    });
                    int count = task.Result.Count;
                    if (count < 1)
                    {
                        try
                        {
                            boardrepo.Add <MongoBoardGplusFeeds>(bgpfeed);
                        }
                        catch { }
                    }
                }
            }
            catch { }



            return(output);
        }