JAMS Developer Guide
Viewing a List of Jobs by Folder

You can view a list of all Jobs within a folder by using C#. This sample shows you how to list all Jobs within the Samples folder in JAMS that have run within the past 7 days. 

Viewing a List of Jobs by Folder
Copy Code
/  
// Get a connection to our JAMS Server 
// You will probably have to change the node name "localhost" 
// to the name of your JAMS Server 
//  
var server = Server.GetServer("localhost"); 
// 
// Get a collection of Jobs in the Samples folder 
// 
var sampleJobs = Job.Find(@"\Samples\*", server); 
// 
// Log History information about the Jobs 
// 
foreach (var job in sampleJobs) 
{ 
     // 
     // Get the Job's most recent run over the last 7 days 
     // 
     var jobHistory = History.Find(job.JobID, DateTime.Now.AddDays(-7), HistorySearchOptions.None, server); 
     var lastRun = jobHistory.OrderByDescending(history => history.CompletionTime).FirstOrDefault(); 
     Console.WriteLine($"Job Name: {job.QualifiedName}"); 
 
     if (lastRun == null) 
     { 
         Console.WriteLine($"The Job has not run within the specified time range.\n");  
     } 
 
     else 
     { 
         Console.WriteLine($"Last Run Time: {lastRun.StartTime}"); 
         Console.WriteLine($"Final Status Code: {lastRun.FinalStatusCode}"); 
         Console.WriteLine($"Elapsed Time: {lastRun.ElapsedTime}\n"); 
      } 
} 

 

 

 


Copyright © Fortra, LLC and its group of companies.
All trademarks and registered trademarks are the property of their respective owners.