public void addFacebookStats(FacebookStats fbstats) { using (NHibernate.ISession session = SessionFactory.GetNewSession()) { using (NHibernate.ITransaction transaction = session.BeginTransaction()) { session.Save(fbstats); transaction.Commit(); } } }
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; }
public void updateFacebookStats(FacebookStats fbaccount) { throw new NotImplementedException(); }