示例#1
0
        static async Task GenerateReports(List <Prompt> prompts)
        {
            /*We will now initialize some objects that will be used as we go execute the call for each prompt */
            var           compiler = new ReportCompile();
            CourseGrabber http     = new CourseGrabber();

            var SuccessReports = new List <ReportItem>();

            /*Loop through each prompt, set up the http call, calibrate how the compiler should work and send the success reports to the Dictionary we have for keeping track of it */
            foreach (var prompt in prompts)
            {
                http.CourseID = prompt.CourseId;
                compiler.CalibrateCompiler(prompt, grabReportObject(prompt.OutFormat, prompt.Destination), http);

                var success = false;
                try
                {
                    success = await compiler.CompileReport();
                }
                catch (Exception e)
                {
                    // Display all errors in an awesome fashion.
                    ConsoleRep.Log(new string[] { "WE GOT AN ERROR BOSS!", e.Message, "Course: " + prompt.CourseId, prompt.OutFormat + " " + prompt.Destination }, ConsoleColor.Red);
                    success = false;
                }
                SuccessReports.Add(new ReportItem(prompt.OutFormat + " " + prompt.Destination + "    =====   " + (success ? "Successful" : "Error!"), success ? ConsoleColor.Green : ConsoleColor.Red));
            }

            ConsoleRep.Log(SuccessReports);
        }
        private static string getValidData(string prompt, Validator validator, string exresonse = "response")
        {
            var response = "";
            var times    = 0;

            do
            {
                times++;
                if (times > 5)
                {
                    ConsoleRep.Log(new string[] { "You obviously have no idea what you are doing! Come back with someone who actually knows how to use this tool" }, ConsoleColor.Green, ConsoleColor.DarkMagenta);
                    for (var i = 0; i < 3; i++)
                    {
                        Console.Beep();
                    }
                    throw new Exception("YOU ARE INCOMPETENT!");
                }
                else if (times < 4)
                {
                    System.Console.WriteLine((times > 1) ? $"That {exresonse} was not legit man! Try again! " : prompt);
                }
                else
                {
                    ConsoleRep.Log(new string[] { "YOU ARE REALLY TRYING MY PATIENCE NOW!", $"That {exresonse} was not legit man! Try again! ", prompt }, ConsoleColor.DarkMagenta, ConsoleColor.Gray);
                }
                response = Console.ReadLine();
            }while (!validator(response));

            if (times >= 5)
            {
                ConsoleRep.Log("THANK YOU INCOMPETENT BABOON!", ConsoleColor.DarkRed);
            }
            return(response);
        }
示例#3
0
 public HttpObject()
 {
     Token = Environment.GetEnvironmentVariable("API_TOKEN");
     if (Token == null)
     {
         ConsoleRep.Log(new string[] { "We could not find the environment variable \"API_TOKEN\"", "Please insert your auth token!" }, ConsoleColor.Blue, ConsoleColor.Yellow);
         Token = Console.ReadLine();
         Environment.SetEnvironmentVariable("API_TOKEN", Token);
     }
 }
        public void PrintStatusMessage()
        {
            var color  = (this.StatusCode == 0) ? ConsoleColor.Green : (this.StatusCode == 1) ? ConsoleColor.Yellow : ConsoleColor.Red;
            var status = (this.StatusCode == 0) ? "SUCCESS" : (this.StatusCode == 1) ? "WARNING" : "FAIL";

            var ReportItemz = new List <ReportItem>()
            {
                new ReportItem($" The Audit \"{StatusTitle}\" resulted with the status: \"{status}\"!", color, (color.Equals(ConsoleColor.Yellow) ? ConsoleColor.DarkBlue : ConsoleColor.White)),
                new ReportItem(StatusMessage, ConsoleColor.Black)
            };

            ConsoleRep.Log(ReportItemz);
        }
