Exemple #1
0
 public string getOutput()
 {
     Object[] returnVal = codeRunner.getSubmissionStatus(UserName, Password, submissionId);
     result = new Dictionary <string, string>();
     foreach (object o in returnVal)
     {
         if (o is XmlElement)
         {
             XmlNodeList x = ((XmlElement)o).ChildNodes;
             result.Add(x.Item(0).InnerText, x.Item(1).InnerText);
         }
     }
     if (!result["error"].Equals("OK"))
     {
         return("Error!");
     }
     else
     {
         result    = new Dictionary <string, string>();
         returnVal = codeRunner.getSubmissionDetails(UserName, Password, submissionId, false, false, true, true, true);
         foreach (object o in returnVal)
         {
             if (o is XmlElement)
             {
                 XmlNodeList x = ((XmlElement)o).ChildNodes;
                 result.Add(x.Item(0).InnerText, x.Item(1).InnerText);
             }
         }
         return(result["output"]);
     }
 }
Exemple #2
0
        /// <summary>
        /// Executes the job.
        /// </summary>
        /// <returns>Output of compiled program.</returns>
        public string Execute()
        {
            var returnedData = client.createSubmission(
                user: Username,
                pass: ApiPassword,
                sourceCode: Code,
                language: Lang,
                input: null,
                run: true,
                @private: false
                );
            var result = FilterResult(returnedData);

            if (result["error"] != "OK")
            {
                throw new RemoteServiceException("createSubmission: " + result["error"]);
            }
            var link = result["link"];

            do
            {
                System.Threading.Thread.Sleep(1000);
                returnedData = client.getSubmissionDetails(
                    Username,
                    ApiPassword,
                    link,
                    withSource: false,
                    withInput: false,
                    withOutput: true,
                    withStderr: false,
                    withCmpinfo: false
                    );
                result = FilterResult(returnedData);
            } while (result["status"] != "0");
            if (result["result"] == "15")
            {
                Output = result["output"];
            }
            else
            {
                throw new BadCodeException("Failed to execute properly");
            }
            return(Output);
        }