public PageTask Add( bool async, bool continueOnErrMsg, String desc, MySQLTaskStatusLabel label, Label stageLabel, Label resultLabel, Panel panel, TextBox logTextBox, PageTask.PrepareToExecDelegate prepareToExec, PageTask.RunTaskDelegate execTask, PageTask.ProcessTaskFailDelegate processTaskFail, PageTask.ProcessTaskFinishDelegate processTaskFinish, ProgressBar progressBar, Label progressDetailsLabel ) { PageTask task = new PageTask(); task.pageTasks = this; task.async = async; task.continueOnErrMsg = continueOnErrMsg; task.desc = desc; task.label = label; task.stageLabel = stageLabel; task.resultLabel = resultLabel; task.panel = panel; task.logTextBox = logTextBox; task.prepareToExec = prepareToExec; task.execTask = execTask; task.processTaskFail = processTaskFail; task.processTaskFinish = processTaskFinish; task.progressBar = progressBar; task.progressDetailsLabel = progressDetailsLabel; task.Init(); pageTasks.Add(task); return(task); }
public String Exec() //! todo: replace String with void { String errMsg = ""; try { if (-1 == initialCount) { initialCount = pageTasks.Count; } while (0 < pageTasks.Count) { PageTask task = pageTasks[0]; if (task.runningAsync) { task.runningAsync = false; if (task.failedAsync) { throw new Exception(); } else { task.MarkSucceded(pageTasks.Count, initialCount); task.ProcessTaskMsg((int)Msg_type.MT_info, ""); // delimit task log messages with empty line pageTasks.Remove(task); continue; } } task.PrepareToExec(pageTasks.Count, initialCount); if (task.async) { wizard.SkipRestoreControlsStateOnce(); needRestoreControlsState = true; } task.execTask(); if (!task.async) { task.MarkSucceded(pageTasks.Count, initialCount); task.ProcessTaskMsg((int)Msg_type.MT_info, ""); // delimit task log messages with empty line pageTasks.Remove(task); } else { task.runningAsync = true; return(errMsg); } } } catch (Exception e) { pageTasks[0].ProcessTaskMsg((int)Msg_type.MT_info, "FAILED" + ((0 < e.Message.Length) ? ": " + e.Message : "")); foreach (PageTask task in pageTasks) { task.MarkFailed(pageTasks.Count, initialCount); } pageTasks.Clear(); failed = true; ErrMsgExists = true; errMsg = "-"; } if (needRestoreControlsState) { wizard.RestoreControlsState(errMsg); } if (0 == pageTasks.Count) { SetResultState(); if (null != afterExecTask) { afterExecTask(); } } return(errMsg); }
public PageTask Add( bool async, bool continueOnErrMsg, String desc, MySQLTaskStatusLabel label, Label stageLabel, Label resultLabel, Panel panel, TextBox logTextBox, PageTask.PrepareToExecDelegate prepareToExec, PageTask.RunTaskDelegate execTask, PageTask.ProcessTaskFailDelegate processTaskFail, PageTask.ProcessTaskFinishDelegate processTaskFinish, ProgressBar progressBar, Label progressDetailsLabel ) { PageTask task = new PageTask(); task.pageTasks = this; task.async = async; task.continueOnErrMsg = continueOnErrMsg; task.desc = desc; task.label = label; task.stageLabel = stageLabel; task.resultLabel = resultLabel; task.panel = panel; task.logTextBox = logTextBox; task.prepareToExec = prepareToExec; task.execTask = execTask; task.processTaskFail = processTaskFail; task.processTaskFinish = processTaskFinish; task.progressBar = progressBar; task.progressDetailsLabel = progressDetailsLabel; task.Init(); pageTasks.Add(task); return task; }