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 May 1, 2018
1 parent 6df5305 commit 4f05569
Show file tree
Hide file tree
Showing 190 changed files with 354 additions and 2,345 deletions.
Binary file modified .vs/Socioboard/v14/.suo
Binary file not shown.
62 changes: 54 additions & 8 deletions src/Api.Socioboard/Controllers/NotificationsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Socioboard.Twitter.App.Core;
using MongoDB.Driver;
using Domain.Socioboard.Models;
using MongoDB.Bson;

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

Expand Down Expand Up @@ -144,36 +145,81 @@ public IActionResult UpdateNotifications(long userId)
public IActionResult ChangePasswordDetail(long userId)
{
try
{

{
MongoRepository mongorepo = new MongoRepository("FacebookPasswordChangeUserDetail", _appSettings);
DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
List<Domain.Socioboard.Models.Facebookaccounts> datalst = dbr.Find<Facebookaccounts>(t => t.UserId == userId).ToList();
Domain.Socioboard.Models.User userDet = dbr.FindSingle<User>(t => t.Id == userId);
// Domain.Socioboard.Models.User userDet = dbr.FindSingle<User>(t => t.Id == userId);
var result = mongorepo.Find<Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail>(t => t.userId == userId && t.status==false);
var task = Task.Run(async () =>
{
return await result;
});
int count = task.Result.Count;
IList<Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail> lstfbpasschange = task.Result;


List<Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail> lstfab = new List<Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail>();
foreach(var lstfb in lstfbpasschange)
{
if (lstfb.message.Contains("password"))
{
string str = lstfb.message;
try
{
lstfab.Add(lstfb);
}
catch (Exception ex)
{

}

}

}
if (count>0)
{
return Ok(userDet);
return Ok(lstfab);
}
else
{
return NotFound();
return Ok("No Data");
}
}
catch (Exception ex)
{
return NotFound();
}
}

[HttpGet("ChangeStatus")]
public IActionResult ChangeStatus(string profileId)
{
try
{
MongoRepository mongorepo = new MongoRepository("FacebookPasswordChangeUserDetail", _appSettings);
// DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
// List<Domain.Socioboard.Models.Facebookaccounts> datalst = dbr.Find<Facebookaccounts>(t => t.UserId == userId).ToList();
// Domain.Socioboard.Models.User userDet = dbr.FindSingle<User>(t => t.Id == userId);
// Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail lstchanges = new Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail();
var result = mongorepo.Find<Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail>(t => t.profileId == profileId && t.status == false);
var task = Task.Run(async () =>
{
return await result;
});
int count = task.Result.Count;
if (count > 0)
{

var builders = Builders<BsonDocument>.Filter;
FilterDefinition<BsonDocument> filter = builders.Eq("profileId", profileId);
var update = Builders<BsonDocument>.Update.Set("status", true);
mongorepo.Update<Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail>(update, filter);
}
}
catch (Exception ex)
{

}
return Ok("success");
}

[HttpGet("getfbchangeprofile")]
Expand All @@ -192,7 +238,7 @@ public IActionResult getfbchangeprofile(long userId)
IList<Domain.Socioboard.Models.Mongo.FacebookPasswordChangeUserDetail> lstfbpasschange = task.Result;
if (count>0)
{
return Ok(lstfbpasschange.FirstOrDefault().profileId);
return Ok(lstfbpasschange);
}
else
{
Expand Down
92 changes: 80 additions & 12 deletions src/Api.Socioboard/Controllers/RssFeedController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,96 @@ public RssFeedController(ILogger<RssFeedController> logger, Microsoft.Extensions
/// <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, null,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, null,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, null,dbr, _appSettings);

}
}


}
return Ok("Added Successfully");
}

[HttpPost("AddXMlUrl")]
public IActionResult AddXMlUrl(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");
var abc = xmlDoc.DocumentElement.GetElementsByTagName("sitemap");

if (abc.Count == 0)
{
return Ok("This Url Does't Conatin Rss Feed");
var urldata = xmlDoc.DocumentElement.GetElementsByTagName("url");
if(urldata.Count==0)
{
return Ok("This Url Does't Conatin xml sitemap url");
}
}
}
catch (Exception ex)
{
return Ok("This Url Does't Conatin Rss Feed");
}
return Ok("This Url Does't Conatin xml sitemap url");
}

DatabaseRepository dbr = new DatabaseRepository(_logger, _env);
string _RssFeedUrl = Repositories.RssFeedRepository.AddRssUrl(profileId, rssUrl, dbr);
if (_RssFeedUrl != "null")
if (_RssFeedUrl != "null")
{
string[] lstProfileIds = null;
if (profileId != null)
Expand All @@ -81,22 +151,22 @@ public IActionResult AddRssUrl(long userId, long groupId, string rssUrl, string
{
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);
string ret = Repositories.RssFeedRepository.AddRssFeed(rssUrl, userId, prId, Domain.Socioboard.Enum.SocialProfileType.Facebook, "http://graph.facebook.com/" + objFacebookAccount.FbUserId + "/picture?type=small", objFacebookAccount.FbUserName, "xmldata",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);
string ret = Repositories.RssFeedRepository.AddRssFeed(rssUrl, userId, prId, Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage, "http://graph.facebook.com/" + objFacebookAccount.FbUserId + "/picture?type=small", objFacebookAccount.FbUserName,"xmldata" ,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);
string ret = Repositories.RssFeedRepository.AddRssFeed(rssUrl, userId, prId, Domain.Socioboard.Enum.SocialProfileType.Twitter, objTwitterAccount.profileImageUrl, objTwitterAccount.twitterName,"xmldata", dbr, _appSettings);

}
}
Expand Down Expand Up @@ -184,10 +254,8 @@ 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);

return Ok(Repositories.RssNewsContentsRepository.GetRssNewsPostedFeeds(userId, _redisCache, _appSettings).Skip(skip).Take(count));

}
else
{
Expand Down
12 changes: 10 additions & 2 deletions src/Api.Socioboard/Repositories/FacebookRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,13 @@ public static void SaveFacebookFeeds(string AccessToken, string ProfileId, Helpe
objFacebookFeed.FromName = result["from"]["name"].ToString();
objFacebookFeed.FromId = result["from"]["id"].ToString();
objFacebookFeed.FeedId = result["id"].ToString();
objFacebookFeed.FeedDate = DateTime.Parse(result["created_time"].ToString()).ToString("yyyy/MM/dd HH:mm:ss");
try
{
//objFacebookFeed.FeedDate = DateTime.Parse(result["created_time"].ToString()).ToString("yyyy/MM/dd HH:mm:ss");
objFacebookFeed.FeedDateToshow = DateTime.Parse(result["created_time"].ToString()).ToString("yyyy/MM/dd HH:mm:ss");
objFacebookFeed.FeedDate = Domain.Socioboard.Helpers.SBHelper.ConvertToUnixTimestamp(Convert.ToDateTime(objFacebookFeed.FeedDateToshow)).ToString();
}
catch(Exception ex) { }
objFacebookFeed.FbComment = "http://graph.facebook.com/" + result["id"] + "/comments";
objFacebookFeed.FbLike = "http://graph.facebook.com/" + result["id"] + "/likes";
objFacebookFeed.shareStatus = false;
Expand Down Expand Up @@ -1680,8 +1686,10 @@ public static List<MongoFbPostComment> FbPostComments(string postid, dynamic pos
List<Domain.Socioboard.Models.Mongo.facebookfeed> lstfacebookfeed = new List<Domain.Socioboard.Models.Mongo.facebookfeed>();
MongoRepository mongorepo = new MongoRepository("MongoFacebookFeed", settings);
var builder = Builders<MongoFacebookFeed>.Sort;


var sort = builder.Descending(t => t.EntryDate);
var sort = builder.Descending(t => t.FeedDate);

var result = mongorepo.FindWithRange<Domain.Socioboard.Models.Mongo.MongoFacebookFeed>(t => t.ProfileId.Equals(profileId), sort, skip, 20);
var task = Task.Run(async () =>
{
Expand Down
Loading

0 comments on commit 4f05569

Please sign in to comment.