// Edited by Antima[20/12/2014] public Domain.Myfashion.Domain.FacebookFeed getFacebookFeedByProfileId(string ProfileId, string FeedId) { //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { //After Session creation, start Transaction. using (NHibernate.ITransaction transaction = session.BeginTransaction()) { try { //Proceed action, to get feeds of twitter account by profile id. Domain.Myfashion.Domain.FacebookFeed msg = session.CreateQuery("from FacebookFeed where ProfileId = :ProfileId and FeedId =:FeedId") .SetParameter("ProfileId", ProfileId) .SetParameter("FeedId", FeedId).UniqueResult <Domain.Myfashion.Domain.FacebookFeed>(); return(msg); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(null); } } //End Transaction } //End Session }
/// <addFacebookFeed> /// add new Facebook Feed /// </summary> /// <param name="fbfeed">Set Values in a Facebook feed Class Property and Pass the Object of Facebook feed Class (SocioBoard.Domain.Facebookfeed).</param> public void addFacebookFeed(Domain.Myfashion.Domain.FacebookFeed fbfeed) { //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { //Begin session trasaction and opens up. using (NHibernate.ITransaction transaction = session.BeginTransaction()) { //Procees action, to save new data. session.Save(fbfeed); transaction.Commit(); } //End Trasaction } //End session }
// Edited by Antima[20/12/2014] public DataSet bindMyTickets(Guid UserId) { Messages mstable = new Messages(); DataSet ds = DataTableGenerator.CreateDataSetForTable(mstable); Api.SentimentalAnalysis.SentimentalAnalysis ApiobjSentimentalAnalysis = new Api.SentimentalAnalysis.SentimentalAnalysis(); List <Domain.Myfashion.Domain.FeedSentimentalAnalysis> lstNegativeFeedsOfUser = new List <Domain.Myfashion.Domain.FeedSentimentalAnalysis>(); lstNegativeFeedsOfUser = (List <Domain.Myfashion.Domain.FeedSentimentalAnalysis>)(new JavaScriptSerializer().Deserialize(ApiobjSentimentalAnalysis.getNegativeFeedsOfUser(UserId.ToString()), typeof(List <Domain.Myfashion.Domain.FeedSentimentalAnalysis>))); if (lstNegativeFeedsOfUser != null) { foreach (var item in lstNegativeFeedsOfUser) { string Network = item.Network; if (Network == "facebook") { Api.FacebookFeed.FacebookFeed ApiobjFacebookFeed = new Api.FacebookFeed.FacebookFeed(); Domain.Myfashion.Domain.FacebookFeed facebookfeed = (Domain.Myfashion.Domain.FacebookFeed)(new JavaScriptSerializer().Deserialize(ApiobjFacebookFeed.getFacebookFeedByProfileId(item.ProfileId, item.FeedId), typeof(Domain.Myfashion.Domain.FacebookFeed))); if (facebookfeed != null) { ds.Tables[0].Rows.Add(facebookfeed.ProfileId, "facebook", facebookfeed.FromId, facebookfeed.FromName, facebookfeed.FromProfileUrl, facebookfeed.FeedDate, facebookfeed.FeedDescription, facebookfeed.FbComment, facebookfeed.FbLike, facebookfeed.FeedId, facebookfeed.Type, ""); } } if (Network == "twitter") { Api.TwitterFeed.TwitterFeed ApiobjTwitterFeed = new Api.TwitterFeed.TwitterFeed(); Domain.Myfashion.Domain.TwitterFeed twtfeed = (Domain.Myfashion.Domain.TwitterFeed)(new JavaScriptSerializer().Deserialize(ApiobjTwitterFeed.getTwitterFeedByProfileId(item.ProfileId, item.FeedId), typeof(Domain.Myfashion.Domain.TwitterFeed))); if (twtfeed != null) { ds.Tables[0].Rows.Add(twtfeed.ProfileId, item.Network, twtfeed.FromId, twtfeed.FromScreenName, twtfeed.FromProfileUrl, twtfeed.FeedDate, twtfeed.Feed, "", "", twtfeed.MessageId, twtfeed.Type, ""); } } } } return(ds); }
public string GetTicketsofGroup(string GroupId, string UserId) { string AssignedUser = string.Empty; try { GroupProfileRepository objGroupProfileRepository = new GroupProfileRepository(); FacebookFeedRepository objFacebookFeedRepository = new FacebookFeedRepository(); TwitterFeedRepository objTwitterFeedRepository = new TwitterFeedRepository(); List <Domain.Myfashion.Domain.FeedSentimentalAnalysis> lstNegativeFeedsOfUser = new List <Domain.Myfashion.Domain.FeedSentimentalAnalysis>(); List <Domain.Myfashion.Domain.GroupProfile> objGroupProfile = new List <Domain.Myfashion.Domain.GroupProfile>(); List <FBTwitterFeeds> objListFBTwitterFeeds = new List <FBTwitterFeeds>(); objGroupProfile = objGroupProfileRepository.getAllGroupProfiles(Guid.Parse(UserId), Guid.Parse(GroupId)); if (objGroupProfile.Count > 0) { lstNegativeFeedsOfUser = _FeedSentimentalAnalysisRepository.getAllNegativeFeedsOfUser(Guid.Parse(UserId)); } else { lstNegativeFeedsOfUser = _FeedSentimentalAnalysisRepository.getNegativeFeedsOfUser(Guid.Parse(UserId)); } if (lstNegativeFeedsOfUser != null) { foreach (var item in lstNegativeFeedsOfUser) { FBTwitterFeeds objFBTwitterFeeds = new FBTwitterFeeds(); UserRepository objUserRepository = new UserRepository(); Domain.Myfashion.Domain.User user = objUserRepository.getUsersById(item.AssigneUserId); if (objGroupProfileRepository.checkProfileExistsingroup(Guid.Parse(GroupId), item.ProfileId)) { string Network = item.Network; if (Network == "facebook") { Domain.Myfashion.Domain.FacebookFeed facebookfeed = objFacebookFeedRepository.getFacebookFeedByProfileId(item.ProfileId, item.FeedId); if (facebookfeed != null) { objFBTwitterFeeds.FacebookFeed = facebookfeed; } } if (Network == "twitter") { Domain.Myfashion.Domain.TwitterFeed twtfeed = objTwitterFeedRepository.getTwitterFeedByProfileId(item.ProfileId, item.FeedId); if (twtfeed != null) { objFBTwitterFeeds.TwitterFeed = twtfeed; } } if (objFBTwitterFeeds.TwitterFeed != null) { try { objFBTwitterFeeds.TicketNo = item.TicketNo; if (user != null) { objFBTwitterFeeds.AssignedUser = user.UserName; } else { objFBTwitterFeeds.AssignedUser = ""; } objListFBTwitterFeeds.Add(objFBTwitterFeeds); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } if (objFBTwitterFeeds.FacebookFeed != null) { try { objFBTwitterFeeds.TicketNo = item.TicketNo; if (user != null) { objFBTwitterFeeds.AssignedUser = user.UserName; } else { objFBTwitterFeeds.AssignedUser = ""; } objListFBTwitterFeeds.Add(objFBTwitterFeeds); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } } } return(new JavaScriptSerializer().Serialize(objListFBTwitterFeeds)); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return("SomethingWentWrong"); } }
public int updateFacebookFeed(Domain.Myfashion.Domain.FacebookFeed fbfeed) { throw new NotImplementedException(); }
private List<Domain.Myfashion.Domain.FacebookFeed> AddFacebookFeeds(string UserId, FacebookClient fb, dynamic profile) { //List of new Feeds List<Domain.Myfashion.Domain.FacebookFeed> lstFacebookFeeds = new List<Domain.Myfashion.Domain.FacebookFeed>(); try { Domain.Myfashion.Domain.FacebookFeed objFacebookFeed = new Domain.Myfashion.Domain.FacebookFeed(); System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; string nexturl = "v2.0/me/feed";//"v2.0/me/posts"; //for (int i = 0; i < 10; i++) { dynamic feeds = fb.Get(nexturl); //dynamic feedss = fb.Get("/338818712957141/posts"); //dynamic feedsss = fb.Get("/338818712957141/feed"); if (feeds != null) { try { nexturl = feeds["paging"]["next"].ToString(); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); } foreach (var result in feeds["data"]) { objFacebookFeed = new Domain.Myfashion.Domain.FacebookFeed(); objFacebookFeed.Type = "fb_feed"; try { objFacebookFeed.UserId = Guid.Parse(UserId); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objFacebookFeed.ProfileId = profile["id"].ToString(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objFacebookFeed.Id = Guid.NewGuid(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } objFacebookFeed.FromProfileUrl = "http://graph.facebook.com/" + result["from"]["id"] + "/picture?type=small"; 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()); objFacebookFeed.FbComment = "http://graph.facebook.com/" + result["id"] + "/comments"; objFacebookFeed.FbLike = "http://graph.facebook.com/" + result["id"] + "/likes"; //Commented as these cause errors on API //Added by Sumit Gupta [31-01-15] to get post Shares/Likes/Comments #region Added by Sumit Gupta [31-01-15] //try //{ // dynamic like = fb.Get("v2.0/" + objFbPagePost.PostId + "/likes?summary=1&limit=0"); // objFbPagePost.Likes = Convert.ToInt32(like["summary"]["total_count"]); //} //catch (Exception ex) //{ // Console.WriteLine(ex.StackTrace); //} //try //{ // dynamic comment = fb.Get("v2.0/" + objFbPagePost.PostId + "/comments?summary=1&limit=0"); // objFbPagePost.Comments = Convert.ToInt32(comment["summary"]["total_count"]); //} //catch (Exception ex) //{ // Console.WriteLine(ex.StackTrace); //} //try //{ // dynamic shares = fb.Get("v2.0/" + objFbPagePost.PostId); // objFbPagePost.Shares = Convert.ToInt32(shares["shares"]["count"]); //} //catch (Exception ex) //{ // Console.WriteLine(ex.StackTrace); // logger.Error(ex.StackTrace); //} #endregion //Added by Sumit Gupta [17-02-15] try { objFacebookFeed.Picture = result["picture"].ToString(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); objFacebookFeed.Picture = ""; } string message = string.Empty; int lstfbcount = 0; if (lstfbcount < 25) { try { if (result["message"] != null) { message = result["message"]; lstfbcount++; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); try { if (result["description"] != null) { message = result["description"]; lstfbcount++; } } catch (Exception exx) { try { Console.WriteLine(exx.StackTrace); if (result["story"] != null) { message = result["story"]; lstfbcount++; } } catch (Exception exxx) { Console.WriteLine(exxx.StackTrace); message = string.Empty; } } } } if (message == null) { message = ""; } objFacebookFeed.FeedDescription = message; objFacebookFeed.EntryDate = DateTime.Now; //Check to avoid duplicacy if (!objFacebookFeedRepository.checkFacebookFeedExists(objFacebookFeed.FeedId)) { objFacebookFeedRepository.addFacebookFeed(objFacebookFeed); lstFacebookFeeds.Add(objFacebookFeed); } } } else { //break; } } } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.Write(ex.StackTrace); } return lstFacebookFeeds; }
//Added by Avinash Verma & Sumit Gupta [30-01-15] private void AddFacebookFeedsWithPagination(string UserId, FacebookClient fb, dynamic profile) { int I = 0; try { objFacebookFeed = new Domain.Myfashion.Domain.FacebookFeed(); System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; string nexturl = "v2.0/me/feed";//"v2.0/me/posts"; for (int i = 0; i < 50; i++) { dynamic feeds = fb.Get(nexturl); //dynamic feedss = fb.Get("/338818712957141/posts"); //dynamic feedsss = fb.Get("/338818712957141/feed"); if (feeds != null) { try { nexturl = feeds["paging"]["next"].ToString(); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); } foreach (var result in feeds["data"]) { objFacebookFeed.Type = "fb_feed"; try { objFacebookFeed.UserId = Guid.Parse(UserId); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objFacebookFeed.ProfileId = profile["id"].ToString(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { objFacebookFeed.Id = Guid.NewGuid(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } objFacebookFeed.FromProfileUrl = "http://graph.facebook.com/" + result["from"]["id"] + "/picture?type=small"; 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()); objFacebookFeed.FbComment = "http://graph.facebook.com/" + result["id"] + "/comments"; objFacebookFeed.FbLike = "http://graph.facebook.com/" + result["id"] + "/likes"; //Added by Sumit Gupta [17-02-15] try { objFacebookFeed.Picture = result["picture"].ToString(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); objFacebookFeed.Picture = null; } string message = string.Empty; int lstfbcount = 0; if (lstfbcount < 25) { try { if (result["message"] != null) { message = result["message"]; lstfbcount++; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); try { if (result["description"] != null) { message = result["description"]; lstfbcount++; } } catch (Exception exx) { try { Console.WriteLine(exx.StackTrace); if (result["story"] != null) { message = result["story"]; lstfbcount++; } } catch (Exception exxx) { Console.WriteLine(exxx.StackTrace); message = string.Empty; } } } } objFacebookFeed.FeedDescription = message; objFacebookFeed.EntryDate = DateTime.Now; if (!objFacebookFeedRepository.checkFacebookFeedExists(objFacebookFeed.FeedId)) { I++; objFacebookFeedRepository.addFacebookFeed(objFacebookFeed); logger.Error("AddFacebookFeedsWithPaginationCount>>" + I); } } } else { break; } } } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.Write(ex.StackTrace); } }