JAMS 6.x Help
Creating a Setup and Assigning it to Jobs

Creating a Setup and Assigning Jobs to the Setup

A Setup is assigned Jobs and the Setup's properties determine how and when these Jobs are run. A Setup allows you to easily run Jobs in parallel as well as in a specific order. Setups allow for large numbers of Jobs to be quickly and consistently submitted by simply submitting a Setup.

Before you create a Setup you will need to be connected to a JAMS server.

Connecting to your JAMS Server
Copy Code
//
// If this is run on your JAMS Server, "localhost" will work
// If you want to run this on a different machine, you have to change "localhost"
// to the name of your JAMS Server
//
Server jamSver = Server.GetServer("localhost");

A Job must exist before it can be added to a Setup. The Job created below will be used throughout this example. It is also possible to add existing Jobs to a Setup. As shown below, a Job added to a Setup can have Parameters. To see more details on how to create a Job with Parameters see the topic: Creating a Job With Parameters documentation.

Creating a Job
Copy Code
//
// Create the Job and set the desired properties
// At a minimum you must define a unique "JobName"
//
Job job1 = new Job()
{
JobName = "job_1",
Description = "This is a new Job that will have some Parameters",
ParentFolderName = @"\Setup Sample\",
ScheduledDate = "monday",
ScheduledTime = TimeOfDay.Parse("11:30 am")
};

//
// Next create your Parameters and set the desired properties
// You must at least define a unique "ParamName"
//
Param nameParamater = new Param()
{
ParamName = "Name_Input",
Prompt = "enter a name",
HelpText = "only enter the first name",
Required = true
};

Param addressParamater = new Param()
{
ParamName = "Address_Input",
Length = 30,
Prompt = "enter an address"
};

//
// Assign the Parameters to the Job
//
job1.Parameters.Add(nameParamater);
job1.Parameters.Add(addressParamater);

//
// Save the Job to the Database
//
job1.Update(jamSver);

In order to add the Job we just created to a Setup we need to first create a Setup Job. The "JobName" property of a Setup Job should be set to the path of the Job you want to add to a Setup. By setting the "ScheduleFromTime" and the "ScheduleToTime" you can define a window of time in which the Job will be allowed to run (specifying these values is not required). For a complete list of the properties you can set see the SetupJob Class Properties documentation. Within a Setup, Jobs with smaller step values will be run first, going from least to greatest step values. Jobs that have the same step values will be run in parallel.

Note: A Setup Job inherits Parameters and other property values, such as "Description" from the Job it references via the "JobName" property.
Creating a Setup Job
Copy Code
SetupJob exampleSetupJob_1 = new SetupJob()
{
JobName = @"\Setup Sample\" + @"job_1",
ScheduleFromTime = TimeOfDay.Parse("9:00 am"),
ScheduleToTime = TimeOfDay.Parse("4:10 pm"),
Step = 10
};

Next create the Setup and define the desired properties. You will need to at least define a unique "SetupName". The Setup's properties will determine when the associated Setup Jobs will run (except in a Setup Job where a specific schedule window has been defined). For a complete list of properties see the Setup Class Properties documentation. 

Creating a Setup
Copy Code
Setup exampleSetup = new Setup()
{
SetupName = "example Setup",
ParentFolderName = @"\Setup Sample\",
ScheduledDate = "Weekdays",
ScheduledTime = TimeOfDay.Parse("3:30 pm"),
AutoSubmit = true
};

Now that the Setup has been created we can assign it Jobs via Setup Jobs like the one we created above. As shown below you can, and usually will, assign multiple Jobs to the same setup. After adding the Jobs to the Setup call the update method to save the changes. After doing this the Job(s) and Setup should be visible in the JAMS Client in the folder you specified  ("ParentFolderName"), or the root folder if you did not specify a location.

Once a Job has been assigned to a Setup you cannot delete the Job unless you delete its corresponding Setup Job, or delete the Setup
Adding Setup Jobs to a Setup
Copy Code
exampleSetup.Jobs.Add(exampleSetupJob_1);
exampleSetup.Jobs.Add(exampleSetupJob_2);
exampleSetup.Jobs.Add(exampleSetupJob_3);

//
// Save the Setup to Database
//
exampleSetup.Update(jamSver);
See Also

 

 


Topic updated: 3/24/2017
©2017 MVP Systems Software, Inc. All Rights Reserved.

Send comments on this topic.