public static Domain.Socioboard.Models.LinkedInData GetTopCompanyPagePosts(string PageId, long userId, Helper.Cache _redisCache, Helper.AppSettings _appSettings, Model.DatabaseRepository dbr, int skip, int count) { List <Domain.Socioboard.Models.Mongo.LinkedinCompanyPagePosts> inMemCompanyPagePosts = _redisCache.Get <List <Domain.Socioboard.Models.Mongo.LinkedinCompanyPagePosts> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheLinkedInCompanyPageFeed + PageId); if (inMemCompanyPagePosts != null) { Domain.Socioboard.Models.LinkedInData _LinkedInData = new Domain.Socioboard.Models.LinkedInData(); _LinkedInData._LinkedinCompanyPage = Repositories.LinkedInAccountRepository.getLinkedinCompanyPage(PageId, _redisCache, dbr); _LinkedInData._LinkedinCompanyPagePosts = inMemCompanyPagePosts; return(_LinkedInData); } else { List <Domain.Socioboard.Models.Mongo.LinkedinCompanyPagePosts> lstLinkedinCompanyPagePosts = new List <LinkedinCompanyPagePosts>(); MongoRepository _linkedincompanypagereppo = new MongoRepository("LinkedinCompanyPagePosts", _appSettings); var builder = Builders <LinkedinCompanyPagePosts> .Sort; var sort = builder.Descending(t => t.PostDate); var ret = _linkedincompanypagereppo.FindWithRange <Domain.Socioboard.Models.Mongo.LinkedinCompanyPagePosts>(t => t.PageId.Equals(PageId), sort, 0, 100); var task = Task.Run(async() => { return(await ret); }); lstLinkedinCompanyPagePosts = task.Result.ToList(); if (lstLinkedinCompanyPagePosts.Count > 0) { _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheLinkedInCompanyPageFeed + PageId, lstLinkedinCompanyPagePosts); } Domain.Socioboard.Models.LinkedInData _LinkedInData = new Domain.Socioboard.Models.LinkedInData(); _LinkedInData._LinkedinCompanyPage = Repositories.LinkedInAccountRepository.getLinkedinCompanyPage(PageId, _redisCache, dbr); _LinkedInData._LinkedinCompanyPagePosts = lstLinkedinCompanyPagePosts; return(_LinkedInData); } }
/// <summary> /// /// </summary> /// <param name="userId"></param> /// <param name="redisCache"></param> /// <param name="appSettings"></param> /// <returns></returns> public static List <RssNewsContentsFeeds> GetRssNewsPostedFeeds(string userId, Helper.Cache redisCache, Helper.AppSettings appSettings) { var rssRepository = redisCache.Get <List <RssNewsContentsFeeds> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheTwitterRecent100Feeds + userId); if (rssRepository != null) { return(rssRepository); } var mongodbRssSuppository = new MongoRepository("RssNewsContentsFeeds", appSettings); var builder = Builders <RssNewsContentsFeeds> .Sort; var sort = builder.Descending(t => t.PublishingDate); var result = mongodbRssSuppository.FindWithRange(t => t.UserId.Equals(userId), sort, 0, 200); var task = Task.Run(async() => await result); var lstRss = task.Result; if (lstRss == null) { return(null); } redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheTwitterRecent100Feeds + userId, lstRss.ToList()); return(lstRss.ToList()); }
public static List <Domain.Socioboard.Models.Mongo.InstaFollowerFollowing> getInstafollofollowingReport(string[] profileId, int daysCount, Helper.Cache _redisCache, Helper.AppSettings _appSettings) { MongoRepository mongorepo = new MongoRepository("InstagramDailyReport", _appSettings); List <Domain.Socioboard.Models.Mongo.InstaFollowerFollowing> inMemFacaebookPageDailyReports = _redisCache.Get <List <Domain.Socioboard.Models.Mongo.InstaFollowerFollowing> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheInstagramDailyReport + profileId); if (inMemFacaebookPageDailyReports != null) { return(inMemFacaebookPageDailyReports); } else { List <Domain.Socioboard.Models.Mongo.InstaFollowerFollowing> reportdata = new List <InstaFollowerFollowing>(); DateTime dayStart = new DateTime(DateTime.UtcNow.AddDays(-daysCount).Year, DateTime.UtcNow.AddDays(-daysCount).Month, DateTime.UtcNow.AddDays(-daysCount).Day, 0, 0, 0, DateTimeKind.Utc); DateTime dayEnd = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, 23, 59, 59, DateTimeKind.Utc); var ret = mongorepo.Find <Domain.Socioboard.Models.Mongo.InstagramDailyReport>(t => profileId.Contains(t.profileId) && t.date <= Helper.DateExtension.ConvertToUnixTimestamp(dayEnd) && t.date >= Helper.DateExtension.ConvertToUnixTimestamp(dayStart)); var task = Task.Run(async() => { return(await ret); }); if (task.Result != null) { IList <Domain.Socioboard.Models.Mongo.InstagramDailyReport> lstfbpagereportdata = task.Result.ToList(); var Instapid = lstfbpagereportdata.GroupBy(x => x.profileId).Select(x => x.First()).ToList(); var random = new Random(); foreach (Domain.Socioboard.Models.Mongo.InstagramDailyReport lstcolordata in Instapid) { var randomColor = String.Format("#{0:X6}", random.Next(0x1000000)); Domain.Socioboard.Models.Mongo.InstaFollowerFollowing repo = new InstaFollowerFollowing(); long InstaFollowerCount = lstfbpagereportdata.ToList().Where(t => t.profileId == lstcolordata.profileId).Sum(t => t.followcount); long InstaFollowingCount = lstfbpagereportdata.ToList().Where(t => t.profileId == lstcolordata.profileId).Sum(t => t.followingcount); repo.startdate = dayStart; repo.endtdate = dayEnd; repo.InstaFollowerCounts = InstaFollowerCount; repo.InstaFollowingCounts = InstaFollowingCount; repo.profileId = lstcolordata.profileId; repo.instaName = lstcolordata.instaName; repo.profilepic = lstcolordata.profilePicUrl; repo.colors = Convert.ToString(randomColor); reportdata.Add(repo); } // long TwitterFollowerCount = lstfbpagereportdata.ToList().Where(t => profileId.Contains(t.profileId)).Sum(t => t.followcount); if (lstfbpagereportdata.Count > 0) { _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheInstagramDailyReport + profileId, lstfbpagereportdata.ToList()); } return(reportdata.OrderBy(t => t.startdate).ToList()); // return lstfbpagereportdata.OrderBy(t => t.date).ToList(); } return(new List <Domain.Socioboard.Models.Mongo.InstaFollowerFollowing>()); } }
public static int GetAllSentMessagesCount(long userId, long groupId, Model.DatabaseRepository dbr, Helper.Cache _redisCache) { string[] profileids = null; List <Domain.Socioboard.Models.Groupprofiles> iMmemGroupprofiles = _redisCache.Get <List <Domain.Socioboard.Models.Groupprofiles> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId); List <Domain.Socioboard.Models.Groupprofiles> lstGroupprofiles = new List <Groupprofiles>(); if (iMmemGroupprofiles != null && iMmemGroupprofiles.Count > 0) { lstGroupprofiles = iMmemGroupprofiles; } else { lstGroupprofiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId).ToList(); _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId, lstGroupprofiles); } profileids = lstGroupprofiles.Select(t => t.profileId).ToArray(); List <Domain.Socioboard.Models.ScheduledMessage> lstScheduledMessage = dbr.Find <Domain.Socioboard.Models.ScheduledMessage>(t => profileids.Contains(t.profileId) && t.status == Domain.Socioboard.Enum.ScheduleStatus.Compleated).ToList(); return(lstScheduledMessage.Count); }