Exemplo n.º 1
0
        public void Execute(ExecutingOptions options)
        {
            var host = new RhinoServiceBusHost();

            host.SetArguments(options);
            host.InitialDeployment(options.Account);
        }
Exemplo n.º 2
0
        public void Execute(ExecutingOptions options)
        {
            var installer = new ProjectInstaller
            {
                DisplayName = options.Name,
                Description = options.Name,
                Context     = new InstallContext()
            };

            if (!string.IsNullOrEmpty(options.Account))
            {
                if (string.IsNullOrEmpty(options.Password))
                {
                    throw new InvalidOperationException("When /Action is Install and /Account is set /Password is required.");
                }

                installer.SetUserAccount(options.Account, options.Password);
            }

            installer.Context.Parameters.Add("assemblypath", GetType().Assembly.Location);

            installer.Install(new Hashtable());

            using (var system = Registry.LocalMachine.OpenSubKey("System"))
                using (var currentControlSet = system.OpenSubKey("CurrentControlSet"))
                    using (var services = currentControlSet.OpenSubKey("Services"))
                        using (var service = services.OpenSubKey(installer.ServiceName, true))
                        {
                            var path = (string)service.GetValue("ImagePath");

                            options.Action = Action.Server;

                            service.SetValue("ImagePath", path + options);
                        }
        }
Exemplo n.º 3
0
        public void Execute(ExecutingOptions options)
        {
            var installer = new ProjectInstaller
            {
                DisplayName = options.Name,
                Description = options.Name,
                Context     = new InstallContext()
            };

            installer.Context.Parameters.Add("assemblypath", GetType().Assembly.Location);

            installer.Install(new Hashtable());

            using (var system = Registry.LocalMachine.OpenSubKey("System"))
                using (var currentControlSet = system.OpenSubKey("CurrentControlSet"))
                    using (var services = currentControlSet.OpenSubKey("Services"))
                        using (var service = services.OpenSubKey(installer.ServiceName, true))
                        {
                            var path = (string)service.GetValue("ImagePath");

                            options.Action = Action.Server;

                            service.SetValue("ImagePath", path + options);
                        }
        }
Exemplo n.º 4
0
        public void Execute(ExecutingOptions options)
        {
            var host = new RhinoServiceBusHost();

            host.SetArguments(options);
            try
            {
                host.DebugStart(new string[0]);
                bool keepGoing = true;
                while (keepGoing)
                {
                    Console.WriteLine("Enter 'cls' to clear the screen, 'q' to exit");
                    var op = Console.ReadLine() ?? "";
                    switch (op.ToLowerInvariant())
                    {
                    case "q":
                        keepGoing = false;
                        break;

                    case "cls":
                        Console.Clear();
                        break;
                    }
                }
                host.Stop();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.ReadKey();
            }
        }
Exemplo n.º 5
0
        public void Execute(ExecutingOptions options)
        {
            var host = new RhinoServiceBusHost();
            host.SetArguments(options);
            try
            {
				host.DebugStart(new string[0]);
            	bool keepGoing = true;
				while (keepGoing)
            	{
					Console.WriteLine("Enter 'cls' to clear the screen, 'q' to exit");
            		var op = Console.ReadLine() ?? "";
            		switch (op.ToLowerInvariant())
            		{
						case "q":
            				keepGoing = false;
            				break;
						case "cls":
							Console.Clear();
            				break;
            		}

            	}
                host.Stop();
            }
            catch (Exception e)
            {
                Log.Fatal("Host has crashed", e);
                Console.WriteLine(e);
                Console.ReadKey();
            }
            
        }
Exemplo n.º 6
0
        public void Execute(ExecutingOptions options)
        {
            var installer = new ProjectInstaller
            {
                DisplayName = options.Name,
                Description = options.Name,
                Context = new InstallContext()
            };

            installer.Context.Parameters.Add("assemblypath", GetType().Assembly.Location);

            installer.Install(new Hashtable());

            using (var system = Registry.LocalMachine.OpenSubKey("System"))
            using (var currentControlSet = system.OpenSubKey("CurrentControlSet"))
            using (var services = currentControlSet.OpenSubKey("Services"))
            using (var service = services.OpenSubKey(installer.ServiceName, true))
            {
                var path = (string)service.GetValue("ImagePath");

                options.Action = Action.Server;

                service.SetValue("ImagePath", path + options);
            }
        }
Exemplo n.º 7
0
        public void Execute(ExecutingOptions options)
        {
            var host = new RhinoServiceBusHost();

            host.SetArguments(options);
            ServiceBase.Run(host);
        }
Exemplo n.º 8
0
        public void Execute(ExecutingOptions options)
        {
            var installer = new ProjectInstaller
            {
                DisplayName = options.Name,
                Description = options.Name,
                Context = new InstallContext()
            };

            if (!string.IsNullOrEmpty(options.Account))
            {
                if (string.IsNullOrEmpty(options.Password))
                {
                    throw new InvalidOperationException("When /Action is Install and /Account is set /Password is required.");
                }

                installer.SetUserAccount(options.Account, options.Password);
            }

            installer.Context.Parameters.Add("assemblypath", GetType().Assembly.Location);

            installer.Install(new Hashtable());

            using (var system = Registry.LocalMachine.OpenSubKey("System"))
            using (var currentControlSet = system.OpenSubKey("CurrentControlSet"))
            using (var services = currentControlSet.OpenSubKey("Services"))
            using (var service = services.OpenSubKey(installer.ServiceName, true))
            {
                var path = (string)service.GetValue("ImagePath");

                options.Action = Action.Server;

                service.SetValue("ImagePath", path + options);
            }
        }
