static RundotnetData RunLinux(RundotnetData data) { LinuxService service = new LinuxService(); Service.linux.Languages lang = Service.linux.Languages.Java; if (data.LanguageChoice == LanguagesEnum.Prolog) { data.Input += "\nhalt."; } switch(data.LanguageChoice) { case LanguagesEnum.Java: lang = Service.linux.Languages.Java; break; case LanguagesEnum.Python: lang = Service.linux.Languages.Python; break; case LanguagesEnum.C: lang = Service.linux.Languages.C; break; case LanguagesEnum.CPP: lang = Service.linux.Languages.CPP; break; case LanguagesEnum.Php: lang = Service.linux.Languages.Php; break; case LanguagesEnum.Pascal: lang = Service.linux.Languages.Pascal; break; case LanguagesEnum.ObjectiveC: lang = Service.linux.Languages.ObjectiveC; break; case LanguagesEnum.Haskell: lang = Service.linux.Languages.Haskell; break; case LanguagesEnum.Ruby: lang = Service.linux.Languages.Ruby; break; case LanguagesEnum.Perl: lang = Service.linux.Languages.Perl; break; case LanguagesEnum.Lua: lang = Service.linux.Languages.Lua; break; case LanguagesEnum.Nasm: lang = Service.linux.Languages.Nasm; break; case LanguagesEnum.Javascript: lang = Service.linux.Languages.Javascript; break; case LanguagesEnum.Lisp: lang = Service.linux.Languages.Lisp; break; case LanguagesEnum.Prolog: lang = Service.linux.Languages.Prolog; break; case LanguagesEnum.Go: lang = Service.linux.Languages.Go; break; case LanguagesEnum.Scala: lang = Service.linux.Languages.Scala; break; case LanguagesEnum.Scheme: lang = Service.linux.Languages.Scheme; break; case LanguagesEnum.Nodejs: lang = Service.linux.Languages.Nodejs; break; case LanguagesEnum.Python3: lang = Service.linux.Languages.Python3; break; case LanguagesEnum.Octave: lang = Service.linux.Languages.Octave; break; case LanguagesEnum.CClang: lang = Service.linux.Languages.CClang; break; case LanguagesEnum.CPPClang: lang = Service.linux.Languages.CppClang; break; case LanguagesEnum.D: lang = Service.linux.Languages.D; break; case LanguagesEnum.R: lang = Service.linux.Languages.R; break; case LanguagesEnum.Tcl: lang = Service.linux.Languages.Tcl; break; case LanguagesEnum.Swift: lang = Service.linux.Languages.Swift; break; case LanguagesEnum.FSharp: lang = Service.linux.Languages.FSharp; break; case LanguagesEnum.Bash: lang = Service.linux.Languages.Bash; break; case LanguagesEnum.Ada: lang = Service.linux.Languages.Ada; break; case LanguagesEnum.Erlang: lang = Service.linux.Languages.Erlang; break; case LanguagesEnum.Elixir: lang = Service.linux.Languages.Elixir; break; case LanguagesEnum.Ocaml: lang = Service.linux.Languages.Ocaml; break; default: break; } Stopwatch watch = new Stopwatch(); watch.Start(); var res = service.DoWork(data.Program, data.Input, data.CompilerArgs, lang); watch.Stop(); if (res != null) { if (string.IsNullOrEmpty(res.Stats)) res.Stats = ""; else res.Stats += ", "; res.Stats += string.Format("absolute service time: {0} sec", Math.Round((double)watch.ElapsedMilliseconds/(double)1000, 2)); data.RunStats = res.Stats; } bool logged = false; if (!string.IsNullOrEmpty(res.System_Error)) { reExp.Utils.Log.LogInfo("Linux " + res.System_Error, null, "RunDotNet"); data.Errors.Add(res.System_Error); Utils.Log.LogCodeToDB(data.Program, data.Input, data.CompilerArgs, "Linux: system error " + res.System_Error, (int)data.LanguageChoice, data.IsApi, false); return data; } if (!string.IsNullOrEmpty(res.Errors)) { data.Errors.Add(res.Errors); if (!logged) { Utils.Log.LogCodeToDB(data.Program, data.Input, data.CompilerArgs, "Linux: error " + res.Errors, (int)data.LanguageChoice, data.IsApi, false); logged = true; } } if (res.Exit_Code < 0) { data.Errors.Add(res.Exit_Status); if (!logged) { Utils.Log.LogCodeToDB(data.Program, data.Input, data.CompilerArgs, "Linux: negative exit code " + res.Exit_Status, (int)data.LanguageChoice, data.IsApi, false); logged = true; } } if (!string.IsNullOrEmpty(res.Warnings)) { data.Warnings.Add(res.Warnings); if (!logged) { Utils.Log.LogCodeToDB(data.Program, data.Input, data.CompilerArgs, "Linux: warnings", (int)data.LanguageChoice, data.IsApi, true); logged = true; } } data.Output = res.Output; if (res.Files != null) { data.Files = new List<string>(); foreach (var f in res.Files) { data.Files.Add(Convert.ToBase64String(f)); } } if (!logged) { Utils.Log.LogCodeToDB(data.Program, data.Input, data.CompilerArgs, "Linux: ok", (int)data.LanguageChoice, data.IsApi, true); logged = true; } return data; }
static RundotnetData RunLinux(RundotnetData data) { LinuxService service = new LinuxService(); Service.linux.Languages lang = Service.linux.Languages.Java; switch(data.LanguageChoice) { case "4": lang = Service.linux.Languages.Java; break; case "5": lang = Service.linux.Languages.Python; break; case "6": lang = Service.linux.Languages.C; break; case "7": lang = Service.linux.Languages.CPP; break; default: break; } Stopwatch watch = new Stopwatch(); watch.Start(); var res = service.DoWork(data.Program, lang); watch.Stop(); if (res != null) { if (string.IsNullOrEmpty(res.Stats)) res.Stats = ""; else res.Stats += ", "; res.Stats += string.Format("absolute service time: {0}", Math.Round((double)watch.ElapsedMilliseconds/(double)1000, 2)); data.RunStats = res.Stats; } bool logged = false; if (!string.IsNullOrEmpty(res.System_Error)) { reExp.Utils.Log.LogInfo("Linux " + res.System_Error, "RunDotNet"); data.Errors.Add(res.System_Error); Utils.Log.LogCodeToDB(data.Program, "Linux: system error"); return data; } if (!string.IsNullOrEmpty(res.Errors)) { data.Errors.Add(res.Errors); if (!logged) { Utils.Log.LogCodeToDB(data.Program, "Linux: error"); logged = true; } } if (res.Exit_Code < 0) { data.Errors.Add(res.Exit_Status); if (!logged) { Utils.Log.LogCodeToDB(data.Program, "Linux: negative exit code"); logged = true; } } if (!string.IsNullOrEmpty(res.Warnings)) { data.Warnings.Add(res.Warnings); if (!logged) { Utils.Log.LogCodeToDB(data.Program, "Linux: warnings"); logged = true; } } data.Output = res.Output; if (!logged) { Utils.Log.LogCodeToDB(data.Program, "Linux: ok"); logged = true; } return data; }