Hi Bill,
Is there a method that would give me the job name if I provide it with the Job ID? I did look through the documentation but could not find any. Kindly let me know if I am missing something.
Hi Bill,
Is there a method that would give me the job name if I provide it with the Job ID? I did look through the documentation but could not find any. Kindly let me know if I am missing something.
The Job ID (displayed in the job properties in the Console) is the OID in the API. You would convert the value to a GUID, then use DataContext.GetObject to get the job for the OID (I don't think DataContext.GetJob works if you give it an OID instead of a name).
Cast the result to type Job, then use Name or FullyQualifiedName to get the name.
Thanks Bill,
I did try that, Below is the code, but it gives an error as Cannot implicitly convert type '... .ADTOblect' to ' ... .Job'.
Can you let me know how do I cast it?
using (DataContext context = connection.NewDataContext()) { OID o = new OID("c8092893-0136-4271-b88d-4356de7c51a8"); Job obj = context.GetObject(o); // error on this line//Rest of the codeYou need an explicit cast:
Job obj = (Job)context.GetObject(o);
or
Job obj = context.GetObject(o) as Job;
Yeah, I did cast it, but it still gives me a null response.
OID o = new OID("c8092893-0136-4271-b88d-4356de7c51a8"); -> Is this the right way to declare the JOB Id i.e. OID in the API ?
string connectionDesciptor = Scheduler.BuildConnectionDescriptor(ConfigurationManager.AppSettings["AdTempusServer"],Int32.Parse(ConfigurationManager.AppSettings["AdTempusPort"]),"" );using (Scheduler connection = Scheduler.Connect()) { using (DataContext context = connection.NewDataContext()) { OID o = new OID("118827ab-a00d-40c9-8c36-b8fb6f93014d"); Job obj = (Job)context.GetObject(o); Job job = context.GetJob(obj.Name); }Doing something like this.
JOB ID is : {118827ab-a00d-40c9-8c36-b8fb6f93014d} when I view in the Console. Kindly let me know where I am going wrong.
Sorry! I didn't answer correctly, and I didn't pay attention to that part of your code. The Job ID doesn't translate straight to the OID: An OID is the object ID (GUID) plus a class ID, and you're missing the class ID. I'm surprised something didn't throw an exception since the string value you're passing it isn't a valid OID.
You need:
OID o=new OID(ClassID.Job, New Guid("118827ab-a00d-40c9-8c36-b8fb6f93014d"));
Also Bill,
Is there a way to retrieve the Job ID from the fully qualified job name?
Replies are disabled for this topic.