Skip to content

Commit

Permalink
socioboard 3.0 update
Browse files Browse the repository at this point in the history
socioboard 3.0 update
  • Loading branch information
swetasb committed Mar 26, 2018
1 parent 6997f4b commit 07cece4
Show file tree
Hide file tree
Showing 525 changed files with 12,471 additions and 2,080 deletions.
Binary file modified .vs/Socioboard/v14/.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion src/Api.Socioboard/Controllers/BoardMeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ public IActionResult getGplusfeeds(long boardId, int skip, int count)
List<MongoBoardGplusFeeds> lstBGFeeds = objTwitterPagelist.ToList();
foreach (var items_lstBGFeed in lstBGFeeds)
{
if (items_lstBGFeed.FromName.Any(c => char.IsSymbol(c)))
if (items_lstBGFeed.FromName.Any(c => char.IsSymbol(c)) || items_lstBGFeed.Title.Contains("¾"))
{
objTwitterPagelist.Remove(items_lstBGFeed);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Api.Socioboard/Controllers/FacebookController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,15 @@ public IActionResult ComposeMessage(string message, string profileId, long userI
byte[] img = webClient.DownloadData(imagePath);
media.SetValue(img);
args["source"] = media;
ret = fb.Post("v2.0/" + objFacebookAccount.FbUserId + "/photos", args).ToString();
ret = fb.Post("v2.7/" + objFacebookAccount.FbUserId + "/photos", args).ToString();
}
else
{
if (!string.IsNullOrEmpty(link))
{
args["link"] = link;
}
ret = fb.Post("v2.0/" + objFacebookAccount.FbUserId + "/feed", args).ToString();
ret = fb.Post("v2.7/" + objFacebookAccount.FbUserId + "/feed", args).ToString();

}
ScheduledMessage scheduledMessage = new ScheduledMessage();
Expand Down
68 changes: 68 additions & 0 deletions src/Api.Socioboard/Controllers/InstagramController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,5 +253,73 @@ public IActionResult GetInstaAccSingle(string accId)
Domain.Socioboard.Models.Instagramaccounts pageDetails = dbr.Single<Domain.Socioboard.Models.Instagramaccounts>(t => t.InstagramId == accId);
return Ok(pageDetails);
}


// [HttpGet("alldata")]
//public IActionResult Notifications(long groupId, long userId , int skip, int count)
//{

// DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
// List<int> alldata = new List<int>();
// List<Domain.Socioboard.Models.Groupprofiles> lstGrpProfiles = Repositories.GroupProfilesRepository.getAllGroupProfiles(groupId, _redisCache, dbr);
// List<Domain.Socioboard.Models.Mongo.MongoTwitterMessage> lstTwtMessages = new List<Domain.Socioboard.Models.Mongo.MongoTwitterMessage>();
// List<Domain.Socioboard.Models.Mongo.MongoTwitterMessage> TwtMessages = new List<Domain.Socioboard.Models.Mongo.MongoTwitterMessage>();
// foreach (var item in lstGrpProfiles.Where(t => t.profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter))
// {
// MongoRepository mongorepo = new MongoRepository("MongoTwitterMessage", _appSettings);
// var builder = Builders<Domain.Socioboard.Models.Mongo.MongoTwitterMessage>.Sort;
// var sort = builder.Descending(t => t.messageDate);
// var result = mongorepo.FindWithRange<Domain.Socioboard.Models.Mongo.MongoTwitterMessage>(t => t.profileId.Equals(item.profileId) && (t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterMention || t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterRetweet || t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterFollower || t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterUsertweet), sort, skip, count);
// var task = Task.Run(async () =>
// {
// return await result;
// });
// IList<Domain.Socioboard.Models.Mongo.MongoTwitterMessage> lstTwitterTweets = task.Result;
// TwtMessages = lstTwitterTweets.Where(t => t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterUsertweet).ToList();
// if (lstTwitterTweets != null)
// {
// lstTwtMessages.AddRange(lstTwitterTweets);
// }
// var d = lstTwitterTweets.Count;
// }
// int posttext = TwtMessages.FindAll(t => t.twitterMsg!= null && t.mediaUrl== null && !t.twitterMsg.Contains("http") || !t.twitterMsg.Contains("https") || !t.twitterMsg.Contains("www.") || !t.twitterMsg.Contains("http://") || !t.twitterMsg.Contains("https://") || !t.twitterMsg.Contains("www.")).Count;
// int mediapost = TwtMessages.FindAll(t => t.mediaUrl != null).Count;
// int linkpost= TwtMessages.FindAll(t => t.twitterMsg.Contains("http") || t.twitterMsg.Contains("https") || t.twitterMsg.Contains("www.") || t.twitterMsg.Contains("http://") || t.twitterMsg.Contains("https://") || t.twitterMsg.Contains("www.")).Count;
// int mentions = lstTwtMessages.FindAll(t => t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterMention).Count;
// int retweet = lstTwtMessages.FindAll(t => t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterRetweet).Count;

//// || t.twitterMsg.Contains("https") || t.twitterMsg.Contains("www.") || t.twitterMsg.Contains("http://") || t.twitterMsg.Contains("https://") || t.twitterMsg.Contains("www.")
// alldata.Add(mentions);
// alldata.Add(retweet);
// List<Domain.Socioboard.Models.Mongo.MongoTwitterDirectMessages> lstTwtMessagess = new List<Domain.Socioboard.Models.Mongo.MongoTwitterDirectMessages>();

// foreach (var item in lstGrpProfiles.Where(t => t.profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter))
// {
// MongoRepository mongorepoDm = new MongoRepository("MongoTwitterDirectMessages", _appSettings);

// var builder = Builders<Domain.Socioboard.Models.Mongo.MongoTwitterDirectMessages>.Sort;
// var sort = builder.Descending(t => t.entryDate);
// var result = mongorepoDm.FindWithRange<Domain.Socioboard.Models.Mongo.MongoTwitterDirectMessages>(t => t.profileId.Equals(item.profileId) && (t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterDirectMessageReceived || t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterDirectMessageSent), sort, skip, count);
// var task = Task.Run(async () =>
// {
// return await result;
// });
// IList<Domain.Socioboard.Models.Mongo.MongoTwitterDirectMessages> lstTwitterdm = task.Result;
// if (lstTwitterdm != null)
// {
// lstTwtMessagess.AddRange(lstTwitterdm);
// }

// }

// int dmrecived = lstTwtMessagess.FindAll(t => t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterDirectMessageReceived).Count;
// int dmsend = lstTwtMessagess.FindAll(t => t.type == Domain.Socioboard.Enum.TwitterMessageType.TwitterDirectMessageSent).Count;
// alldata.Add(dmrecived);
// alldata.Add(dmsend);
// alldata.Add(posttext);
// alldata.Add(mediapost);
// alldata.Add(linkpost);
// return Ok(alldata);
//}
}
}
217 changes: 217 additions & 0 deletions src/Api.Socioboard/Controllers/RssFeedController.cs~RF2f872c63.TMP
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging;
using Api.Socioboard.Model;
using Microsoft.AspNetCore.Cors;
using System.Xml;
using System.Text.RegularExpressions;
using Socioboard.Twitter.App.Core;
using MongoDB.Driver;

