public IActionResult Login(UserLoginViewModel user) { try { User inMemUser = _redisCache.Get <User>(user.UserName); // User inMemUser = (User)_memoryCache.Get(user.UserName); if (inMemUser != null) { if (inMemUser.Password.Equals(SBHelper.MD5Hash(user.Password))) { return(Ok(inMemUser)); } else { return(Ok("Wrong Password")); } } } catch (Exception ex) { _logger.LogInformation(ex.Message); _logger.LogError(ex.StackTrace); } DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); IList <User> lstUser = dbr.Find <User>(t => t.EmailId.Equals(user.UserName)); if (lstUser != null && lstUser.Count() > 0) { if (lstUser.First().Password != null && lstUser.First().Password.Equals(SBHelper.MD5Hash(user.Password))) { DateTime d1 = DateTime.UtcNow; //User userTable = dbr.Single < User>(t => t.EmailId == user.UserName); lstUser.First().LastLoginTime = d1; //userTable.LastLoginTime = d1; dbr.Update <User>(lstUser.First()); // _memoryCache.Set(lstUser.First().EmailId, lstUser.First()); _redisCache.Set <User>(lstUser.First().EmailId, lstUser.First()); if (lstUser.First().ActivationStatus == Domain.Socioboard.Enum.SBUserActivationStatus.Active) { return(Ok(lstUser.First())); } else { return(Ok("Account not activated.")); } } else { return(Ok("Wrong Password")); } } else { return(Ok("EmailId Not Exist")); } }
public static Domain.Socioboard.Models.LinkedinCompanyPage getLinkedinCompanyPage(string LICompanyPageUserId, Helper.Cache _redisCache, Model.DatabaseRepository dbr) { try { Domain.Socioboard.Models.LinkedinCompanyPage inMemLiAcc = _redisCache.Get <Domain.Socioboard.Models.LinkedinCompanyPage>(Domain.Socioboard.Consatants.SocioboardConsts.CacheLinkedInCompanyPage + LICompanyPageUserId); if (inMemLiAcc != null) { return(inMemLiAcc); } } catch { } try { List <Domain.Socioboard.Models.LinkedinCompanyPage> lstLiAcc = dbr.Find <Domain.Socioboard.Models.LinkedinCompanyPage>(t => t.LinkedinPageId.Equals(LICompanyPageUserId) && t.IsActive).ToList(); if (lstLiAcc != null) { _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheLinkedInCompanyPage + LICompanyPageUserId, lstLiAcc.First()); return(lstLiAcc.First()); } else { return(null); } } catch (Exception ex) { return(null); } }
public static List <Domain.Socioboard.Models.Mongo.intafeed> GetInstagramFeeds(string instagramId, Helper.AppSettings _appSettings, Helper.Cache _redisCache) { List <Domain.Socioboard.Models.Mongo.intafeed> lstintafeed = new List <Domain.Socioboard.Models.Mongo.intafeed>(); List <Domain.Socioboard.Models.Mongo.InstagramFeed> iMmemInstagramFeed = _redisCache.Get <List <Domain.Socioboard.Models.Mongo.InstagramFeed> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheInstagramFeed + instagramId); MongoRepository InstagramFeedRepo = new MongoRepository("InstagramFeed", _appSettings); var ret = InstagramFeedRepo.Find <Domain.Socioboard.Models.Mongo.InstagramFeed>(t => t.InstagramId.Equals(instagramId)); var task = Task.Run(async() => { return(await ret); }); IList <Domain.Socioboard.Models.Mongo.InstagramFeed> _lstInstagramFeed = task.Result; var sortt = _lstInstagramFeed.OrderByDescending(t => t.FeedDate); _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheInstagramFeed + instagramId, sortt.ToList()); foreach (var item in sortt.ToList()) { Domain.Socioboard.Models.Mongo.intafeed _intafeed = new Domain.Socioboard.Models.Mongo.intafeed(); MongoRepository InstagramCommentRepo = new MongoRepository("InstagramComment", _appSettings); var ret1 = InstagramCommentRepo.Find <Domain.Socioboard.Models.Mongo.InstagramComment>(t => t.FeedId.Equals(item.FeedId)); var taskq = Task.Run(async() => { return(await ret1); }); IList <Domain.Socioboard.Models.Mongo.InstagramComment> _lstInstagramComment = taskq.Result; _intafeed._InstagramFeed = item; _intafeed._InstagramComment = _lstInstagramComment.ToList(); lstintafeed.Add(_intafeed); } return(lstintafeed); }
/// <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 MongoBoards getBoardByName(string boardName, Helper.Cache _redisCache, Helper.AppSettings _appSettings, ILogger _logger) { MongoRepository boardrepo = new MongoRepository("MongoBoards", _appSettings); try { MongoBoards inMemboard = _redisCache.Get <MongoBoards>(Domain.Socioboard.Consatants.SocioboardConsts.CacheBoard + boardName); if (inMemboard != null) { return(inMemboard); } else { var result = boardrepo.Find <MongoBoards>(t => t.boardName.Equals(boardName) && t.isActive == true); var task = Task.Run(async() => { return(await result); }); MongoBoards board = task.Result.First(); return(board); } } catch (Exception ex) { _logger.LogError(ex.StackTrace); return(null); } }
public static List <Domain.Socioboard.Models.ScheduledMessage> DeleteSocialMessages(long socioqueueId, long userId, long GroupId, Helper.Cache _redisCache, Helper.AppSettings _appSeetings, Model.DatabaseRepository dbr) { string[] profileids = null; Domain.Socioboard.Models.ScheduledMessage ScheduledMessage = dbr.Find <Domain.Socioboard.Models.ScheduledMessage>(t => t.id == socioqueueId).FirstOrDefault(); ScheduledMessage.status = Domain.Socioboard.Enum.ScheduleStatus.Deleted; dbr.Update <Domain.Socioboard.Models.ScheduledMessage>(ScheduledMessage); 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 == 0).ToList(); if (lstScheduledMessage != null && lstScheduledMessage.Count > 0) { _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheScheduleMessage + GroupId, lstScheduledMessage); return(lstScheduledMessage); } else { return(null); } }
public static List <GoogleAnalyticsReport> getGoogleAnalyticsReportData(string profileId, int daysCount, Helper.Cache _redisCache, Helper.AppSettings _appSettings) { var mongorepo = new MongoRepository("GoogleAnalyticsReport", _appSettings); var inMemGoogleAnalyticsDailyReports = _redisCache.Get <List <GoogleAnalyticsReport> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheGoogleAnalyticsReport + profileId); if (inMemGoogleAnalyticsDailyReports != null) { return(inMemGoogleAnalyticsDailyReports); } if (daysCount == -1) { var ret = mongorepo.Find <GoogleAnalyticsReport>(t => t.GaProfileId == profileId); var task = Task.Run(async() => { return(await ret); }); if (task.Result == null) { return(new List <GoogleAnalyticsReport>()); } var lstGoogleAnalyticsReport = task.Result.ToList(); if (lstGoogleAnalyticsReport.Count > 0) { _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheGoogleAnalyticsReport + profileId, lstGoogleAnalyticsReport.ToList()); } return(lstGoogleAnalyticsReport.ToList()); } else { var dayStart = new DateTime(DateTime.UtcNow.AddDays(-90).Year, DateTime.UtcNow.AddDays(-90).Month, DateTime.UtcNow.AddDays(-90).Day, 0, 0, 0, DateTimeKind.Utc); var dayEnd = new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, 23, 59, 59, DateTimeKind.Utc); var ret = mongorepo.Find <GoogleAnalyticsReport>(t => t.GaProfileId == profileId && t.date <= DateExtension.ConvertToUnixTimestamp(dayEnd) && t.date >= DateExtension.ConvertToUnixTimestamp(dayStart)); var task = Task.Run(async() => { return(await ret); }); if (task.Result != null) { var lstGoogleAnalyticsReport = task.Result.ToList(); if (lstGoogleAnalyticsReport.Count > 0) { _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheGoogleAnalyticsReport + profileId, lstGoogleAnalyticsReport.ToList()); } return(lstGoogleAnalyticsReport.ToList()); } } return(new List <GoogleAnalyticsReport>()); }
public static List <Domain.Socioboard.Models.ScheduledMessage> GetAllSentMessages(long userId, long groupId, Helper.Cache _redisCache, Helper.AppSettings _appSeetings, Model.DatabaseRepository dbr) { string[] profileids = null; List <Domain.Socioboard.Models.ScheduledMessage> inMemScheduleMessgae = _redisCache.Get <List <Domain.Socioboard.Models.ScheduledMessage> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheSentMessages + groupId); if (inMemScheduleMessgae != null && inMemScheduleMessgae.Count > 0) { return(inMemScheduleMessgae); } else { 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(); if (lstScheduledMessage != null && lstScheduledMessage.Count > 0) { var ListSrted = lstScheduledMessage.OrderByDescending(t => t.scheduleTime).Take(200); _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheSentMessages + groupId, ListSrted.ToList()); return(ListSrted.ToList()); } else { return(null); } } }
public static List <Domain.Socioboard.Models.ScheduledMessage> getAllSentMessageDetailsForCustomrange(long userId, long groupId, DateTime sdate, DateTime ldate, Helper.Cache _redisCache, Helper.AppSettings _appSeetings, Model.DatabaseRepository dbr) { string[] profileids = null; List <Domain.Socioboard.Models.ScheduledMessage> inMemScheduleMessgae = _redisCache.Get <List <Domain.Socioboard.Models.ScheduledMessage> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheSentMessageDetailsForCustomrange + groupId); if (inMemScheduleMessgae != null && inMemScheduleMessgae.Count > 0) { return(inMemScheduleMessgae); } else { 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).Where(a => a.scheduleTime.Date >= sdate && a.scheduleTime.Date <= ldate).ToList(); if (lstScheduledMessage != null && lstScheduledMessage.Count > 0) { _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheSentMessageDetailsForCustomrange + groupId, lstScheduledMessage); return(lstScheduledMessage); } else { return(null); } } }
public static List <Domain.Socioboard.Models.Groupmembers> findmember(long SBgroupId, long userId, Helper.Cache _redisCache, Model.DatabaseRepository dbr) { try { List <Domain.Socioboard.Models.Groupmembers> inMemGroupMembers = _redisCache.Get <List <Domain.Socioboard.Models.Groupmembers> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupMembers + userId); if (inMemGroupMembers != null) { return(inMemGroupMembers); } } catch { } List <Domain.Socioboard.Models.Groupmembers> groupMembers = dbr.Find <Domain.Socioboard.Models.Groupmembers>(t => t.userId == userId && t.groupid != SBgroupId).ToList(); _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupMembers + userId, groupMembers); return(groupMembers); }
public static List <Domain.Socioboard.Models.Groupprofiles> getGroupProfiles(long groupId, Helper.Cache _redisCache, Helper.DatabaseRepository dbr) { try { List <Domain.Socioboard.Models.Groupprofiles> inMemGroupProfiles = _redisCache.Get <List <Domain.Socioboard.Models.Groupprofiles> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId); if (inMemGroupProfiles != null) { return(inMemGroupProfiles); } } catch { } List <Domain.Socioboard.Models.Groupprofiles> groupProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId).ToList(); _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId, groupProfiles); return(groupProfiles); }
public static int getAllProfilesCountOfUser(Int64 userId, Helper.Cache _redisCache, Model.DatabaseRepository dbr) { try { string inMemProfilesCount = _redisCache.Get <string>(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId); if (inMemProfilesCount != null) { return(Convert.ToInt32(inMemProfilesCount)); } } catch { } int groupProfilesCount = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.profileOwnerId == userId).GroupBy(t => t.profileId).Select(x => x.First()).Count(); _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId, groupProfilesCount.ToString()); return(groupProfilesCount); }
public static List <Domain.Socioboard.Models.Groups> getGroupsofUser(long userId, Helper.Cache _redisCache, Model.DatabaseRepository dbr) { try { List <Domain.Socioboard.Models.Groups> inMemGroups = _redisCache.Get <List <Domain.Socioboard.Models.Groups> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserGroups + userId); if (inMemGroups != null) { return(inMemGroups); } } catch { } List <long> lstGroupIds = dbr.Find <Domain.Socioboard.Models.Groupmembers>(t => t.userId == userId && t.memberStatus == Domain.Socioboard.Enum.GroupMemberStatus.Accepted && t.isAdmin == false).Select(t => t.groupid).ToList(); List <Domain.Socioboard.Models.Groups> groups = dbr.Find <Domain.Socioboard.Models.Groups>(t => lstGroupIds.Contains(t.id)).ToList(); _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserGroups + userId, groups); return(groups); }
public static List <Domain.Socioboard.Models.Affiliates> GetAffilieteDetailbyUserId(long userId, Model.DatabaseRepository dbr, Helper.Cache _redisCache) { List <Domain.Socioboard.Models.Affiliates> inMemAffiliates = _redisCache.Get <List <Domain.Socioboard.Models.Affiliates> >(Domain.Socioboard.Consatants.SocioboardConsts.Affiliates + userId); if (inMemAffiliates != null) { return(inMemAffiliates); } else { List <Domain.Socioboard.Models.Affiliates> lstAffiliates = dbr.Find <Domain.Socioboard.Models.Affiliates>(t => t.UserId == userId).ToList(); if (lstAffiliates != null) { _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.Affiliates + userId, lstAffiliates); } return(lstAffiliates); } }
public static List <Helper.DiscoverySmart> TwitterTweetSearchWithGeoLocation(string searchkeyword, string geoLocation, Helper.Cache _redisCache) { List <Helper.DiscoverySmart> iMmemDiscoverySmart = _redisCache.Get <List <Helper.DiscoverySmart> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheTwitterTweetSearchWithGeoLocation + searchkeyword + geoLocation); if (iMmemDiscoverySmart != null) { return(iMmemDiscoverySmart); } else { List <Helper.DiscoverySmart> lstDiscoverySmart = Helper.TwitterHelper.TwitterTweetSearchWithGeoLocation(searchkeyword, geoLocation); if (lstDiscoverySmart.Count > 0 && lstDiscoverySmart != null) { _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheTwitterTweetSearchWithGeoLocation + searchkeyword + geoLocation, lstDiscoverySmart); } return(lstDiscoverySmart); } }
public static string TwitterUserFollow(string profileId, string toTwitterUserId, Model.DatabaseRepository dbr, ILogger _logger, Helper.Cache _redisCache, Helper.AppSettings _appSettings) { Domain.Socioboard.Models.TwitterAccount twtacc = new Domain.Socioboard.Models.TwitterAccount(); Domain.Socioboard.Models.TwitterAccount imtwtacc = _redisCache.Get <Domain.Socioboard.Models.TwitterAccount>(Domain.Socioboard.Consatants.SocioboardConsts.CacheTwitterAccount + profileId); if (imtwtacc == null) { twtacc = dbr.Find <Domain.Socioboard.Models.TwitterAccount>(t => t.twitterUserId.Equals(profileId)).FirstOrDefault(); if (twtacc != null) { _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheTwitterAccount + profileId, twtacc); } } else { twtacc = imtwtacc; } oAuthTwitter oAuth = new oAuthTwitter(_appSettings.twitterConsumerKey, _appSettings.twitterConsumerScreatKey, _appSettings.twitterRedirectionUrl); oAuth.AccessToken = twtacc.oAuthToken; oAuth.AccessTokenSecret = twtacc.oAuthSecret; oAuth.TwitterScreenName = twtacc.twitterScreenName; oAuth.TwitterUserId = twtacc.twitterUserId; FollowerManage follow_obj = new FollowerManage(); try { string followUserResp = follow_obj.FollowUserByUserId(oAuth, toTwitterUserId); if (followUserResp != "") { return("User followed successfully"); } else { return("Issue in user following"); } } catch (Exception ex) { _logger.LogError("user following" + ex.StackTrace); _logger.LogError("user following" + ex.Message); return("api issue while user following"); } }
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); }
public static List <Domain.Socioboard.Models.Draft> getUsreDraftMessage(long userId, long GroupId, Helper.Cache _redisCache, Helper.AppSettings _appSeetings, Model.DatabaseRepository dbr) { List <Domain.Socioboard.Models.Draft> inMemDraftMessgae = _redisCache.Get <List <Domain.Socioboard.Models.Draft> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheDraftMessage + userId); if (inMemDraftMessgae != null && inMemDraftMessgae.Count > 0) { return(inMemDraftMessgae); } else { List <Domain.Socioboard.Models.Draft> lstDraftMessage = dbr.Find <Domain.Socioboard.Models.Draft>(t => t.userId == userId && t.GroupId == GroupId).ToList(); if (lstDraftMessage != null && lstDraftMessage.Count > 0) { _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheDraftMessage + userId, lstDraftMessage); return(lstDraftMessage); } else { return(null); } } }
public static List <MongoTwitterDailyReports> GetTwitterMessageReports(string profileId, int dayCount, Helper.Cache _redisCache, Helper.AppSettings settings) { List <MongoTwitterDailyReports> inMemReports = _redisCache.Get <List <MongoTwitterDailyReports> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheTwitterMessageReportsByProfileId + profileId); if (inMemReports != null && inMemReports.Count > 0) { return(inMemReports); } else { MongoRepository mongorepo = new MongoRepository("MongoTwitterDailyReports", settings); DateTime dayStart = new DateTime(DateTime.UtcNow.AddDays(-90).Year, DateTime.UtcNow.AddDays(-90).Month, DateTime.UtcNow.AddDays(-90).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 result = mongorepo.Find <MongoTwitterDailyReports>(t => t.profileId.Equals(profileId) && (t.timeStamp > SBHelper.ConvertToUnixTimestamp(dayStart)) && (t.timeStamp < SBHelper.ConvertToUnixTimestamp(dayEnd))); var task = Task.Run(async() => { return(await result); }); IList <MongoTwitterDailyReports> lstDailyReports = task.Result; _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheTwitterMessageReportsByProfileId + profileId, lstDailyReports.ToList()); return(lstDailyReports.ToList()); } }
public static Domain.Socioboard.Models.MongoBoards getBoard(long boardId, Helper.Cache _redisCache, Helper.AppSettings _appSettings, ILogger _logger, DatabaseRepository dbr) { MongoRepository boardrepo = new MongoRepository("MongoBoards", _appSettings); try { Domain.Socioboard.Models.MongoBoards inMemboard = _redisCache.Get <Domain.Socioboard.Models.MongoBoards>(Domain.Socioboard.Consatants.SocioboardConsts.CacheBoard + boardId); if (inMemboard != null) { return(inMemboard); } else { Domain.Socioboard.Models.MongoBoards board = dbr.Find <Domain.Socioboard.Models.MongoBoards>(t => t.id.Equals(boardId)).First(); return(board); } } catch (Exception ex) { _logger.LogError(ex.StackTrace); return(null); } }
public static Domain.Socioboard.Models.TwitterAccount getTwitterAccount(string twitterUserId, Helper.Cache _redisCache, Helper.DatabaseRepository dbr) { try { Domain.Socioboard.Models.TwitterAccount inMemTwitterAcc = _redisCache.Get <Domain.Socioboard.Models.TwitterAccount>(Domain.Socioboard.Consatants.SocioboardConsts.CacheTwitterAccount + twitterUserId); if (inMemTwitterAcc != null) { return(inMemTwitterAcc); } } catch { } List <Domain.Socioboard.Models.TwitterAccount> lstTwitterAcc = dbr.Find <Domain.Socioboard.Models.TwitterAccount>(t => t.twitterUserId.Equals(twitterUserId)).ToList(); if (lstTwitterAcc != null && lstTwitterAcc.Count() > 0) { _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheTwitterAccount + twitterUserId, lstTwitterAcc.First()); return(lstTwitterAcc.First()); } else { return(null); } }
public static Domain.Socioboard.Models.Instagramaccounts getInstagramAccount(string instagramUserId, Helper.Cache _redisCache, Model.DatabaseRepository dbr) { try { Domain.Socioboard.Models.Instagramaccounts inMemTwitterAcc = _redisCache.Get <Domain.Socioboard.Models.Instagramaccounts>(Domain.Socioboard.Consatants.SocioboardConsts.CacheInstagramAccount + instagramUserId); if (inMemTwitterAcc != null) { return(inMemTwitterAcc); } } catch { } List <Domain.Socioboard.Models.Instagramaccounts> lstInstagramaccounts = dbr.Find <Domain.Socioboard.Models.Instagramaccounts>(t => t.InstagramId.Equals(instagramUserId)).ToList(); if (lstInstagramaccounts != null && lstInstagramaccounts.Count() > 0) { _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheInstagramAccount + instagramUserId, lstInstagramaccounts.First()); return(lstInstagramaccounts.First()); } else { return(null); } }
// public static Domain.Socioboard.Models.YoutubeChannel GetYtChannelLsts(string YtChannelId, Helper.Cache _redisCache, Model.DatabaseRepository dbr) { try { Domain.Socioboard.Models.YoutubeChannel inMemYTChannel = _redisCache.Get <Domain.Socioboard.Models.YoutubeChannel>(Domain.Socioboard.Consatants.SocioboardConsts.CacheYTChannel + YtChannelId); if (inMemYTChannel != null) { return(inMemYTChannel); } } catch { } List <Domain.Socioboard.Models.YoutubeChannel> lstYTChannel = dbr.Find <Domain.Socioboard.Models.YoutubeChannel>(t => t.YtubeChannelId.Equals(YtChannelId)).ToList(); if (lstYTChannel != null && lstYTChannel.Count() > 0) { _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheYTChannel + YtChannelId, lstYTChannel.First()); return(lstYTChannel.First()); } else { return(null); } }
public static Domain.Socioboard.Models.GoogleAnalyticsAccount getGAAccount(string GaAccountId, Helper.Cache _redisCache, Model.DatabaseRepository dbr) { try { Domain.Socioboard.Models.GoogleAnalyticsAccount inMemGAAcc = _redisCache.Get <Domain.Socioboard.Models.GoogleAnalyticsAccount>(Domain.Socioboard.Consatants.SocioboardConsts.CacheGAAccount + GaAccountId); if (inMemGAAcc != null) { return(inMemGAAcc); } } catch { } List <Domain.Socioboard.Models.GoogleAnalyticsAccount> lstGAAcc = dbr.Find <Domain.Socioboard.Models.GoogleAnalyticsAccount>(t => t.GaProfileId.Equals(GaAccountId)).ToList(); if (lstGAAcc != null && lstGAAcc.Count() > 0) { _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheGplusAccount + GaAccountId, lstGAAcc.First()); return(lstGAAcc.First()); } else { return(null); } }
public static Domain.Socioboard.Models.Googleplusaccounts getGPlusAccount(string GPlusUserId, Helper.Cache _redisCache, Model.DatabaseRepository dbr) { try { Domain.Socioboard.Models.Googleplusaccounts inMemGplusAcc = _redisCache.Get <Domain.Socioboard.Models.Googleplusaccounts>(Domain.Socioboard.Consatants.SocioboardConsts.CacheGplusAccount + GPlusUserId); if (inMemGplusAcc != null) { return(inMemGplusAcc); } } catch { } List <Domain.Socioboard.Models.Googleplusaccounts> lstGPlusAcc = dbr.Find <Domain.Socioboard.Models.Googleplusaccounts>(t => t.GpUserId.Equals(GPlusUserId) && t.IsActive).ToList(); if (lstGPlusAcc != null && lstGPlusAcc.Count() > 0) { _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheGplusAccount + GPlusUserId, lstGPlusAcc.First()); return(lstGPlusAcc.First()); } else { return(null); } }
/// <summary> /// /// </summary> /// <param name="userId"></param> /// <param name="redisCache"></param> /// <param name="dbr"></param> /// <returns></returns> public static List <Groups> GetAllGroupsofUser(long userId, Helper.Cache redisCache, Model.DatabaseRepository dbr) { try { var inMemGroups = redisCache.Get <List <Groups> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserGroups + userId); if (inMemGroups != null) { return(inMemGroups); } var lstGroupIds = dbr.Find <Groupmembers>(t => t.userId == userId && t.memberStatus == Domain.Socioboard.Enum.GroupMemberStatus.Accepted).Select(t => t.groupid).ToList(); var groups = dbr.Find <Groups>(t => lstGroupIds.Contains(t.id)).ToList(); redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserGroups + userId, groups); return(groups); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } return(null); }
public IActionResult GoogleLogin(string code, Domain.Socioboard.Enum.SBAccountType accType) { string ret = string.Empty; string objRefresh = string.Empty; string refreshToken = string.Empty; string access_token = string.Empty; oAuthTokenGPlus ObjoAuthTokenGPlus = new oAuthTokenGPlus(_appSettings.GoogleConsumerKey, _appSettings.GoogleConsumerSecret, _appSettings.GoogleRedirectUri); oAuthToken objToken = new oAuthToken(_appSettings.GoogleConsumerKey, _appSettings.GoogleConsumerSecret, _appSettings.GoogleRedirectUri); JObject userinfo = new JObject(); try { objRefresh = ObjoAuthTokenGPlus.GetRefreshToken(code); JObject objaccesstoken = JObject.Parse(objRefresh); _logger.LogInformation(objaccesstoken.ToString()); try { refreshToken = objaccesstoken["refresh_token"].ToString(); } catch { } access_token = objaccesstoken["access_token"].ToString(); string user = objToken.GetUserInfo("self", access_token.ToString()); _logger.LogInformation(user); userinfo = JObject.Parse(JArray.Parse(user)[0].ToString()); } catch (Exception ex) { //access_token = objaccesstoken["access_token"].ToString(); //ObjoAuthTokenGPlus.RevokeToken(access_token); _logger.LogInformation(ex.Message); _logger.LogError(ex.StackTrace); ret = "Access Token Not Found"; return(Ok(ret)); } string EmailId = string.Empty; try { EmailId = (Convert.ToString(userinfo["email"])); } catch { } if (string.IsNullOrEmpty(EmailId)) { return(Ok("Google Not retuning Email")); } try { User inMemUser = _redisCache.Get <User>(EmailId); if (inMemUser != null) { return(Ok(inMemUser)); } } catch (Exception ex) { _logger.LogInformation(ex.Message); _logger.LogError(ex.StackTrace); } DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); IList <User> lstUser = dbr.Find <User>(t => t.EmailId.Equals(EmailId)); if (lstUser != null && lstUser.Count() > 0) { DateTime d1 = DateTime.UtcNow; //User userTable = dbr.Single<User>(t => t.EmailId == EmailId); //userTable.LastLoginTime = d1; lstUser.First().LastLoginTime = d1; dbr.Update <User>(lstUser.First()); _redisCache.Set <User>(lstUser.First().EmailId, lstUser.First()); return(Ok(lstUser.First())); } else { Domain.Socioboard.Models.Googleplusaccounts gplusAcc = Api.Socioboard.Repositories.GplusRepository.getGPlusAccount(Convert.ToString(userinfo["id"]), _redisCache, dbr); if (gplusAcc != null && gplusAcc.IsActive == true) { return(Ok("GPlus account added by other user.")); } Domain.Socioboard.Models.User user = new Domain.Socioboard.Models.User(); if (accType == Domain.Socioboard.Enum.SBAccountType.Free) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Free; } else if (accType == Domain.Socioboard.Enum.SBAccountType.Deluxe) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Deluxe; } else if (accType == Domain.Socioboard.Enum.SBAccountType.Premium) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Premium; } else if (accType == Domain.Socioboard.Enum.SBAccountType.Topaz) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Topaz; } else if (accType == Domain.Socioboard.Enum.SBAccountType.Platinum) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Platinum; } else if (accType == Domain.Socioboard.Enum.SBAccountType.Gold) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Gold; } else if (accType == Domain.Socioboard.Enum.SBAccountType.Ruby) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Ruby; } else if (accType == Domain.Socioboard.Enum.SBAccountType.Standard) { user.AccountType = Domain.Socioboard.Enum.SBAccountType.Standard; } user.PaymentType = Domain.Socioboard.Enum.PaymentType.paypal; user.ActivationStatus = Domain.Socioboard.Enum.SBUserActivationStatus.Active; user.CreateDate = DateTime.UtcNow; user.EmailId = EmailId; user.ExpiryDate = DateTime.UtcNow.AddDays(1); user.UserName = "******"; user.EmailValidateToken = "Google"; user.UserType = "User"; user.PaymentStatus = Domain.Socioboard.Enum.SBPaymentStatus.UnPaid; try { user.FirstName = (Convert.ToString(userinfo["name"])); } catch { } user.RegistrationType = Domain.Socioboard.Enum.SBRegistrationType.Google; int SavedStatus = dbr.Add <Domain.Socioboard.Models.User>(user); User nuser = dbr.Single <User>(t => t.EmailId.Equals(user.EmailId)); if (SavedStatus == 1 && nuser != null) { Groups group = new Groups(); group.adminId = nuser.Id; group.createdDate = DateTime.UtcNow; group.groupName = Domain.Socioboard.Consatants.SocioboardConsts.DefaultGroupName; SavedStatus = dbr.Add <Groups>(group); if (SavedStatus == 1) { Groups ngrp = dbr.Find <Domain.Socioboard.Models.Groups>(t => t.adminId == nuser.Id && t.groupName.Equals(Domain.Socioboard.Consatants.SocioboardConsts.DefaultGroupName)).FirstOrDefault(); GroupMembersRepository.createGroupMember(ngrp.id, nuser, _redisCache, dbr); // Adding GPlus Profile Api.Socioboard.Repositories.GplusRepository.AddGplusAccount(userinfo, dbr, nuser.Id, ngrp.id, access_token, refreshToken, _redisCache, _appSettings, _logger); } } return(Ok(nuser)); } }
public static List <Domain.Socioboard.ViewModels.DiscoveryViewModal> DiscoverySearchGplus(long userId, long groupId, string keyword, Helper.Cache _redisCache, Helper.AppSettings _appSeetings, Model.DatabaseRepository dbr) { List <Domain.Socioboard.ViewModels.DiscoveryViewModal> iMmemDiscoveryViewModal = _redisCache.Get <List <Domain.Socioboard.ViewModels.DiscoveryViewModal> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheDiscoveryGplus + keyword); if (iMmemDiscoveryViewModal != null && iMmemDiscoveryViewModal.Count > 0) { return(iMmemDiscoveryViewModal); } else { List <Domain.Socioboard.ViewModels.DiscoveryViewModal> lstDiscoveryViewModal = Helper.GplusDiscoverySearchHelper.DiscoverySearchGplus(userId, keyword); _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheDiscoveryGplus + keyword, lstDiscoveryViewModal); return(lstDiscoveryViewModal); } }
public static List <Domain.Socioboard.ViewModels.DiscoveryViewModal> DiscoverySearchTwitter(long userId, long groupId, string keyword, Helper.Cache _redisCache, Helper.AppSettings _appSeetings, Model.DatabaseRepository dbr) { List <Domain.Socioboard.ViewModels.DiscoveryViewModal> iMmemDiscoveryViewModal = _redisCache.Get <List <Domain.Socioboard.ViewModels.DiscoveryViewModal> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheDiscoveryTwitter + keyword); if (iMmemDiscoveryViewModal != null && iMmemDiscoveryViewModal.Count > 0) { return(iMmemDiscoveryViewModal); } else { oAuthTwitter oauth = new oAuthTwitter(); Domain.Socioboard.Models.Discovery _discovery = new Domain.Socioboard.Models.Discovery(); List <Domain.Socioboard.Models.TwitterAccount> lsttwtaccount = dbr.Find <Domain.Socioboard.Models.TwitterAccount>(t => t.oAuthSecret != null).Take(20).ToList(); List <Domain.Socioboard.Models.Discovery> lstdiscovery = dbr.Find <Domain.Socioboard.Models.Discovery>(t => t.SearchKeyword.Equals(keyword) && t.userId == userId).ToList(); if (lstdiscovery.Count == 0) { _discovery.createTime = DateTime.UtcNow; _discovery.GroupId = groupId; _discovery.SearchKeyword = keyword; _discovery.userId = userId; dbr.Add(_discovery); } foreach (Domain.Socioboard.Models.TwitterAccount item in lsttwtaccount) { oauth.AccessToken = item.oAuthToken; oauth.AccessTokenSecret = item.oAuthSecret; oauth.TwitterUserId = item.twitterUserId; oauth.TwitterScreenName = item.twitterScreenName; SetCofigDetailsForTwitter(oauth, _appSeetings); try { Users _Users = new Users(); JArray _AccountVerify = _Users.Get_Account_Verify_Credentials(oauth); string id = (string)(_AccountVerify[0]["id_str"]); break; } catch (Exception ex) { } } List <Domain.Socioboard.ViewModels.DiscoveryViewModal> lstdiscoveryDiscoveryViewModal = Helper.TwitterHelper.DiscoverySearchTwitter(oauth, keyword, userId, groupId); if (lstdiscoveryDiscoveryViewModal.Count > 0) { _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheDiscoveryTwitter + keyword, lstdiscoveryDiscoveryViewModal); } return(lstdiscoveryDiscoveryViewModal); } }
public static List <Domain.Socioboard.Models.InstagramDiscoveryFeed> DiscoverySearchinstagram(string keyword, long userId, long groupId, Helper.Cache _redisCache, Helper.AppSettings _appSettings, Model.DatabaseRepository dbr) { List <Domain.Socioboard.Models.InstagramDiscoveryFeed> iMmemInstagramDiscoveryFeed = _redisCache.Get <List <Domain.Socioboard.Models.InstagramDiscoveryFeed> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheDiscoveryInstagram + keyword); List <Domain.Socioboard.Models.InstagramDiscoveryFeed> lstnstagramDiscoveryFeed = new List <Domain.Socioboard.Models.InstagramDiscoveryFeed>(); if (iMmemInstagramDiscoveryFeed != null && iMmemInstagramDiscoveryFeed.Count > 0) { return(iMmemInstagramDiscoveryFeed); } else { List <Domain.Socioboard.Models.Instagramaccounts> _Instagramaccounts = dbr.Find <Domain.Socioboard.Models.Instagramaccounts>(t => t.AccessToken != null).ToList(); foreach (var item in _Instagramaccounts) { lstnstagramDiscoveryFeed = Helper.InstagramHelper.DiscoverySearchinstagram(keyword, item.AccessToken, _appSettings.InstagramClientKey); if (lstnstagramDiscoveryFeed != null) { _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheDiscoveryInstagram + keyword, lstnstagramDiscoveryFeed); break; } } return(lstnstagramDiscoveryFeed); } }