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 Friday, February 21, 2014 9:50:42 AM(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: 7,278
Man
Location: Sweden

Thanks: 304 times
Was thanked: 179 time(s) in 171 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: 7,278
Man
Location: Sweden

Thanks: 304 times
Was thanked: 179 time(s) in 171 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: 7,278
Man
Location: Sweden

Thanks: 304 times
Was thanked: 179 time(s) in 171 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: 7,278
Man
Location: Sweden

Thanks: 304 times
Was thanked: 179 time(s) in 171 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: 7,278
Man
Location: Sweden

Thanks: 304 times
Was thanked: 179 time(s) in 171 post(s)
Thanks for the feedback!
Henrik
Support
http://www.visualcron.com

Please like VisualCron on facebook!
WalterG Offline
#10 Posted : Wednesday, September 4, 2013 1:48:45 AM(UTC)
WalterG
Rank: Newbie

Reputation:

Joined: 9/11/2012(UTC)
Posts: 5
Canada

Originally Posted by: mikeb Go to Quoted Post

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);


Mine continuously hang on the "vClient.Connect(vConnection, true);" statement.
I tried various combinations of code found on the forum. I tried "admin" and usernames that I've added.

Does anyone experience this problem and have resolved it? How did you do?
Support Offline
#11 Posted : Wednesday, September 4, 2013 7:20:01 AM(UTC)
Support
Rank: Administration

Reputation:

Joined: 2/23/2008(UTC)
Posts: 7,278
Man
Location: Sweden

Thanks: 304 times
Was thanked: 179 time(s) in 171 post(s)
Have you tried this locally first with ip just to verify that there is no firewall or dns problem?
Henrik
Support
http://www.visualcron.com

Please like VisualCron on facebook!
WalterG Offline
#12 Posted : Thursday, September 5, 2013 5:17:24 PM(UTC)
WalterG
Rank: Newbie

Reputation:

Joined: 9/11/2012(UTC)
Posts: 5
Canada

Originally Posted by: Support Go to Quoted Post
Have you tried this locally first with ip just to verify that there is no firewall or dns problem?


Question: are there any issue with API and Windows 8? Visual Studio 2012. Thank you for your response.

I was using IP address so I didn't think DNS was the issue. However, I do have VisualCRON on two servers on separate network and I was able to connect into each other from the management consoles. So I didn't think firewall was the issue.

Below is the exact code and it never got to the last statement, MessageBox.

I had previously tried as local and copied the EXE to the VisualCron folder where the API dll resides. I got the error "Could not load file or assembly "VisualCronAPI, version=1.03.20914 or one of its dependencies..."

On the development station which is Windows 8 I had problem with installing Visual Cron client & server. So, I'm going to start a new environment on another clean station - Windows 8. I was able to install Visual Cron 7.04. I will try and get the local client & server working first. If this work, then I will expand from there.

private VisualCronAPI.Server vcServer = null;

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
try
{
VisualCronAPI.Client vcClient = new VisualCronAPI.Client();
vcServer = new VisualCronAPI.Server();
vcClient.LogToFile = false;

VisualCronAPI.Connection conn = new VisualCronAPI.Connection();
conn.Address = "www.xxx.yyy.zzz";
conn.UserName = "admin";
conn.PassWord = "";
conn.Port = 16444;

// conn.ConnectionType = VisualCronAPI.Connection.ConnectionT.Remote;
conn.ConnectionType = VisualCronAPI.Connection.ConnectionT.Local;
conn.ClientType = VisualCron.ClientConnectionClass.ClientT.APIClient;
MessageBox.Show("new connection");

try
{
vcServer = vcClient.Connect(conn, true);
MessageBox.Show("set connection to client");




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   Join the VisualCron group on LinkedIn neteject.com anyconnect.net millimetrics.com xendapp.com