public void addFacebookStats(FacebookStats fbstats) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { session.Save(fbstats); transaction.Commit(); } } }
public void updateFacebookStats(FacebookStats fbaccount) { throw new NotImplementedException(); }
private void AddFacebookStats(string UserId, FacebookClient fb, dynamic profile) { try { System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; dynamic friendsgenderstats = fb.Get("v2.0/" + profile["id"] + "/friends?fields=gender"); Domain.Socioboard.Domain.FacebookStats objfbStats = new Domain.Socioboard.Domain.FacebookStats(); FacebookStatsRepository objFBStatsRepo = new FacebookStatsRepository(); int malecount = 0; int femalecount = 0; foreach (var item in friendsgenderstats["data"]) { if (item["gender"] == "male") malecount++; else if (item["gender"] == "female") femalecount++; } objfbStats.EntryDate = DateTime.Now; objfbStats.FbUserId = profile["id"].ToString(); objfbStats.FemaleCount = femalecount; objfbStats.Id = Guid.NewGuid(); objfbStats.MaleCount = malecount; objfbStats.UserId = Guid.Parse(UserId); #region fancount int fancountPage = 0; try { System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls; //dynamic fancount = fb.Get("fql", new { q = " SELECT fan_count FROM page WHERE page_id =" + objfbStats.FbUserId }); //foreach (var friend in fancount.data) //{ // fancountPage = Convert.ToInt32(friend.fan_count); //} dynamic friends = fb.Get("v2.0/" + objfbStats.FbUserId + "/friends"); fancountPage = Convert.ToInt16(friends["summary"]["total_count"].ToString()); } catch (Exception) { fancountPage = 0; } #endregion objfbStats.FanCount = fancountPage;//getfanCount(objfbStats,fb.AccessToken.ToString()); objFBStatsRepo.addFacebookStats(objfbStats); } catch (Exception ex) { logger.Error(ex.Message); logger.Error(ex.StackTrace); Console.WriteLine(ex.StackTrace); } }
public void getfbFriendsGenderStatsForFanPage(dynamic profile, Guid userId, ref FacebookAccount objfbacnt) { FacebookStats objfbStats = new FacebookStats(); FacebookStatsRepository objFBStatsRepo = new FacebookStatsRepository(); //int malecount = 0; //int femalecount = 0; //foreach (var item in data["data"]) //{ // if (item["gender"] == "male") // malecount++; // else if (item["gender"] == "female") // femalecount++; //} objfbStats.EntryDate = DateTime.Now; objfbStats.FbUserId = profile["id"].ToString(); //objfbStats.FemaleCount = femalecount; objfbStats.Id = Guid.NewGuid(); //objfbStats.MaleCount = malecount; objfbStats.UserId = userId; objfbStats.FanCount = objfbacnt.Friends; //objfbStats.ShareCount = getShareCount(); //objfbStats.CommentCount = getCommentCount(); //objfbStats.LikeCount = getLikeCount(); objFBStatsRepo.addFacebookStats(objfbStats); FacebookInsightStatsHelper objfbinshlpr = new FacebookInsightStatsHelper(); string pId = profile["id"].ToString(); //string pId = "329139457226886"; objfbinshlpr.getPageImpresion(pId, userId, 7); }
public void getfbFriendsGenderStats(dynamic data, dynamic profile, Guid userId) { FacebookStats objfbStats = new FacebookStats(); FacebookStatsRepository objFBStatsRepo = new FacebookStatsRepository(); int malecount = 0; int femalecount = 0; foreach (var item in data["data"]) { if (item["gender"] == "male") malecount++; else if (item["gender"] == "female") femalecount++; } objfbStats.EntryDate = DateTime.Now; objfbStats.FbUserId = profile["id"].ToString(); objfbStats.FemaleCount = femalecount; objfbStats.Id = Guid.NewGuid(); objfbStats.MaleCount = malecount; objfbStats.UserId = userId; objfbStats.FanCount = getfanCount(ref objfbStats); objFBStatsRepo.addFacebookStats(objfbStats); }
public int getfanCount(ref FacebookStats objfbsts) { int friendscnt = 0; long friendscount = 0; try { FacebookClient fb = new FacebookClient(); string accessToken = HttpContext.Current.Session["accesstoken"].ToString(); fb.AccessToken = accessToken; var client = new FacebookClient(); dynamic me = fb.Get("me"); dynamic friedscount = fb.Get("fql", new { q = "SELECT friend_count FROM user WHERE uid=me()" }); foreach (var friend in friedscount.data) { friendscount = friend.friend_count; } friendscnt = Convert.ToInt32(friendscount); } catch (Exception ex) { //logger.Error(ex.StackTrace); //Console.WriteLine(ex.StackTrace); } return friendscnt; }