public void addFacebookFeed(FacebookFeed fbfeed)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             session.Save(fbfeed);
             transaction.Commit();
         }
     }
 }
 /// <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(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
 }
 public int updateFacebookFeed(FacebookFeed fbfeed)
 {
     throw new NotImplementedException();
 }
Example #4
0
        public void getFacebookUserFeeds(dynamic data, dynamic profile, Guid userId)
        {
            FacebookFeed fbfeed = new FacebookFeed();
            FacebookFeedRepository fbfeedrepo = new FacebookFeedRepository();

            if (data != null)
            {
                foreach (var result in data["data"])
                {

                    fbfeed.Type = "fb_feed";
                    try
                    {
                        fbfeed.UserId = userId;
                    }
                    catch (Exception ex)
                    { Console.WriteLine(ex.StackTrace); }

                    try
                    {
                        fbfeed.ProfileId = profile["id"].ToString();
                    }
                    catch (Exception ex)
                    { Console.WriteLine(ex.StackTrace); }

                    try
                    {
                        fbfeed.Id = Guid.NewGuid();
                    }
                    catch (Exception ex)
                    { Console.WriteLine(ex.StackTrace); }



                    fbfeed.FromProfileUrl = "http://graph.facebook.com/" + result["from"]["id"] + "/picture?type=small";
                    fbfeed.FromName = result["from"]["name"].ToString();
                    fbfeed.FromId = result["from"]["id"].ToString();
                    fbfeed.FeedId = result["id"].ToString();
                    fbfeed.FeedDate = DateTime.Parse(result["created_time"].ToString());
                    fbfeed.FbComment = "http://graph.facebook.com/" + result["id"] + "/comments";
                    fbfeed.FbLike = "http://graph.facebook.com/" + result["id"] + "/likes";
                    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;
                                }
                            }

                        }
                    }
                    fbfeed.FeedDescription = message;
                    fbfeed.EntryDate = DateTime.Now;

                    if (!fbfeedrepo.checkFacebookFeedExists(fbfeed.FeedId, userId))
                    {
                        fbfeedrepo.addFacebookFeed(fbfeed);
                    }
                }
            }
        }
        public string getFacebookpageFeeds(dynamic data, dynamic profile)
        {
            FacebookFeed fbfeed = new FacebookFeed();
            User user = (User)HttpContext.Current.Session["LoggedUser"];
            FacebookFeedRepository fbfeedrepo = new FacebookFeedRepository();
            string fanpost = string.Empty;
            if (data != null)
            {
                foreach (var result in data["data"])
                {

                  
                    string message = string.Empty;
                    int likecount = 0;
                    int lstfbcount = 0;
                    int commentcount = 0;
                    int talking = 0;
                    string sharecount = string.Empty;
                    
                        try
                        {
                            if (result["message"] != null)
                            {
                                message = result["message"];

                                try
                                {
                                    if (result["likes"]["data"] != null)
                                    {
                                        foreach (var item in result["likes"]["data"])
                                        {
                                            if (item != null)
                                            {
                                                likecount++;
                                            }
                                            else
                                            {
                                                likecount = 0;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        likecount = 0;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    likecount = 0;
                                }

                                try
                                {
                                    if (result["comments"]["data"] != null)
                                    {
                                        foreach (var item in result["comments"]["data"])
                                        {
                                            if (item != null)
                                            {
                                                commentcount++;
                                            }
                                            else
                                            {
                                                commentcount = 0;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        commentcount = 0;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    commentcount = 0;
                                }



                                try
                                {
                                    if (result["shares"]["count"] != null)
                                    {
                                        sharecount = result["shares"]["count"].ToString();
                                    }
                                    else
                                    {
                                        sharecount = "0";
                                    }
                                }
                                catch (Exception ex)
                                {
                                    sharecount = "0";
                                }



                                

                               // lstfbcount++;

                            }
                            fanpost = fanpost + "<div class=\"message-sent-table\" ><div class=\"labe-1\">" + message + "</div>" +
                                                               "<div class=\"labe-4\">" + talking + "</div><div class=\"labe-5\">" + likecount + "</div><div class=\"labe-6\">" + commentcount + "</div><div class=\"labe-5\">" + sharecount + "</div></div>";
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                           

                        }

                        //fanpost = fanpost + "<div class=\"message-sent-table\" ><div class=\"labe-1\">" + message + "</div>" +
                        //           "<div class=\"labe-4\">" + talking + "</div><div class=\"labe-5\">" + likecount + "</div><div class=\"labe-6\">" + commentcount + "</div><div class=\"labe-5\">" + sharecount + "</div></div>";
                    
                }
            }
            return fanpost;
        }