Beispiel #1
0
        private void AddJob(JobGroupNode selectedNode, Action updateAction)
        {
            var frm = new AddJob(mRoot);

            if (frm.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            // add macro
            var selSpecPath = frm.SelectedSpecificationPath;
            var jobData     = new JobDataMap
            {
                { Host.MacroFilePathKey, selSpecPath }
            };
            var jobName = Path.GetFileNameWithoutExtension(selSpecPath);
            var job     = JobBuilder.Create <Host>().
                          WithDescription("TODO extract description from spec"). // TODO extract description from spec
                          WithIdentity(jobName, selectedNode.Name).
                          SetJobData(jobData).
                          StoreDurably().
                          Build();

            mScheduler.AddJob(job, true);
            updateAction();
        }
Beispiel #2
0
        private void LoadScheduledJobs()
        {
            var expNodePaths = SchedulerView.Nodes.GetExpansionState();
            var selNodePath  = SchedulerView.SelectedNode != null?SchedulerView.SelectedNode.GetNamesFullPath() : null;

            try
            {
                var schedulerNode = new SchedulerNode(mScheduler);
                if (SchedulerView.Nodes.ContainsKey(schedulerNode.Name))
                {
                    SchedulerView.Nodes.RemoveByKey(schedulerNode.Name);
                }
                SchedulerView.Nodes.Add(schedulerNode);
                var jobGroupsIdx  = schedulerNode.Nodes.Add(new JobGroupsNode("Job Groups"));
                var jobGroupsNode = schedulerNode.Nodes[jobGroupsIdx];
                var jobGroups     = mScheduler.GetJobGroupNames();
                foreach (var jobGroup in jobGroups)
                {
                    var jobGroupNode = new JobGroupNode(jobGroup);
                    jobGroupsNode.Nodes.Add(jobGroupNode);
                    LoadJobNodes(jobGroupNode);
                }

                LoadOrphanJobs(schedulerNode);
                LoadCalendars(schedulerNode);
            }
            finally
            {
                SchedulerView.Nodes.SetExpansionState(expNodePaths);
                SchedulerView.SelectedNode = SchedulerView.Nodes.FindByNamesFullPath(selNodePath);
                SchedulerView_AfterSelect(this, new TreeViewEventArgs(SchedulerView.SelectedNode));
            }
        }
Beispiel #3
0
        private void LoadJobNodes(JobGroupNode node)
        {
            var group        = node.Name;
            var groupMatcher = GroupMatcher <JobKey> .GroupContains(group);

            var jobKeys = mScheduler.GetJobKeys(groupMatcher);

            foreach (var jobKey in jobKeys)
            {
                try
                {
                    var detail  = mScheduler.GetJobDetail(jobKey);
                    var jobNode = new JobNode(detail);
                    node.Nodes.Add(jobNode);
                    LoadTriggerNodes(jobNode);
                }
                catch (Exception ex)
                {
                    node.Nodes.Add(string.Format("Unknown Job Type ({0})", jobKey.Name));
                    //TODO: Do something useful with this exception. Most likely cause is the client does not have a copy of a given dll and can't load the type.
                    Log.Error("Error loading jobs.", ex);
                }
            }
        }