Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


JWood
  •  JWood
  • No customer Topic Starter
2015-08-12T18:14:59Z
I have a situation where I need to iterate over a Job's tasks and then email said results.

Problem is that I do not know what Job it will be, nor do any of my Job's have the same number of Tasks underneath them.

Question:
* Is there a way to iterate of Job's Tasks to them be emailed as Text?

Ideally the Email Body would be something like:
Server: {COMPUTER(Name)}

<!-- Start Job Task Loop -->
{Task(....., Name)}
Output:
{Task(....., StdOut)}
Error:
{Task(....., StdErr)}
<!-- End job Task Loop; Rinse-Repeat -->

{Job(Active,Description)}
Sponsor
Forum information
thomas
2015-08-13T08:17:14Z
Have you looked at the Job Report task (under Internal)?
JWood
  •  JWood
  • No customer Topic Starter
2015-08-13T12:09:01Z
Yes but it looks to not loop through a Job's Task association but instead the execution of a (local or remote) Job, or Task, as a step within a Job.

I am looking for something that will allow me identify a Job, most likely via {Job(...)} Token, and then from that iterate through each of its child Tasks to produce a report of the values.

The reason for this request? I have several email tasks, at the end of its execution flow, that reports back (success or error) the values of each of the tasks, explicitly defined. My goal is to simply identify the job and pseudo-scripted behavior will iterate through all the Tasks and apply a standard evaluation template against each of those Tasks identified.

I have not looked at the API available through the local Web Site, as i do not have time currently to review/read through all of it. It would be nice if there were some "variable" implementation that allowed for this looping logic.
thomas
2015-08-13T14:29:24Z
I'm not sure this can be done. If you want to try using the api, you can use this code as a starting point. I haven't used the api much, so I can't claim this is best practice, but you can play around with it if you fell like it. It worked when I tried it. The output from the method can be used in an email body

TaskStatistics.PNG
JWood
  •  JWood
  • No customer Topic Starter
2015-08-13T14:53:05Z
Yeah, I am trying to stay out the API.

Right now the Task to do emails is working, albeit i explicitly define each task in the body. I am looking to develop a more generic Email Task that will accommodate any Job, no matter how many Tasks it has.

I will have a look see and do what I can.
JWood
  •  JWood
  • No customer Topic Starter
2015-08-13T19:16:57Z
@Thomas:
Thanx for the feeder on using ".Net code Execute" Task.

As the documentation is basically nothing for this type of Task, How do i pass in a Job Name/ID being passed to the Task?

What I have so far:
using System;

public class JobEmail
{
	public static string ReportTasks(string jobid){
		return jobid;
	}
	
}


All i want to be able to do is pass the Job ID/Name into the method. As i can validate steps of ability, i will be making it more complex.
ErikC
2015-08-14T09:38:39Z
Hi,

Just to let you know, you can't use the .NET API task to connect to it's own server. You have to use an external application doing this. You can't create a client application within the client. So you have to use e.g. Visual Studio and make an external client application.

You could also use the Web.API (now in 7.7.4) to get a complete list of all your jobs and tasks as an xml file (http://localhost:8001/VisualCron/xml/Job/List). You can add a line on top to use a layout file (<?xml-stylesheet href="layout.xsl" type="text/xsl"?>) and than you van itterate though all your jobs (using the layout.xsl), looking at the result (Stats/R) of the job. If the match "Stats/R!='Success'" you can itterate through it tasks and create a nice table view of the taske beloging to the failed job.

It could be a hassle to figure it all out if you're new to xsl, using an external .NET application could be easier.
Look in the %installationdir%/API for the samples.

Regards,
Erik
Uses Visualcron since 2006.
JWood
  •  JWood
  • No customer Topic Starter
2015-08-14T12:19:59Z
I should be able to use a ".Net code execute" Task, correct?

I am looking to make a Task to be the Error Email for all jobs. Basically, on error goto Email Task. That Email task will receive a JobID/Name, from that iterate across all of its child tasks and construct an email body that will be sent out to the appropriate support staff (ie myself).

I have the email body "template" built, just would like a way to iterate over a Job's Tasks (some have 3, most have 5-7, and some have 10+).

thomas
2015-08-14T12:33:07Z
I vote for the external application 🙂 You will end up with several methods after a while, so it's better to keep them in an assembly. You will then be able to unit test your code and so on. Here are the steps (roughly) you have to follow (sorry if this is stuff you already know):

1) Get Visual Studio if you don't have it already. https://www.visualstudio...ad-visual-studio-vs.aspx . The community version is free, but strictly speaking it cannot be used in enterprises. Use it for practicing...