Exemplo n.º 9
0
 public Judger(FileFactory factory, Problem problem, Submit submit)
 {
     _factory = factory;
     _problem = problem;
     _options = problem.Options;
     _submit  = submit;
     _checker = JudgeProcess.ApprKernel.Get <IChecker>();
 }
Exemplo n.º 10
0
 /// <summary>
 /// Executes the specified options.
 /// </summary>
 /// <param name="options">The options.</param>
 public void Execute(ExecutingOptions options)
 {
     var installer = new ProjectInstaller
     {
         DisplayName = options.Name,
         Description = options.Name,
         Context = new InstallContext()
     };
     installer.Uninstall(null);
 }
Exemplo n.º 11
0
        public void Execute(ExecutingOptions options)
        {
            var installer = new ProjectInstaller
            {
                DisplayName = options.Name,
                Description = options.Name,
                Context     = new InstallContext()
            };

            installer.Uninstall(null);
        }
Exemplo n.º 12
0
        public TestVerdict CheckMemory(ExecutionOutput executionOutput, ExecutingOptions executingOptions)
        {
            TypeVerdicts verdict = TypeVerdicts.OK;

            if (executionOutput.Memory.TotalKilobytes > executingOptions.MemoryLimit.TotalKilobytes)
            {
                verdict = TypeVerdicts.MemoryLimit;
            }

            return(new TestVerdict(executionOutput.Memory, executionOutput.Time, executionOutput.ExitCode, verdict));
        }
Exemplo n.º 13
0
        public TestVerdict CheckTime(ExecutionOutput executionOutput, ExecutingOptions executingOptions)
        {
            TypeVerdicts verdict = TypeVerdicts.OK;

            if (executionOutput.Time.TotalMilliseconds < executingOptions.TimeLimit.TotalMilliseconds)
            {
                verdict = TypeVerdicts.TimeLimit;
            }

            return(new TestVerdict(executionOutput.Memory, executionOutput.Time, executionOutput.ExitCode, verdict));
        }
Exemplo n.º 14
0
 public void Execute(ExecutingOptions options)
 {
     var host = new RhinoServiceBusHost();
     host.SetArguments(options);
     try
     {
         host.DebugStart(new string[0]);
         Console.WriteLine("Press any key to continue...");
         Console.ReadKey();
         host.Stop();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         Console.ReadKey();
     }
 }
Exemplo n.º 15
0
        public void Execute(ExecutingOptions options)
        {
            var host = new RhinoServiceBusHost();

            host.SetArguments(options);
            try
            {
                host.DebugStart(new string[0]);
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
                host.Stop();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.ReadKey();
            }
        }
Exemplo n.º 16
0
 public ExecutionOutput Execute(string path, string input, ExecutingOptions options, string startArguments)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 17
0
 public void Execute(ExecutingOptions options)
 {
     var host = new RhinoServiceBusHost();
     host.SetArguments(options);
     host.InitialDeployment(options.Account);
 }
Exemplo n.º 18
0
 public Problem(ExecutingOptions options)
 {
     Options = options;
 }
Exemplo n.º 19
0
        public ExecutionOutput Execute(string path, string input, ExecutingOptions option, string startArguments)
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();
            CancellationTokenSource cancelTokenSource = new CancellationTokenSource();
            CancellationToken       token             = cancelTokenSource.Token;
            long    memory = 0;
            Process solve  = new Process();

            Task executing = new Task(() =>
            {
                //Init


                solve.StartInfo = new ProcessStartInfo(path);
                solve.StartInfo.CreateNoWindow         = true;
                solve.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
                solve.StartInfo.RedirectStandardInput  = true;
                solve.StartInfo.RedirectStandardOutput = true;
                solve.StartInfo.UseShellExecute        = false;

                if (startArguments != "")
                {
                    solve.StartInfo.Arguments = startArguments + ".txt";
                }

                solve.Start();

                //Memory
                Task memoryCheck = new Task(() =>
                {
                    while (!token.IsCancellationRequested)
                    {
                        memory = Math.Max(solve.WorkingSet64, memory);
                        Thread.Sleep(25);
                    }
                });
                memoryCheck.Start();


                // Math.Max(0.5, TL*1.5)+0.5

                // Input
                solve.StandardInput.WriteLine(input);


                //byte
                //ToDo: new memory thread 5oms

                //Output
                string result = solve.StandardOutput.ReadToEnd();
                solve.WaitForExit();
                int exitCode = solve.ExitCode;

                //Time
                TimeSpan execitionTime = TimeSpan.FromMilliseconds((int)watch.Elapsed.TotalMilliseconds);

                executionOutput = new ExecutionOutput(execitionTime, new MemorySpan(memory), result, exitCode);
                cancelTokenSource.Cancel();
            }, token);

            executing.Start();

            for (int i = 0; i < option.TimeLimit.Seconds; i++)
            {
                Thread.Sleep(100);
            }

            if (!token.IsCancellationRequested)
            {
                cancelTokenSource.Cancel();
                solve.Kill();
                executionOutput = new ExecutionOutput(TimeSpan.FromMilliseconds((int)watch.Elapsed.TotalMilliseconds), new MemorySpan(-1), "TL", -1);
            }
            return(executionOutput);
        }
Exemplo n.º 20
0
 public void Execute(ExecutingOptions options)
 {
     var host = new RhinoServiceBusHost();
     host.SetArguments(options);
     ServiceBase.Run(host);
 }