Exemplo n.º 1
0
        public static void GetScheduleListDatabase(MainForm frm)
        {
            PFList <PFSchedule> scheduleList = null;
            PFScheduleManager   sm           = null;
            string connectionString          = string.Empty;

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

                InitFolderPaths();

                connectionString = _taskDefsDbConnectionString;

                sm = new PFScheduleManager(enScheduleStorageType.Database, connectionString);

                scheduleList = sm.GetScheduleList();

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

                _msg.Length = 0;
                _msg.Append("Number of schedule definitions found: ");
                _msg.Append(scheduleList.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 < scheduleList.Count; i++)
                {
                    _msg.Length = 0;
                    _msg.Append(scheduleList[i].Name);
                    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... GetScheduleListDatabase finished.");
                Program._messageLog.WriteLine(_msg.ToString());
            }
        }
Exemplo n.º 2
0
        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
            {
                ;
            }
        }
Exemplo n.º 3
0
        private void LoadScheduleFromDatabase()
        {
            string connectionString      = _taskDefsDbConnectionString;
            string scheduleName          = this.txtScheduleName.Text.Trim();
            PFList <PFSchedule> skedList = null;
            PFSchedule          sked     = null;
            PFScheduleManager   skedMgr  = new PFScheduleManager(enScheduleStorageType.Database, connectionString);
            string inputFileName         = string.Empty;

            if (this.chkEraseOutputBeforeEachTest.Checked)
            {
                Program._messageLog.Clear();
            }

            try
            {
                skedList = skedMgr.GetScheduleList();
                NameListPrompt namesPrompt = new NameListPrompt();
                namesPrompt.lblSelect.Text = "Select the name from list below:";
                for (int i = 0; i < skedList.Count; i++)
                {
                    namesPrompt.lstNames.Items.Add(skedList[i].Name);
                }
                if (skedList.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 schedule to load");
                        throw new System.Exception(_msg.ToString());
                    }
                    this.InitializeForm();
                    scheduleName = namesPrompt.lstNames.SelectedItem.ToString();
                    if (scheduleName.Length == 0)
                    {
                        _msg.Length = 0;
                        _msg.Append("You must specify a sked name");
                        throw new System.Exception(_msg.ToString());
                    }

                    sked = skedMgr.GetScheduleByName(scheduleName);

                    if (sked == null)
                    {
                        _msg.Length = 0;
                        _msg.Append("Unable to find schedule ");
                        _msg.Append(scheduleName);
                        _msg.Append(" in the database at ");
                        _msg.Append(_taskDefsDbConnectionString);
                        throw new System.Exception(_msg.ToString());
                    }

                    Tests.CreateScreenInputFromSchedule(this, sked);
                    ProcessScheduleFrequencyChange();
                }
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                Program._messageLog.WriteLine(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }
            finally
            {
                ;
            }
        }