2) Create a new class library. File -> New project, Class library. Remember to choose your prefered language (vb or c#).

3) Put the code that you wrote in you example above, in a class file. You will by default see a file there called Class1.cs. Rename it first and add you code.

4) Choose Build in the menu, Build solution

5) Take the resulting .dll file and place it on the server. It will have the name YourProjectName.dll

6)Create an assembly execute task. Find your assembly, select your class, and then your method. (make sure it is a static method)

7)You will see the parameters at the bottom. You can feed the job name dynamically in there.

When you later make it more advanced, and code against the VC api, you have to include those assemblies, and copy those to the server also, but we can get to that later.

Thomas
ErikC
2015-08-14T12:48:24Z
Originally Posted by: JWood 

I should be able to use a ".Net code execute" Task, correct?


No you can not. You can do a lot with the .net execute task, but not connect to visualcron itself. It has to be done with an external application.
You could create a dll as Thomas mentioned, or a commandline executable.

Creating a dll, the returning method value will be shown in the output column of visualcron.
Creating a commandline executable, everything what is written to the console is shown in the output column of visualcron.

Regards,
Erik


Uses Visualcron since 2006.
JWood
  •  JWood
  • No customer Topic Starter
2015-08-14T17:01:20Z
So in short, there is no "real" workaround for acquiring a job's tasks.

Everything you have stated and provided an example for, pretty much "lives" outside of the VC Bubble.

To make things even more fun and interesting, i am working with version 7.6.6, until i can consolidate all the jobs from 5 servers into one server.

Maybe they will provide a way "internally" to iterate over a known Job's Tasks without skirting around the "bubble".
ErikC
2015-08-17T05:54:10Z
Originally Posted by: JWood 

Everything you have stated and provided an example for, pretty much "lives" outside of the VC Bubble.

From 7.7.0 there is a WEB.API. You can use an URL wich will give you alle the details of the jobs/tasks. You might check this out. Wit the use of this output and a .NET task using this as input, you can do a lot.

Regards,
Erik


Uses Visualcron since 2006.
JWood
  •  JWood
  • No customer Topic Starter
2015-08-17T12:15:17Z
Right now i am stuck with 7.6.6

Don't have much time to fully implement it, right now. Consolidating 5+ VC servers into 1 server.

As well, you pretty much need the same version client to connect to that version client. It would be awesome if we could have 1 client "to rule them all", instead of multiple clients on a desktop to connect to various versions.

Either way, this adventure got back-burner'ed for a couple more weeks till i can find some good time to invest in development.
John Vaden
2023-08-16T19:03:46Z
Originally Posted by: ErikC 

Originally Posted by: JWood 

I should be able to use a ".Net code execute" Task, correct?


No you can not. You can do a lot with the .net execute task, but not connect to visualcron itself. It has to be done with an external application.
You could create a dll as Thomas mentioned, or a commandline executable.

Creating a dll, the returning method value will be shown in the output column of visualcron.
Creating a commandline executable, everything what is written to the console is shown in the output column of visualcron.

Regards,
Erik



I'm just wondering, with 8 years of progress and upgrades in VisualCron, if anything has changed with the ability to connect to VisualCron, itself, from a .NET execute task, or if this is still not possible?
Scroll to Top