Beispiel #1
0
        private void _refreshJobButton_Click(object sender, EventArgs e)
        {
            foreach (var job in SelectedJobs)
            {
                try
                {
                    var updated = _client.Get <Job>(job.Key);
                    CopyObjectValues(updated, job);
                }
                catch (SDataException ex)
                {
                    MessageBox.Show(string.Format("Error refreshing job '{0}'\r\n{1}", job.Key, ex.Message));

                    if (ex.StatusCode == HttpStatusCode.Gone)
                    {
                        ((ICollection <Job>)_jobsGrid.DataSource).Remove(job);
                    }
                }
            }

            _jobsGrid.Refresh();
            _jobsGrid.AutoResizeColumns();
            _jobParametersGrid.DataSource = _jobsGrid.SelectedRows.Count == 1 ? SelectedJobs.First().Parameters : null;
            _jobParametersGrid.AutoResizeColumns();
            _jobStateGrid.DataSource = _jobsGrid.SelectedRows.Count == 1 ? SelectedJobs.First().State : null;
            _jobStateGrid.AutoResizeColumns();
        }
Beispiel #2
0
        private void _createTriggerButton_Click(object sender, EventArgs e)
        {
            var job     = SelectedJobs.First();
            var trigger = new Trigger
            {
                Job = new SDataResource {
                    Key = job.Key
                },
                Parameters = job.Parameters != null?job.Parameters.Select(param => new TriggerParameter {
                    Name = param.Name, Value = param.DefaultValue
                }).ToList() : null
            };

            using (var form = new EditForm())
            {
                if (form.ShowDialog(trigger, this) != DialogResult.OK)
                {
                    return;
                }
            }

            Trigger created;

            try
            {
                created = _client.Post(trigger);
            }
            catch (SDataException ex)
            {
                MessageBox.Show(string.Format("Error creating trigger '{0}'\r\n{1}", trigger.Key, ex.Message));
                return;
            }

            var list = _triggersGrid.DataSource as ICollection <Trigger>;

            if (list != null && list.Count > 0)
            {
                list.Add(created);
            }
            else
            {
                _triggersGrid.DataSource = new BindingList <Trigger>(new List <Trigger> {
                    created
                });
            }

            _triggersGrid.Refresh();
            _triggersGrid.AutoResizeColumns();
        }
Beispiel #3
0
        private void _jobsGrid_SelectionChanged(object sender, EventArgs e)
        {
            var selected = _jobsGrid.SelectedRows.Count > 0;

            _jobParametersGrid.DataSource = _jobsGrid.SelectedRows.Count == 1 ? SelectedJobs.First().Parameters : null;
            _jobParametersGrid.AutoResizeColumns();
            _jobStateGrid.DataSource = _jobsGrid.SelectedRows.Count == 1 ? SelectedJobs.First().State : null;
            _jobStateGrid.AutoResizeColumns();
            _refreshJobButton.Enabled    = selected;
            _triggerJobButton.Enabled    = selected;
            _interuptJobButton.Enabled   = selected;
            _pauseJobButton.Enabled      = selected;
            _resumeJobButton.Enabled     = selected;
            _createTriggerButton.Enabled = _jobsGrid.SelectedRows.Count == 1;
        }