public void getUserTweets(oAuthTwitter OAuth, string TwitterScreenName, string TwitterUserId, Guid userId) { try { TwitterUser twtuser = new TwitterUser(); JArray data = twtuser.GetStatuses_User_Timeline(OAuth); TwitterMessageRepository twtmsgrepo = new TwitterMessageRepository(); TwitterMessage twtmsg = new TwitterMessage(); foreach (var item in data) { twtmsg.UserId = userId; 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 = TwitterScreenName; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { twtmsg.ProfileId = 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.ProfileId, twtmsg.UserId, twtmsg.MessageId)) { twtmsgrepo.addTwitterMessage(twtmsg); } } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
public void getUserTweets(oAuthTwitter OAuth, string TwitterScreenName, string TwitterUserId, Guid userId, Domain.Socioboard.Domain.TwitterAccount objTwitterAccount) { try { Users userinfo = new Users(); TwitterUser twtuser = new TwitterUser(); JArray data = twtuser.GetStatuses_User_Timeline(OAuth); TwitterMessageRepository twtmsgrepo = new TwitterMessageRepository(); // TwitterMessage twtmsg = new TwitterMessage(); Domain.Socioboard.Domain.TwitterMessage ObjTwitterMessage = new Domain.Socioboard.Domain.TwitterMessage(); foreach (var item in data) { ObjTwitterMessage.UserId = userId; ObjTwitterMessage.Type = "twt_usertweets"; try { ObjTwitterMessage.TwitterMsg = item["text"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { ObjTwitterMessage.SourceUrl = item["source"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { ObjTwitterMessage.ScreenName = TwitterScreenName; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { ObjTwitterMessage.ProfileId = TwitterUserId; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { ObjTwitterMessage.MessageId = item["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { ObjTwitterMessage.MessageDate = Utility.ParseTwitterTime(item["created_at"].ToString().TrimStart('"').TrimEnd('"')); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { ObjTwitterMessage.InReplyToStatusUserId = item["in_reply_to_status_id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { ObjTwitterMessage.Id = Guid.NewGuid(); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { ObjTwitterMessage.FromProfileUrl = item["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { ObjTwitterMessage.FromName = item["user"]["name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } try { ObjTwitterMessage.FromId = item["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } ObjTwitterMessage.EntryDate = DateTime.Now; try { ObjTwitterMessage.FromScreenName = item["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"'); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } if (!twtmsgrepo.checkTwitterMessageExists(ObjTwitterMessage.ProfileId, ObjTwitterMessage.UserId, ObjTwitterMessage.MessageId)) { twtmsgrepo.addTwitterMessage(ObjTwitterMessage); } #region Add TwitterFollowerCount TwitterAccountFollowersRepository objTwitterAccountFollowersRepository = new TwitterAccountFollowersRepository(); Domain.Socioboard.Domain.TwitterAccountFollowers objTwitterAccountFollowers = new Domain.Socioboard.Domain.TwitterAccountFollowers(); objTwitterAccountFollowers.Id = Guid.NewGuid(); objTwitterAccountFollowers.UserId = userId; objTwitterAccountFollowers.EntryDate = DateTime.Now; objTwitterAccountFollowers.ProfileId = TwitterUserId; JArray profile = userinfo.Get_Users_LookUp_ByScreenName(OAuth, TwitterScreenName); foreach (var item_followerdata in profile) { try { objTwitterAccountFollowers.FollowingsCount = Convert.ToInt32(item_followerdata["friends_count"].ToString()); } catch (Exception ex) { logger.Error(ex.StackTrace); } try { objTwitterAccountFollowers.FollowersCount = Convert.ToInt32(item_followerdata["followers_count"].ToString()); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } objTwitterAccountFollowersRepository.addTwitterAccountFollower(objTwitterAccountFollowers); #endregion } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } }
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); } } }