void GetNextProblemOrNewTheory() { if (!Data.choosedCourseDirectory.Contains(Data.GetCurrentTheme() + "\\Theory")) { List <string> currentShortProblems = new List <string>(); currentShortProblems = Data.GetShortProblemNames(Data.GetCurrentTheme()); string gk = Data.GetCurrentProblem().Substring(Data.GetCurrentTheme().Length + 1); int currentProblemNumber = currentShortProblems.IndexOf(gk); if (currentShortProblems.Count - 1 > currentProblemNumber) { Data.choosedCourseDirectory = Data.courseDirectory + Data.GetCurrentTheme() + "\\" + currentShortProblems.ElementAt(currentProblemNumber + 1); choosingProblemOrTheory = "\\Problem"; } else { int currentCourseNumber = Data.courses.IndexOf(Data.GetCurrentTheme()); if (Data.courses.Count - 1 > currentCourseNumber) { choosingProblemOrTheory = ""; Data.choosedCourseDirectory = Data.courseDirectory + Data.courses.ElementAt(currentCourseNumber + 1) + "\\Theory"; } else { MessageBox.Show("Поздравляем с окончанием курса!"); end = true; } } } else { choosingProblemOrTheory = "\\Problem"; Data.choosedCourseDirectory = Data.courseDirectory + Data.GetCurrentTheme() + "\\" + Data.GetFirstProblem(Data.GetCurrentTheme()); } }
private void Send_Click(object sender, RoutedEventArgs e) { Results.Document.Blocks.Clear(); string errText = ""; string data = ""; compilationError = false; if (!string.IsNullOrWhiteSpace(new TextRange(Code.Document.ContentStart, Code.Document.ContentEnd).Text)) { data = new TextRange(Code.Document.ContentStart, Code.Document.ContentEnd).Text; if (choosingProblemOrTheory != "") { if (CheckForCoinsidence(data)) { string[] CodeText = data.Split('\n'); File.WriteAllLines(@"Text.cs", CodeText); Process CompileCSC = CreateCompileProcess(); CompileCSC.Start(); errText = CompileCSC.StandardOutput.ReadToEnd(); if (errText.Length > 412) // шапка вывода компилятора, 412 символов { bufferOfOutput += errText.Substring(412) + "\n"; compilationError = true; } CompileCSC.WaitForExit(); if (!compilationError) { checkerResult = Checkers.Check(Data.choosedCourseDirectory); switch (checkerResult) { case 0: bufferOfOutput += "Решение принято!"; break; case 1: bufferOfOutput += "Ошибка! Неверное решение!"; break; case 2: bufferOfOutput += "Ошибка! Превышено время ожидания результата!"; break; } if (checkerResult == 0) { Next.Visibility = Visibility.Visible; Send.Visibility = Visibility.Hidden; Directory.CreateDirectory("usersdata"); string wasTest = ""; if (Data.numOfTests != 0) { wasTest = "Test: "; } File.AppendAllText("usersdata/" + Data.firstName + " " + Data.lastName, wasTest + "In theme " + Data.GetCurrentTheme() + " was solved " + Data.GetCurrentProblem().Substring(Data.GetCurrentTheme().Length + 1) + " date: " + DateTime.UtcNow + "\n"); SendSolveAndResults(data); } } } } else { if (CheckTest(data)) { Next.Visibility = Visibility.Visible; Send.Visibility = Visibility.Hidden; } } Results.Document.Blocks.Add(new Paragraph(new Run(bufferOfOutput))); bufferOfOutput = ""; } }