Skip to content

Instantly share code, notes, and snippets.

Created July 10, 2017 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/d73cbb47b951f2bd0802ffd5108f3f6d to your computer and use it in GitHub Desktop.
Save anonymous/d73cbb47b951f2bd0802ffd5108f3f6d to your computer and use it in GitHub Desktop.
Module fixing 101
using System;
using System.Drawing;
using System.Linq;
using System.Threading;
using Console = Colorful.Console;
namespace VMCancelInvoice
{
class Program
{
// THERE IS NO COW LEVEL
private const string THEROCKET = "###############################|\\****/" +
"|\n ###############################\\#=" +
"=#/\n ################################|" +
"##|\n ################################|" +
"##|\n ################################" +
"\\##/\n ###############################" +
"##\\/";
private const string THEBLAST = "###############################_________" +
"_______\n ##########################____" +
"/#(##(####)###)##\\___\n ###############" +
"##########/(#(##(##)###_####))##)###)\\\n " +
"#######################((#####(###)(####" +
")##)###(###)##)\n #####################(" +
"(/##(#_(###)###(###_)#)#(##()#)##)\n ###" +
"#################(#(##(#(_)###((####(###" +
")##.((_#)#.##)_\n ###################(#(" +
"##)####(######(##)####)###)#.#)#(###)\n " +
"##################(##(###(##(###)#(##_##" +
"(#_)#).##)#.#)#)#(#)\n #################" +
"#(#(##(###)#(##)###(##))#####)#_)(###)##" +
")##)\n #################(#(##(#\\#)#(###" +
"#(_##(#)#(#)##)###)#)##))#(#)\n ########" +
"##########(##(###(##(###(_#(#)#(#_####)#" +
"#)#(##)##)###)\n #################(#(##(" +
"#(##(##)#####(_##)##)#)##_)###)#_(#(#)\n" +
" ##################((##(###)(####(#####_" +
"####)###_)#_(_#(##(_#)\n ###############" +
"####(_((__(_(__((#(#(#|##)#)#)#)_))__))_" +
")___)\n ###################((__)########" +
"\\||lll|l||///##########\\_))\n ########" +
"####################(###/(/#(##)##)#)\\#" +
"##)\n ##########################(####(#(" +
"#(#|#|#)#)#)\\###)\n ###################" +
"########(###/(|#/#(#))#)#)#))#)\n ######" +
"###################(#####(#((((_(|)_))))" +
")#####)\n ##########################(###" +
"###||\\(|(|)|/||#####)\n ###############" +
"#########(########|(||(||)||||########)\n " +
"##########################(#####//|/l|||" +
")|\\#\\#####)\n ########################" +
"(/#/#//##/|//||||\\##\\#\\##\\#_)\n ----" +
"----------------------------------------" +
"-------------------------------";
private static Color message = Color.GreenYellow;
private static Color error = Color.OrangeRed;
private static Color neutral = Color.Yellow;
static void Main()
{
Console.Title = "Cancel Invoice";
/* Once upon a time... */
TimeToShine();
DecisionsDecisions();
}
private static void TimeToShine()
{
/*
-----------------------------------
"Destruction" By Charles Baudelaire
-----------------------------------
At my side the Demon writhes forever,
Swimming around me like impalpable air;
As I breathe, he burns my lungs like fever
And fills me with an eternal guilty desire.
Knowing my love of Art, he snares my senses,
Apearing in woman's most seductive forms,
And, under the sneak's plausible pretenses,
Lips grow accustomed to his lewd love-charms.
He leads me thus, far from the sight of God,
Panting and broken with fatigue into
The wilderness of Ennui, deserted and broad,
And into my bewildered eyes he throws
Visions of festering wounds and filthy clothes,
And all Destruction's bloody retinue.
*/
var wayAround = 0;
while (wayAround < 20)
{
for (int i = 0; i < wayAround; i++)
{
Console.WriteLine();
}
Console.WriteLine(THEROCKET.Replace("#", " "),
Color.Gold);
Thread.Sleep(100);
Console.Clear();
wayAround++;
}
// At this point picture the nuclear blast scene from Terminator 2
while (wayAround > 0)
{
Console.WriteLine(THEBLAST.Replace("#", " "),
Color.Firebrick);
Thread.Sleep(50);
Console.Clear();
Console.WriteLine(THEBLAST.Replace("#", " "),
Color.Orange);
Thread.Sleep(50);
Console.Clear();
wayAround--;
}
}
private static void DecisionsDecisions()
{
Console.Clear();
DrawTheGoddamnMenu();
// CHOOSE YOUR DESTINY!
switch (Console.ReadLine())
{
case "1":
RockAndRoll();
break;
case "2":
Environment.Exit(0);
break;
default:
// Unfortunately, in this world, your input is not an option.
Console.WriteLine("Incorrect Input", error);
break;
}
}
private static void DrawTheGoddamnMenu()
{
Console.WriteLine();
Console.WriteAscii(" CANCEL", Color.Gold);
Console.WriteAscii(" INVOICE", Color.Yellow);
Console.WriteLine(" * ═══════════════════════════════════ *");
Console.WriteLine(" (1) - Cancel an Invoice",
Color.Aqua);
Console.WriteLine(" (2) - Exit",
Color.LightCoral);
Console.WriteLine(" * ═══════════════════════════════════ *");
Console.WriteLine(" Choose option and press ENTER",
Color.Aquamarine); // Simple, right?
}
private static void RockAndRoll()
{
Console.Clear();
Console.WriteLine("Input the invoice number you want to cancel:",
message);
var thisIsWrong = Console.ReadLine();
Console.Clear();
Console.WriteLine("Reason to cancel:", message);
// eg. I wasnt paying attention to what I was doing. I Suck.
var explainYourself = Console.ReadLine();
if (ForTheLoveOfGodTellMeThisIsAValid32BitInteger(thisIsWrong)
&& LetsMakeSureYetAnotherErrorIsNotInTheMaking(thisIsWrong)
&& explainYourself != String.Empty)
{
try // Gotta try...
{
using (var nuclearReactor = new DataClassesDataContext())
{
// NUCLEAR LAUNCH DETECTED
nuclearReactor.spCancelInvoices(thisIsWrong, explainYourself
.Replace("'", "''"));
// Only ashes will come out of this successful execution...
}
}
catch (Exception)
{
// Not enough minerals, mine more minerals.
Console.WriteLine("There was a problem with the database " +
"connection\nPlease try again.", error);
Console.WriteLine();
Console.WriteLine("Press ENTER", neutral);
Console.ReadLine();
RockAndRoll();
}
// Not a single exception was thrown that day...
}
else
{
// Congratulations, you manage to break yet another program.
Console.WriteLine("Invoice number " + thisIsWrong + " is not on " +
"the database.", error);
Console.WriteLine();
Console.WriteLine("Press ENTER to try again.", neutral);
Console.ReadLine();
RockAndRoll();
}
Console.Clear();
Console.WriteLine("Success!", message);
Console.WriteLine("Press ENTER", neutral);
Console.ReadLine();
DecisionsDecisions();
}
private static bool LetsMakeSureYetAnotherErrorIsNotInTheMaking(
string isThisReal)
{
using (var rocketLauncher = new DataClassesDataContext())
{
return (from potatoes in rocketLauncher.tblVesselInvoices
where potatoes.InvoiceNumber == Int32.Parse(isThisReal)
select potatoes).Count().Equals(1);
}
}
private static bool ForTheLoveOfGodTellMeThisIsAValid32BitInteger(
string letsCallItANumber)
{
Int32 anInteger;
bool userActuallyManaged = Int32.TryParse(letsCallItANumber,
out anInteger);
return userActuallyManaged;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment