Exemplo n.º 1
0
        public static void StartFileDeletion(List <string> imageIDs)
        {
            Console.WriteLine("------------------------------------------------");

            Console.WriteLine("               _                            __ ");
            Console.WriteLine(" ____         | |_      _____         _    |  |");
            Console.WriteLine("|    \\ ___ ___|_| |_   |  _  |___ ___|_|___|  |");
            Console.WriteLine("|  |  | . |   | |  _|  |   __| .'|   | |  _|__|");
            Console.WriteLine("|____/|___|_|_| |_|    |__|  |__,|_|_|_|___|__|");
            Console.WriteLine("");
            Console.WriteLine("------------------------------------------------");

            Console.WriteLine("Open source Hacked Core Restorative Automatic Program (OH CRAP) v2");
            Console.WriteLine("------------");
            Console.WriteLine("Deleting uploaded images...");

            foreach (string iD in imageIDs)
            {
                var result = WordPressConnector.Delete(Convert.ToInt32(iD));
                if (result)
                {
                    Console.WriteLine("Deleted file with id " + iD);
                }
                else
                {
                    ColoredConsole.WriteLineWithColor("Failed to delete file with id " + iD, ConsoleColor.Red);
                }
            }

            Console.WriteLine("Cleanup complete! Press any key to exit.");
            Console.ReadKey();
        }
Exemplo n.º 2
0
        private void TryToDeleteImages()
        {
            lblStatus.Text = "Rolling back...";

            WordPressConfig config = new WordPressConfig("https://www.raywenderlich.com", txtUsername.Text, txtPassword.Text);

            try
            {
                // Something went wrong, delete all uploaded images
                for (var i = 0; i < _imageIdList.Count; i++)
                {
                    int  id      = _imageIdList[i];
                    bool deleted = WordPressConnector.Delete(id);
                    progressUpload.Value--;

                    if (!deleted)
                    {
                        MessageBox.Show("Couldn't delete image: " + ImageUploadData.ImageUrls[i]);
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                MessageBox.Show("Image rollback failed. Please delete the remaining images manually.");
                return;
            }

            MessageBox.Show("Rollback succesfull!");
        }