Beispiel #1
0
        void Application_Error(object sender, EventArgs e)
        {
            // Code that runs when an unhandled error occurs

            // Get the exception object.
            Exception exc = Server.GetLastError();

            LoggerUtils.GetLogger().Error("Exception occured!", exc);
        }
Beispiel #2
0
        protected void Application_Start()
        {
            log4net.Config.XmlConfigurator.Configure();

            LoggerUtils.GetLogger().Debug("Application started.");

            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
Beispiel #3
0
        protected override void OnException(ExceptionContext filterContext)
        {
            Exception ex = filterContext.Exception;

            filterContext.ExceptionHandled = true;
            LoggerUtils.GetLogger().Error("API call throw exception. URL: " + Request.RawUrl);
            filterContext.Result = new JsonResult
            {
                Data = new ApiResponse
                {
                    StatusCode = 500,
                    Message    = "Internal Server Error"
                },
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };
        }
Beispiel #4
0
        private static void Main(string[] args)
        {
            var logger = LoggerUtils.GetLogger("QuizizzHack");

            LoggerUtils.PrintSystemInformation();
            LoggerUtils.RegisterExceptionHandler();

            if (File.Exists("answers.txt"))
            {
                File.Delete("answers.txt");
            }

            var id = logger.GetInput("Quizizz id:");

            var wc = new WebClient();

            var jsonData = wc.DownloadString("https://quizizz.com/quiz/" + id);

            var data = QuizizzData.FromJson(jsonData);

            if (!data.Success)
            {
                logger.Error("Failed to fetch data from quizizz!");
                Environment.Exit(-1);
            }

            logger.Success("Data fetched successfully!");

            var quizData    = $"Quiz name: {data.Data.Quiz.Info.Name}\nLast update date: {data.Data.Quiz.Info.Updated}";
            var creatorInfo =
                $"Creator username: {data.Data.Quiz.CreatedBy.Local.CasedUsername}\nName: {data.Data.Quiz.CreatedBy.FirstName + " " + data.Data.Quiz.CreatedBy.LastName}";
            var playedTimes    = $"Times played: {data.Data.Quiz.Stats.Played} ({data.Data.Quiz.Stats.TotalPlayers})";
            var totalQuestions = "\n\nTotal questions: {0}";

            logger.Info(quizData);
            logger.Info(creatorInfo);
            logger.Info(playedTimes);

            File.AppendAllText("answers.txt", quizData + "\n" + creatorInfo + "\n\n\nAnswers:\n\n\n");

            logger.Warn("\n\nPrinting answers...\n\n");

            var re = new Regex(@"<[/\w]+>");

            var i = 0;

            foreach (var question in data.Data.Quiz.Info.Questions)
            {
                var q = re.Replace(question.Structure.Query.Text, "");
                var b = new StringBuilder();
                if (question.Structure.Answer.IntegerArray?.Any() == true)
                {
                    var end = question.Structure.Answer.IntegerArray.LastOrDefault();
                    foreach (var l in question.Structure.Answer.IntegerArray)
                    {
                        b.Append(question.Structure.Options[(int)l].Text);
                        if (l != end)
                        {
                            b.Append(", ");
                        }
                    }
                }
                else
                {
                    b.Append(question.Structure.Settings.HasCorrectAnswer
                        ? question.Structure.Options[(int)(question.Structure.Answer.Integer ?? 0)].Text
                        : "no correct answer");
                }

                var ans = re.Replace(b.ToString(),
                                     "");
                var str = ">>> " + q + " <<< === >>> " + ans + " <<<";
                logger.Info(str);
                File.AppendAllText("answers.txt", str + "\n");
                ++i;
            }

            totalQuestions = string.Format(totalQuestions, i);

            File.AppendAllText("answers.txt", totalQuestions);

            logger.Warn("\n{0}\n\n\nEverything is done!", totalQuestions);
        }
Beispiel #5
0
 void Application_End(object sender, EventArgs e)
 {
     LoggerUtils.GetLogger().Debug("Application is shutting down.");
 }