Пример #1
0
        private void addSQLExportJobMenuItem_M_Click(object sender, EventArgs e)
        {
            try
            {
                using (SQLExportJob_M form = new SQLExportJob_M())
                {
                    form.ShowDialog();

                    if (!form.Cancelled && (form.JobDetail != null) && (form.Trigger != null))
                    {
                        Scheduler.Instance.GetScheduler()
                        .ScheduleJob(form.JobDetail, new HashSet <ITrigger> {
                            form.Trigger
                        }, true);

                        _scheduleChanged = true;
                        RefreshGrid();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Resources.Unexpected_error);
            }
        }
Пример #2
0
        private void EditJob()
        {
            try
            {
                var jobName  = jobsDataGridView.SelectedRows[0].Cells["JobName"].Value.ToString();
                var jobGroup = jobsDataGridView.SelectedRows[0].Cells["JobGroup"].Value.ToString();
                var jobKey   = new JobKey(jobName, jobGroup);

                var scheduler = Scheduler.Instance.GetScheduler();
                if (scheduler == null)
                {
                    MessageBox.Show(Resources.No_active_scheduler, Resources.Missing_scheduler);
                    return;
                }

                var jobDetail  = scheduler.GetJobDetail(jobKey);
                var jobTrigger = scheduler.GetTriggersOfJob(jobKey)[0];

                switch (jobDetail.JobType.FullName)
                {
                case SettingsConstants.DownloadJob:
                    using (DownloadJob downloadForm = new DownloadJob
                    {
                        JobDetail = jobDetail,
                        Trigger = jobTrigger
                    })
                    {
                        downloadForm.ShowDialog();

                        if (!downloadForm.Cancelled && (downloadForm.JobDetail != null) &&
                            (downloadForm.Trigger != null))
                        {
                            scheduler.ScheduleJob(
                                downloadForm.JobDetail, new HashSet <ITrigger> {
                                downloadForm.Trigger
                            }, true);

                            RefreshGrid();
                        }
                    }
                    break;

                case SettingsConstants.ExportJob:
                    using (ExportJob exportForm = new ExportJob
                    {
                        JobDetail = jobDetail,
                        Trigger = jobTrigger
                    })
                    {
                        exportForm.ShowDialog();

                        if (!exportForm.Cancelled && (exportForm.JobDetail != null) &&
                            (exportForm.Trigger != null))
                        {
                            scheduler.ScheduleJob(
                                exportForm.JobDetail, new HashSet <ITrigger> {
                                exportForm.Trigger
                            }, true);

                            RefreshGrid();
                        }
                    }
                    break;

                case SettingsConstants.UploadJob:
                    //find related processing job
                    var      processingJobName    = jobDetail.Key.Name + "-Processing monitor";
                    var      processingJobKey     = new JobKey(processingJobName, jobDetail.Key.Group);
                    var      processingJobDetail  = scheduler.GetJobDetail(processingJobKey);
                    ITrigger processingJobTrigger = null;

                    if (processingJobDetail != null)
                    {
                        processingJobTrigger = scheduler.GetTriggersOfJob(processingJobKey)[0];
                    }

                    using (UploadJob uploadForm = new UploadJob
                    {
                        UploadJobDetail = jobDetail,
                        UploadTrigger = jobTrigger
                    })
                    {
                        if ((processingJobDetail != null) && (processingJobTrigger != null))
                        {
                            uploadForm.ProcessingJobDetail = processingJobDetail;
                            uploadForm.ProcessingTrigger   = processingJobTrigger;
                        }

                        uploadForm.ShowDialog();
                        if (!uploadForm.Cancelled && (uploadForm.UploadJobDetail != null) &&
                            (uploadForm.UploadTrigger != null))
                        {
                            scheduler.ScheduleJob(
                                uploadForm.UploadJobDetail, new HashSet <ITrigger> {
                                uploadForm.UploadTrigger
                            }, true);

                            if ((uploadForm.ProcessingJobDetail != null) && (uploadForm.ProcessingTrigger != null))
                            {
                                scheduler.ScheduleJob(
                                    uploadForm.ProcessingJobDetail, new HashSet <ITrigger> {
                                    uploadForm.ProcessingTrigger
                                }, true);
                            }

                            RefreshGrid();
                        }
                    }
                    break;

                case SettingsConstants.ImportJob:
                    //find related execution job
                    var      executionJobName    = jobDetail.Key.Name + "-Execution monitor";
                    var      executionJobKey     = new JobKey(executionJobName, jobDetail.Key.Group);
                    var      executionJobDetail  = scheduler.GetJobDetail(executionJobKey);
                    ITrigger executionJobTrigger = null;

                    if (executionJobDetail != null)
                    {
                        executionJobTrigger = scheduler.GetTriggersOfJob(executionJobKey)[0];
                    }

                    using (ImportJob importForm = new ImportJob
                    {
                        ImportJobDetail = jobDetail,
                        ImportTrigger = jobTrigger
                    })
                    {
                        if ((executionJobDetail != null) && (executionJobTrigger != null))
                        {
                            importForm.ExecutionJobDetail = executionJobDetail;
                            importForm.ExecutionTrigger   = executionJobTrigger;
                        }

                        importForm.ShowDialog();
                        if (!importForm.Cancelled && (importForm.ImportJobDetail != null) &&
                            (importForm.ImportTrigger != null))
                        {
                            scheduler.ScheduleJob(
                                importForm.ImportJobDetail, new HashSet <ITrigger> {
                                importForm.ImportTrigger
                            }, true);

                            if ((importForm.ExecutionJobDetail != null) && (importForm.ExecutionTrigger != null))
                            {
                                scheduler.ScheduleJob(
                                    importForm.ExecutionJobDetail, new HashSet <ITrigger> {
                                    importForm.ExecutionTrigger
                                }, true);
                            }

                            RefreshGrid();
                        }
                    }
                    break;

                //Start - DManc - 2017/10/13
                case SettingsConstants_M.SQLImportJob_M:
                    //find related execution job
                    var      executionJobName_M    = jobDetail.Key.Name + "-Execution monitor";
                    var      executionJobKey_M     = new JobKey(executionJobName_M, jobDetail.Key.Group);
                    var      executionJobDetail_M  = scheduler.GetJobDetail(executionJobKey_M);
                    ITrigger executionJobTrigger_M = null;

                    if (executionJobDetail_M != null)
                    {
                        executionJobTrigger = scheduler.GetTriggersOfJob(executionJobKey_M)[0];
                    }

                    using (SQLImportJob_M importForm = new SQLImportJob_M
                    {
                        ImportJobDetail = jobDetail,
                        ImportTrigger = jobTrigger
                    })
                    {
                        if ((executionJobDetail_M != null) && (executionJobTrigger_M != null))
                        {
                            importForm.ExecutionJobDetail = executionJobDetail_M;
                            importForm.ExecutionTrigger   = executionJobTrigger_M;
                        }

                        importForm.ShowDialog();
                        if (!importForm.Cancelled && (importForm.ImportJobDetail != null) &&
                            (importForm.ImportTrigger != null))
                        {
                            scheduler.ScheduleJob(
                                importForm.ImportJobDetail, new HashSet <ITrigger> {
                                importForm.ImportTrigger
                            }, true);

                            if ((importForm.ExecutionJobDetail != null) && (importForm.ExecutionTrigger != null))
                            {
                                scheduler.ScheduleJob(
                                    importForm.ExecutionJobDetail, new HashSet <ITrigger> {
                                    importForm.ExecutionTrigger
                                }, true);
                            }

                            RefreshGrid();
                        }
                    }
                    break;

                case SettingsConstants_M.SQLExportJob_M:
                    using (SQLExportJob_M exportForm = new SQLExportJob_M
                    {
                        JobDetail = jobDetail,
                        Trigger = jobTrigger
                    })
                    {
                        exportForm.ShowDialog();

                        if (!exportForm.Cancelled && (exportForm.JobDetail != null) &&
                            (exportForm.Trigger != null))
                        {
                            scheduler.ScheduleJob(
                                exportForm.JobDetail, new HashSet <ITrigger> {
                                exportForm.Trigger
                            }, true);

                            RefreshGrid();
                        }
                    }
                    break;
                //End - DManc - 2017/10/13

                case SettingsConstants.ProcessingJob:
                    MessageBox.Show(Resources.Processing_monitoring_job_is_not_supported);
                    break;

                default:
                    MessageBox.Show(Resources.This_type_of_job_is_not_supported_for_direct_editing);
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Resources.Unexpected_error);
            }
        }