示例#5
0
        static List <Prompt> GenerateReportsFromPrompt()
        {
            List <Prompt> prompts = new List <Prompt>();

            try
            {
                /*Gets all necessary input and stores it into a list of prompts */
                prompts = Prompter.PromptUser();
            }
            catch (Exception e)
            {
                ConsoleRep.Log(new string[] { "There was an error collecting the prompt data!", "Error:", e.Message, "Seeing that you have given us absolutely nothing to work with,", "I will just retire to my room until you actually give me something useful!" }, ConsoleColor.Red);

                throw;
            }

            return(prompts);
        }
示例#6
0
        public async Task FullProcessRuns()
        {
            // the test will go on forever if this token is not set! To fix that issue, we will fail the test if it is not set.
            var token = Environment.GetEnvironmentVariable("API_TOKEN");

            Assert.False(token == null);

            // the test will go on forever if this token is not set! To fix that issue, we will fail the test if it is not set.
            List <Prompt> prompts = new List <Prompt>()
            {
                new Prompt("59796", "JSON", RelPath + "full_generated.json"),
                new Prompt("59796", "CSV", RelPath + "full_generated.csv"),
                new Prompt("59796", "HTML", RelPath + "full_generated.html")
            };

            /*We will now initialize some objects that will be used as we go execute the call for each prompt */
            var           compiler = new ReportCompile();
            CourseGrabber http     = new CourseGrabber();

            var SuccessReports = new List <ReportItem>();

            /*Loop through each prompt, set up the http call, calibrate how the compiler should work and send the success reports to the Dictionary we have for keeping track of it */
            foreach (var prompt in prompts)
            {
                http.CourseID = prompt.CourseId;
                compiler.CalibrateCompiler(prompt, grabReportObject(prompt.OutFormat, prompt.Destination), http);

                var success = false;
                try
                {
                    success = await compiler.CompileReport();
                }
                catch (Exception e)
                {
                    // Display all errors in an awesome fashion.
                    ConsoleRep.Log(new string[] { "WE GOT AN ERROR BOSS!", e.Message, "Course: " + prompt.CourseId, prompt.OutFormat + " " + prompt.Destination }, ConsoleColor.Red);
                    success = false;
                }
                Assert.True(success);
            }
            Assert.True(FilesAreEqual(prompts[0].Destination, ExpRelPath + "expected.json"));
            Assert.True(FilesAreEqual(prompts[1].Destination, ExpRelPath + "expected.csv"));
            Assert.True(FilesAreEqual(prompts[2].Destination, ExpRelPath + "expected.html"));
        }
示例#7
0
        public static IReport grabReportObject(string type, string destination)
        {
            switch (type.ToLower().Trim())
            {
            case "json":
                return(new GenerateJSON(destination));

            case "html":
                return(new GenerateHTML(destination, "./boilerplate.html"));

            case "csv":
                return(new GenerateCSV(destination));

            default:
                System.Console.WriteLine("YOU ARE UNWORTHY! Loser!!");
                ConsoleRep.Log(new string[] { $"Warning! We do not have a generator for the type \"{type.ToLower().Trim()}\"!!!", "We will just give you a json instead!" }, ConsoleColor.Yellow, ConsoleColor.DarkBlue);
                break;
            }

            return(new GenerateJSON(destination));
        }
示例#8
0
        static List <Prompt> GenerateReportsFromCsv(string filePath)
        {
            List <Prompt> prompts = new List <Prompt>();

            try
            {
                /*Read PROMPTS FROM CSV */
                List <string[]> promptData = readCsvFromPath(filePath);
                //courseid, filetype, destination
                for (int i = 1; i < promptData.Count; i++)
                {
                    var prompt = new Prompt(promptData[i][0].Trim(), promptData[i][1].Trim(), promptData[i][2].Trim());
                    prompts.Add(prompt);
                }
            }
            catch (Exception e)
            {
                ConsoleRep.Log(new string[] { "There was an error collecting the prompt data!", "Error:", e.Message, "Seeing that you have given us absolutely nothing to work with,", "I will just retire to my room until you actually give me something useful!" }, ConsoleColor.Red);

                throw;
            }
            return(prompts);
        }