You must be logged in to reply to this topic.
Prior to adTempus, our company had some automation scripts which programmatically calcluated the number of times a job had executed within the past month, and generated a usage charge based on that number.
In adTempus, it seems there are quite a number of new data points we can use to generate charge info. However to start off with, I'd like to copy that model. Does anyone have a sampleĀ .NET code snippet which will loop through each job, and calculate the number of times it has executed in the past month?
Depending on what you are doing, there may be better ways to get this data than through the API.
First, there's a Job Accounting report built in to the Console, which gives you instance counts and processing times.
If you need to integrate this into your own system, it's probably going to be more efficient to query the adTempus database directly rather than going through the API. This query will get you the total instances for each job in a given date range:
This just gives you the total instances, but you could also easily sum up the execution times if you want that information.
You can accomplish what you want using the API, but the API isn't set up for aggregating data, so it takes some work and involves retrieving a lot of data. The following VB code shows how you could do this. It retrieves all jobs, then iterates through them.
For each job it fetches the history for the date range you're interested in. Here's where things get inefficient. If you only care about the total number of instances, you can get a record count without retrieving them all (Option A in the code). However, if you want to get anything else (like, say, summing up the total execution time), you would have to retrieve each instance and look at it, which can be slow if there's a lot of history to look at. To use this approach, comment out Option A and uncomment Option B below.
The code assumes you already have a connection. See this example if you need the code for that.
It didn't occur to me to query the database directly, but that makes perfect sense. Thanks for the sample code.
Generally, you want to create an ADO or OLEDB connection. See this article for information on the database connection string that adTempus uses. Your script will use the same or a similar one.
I hesitated responding to this because I am using Perl, and I was a bit afraid of the reaction I would get. However, I was able to successfully make a connection to the database two different ways with Perl and successfully execute the query you provided. I will submit a post in the General section to explain how I made the connection - hopefully will help others.
Now I need to read up on the database schema :)
Thanks very much for your help.