Esempio n. 1
0
 public void getUserFollowersData(oAuthTwitter OAuth, string screeenName, string TwitterUserId, Guid userId)
 {
     try
     {
         TimeLine _TimeLine = new TimeLine();
         JArray jdata = _TimeLine.Get_User_Followers(OAuth);
         JArray user_data = JArray.Parse(jdata[0]["users"].ToString());
         Domain.Socioboard.Domain.InboxMessages _InboxMessages;
         foreach (var item in user_data)
         {
             try
             {
                 _InboxMessages = new Domain.Socioboard.Domain.InboxMessages();
                 _InboxMessages.Id = Guid.NewGuid();
                 _InboxMessages.UserId = userId;
                 _InboxMessages.ProfileId = TwitterUserId;
                 _InboxMessages.ProfileType = "twt";
                 _InboxMessages.MessageType = "twt_followers";
                 _InboxMessages.EntryTime = DateTime.Now;
                 _InboxMessages.MessageId = "";
                 _InboxMessages.Status = 0;
                 try
                 {
                     _InboxMessages.Message = item["description"].ToString();
                 }
                 catch (Exception ex)
                 {
                     logger.Error("Twitter.asmx => getUserFollowers => " + ex.Message);
                 }
                 try
                 {
                     _InboxMessages.FromId = item["id_str"].ToString();
                 }
                 catch (Exception ex)
                 {
                     _InboxMessages.FromId = item["id"].ToString();
                 }
                 try
                 {
                     _InboxMessages.FromName = item["screen_name"].ToString();
                 }
                 catch (Exception ex)
                 {
                     logger.Error("Twitter.asmx => getUserFollowers => " + ex.Message);
                 }
                 try
                 {
                     _InboxMessages.FollowerCount = item["followers_count"].ToString();
                 }
                 catch (Exception ex)
                 {
                     logger.Error("Twitter.asmx => getUserFollowers => " + ex.Message);
                 }
                 try
                 {
                     _InboxMessages.FollowingCount = item["friends_count"].ToString();
                 }
                 catch (Exception ex)
                 {
                     logger.Error("Twitter.asmx => getUserFollowers => " + ex.Message);
                 }
                 try
                 {
                     _InboxMessages.FromImageUrl = item["profile_image_url"].ToString();
                 }
                 catch (Exception ex)
                 {
                     _InboxMessages.FromImageUrl = item["profile_image_url_https"].ToString();
                 }
                 try
                 {
                     _InboxMessages.CreatedTime = DateTime.Now;
                 }
                 catch (Exception ex)
                 {
                     logger.Error("Twitter.asmx => getUserFollowers => " + ex.Message);
                 }
                 _InboxMessages.RecipientId = TwitterUserId;
                 _InboxMessages.RecipientName = screeenName;
                 if (!objInboxMessagesRepository.checkInboxMessageFriendExists(userId, _InboxMessages.FromId, _InboxMessages.RecipientId, _InboxMessages.MessageType))
                 {
                     objInboxMessagesRepository.AddInboxMessages(_InboxMessages);
                 }
             }
             catch (Exception ex)
             {
                 logger.Error("Twitter.asmx => getUserFollowers => " + ex.Message);
             }
         }
     }
     catch (Exception ex)
     {
         logger.Error("Twitter.asmx => getUserFollowers => " + ex.Message);
     }
 }
        public void getUserNotifications(string UserId, FacebookClient fb, dynamic profile)
        {
            try
            {
                Domain.Socioboard.Domain.InboxMessages _InboxMessages;
                dynamic data = fb.Get("v2.0/me/notifications");
                foreach (var item in data["data"])
                {
                    _InboxMessages = new Domain.Socioboard.Domain.InboxMessages();
                    _InboxMessages.Id = Guid.NewGuid();
                    _InboxMessages.UserId = Guid.Parse(UserId);
                    _InboxMessages.ProfileId = profile["id"].ToString();
                    _InboxMessages.ProfileType = "fb";
                    _InboxMessages.MessageType = "fb_notification";
                    _InboxMessages.EntryTime = DateTime.Now;
                    try
                    {
                        _InboxMessages.Message = item["title"].ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error("Facebook.asmx = > getUserNotifications = > " + ex.Message);
                    }
                    try
                    {
                        _InboxMessages.MessageId = item["id"].ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error("Facebook.asmx = > getUserNotifications = > " + ex.Message);
                    }
                    try
                    {
                        _InboxMessages.FromId = item["from"]["id"].ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error("Facebook.asmx = > getUserNotifications = > " + ex.Message);
                    }
                    try
                    {
                        _InboxMessages.FromName = item["from"]["name"].ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error("Facebook.asmx = > getUserNotifications = > " + ex.Message);
                    }
                    try
                    {
                        _InboxMessages.FromImageUrl = "http://graph.facebook.com/" + _InboxMessages.FromId + "/picture?type=small";
                    }
                    catch (Exception ex)
                    {
                        logger.Error("Facebook.asmx = > getUserNotifications = > " + ex.Message);
                    }
                    try
                    {
                        _InboxMessages.RecipientId = item["to"]["id"].ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error("Facebook.asmx = > getUserNotifications = > " + ex.Message);
                    }
                    try
                    {
                        _InboxMessages.RecipientName = item["to"]["name"].ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error("Facebook.asmx = > getUserNotifications = > " + ex.Message);
                    }
                    try
                    {
                        _InboxMessages.RecipientImageUrl = "http://graph.facebook.com/" + _InboxMessages.RecipientId + "/picture?type=small";
                    }
                    catch (Exception ex)
                    {
                        logger.Error("Facebook.asmx = > getUserNotifications = > " + ex.Message);
                    }
                    try
                    {
                        _InboxMessages.CreatedTime = Convert.ToDateTime(item["created_time"].ToString());
                    }
                    catch (Exception ex)
                    {
                        logger.Error("Facebook.asmx = > getUserNotifications = > " + ex.Message);
                    }

                    if (!objInboxMessagesRepository.checkInboxMessageExists(Guid.Parse(UserId), _InboxMessages.MessageId, _InboxMessages.MessageType))
                    {
                        objInboxMessagesRepository.AddInboxMessages(_InboxMessages);
                    }

                }
            }
            catch (Exception ex)
            {
                logger.Error("getUserNotifications = > " + ex.Message);
            }

        }
