Beispiel #1
0
    protected void Submit_Click(object sender, EventArgs e)
    {
        code             = Code.Text;
        selectedLanguage = LanguageSelection.SelectedValue;
        int.TryParse(TextBox1.Text, out problemID);
        Common c = new Common();

        c.openConnection();
        string        query = "select input,output from problems where Id=" + problemID;
        SqlDataReader data  = c.executeReader(query);

        data.Read();
        input          = data.GetString(0);
        expectedOutput = data.GetString(1);
        data.Close();
        codeRun = new CodeRunner(selectedLanguage, code, input);
        codeRun.runCode();
        System.Threading.Thread.Sleep(15000);
        output      = codeRun.getOutput();
        Output.Text = "Output:\n" + output + "\n\nResult: ";
        if (output.Equals(expectedOutput))
        {
            Output.Text += "Accepted";
        }
        else
        {
            Output.Text += "Wrong Answer";
        }
        c.closeConnection();
    }