Example #1
0
        private void CreateExecution(object execInfo)
        {
            IntervalExecInfoModel obj = execInfo as IntervalExecInfoModel;

            ReportTask(new TaskMessageDataModel(obj.Name, DateTime.Now, TaskBehaviorEnum.Start, "Start to " + obj.Name + ", Path: " + obj.Path + ", Args: " + obj.Arguments));

            ExecuteCommand(obj);

            ReportTask(new TaskMessageDataModel(obj.Name, DateTime.Now, TaskBehaviorEnum.End, obj.Name + " End"));
        }
Example #2
0
        private void ExecuteCommand(IntervalExecInfoModel execInfo)
        {
            int exitCode;
            ProcessStartInfo processInfo;
            Process          process;

            processInfo = new ProcessStartInfo(execInfo.Path, execInfo.Arguments);
            processInfo.CreateNoWindow  = true;
            processInfo.UseShellExecute = false;

            processInfo.RedirectStandardError  = true;
            processInfo.RedirectStandardOutput = true;

            process = Process.Start(processInfo);
            process.WaitForExit();

            string output = process.StandardOutput.ReadToEnd();
            string error  = process.StandardError.ReadToEnd();

            exitCode = process.ExitCode;
            process.Close();
        }
Example #3
0
 public IntervalExecTimer(IntervalExecInfoModel execInfo)
     : base(execInfo)
 {
     _timer = new Timer(CreateExecution, execInfo, 5, execInfo.Interval * 1000);
 }