/// <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); }
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); }