Login Cart  Cart
logo

Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

mikeb Offline
#1 Posted : Tuesday, August 23, 2011 11:42:52 PM(UTC)
mikeb
Rank: Newbie

Reputation:

Joined: 8/23/2011(UTC)
Posts: 5
Location: Phoenix

Thanks: 4 times
Hello all.

I have a Visual Cron Job with a Task that executes a program. The task normally runs without any paramters. However, we have a need to run the task with paramters for special processing. Instead of having the users access the Visual Cron Client I want to create an application (DotNet C#) and use the API to run the task with the paramters. I am new at using the API. I have been able to connect, get the correct job and task, and run it. But even though I have theTask.Execute.Arguments = "arg1,arg2", the task is run without passing the paramters to the executable.

There are other ways to accomplish this but I was hoping to do it with the Visual Cron API, mostly because it will always have the correct location of the executable which changes with each new release. I thought about creating a new Job/Task and copy the values from the existing Job/Task, which will probably work, but...

So the short question is; can I use an existing Job/Task and have it pass some arguments that I set to the executable?

Thanks.
Mike

Edited by user Thursday, August 25, 2011 12:51:52 PM(UTC)  | Reason: added solved to title

Support Offline
#2 Posted : Wednesday, August 24, 2011 7:30:14 AM(UTC)
Support
Rank: Administration

Reputation:

Joined: 2/23/2008(UTC)
Posts: 6,120
Man
Location: Sweden

Thanks: 198 times
Was thanked: 117 time(s) in 112 post(s)
What you need to do, before running the Task/Job is to update the Job. If you make any change to Arguments you need to send the Job/Task for update before running it.
Henrik
Support
http://www.visualcron.com

Please like VisualCron on facebook!
 1 user thanked Support for this useful post.
mikeb on 8/25/2011(UTC)
mikeb Offline
#3 Posted : Wednesday, August 24, 2011 4:40:40 PM(UTC)
mikeb
Rank: Newbie

Reputation:

Joined: 8/23/2011(UTC)
Posts: 5
Location: Phoenix

Thanks: 4 times
Thank you Henrik for the quick response and help. One more question. Do I need to do something between the
Server.Jobs.Tasks.Update(mytask) and the
Server.Jobs.Tasks.Run(myjob,mytask,false)
?

I don't think the job/task is running. In the log file, I see the Task Update, but no Job or Task Started or completed or any errors. And no output from the exectubale.

Thanks Again
Mike
Support Offline
#4 Posted : Wednesday, August 24, 2011 5:38:05 PM(UTC)
Support
Rank: Administration

Reputation:

Joined: 2/23/2008(UTC)
Posts: 6,120
Man
Location: Sweden

Thanks: 198 times
Was thanked: 117 time(s) in 112 post(s)
You should not have to do anything between. What happens if you uncomment the Update part - does it run then?
Henrik
Support
http://www.visualcron.com

Please like VisualCron on facebook!
 1 user thanked Support for this useful post.
mikeb on 8/25/2011(UTC)
mikeb Offline
#5 Posted : Wednesday, August 24, 2011 5:53:09 PM(UTC)
mikeb
Rank: Newbie

Reputation:

Joined: 8/23/2011(UTC)
Posts: 5
Location: Phoenix

Thanks: 4 times
Update: Running local works just fine. It seems to be only when running remote.


WOW, that was super fast. Thank. Yes it does run when the Update is commented out. It seems that one or the other work but not both.
This is my test app.


var vClient = new Client();
var vServer = new Server();
var vConnection = new Connection();
vConnection.ConnectionType = Connection.ConnectionT.Remote;
vConnection.UserName = "topsecret";
vConnection.Port = 16444;
vConnection.Address = "phxvs57";
vConnection.UseADLogon = true;
vConnection.ClientType = ClientConnectionClass.ClientT.APIClient;
vServer = vClient.Connect(vConnection, true);

var jobs = vServer.Jobs.GetAll();

var job = jobs.Where(j => j.Name == "Test - Journaling - EU").FirstOrDefault();
if(job == null)
return;

var task = job.Tasks.Where(t => t.Name == "Test - EU - Journaling Task").FirstOrDefault();
if( task == null)
return;

task.Execute.CmdLine = task.Execute.CmdLine;
task.Execute.Arguments = @"/StartDate:2011814 /EndDate:20110818";
job.NotStartIfRunning = true;

vServer.Jobs.Tasks.Update(task);
vServer.Jobs.Tasks.Run(job,task,true);


vServer.Disconnect();

Edited by user Wednesday, August 24, 2011 6:25:25 PM(UTC)  | Reason: Not specified

Support Offline
#6 Posted : Wednesday, August 24, 2011 5:59:01 PM(UTC)
Support
Rank: Administration

Reputation:

Joined: 2/23/2008(UTC)
Posts: 6,120
Man
Location: Sweden

Thanks: 198 times
Was thanked: 117 time(s) in 112 post(s)
Thanks, we will test this and get back to you. That will probably be tomorrow.
Henrik
Support
http://www.visualcron.com

Please like VisualCron on facebook!
 1 user thanked Support for this useful post.
mikeb on 8/24/2011(UTC)
Support Offline
#7 Posted : Wednesday, August 24, 2011 10:52:51 PM(UTC)
Support
Rank: Administration

Reputation:

Joined: 2/23/2008(UTC)
Posts: 6,120
Man
Location: Sweden

Thanks: 198 times
Was thanked: 117 time(s) in 112 post(s)
Please try to set the bolSynchrous flag to true in the Run method. The problem is that the remote connection method is slower. And if not a Synchrous run is being made there is a risk that you close the connection before the actual Run command is sent. I guess you are running the command from a console application or other application that just exists after this command.
Henrik
Support
http://www.visualcron.com

Please like VisualCron on facebook!
 1 user thanked Support for this useful post.
mikeb on 8/24/2011(UTC)
mikeb Offline
#8 Posted : Thursday, August 25, 2011 12:37:27 AM(UTC)
mikeb
Rank: Newbie

Reputation:

Joined: 8/23/2011(UTC)
Posts: 5
Location: Phoenix

Thanks: 4 times
That resolved my issue. Yes, I was running from a console app and disconnecting before it had a chance to run. It is now running exactly like I was hoping.

Thank you very much for the help and fantastic support!

Mike
BigGrin
Support Offline
#9 Posted : Thursday, August 25, 2011 7:17:16 AM(UTC)
Support
Rank: Administration

Reputation:

Joined: 2/23/2008(UTC)
Posts: 6,120
Man
Location: Sweden

Thanks: 198 times
Was thanked: 117 time(s) in 112 post(s)
Thanks for the feedback!
Henrik
Support
http://www.visualcron.com

Please like VisualCron on facebook!
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

footer
Follow VisualCron on Facebook Follow VisualCron on Twitter neteject.com anyconnect.net millimetrics.com xendapp.com