Esempio n. 1
0
        private void CreateExecution(object execInfo)
        {
            DailyExecInfoModel obj = execInfo as DailyExecInfoModel;

            string timeLine = DateTime.Now.ToString("HH:mm");

            if (timeLine == obj.DailyTimeLine)
            {
                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"));
            }
        }
Esempio n. 2
0
        private void ExecuteCommand(DailyExecInfoModel 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();
        }
Esempio n. 3
0
 public DailyExecTimer(DailyExecInfoModel execInfo)
     : base(execInfo)
 {
     _timer = new Timer(CreateExecution, execInfo, 0, 60000);
 }