JAMS is very expandable and can be customized and integrated into many applications. This is also true when connecting to JAMS over the web. This guide will demonstrate how to connect to a JAMS server and submit Jobs via a web page.
Create a new ASP.NET Web Application name it JAMSWebParameters.
After creating a new project, open the web designer for Default.aspx and add 2 text boxes to the page and a button. These will be used to accept input from the user for Job Parameters, and start the new Job instance.
- Double click the button to move to the code behind of the web page and add a new button click event.
- Add a reference to JAMSShr.dll.
- Right click on the References folder in the Solution Explorer window, choose Add Reference, and then select the browse tab.
- The dll can be found at Program Files\MVPSI\JAMS\Client\JAMSShr.dll
- The code to submit a job and set parameter values can be found below:
protected void Button1_Click(object sender, EventArgs e) { // Accesses the JAMS server running on the local machine MVPSI.JAMS.Server server = MVPSI.JAMS.Server.GetServer("localhost"); // Load the job we will be submitting Submit.Info si; Submit.Load(out si, "ReportProjectedScheduleV2", server, Submit.Type.Job); // // Set the parameters which the job needs. // Some of these will be obtained from the textboxes on the webpage // si.Parameters["Server"].ParamValue = server.Name; si.Parameters["StartDate"].ParamValue = DateTime.Today; si.Parameters["EndDate"].ParamValue = DateTime.Today.AddDays(1); si.Reports["ProjectedSchedule"].PrintQueue = TextBox1.Text; si.Reports["ProjectedSchedule"].PrintForm = TextBox2.Text; // Submit the job si.Submit(); }
- Build and run the application.
- When the web page is displayed, enter the required information in the textboxes and click the submit button.
- This will submit a new Job instance in the Scheduler on the local machine.
This simple concept can be taken much further to fully leverage the programmability of the JAMS system. All of the functionality of the client GUI is available to the developer. Using the API, a developer can display information about any JAMS object, such as Jobs, Setups, Systems, Variables, and Triggers. It is also possible to edit the definitions of any of these objects, if necessary.
Below are a couple of code snippets which demonstrate how to retrieve a listing of Jobs from a JAMS server, and how to change values in a Job definition.
protected void Page_Load(object sender, EventArgs e) { Server server = new MVPSI.JAMS.Server("localhost"); // The find method requires query information to find the jobs you are looking for List<Job> joblist = Job.Find("*","*", server).ToList(); // The list can now be bound to a web control datasource DataList1.DataSource = joblist; DataList1.DataBind(); }
Change the definition of a Job:
protected void Page_Load(object sender, EventArgs e) { Server server = new MVPSI.JAMS.Server("localhost"); // The find method requires query information to find the jobs you are looking for List<Job> joblist = Job.Find("*","*", server).ToList(); // The list can now be bound to a web control datasource DataList1.DataSource = joblist; DataList1.DataBind(); } protected void Button1_Click1(object sender, EventArgs e) { // Connect to a server Server server = new MVPSI.JAMS.Server("localhost"); // Get the job named DefragDisk Job job = new Job(); Job.Load(out job, 9, server); // Start an Edit and set the new name job.BeginEdit(); job.JobName = TextBox1.Text; // Submit the update to the server job.Update(server); }
The sample application described in this article can be downloaded here:
Comments