Ejemplo n.º 1
0
        private static void RunAgent(string agent,
                                     ConcurrentQueue <string[]> queue,
                                     string distrFolder)
        {
            ProcessHelpers.KillProcess("Referee.exe", agent);
            ProcessHelpers.KillProcess("Server.exe", agent);
            ProcessHelpers.KillProcess("Client.exe", agent);

            DeployAgent(agent, distrFolder);

            while (!queue.IsEmpty)
            {
                string[] battle;
                while (!queue.TryDequeue(out battle))
                {
                    Thread.Sleep(10);
                }

                try
                {
                    ProcessHelpers.KillProcess("Referee.exe", agent);
                    ProcessHelpers.KillProcess("Server.exe", agent);
                    ProcessHelpers.KillProcess("Client.exe", agent);

                    RunBattle(agent, battle);
                }
                catch (Exception e)
                {
                    Log($"Error: {e.Message}");
                    queue.Enqueue(battle);
                }

                Log($"{queue.Count} left!");
            }
        }
Ejemplo n.º 2
0
        private static void RunBattle(string agent,
                                      string[] battle)
        {
            const string dir           = @"C:\LambdaContest\distr\Referee\bin\Debug\";
            var          exe           = Path.Combine(dir, "Referee.exe");
            var          parameters    = string.Join(" ", battle);
            var          a             = ProcessHelpers.ExecuteCommand($"PsExec64 \\\\{agent} -w {dir} {exe} {parameters}", ProcessHelpers.FailIfError, Environment.CurrentDirectory);
            var          resultsFolder = Path.Combine(GetAgentDistrFolder(agent), @"Referee\bin\Debug\Results");

            RoboCopy(resultsFolder, "Results");
        }
Ejemplo n.º 3
0
        public static string RoboCopy(string sourceDir,
                                      string destinationDir,
                                      IEnumerable <string> includedFilesFilter = null,
                                      IEnumerable <string> excludedFilesFilter = null,
                                      string additionalOptions = null)
        {
            var include = includedFilesFilter != null
                              ? string.Join(" ", includedFilesFilter.Select(x => $"\"{x}\""))
                              : "";

            var exclude = excludedFilesFilter != null
                              ? string.Format("/xd {0}", string.Join(" ", excludedFilesFilter.Select(x => $"\"{x}\"")))
                              : "";

            var parameters = string.Format(@"""{0}"" ""{1}"" /r:10 /w:2 /fft {2} /e /xo {3}{4}", PathHelpers.ExcludeTrailingSlash(sourceDir),
                                           PathHelpers.ExcludeTrailingSlash(destinationDir), include, exclude,
                                           additionalOptions);

            return(ProcessHelpers.ExecuteCommand("robocopy.exe " + parameters, result => result.ExitCode >= 8, Environment.CurrentDirectory));
        }