public IActionResult updateTrainingDetails(Domain.Socioboard.Models.Training _training) { Model.DatabaseRepository dbr = new Model.DatabaseRepository(_logger, _env); _training.CreatedDate = DateTime.UtcNow; int SavedStatus = dbr.Add <Domain.Socioboard.Models.Training>(_training); if (SavedStatus == 1 && _training != null) { try { string path = _env.WebRootPath + "\\views\\mailtemplates\\plan.html"; string html = System.IO.File.ReadAllText(path); html = html.Replace("[FirstName]", _training.FirstName); html = html.Replace("[AccountType]", "Training"); _emailSender.SendMailSendGrid(_appSettings.frommail, "", _training.EmailId, "", "", "hello", html, _appSettings.SendgridUserName, _appSettings.SendGridPassword); Mailforsocioboard(_training); return(Ok("Demo Requested Added")); } catch (Exception ex) { return(Ok("Issue while sending mail.")); } } else { return(Ok("problem while saving,pls try after some time")); } }
public IActionResult UpdateUserInfo(Domain.Socioboard.Models.AgencyUser _AgencyUser) { Model.DatabaseRepository dbr = new Model.DatabaseRepository(_logger, _appEnv); _AgencyUser.createdDate = DateTime.UtcNow; int SavedStatus = dbr.Add <Domain.Socioboard.Models.AgencyUser>(_AgencyUser); if (SavedStatus == 1 && _AgencyUser != null) { try { string path = _appEnv.WebRootPath + "\\views\\mailtemplates\\plan.html"; string html = System.IO.File.ReadAllText(path); html = html.Replace("[FirstName]", _AgencyUser.userName); html = html.Replace("[AccountType]", _AgencyUser.planType.ToString()); _emailSender.SendMailSendGrid(_appSettings.frommail, "", _AgencyUser.email, "", "", "You requested for Demo plan", html, _appSettings.SendgridUserName, _appSettings.SendGridPassword); Mailforsocioboard(_AgencyUser); return(Ok("Demo Requested Added")); } catch (Exception ex) { return(Ok("Issue while sending mail.")); } } else { return(Ok("problem while saving,pls try after some time")); } }
public static int AddPaymentTransaction(long userId, string amount, string email, Domain.Socioboard.Enum.PaymentType PaymentType, string paymentId, string trasactionId, DateTime subscr_date, string payer_email, string Payername, string payment_status, string item_name, string media, Model.DatabaseRepository dbr) { try { Domain.Socioboard.Models.PaymentTransaction _PaymentTransaction = new Domain.Socioboard.Models.PaymentTransaction(); _PaymentTransaction.amount = amount; _PaymentTransaction.email = email; _PaymentTransaction.paymentdate = DateTime.UtcNow; _PaymentTransaction.userid = userId; _PaymentTransaction.PaymentType = PaymentType; _PaymentTransaction.trasactionId = trasactionId; _PaymentTransaction.paymentId = paymentId; _PaymentTransaction.payeremail = payer_email; _PaymentTransaction.Payername = Payername; _PaymentTransaction.paymentstatus = payment_status; _PaymentTransaction.itemname = item_name; _PaymentTransaction.media = media; _PaymentTransaction.subscrdate = subscr_date; int isaved = dbr.Add <Domain.Socioboard.Models.PaymentTransaction>(_PaymentTransaction); return(isaved); } catch (Exception) { return(0); } }
/// <summary> /// /// </summary> /// <param name="userId"></param> /// <param name="amount"></param> /// <param name="email"></param> /// <param name="PaymentType"></param> /// <param name="paymentId"></param> /// <param name="trasactionId"></param> /// <param name="subscr_date"></param> /// <param name="payer_email"></param> /// <param name="Payername"></param> /// <param name="payment_status"></param> /// <param name="item_name"></param> /// <param name="media"></param> /// <param name="dbr"></param> /// <returns></returns> public static int AddPaymentTransaction(long userId, string amount, string email, Domain.Socioboard.Enum.PaymentType PaymentType, string paymentId, string trasactionId, DateTime subscr_date, string payer_email, string Payername, string payment_status, string item_name, string media, Model.DatabaseRepository dbr) { try { var paymentTransaction = new Domain.Socioboard.Models.PaymentTransaction { amount = amount, email = email, paymentdate = DateTime.UtcNow, userid = userId, PaymentType = PaymentType, trasactionId = trasactionId, paymentId = paymentId, payeremail = payer_email, Payername = Payername, paymentstatus = payment_status, itemname = item_name, media = media, subscrdate = subscr_date }; return(dbr.Add(paymentTransaction)); } catch (Exception) { return(0); } }
public static void AddAffiliate(long userId, long friendId, double amount, Model.DatabaseRepository dbr) { Domain.Socioboard.Models.Affiliates _Affiliates = new Domain.Socioboard.Models.Affiliates(); _Affiliates.AffiliateDate = DateTime.UtcNow; _Affiliates.Amount = amount; _Affiliates.UserId = userId; _Affiliates.FriendUserId = friendId; dbr.Add(_Affiliates); }
public static int AddGroupProfile(Int64 GroupId, string ProfileId, string ProfileName, Int64 ProfileOwnerId, string ProfilePic, Domain.Socioboard.Enum.SocialProfileType profileType, Model.DatabaseRepository dbr) { Domain.Socioboard.Models.Groupprofiles grpProfile = new Domain.Socioboard.Models.Groupprofiles(); grpProfile.groupId = GroupId; grpProfile.profileId = ProfileId; grpProfile.profileName = ProfileName; grpProfile.profileOwnerId = ProfileOwnerId; grpProfile.profilePic = ProfilePic; grpProfile.profileType = profileType; return(dbr.Add <Domain.Socioboard.Models.Groupprofiles>(grpProfile)); }
public static int createGroupMember(long groupId, User user, Helper.Cache _redisCache, Model.DatabaseRepository dbr) { Domain.Socioboard.Models.Groupmembers grpMember = new Domain.Socioboard.Models.Groupmembers(); grpMember.groupid = groupId; grpMember.email = user.EmailId; grpMember.firstName = user.FirstName; grpMember.lastName = user.LastName; grpMember.memberStatus = Domain.Socioboard.Enum.GroupMemberStatus.Accepted; grpMember.profileImg = user.ProfilePicUrl; grpMember.userId = user.Id; grpMember.memberCode = "Admin"; grpMember.isAdmin = true; return(dbr.Add <Groupmembers>(grpMember)); }
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); } }
/// <summary> /// To add the member to the specified group /// </summary> /// <param name="groupId">group Id</param> /// <param name="user">user details</param> /// <param name="redisCache"></param> /// <param name="dbr">Database respository object</param> /// <returns></returns> public static int CreateGroupMember(long groupId, User user, Helper.Cache redisCache, Model.DatabaseRepository dbr) { var grpMember = new Groupmembers { groupid = groupId, email = user.EmailId, firstName = user.FirstName, lastName = user.LastName, memberStatus = Domain.Socioboard.Enum.GroupMemberStatus.Accepted, profileImg = user.ProfilePicUrl, userId = user.Id, memberCode = "Admin", isAdmin = true }; return(dbr.Add(grpMember)); }
public static Domain.Socioboard.Models.RssFeedUrl AddRssUrl(string Url, Model.DatabaseRepository dbr) { Domain.Socioboard.Models.RssFeedUrl _RssFeedUrl = dbr.FindSingle <Domain.Socioboard.Models.RssFeedUrl>(t => t.rssurl.Contains(Url)); if (_RssFeedUrl != null) { return(_RssFeedUrl); } else { _RssFeedUrl = new Domain.Socioboard.Models.RssFeedUrl(); _RssFeedUrl.rssurl = Url; _RssFeedUrl.LastUpdate = DateTime.UtcNow; dbr.Add <Domain.Socioboard.Models.RssFeedUrl>(_RssFeedUrl); _RssFeedUrl = dbr.FindSingle <Domain.Socioboard.Models.RssFeedUrl>(t => t.rssurl.Contains(Url)); return(_RssFeedUrl); } }
public static string PostLinkedInCompanyPagePost(string ImageUrl, long userid, string comment, string LinkedinPageId, Helper.Cache _redisCache, Model.DatabaseRepository dbr, Helper.AppSettings _appSettings) { string json = ""; Domain.Socioboard.Models.LinkedinCompanyPage objlicompanypage = Repositories.LinkedInAccountRepository.getLinkedinCompanyPage(LinkedinPageId, _redisCache, dbr); oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn(); Linkedin_oauth.ConsumerKey = _appSettings.LinkedinApiKey; Linkedin_oauth.ConsumerSecret = _appSettings.LinkedinSecretKey; Linkedin_oauth.Verifier = objlicompanypage.OAuthVerifier; Linkedin_oauth.TokenSecret = objlicompanypage.OAuthSecret; Linkedin_oauth.Token = objlicompanypage.OAuthToken; Linkedin_oauth.Id = objlicompanypage.LinkedinPageId; Linkedin_oauth.FirstName = objlicompanypage.LinkedinPageName; Company company = new Company(); if (string.IsNullOrEmpty(ImageUrl)) { json = company.SetPostOnPage(Linkedin_oauth, objlicompanypage.LinkedinPageId, comment); } else { json = company.SetPostOnPageWithImage(Linkedin_oauth, objlicompanypage.LinkedinPageId, ImageUrl, comment); } if (!string.IsNullOrEmpty(json)) { ScheduledMessage scheduledMessage = new ScheduledMessage(); scheduledMessage.createTime = DateTime.UtcNow; scheduledMessage.picUrl = ImageUrl; scheduledMessage.profileId = objlicompanypage.LinkedinPageId; scheduledMessage.profileType = Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage; scheduledMessage.scheduleTime = DateTime.UtcNow; scheduledMessage.shareMessage = comment; scheduledMessage.userId = userid; scheduledMessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated; scheduledMessage.url = json; dbr.Add <ScheduledMessage>(scheduledMessage); return("posted"); } else { json = "Message not posted"; return(json); } }
public static void AddRequestToWithdraw(string WithdrawAmount, string PaymentMethod, string PaypalEmail, string IbanCode, string SwiftCode, string Other, long UserID, Model.DatabaseRepository dbr) { Domain.Socioboard.Models.User _User = dbr.Find <Domain.Socioboard.Models.User>(t => t.Id == UserID).First(); Domain.Socioboard.Models.EwalletWithdrawRequest _EwalletWithdrawRequest = new Domain.Socioboard.Models.EwalletWithdrawRequest(); _EwalletWithdrawRequest.UserID = _User.Id; _EwalletWithdrawRequest.Other = Other; _EwalletWithdrawRequest.PaymentMethod = PaymentMethod; _EwalletWithdrawRequest.PaypalEmail = PaypalEmail; _EwalletWithdrawRequest.RequestDate = DateTime.UtcNow; _EwalletWithdrawRequest.Status = Domain.Socioboard.Enum.EwalletStatus.pending; _EwalletWithdrawRequest.SwiftCode = SwiftCode; _EwalletWithdrawRequest.UserEmail = _User.EmailId; _EwalletWithdrawRequest.UserName = _User.FirstName + " " + _User.LastName; _EwalletWithdrawRequest.WithdrawAmount = WithdrawAmount; dbr.Add(_EwalletWithdrawRequest); _User.Ewallet = (Double.Parse(_User.Ewallet) - Double.Parse(WithdrawAmount)).ToString(); dbr.Update(_User); }
public static string AddRssUrl(string profileId, string Url, Model.DatabaseRepository dbr) { string[] profilesList = null; if (profileId != null) { profilesList = profileId.Split(','); profileId = profilesList[0]; } foreach (var item in profilesList) { string prid = null; if (item.Contains("page_")) { prid = item.Substring(5, item.Length - 5); } else if (item.Contains("tw_")) { prid = item.Substring(3, item.Length - 3); } else { prid = item.Substring(3, item.Length - 3); } Domain.Socioboard.Models.RssFeedUrl _RssFeedUrl = dbr.FindSingle <Domain.Socioboard.Models.RssFeedUrl>(t => t.rssurl.Contains(Url) && t.Keywords == null && t.ProfileId == prid); if (_RssFeedUrl != null) { return("null"); } else { _RssFeedUrl = new Domain.Socioboard.Models.RssFeedUrl(); _RssFeedUrl.rssurl = Url; _RssFeedUrl.ProfileId = prid; _RssFeedUrl.LastUpdate = DateTime.UtcNow; dbr.Add <Domain.Socioboard.Models.RssFeedUrl>(_RssFeedUrl); _RssFeedUrl = dbr.FindSingle <Domain.Socioboard.Models.RssFeedUrl>(t => t.rssurl.Contains(Url) && t.Keywords == null); } } return("success"); }
public static string PostLinkedInMessage(string ImageUrl, long userid, string comment, string ProfileId, string imagepath, Helper.Cache _redisCache, Helper.AppSettings _appSettings, Model.DatabaseRepository dbr) { string json = ""; Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = Repositories.LinkedInAccountRepository.getLinkedInAccount(ProfileId, _redisCache, dbr); oAuthLinkedIn _oauth = new oAuthLinkedIn(); _oauth.ConsumerKey = _appSettings.LinkedinApiKey; _oauth.ConsumerSecret = _appSettings.LinkedinSecretKey; _oauth.Token = _LinkedInAccount.OAuthToken; string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json"; if (string.IsNullOrEmpty(ImageUrl)) { json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, comment); } else { json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, comment, imagepath); } if (!string.IsNullOrEmpty(json)) { ScheduledMessage scheduledMessage = new ScheduledMessage(); scheduledMessage.createTime = DateTime.UtcNow; scheduledMessage.picUrl = ImageUrl; scheduledMessage.profileId = ProfileId; scheduledMessage.profileType = Domain.Socioboard.Enum.SocialProfileType.LinkedIn; scheduledMessage.scheduleTime = DateTime.UtcNow; scheduledMessage.shareMessage = comment; scheduledMessage.userId = userid; scheduledMessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated; scheduledMessage.url = json; dbr.Add <ScheduledMessage>(scheduledMessage); return("posted"); } else { json = "Message not posted"; return(json); } }
public static string ComposeLinkedInCompanyPagePost(string ImageUrl, long userid, string comment, string LinkedinPageId, Model.DatabaseRepository dbr, Domain.Socioboard.Models.LinkedinCompanyPage objLinkedinCompanyPage, Domain.Socioboard.Models.ScheduledMessage schmessage) { string json = ""; Domain.Socioboard.Models.LinkedinCompanyPage objlicompanypage = objLinkedinCompanyPage; oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn(); //Linkedin_oauth.ConsumerKey = "81k55eukagnqfa"; //Linkedin_oauth.ConsumerSecret = "d9rqHEf7ewdSbsF1"; Linkedin_oauth.ConsumerKey = "754ysxdp72ulk5"; Linkedin_oauth.ConsumerSecret = "vbU52SjK7xS6cT8H"; Linkedin_oauth.Verifier = objlicompanypage.OAuthVerifier; Linkedin_oauth.TokenSecret = objlicompanypage.OAuthSecret; Linkedin_oauth.Token = objlicompanypage.OAuthToken; Linkedin_oauth.Id = objlicompanypage.LinkedinPageId; Linkedin_oauth.FirstName = objlicompanypage.LinkedinPageName; Company company = new Company(); if (string.IsNullOrEmpty(ImageUrl)) { json = company.SetPostOnPage(Linkedin_oauth, objlicompanypage.LinkedinPageId, comment); } else { json = company.SetPostOnPageWithImage(Linkedin_oauth, objlicompanypage.LinkedinPageId, ImageUrl, comment); } if (!string.IsNullOrEmpty(json)) { apiHitsCount++; schmessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated; schmessage.url = json; dbr.Add <ScheduledMessage>(schmessage); return("posted"); } else { apiHitsCount = MaxapiHitsCount; json = "Message not posted"; return(json); } }
public static int AddPaymentTransaction(long userId, string amount, string email, Domain.Socioboard.Enum.PaymentType PaymentType, string paymentId, string trasactionId, Model.DatabaseRepository dbr) { try { Domain.Socioboard.Models.PaymentTransaction _PaymentTransaction = new Domain.Socioboard.Models.PaymentTransaction(); _PaymentTransaction.amount = amount; _PaymentTransaction.email = email; _PaymentTransaction.paymentdate = DateTime.UtcNow; _PaymentTransaction.userid = userId; _PaymentTransaction.PaymentType = PaymentType; _PaymentTransaction.trasactionId = trasactionId; _PaymentTransaction.paymentId = paymentId; int isaved = dbr.Add <Domain.Socioboard.Models.PaymentTransaction>(_PaymentTransaction); return(isaved); } catch (Exception) { return(0); } }
public static string ComposeLinkedInMessage(string ImageUrl, long userid, string comment, string ProfileId, string imagepath, Domain.Socioboard.Models.LinkedInAccount _objLinkedInAccount, Model.DatabaseRepository dbr, Domain.Socioboard.Models.ScheduledMessage schmessage) { string json = ""; Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = _objLinkedInAccount; oAuthLinkedIn _oauth = new oAuthLinkedIn(); //_oauth.ConsumerKey = "81k55eukagnqfa"; //_oauth.ConsumerSecret = "d9rqHEf7ewdSbsF1"; _oauth.ConsumerKey = "754ysxdp72ulk5"; _oauth.ConsumerSecret = "vbU52SjK7xS6cT8H"; _oauth.Token = _LinkedInAccount.OAuthToken; string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json"; if (string.IsNullOrEmpty(ImageUrl)) { json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, comment); } else { json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, comment, imagepath); } if (!string.IsNullOrEmpty(json)) { apiHitsCount++; schmessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated; schmessage.url = json; dbr.Add <ScheduledMessage>(schmessage); return("posted"); } else { apiHitsCount = MaxapiHitsCount; json = "Message not posted"; return(json); } }
public static int AddYoutubeChannels(string profiledata, long userId, long groupId, Helper.Cache _redisCache, Helper.AppSettings _appSettings, Model.DatabaseRepository dbr, IHostingEnvironment _appEnv) { int isSaved = 0; Channels _Channels = new Channels("575089347457-74q0u81gj88ve5bfdmbklcf2dnc0353q.apps.googleusercontent.com", "JRtS_TaeYpKOJWBCqt9h8-iG", "http://localhost:9821/GoogleManager/Google"); Domain.Socioboard.Models.YoutubeChannel _YoutubeChannel; string[] YTdata = Regex.Split(profiledata, "<:>"); _YoutubeChannel = Repositories.GplusRepository.getYTChannel(YTdata[2], _redisCache, dbr); if (_YoutubeChannel != null) { try { _YoutubeChannel.UserId = userId; _YoutubeChannel.YtubeChannelId = YTdata[2]; _YoutubeChannel.YtubeChannelName = YTdata[3]; _YoutubeChannel.ChannelpicUrl = YTdata[9]; _YoutubeChannel.WebsiteUrl = "https://www.youtube.com/channel/" + YTdata[2]; _YoutubeChannel.EntryDate = DateTime.UtcNow; _YoutubeChannel.YtubeChannelDescription = YTdata[4]; _YoutubeChannel.IsActive = true; _YoutubeChannel.AccessToken = YTdata[0]; _YoutubeChannel.RefreshToken = YTdata[1]; _YoutubeChannel.PublishingDate = Convert.ToDateTime(YTdata[5]); _YoutubeChannel.VideosCount = Convert.ToDouble(YTdata[8]); _YoutubeChannel.CommentsCount = Convert.ToDouble(YTdata[7]); _YoutubeChannel.SubscribersCount = Convert.ToDouble(YTdata[10]); _YoutubeChannel.ViewsCount = Convert.ToDouble(YTdata[6]); } catch (Exception ex) { } isSaved = dbr.Update <Domain.Socioboard.Models.YoutubeChannel>(_YoutubeChannel); } else { _YoutubeChannel = new Domain.Socioboard.Models.YoutubeChannel(); try { _YoutubeChannel.UserId = userId; _YoutubeChannel.YtubeChannelId = YTdata[2]; _YoutubeChannel.YtubeChannelName = YTdata[3]; _YoutubeChannel.ChannelpicUrl = YTdata[9]; _YoutubeChannel.WebsiteUrl = "https://www.youtube.com/channel/" + YTdata[2]; _YoutubeChannel.EntryDate = DateTime.UtcNow; _YoutubeChannel.YtubeChannelDescription = YTdata[4]; _YoutubeChannel.IsActive = true; _YoutubeChannel.AccessToken = YTdata[0]; _YoutubeChannel.RefreshToken = YTdata[1]; _YoutubeChannel.PublishingDate = Convert.ToDateTime(YTdata[5]); _YoutubeChannel.VideosCount = Convert.ToDouble(YTdata[8]); _YoutubeChannel.CommentsCount = Convert.ToDouble(YTdata[7]); _YoutubeChannel.SubscribersCount = Convert.ToDouble(YTdata[10]); _YoutubeChannel.ViewsCount = Convert.ToDouble(YTdata[6]); } catch (Exception ex) { } isSaved = dbr.Add <Domain.Socioboard.Models.YoutubeChannel>(_YoutubeChannel); } if (isSaved == 1) { List <Domain.Socioboard.Models.YoutubeChannel> lstytChannel = dbr.Find <Domain.Socioboard.Models.YoutubeChannel>(t => t.YtubeChannelId.Equals(_YoutubeChannel.YtubeChannelId)).ToList(); if (lstytChannel != null && lstytChannel.Count() > 0) { isSaved = GroupProfilesRepository.AddGroupProfile(groupId, lstytChannel.First().YtubeChannelId, lstytChannel.First().YtubeChannelName, userId, lstytChannel.First().ChannelpicUrl, Domain.Socioboard.Enum.SocialProfileType.YouTube, dbr); //codes to delete cache _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId); _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId); } } return(isSaved); }
public static string PostLinkedInMessage(string ImageUrl, long userid, string comment, string ProfileId, string imagepath, Domain.Socioboard.Enum.MediaType mediaType, string profileName, Helper.Cache _redisCache, Helper.AppSettings _appSettings, Model.DatabaseRepository dbr) { try { if (!ImageUrl.Contains("https://") && !ImageUrl.Contains("http://") && !string.IsNullOrEmpty(ImageUrl)) { var client = new ImgurClient("5f1ad42ec5988b7", "f3294c8632ef8de6bfcbc46b37a23d18479159c5"); var endpoint = new ImageEndpoint(client); IImage image; using (var fs = new FileStream(imagepath, FileMode.Open)) { image = endpoint.UploadImageStreamAsync(fs).GetAwaiter().GetResult(); } var img = image.Link; string json = ""; Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = Repositories.LinkedInAccountRepository.getLinkedInAccount(ProfileId, _redisCache, dbr); oAuthLinkedIn _oauth = new oAuthLinkedIn(); _oauth.ConsumerKey = _appSettings.LinkedinApiKey; _oauth.ConsumerSecret = _appSettings.LinkedinSecretKey; _oauth.Token = _LinkedInAccount.OAuthToken; string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json"; if (string.IsNullOrEmpty(ImageUrl)) { json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, comment); } else { json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, comment, img); } if (!string.IsNullOrEmpty(json)) { ScheduledMessage scheduledMessage = new ScheduledMessage(); scheduledMessage.createTime = DateTime.UtcNow; scheduledMessage.picUrl = _LinkedInAccount.ProfileImageUrl; scheduledMessage.profileId = ProfileId; scheduledMessage.profileType = Domain.Socioboard.Enum.SocialProfileType.LinkedIn; scheduledMessage.scheduleTime = DateTime.UtcNow; scheduledMessage.shareMessage = comment; scheduledMessage.userId = userid; scheduledMessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated; scheduledMessage.url = ImageUrl; scheduledMessage.mediaType = mediaType; scheduledMessage.socialprofileName = _LinkedInAccount.LinkedinUserName; dbr.Add <ScheduledMessage>(scheduledMessage); return("posted"); } else { json = "Message not posted"; return(json); } } else { string json = ""; Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = Repositories.LinkedInAccountRepository.getLinkedInAccount(ProfileId, _redisCache, dbr); oAuthLinkedIn _oauth = new oAuthLinkedIn(); _oauth.ConsumerKey = _appSettings.LinkedinApiKey; _oauth.ConsumerSecret = _appSettings.LinkedinSecretKey; _oauth.Token = _LinkedInAccount.OAuthToken; string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json"; if (string.IsNullOrEmpty(ImageUrl)) { json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, comment); } else { var client = new ImgurClient("5f1ad42ec5988b7", "f3294c8632ef8de6bfcbc46b37a23d18479159c5"); var endpoint = new ImageEndpoint(client); IImage image; using (var fs = new FileStream(imagepath, FileMode.Open)) { image = endpoint.UploadImageStreamAsync(fs).GetAwaiter().GetResult(); } var img = image.Link; json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, comment, img); } if (!string.IsNullOrEmpty(json)) { ScheduledMessage scheduledMessage = new ScheduledMessage(); scheduledMessage.createTime = DateTime.UtcNow; scheduledMessage.picUrl = _LinkedInAccount.ProfileImageUrl; scheduledMessage.profileId = ProfileId; scheduledMessage.profileType = Domain.Socioboard.Enum.SocialProfileType.LinkedIn; scheduledMessage.scheduleTime = DateTime.UtcNow; scheduledMessage.shareMessage = comment; scheduledMessage.userId = userid; scheduledMessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated; scheduledMessage.url = ImageUrl; scheduledMessage.mediaType = mediaType; scheduledMessage.socialprofileName = _LinkedInAccount.LinkedinUserName; dbr.Add <ScheduledMessage>(scheduledMessage); return("posted"); } else { json = "Message not posted"; return(json); } } } catch (Exception ex) { return("Message not posted"); } }
public static string PostLinkedInCompanyPagePost(string upload, string ImageUrl, long userid, string comment, string LinkedinPageId, Domain.Socioboard.Enum.MediaType mediaType, string profileName, Helper.Cache _redisCache, Model.DatabaseRepository dbr, Helper.AppSettings _appSettings) { try { if (!ImageUrl.Contains("https://") && !ImageUrl.Contains("http://") && !string.IsNullOrEmpty(ImageUrl)) { var client = new ImgurClient("5f1ad42ec5988b7", "f3294c8632ef8de6bfcbc46b37a23d18479159c5"); var endpoint = new ImageEndpoint(client); IImage image; using (var fs = new FileStream(ImageUrl, FileMode.Open)) { image = endpoint.UploadImageStreamAsync(fs).GetAwaiter().GetResult(); } var img = image.Link; string json = ""; Domain.Socioboard.Models.LinkedinCompanyPage objlicompanypage = Repositories.LinkedInAccountRepository.getLinkedinCompanyPage(LinkedinPageId, _redisCache, dbr); oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn(); Linkedin_oauth.ConsumerKey = _appSettings.LinkedinApiKey; Linkedin_oauth.ConsumerSecret = _appSettings.LinkedinSecretKey; Linkedin_oauth.Verifier = objlicompanypage.OAuthVerifier; Linkedin_oauth.TokenSecret = objlicompanypage.OAuthSecret; Linkedin_oauth.Token = objlicompanypage.OAuthToken; Linkedin_oauth.Id = objlicompanypage.LinkedinPageId; Linkedin_oauth.FirstName = objlicompanypage.LinkedinPageName; Company company = new Company(); if (string.IsNullOrEmpty(ImageUrl)) { json = company.SetPostOnPage(Linkedin_oauth, objlicompanypage.LinkedinPageId, comment); } else { json = company.SetPostOnPageWithImage(Linkedin_oauth, objlicompanypage.LinkedinPageId, img, comment); } if (!string.IsNullOrEmpty(json)) { ScheduledMessage scheduledMessage = new ScheduledMessage(); scheduledMessage.createTime = DateTime.UtcNow; scheduledMessage.picUrl = objlicompanypage.LogoUrl; scheduledMessage.profileId = objlicompanypage.LinkedinPageId; scheduledMessage.profileType = Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage; scheduledMessage.scheduleTime = DateTime.UtcNow; scheduledMessage.shareMessage = comment; scheduledMessage.userId = userid; scheduledMessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated; scheduledMessage.url = upload; scheduledMessage.mediaType = mediaType; scheduledMessage.socialprofileName = objlicompanypage.LinkedinPageName; dbr.Add <ScheduledMessage>(scheduledMessage); return("posted"); } else { json = "Message not posted"; return(json); } } else { string json = ""; Domain.Socioboard.Models.LinkedinCompanyPage objlicompanypage = Repositories.LinkedInAccountRepository.getLinkedinCompanyPage(LinkedinPageId, _redisCache, dbr); oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn(); Linkedin_oauth.ConsumerKey = _appSettings.LinkedinApiKey; Linkedin_oauth.ConsumerSecret = _appSettings.LinkedinSecretKey; Linkedin_oauth.Verifier = objlicompanypage.OAuthVerifier; Linkedin_oauth.TokenSecret = objlicompanypage.OAuthSecret; Linkedin_oauth.Token = objlicompanypage.OAuthToken; Linkedin_oauth.Id = objlicompanypage.LinkedinPageId; Linkedin_oauth.FirstName = objlicompanypage.LinkedinPageName; Company company = new Company(); if (string.IsNullOrEmpty(ImageUrl)) { json = company.SetPostOnPage(Linkedin_oauth, objlicompanypage.LinkedinPageId, comment); } else { var client = new ImgurClient("5f1ad42ec5988b7", "f3294c8632ef8de6bfcbc46b37a23d18479159c5"); var endpoint = new ImageEndpoint(client); IImage image; using (var fs = new FileStream(ImageUrl, FileMode.Open)) { image = endpoint.UploadImageStreamAsync(fs).GetAwaiter().GetResult(); } var img = image.Link; json = company.SetPostOnPageWithImage(Linkedin_oauth, objlicompanypage.LinkedinPageId, img, comment); } if (!string.IsNullOrEmpty(json)) { ScheduledMessage scheduledMessage = new ScheduledMessage(); scheduledMessage.createTime = DateTime.UtcNow; scheduledMessage.picUrl = objlicompanypage.LogoUrl; scheduledMessage.profileId = objlicompanypage.LinkedinPageId; scheduledMessage.profileType = Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage; scheduledMessage.scheduleTime = DateTime.UtcNow; scheduledMessage.shareMessage = comment; scheduledMessage.userId = userid; scheduledMessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated; scheduledMessage.url = upload; scheduledMessage.mediaType = mediaType; scheduledMessage.socialprofileName = objlicompanypage.LinkedinPageName; dbr.Add <ScheduledMessage>(scheduledMessage); return("posted"); } else { json = "Message not posted"; return(json); } } //} //catch(Exception ex) //{ // return "Message not posted"; //} } catch (Exception ex) { return("Message not posted"); } }
public static int AddLinkedInCompantPage(oAuthLinkedIn _oauth, dynamic profile, Model.DatabaseRepository dbr, Int64 userId, Int64 groupId, string accesstoken, Helper.Cache _redisCache, Helper.AppSettings _appSettings, ILogger _logger) { int isSaved = 0; Domain.Socioboard.Models.LinkedinCompanyPage _LinkedInAccount = Repositories.LinkedInAccountRepository.getLinkedinCompanyPage(profile.Pageid.ToString(), _redisCache, dbr); if (_LinkedInAccount != null && _LinkedInAccount.IsActive == false) { _LinkedInAccount.IsActive = true; _LinkedInAccount.UserId = userId; _LinkedInAccount.EmailDomains = profile.EmailDomains.ToString(); _LinkedInAccount.OAuthToken = accesstoken; _LinkedInAccount.LinkedinPageName = profile.name.ToString(); _LinkedInAccount.lastUpdate = DateTime.UtcNow; try { string NuberOfFollower = profile.num_followers.ToString(); _LinkedInAccount.NumFollowers = Convert.ToInt16(NuberOfFollower); } catch { } try { _LinkedInAccount.CompanyType = profile.company_type.ToString(); } catch { } try { _LinkedInAccount.LogoUrl = profile.logo_url.ToString(); } catch { } try { _LinkedInAccount.SquareLogoUrl = profile.square_logo_url.ToString(); } catch { } try { _LinkedInAccount.BlogRssUrl = profile.blog_rss_url.ToString(); } catch { } try { _LinkedInAccount.UniversalName = profile.universal_name.ToString(); } catch { } isSaved = dbr.Update <Domain.Socioboard.Models.LinkedinCompanyPage>(_LinkedInAccount); } else { _LinkedInAccount = new Domain.Socioboard.Models.LinkedinCompanyPage(); _LinkedInAccount.LinkedinPageId = profile.Pageid.ToString(); _LinkedInAccount.IsActive = true; _LinkedInAccount.UserId = userId; _LinkedInAccount.lastUpdate = DateTime.UtcNow; try { _LinkedInAccount.EmailDomains = profile.EmailDomains.ToString(); } catch (Exception ex) { } _LinkedInAccount.LinkedinPageName = profile.name.ToString(); _LinkedInAccount.OAuthToken = _oauth.Token; _LinkedInAccount.OAuthSecret = _oauth.TokenSecret; _LinkedInAccount.OAuthVerifier = _oauth.Verifier; try { _LinkedInAccount.Description = profile.description.ToString(); } catch { } try { _LinkedInAccount.FoundedYear = profile.founded_year.ToString(); } catch { } try { _LinkedInAccount.EndYear = profile.end_year.ToString(); } catch { } try { _LinkedInAccount.Locations = profile.locations.ToString(); } catch { } try { _LinkedInAccount.Specialties = profile.Specialties.ToString(); } catch { } try { _LinkedInAccount.WebsiteUrl = profile.website_url.ToString(); } catch { } try { _LinkedInAccount.Status = profile.status.ToString(); } catch { } try { _LinkedInAccount.EmployeeCountRange = profile.employee_count_range.ToString(); } catch { } try { _LinkedInAccount.Industries = profile.industries.ToString(); } catch { } try { string NuberOfFollower = profile.num_followers.ToString(); _LinkedInAccount.NumFollowers = Convert.ToInt16(NuberOfFollower); } catch { } try { _LinkedInAccount.CompanyType = profile.company_type.ToString(); } catch { } try { _LinkedInAccount.LogoUrl = profile.logo_url.ToString(); } catch { } try { _LinkedInAccount.SquareLogoUrl = profile.square_logo_url.ToString(); } catch { } try { _LinkedInAccount.BlogRssUrl = profile.blog_rss_url.ToString(); } catch { } try { _LinkedInAccount.UniversalName = profile.universal_name.ToString(); } catch { } isSaved = dbr.Add <Domain.Socioboard.Models.LinkedinCompanyPage>(_LinkedInAccount); if (isSaved == 1) { List <Domain.Socioboard.Models.LinkedinCompanyPage> lstliAcc = dbr.Find <Domain.Socioboard.Models.LinkedinCompanyPage>(t => t.LinkedinPageId.Equals(_LinkedInAccount.LinkedinPageId)).ToList(); if (lstliAcc != null && lstliAcc.Count() > 0) { isSaved = GroupProfilesRepository.AddGroupProfile(groupId, lstliAcc.First().LinkedinPageId, lstliAcc.First().LinkedinPageName, userId, lstliAcc.First().LogoUrl, Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage, dbr); if (isSaved == 1) { _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId); _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId); new Thread(delegate() { LinkedInAccountRepository.SaveLinkedInCompanyPageFeed(_oauth, lstliAcc.First().LinkedinPageId, lstliAcc.First().UserId, _appSettings); }).Start(); } } } } return(isSaved); }
public static string ComposeLinkedInCompanyPagePost(string ImageUrl, long userid, string comment, string LinkedinPageId, Model.DatabaseRepository dbr, Domain.Socioboard.Models.LinkedinCompanyPage objLinkedinCompanyPage, Domain.Socioboard.Models.ScheduledMessage schmessage, Domain.Socioboard.Models.User _user) { string json = ""; Domain.Socioboard.Models.LinkedinCompanyPage objlicompanypage = objLinkedinCompanyPage; oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn(); Linkedin_oauth.ConsumerKey = AppSettings.LinkedinApiKey; Linkedin_oauth.ConsumerSecret = AppSettings.LinkedinSecretKey; Linkedin_oauth.Verifier = objlicompanypage.OAuthVerifier; Linkedin_oauth.TokenSecret = objlicompanypage.OAuthSecret; Linkedin_oauth.Token = objlicompanypage.OAuthToken; Linkedin_oauth.Id = objlicompanypage.LinkedinPageId; Linkedin_oauth.FirstName = objlicompanypage.LinkedinPageName; Company company = new Company(); if (string.IsNullOrEmpty(ImageUrl)) { json = company.SetPostOnPage(Linkedin_oauth, objlicompanypage.LinkedinPageId, comment); } else { var client = new ImgurClient(AppSettings.imgurclietId, AppSettings.imgurclietSecret); var endpoint = new ImageEndpoint(client); IImage image; using (var fs = new FileStream(ImageUrl, FileMode.Open)) { image = endpoint.UploadImageStreamAsync(fs).GetAwaiter().GetResult(); } var imgs = image.Link; json = company.SetPostOnPageWithImage(Linkedin_oauth, objlicompanypage.LinkedinPageId, imgs, comment); } if (!string.IsNullOrEmpty(json)) { apiHitsCount++; schmessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated; schmessage.url = json; dbr.Update <ScheduledMessage>(schmessage); Domain.Socioboard.Models.Notifications notify = new Notifications(); Notifications lstnotifications = dbr.Single <Notifications>(t => t.MsgId == schmessage.id); if (lstnotifications == null) { notify.MsgId = schmessage.id; notify.MsgStatus = "Scheduled"; notify.notificationtime = schmessage.localscheduletime; notify.NotificationType = "Schedule Successfully"; notify.ReadOrUnread = "Unread"; notify.UserId = userid; dbr.Add <Notifications>(notify); if (_user.scheduleSuccessUpdates) { string sucResponse = SendMailbySendGrid(AppSettings.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, true, AppSettings.sendGridUserName, AppSettings.sendGridPassword); } return("posted"); } else { if (_user.scheduleSuccessUpdates) { string sucResponse = SendMailbySendGrid(AppSettings.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, true, AppSettings.sendGridUserName, AppSettings.sendGridPassword); } return("posted"); } } else { apiHitsCount = MaxapiHitsCount; json = "Message not posted"; Domain.Socioboard.Models.Notifications notify = new Notifications(); Notifications lstnotifications = dbr.Single <Notifications>(t => t.MsgId == schmessage.id); if (lstnotifications == null) { notify.MsgId = schmessage.id; notify.MsgStatus = "Failed"; notify.notificationtime = schmessage.localscheduletime; notify.NotificationType = "Schedule Failed"; notify.ReadOrUnread = "Unread"; notify.UserId = userid; dbr.Add <Notifications>(notify); if (_user.scheduleFailureUpdates) { string falResponse = SendMailbySendGrid(AppSettings.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, false, AppSettings.sendGridUserName, AppSettings.sendGridPassword); } return(json); } else { if (_user.scheduleFailureUpdates) { string falResponse = SendMailbySendGrid(AppSettings.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, false, AppSettings.sendGridUserName, AppSettings.sendGridPassword); } return(json); } } }
public static string AddInstagramAccount(string client_id, string client_secret, string redirect_uri, string code, long userId, long groupId, Model.DatabaseRepository dbr, ILogger _logger, Helper.Cache _redisCache, Helper.AppSettings _appSettings) { string ret = string.Empty; oAuthInstagram objInsta = new oAuthInstagram(); ConfigurationIns configi = new ConfigurationIns("https://api.instagram.com/oauth/authorize/", client_id, client_secret, redirect_uri, "https://api.instagram.com/oauth/access_token", "https://api.instagram.com/v1/", ""); oAuthInstagram _api = new oAuthInstagram(); _api = oAuthInstagram.GetInstance(configi); AccessToken access = new AccessToken(); access = _api.AuthGetAccessToken(code); UserController objusercontroller = new UserController(); if (access != null) { Domain.Socioboard.Models.Instagramaccounts Instagramaccounts = new Domain.Socioboard.Models.Instagramaccounts(); Domain.Socioboard.Models.Instagramaccounts objInstagramAccount; #region InstagramAccount InstagramResponse <User> objuser = objusercontroller.GetUserDetails(access.user.id, access.access_token); objInstagramAccount = new Domain.Socioboard.Models.Instagramaccounts(); objInstagramAccount.AccessToken = access.access_token; objInstagramAccount.InstagramId = access.user.id; try { objInstagramAccount.bio = access.user.bio; } catch { objInstagramAccount.bio = ""; } try { objInstagramAccount.ProfileUrl = access.user.profile_picture; } catch (Exception ex) { _logger.LogError("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace); } try { objInstagramAccount.InsUserName = access.user.username; } catch (Exception ex) { _logger.LogError("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace); } try { objInstagramAccount.TotalImages = objuser.data.counts.media; } catch (Exception ex) { _logger.LogError("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace); } try { objInstagramAccount.FollowedBy = objuser.data.counts.followed_by; } catch (Exception ex) { _logger.LogError("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace); } try { objInstagramAccount.Followers = objuser.data.counts.follows; } catch (Exception ex) { _logger.LogError("Instagram.asmx.cs >> AddInstagramAccount >> " + ex.StackTrace); } objInstagramAccount.UserId = userId; objInstagramAccount.IsActive = true; objInstagramAccount.lastUpdate = DateTime.UtcNow; if (objInstagramAccount.InstagramId != null) { Instagramaccounts = Api.Socioboard.Repositories.InstagramRepository.getInstagramAccount(objInstagramAccount.InstagramId, _redisCache, dbr); if (Instagramaccounts != null && Instagramaccounts.IsActive == true) { return("This Account is added by some body else."); } } else { return("Issue while fetching instagram userId"); } if (Instagramaccounts == null) { int isSaved = dbr.Add <Domain.Socioboard.Models.Instagramaccounts>(objInstagramAccount); if (isSaved == 1) { List <Domain.Socioboard.Models.Instagramaccounts> lstinsAcc = dbr.Find <Domain.Socioboard.Models.Instagramaccounts>(t => t.InstagramId.Equals(objInstagramAccount.InstagramId)).ToList(); if (lstinsAcc != null && lstinsAcc.Count() > 0) { isSaved = GroupProfilesRepository.AddGroupProfile(groupId, lstinsAcc.First().InstagramId, lstinsAcc.First().InsUserName, userId, lstinsAcc.First().ProfileUrl, Domain.Socioboard.Enum.SocialProfileType.Instagram, dbr); if (isSaved == 1) { _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId); _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId); GetInstagramSelfFeeds(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _appSettings); GetInstagramUserDetails(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _redisCache, dbr); GetInstagramFollowing(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings); GetInstagramFollower(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings); new Thread(delegate() { GetInstagramPostLikes(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings); GetInstagramPostComments(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _appSettings); }).Start(); return("Added_Successfully"); } } } } else { objInstagramAccount.id = Instagramaccounts.id; int isSaved = dbr.Update <Domain.Socioboard.Models.Instagramaccounts>(objInstagramAccount); if (isSaved == 1) { List <Domain.Socioboard.Models.Instagramaccounts> lstinsAcc = dbr.Find <Domain.Socioboard.Models.Instagramaccounts>(t => t.InstagramId.Equals(objInstagramAccount.InstagramId)).ToList(); if (lstinsAcc != null && lstinsAcc.Count() > 0) { isSaved = GroupProfilesRepository.AddGroupProfile(groupId, lstinsAcc.First().InstagramId, lstinsAcc.First().InsUserName, userId, lstinsAcc.First().ProfileUrl, Domain.Socioboard.Enum.SocialProfileType.Instagram, dbr); if (isSaved == 1) { _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId); _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId); //todo : codes to update feeds GetInstagramSelfFeeds(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _appSettings); GetInstagramUserDetails(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _redisCache, dbr); GetInstagramFollowing(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings); GetInstagramFollower(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings); new Thread(delegate() { GetInstagramPostLikes(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, 1, _appSettings); GetInstagramPostComments(objInstagramAccount.InstagramId, objInstagramAccount.AccessToken, _appSettings); }).Start(); return("Added_Successfully"); } } } } } return("issue in access token fetching"); #endregion }
public IActionResult PostBlueSnapSubscription(string XMLData, string emailId) { string responseFromServer = string.Empty; try { // Create a request using a URL that can receive a post. HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://sandbox.bluesnap.com/services/2/recurring/subscriptions"); // Set the Method property of the request to POST. request.Method = "POST"; request.Headers["Authorization"] = "Basic " + _appSettings.bluesnapBase64; request.UserAgent = ".NET Framework Test Client"; string postData = XMLData; byte[] byteArray = Encoding.UTF8.GetBytes(postData); request.ContentType = "application/xml"; request.ContentLength = byteArray.Length; ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; Stream dataStream = request.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); // Get the response. HttpWebResponse myHttpWebResponse = (HttpWebResponse)request.GetResponse(); Console.WriteLine((myHttpWebResponse.StatusDescription)); dataStream = myHttpWebResponse.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); responseFromServer = reader.ReadToEnd(); Console.WriteLine(responseFromServer); reader.Close(); dataStream.Close(); myHttpWebResponse.Close(); } catch (WebException wex) { var pageContent = new StreamReader(wex.Response.GetResponseStream()) .ReadToEnd(); Console.WriteLine(wex.Message); return(BadRequest()); } DatabaseRepository dbr = new Model.DatabaseRepository(_logger, _appEnv); try { //JSON XmlDocument doc = new XmlDocument(); doc.LoadXml(responseFromServer); JObject jsonTextResponse = JObject.Parse(JsonConvert.SerializeXmlNode(doc)); User userObj = dbr.FindSingle <User>(t => t.EmailId == emailId); PaymentTransaction objPaymentTransaction = new PaymentTransaction(); objPaymentTransaction.amount = jsonTextResponse["recurring-subscription"]["recurring-charge-amount"].ToString(); objPaymentTransaction.userid = userObj.Id; objPaymentTransaction.email = userObj.EmailId; objPaymentTransaction.paymentdate = DateTime.UtcNow; objPaymentTransaction.trasactionId = jsonTextResponse["recurring-subscription"]["subscription-id"].ToString(); try { objPaymentTransaction.paymentId = jsonTextResponse["recurring-subscription"]["charge"]["charge-id"].ToString(); } catch { objPaymentTransaction.paymentId = "NA"; } objPaymentTransaction.PaymentType = Domain.Socioboard.Enum.PaymentType.bluesnap; try { objPaymentTransaction.paymentstatus = jsonTextResponse["recurring-subscription"]["status"].ToString(); } catch { objPaymentTransaction.paymentstatus = "NA"; } objPaymentTransaction.itemname = "Socioboard" + userObj.AccountType.ToString(); objPaymentTransaction.Payername = userObj.FirstName + " " + userObj.LastName; objPaymentTransaction.email = userObj.EmailId; dbr.Add <PaymentTransaction>(objPaymentTransaction); userObj.ExpiryDate = DateTime.Now.AddYears(1); userObj.PaymentStatus = Domain.Socioboard.Enum.SBPaymentStatus.Paid; userObj.TrailStatus = Domain.Socioboard.Enum.UserTrailStatus.active; userObj.PayPalAccountStatus = Domain.Socioboard.Enum.PayPalAccountStatus.added; userObj.PaymentType = Domain.Socioboard.Enum.PaymentType.bluesnap; dbr.Update <User>(userObj); return(Ok()); } catch { return(BadRequest()); } }
public static int AddLinkedInAccount(oAuthLinkedIn _oauth, dynamic profile, Model.DatabaseRepository dbr, Int64 userId, Int64 groupId, string accessToken, Helper.Cache _redisCache, Helper.AppSettings settings, ILogger _logger) { int isSaved = 0; Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = Repositories.LinkedInAccountRepository.getLinkedInAccount(profile.id.ToString(), _redisCache, dbr); if (_LinkedInAccount != null && _LinkedInAccount.IsActive == false) { _LinkedInAccount.IsActive = true; _LinkedInAccount.UserId = userId; _LinkedInAccount.EmailId = profile.email.ToString(); _LinkedInAccount.OAuthToken = accessToken; _LinkedInAccount.Connections = Convert.ToInt32(profile.connections.ToString()); _LinkedInAccount.LastUpdate = DateTime.UtcNow; isSaved = dbr.Update <Domain.Socioboard.Models.LinkedInAccount>(_LinkedInAccount); } else { _LinkedInAccount = new Domain.Socioboard.Models.LinkedInAccount(); _LinkedInAccount.LinkedinUserId = profile.id.ToString(); _LinkedInAccount.IsActive = true; _LinkedInAccount.UserId = userId; _LinkedInAccount.Connections = Convert.ToInt32(profile.connections.ToString()); _LinkedInAccount.LastUpdate = DateTime.UtcNow; try { _LinkedInAccount.EmailId = profile.email.ToString(); } catch (Exception ex) { } _LinkedInAccount.LinkedinUserName = profile.first_name.ToString() + profile.last_name.ToString(); _LinkedInAccount.OAuthToken = _oauth.Token; _LinkedInAccount.OAuthSecret = _oauth.TokenSecret; _LinkedInAccount.OAuthVerifier = _oauth.Verifier; try { _LinkedInAccount.ProfileImageUrl = profile.picture_url.ToString(); } catch (Exception ex) { } try { _LinkedInAccount.ProfileUrl = profile.profile_url.ToString(); } catch (Exception ex) { } isSaved = dbr.Add <Domain.Socioboard.Models.LinkedInAccount>(_LinkedInAccount); if (isSaved == 1) { List <Domain.Socioboard.Models.LinkedInAccount> lstliAcc = dbr.Find <Domain.Socioboard.Models.LinkedInAccount>(t => t.LinkedinUserId.Equals(_LinkedInAccount.LinkedinUserId)).ToList(); if (lstliAcc != null && lstliAcc.Count() > 0) { isSaved = GroupProfilesRepository.AddGroupProfile(groupId, lstliAcc.First().LinkedinUserId, lstliAcc.First().LinkedinUserName, userId, lstliAcc.First().ProfileImageUrl, Domain.Socioboard.Enum.SocialProfileType.LinkedIn, dbr); if (isSaved == 1) { _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId); _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId); } } } } return(isSaved); }
public static int AddGplusAccount(JObject profile, Model.DatabaseRepository dbr, Int64 userId, Int64 groupId, string accessToken, string refreshToken, Helper.Cache _redisCache, Helper.AppSettings settings, ILogger _logger) { int isSaved = 0; Domain.Socioboard.Models.Googleplusaccounts gplusAcc = GplusRepository.getGPlusAccount(Convert.ToString(profile["id"]), _redisCache, dbr); oAuthTokenGPlus ObjoAuthTokenGPlus = new oAuthTokenGPlus(settings.GoogleConsumerKey, settings.GoogleConsumerSecret, settings.GoogleRedirectUri); if (gplusAcc != null && gplusAcc.IsActive == false) { gplusAcc.IsActive = true; gplusAcc.UserId = userId; gplusAcc.AccessToken = accessToken; gplusAcc.RefreshToken = refreshToken; gplusAcc.EntryDate = DateTime.UtcNow; try { gplusAcc.GpUserName = profile["displayName"].ToString(); } catch { try { gplusAcc.GpUserName = profile["name"].ToString(); } catch { } } try { gplusAcc.GpProfileImage = Convert.ToString(profile["image"]["url"]); } catch { try { gplusAcc.GpProfileImage = Convert.ToString(profile["picture"]); } catch { } } gplusAcc.AccessToken = accessToken; try { gplusAcc.about = Convert.ToString(profile["tagline"]); } catch { gplusAcc.about = ""; } try { gplusAcc.college = Convert.ToString(profile["organizations"][0]["name"]); } catch { gplusAcc.college = ""; } try { gplusAcc.coverPic = Convert.ToString(profile["cover"]["coverPhoto"]["url"]); } catch { gplusAcc.coverPic = ""; } try { gplusAcc.education = Convert.ToString(profile["organizations"][0]["type"]); } catch { gplusAcc.education = ""; } try { gplusAcc.EmailId = Convert.ToString(profile["emails"][0]["value"]); } catch { gplusAcc.EmailId = ""; } try { gplusAcc.gender = Convert.ToString(profile["gender"]); } catch { gplusAcc.gender = ""; } try { gplusAcc.workPosition = Convert.ToString(profile["occupation"]); } catch { gplusAcc.workPosition = ""; } gplusAcc.LastUpdate = DateTime.UtcNow; #region Get_InYourCircles try { string _InyourCircles = ObjoAuthTokenGPlus.APIWebRequestToGetUserInfo(Globals.strGetPeopleList.Replace("[userId]", gplusAcc.GpUserId).Replace("[collection]", "visible") + "?key=" + settings.GoogleApiKey, accessToken); JObject J_InyourCircles = JObject.Parse(_InyourCircles); gplusAcc.InYourCircles = Convert.ToInt32(J_InyourCircles["totalItems"].ToString()); } catch (Exception ex) { gplusAcc.InYourCircles = 0; } #endregion #region Get_HaveYouInCircles try { string _HaveYouInCircles = ObjoAuthTokenGPlus.APIWebRequestToGetUserInfo(Globals.strGetPeopleProfile + gplusAcc.GpUserId + "?key=" + settings.GoogleApiKey, accessToken); JObject J_HaveYouInCircles = JObject.Parse(_HaveYouInCircles); gplusAcc.HaveYouInCircles = Convert.ToInt32(J_HaveYouInCircles["circledByCount"].ToString()); } catch (Exception ex) { gplusAcc.HaveYouInCircles = 0; } #endregion dbr.Update <Domain.Socioboard.Models.Googleplusaccounts>(gplusAcc); } else { gplusAcc = new Domain.Socioboard.Models.Googleplusaccounts(); gplusAcc.UserId = userId; gplusAcc.GpUserId = profile["id"].ToString(); try { gplusAcc.GpUserName = profile["displayName"].ToString(); } catch { try { gplusAcc.GpUserName = profile["name"].ToString(); } catch { } } gplusAcc.IsActive = true; gplusAcc.AccessToken = accessToken; gplusAcc.RefreshToken = refreshToken; gplusAcc.EntryDate = DateTime.UtcNow; try { gplusAcc.GpProfileImage = Convert.ToString(profile["image"]["url"]); } catch { try { gplusAcc.GpProfileImage = Convert.ToString(profile["picture"]); } catch { } } gplusAcc.AccessToken = accessToken; try { gplusAcc.about = Convert.ToString(profile["tagline"]); } catch { gplusAcc.about = ""; } try { gplusAcc.college = Convert.ToString(profile["organizations"][0]["name"]); } catch { gplusAcc.college = ""; } try { gplusAcc.coverPic = Convert.ToString(profile["cover"]["coverPhoto"]["url"]); } catch { gplusAcc.coverPic = ""; } try { gplusAcc.education = Convert.ToString(profile["organizations"][0]["type"]); } catch { gplusAcc.education = ""; } try { gplusAcc.EmailId = Convert.ToString(profile["emails"][0]["value"]); } catch { try { try { gplusAcc.EmailId = Convert.ToString(profile["email"]); } catch { } } catch { } gplusAcc.EmailId = ""; } try { gplusAcc.gender = Convert.ToString(profile["gender"]); } catch { gplusAcc.gender = ""; } try { gplusAcc.workPosition = Convert.ToString(profile["occupation"]); } catch { gplusAcc.workPosition = ""; } gplusAcc.LastUpdate = DateTime.UtcNow; #region Get_InYourCircles try { string _InyourCircles = ObjoAuthTokenGPlus.APIWebRequestToGetUserInfo(Globals.strGetPeopleList.Replace("[userId]", gplusAcc.GpUserId).Replace("[collection]", "visible") + "?key=" + settings.GoogleApiKey, accessToken); JObject J_InyourCircles = JObject.Parse(_InyourCircles); gplusAcc.InYourCircles = Convert.ToInt32(J_InyourCircles["totalItems"].ToString()); } catch (Exception ex) { gplusAcc.InYourCircles = 0; } #endregion #region Get_HaveYouInCircles try { string _HaveYouInCircles = ObjoAuthTokenGPlus.APIWebRequestToGetUserInfo(Globals.strGetPeopleProfile + gplusAcc.GpUserId + "?key=" + settings.GoogleApiKey, accessToken); JObject J_HaveYouInCircles = JObject.Parse(_HaveYouInCircles); gplusAcc.HaveYouInCircles = Convert.ToInt32(J_HaveYouInCircles["circledByCount"].ToString()); } catch (Exception ex) { gplusAcc.HaveYouInCircles = 0; } #endregion isSaved = dbr.Add <Domain.Socioboard.Models.Googleplusaccounts>(gplusAcc); } if (isSaved == 1) { List <Domain.Socioboard.Models.Googleplusaccounts> lstgplusAcc = dbr.Find <Domain.Socioboard.Models.Googleplusaccounts>(t => t.GpUserId.Equals(gplusAcc.GpUserId)).ToList(); if (lstgplusAcc != null && lstgplusAcc.Count() > 0) { isSaved = GroupProfilesRepository.AddGroupProfile(groupId, lstgplusAcc.First().GpUserId, lstgplusAcc.First().GpUserName, userId, lstgplusAcc.First().GpProfileImage, Domain.Socioboard.Enum.SocialProfileType.GPlus, dbr); //codes to delete cache _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId); _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId); if (isSaved == 1) { new Thread(delegate() { GetUserActivities(gplusAcc.GpUserId, gplusAcc.AccessToken, settings, _logger); }).Start(); } } } return(isSaved); }
public static int AddGaSites(string profiledata, long userId, long groupId, Helper.Cache _redisCache, Helper.AppSettings _appSettings, Model.DatabaseRepository dbr, IHostingEnvironment _appEnv) { int isSaved = 0; Analytics _Analytics = new Analytics(_appSettings.GoogleConsumerKey, _appSettings.GoogleConsumerSecret, _appSettings.GoogleRedirectUri); Domain.Socioboard.Models.GoogleAnalyticsAccount _GoogleAnalyticsAccount; string[] GAdata = Regex.Split(profiledata, "<:>"); _GoogleAnalyticsAccount = Repositories.GplusRepository.getGAAccount(GAdata[5], _redisCache, dbr); if (_GoogleAnalyticsAccount != null && _GoogleAnalyticsAccount.IsActive == false) { try { _GoogleAnalyticsAccount.UserId = userId; _GoogleAnalyticsAccount.IsActive = true; _GoogleAnalyticsAccount.EntryDate = DateTime.UtcNow; _GoogleAnalyticsAccount.EmailId = GAdata[4]; _GoogleAnalyticsAccount.GaAccountId = GAdata[2]; _GoogleAnalyticsAccount.GaAccountName = GAdata[3]; _GoogleAnalyticsAccount.GaWebPropertyId = GAdata[7]; _GoogleAnalyticsAccount.GaProfileId = GAdata[5]; _GoogleAnalyticsAccount.GaProfileName = GAdata[6]; _GoogleAnalyticsAccount.AccessToken = GAdata[0]; _GoogleAnalyticsAccount.RefreshToken = GAdata[1]; _GoogleAnalyticsAccount.WebsiteUrl = GAdata[8]; string visits = string.Empty; string pageviews = string.Empty; try { string analytics = _Analytics.getAnalyticsData(GAdata[5], "ga:visits,ga:pageviews", DateTime.UtcNow.AddDays(-7).ToString("yyyy-MM-dd"), DateTime.UtcNow.ToString("yyyy-MM-dd"), GAdata[0]); JObject JData = JObject.Parse(analytics); visits = JData["totalsForAllResults"]["ga:visits"].ToString(); pageviews = JData["totalsForAllResults"]["ga:pageviews"].ToString(); } catch (Exception ex) { visits = "0"; pageviews = "0"; } _GoogleAnalyticsAccount.Views = Double.Parse(pageviews); _GoogleAnalyticsAccount.Visits = Double.Parse(visits); _GoogleAnalyticsAccount.ProfilePicUrl = "https://www.socioboard.com/Contents/Socioboard/images/analytics_img.png"; _GoogleAnalyticsAccount.EntryDate = DateTime.UtcNow; } catch (Exception ex) { } dbr.Update <Domain.Socioboard.Models.GoogleAnalyticsAccount>(_GoogleAnalyticsAccount); } else { try { _GoogleAnalyticsAccount = new Domain.Socioboard.Models.GoogleAnalyticsAccount(); _GoogleAnalyticsAccount.UserId = userId; _GoogleAnalyticsAccount.IsActive = true; _GoogleAnalyticsAccount.EntryDate = DateTime.UtcNow; _GoogleAnalyticsAccount.EmailId = GAdata[4]; _GoogleAnalyticsAccount.GaAccountId = GAdata[2]; _GoogleAnalyticsAccount.GaAccountName = GAdata[3]; _GoogleAnalyticsAccount.GaWebPropertyId = GAdata[7]; _GoogleAnalyticsAccount.GaProfileId = GAdata[5]; _GoogleAnalyticsAccount.GaProfileName = GAdata[6]; _GoogleAnalyticsAccount.AccessToken = GAdata[0]; _GoogleAnalyticsAccount.RefreshToken = GAdata[1]; _GoogleAnalyticsAccount.WebsiteUrl = GAdata[8]; string visits = string.Empty; string pageviews = string.Empty; try { string analytics = _Analytics.getAnalyticsData(GAdata[5], "ga:visits,ga:pageviews", DateTime.UtcNow.AddDays(-7).ToString("yyyy-MM-dd"), DateTime.UtcNow.ToString("yyyy-MM-dd"), GAdata[0]); JObject JData = JObject.Parse(analytics); visits = JData["totalsForAllResults"]["ga:visits"].ToString(); pageviews = JData["totalsForAllResults"]["ga:pageviews"].ToString(); } catch (Exception ex) { visits = "0"; pageviews = "0"; } _GoogleAnalyticsAccount.Views = Double.Parse(pageviews); _GoogleAnalyticsAccount.Visits = Double.Parse(visits); _GoogleAnalyticsAccount.ProfilePicUrl = "https://www.socioboard.com/Themes/Socioboard/Contents/img/analytics_img.png"; _GoogleAnalyticsAccount.EntryDate = DateTime.UtcNow; } catch (Exception ex) { } isSaved = dbr.Add <Domain.Socioboard.Models.GoogleAnalyticsAccount>(_GoogleAnalyticsAccount); } if (isSaved == 1) { List <Domain.Socioboard.Models.GoogleAnalyticsAccount> lstgaAcc = dbr.Find <Domain.Socioboard.Models.GoogleAnalyticsAccount>(t => t.GaProfileId.Equals(_GoogleAnalyticsAccount.GaProfileId)).ToList(); if (lstgaAcc != null && lstgaAcc.Count() > 0) { isSaved = GroupProfilesRepository.AddGroupProfile(groupId, lstgaAcc.First().GaProfileId, lstgaAcc.First().GaProfileName, userId, lstgaAcc.First().ProfilePicUrl, Domain.Socioboard.Enum.SocialProfileType.GoogleAnalytics, dbr); //codes to delete cache _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheUserProfileCount + userId); _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId); } } return(isSaved); }
public static Domain.Socioboard.Models.YoutubeGroupInvite InviteGroupMember(Int64 userId, string emailId, Helper.AppSettings settings, ILogger _logger, Model.DatabaseRepository dbr) { YoutubeGroupInvite _objGrp = new YoutubeGroupInvite(); IList <Domain.Socioboard.Models.User> lstUser = dbr.Find <Domain.Socioboard.Models.User>(t => t.Id == userId || t.EmailId == emailId); Domain.Socioboard.Models.User _SBUser = lstUser.FirstOrDefault(t => t.Id == userId); Domain.Socioboard.Models.User _SBUserInvite = lstUser.FirstOrDefault(t => t.EmailId == emailId); IList <Domain.Socioboard.Models.YoutubeGroupInvite> lstGrpUser = dbr.Find <Domain.Socioboard.Models.YoutubeGroupInvite>(t => t.AccessSBUserId == userId); Domain.Socioboard.Models.YoutubeGroupInvite _grpOwner = lstGrpUser.FirstOrDefault(t => t.UserId == userId); Domain.Socioboard.Models.YoutubeGroupInvite _grpInvMem = lstGrpUser.FirstOrDefault(t => t.SBEmailId == emailId); if (_grpOwner == null) { _objGrp.UserId = _SBUser.Id; _objGrp.Owner = true; _objGrp.OwnerName = _SBUser.FirstName + " " + _SBUser.LastName; _objGrp.Active = true; _objGrp.SBUserName = _SBUser.FirstName + " " + _SBUser.LastName; _objGrp.SBEmailId = _SBUser.EmailId; _objGrp.OwnerEmailid = _SBUser.EmailId; if (_SBUser.ProfilePicUrl == null || _SBUser.ProfilePicUrl == "") { _objGrp.SBProfilePic = "https://i.imgur.com/zqN47Qp.png"; } else { _objGrp.SBProfilePic = _SBUser.ProfilePicUrl; } _objGrp.AccessSBUserId = userId; dbr.Add(_objGrp); } if (_SBUserInvite != null && _grpInvMem == null) { _objGrp.UserId = _SBUserInvite.Id; _objGrp.Owner = false; _objGrp.OwnerName = _SBUser.FirstName + " " + _SBUser.LastName; _objGrp.OwnerEmailid = _SBUser.EmailId; _objGrp.Active = false; _objGrp.SBUserName = _SBUserInvite.FirstName + " " + _SBUserInvite.LastName; _objGrp.SBEmailId = _SBUserInvite.EmailId; if (_SBUserInvite.ProfilePicUrl == null || _SBUserInvite.ProfilePicUrl == "") { _objGrp.SBProfilePic = "https://i.imgur.com/zqN47Qp.png"; } else { _objGrp.SBProfilePic = _SBUserInvite.ProfilePicUrl; } _objGrp.AccessSBUserId = userId; _objGrp.EmailValidationToken = SBHelper.RandomString(35); dbr.Add(_objGrp); return(_objGrp); } else if (_SBUserInvite == null && _grpInvMem == null) { _objGrp.UserId = 0; _objGrp.Owner = false; _objGrp.OwnerName = _SBUser.FirstName + " " + _SBUser.LastName; _objGrp.OwnerEmailid = _SBUser.EmailId; _objGrp.Active = false; _objGrp.SBUserName = "******"; _objGrp.SBEmailId = emailId; _objGrp.SBProfilePic = "https://i.imgur.com/zqN47Qp.png"; _objGrp.EmailValidationToken = SBHelper.RandomString(35); _objGrp.AccessSBUserId = userId; dbr.Add(_objGrp); return(_objGrp); } else if (_grpInvMem.Active == false) { return(_grpInvMem); } else { return(null); } }
public static string AddRssContentsUrl(string keywords, long userId, Helper.AppSettings _appSettings, Model.DatabaseRepository dbr) { MongoRepository _rssNewsContents = new MongoRepository("RssNewsContents", _appSettings); //Domain.Socioboard.Models.RssFeedUrl _RssFeedUrl = dbr.FindSingle<Domain.Socioboard.Models.RssFeedUrl>(t => t.rssurl.Contains(url)); List <string> list = new List <string>(); list = findUrl(keywords).ToList(); Domain.Socioboard.Models.Mongo.RssNewsContents _rssnews = new Domain.Socioboard.Models.Mongo.RssNewsContents(); Domain.Socioboard.Models.RssFeedUrl _RssContentFeeds = new Domain.Socioboard.Models.RssFeedUrl(); foreach (var urlValue in list) { if (urlValue != null) { string rt = ParseFeedUrl(urlValue.ToString(), keywords, userId.ToString(), _appSettings); _RssContentFeeds = dbr.FindSingle <Domain.Socioboard.Models.RssFeedUrl>(t => t.rssurl.Contains(urlValue) && t.Keywords != null); if (_RssContentFeeds != null) { //return _RssFeedUrl.ToString(); } else { _RssContentFeeds = new Domain.Socioboard.Models.RssFeedUrl(); _RssContentFeeds.rssurl = urlValue; _RssContentFeeds.LastUpdate = DateTime.UtcNow; _RssContentFeeds.Keywords = keywords; try { dbr.Add <Domain.Socioboard.Models.RssFeedUrl>(_RssContentFeeds); } catch (Exception error) { } //_RssContentFeedUrl = dbr.FindSingle<Domain.Socioboard.Models.RssFeedUrl>(t => t.rssurl.Contains(urlValue) && t.Keywords == null); //return urlValue; } var ret = _rssNewsContents.Find <Domain.Socioboard.Models.Mongo.RssNewsContents>(t => t.RssFeedUrl.Equals(urlValue) && t.ProfileId.Contains(userId.ToString())); var task = Task.Run(async() => { return(await ret); }); int count = task.Result.Count; if (count < 1) { _rssnews.Id = ObjectId.GenerateNewId(); _rssnews.ProfileId = userId.ToString(); _rssnews.RssFeedUrl = urlValue.ToString(); _rssnews.LastUpdate = Domain.Socioboard.Helpers.SBHelper.ConvertToUnixTimestamp(DateTime.UtcNow); _rssNewsContents.Add(_rssnews); } else { return("Data already added"); } } } return("added successfully"); }
public static string ComposeLinkedInMessage(string ImageUrl, long userid, string comment, string ProfileId, string imagepath, Domain.Socioboard.Models.LinkedInAccount _objLinkedInAccount, Model.DatabaseRepository dbr, Domain.Socioboard.Models.ScheduledMessage schmessage, Domain.Socioboard.Models.User _user) { string json = ""; var img = ""; Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = _objLinkedInAccount; oAuthLinkedIn _oauth = new oAuthLinkedIn(); _oauth.ConsumerKey = AppSettings.LinkedinApiKey; _oauth.ConsumerSecret = AppSettings.LinkedinSecretKey; _oauth.Token = _LinkedInAccount.OAuthToken; string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json"; if (string.IsNullOrEmpty(ImageUrl)) { json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, comment); } else { var client = new ImgurClient(AppSettings.imgurclietId, AppSettings.imgurclietSecret); var endpoint = new ImageEndpoint(client); IImage image; using (var fs = new FileStream(imagepath, FileMode.Open)) { image = endpoint.UploadImageStreamAsync(fs).GetAwaiter().GetResult(); } var imgs = image.Link; json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, comment, imgs); } if (!string.IsNullOrEmpty(json)) { apiHitsCount++; schmessage.status = Domain.Socioboard.Enum.ScheduleStatus.Compleated; schmessage.url = json; dbr.Update <ScheduledMessage>(schmessage); Domain.Socioboard.Models.Notifications notify = new Notifications(); Notifications lstnotifications = dbr.Single <Notifications>(t => t.MsgId == schmessage.id); if (lstnotifications == null) { notify.MsgId = schmessage.id; notify.MsgStatus = "Scheduled"; notify.notificationtime = schmessage.localscheduletime; notify.NotificationType = "Schedule Successfully"; notify.ReadOrUnread = "Unread"; notify.UserId = userid; dbr.Add <Notifications>(notify); if (_user.scheduleSuccessUpdates) { string sucResponse = SendMailbySendGrid(AppSettings.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, true, AppSettings.sendGridUserName, AppSettings.sendGridPassword); } return("posted"); } else { if (_user.scheduleSuccessUpdates) { string sucResponse = SendMailbySendGrid(AppSettings.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, true, AppSettings.sendGridUserName, AppSettings.sendGridPassword); } return("posted"); } } else { apiHitsCount = MaxapiHitsCount; json = "Message not posted"; Domain.Socioboard.Models.Notifications notify = new Notifications(); Notifications lstnotifications = dbr.Single <Notifications>(t => t.MsgId == schmessage.id); if (lstnotifications == null) { notify.MsgId = schmessage.id; notify.MsgStatus = "Failed"; notify.notificationtime = schmessage.localscheduletime; notify.NotificationType = "Schedule Failed"; notify.ReadOrUnread = "Unread"; notify.UserId = userid; dbr.Add <Notifications>(notify); if (_user.scheduleFailureUpdates) { string falResponse = SendMailbySendGrid(AppSettings.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, false, AppSettings.sendGridUserName, AppSettings.sendGridPassword); } return(json); } else { if (_user.scheduleFailureUpdates) { string falResponse = SendMailbySendGrid(AppSettings.frommail, "", _user.EmailId, "", "", "", "", _user.FirstName, schmessage.localscheduletime, false, AppSettings.sendGridUserName, AppSettings.sendGridPassword); } return(json); } } }