Community forum

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

Notification

Icon
Error

Options
View
Go to last post Go to first unread
Offline NigelH  
#1 Posted : Monday, September 1, 2014 11:56:51 AM(UTC)
NigelH

Rank: Paid support

Joined: 8/28/2014(UTC)
Posts: 6
United Kingdom
Location: Alfreton

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
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

Edited by moderator Wednesday, September 3, 2014 5:02:52 PM(UTC)  | Reason: Not specified

Offline Support  
#2 Posted : Monday, September 1, 2014 1:58:44 PM(UTC)
Support

Rank: Official support

Medals:
Joined: 2/23/2008(UTC)
Posts: 9,412

Thanks: 573 times
Was thanked: 326 time(s) in 314 post(s)
Here is a sample:

Code:
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!
Offline NigelH  
#3 Posted : Monday, September 1, 2014 2:45:07 PM(UTC)
NigelH

Rank: Paid support

Joined: 8/28/2014(UTC)
Posts: 6
United Kingdom
Location: Alfreton

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
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
Offline Support  
#4 Posted : Tuesday, September 2, 2014 8:12:47 AM(UTC)
Support

Rank: Official support

Medals:
Joined: 2/23/2008(UTC)
Posts: 9,412

Thanks: 573 times
Was thanked: 326 time(s) in 314 post(s)
You need to use the latest version for this.
Henrik
Support
http://www.visualcron.com

Please like VisualCron on facebook!
Offline NigelH  
#5 Posted : Tuesday, September 2, 2014 9:54:33 AM(UTC)
NigelH

Rank: Paid support

Joined: 8/28/2014(UTC)
Posts: 6
United Kingdom
Location: Alfreton

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
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
Offline Support  
#6 Posted : Tuesday, September 2, 2014 11:38:22 AM(UTC)
Support

Rank: Official support

Medals:
Joined: 2/23/2008(UTC)
Posts: 9,412

Thanks: 573 times
Was thanked: 326 time(s) in 314 post(s)
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!
Offline Support  
#7 Posted : Tuesday, September 2, 2014 11:40:51 AM(UTC)
Support

Rank: Official support

Medals:
Joined: 2/23/2008(UTC)
Posts: 9,412

Thanks: 573 times
Was thanked: 326 time(s) in 314 post(s)
Let me double check this.
Henrik
Support
http://www.visualcron.com

Please like VisualCron on facebook!
Offline Support  
#8 Posted : Wednesday, September 3, 2014 12:05:27 PM(UTC)
Support

Rank: Official support

Medals:
Joined: 2/23/2008(UTC)
Posts: 9,412

Thanks: 573 times
Was thanked: 326 time(s) in 314 post(s)
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!
thanks 1 user thanked Support for this useful post.
NigelH on 9/3/2014(UTC)
Offline NigelH  
#9 Posted : Wednesday, September 3, 2014 1:59:35 PM(UTC)
NigelH

Rank: Paid support

Joined: 8/28/2014(UTC)
Posts: 6
United Kingdom
Location: Alfreton

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
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

Edited by user Wednesday, September 3, 2014 2:03:11 PM(UTC)  | Reason: Not specified

Offline Support  
#10 Posted : Wednesday, September 3, 2014 4:34:05 PM(UTC)
Support

Rank: Official support

Medals:
Joined: 2/23/2008(UTC)
Posts: 9,412

Thanks: 573 times
Was thanked: 326 time(s) in 314 post(s)
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!
thanks 1 user thanked Support for this useful post.
NigelH on 9/3/2014(UTC)
Offline NigelH  
#11 Posted : Wednesday, September 3, 2014 5:01:57 PM(UTC)
NigelH

Rank: Paid support

Joined: 8/28/2014(UTC)
Posts: 6
United Kingdom
Location: Alfreton

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
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
thanks 1 user thanked NigelH for this useful post.
Support on 9/3/2014(UTC)
Offline NigelH  
#12 Posted : Thursday, September 4, 2014 11:33:49 AM(UTC)
NigelH

Rank: Paid support

Joined: 8/28/2014(UTC)
Posts: 6
United Kingdom
Location: Alfreton

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
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?
Offline Support  
#13 Posted : Saturday, September 6, 2014 10:44:19 AM(UTC)
Support

Rank: Official support

Medals:
Joined: 2/23/2008(UTC)
Posts: 9,412

Thanks: 573 times
Was thanked: 326 time(s) in 314 post(s)
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!
Users browsing this topic
Guest (2)
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.

Powered by YAF.NET | YAF.NET © 2003-2016, Yet Another Forum.NET
This page was generated in 0.476 seconds.
Scroll to Top