private TaskActionType objDownloadJob_TaskEnd(ITaskResult objTaskResult, int intIndex) { timerUpdateProgress.Enabled = false; TaskActionType enuTaskActionType = TaskActionType.Continue; if (objTaskResult.Result == TaskResultType.Failed) { enuTaskActionType = DownloadFailedMessage.ShowMessage(objTaskResult); } this.ThreadSafe(new MethodInvoker(delegate() { timerUpdateProgress.Enabled = false; UpdateOverallProgress(_intTaskCount, _intTaskIndex); ListViewItem objListViewItem = listViewStatus.Items[_intTaskIndex - 1]; if (objListViewItem != null) { objListViewItem.SubItems[1].Text = objTaskResult.Result.ToString(); listViewStatus.EnsureVisible(objListViewItem.Index); } UpdateCurrentProgress(progressBarCurrent.Maximum, progressBarCurrent.Maximum); })); _objCurrentDownloadStats = null; return(enuTaskActionType); }
internal static Action ActionFromScript(string actionType, string script) { TaskActionType tat = TryParse(actionType, TaskActionType.Execute); Type t = GetObjectType(tat); return((Action)t.InvokeMember("FromPowerShellCommand", BindingFlags.DeclaredOnly | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.InvokeMethod, null, null, new object[] { script })); }
/// <summary> /// 请求执行任务 /// </summary> /// <param name="type"></param> /// <param name="value"></param> public void Request(TaskActionType type, object value) { if (RunMode == RunModeType.Normal) { TaskQueueObject tqo = new TaskQueueObject(); tqo.ActionType = type; tqo.Value = value; TaskQueues.Enqueue(tqo); } else { try { if (MainService.MainUIObj.IsHandleCreated) { MainService.MainUIObj.Invoke(new MethodInvoker(delegate() { if (MainService.VoiceUIObj != null) { MainService.VoiceUIObj.ChatPanel.AddMachineMsg(SuperObject.Config.DebugModeHintText); } })); } } catch (Exception ex) { System.Console.WriteLine(ex.ToString()); } } }
public Action AddNew(TaskActionType actionType) { if (_v1Task != null) { return(new ExecAction(_v1Task)); } return(Action.CreateAction(_v2Coll.Create(actionType))); }
protected TaskActionType OnTaskEnd(ITaskResult objTaskResult, int intIndex) { TaskActionType enuTaskActionType = TaskActionType.Continue; if (this.TaskEnd != null) { enuTaskActionType = this.TaskEnd(objTaskResult, intIndex); } return(enuTaskActionType); }
public static TaskActionType ShowMessage(ITaskResult objTaskResult) { TaskActionType enuResult = default(TaskActionType); using (UploadFailedMessage objDialog = new UploadFailedMessage()) { enuResult = objDialog.ShowDialogWithResult(objTaskResult); } return(enuResult); }
public static Action CreateAction(TaskActionType actionType) { switch (actionType) { case TaskActionType.ComHandler: return(new ComHandlerAction()); case TaskActionType.SendEmail: return(new EmailAction()); case TaskActionType.ShowMessage: return(new ShowMessageAction()); } return(new ExecAction()); }
/// <summary> /// Creates the specified action. /// </summary> /// <param name="actionType">Type of the action to instantiate.</param> /// <returns><see cref="Action"/> of specified type.</returns> public static Action CreateAction(TaskActionType actionType) { switch (actionType) { case TaskActionType.ComHandler: return new ComHandlerAction(); case TaskActionType.SendEmail: return new EmailAction(); case TaskActionType.ShowMessage: return new ShowMessageAction(); case TaskActionType.Execute: default: return new ExecAction(); } }
public Action AddNew(TaskActionType actionType) { if (Count >= MaxActions) { throw new ArgumentOutOfRangeException(nameof(actionType), "A maximum of 32 actions is allowed within a single task."); } if (v1Task != null) { if (!SupportV1Conversion && (v1Actions.Count >= 1 || actionType != TaskActionType.Execute)) { throw new NotV1SupportedException($"Only a single {nameof(ExecAction)} is supported unless the {nameof(PowerShellConversion)} property includes the {nameof(PowerShellActionPlatformOption.Version1)} value."); } return(Action.CreateAction(v1Task)); } return(Action.CreateAction(v2Coll.Create(actionType))); }
private static Type GetObjectType(TaskActionType actionType) { switch (actionType) { case TaskActionType.ComHandler: return(typeof(ComHandlerAction)); case TaskActionType.SendEmail: return(typeof(EmailAction)); case TaskActionType.ShowMessage: return(typeof(ShowMessageAction)); default: return(typeof(ExecAction)); } }
public void Process(TaskActionType processingType, DateTime date) { switch (processingType) { case TaskActionType.Finished: TaskCompleted(date); break; case TaskActionType.Removed: TaskRemoved(date); break; case TaskActionType.Added: TaskAdded(date); break; default: break; } }
public Task(string name, string description, TaskActionType actionType) { this.name = name; this.description = description; this.actionType = actionType; input = new Dictionary <string, object>(); output = new Dictionary <string, object>(); isDone = false; if (actionType == TaskActionType.Sync) { syncActionList = new List <Action>(); } else { asynActionList = new List <IEnumerator <float> >(); } workFlow = null; }
private void buttonCancel_Click(object sender, EventArgs e) { _enuTaskActionType = TaskActionType.Cancel; this.Close(); }
private void buttonContinue_Click(object sender, EventArgs e) { _enuTaskActionType = TaskActionType.Continue; this.Close(); }
private void buttonRetry_Click(object sender, EventArgs e) { _enuTaskActionType = TaskActionType.Retry; this.Close(); }
public void ProcesOutlookTask(TaskActionType taskActionType) { this.Client.ProcessTask(taskActionType, Now); (this.Client as IClientChannel).Close(); }
/// <summary> /// Creates the specified action. /// </summary> /// <param name="actionType">Type of the action to instantiate.</param> /// <returns><see cref="Action"/> of specified type.</returns> public static Action CreateAction(TaskActionType actionType) => Activator.CreateInstance(GetObjectType(actionType)) as Action;
private void StartThread() { DateTime dtJobStartTime = DateTime.Now; TaskResultList objTaskResults = new TaskResultList(); Status = JobStatusType.Running; OnJobBegin(); JobResultType enuJobResult = JobResultType.Completed; int intTaskIndex = 0; int intTaskCount = _objTasks.Count; bool blnHasBeenCancelled = false; while (intTaskIndex < intTaskCount) { ITask objTask = _objTasks[intTaskIndex]; blnHasBeenCancelled = HasBeenCancelled(); if (blnHasBeenCancelled == true) { enuJobResult = JobResultType.Cancelled; break; } DateTime dtTaskStartTime = DateTime.Now; JobTicket objJobTicket = new JobTicket(dtTaskStartTime, HasBeenCancelled, TaskProgressChanged); ITaskResult objTaskResult = null; try { OnTaskBegin(objTask, intTaskIndex, intTaskCount); objTaskResult = objTask.Execute(objJobTicket); } catch (Exception objException) { string strErrorMessage = objException.ToString(); TaskStats objTaskStats = new TaskStats(objTask, dtTaskStartTime, DateTime.Now); objTaskResult = new TaskResult(objTask, objTaskStats, TaskResultType.Failed, strErrorMessage); } if (objTaskResult == null) { string strErrorMessage = "A null value was returned by the task."; TaskStats objTaskStats = new TaskStats(objTask, dtTaskStartTime, DateTime.Now); objTaskResult = new TaskResult(objTask, objTaskStats, TaskResultType.Failed, strErrorMessage); } blnHasBeenCancelled = HasBeenCancelled(); if (blnHasBeenCancelled == true) { objTaskResults.Add(objTaskResult); break; } else { TaskActionType enuTaskActionType = OnTaskEnd(objTaskResult, intTaskIndex); if (enuTaskActionType == TaskActionType.Retry) { continue; } else if (enuTaskActionType == TaskActionType.Continue) { objTaskResults.Add(objTaskResult); intTaskIndex++; if (objTaskResult.Result == TaskResultType.RebootRequired) { enuJobResult = JobResultType.RebootRequired; break; } continue; } else if (enuTaskActionType == TaskActionType.Cancel) { objTaskResults.Add(objTaskResult); enuJobResult = JobResultType.Cancelled; break; } } } if (blnHasBeenCancelled == true) { for (int intRemainingTaskIndex = intTaskIndex + 1; intRemainingTaskIndex < intTaskCount; intRemainingTaskIndex++) { ITask objRemainingTask = _objTasks[intRemainingTaskIndex]; TaskStats objTaskStats = new TaskStats(objRemainingTask, dtJobStartTime, DateTime.Now); ITaskResult objRemainingTaskResult = new TaskResult(objRemainingTask, objTaskStats, TaskResultType.Cancelled); objTaskResults.Add(objRemainingTaskResult); } } Thread.Sleep(200); JobResult objJobResult = new JobResult(this, enuJobResult, dtJobStartTime, DateTime.Now, new TaskResultList(objTaskResults)); OnJobEnd(objJobResult); Thread.Sleep(200); Status = JobStatusType.Completed; }
public void ProcessTask(TaskActionType taskActionType, DateTime occured) { TaskManager taskManager = new TaskManager(); taskManager.Process(taskActionType, occured); }