コード例 #1
0
 public void addFacebookMessage(FacebookMessage fbmsg)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             session.Save(fbmsg);
             transaction.Commit();
         }
     }
 }
コード例 #2
0
 /// <addFacebookMessage>
 /// Add new Facebook Message
 /// </summary>
 /// <param name="fbmsg">Set Values in a FacebookMessage Class Property and Pass the same Object of FacebookMessage Class.(Domain.FacebookMessage)</param>
 public void addFacebookMessage(FacebookMessage fbmsg)
 {
     //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())
         {
             //Proceed action, to save data.
             session.Save(fbmsg);
             transaction.Commit();
         }//End Transaction
     }//End session
 }
コード例 #3
0
 public int updateFacebookMessage(FacebookMessage fbaccount)
 {
     throw new NotImplementedException();
 }
コード例 #4
0
ファイル: FacebookData.cs プロジェクト: NALSS/socioboard
        public void getFacebookUserHome(dynamic data, dynamic profile, Guid userId)
        {
            FacebookMessage fbmsg = new FacebookMessage();
            FacebookMessageRepository fbmsgrepo = new FacebookMessageRepository();
            int lstfbcount = 0;
            foreach (dynamic result in data["data"])
            {

                string message = string.Empty;
                string imgprof = "http://graph.facebook.com/" + result["from"]["id"] + "/picture?type=small";
                fbmsg.EntryDate = DateTime.Now;
                fbmsg.MessageId = result["id"].ToString();
                fbmsg.FromId = result["from"]["id"].ToString();
                fbmsg.FromName = result["from"]["name"].ToString();
                fbmsg.FromProfileUrl = imgprof;
                fbmsg.Id = Guid.NewGuid();
                fbmsg.MessageDate = DateTime.Parse(result["created_time"].ToString());
                fbmsg.UserId = userId;
                fbmsg.Type = "fb_home";
                fbmsg.ProfileId = profile["id"].ToString();
                fbmsg.FbComment = "http://graph.facebook.com/" + result["id"] + "/comments";
                fbmsg.FbLike = "http://graph.facebook.com/" + result["id"] + "/likes";


                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;
                            }
                        }

                    }

                }
                fbmsg.Message = message;

                if (!fbmsgrepo.checkFacebookMessageExists(fbmsg.MessageId, fbmsg.UserId))
                {
                    fbmsgrepo.addFacebookMessage(fbmsg);
                }
            }
        }
コード例 #5
0
        public void getInboxMessages(dynamic data, dynamic profile, Guid userId)
        {
            FacebookMessage fbmsg = new FacebookMessage();
            FacebookMessageRepository fbmsgrepo = new FacebookMessageRepository();

            string profileid = string.Empty;
            User user = (User)HttpContext.Current.Session["LoggedUser"];

            if (data != null)
            {
                int lstfbcount = 0;
                foreach (dynamic result in data["data"])
                {


                    try
                    {
                        foreach (dynamic message in result["comments"]["data"])
                        {
                            //Do want you want with the messages
                            fbmsg.MessageId = message["id"];
                            fbmsg.FromName = message["from"]["name"];
                            fbmsg.FromId = message["from"]["id"];
                            fbmsg.Message = message["message"];
                            fbmsg.MessageDate = DateTime.Parse(message["created_time"].ToString()); ;
                            fbmsg.FromProfileUrl = "http://graph.facebook.com/" + message["from"]["id"] + "/picture?type=small";
                            fbmsg.EntryDate = DateTime.Now;
                            fbmsg.Id = Guid.NewGuid();
                            fbmsg.ProfileId = profile["id"].ToString();
                            fbmsg.Type = "inbox_message";
                            fbmsg.UserId = userId;
                            if (!fbmsgrepo.checkFacebookMessageExists(fbmsg.MessageId))
                            {
                                fbmsgrepo.addFacebookMessage(fbmsg);
                            }

                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }

                }
            }
        }