/// <deleteTwitterMessage>
 /// Delete Twitter Message
 /// </summary>
 /// <param name="twtmsg">Set Values of profile id and user id in a TwitterMessage Class Property and Pass the Object of Class.(Domein.TwitterMessage)</param>
 /// <returns>Return 1 for success and 0 for failure.(int) </returns>
 public int deleteTwitterMessage(TwitterMessage twtmsg)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, open up a Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 //Proceed action, to delete twitter message by twitter user id and user id 
                 NHibernate.IQuery query = session.CreateQuery("delete from TwitterMessage where ProfileId = :twtuserid and UserId = :userid")
                                 .SetParameter("twtuserid", twtmsg.ProfileId)
                                 .SetParameter("userid", twtmsg.UserId);
                 int isUpdated = query.ExecuteUpdate();
                 transaction.Commit();
                 return isUpdated;
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return 0;
             }
         }//End Transaction
     }//End Session
 }
 public void addTwitterMessage(TwitterMessage twtmsg)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             session.Save(twtmsg);
             transaction.Commit();
         }
     }
 }
 /// <addTwitterMessage>
 /// Add New Twitter Message
 /// </summary>
 /// <param name="twtmsg">Set Values in a TwitterMessage Class Property and Pass the Object of Class.(Domein.TwitterMessage)</param>
 public void addTwitterMessage(TwitterMessage twtmsg)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, open up a Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             //Proceed action, to save data.
             session.Save(twtmsg);
             transaction.Commit();
         }//End Transaction
     }//End Session
 }
 public int deleteTwitterMessage(TwitterMessage twtmsg)
 {
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 NHibernate.IQuery query = session.CreateQuery("delete from TwitterMessage where ProfileId = :twtuserid and UserId = :userid")
                                 .SetParameter("twtuserid", twtmsg.ProfileId)
                                 .SetParameter("userid", twtmsg.UserId);
                 int isUpdated = query.ExecuteUpdate();
                 transaction.Commit();
                 return isUpdated;
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return 0;
             }
         }
     }
 }
 public int updateTwitterMessage(TwitterMessage fbaccount)
 {
     throw new NotImplementedException();
 }
示例#6
0
        public void getMentions(oAuthTwitter oauth,TwitterAccount twitterAccount,Guid userid)
        {
            TwitterUser twtuser = new TwitterUser();
            TimeLine tl = new TimeLine();
            JArray data = tl.Get_Statuses_Mentions_Timeline(oauth);

            TwitterMessageRepository twtmsgrepo = new TwitterMessageRepository();
            TwitterMessage twtmsg = new TwitterMessage();
            foreach (var item in data)
            {
                twtmsg.UserId = userid;
                twtmsg.Type = "twt_mentions";
                twtmsg.Id = Guid.NewGuid();

                try
                {
                    twtmsg.MessageId = item["id_str"].ToString().TrimStart('"').TrimEnd('"');
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    twtmsg.MessageDate = SocioBoard.Helper.Extensions.ParseTwitterTime(item["created_at"].ToString().TrimStart('"').TrimEnd('"'));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    twtmsg.TwitterMsg = item["text"].ToString().TrimStart('"').TrimEnd('"');
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }

                try
                {
                    twtmsg.FromId = item["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"');
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }

                try
                {
                    twtmsg.FromScreenName = item["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"');
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }

                try
                {
                    twtmsg.FromProfileUrl = item["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"');
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }

                try
                {
                    twtmsg.InReplyToStatusUserId = item["in_reply_to_status_id_str"].ToString().TrimStart('"').TrimEnd('"');
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }

                try
                {
                    twtmsg.SourceUrl = item["source"].ToString().TrimStart('"').TrimEnd('"');
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                } try
                {
                    twtmsg.ProfileId = twitterAccount.TwitterUserId;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    twtmsg.ScreenName = item["user"]["screen_name"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                
                try
                {
                    twtmsg.EntryDate = DateTime.Now;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                if (!twtmsgrepo.checkTwitterMessageExists(twtmsg.MessageId))
                {
                    twtmsgrepo.addTwitterMessage(twtmsg);
                }
               
            }

        }
示例#7
0
        public void getUserFeeds(string profileid)
        {
            TwitterUser twtuser = new TwitterUser();
            User user = (User)HttpContext.Current.Session["LoggedUser"];
            oAuthTwitter OAuth = new oAuthTwitter();
            JArray data = twtuser.GetStatuses_User_Timeline(OAuth);
            TwitterMessageRepository twtmsgrepo = new TwitterMessageRepository();
             TwitterAccountRepository twtrepo = new TwitterAccountRepository();
             TwitterAccount twtaccount = twtrepo.getUserInformation(user.Id, profileid);

             OAuth.CallBackUrl = ConfigurationManager.AppSettings["callbackurl"];
            OAuth.ConsumerKey = ConfigurationManager.AppSettings["consumerKey"];
            OAuth.ConsumerKeySecret = ConfigurationManager.AppSettings["consumerSecret"];
            OAuth.TwitterScreenName = twtaccount.TwitterScreenName;
            OAuth.AccessTokenSecret = twtaccount.OAuthSecret;
            OAuth.AccessToken = twtaccount.OAuthToken;
            OAuth.ProfileImage = twtaccount.ProfileImageUrl;
         

            TwitterMessage twtmsg = new TwitterMessage();
            foreach (var item in data)
            {
                twtmsg.UserId = user.Id;
                twtmsg.Type = "twt_usertweets";
                try
                {
                    twtmsg.TwitterMsg = item["text"].ToString().TrimStart('"').TrimEnd('"');
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    twtmsg.SourceUrl = item["source"].ToString().TrimStart('"').TrimEnd('"');
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    twtmsg.ScreenName = twtaccount.TwitterScreenName;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    twtmsg.ProfileId = twtaccount.TwitterUserId;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    twtmsg.MessageId = item["id_str"].ToString().TrimStart('"').TrimEnd('"');
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    twtmsg.MessageDate = SocioBoard.Helper.Extensions.ParseTwitterTime(item["created_at"].ToString().TrimStart('"').TrimEnd('"'));
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    twtmsg.InReplyToStatusUserId = item["in_reply_to_status_id_str"].ToString().TrimStart('"').TrimEnd('"');
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    twtmsg.Id = Guid.NewGuid();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    twtmsg.FromProfileUrl = item["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"');
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    twtmsg.FromName = item["user"]["name"].ToString().TrimStart('"').TrimEnd('"');
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    twtmsg.FromId = item["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"');
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                twtmsg.EntryDate = DateTime.Now;
                try
                {
                    twtmsg.FromScreenName = item["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"');
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                if (!twtmsgrepo.checkTwitterMessageExists(twtmsg.MessageId))
                {
                    twtmsgrepo.addTwitterMessage(twtmsg);
                }

            }
        }