public void GetScheduleDatabase() { string scheduleName = _frm.txtTaskSchedule.Text.Trim(); PFList <PFSchedule> scheduleList = null; PFSchedule sked = null; PFScheduleManager skedMgr = new PFScheduleManager(enScheduleStorageType.Database, _taskDefsDbConnectionString); try { if (_frm.chkEraseOutputBeforeEachTest.Checked) { Program._messageLog.Clear(); } scheduleList = skedMgr.GetScheduleList(); if (scheduleList.Count == 0) { _msg.Length = 0; _msg.Append("No schedules found in database: "); _msg.Append(_taskDefsDbConnectionString); throw new System.Exception(_msg.ToString()); } NameListPrompt namesPrompt = new NameListPrompt(); namesPrompt.lblSelect.Text = "Select the name from list below:"; for (int i = 0; i < scheduleList.Count; i++) { namesPrompt.lstNames.Items.Add(scheduleList[i].Name); } if (scheduleList.Count > 0) { namesPrompt.lstNames.SelectedIndex = 0; } else { _msg.Length = 0; _msg.Append("No schedules found in database: "); _msg.Append(_taskDefsDbConnectionString); Program._messageLog.WriteLine(_msg.ToString()); } DialogResult res = namesPrompt.ShowDialog(); if (res == DialogResult.OK) { if (namesPrompt.lstNames.SelectedIndex == -1) { _msg.Length = 0; _msg.Append("You did not select any schedule."); throw new System.Exception(_msg.ToString()); } scheduleName = namesPrompt.lstNames.SelectedItem.ToString(); if (scheduleName.Length == 0) { _msg.Length = 0; _msg.Append("You must specify a the name"); throw new System.Exception(_msg.ToString()); } sked = skedMgr.GetScheduleByName(scheduleName); if (sked == null) { _msg.Length = 0; _msg.Append("Unable to find the "); _msg.Append(scheduleName); _msg.Append(" in the database at "); _msg.Append(_taskDefsDbConnectionString); throw new System.Exception(_msg.ToString()); } _frm.txtTaskSchedule.Text = sked.Name; } } catch (System.Exception ex) { _msg.Length = 0; _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex)); Program._messageLog.WriteLine(_msg.ToString()); AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog); } finally { ; } }
public void GetTaskFromDatabase() { string taskName = _frm.txtTaskName.Text.Trim(); PFList <PFTask> taskList = null; PFTask task = null; PFTaskManager taskMgr = new PFTaskManager(enTaskStorageType.Database, _taskDefsDbConnectionString); string inputFileName = string.Empty; try { if (_frm.chkEraseOutputBeforeEachTest.Checked) { Program._messageLog.Clear(); } taskList = taskMgr.GetTaskList(); NameListPrompt namesPrompt = new NameListPrompt(); namesPrompt.lblSelect.Text = "Select the name from list below:"; for (int i = 0; i < taskList.Count; i++) { namesPrompt.lstNames.Items.Add(taskList[i].TaskName); } if (taskList.Count > 0) { namesPrompt.lstNames.SelectedIndex = 0; } DialogResult res = namesPrompt.ShowDialog(); if (res == DialogResult.OK) { if (namesPrompt.lstNames.SelectedIndex == -1) { _msg.Length = 0; _msg.Append("You did not select any task to load"); throw new System.Exception(_msg.ToString()); } _frm.InitForm(); taskName = namesPrompt.lstNames.SelectedItem.ToString(); if (taskName.Length == 0) { _msg.Length = 0; _msg.Append("You must specify a task name"); throw new System.Exception(_msg.ToString()); } task = taskMgr.GetTaskByName(taskName); if (task == null) { _msg.Length = 0; _msg.Append("Unable to find task "); _msg.Append(taskName); _msg.Append(" in the database at "); _msg.Append(_taskDefsDbConnectionString); throw new System.Exception(_msg.ToString()); } _frm.txtTaskName.Text = task.TaskName; _frm.txtTaskDescription.Text = task.TaskDescription; _frm.cboTaskType.Text = task.TaskType.ToString(); _frm.txtMaxHistoryEntries.Text = task.MaxTaskHistoryEntries.ToString(); _frm.txtTaskSchedule.Text = task.ScheduleName; _frm.txtFileToRun.Text = task.FileToRun; _frm.txtWorkingDirectory.Text = task.WorkingDirectory; if (task.Arguments != null) { foreach (string s in task.Arguments) { if (s.Trim().Length > 0) { _frm.txtArguments.Text += s + Environment.NewLine; } } } _frm.cboWindowStyle.Text = task.WindowStyle.ToString(); _frm.chkCreateNoWindow.Checked = task.CreateNoWindow; _frm.chkUseShellExecute.Checked = task.UseShellExecute; _frm.chkRedirectStandardOutput.Checked = task.RedirectStandardOutput; _frm.chkRedirectStandardError.Checked = task.RedirectStandardError; } } catch (System.Exception ex) { _msg.Length = 0; _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex)); Program._messageLog.WriteLine(_msg.ToString()); AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog); } finally { ; } }