Accessing Variable Values via API - VisualCron - Forum

Community forum

rdiesel
2010-04-19T17:12:33Z
Hi

First off, could you kindly clarify the runtime scope of user variables defined via the client interface. If 2 jobs are running concurrently and one job changes the value of a variable will this changed value be visible to another job or do i need to use the "Translate to constant when running" to prevent the other job from seeing the changed variable.

Also I am having trouble accessing the variable values at runtime via the API...



      Client vcClient = new Client();

            Connection vcConn = new Connection();

            vcConn.ConnectionType = Connection.ConnectionT.Local;

            Server vcSvr = vcClient.Connect(vcConn, true);

            UserVariableClass uvCls = vcSvr.Variables.Get("AirtimeStockImportLog");

            string ascVal = new ASCIIEncoding().GetString(uvCls.ValueObject);


the uvCls.Value returns a .Net byte[] type which I cannot decode. Also if i wish to set the value of the Variable programatically how should the value be encoded?

regards
Support
2010-04-19T17:15:13Z
That value is encrypted. You should use the ToString method on this method:

GetVariableValue
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
rdiesel
2010-04-19T18:07:31Z
Thanks, have been able to retrieve the value, But have just tested (5.5.5) and it seems that these are global variables ie. if a task in Job x uses and changes the global variable, then another task in Job y will see the changed value - which makes life fairly difficult in creating generic jobs!

Also what is the meaning of "Translate to constant when running"
Support
2010-04-19T18:11:37Z
Yes, those are global Variables so they can be reused easily. But that should not stop you for creating unique Variables based on Job Id or similar in the key.

"Translate to constant when running..". Let say you use a current date variable within a user variable. If that box is not checked it will always retrieve the current that - if checked it will be turned into a string (same date as running) and keep that same string.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
rdiesel
2010-04-19T18:55:57Z
Thanks, the JobId prefix will solve my problem.
Luke Watson
2015-01-02T14:26:11Z
Originally Posted by: Support 

That value is encrypted. You should use the ToString method on this method:

GetVariableValue



I am trying to get the value of a Job Variable, but the only reference i can find to GetVariableValue is "VisualCronAPI.Variables._Variables.GetVariableValue" and it requires a UserVariable, not a JobVariable.

we are on version 7.0.5, im sure im just doing something simple, but i cant find anything on search either.

Many thanks
Support
2015-01-05T09:44:26Z
If it is a Job Variable you should use;

serverObj.Jobs.JobVariables.GetValue()
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Scroll to Top