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


NigelH
2014-09-01T10:56:51Z
Hi,

How do I pass variables from a vb.net app through to a job? I have tried several ways and none appear to work for me. I have a snapshot of some code below that shows the job I can run but this job now has variables. I have tried using jobVariablesClass but cannot understand how to use it. Any help would be very much appreciated.

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Dim jobs As Jobs = s.Jobs
Dim jobToRun As JobClass = Nothing

jobs.GetJobByName("TestJob")
jobToRun = jobs.GetJobByName("TestJob")

'For Each job In jobs.GetAll()
' If job.Name = "TestJob" Then
' jobToRun = job
' Exit For
' End If
'Next

If jobToRun Is Nothing Then
TextBox1.Text = "Cannot find job"
Else
jobs.Run(jobToRun, False)
TextBox1.Text = "Jobby found"
End If

End Sub
Sponsor
Forum information
Support
2014-09-01T12:58:44Z
Here is a sample:

using System;
using VisualCron;
using VisualCronAPI;

public class Test
{
 public static void ConnectMe()
 {
     Client c = new Client();
     Connection conn = new Connection();
     Server s = c.Connect(conn,true);
     s.Jobs.AddUpdateJobVariable("{JOB(Active|Id)}","testkey","testvalue");
 }
} 

Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
NigelH
2014-09-01T13:45:07Z
Thanks Henrik - that looks simple enough but I get the following error:

Error 1 'AddUpdateJobVariable' is not a member of 'VisualCronAPI.Jobs'. C:\crap\vc2\WindowsApplication1\WindowsApplication1\Form1.vb 36 9 WindowsApplication1

All dlls are defined, s represents the connected server and is visible in my block. However when I use intellisense to assist, there is no AddUpdateJobVariable method to Jobs.

There is Add, AddAsync then Contains ...... etc etc
Support
2014-09-02T07:12:47Z
You need to use the latest version for this.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
NigelH
2014-09-02T08:54:33Z
Hi Henrik - I'm hoping that resolves the problem - I'm currently using runtime version 4.0.30319 (version 1.0.3.17187) VisualCronAPI

What should the latest version be?

regards

NigelH
Support
2014-09-02T10:38:22Z
Hi,

sorry, it seems the API has been updated. So it should appear somewhere here:

s.Jobs.Variables.AddUpdate(
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Support
2014-09-02T10:40:51Z
Let me double check this.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Support
2014-09-03T11:05:27Z
I think we have found an issue. Please test this version:

http://www.visualcron.co....aspx?g=posts&t=4452 
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
NigelH
2014-09-03T12:59:35Z
Hi Henrik,

Thanks for the beta changes but I'm still having no luck with passing variables. I have changed the test to make it more visible to me if the code works - I now have a job that creates a folder. The code (I have not included the connection code as I know this works) is below.

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Dim jobs As Jobs = s.Jobs
Dim jobToRun As JobClass = jobs.GetJobByName("TestJob")

jobs.JobVariables.AddUpdate("{JOB(Active,Variable,param1)}", "param1", "c:\aaaa")

If jobToRun Is Nothing Then
TextBox1.Text = "Cannot find job"
Else
jobs.Run(jobToRun, False)
TextBox1.Text = "Jobby found"
End If

End Sub


The job runs but the variable param1 does not get updated and so the task to create the folder fails. If the job is run from the VisualCron client (with a value in the variable) it works. Any further thoughts or ideas on a different syntax?

I have also tried setting up a jobVariableClass and setting the key as "param1" and running the method variableUpdate(instance of jobVariableClass). This updates the variable in the job but I see nowhere to update the value of this variable.

regards

Nigel J Hartley
Support
2014-09-03T15:34:05Z
You need to pass the Id of the Job. The actual Variable is not resolved in that function. Variables are resolved in VisualCron fields - not normally within API functions.

So, use jobToRun.Id instead.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
NigelH
2014-09-03T16:01:57Z
Thank you Henrik - this has made all the difference.

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Dim jobs As Jobs = s.Jobs
Dim jobToRun As JobClass = jobs.GetJobByName("TestJob")
Dim job_id As String = ""


jobToRun = jobs.GetJobByName("TestJob")
job_id = jobToRun.Id

jobs.JobVariables.AddUpdate("{JOB(Active,Variable,param1)}", job_id, "c:\aaaa")

If jobToRun Is Nothing Then
TextBox1.Text = "Cannot find job"
Else
jobs.Run(jobToRun, False)
TextBox1.Text = "Jobby found"
End If

End Sub
NigelH
2014-09-04T10:33:49Z
Hi,

sorry about this continued saga - I've run into a related issue:

Trying to run as described -

jobs.JobVariables.AddUpdate(Job_id,"param1","c:\aaaa")

The variable is obviously updating on the server but the application hangs with the resulting error - ReplyTimeoutException was unhandled (Expected reply has not been recieved within time period).

This takes about 30 seconds to error and hangs without running the task

Any thoughts?
Support
2014-09-06T09:44:19Z
Please try this, we did some more changes:

http://www.visualcron.co....aspx?g=posts&t=4452 
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Scroll to Top