コード例 #1
0
        private void ShredButton_Click(object sender, RoutedEventArgs e)
        {
            _shreddedComments = 0;
            _shreddedPosts    = 0;
            _logger           = new Logger();
            if (_redditUser == null)
            {
                MessageBox.Show("You're not logged in. Try again.", "Not logged in!", MessageBoxButton.OK, MessageBoxImage.Error);
                ShredButton.IsEnabled = false;
                return;
            }

            var sure = MessageBox.Show("Are you certain you want to shred your reddit history?", "Shred for real?", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (sure != MessageBoxResult.Yes)
            {
                return;
            }

            sure = MessageBox.Show("Shredding is irreversible. Are you really, really sure?", "No, seriously...", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (sure != MessageBoxResult.Yes)
            {
                return;
            }

            ToggleShredImage(true);
            ShredButton.IsEnabled = false;

            var writeGarbage = WriteGarbage.Text == "Yes";
            int numberOfPasses;

            int.TryParse(PassNumber.Text, out numberOfPasses);
            var deletePostsQty    = int.Parse(DeletePostsQuantity.Text);
            var deleteCommentsQty = int.Parse(DeleteCommentsQuantity.Text);

            var sc = new ShredCommand(writeGarbage, numberOfPasses, deletePostsQty, deleteCommentsQty);

            ThreadPool.QueueUserWorkItem(ShredThreadProc, sc);
            OutputTextBlock.Text = _logger.LogEntry(OutputTextBlock.Text, "Shredding in progress.", false);

            Thread.Sleep(1000);
        }
コード例 #2
0
ファイル: ShredEngine.cs プロジェクト: maxawesome/shReddit
        public bool Shred(AuthenticatedUser redditUser, ShredCommand sc)
        {
            var postsToShred = redditUser.Posts.Take(sc.DeletePostsQty).ToList();
            var commentsToShred = redditUser.Comments.Take(sc.DeleteCommentsQty).ToList();

            ShreddedPosts = 0;
            ShreddedComments = 0;

            foreach (var post in postsToShred)
            {
                if (sc.WriteGarbage)
                {
                    for (var i = 0; i < sc.NumberOfPasses; i++)
                    {
                        if (!post.IsSelfPost) continue;
                        try
                        {
                            post.EditText(GenerateRandomString());
                        }
                        catch (Exception ex)
                        {
                            var msg = ex.Message;
                            ErrorCount++;
                        }
                    }
                }

                if (sc.DeletePostsQty == 0) continue;
                try
                {
                    post.Del();
                    ShreddedPosts++;
                }
                catch (Exception ex)
                {
                    var msg = ex.Message;
                    ErrorCount++;
                }
            }

            foreach (var comment in commentsToShred)
            {
                if (sc.WriteGarbage)
                {
                    for (var i = 0; i < sc.NumberOfPasses; i++)
                    {
                        try
                        {
                            comment.EditText(GenerateRandomString());
                        }
                        catch (Exception ex)
                        {
                            var msg = ex.Message;
                            ErrorCount++;
                        }
                    }
                }

                if (sc.DeleteCommentsQty == 0) continue;
                try
                {
                    comment.Del();
                    ShreddedComments++;
                }
                catch (Exception ex)
                {
                    var msg = ex.Message;
                    ErrorCount++;
                }
            }

            return true;
        }
コード例 #3
0
        private void ShredButton_Click(object sender, RoutedEventArgs e)
        {
            if (_redditUser == null)
            {
                MessageBox.Show("You're not logged in. Try again.", "Not logged in!", MessageBoxButton.OK, MessageBoxImage.Error);
                ShredButton.IsEnabled = false;
                return;
            }

            var sure = MessageBox.Show("Are you certain you want to shred your reddit history?", "Shred for real?", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (sure != MessageBoxResult.Yes) return;

            sure = MessageBox.Show("Shredding is irreversible. Are you really, really sure?", "No, seriously...", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (sure != MessageBoxResult.Yes) return;

            ToggleShredImage(true);
            ShredButton.IsEnabled = false;

            var writeGarbage = WriteGarbage.Text == "Yes";
            int numberOfPasses;
            int.TryParse(PassNumber.Text, out numberOfPasses);
            var deletePostsQty = int.Parse(DeletePostsQuantity.Text);
            var deleteCommentsQty = int.Parse(DeleteCommentsQuantity.Text);

            var sc = new ShredCommand(writeGarbage, numberOfPasses, deletePostsQty, deleteCommentsQty);

            ThreadPool.QueueUserWorkItem(ShredThreadProc, sc);
            OutputTextBlock.Text += $"\r\n{DateTime.Now} | Shredding in progress.";

            Thread.Sleep(1000);
        }
コード例 #4
0
        public bool Shred(AuthenticatedUser redditUser, ShredCommand sc)
        {
            var postsToShred    = redditUser.Posts.Take(sc.DeletePostsQty).ToList();
            var commentsToShred = redditUser.Comments.Take(sc.DeleteCommentsQty).ToList();

            ShreddedPosts    = 0;
            ShreddedComments = 0;

            foreach (var post in postsToShred)
            {
                if (sc.WriteGarbage)
                {
                    for (var i = 0; i < sc.NumberOfPasses; i++)
                    {
                        if (!post.IsSelfPost)
                        {
                            continue;
                        }
                        try
                        {
                            post.EditText(GenerateRandomString());
                        }
                        catch (Exception ex)
                        {
                            var msg = ex.Message;
                            ErrorCount++;
                        }
                    }
                }

                if (sc.DeletePostsQty == 0)
                {
                    continue;
                }
                try
                {
                    post.Del();
                    ShreddedPosts++;
                }
                catch (Exception ex)
                {
                    var msg = ex.Message;
                    ErrorCount++;
                }
            }



            foreach (var comment in commentsToShred)
            {
                if (sc.WriteGarbage)
                {
                    for (var i = 0; i < sc.NumberOfPasses; i++)
                    {
                        try
                        {
                            comment.EditText(GenerateRandomString());
                        }
                        catch (Exception ex)
                        {
                            var msg = ex.Message;
                            ErrorCount++;
                        }
                    }
                }

                if (sc.DeleteCommentsQty == 0)
                {
                    continue;
                }
                try
                {
                    comment.Del();
                    ShreddedComments++;
                }
                catch (Exception ex)
                {
                    var msg = ex.Message;
                    ErrorCount++;
                }
            }

            return(true);
        }