Community forum

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


mikeb
  •  mikeb
  • No customer Topic Starter
2011-08-23T22:42:52Z
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
Sponsor
Forum information
Support
2011-08-24T06:30:14Z
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!
mikeb
  •  mikeb
  • No customer Topic Starter
2011-08-24T15:40:40Z
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
2011-08-24T16:38:05Z
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!
mikeb
  •  mikeb
  • No customer Topic Starter
2011-08-24T16:53:09Z
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();
Support
2011-08-24T16:59:01Z
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!
Support
2011-08-24T21:52:51Z
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!
mikeb
  •  mikeb
  • No customer Topic Starter
2011-08-24T23:37:27Z
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
😁
Support
2011-08-25T06:17:16Z
Thanks for the feedback!
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
WalterG
2013-09-04T00:48:45Z
Originally Posted by: mikeb 


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
2013-09-04T06:20:01Z
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
2013-09-05T16:17:24Z
Originally Posted by: Support 

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




Scroll to Top