MVP Systems Software  
email us now

Accessing JAMS from the Web

Expand / Collapse
 

Accessing JAMS from the Web


JAMS is very extensible and can be customized and integrated into your own applications.  This is also true of connecting to JAMS over the web.  This guide will demonstrate how to connect to a JAMS server and submit jobs via a web page.

 

For this example, we will be creating a new ASP.NET Web Application.  Name it JAMSWebParameters.


 

After creating a new project, open the web designer for Default.aspx.  Add a couple of 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 codebehind of the web page and add a new button click event.  We will need to write some code which interacts with the JAMS system.  Before we do so, we need to 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

 

Now that we have a reference added to the JAMS dll, we can start writing code which accesses the JAMS scheduler.  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, "ReportProjectedSchedule", 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, you can 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 programability 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.

Retrieve a list of Jobs


        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
            JobList joblist = JobList.Find("*","*", server);
            //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
            JobList joblist = JobList.Find("*","*", server);
            //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 from the attachments section of the page.



Rate this Article:
Tags:

Attachments


JAMSWebParameters.zip JAMSWebParameters.zip (33.79 KB, 326 views)

Add Your Comments


Name: *
Email Address:
Web Address:
   
  
 
 
   
Verification Code:
*
 

Details
Last Modified:Thursday, January 29, 2009

Last Modified By: ZachB

Type: HOWTO

Rated 5 stars based on 1 vote

Article has been viewed 2,290 times.

Options