Esempio n. 1
0
        public static void GetTaskListDatabase(MainForm frm)
        {
            PFList <PFTask> taskList         = null;
            PFTaskManager   tm               = null;
            string          connectionString = string.Empty;

            try
            {
                _msg.Length = 0;
                _msg.Append("GetTaskListDatabase started ...\r\n");
                Program._messageLog.WriteLine(_msg.ToString());

                InitFolderPaths();

                connectionString = _taskDefsDbConnectionString;

                tm = new PFTaskManager(enTaskStorageType.Database, connectionString);

                taskList = tm.GetTaskList();

                if (taskList == null)
                {
                    _msg.Length = 0;
                    _msg.Append("No tasks found in ");
                    _msg.Append(connectionString);
                    throw new System.Exception(_msg.ToString());
                }

                _msg.Length = 0;
                _msg.Append("Number of sked definitions found: ");
                _msg.Append(taskList.Count.ToString("#,##0"));
                _msg.Append("\r\n");
                _msg.Append("Database: ");
                _msg.Append(connectionString);
                _msg.Append("\r\n");
                Program._messageLog.WriteLine(_msg.ToString());

                for (int i = 0; i < taskList.Count; i++)
                {
                    _msg.Length = 0;
                    _msg.Append(taskList[i].TaskName);
                    Program._messageLog.WriteLine(_msg.ToString());
                }
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                Program._messageLog.WriteLine(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }
            finally
            {
                _msg.Length = 0;
                _msg.Append("\r\n... GetTaskListDatabase finished.");
                Program._messageLog.WriteLine(_msg.ToString());
            }
        }
Esempio n. 2
0
        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
            {
                ;
            }
        }