コード例 #1
0
 public void updateImage(Domain.Myfashion.Domain.TwitterDirectMessages _TwitterDirectMessages)
 {
     //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())
         {
             try
             {
                 // Proceed action to Update Data.
                 // And Set the reuired paremeters to find the specific values.
                 session.CreateQuery("Update TwitterDirectMessages set Image =:Image where MessageId = :MessageId and UserId = :userid")
                 .SetParameter("Image", _TwitterDirectMessages.Image)
                 .SetParameter("MessageId", _TwitterDirectMessages.MessageId)
                 .SetParameter("userid", _TwitterDirectMessages.UserId)
                 .ExecuteUpdate();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 // return 0;
             }
         } //End Transaction
     }     //End session
 }
コード例 #2
0
 /// <addNewDirectMessage>
 /// Add New Direct Message
 /// </summary>
 /// <param name="twtDirectMessages">Set Values in a TwitterDirectMessages Class Property and Pass the Object of TwitterDirectMessages Class.(Domein.TwitterDirectMessages)</param>
 public void addNewDirectMessage(Domain.Myfashion.Domain.TwitterDirectMessages twtDirectMessages)
 {
     //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(twtDirectMessages);
             transaction.Commit();
         } //End Transaction
     }     //End Session
 }
コード例 #3
0
 public void updateDirectMessage(Domain.Myfashion.Domain.TwitterDirectMessages twtDirectMessages)
 {
     throw new NotImplementedException();
 }
