public IActionResult PluginScheduleMessage(string profile, string twitterText, string tweetId, string tweetUrl, string facebookText, string url, string imgUrl, long userId, string scheduleTime) { string[] profiles = profile.Split(','); foreach (var item in profiles) { string[] ids = item.Split('~'); if (ids[1] == "facebook") { DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); Domain.Socioboard.Models.Facebookaccounts objFacebookAccount = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(ids[0], _redisCache, dbr); Helper.ScheduleMessageHelper.ScheduleMessage(ids[0], objFacebookAccount.FbUserName, facebookText.ToString(), Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage, userId, imgUrl, "https://graph.facebook.com/" + ids[0] + "/picture?type=small", scheduleTime, _appSettings, _redisCache, dbr, _logger); } else { DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); if (!string.IsNullOrEmpty(twitterText) || !string.IsNullOrEmpty(imgUrl)) { twitterText = twitterText + " " + tweetUrl; Domain.Socioboard.Models.TwitterAccount objTwitterAccount = Api.Socioboard.Repositories.TwitterRepository.getTwitterAccount(ids[0], _redisCache, dbr); Helper.ScheduleMessageHelper.ScheduleMessage(ids[0], objTwitterAccount.twitterScreenName, twitterText, Domain.Socioboard.Enum.SocialProfileType.Twitter, userId, imgUrl, objTwitterAccount.profileImageUrl, scheduleTime, _appSettings, _redisCache, dbr, _logger); } else { string data = TwitterRepository.TwitterRetweet_post(ids[0], tweetId, userId, 0, dbr, _logger, _redisCache, _appSettings); } } } return(Ok()); }
public IActionResult PluginComposemessage(string profile, string twitterText, string tweetId, string tweetUrl, string facebookText, string url, string imgUrl, long userId) { string[] profiles = profile.Split(','); foreach (var item in profiles) { string[] ids = item.Split('~'); if (ids[1] == "facebook") { DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); Domain.Socioboard.Models.Facebookaccounts objFacebookAccount = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(ids[0], _redisCache, dbr); string ret = Helper.FacebookHelper.ComposeMessage(objFacebookAccount.FbProfileType, objFacebookAccount.AccessToken, objFacebookAccount.FbUserId, facebookText, ids[0], userId, imgUrl, url, dbr, _logger); } else { DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); if (!string.IsNullOrEmpty(twitterText) || !string.IsNullOrEmpty(imgUrl)) { twitterText = twitterText + " " + tweetUrl; string ret = Helper.TwitterHelper.PostTwitterMessage(_appSettings, _redisCache, twitterText, ids[0], userId, imgUrl, true, dbr, _logger); } else { string data = TwitterRepository.TwitterRetweet_post(ids[0], tweetId, userId, 0, dbr, _logger, _redisCache, _appSettings); } } } return(Ok()); }
public IActionResult PluginScheduleMessage(string profile, string twitterText, string tweetId, string tweetUrl, string facebookText, string url, string imgUrl, long userId, string scheduleTime, string localscheduleTime) { string[] profiles = profile.Split(','); foreach (var item in profiles) { string[] ids = item.Split('~'); if (ids[1] == "facebook") { try { string updatedtext = ""; string postmessage = ""; if (!string.IsNullOrEmpty(facebookText)) { string[] updatedmessgae = Regex.Split(facebookText, "<br>"); foreach (var items in updatedmessgae) { if (!string.IsNullOrEmpty(items)) { if (items.Contains("https://") || items.Contains("http://")) { if (string.IsNullOrEmpty(url)) { url = items; if (items.Contains("https://")) { string link = getBetween(url + "###", "https", "###"); link = "https" + link; url = link; } if (items.Contains("http://")) { string link = getBetween(url + "###", "http", "###"); link = "http" + link; url = link; } } } if (items.Contains("hhh") || items.Contains("nnn")) { if (items.Contains("hhh")) { postmessage = postmessage + "\n\r" + items.Replace("hhh", "#"); } else { postmessage = postmessage + "\n\r" + items; } } else { postmessage = postmessage + "\n\r" + items; } } } } updatedtext = postmessage; DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); Domain.Socioboard.Models.Facebookaccounts objFacebookAccount = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(ids[0], _redisCache, dbr); Helper.ScheduleMessageHelper.ScheduleMessage(ids[0], objFacebookAccount.FbUserName, updatedtext.ToString(), Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage, userId, url, imgUrl, "https://graph.facebook.com/" + ids[0] + "/picture?type=small", scheduleTime, localscheduleTime, _appSettings, _redisCache, dbr, _logger); } catch (Exception ex) { } } else { try { DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); if (!string.IsNullOrEmpty(twitterText) || !string.IsNullOrEmpty(imgUrl)) { twitterText = twitterText + " " + tweetUrl; Domain.Socioboard.Models.TwitterAccount objTwitterAccount = Api.Socioboard.Repositories.TwitterRepository.getTwitterAccount(ids[0], _redisCache, dbr); Helper.ScheduleMessageHelper.ScheduleMessage(ids[0], objTwitterAccount.twitterScreenName, twitterText, Domain.Socioboard.Enum.SocialProfileType.Twitter, userId, "", imgUrl, objTwitterAccount.profileImageUrl, scheduleTime, localscheduleTime, _appSettings, _redisCache, dbr, _logger); } else { string data = TwitterRepository.TwitterRetweet_post(ids[0], tweetId, userId, 0, dbr, _logger, _redisCache, _appSettings); } } catch (Exception ex) { } } } return(Ok()); }
public IActionResult PluginComposemessage(string profile, string twitterText, string tweetId, string tweetUrl, string facebookText, string url, string imgUrl, long userId) { string[] profiles = profile.Split(','); int i = 0; foreach (var item in profiles) { string[] ids = item.Split('~'); if (ids[1] == "facebook") { string updatedtext = ""; string postmessage = ""; DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); Domain.Socioboard.Models.Facebookaccounts objFacebookAccount = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(ids[0], _redisCache, dbr); if (!string.IsNullOrEmpty(facebookText)) { string[] updatedmessgae = Regex.Split(facebookText, "<br>"); foreach (var items in updatedmessgae) { if (!string.IsNullOrEmpty(items)) { if (items.Contains("https://") || items.Contains("http://")) { if (string.IsNullOrEmpty(url)) { url = items; if (items.Contains("https://")) { string link = getBetween(url + "###", "https", "###"); link = "https" + link; url = link; } if (items.Contains("http://")) { string link = getBetween(url + "###", "http", "###"); link = "http" + link; url = link; } } } if (items.Contains("hhh") || items.Contains("nnn")) { if (items.Contains("hhh")) { postmessage = postmessage + "\n\r" + items.Replace("hhh", "#"); } else { postmessage = postmessage + "\n\r" + items; } } else { postmessage = postmessage + "\n\r" + items; } } } } updatedtext = postmessage.Replace(url, ""); int count = dbr.GetCount <ScheduledMessage>(t => t.shareMessage == updatedtext && t.profileId == objFacebookAccount.FbUserId && t.url == imgUrl && t.scheduleTime.Date == DateTime.UtcNow.Date); if (count > 0) { i++; } else { string ret = Helper.FacebookHelper.ComposeMessage(objFacebookAccount.FbProfileType, objFacebookAccount.AccessToken, objFacebookAccount.FbUserId, updatedtext, ids[0], userId, imgUrl, url, dbr, _logger); } } else { DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); if (!string.IsNullOrEmpty(twitterText) || !string.IsNullOrEmpty(imgUrl)) { twitterText = twitterText + " " + tweetUrl; int count = dbr.GetCount <ScheduledMessage>(t => t.shareMessage == twitterText && t.profileId == ids[0] && t.url == imgUrl && t.scheduleTime.Date == DateTime.UtcNow.Date); if (count > 0) { i++; } else { string ret = Helper.TwitterHelper.PostTwitterMessage(_appSettings, _redisCache, twitterText, ids[0], userId, imgUrl, true, dbr, _logger); } } else { string data = TwitterRepository.TwitterRetweet_post(ids[0], tweetId, userId, 0, dbr, _logger, _redisCache, _appSettings); } } } if (i > 0) { return(Ok("it seems you already posted this message to few profiles")); } return(Ok("successfully posted")); }