Esempio n. 3
0
        public void getUserRetweet(oAuthTwitter OAuth, string TwitterUserId, Guid userId)
        {
            try
            {
                TimeLine _TimeLine = new TimeLine();
                JArray jdata = _TimeLine.Get_Statuses_Retweet_Of_Me(OAuth);
                Domain.Socioboard.Domain.InboxMessages _InboxMessages;
                foreach (var item in jdata)
                {
                    try
                    {
                        _InboxMessages = new Domain.Socioboard.Domain.InboxMessages();
                    
                        _InboxMessages.UserId = userId;
                        _InboxMessages.ProfileId = TwitterUserId;
                        _InboxMessages.ProfileType = "twt";
                        _InboxMessages.MessageType = "twt_retweet";
                        _InboxMessages.EntryTime = DateTime.Now;
                        try
                        {
                            _InboxMessages.MessageId = item["id_str"].ToString();
                        }
                        catch (Exception ex)
                        {
                            _InboxMessages.MessageId = item["id"].ToString();
                        }
                        try
                        {
                            _InboxMessages.Message = item["text"].ToString();
                        }
                        catch (Exception ex)
                        {
                            logger.Error("Twitter.asmx => getUserRetweets => " + ex.Message);
                        }
                        try
                        {
                            _InboxMessages.RecipientId = item["user"]["id_str"].ToString();
                        }
                        catch (Exception ex)
                        {
                            logger.Error("Twitter.asmx => getUserRetweets => " + ex.Message);
                        }
                        try
                        {
                            _InboxMessages.RecipientName = item["user"]["screen_name"].ToString();
                        }
                        catch (Exception ex)
                        {
                            logger.Error("Twitter.asmx => getUserRetweets => " + ex.Message);
                        }
                        try
                        {
                            _InboxMessages.RecipientImageUrl = item["user"]["profile_image_url"].ToString();
                        }
                        catch (Exception ex)
                        {
                            _InboxMessages.RecipientImageUrl = item["user"]["profile_image_url_https"].ToString();
                        }
                        Tweet _tweet = new Tweet();
                        JArray retweet_data = _tweet.Get_Statuses_RetweetsById(OAuth, _InboxMessages.MessageId);
                        foreach (var item_retweet in retweet_data)
                        {
                            _InboxMessages.Id = Guid.NewGuid();
                            try
                            {
                                _InboxMessages.CreatedTime = Utility.ParseTwitterTime(item_retweet["created_at"].ToString());
                            }
                            catch (Exception ex)
                            {
                                logger.Error("Twitter.asmx => getUserRetweets => " + ex.Message);
                            }
                            try
                            {
                                _InboxMessages.FromId = item_retweet["user"]["id_str"].ToString();
                            }
                            catch (Exception ex)
                            {
                                _InboxMessages.FromId = item_retweet["user"]["id"].ToString();
                            }
                            try
                            {
                                _InboxMessages.FromName = item_retweet["user"]["screen_name"].ToString();
                            }
                            catch (Exception ex)
                            {
                                logger.Error("Twitter.asmx => getUserRetweets => " + ex.Message);
                            }
                            try
                            {
                                _InboxMessages.FromImageUrl = item_retweet["user"]["profile_image_url"].ToString();
                            }
                            catch (Exception ex)
                            {
                                _InboxMessages.FromImageUrl = item_retweet["user"]["profile_image_url_https"].ToString();
                            }

                            if (!objInboxMessagesRepository.checkInboxMessageRetweetExists(userId, _InboxMessages.MessageId, _InboxMessages.FromId, _InboxMessages.RecipientId, _InboxMessages.MessageType))
                            {
                                objInboxMessagesRepository.AddInboxMessages(_InboxMessages);
                            }

                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error("Twitter.asmx => getUserRetweets => " + ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("Twitter.asmx => getUserRetweets => " + ex.Message);
            }
        }
        public string GetInstagramFollowing(string userid, string profile_id, string access_token, int status)
        {
            string code_status = "false";
            Domain.Socioboard.Domain.InboxMessages insert = new Domain.Socioboard.Domain.InboxMessages();
            JObject post_data = new JObject();
            string url = "https://api.instagram.com/v1/users/" + profile_id + "/follows?access_token=" + access_token + "&count=100";
            try
            {
                post_data = JObject.Parse(ApiInstagramHttp(url));

            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
            try
            {
                dynamic items = post_data["data"];
                foreach (var item in items)
                {
                    try
                    {
                        Guid Id = Guid.NewGuid();

                        string user_name = item["username"].ToString();
                        string id = item["id"].ToString();
                        string full_name = item["full_name"].ToString();
                        DateTime CreatedTime = DateTime.Now;

                        insert.Id = Id;
                        insert.UserId = Guid.Parse(userid);
                        insert.MessageId = "";
                        insert.ProfileId = profile_id;
                        insert.FromId = profile_id;
                        insert.FromName = "";
                        insert.RecipientId = id;
                        insert.RecipientName = full_name;
                        insert.Message = "";
                        insert.FromImageUrl = "";
                        insert.RecipientImageUrl = "";
                        insert.ProfileType = "insta";
                        insert.MessageType = "insta_following";
                        insert.CreatedTime = CreatedTime;
                        insert.EntryTime = CreatedTime;
                        insert.FollowerCount = "";
                        insert.FollowingCount = "";
                        insert.Status = status;
                        //string i = new JavaScriptSerializer().Serialize(insert);
                        insertfollowerfollowingdata(insert);
                        code_status = "true";
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
            //try
            //{
            //    dynamic pagination_url = post_data["pagination"];
            //    string next_url = string.Empty;
            //    if (pagination_url != null)
            //    {
            //        try
            //        {
            //            next_url = post_data["pagination"]["next_url"].ToString();

            //        }
            //        catch (Exception)
            //        {
            //            pagination_url = null;
            //        }
            //        while (pagination_url != null)
            //        {
            //            JObject post_data_next = JObject.Parse(ApiInstagramHttp(next_url));
            //            try
            //            {
            //                next_url = post_data_next["pagination"]["next_url"].ToString();
            //                pagination_url = post_data_next["pagination"];
            //            }
            //            catch (Exception)
            //            {
            //                pagination_url = null;
            //            }

            //            try
            //            {
            //                dynamic items_next = post_data_next["data"];

            //                foreach (var item in items_next)
            //                {
            //                    try
            //                    {
            //                        Guid Id = Guid.NewGuid();
            //                        string user_name = item["username"].ToString();
            //                        string id = item["id"].ToString();
            //                        string full_name = item["full_name"].ToString();
            //                        DateTime CreatedTime = DateTime.Now;
            //                        insert.Id = Id;
            //                        insert.UserId = Guid.Parse(userid);
            //                        insert.MessageId = "";
            //                        insert.ProfileId = id;
            //                        insert.FromId = profile_id;
            //                        insert.FromName = "";
            //                        insert.RecipientId = id;
            //                        insert.RecipientName = full_name;
            //                        insert.Message = "";
            //                        insert.FromImageUrl = "";
            //                        insert.RecipientImageUrl = "";
            //                        insert.ProfileType = "insta";
            //                        insert.MessageType = "insta_following";
            //                        insert.CreatedTime = CreatedTime;
            //                        insert.EntryTime = CreatedTime;
            //                        insert.FollowerCount = "";
            //                        insert.FollowingCount = "";
            //                        insert.Status = status;
            //                        //string i = new JavaScriptSerializer().Serialize(insert);
            //                        insertfollowerfollowingdata(insert);
            //                        code_status = "true";
            //                    }
            //                    catch (Exception)
            //                    {
            //                    }
            //                }
            //            }
            //            catch (Exception)
            //            {
            //            }
            //        }
            //    }
            //}
            //catch (Exception ex)
            //{
            //    logger.Error(ex.Message);
            //}
            return code_status;
        }