Starting a Job from a Group

GuyS (45 posts)
February 16, 2018 06:22 AM
Accepted Answer

Hi Bill,

Can you give me a hint on how to start a job in a specified Group? The jobname itself is not unique and exists in multiple Groups. Something like:

Group: Level-1

SubGroup:  Level-2_A

Job:               Job-1

Subgroup: Level-2_B

Job:               Job-1

 

The code I'm using is like below.

When I change 'Job' to 'job = appl + "/" + region + "/" + job;', or use '\\' instead, it is not found??

Thanks Bill.

public void StartAdtempusJob(ref ListView lvMsg, ref int msgCnt, string job, bool waitResult)
{
    using (DataContext context = aScheduler.NewDataContext())
    {
        try
        {
            var aJob = context.GetJob(job);
 
            if (aJob == null)
            {
                msgCnt += 1;
                var item4 = new ListViewItem(new[] { "(W) Job '" + job + "' not found",
                    msgCnt.ToString().PadLeft(4,'0') });
                lvMsg.Items.Add(item4);
                return;
            }
 
            var settings = new JobExecutionSettings();
            settings.Options = JobExecutionOptions.ForceNewInstance;
 
            //MessageBox.Show(aJob.JobVariables.GetVariable("Jr").ToString());
 
            var result = aJob.Execute(settings);
 
            if (!result.JobSubmitted)
            { ...
GuyS (45 posts)
February 16, 2018 07:46 AM
Accepted Answer
Bill Staff (599 posts)
February 16, 2018 07:55 AM
Accepted Answer

Your second post is empty, so I don't know where you are with this, but GetJob("level-1\\level-2_a\\job-1") is the correct way to do it (documentation here). If that's not finding it then there's something wrong with the name you've constructed.


Replies are disabled for this topic.