protected void btnAddNeverFollow_Click(object sender, EventArgs e)
        {
            List <Twitter.User> addToNeverFollowList = new List <Twitter.User>();

            foreach (GridViewRow row in gvUsers.Rows)
            {
                Control ctrl = row.FindControl("cbxDelete");
                if (ctrl != null)
                {
                    CheckBox cbx = (CheckBox)ctrl;
                    if (cbx.Checked)
                    {
                        Control lblctrl = row.FindControl("lblUserId");
                        if (lblctrl != null)
                        {
                            Label lbl  = (Label)lblctrl;
                            var   user = ListUsers.Where(k => k.UserId == lbl.Text).FirstOrDefault();
                            addToNeverFollowList.Add(user);
                            ListUsers.Remove(user);
                        }
                    }
                }
            }
            CreateDestroyList.AddToNeverFollowList(addToNeverFollowList);
            Serializer.WriteFollowersXML(ListUsers.ToList(), Constants.FriendsFollowers.Users.ToString());
            BindData();
        }
        protected void btnFollowAll_Click(object sender, EventArgs e)
        {
            if (ListUsers.Count > 0)
            {
                bool friendsChanged = false;

                TwitterAuthenticate();
                try {
                    foreach (Twitter.User user in ListUsers)
                    {
                        twdata = new Twitter(user, Twitter.TwitterType.Friends);
                        if (!ListFriends.Contains(user))
                        {
                            ListFriends.Add(user);
                            friendsChanged = true;
                        }
                        ListUsers.Remove(user);
                    }
                    ListUsers.Clear();
                    if (friendsChanged)
                    {
                        Serializer.WriteFollowersXML(ListFriends.ToList(), Constants.FriendsFollowers.Friends.ToString());
                    }

                    Serializer.WriteFollowersXML(ListUsers.ToList(), Constants.FriendsFollowers.NotFollowing.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
                }
            }
        }
        protected void btnDestroy_Click(object sender, EventArgs e)
        {
            if (ListUsers.Count > 0)
            {
                bool usersChanged     = false;
                bool followersChanged = false;

                TwitterAuthenticate();
                try {
                    foreach (GridViewRow row in gvUsers.Rows)
                    {
                        Control ctrl = row.FindControl("cbxDelete");
                        if (ctrl != null)
                        {
                            CheckBox cbx = (CheckBox)ctrl;
                            if (cbx.Checked)
                            {
                                Control lblctrl = row.FindControl("lblUserId");
                                if (lblctrl != null)
                                {
                                    Label lbl  = (Label)lblctrl;
                                    var   user = ListUsers.Where(k => k.UserId == lbl.Text).FirstOrDefault();
                                    if (user != null)
                                    {
                                        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.Remove(user);
                                        usersChanged = true;
                                    }
                                }
                            }
                        }
                    }
                    if (followersChanged)
                    {
                        Serializer.WriteFollowersXML(ListFriends.ToList(), Constants.FriendsFollowers.Friends.ToString());
                    }
                    if (usersChanged)
                    {
                        Serializer.WriteFollowersXML(ListUsers.ToList(), Constants.FriendsFollowers.Analyze.ToString());
                        Serializer.WriteFollowersXML(ListUsers.ToList(), 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
                }
            }
        }
Example #4
0
        private void DeleteUserMethod()
        {
            string login = SelectedUser.login;

            if (Users.DeleteUser(login))
            {
                var msg = Utils.Utils.createMessageBox("L'utilisateur " + login + " a été supprimé avec succès !");
                msg.Show();
                ListUsers.Remove(ListUsers.Where(i => i.login == login).Single());
                SelectedUser = ListUsers.First();
            }
            else
            {
                MaterialMessageBox.ShowError("L'utilisateur " + login + " n'a pas put être supprimé Réessayez plus tard !");
            }
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            if (ListUsers.Count > 0)
            {
                bool usersChanged     = false;
                bool friendsChanged   = false;
                bool followersChanged = false;

                foreach (GridViewRow row in gvUsers.Rows)
                {
                    Control ctrl = row.FindControl("cbxDelete");
                    if (ctrl != null)
                    {
                        CheckBox cbx = (CheckBox)ctrl;
                        if (cbx.Checked)
                        {
                            Control lblctrl = row.FindControl("lblUserId");
                            if (lblctrl != null)
                            {
                                Label lbl  = (Label)lblctrl;
                                var   user = ListUsers.Where(k => k.UserId == lbl.Text).FirstOrDefault();
                                if (user != null)
                                {
                                    var uremove = ListFriends.Where(x => x.UserId == user.UserId).FirstOrDefault();
                                    if (uremove != null)
                                    {
                                        ListFriends.Remove(uremove);
                                        friendsChanged = true;
                                    }
                                    var furemove = ListFollowers.Where(x => x.UserId == user.UserId).FirstOrDefault();
                                    if (furemove != null)
                                    {
                                        ListFollowers.Remove(furemove);
                                        followersChanged = true;
                                    }
                                    ListUsers.Remove(user);
                                    usersChanged = true;
                                }
                            }
                        }
                    }
                }
                if (friendsChanged)
                {
                    Serializer.WriteFollowersXML(ListFriends.ToList(), Constants.FriendsFollowers.Friends.ToString());
                }
                if (followersChanged)
                {
                    Serializer.WriteFollowersXML(ListFollowers.ToList(), Constants.FriendsFollowers.Followers.ToString());
                }
                if (usersChanged)
                {
                    if (friendsChanged)
                    {
                        Serializer.WriteFollowersXML(ListUsers.ToList(), Constants.FriendsFollowers.Analyze.ToString());
                    }
                    if (friendsChanged)
                    {
                        Serializer.WriteFollowersXML(ListUsers.ToList(), Constants.FriendsFollowers.Unfollow.ToString());
                    }
                    if (followersChanged)
                    {
                        Serializer.WriteFollowersXML(ListUsers.ToList(), Constants.FriendsFollowers.NotFollowing.ToString());
                    }
                    Serializer.WriteFollowersXML(ListUsers.ToList(), Constants.FriendsFollowers.Users.ToString());
                }
                BindData();
            }
        }