public string CompileC(string code, string key)
        {
            using (Process process = new Process())
            {
                string output, error, username, dir = @"D:\WORKSPACE\Project\CompilerService\CompileCodeData";
                string name = CompilerService.RandomString(8);
                File.WriteAllText(@"D:\WORKSPACE\Project\CompilerService\CompileCodeData\" + name + ".c", code);
                process.StartInfo.FileName               = "cmd.exe";
                process.StartInfo.UseShellExecute        = false;
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.RedirectStandardError  = true;
                process.StartInfo.Arguments              = String.Format("/C gcc -w -lm " + name + ".c -o " + name + ".exe");
                process.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
                process.StartInfo.CreateNoWindow         = true;
                process.StartInfo.WorkingDirectory       = dir;
                process.Start();
                bool TLE = process.WaitForExit(5000);
                if (!TLE)
                {
                    return("Time Limit Exceeded");
                }
                username = CompilerService.IsAuthorized(key);
                CompilerService.AddRecord(name, username, "C", dir + '\\' + name + ".c");

                StreamReader reader = process.StandardError;

                error = reader.ReadToEnd();
                if (error != "")
                {
                    return(CompilerService.SendResponse(name, "CTE", "", error.Replace(name + ".c:", "")));
                }
                else
                {
                    process.StartInfo.Arguments = String.Format("/C " + name + ".exe && del " + name + ".exe");
                    process.Start();
                    TLE = process.WaitForExit(5000);
                    if (!TLE)
                    {
                        return(CompilerService.SendResponse(name, "TLE", "", "Time Limit Exceeded"));
                    }
                    reader = process.StandardOutput;
                    output = reader.ReadToEnd();
                    reader = process.StandardError;
                    error  = reader.ReadToEnd();

                    if (error != "")
                    {
                        return(CompilerService.SendResponse(name, "RTE", "", error));
                    }
                    else if (output != "")
                    {
                        return(CompilerService.SendResponse(name, "AC", output, ""));
                    }
                    else
                    {
                        return(CompilerService.SendResponse(name, "AC", "No Output", ""));
                    }
                }
            }
        }
        public string CompileJavaWithInput(string code, string input, string key)
        {
            using (Process process = new Process())
            {
                string name = CompilerService.RandomString(8);
                string output, error, username, dir = @"D:\WORKSPACE\Project\CompilerService\CompileCodeData\" + name;

                Directory.CreateDirectory(@"D:\WORKSPACE\Project\CompilerService\CompileCodeData\" + name);
                File.WriteAllText(@"D:\WORKSPACE\Project\CompilerService\CompileCodeData\" + name + "\\Main.java", code);
                File.WriteAllText(@"D:\WORKSPACE\Project\CompilerService\CompileCodeData\" + name + "\\input.txt", input);
                process.StartInfo.FileName               = "cmd.exe";
                process.StartInfo.UseShellExecute        = false;
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.RedirectStandardError  = true;
                process.StartInfo.Arguments              = String.Format("/C javac Main.java");
                process.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
                process.StartInfo.CreateNoWindow         = true;
                process.StartInfo.WorkingDirectory       = dir;
                process.Start();

                username = CompilerService.IsAuthorized(key);
                CompilerService.AddRecord(name, username, "Java", dir + "\\Main.java");

                bool TLE = process.WaitForExit(5000);
                if (!TLE)
                {
                    return(CompilerService.SendResponse(name, "TLE", "", "Time Limit Exceeded"));
                }
                StreamReader reader = process.StandardError;
                error = reader.ReadToEnd();
                if (error != "")
                {
                    return(CompilerService.SendResponse(name, "RTE", "", error));
                }
                else
                {
                    process.StartInfo.Arguments = String.Format("/C Java -cp . Main < input.txt");
                    process.Start();
                    TLE = process.WaitForExit(5000);
                    if (!TLE)
                    {
                        return(CompilerService.SendResponse(name, "TLE", "", "Time Limit Exceeded"));
                    }
                    reader = process.StandardOutput;
                    output = reader.ReadToEnd();
                    reader = process.StandardError;
                    error  = reader.ReadToEnd();

                    if (error != "")
                    {
                        return(CompilerService.SendResponse(name, "CTE", "", error));
                    }
                    else if (output != "")
                    {
                        return(CompilerService.SendResponse(name, "AC", output, ""));
                    }
                    else
                    {
                        return(CompilerService.SendResponse(name, "AC", "No Output", ""));
                    }
                }
            }
        }