Пример #1
0
 /// <Add>
 /// Add a new admin in DataBase.
 /// </summary>
 /// <param name="user">Set Values in a Admin Class Property and Pass the Object of Admin Class (Domain.Socioboard.Domain.Admin).</param>
 public void Add(Domain.Socioboard.Domain.TwitterEngagement user)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, start and open Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             //Proceed action to save data.
             try
             {
                 session.Save(user);
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 logger.Error(ex.StackTrace);
             }
         } //End Using trasaction
     }     //End Using session
 }
Пример #2
0
        public void getTwitterEngagement(string UserId, oAuthTwitter OAuth)
        {
            #region Add Twitter Engagement
            Tweet objTweet = new Tweet();
            TwitterEngagement objTwitterEngagement = new TwitterEngagement();
            TwitterEngagementRepository objTwitterEngagementRepository = new TwitterEngagementRepository();

            //TwitterMessageRepository objTwitterMessageRepository=new TwitterMessageRepository ();
            List<Domain.Socioboard.Domain.TwitterMessage> lsttwtmessage = objTwitterMessageRepository.getAllTwitterMessagesRetweet(Guid.Parse(UserId), objTwitterAccount.TwitterUserId);
            List<Domain.Socioboard.Domain.TwitterMessage> tsttwtwmessagetweet = objTwitterMessageRepository.getAllTwitterMessagestweet(Guid.Parse(UserId), objTwitterAccount.TwitterUserId);
            foreach (var itemmsg in lsttwtmessage)
            {

                JArray EngagementData = objTweet.Get_Statuses_RetweetsById(OAuth, itemmsg.MessageId);
                foreach (var item in EngagementData)
                {
                    objTwitterEngagement.Id = Guid.NewGuid();
                    objTwitterEngagement.UserId = Guid.Parse(UserId);
                    objTwitterEngagement.EntryDate = DateTime.Now;
                    objTwitterEngagement.ProfileId = objTwitterAccount.TwitterUserId;
                    try
                    {
                        objTwitterEngagement.RetweetCount = item["retweet_count"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterEngagement.ReplyCount = objTwitterMessageRepository.getReplyCountbyProfileId(objTwitterAccount.TwitterUserId, Guid.Parse(UserId)).ToString();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterEngagement.Engagement = ((Int32.Parse(objTwitterEngagement.ReplyCount) + Int32.Parse(objTwitterEngagement.RetweetCount)) * 100 / (objTwitterAccount.FollowersCount)).ToString();
                    }
                    catch (Exception ex)
                    {
                        objTwitterEngagement.Engagement = "0".ToString();
                        Console.WriteLine(ex.StackTrace);
                    } try
                    {
                        objTwitterEngagement.Influence = (((tsttwtwmessagetweet.Count)) * 100 / (objTwitterAccount.FollowersCount)).ToString();
                    }
                    catch (Exception ex)
                    {
                        objTwitterEngagement.Influence = "0".ToString();
                        Console.WriteLine(ex.StackTrace);
                    }
                    objTwitterEngagementRepository.Add(objTwitterEngagement);

                }
            }
            #endregion
        }