public void InsertTwitterRecentDetails(Domain.Socioboard.Domain.TwitterRecentDetails data)
        {
            bool exists = false;

            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                exists = session.Query <Domain.Socioboard.Domain.TwitterRecentDetails>()
                         .Any(x => x.TwitterId == data.TwitterId);
            }

            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    if (exists)
                    {
                        session.CreateQuery("Update twitterrecentdetails set AccountCreationDate = : AccountCreationDate , LastActivityDate = : LastActivityDate , LastFeed = : LastFeed , FeedId = : FeedId , FeedRetweetCount = : FeedRetweetCount , FeedFavoriteCount = : FeedFavoriteCount where TwitterId = : TwitterId")
                        .SetParameter("AccountCreationDate", data.AccountCreationDate)
                        .SetParameter("LastActivityDate", data.LastActivityDate)
                        .SetParameter("LastFeed", data.LastFeed)
                        .SetParameter("FeedId", data.FeedId)
                        .SetParameter("FeedRetweetCount", data.FeedRetweetCount)
                        .SetParameter("FeedFavoriteCount", data.FeedFavoriteCount)
                        .ExecuteUpdate();
                        transaction.Commit();
                    }

                    else
                    {
                        session.Save(data);
                        transaction.Commit();
                    }
                }
            }
        }
Esempio n. 2
0
        public void twitterrecentdetails(JArray data)
        {
            Domain.Socioboard.Domain.TwitterRecentDetails insertdata = new Domain.Socioboard.Domain.TwitterRecentDetails();
            TwitterAccountRepository objTwtRepo = new TwitterAccountRepository();


            string TwitterId = string.Empty;
            Guid Id = Guid.NewGuid();
            try
            {
                TwitterId = data[0]["id_str"].ToString();

            }
            catch (Exception)
            {

                TwitterId = string.Empty;

            }

            if (!string.IsNullOrEmpty(TwitterId))
            {
                string AccountCreationDate = string.Empty;
                string LastActivityDate = string.Empty;
                string lastfeed = string.Empty;
                string FeedId = string.Empty;
                string retweetcount = string.Empty;
                string favoritecount = string.Empty;

                try
                {
                    DateTime AccntCreationDate = Utility.ParseTwitterTime((data[0]["created_at"].ToString()));
                    AccountCreationDate = AccntCreationDate.ToString();
                }
                catch (Exception)
                {
                    AccountCreationDate = string.Empty;

                }


                try
                {
                    DateTime lastactivitydate = Utility.ParseTwitterTime((data[0]["status"]["created_at"].ToString()));
                    LastActivityDate = lastactivitydate.ToString();

                }
                catch (Exception)
                {


                    LastActivityDate = string.Empty;
                }

                try
                {
                    lastfeed = data[0]["status"]["text"].ToString();
                    FeedId = data[0]["status"]["id_str"].ToString();
                    retweetcount = data[0]["status"]["retweet_count"].ToString();
                    favoritecount = data[0]["status"]["favorite_count"].ToString();

                }
                catch (Exception)
                {
                    lastfeed = string.Empty;
                    FeedId = string.Empty;
                    retweetcount = string.Empty;
                    favoritecount = string.Empty;

                }

                insertdata.Id = Id;
                insertdata.TwitterId = TwitterId;
                insertdata.AccountCreationDate = AccountCreationDate;
                insertdata.LastActivityDate = LastActivityDate;
                insertdata.LastFeed = lastfeed;
                insertdata.FeedId = FeedId;
                insertdata.FeedRetweetCount = retweetcount;
                insertdata.FeedFavoriteCount = favoritecount;
                objTwtRepo.InsertTwitterRecentDetails(insertdata);



            }







        }