コード例 #4
0
        public void getTwittwrDirectMessageRecieved(oAuthTwitter OAuth, string UserId)
        {
            #region Add Twitter Direct Message
            TwitterUser twtuser = new TwitterUser();
            try
            {
                JArray Messages_Sent = twtuser.GetDirect_Messages(OAuth, 20);

                objTwitterDirectMessages = new Domain.Myfashion.Domain.TwitterDirectMessages();
                foreach (var item in Messages_Sent)
                {
                    objTwitterDirectMessages.UserId = Guid.Parse(UserId);
                    objTwitterDirectMessages.Type = "twt_directmessages_received";
                    objTwitterDirectMessages.Id = Guid.NewGuid();

                    try
                    {
                        objTwitterDirectMessages.MessageId = item["id_str"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterDirectMessages.CreatedDate = Utility.ParseTwitterTime(item["created_at"].ToString().TrimStart('"').TrimEnd('"'));
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterDirectMessages.Message = item["text"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }

                    try
                    {
                        objTwitterDirectMessages.RecipientId = item["recipient"]["id_str"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }

                    try
                    {
                        objTwitterDirectMessages.RecipientScreenName = item["recipient"]["screen_name"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }

                    try
                    {
                        objTwitterDirectMessages.RecipientProfileUrl = item["recipient"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }

                    try
                    {
                        objTwitterDirectMessages.SenderId = item["sender"]["id_str"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }

                    try
                    {
                        objTwitterDirectMessages.SenderScreenName = item["sender"]["screen_name"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    } try
                    {
                        objTwitterDirectMessages.SenderProfileUrl = item["sender"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    } try
                    {
                        objTwitterDirectMessages.EntryDate = DateTime.Now;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    if (!objTwitterDirectMessageRepository.checkExistsDirectMessages(objTwitterDirectMessages.MessageId))
                    {
                        try
                        {
                            objTwitterDirectMessageRepository.addNewDirectMessage(objTwitterDirectMessages);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                logger.Error("twtuser.GetDirect_Messages_Sent ex.StackTrace >> " + ex.StackTrace);
                logger.Error("twtuser.GetDirect_Messages_Sent ex.Message >> " + ex.Message);
            }
            #endregion
        }
コード例 #5
0
        public void getPageConversations(string UserId, FacebookClient fb, dynamic profile)
        {
            try
            {
                TwitterDirectMessageRepository _TwitterDirectMessageRepository = new TwitterDirectMessageRepository();
                Domain.Myfashion.Domain.TwitterDirectMessages _TwitterDirectMessages;
                dynamic data = fb.Get("v2.0/me/conversations");
                foreach (var item in data["data"])
                {
                    foreach (var msg_item in item["messages"]["data"])
                    {
                        _TwitterDirectMessages = new Domain.Myfashion.Domain.TwitterDirectMessages();

                        _TwitterDirectMessages.UserId = Guid.Parse(UserId);
                        _TwitterDirectMessages.EntryDate = DateTime.Now;



                        try
                        {
                            _TwitterDirectMessages.MessageId = msg_item["id"].ToString();
                        }
                        catch (Exception ex)
                        {
                            logger.Error("Facebook.asmx = > getPageConversations = > " + ex.Message);
                        }
                        try
                        {
                            _TwitterDirectMessages.CreatedDate = Convert.ToDateTime(msg_item["created_time"].ToString());
                        }
                        catch (Exception ex)
                        {
                            logger.Error("Facebook.asmx = > getPageConversations = > " + ex.Message);
                        }
                        try
                        {
                            _TwitterDirectMessages.SenderId = msg_item["from"]["id"].ToString();
                        }
                        catch (Exception ex)
                        {
                            logger.Error("Facebook.asmx = > getPageConversations = > " + ex.Message);
                        }
                        try
                        {
                            _TwitterDirectMessages.SenderScreenName = msg_item["from"]["name"].ToString();
                        }
                        catch (Exception ex)
                        {
                            logger.Error("Facebook.asmx = > getPageConversations = > " + ex.Message);
                        }
                        try
                        {
                            _TwitterDirectMessages.SenderProfileUrl = "http://graph.facebook.com/" + _TwitterDirectMessages.SenderId + "/picture?type=small";
                        }
                        catch (Exception ex)
                        {
                            logger.Error("Facebook.asmx = > getPageConversations = > " + ex.Message);
                        }
                        try
                        {
                            _TwitterDirectMessages.RecipientId = msg_item["to"]["data"][0]["id"].ToString();
                        }
                        catch (Exception ex)
                        {
                            logger.Error("Facebook.asmx = > getPageConversations = > " + ex.Message);
                        }
                        try
                        {
                            _TwitterDirectMessages.RecipientScreenName = msg_item["to"]["data"][0]["name"].ToString();
                        }
                        catch (Exception ex)
                        {
                            logger.Error("Facebook.asmx = > getPageConversations = > " + ex.Message);
                        }
                        try
                        {
                            _TwitterDirectMessages.RecipientProfileUrl = "http://graph.facebook.com/" + _TwitterDirectMessages.RecipientId + "/picture?type=small";
                        }
                        catch (Exception ex)
                        {
                            logger.Error("Facebook.asmx = > getPageConversations = > " + ex.Message);
                        }
                        try
                        {
                            _TwitterDirectMessages.Message = msg_item["message"].ToString();
                            if (string.IsNullOrEmpty(_TwitterDirectMessages.Message))
                            {
                                if ((msg_item["attachments"]["data"][0]["mime_type"].ToString()).Contains("image"))
                                {
                                    _TwitterDirectMessages.Image = msg_item["attachments"]["data"][0]["image_data"]["url"].ToString();
                                }
                                else
                                {
                                    _TwitterDirectMessages.Message = msg_item["attachments"]["data"][0]["name"].ToString();
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Error("Facebook.asmx = > getPageConversations = > " + ex.Message);
                        }
                        try
                        {
                            _TwitterDirectMessages.Image = msg_item["shares"]["data"][0]["link"].ToString();
                        }
                        catch (Exception ex)
                        {
                            logger.Error("Facebook.asmx = > getPageConversations = > " + ex.Message);
                        }
                        if (_TwitterDirectMessages.SenderId == profile["id"].ToString())
                        {
                            _TwitterDirectMessages.Type = "fb_sent";
                        }
                        else
                        {
                            _TwitterDirectMessages.Type = "fb_received";
                        }

                        if (!_TwitterDirectMessageRepository.checkExistsDirectMessages(Guid.Parse(UserId), _TwitterDirectMessages.MessageId))
                        {
                            _TwitterDirectMessageRepository.addNewDirectMessage(_TwitterDirectMessages);
                        }
                        else
                        {
                            _TwitterDirectMessageRepository.updateImage(_TwitterDirectMessages);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("getPageConversations = > "+ex.Message);
            }
        }