Esempio n. 1
0
        public string RunJobThread()
        {
            string output = null;

            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 {Settings.Timeout} seconds");
                process.WaitForEnd(Settings.Timeout * 1000);
                output = process.FetchResult();

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

            Logger.Debug("Job finished");
            return(output);
        }
Esempio n. 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());
        }
Esempio n. 3
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());
        }