// For more information on enabling Web API for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860

namespace Api.Socioboard.Controllers
{
[EnableCors("AllowAll")]
[Route("api/[controller]")]
public class RssFeedController : Controller
{
public RssFeedController(ILogger<RssFeedController> logger, Microsoft.Extensions.Options.IOptions<Helper.AppSettings> settings, IHostingEnvironment env)
{
_logger = logger;
_appSettings = settings.Value;
_redisCache = new Helper.Cache(_appSettings.RedisConfiguration);
_env = env;
}
private readonly ILogger _logger;
private Helper.AppSettings _appSettings;
private Helper.Cache _redisCache;
private readonly IHostingEnvironment _env;


/// <summary>
///
/// </summary>
/// <param name="userId">id of the user</param>
/// <param name="groupId">Id of the group to which account is to be added. </param>
/// <param name="rssUrl"></param>
/// <param name="profileId"></param>
/// <returns></returns>
[HttpPost("AddRssUrl")]
public IActionResult AddRssUrl(long userId, long groupId, string rssUrl, string profileId)
{

try
{
XmlDocument xmlDoc = new XmlDocument(); // Create an XML document object
xmlDoc.Load(rssUrl);
var abc = xmlDoc.DocumentElement.GetElementsByTagName("item");
if (abc.Count == 0)
{
return Ok("This Url Does't Conatin Rss Feed");
}
}
catch (Exception ex)
{
return Ok("This Url Does't Conatin Rss Feed");
}

DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
string _RssFeedUrl = Repositories.RssFeedRepository.AddRssUrl(profileId, rssUrl, dbr);
if (_RssFeedUrl != "null")
{
string[] lstProfileIds = null;
if (profileId != null)
{
lstProfileIds = profileId.Split(',');
profileId = lstProfileIds[0];
}
else
{
return Ok("profileId required");
}

foreach (var item in lstProfileIds)
{
if (item.StartsWith("fb"))
{
string prId = item.Substring(3, item.Length - 3);
Domain.Socioboard.Models.Facebookaccounts objFacebookAccount = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(prId, _redisCache, dbr);
string ret = Repositories.RssFeedRepository.AddRssFeed(rssUrl, userId, prId, Domain.Socioboard.Enum.SocialProfileType.Facebook, "http://graph.facebook.com/" + objFacebookAccount.FbUserId + "/picture?type=small", objFacebookAccount.FbUserName, dbr, _appSettings);

}

if (item.StartsWith("page"))
{
string prId = item.Substring(5, item.Length - 5);
Domain.Socioboard.Models.Facebookaccounts objFacebookAccount = Api.Socioboard.Repositories.FacebookRepository.getFacebookAccount(prId, _redisCache, dbr);
string ret = Repositories.RssFeedRepository.AddRssFeed(rssUrl, userId, prId, Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage, "http://graph.facebook.com/" + objFacebookAccount.FbUserId + "/picture?type=small", objFacebookAccount.FbUserName, dbr, _appSettings);

}
if (item.StartsWith("tw"))
{
string prId = item.Substring(3, item.Length - 3);
Domain.Socioboard.Models.TwitterAccount objTwitterAccount = Api.Socioboard.Repositories.TwitterRepository.getTwitterAccount(prId, _redisCache, dbr);
string ret = Repositories.RssFeedRepository.AddRssFeed(rssUrl, userId, prId, Domain.Socioboard.Enum.SocialProfileType.Twitter, objTwitterAccount.profileImageUrl, objTwitterAccount.twitterName, dbr, _appSettings);

}
}


}
return Ok("Added Successfully");
}

[HttpPost("PostRssFeeds")]
public IActionResult PostRssFeeds(string profileId, string userId, string rssUrl)
{
DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
string ret = Repositories.RssFeedRepository.PostRssfeed(profileId, rssUrl, _appSettings, dbr, _redisCache);
return Ok(ret);
}


[HttpGet("GetPostedRssDataByUser")]
public IActionResult GetPostedRssDataByUser(long userId, long groupId)
{
DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
List<Domain.Socioboard.Models.Mongo.RssFeed> lstRss = Repositories.RssFeedRepository.GetPostedRssDataByUser(userId, groupId, _appSettings, dbr);
lstRss = lstRss.Where(t => !string.IsNullOrEmpty(t.Message)).ToList();
List<Domain.Socioboard.Models.Mongo.RssFeed> lstRssFeeds = lstRss.OrderByDescending(t=>t.PublishingDate).ToList();
return Ok(lstRssFeeds);
}

[HttpGet("GetRssDataByUser")]
public IActionResult GetRssDataByUser(long userId, long groupId)
{
DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
List<Domain.Socioboard.Models.Mongo.Rss> lstRss = Repositories.RssFeedRepository.GetRssDataByUser(userId, groupId, _appSettings, dbr);
return Ok(lstRss);
}


[HttpPost("EditFeedUrl")]
public IActionResult EditFeedUrl(string NewFeedUrl, string OldFeedUrl, string RssId)
{
try
{
XmlDocument xmlDoc = new XmlDocument(); // Create an XML document object
xmlDoc.Load(NewFeedUrl);
var abc = xmlDoc.DocumentElement.GetElementsByTagName("item");
if (abc.Count == 0)
{
return Ok("This Url Does't Conatin Rss Feed");
}
}
catch (Exception ex)
{
return Ok("This Url Does't Conatin Rss Feed");
}
DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
string editdata = Repositories.RssFeedRepository.EditFeedUrl(NewFeedUrl, OldFeedUrl, RssId, _appSettings, dbr);
return Ok(editdata);
}

[HttpPost("DeleteFeedUrl")]
public IActionResult DeleteFeedUrl(string RssId)
{
DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
string deletedata = Repositories.RssFeedRepository.DeleteFeedUrl(RssId, dbr, _appSettings);
return Ok(deletedata);
}

// add and fetch the data for content feeds
[HttpGet("RssNewsFeedsUrl")]
public IActionResult RssNewsFeedsUrl(string userId, string keyword)
{
DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
string res1 = Repositories.RssNewsContentsRepository.AddRssContentsUrl(keyword, userId, _appSettings, dbr);
//string res2 = Repositories.RssNewsContentsRepository.addtwitterContentfeedsdata(keyword, userId, _appSettings);
bool res3 = Repositories.RssNewsContentsRepository.addGplusContentfeedsdata(keyword, userId, _appSettings);
DatabaseRepository bdr = new DatabaseRepository(_logger, _env);
List<Domain.Socioboard.Models.Mongo.RssNewsContentsFeeds> lstcontent = Repositories.RssNewsContentsRepository.GetRssNewsFeeds(userId, keyword, _appSettings);
return Ok(lstcontent);
}

//for geting posted data
[HttpGet("getRssNewsFeedsPost")]
public IActionResult getRssNewsFeedsPost(string userId , int skip ,int count)
{
DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
if(count < 100)
{
// return Ok(Repositories.TwitterRepository.GetTopFeeds(profileId, userId, _redisCache, _appSettings).Skip(skip).Take(count));
return Ok(Repositories.RssNewsContentsRepository.GetRssNewsPostedFeeds(userId, _redisCache, _appSettings).Skip(skip).Take(count));
// List<Domain.Socioboard.Models.Mongo.RssNewsContentsFeeds> lstRss = Repositories.RssNewsContentsRepository.GetRssNewsPostedFeeds(userId, _redisCache, _appSettings);

}
else
{
MongoRepository mongorepo = new MongoRepository("RssNewsContentsFeeds", _appSettings);
var builder = Builders<Domain.Socioboard.Models.Mongo.RssNewsContentsFeeds>.Sort;
var sort = builder.Descending(t => t.PublishingDate);
var result = mongorepo.FindWithRange<Domain.Socioboard.Models.Mongo.RssNewsContentsFeeds>(t => t.UserId.Equals(userId), sort, skip, count);
var task = Task.Run(async () =>
{
return await result;
});
IList<Domain.Socioboard.Models.Mongo.RssNewsContentsFeeds> lstcontentFeeds = task.Result;
return Ok(lstcontentFeeds);
}
// lstRss = lstRss.Where(t => !string.IsNullOrEmpty(t.Message)).ToList();
//return Ok(lstRss);
}


[HttpPost("DeleteContentFeeds")]
public IActionResult DeleteContentFeeds(string contentfeedid)
{
string feedData = Repositories.RssNewsContentsRepository.DeleteContentfeedsRepo(contentfeedid, _appSettings);
return Ok(feedData);
}
}
}
16 changes: 9 additions & 7 deletions src/Api.Socioboard/Controllers/TwitterController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -521,23 +521,25 @@ public IActionResult GettwitterSingle(string profileId)

}

[HttpPost("publish")]
public IActionResult publish(string profileId, string twitterText, long userId, string imgUrl, string strid)
[HttpPost("publish")]
public IActionResult publish(string profileId,string twitterText, long userId , string imgUrl ,string strid)
{
DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
string ret = Helper.TwitterHelper.PostTwitterMessage(_appSettings, _redisCache, twitterText, profileId, userId, imgUrl, true, 0, "", dbr, _logger);
if (ret == "")
if (ret =="")
{
string responce = SavedFeedsManagementRepository.publish(profileId, strid, _appSettings);
string responce = SavedFeedsManagementRepository.publish( profileId, strid, _appSettings);

return Ok(responce);
}
else
{
return Ok("failed");
}



}
}
}


}
}
Loading

0 comments on commit 07cece4

Please sign in to comment.