Exemple #1
0
 protected override void TwitterAuthenticate()
 {
     base.TwitterAuthenticate();
     try {
         twdata = new Twitter(Twitter.TwitterType.TimeLine);
     } catch (Exception) {
         //do nothing
     }
     if (twdata != null)
     {
         try {
             if (btnNext.Text == Resources.Resource.First)
             {
                 twdata.FirstCallData(resource_urlFormat, friendsorfollowers, count, string.Empty);
             }
             else
             {
                 if (btnNextClicked && ListTimeLine != null && string.IsNullOrEmpty(txtLastID.Text) && ListTimeLine.Count > 0)
                 {
                     twdata.FirstCallData(resource_urlFormat, friendsorfollowers, count, string.Empty, ListTimeLine[ListTimeLine.Count - 1].ID.ToString());
                 }
                 else
                 {
                     if (string.IsNullOrEmpty(txtLastID.Text))
                     {
                         twdata.FirstCallData(resource_urlFormat, friendsorfollowers, count, string.Empty);
                     }
                     else
                     {
                         twdata.FirstCallData(resource_urlFormat, friendsorfollowers, count, string.Empty, txtLastID.Text);
                     }
                 }
             }
         } catch (Exception ex) {
             //do nothing
             lblError.Text    = ex.Message;
             lblError.Visible = true;
         } finally {
             if (twdata != null)
             {
                 ListTimeLine = twdata.listTimeline;
             }
         }
         GetData(true);
         btnNext.Visible = true;
     }
 }
        protected void btnDestroyAll_Click(object sender, EventArgs e)
        {
            if (ListUsers.Count > 0)
            {
                bool followersChanged = false;

                TwitterAuthenticate();
                try {
                    foreach (Twitter.User user in ListUsers)
                    {
                        twdata = new Twitter(user, Twitter.TwitterType.Unfollow);
                        Twitter.User utoremove = ListFriends.Find(x => x.UserId == user.UserId);
                        if (utoremove != null && ListFriends.Contains(utoremove))
                        {
                            ListFriends.Remove(utoremove);
                            followersChanged = true;
                        }
                    }
                    ListUsers.Clear();
                    if (followersChanged)
                    {
                        Serializer.WriteFollowersXML(ListFriends.ToList(), Constants.FriendsFollowers.Friends.ToString());
                    }

                    Serializer.DeleteListXML(Constants.FriendsFollowers.Analyze.ToString());
                    Serializer.DeleteListXML(Constants.FriendsFollowers.Unfollow.ToString());
                    Serializer.WriteFollowersXML(ListUsers.ToList(), Constants.FriendsFollowers.Users.ToString());
                    BindData();
                } catch (WebException wex) {
                    BindData();
                    ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", string.Format("alert('{0}');", "No internet connection: " + wex.Message.Replace("'", string.Empty)), true);
                } catch (Exception ex) {
                    //do nothing
                }
            }
        }
Exemple #3
0
 private void destroy(bool isreply, bool isRetweets)
 {
     if (ListTimeLine != null)
     {
         try {
             List <Twitter.Timeline> timelinestoremove = new List <Twitter.Timeline>();
             if (ListTimeLine.Count > 0)
             {
                 foreach (Twitter.Timeline timeline in ListTimeLine)
                 {
                     if (isreply)
                     {
                         if (timeline.IsReply)
                         {
                             try {
                                 twdata = new Twitter(timeline, Twitter.TwitterType.TimeLine);
                                 timelinestoremove.Add(timeline);
                             } catch (WebException webex) {
                                 if (webex.Message.Contains("(404)") && webex.Message.ToLower().Contains("not found"))
                                 {
                                     timelinestoremove.Add(timeline);
                                 }
                             }
                         }
                     }
                     else
                     {
                         if (isRetweets)
                         {
                             if (timeline.User != null && timeline.User.ScreenName != Master.screen_name)
                             {
                                 try {
                                     twdata = new Twitter(timeline, Twitter.TwitterType.TimeLine);
                                     timelinestoremove.Add(timeline);
                                 } catch (WebException webex) {
                                     if (webex.Message.Contains("(404)") && webex.Message.ToLower().Contains("not found"))
                                     {
                                         timelinestoremove.Add(timeline);
                                     }
                                 }
                             }
                         }
                         else
                         {
                             try {
                                 twdata = new Twitter(timeline, Twitter.TwitterType.TimeLine);
                                 timelinestoremove.Add(timeline);
                             } catch (WebException webex) {
                                 if (webex.Message.Contains("(404)") && webex.Message.ToLower().Contains("not found"))
                                 {
                                     timelinestoremove.Add(timeline);
                                 }
                             }
                         }
                     }
                 }
             }
             if (timelinestoremove.Count > 0)
             {
                 foreach (Twitter.Timeline timeline in timelinestoremove)
                 {
                     ListTimeLine.Remove(timeline);
                 }
                 friendsorfollowers = Master.Friendorfollower.ToString().ToLower();
                 Serializer.WriteTimelineXML(ListTimeLine.ToList(), friendsorfollowers);
                 ListTimeLine = Serializer.ReadTimelineBindingListXML(friendsorfollowers);
             }
             BindData();
         } catch (WebException wex) {
             BindData();
             ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", string.Format("alert('{0}');", "No internet connection: " + wex.Message.Replace("'", string.Empty)), true);
         } catch (Exception ex) {
             //do nothing
         }
     }
 }