public override ExecutionResult Run(IStepExecutionContext context) { Console.WriteLine($"CareItem id: {WorkItem.Id}, Workflow id: {WorkItem.WorkflowId} Not working, please find out why?"); WorkItem.RaiseErrorEvent("NofifyNoWorking", "time out!"); _rLogger.WriteDebug("執行結果失敗,超過30分鐘沒有結果: " + WorkItem.Id); return(ExecutionResult.Next()); }
/// <summary> /// 將新的需求傳入 work flow,並啟動執行檔執行 /// </summary> /// <param name="id">物件 ID</param> /// <param name="parameters">呼叫執行檔的參數</param> /// <returns></returns> public ExeWorkItem Add(ExeWorkItem item) { while (_workflowDataMappings.Count > 4) { // 一次超過七個 process (可能跟 CPU thread 有關) 會造成無法觸發 Event 的問題 Thread.Sleep(5000); } var workflowId = _host.StartWorkflow("ExeWorkflow", item).Result; item.SetWorkflowId(workflowId); _workflowDataMappings.TryAdd(item.WorkflowId, item.Id); _rLogger.WriteDebug($"執行開始 {item.Id} 頻率: {((NisExeWorkItem)item).TakeTime}"); return(item); }
private void InvokeExe() { _rLogger.WritePerf(new LogEntry { System = "InvokeUdExe.InvokeExe", Layer = WorkItem.Id, }); var process = new Process(); process.StartInfo.FileName = _fileService.ExePath; process.StartInfo.Arguments = string.Join(" ", Params); process.StartInfo.CreateNoWindow = true; process.StartInfo.UseShellExecute = false; try { var isStarted = process.Start(); process.Exited += Process_Exited; var processRunningMessage = $"process {process.SessionId}, session: {process.SessionId} is started: {isStarted}"; Console.WriteLine(processRunningMessage); _rLogger.WriteDebug(processRunningMessage); } catch (Exception ex) { Console.WriteLine("process start failed: " + ex.Message); } //process.WaitForExit(); //Console.WriteLine("Exit of wait."); //process.Close(); _rLogger.WritePerf(new LogEntry { System = "InvokeUdExe.InvokeExe", Layer = WorkItem.Id, }); // for Event handler with Standard output,但 PB 的程式無法成功 //process.StartInfo.RedirectStandardOutput = true; //process.OutputDataReceived += (sender, data) => //{ // if (data.Data != null) // Console.WriteLine("Stdout: " + data.Data); //}; //process.StartInfo.RedirectStandardError = true; //process.ErrorDataReceived += (sender, data) => //{ // if (data.Data != null) // Console.WriteLine("Stderr: " + data.Data + "\n"); //}; //process.BeginOutputReadLine(); // Read each line //process.BeginErrorReadLine(); // Read each line }