示例#1
0
        public void TestStart_DefaultPath()
        {
            var wrapper = new ProcessWrapper("cmd /c cd", _path, false, true);
              wrapper.Start();
              wrapper.WaitForEnd(5000);

              var result = wrapper.FetchResult().Trim();

              Assert.AreEqual(Directory.GetCurrentDirectory().ToLower(), result.ToLower());
        }
示例#2
0
        public void TestStart_RelativePath()
        {
            var wrapper = new ProcessWrapper("system32\\cmd /c cd", "c:\\windows", false, true);
              wrapper.Start();
              wrapper.WaitForEnd(5000);

              var result = wrapper.FetchResult().Trim();

              Assert.AreEqual("c:\\windows\\system32".ToLower(), result.ToLower());
        }
示例#3
0
        public void Run()
        {
            Process = new ProcessWrapper(Command, Settings.Home, false, false);

              try
              {
            Logger.Log("Starting service: " + Command);
            Process.Start();
            Logger.Debug("Process started");
              }
              catch (Exception e)
              {
            var text = string.Format("Failed to start service '{0}': {1}", Command, e.Message);
            Logger.Error(text);
            Helper.SendMail("Cronical: Failed to start service " + Command, text, Settings);
              }
        }
示例#4
0
        public void RunJobThread()
        {
            try
              {
            var process = new ProcessWrapper(Command, Settings.Home, true, Settings.MailStdOut);

            Logger.Log("Starting job: " + Command);
            process.Start();

            Logger.Debug("Process started, waiting at most {0} seconds", Settings.Timeout);
            process.WaitForEnd(Settings.Timeout * 1000);
            var output = process.FetchResult();

            Helper.SendMail("Cronical: Results from " + Command, output, Settings);
              }
              catch (Exception e)
              {
            var text = string.Format("Failed to start process '{0}': {1}", Command, e.Message);
            Logger.Error(text);
            Helper.SendMail("Cronical: Failed to start " + Command, text, Settings);
              }

              Logger.Debug("Job finished");
        }