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.


Archibald P. Weatherby
2017-03-16T16:07:23Z
I am trying to set the credential on the ExecutionContext but I am not sure if that is the correct way to do this.

Below is the code we are using to create the new job and task and a screenshot of what we are attempting to do via the API:
https://www.screencast.com/t/bg9irb0i1x 

    JobClass j = new JobClass();
            j.Group = server;
            j.Name = _mlsArea;
            j.Description = GetDropDownValue(arguments);

            // create interval trigger for last friday in month
            TriggerClass tr = j.AddTrigger(TimeClass.TimeTriggerT.Interval);

            tr.TTime.InitDate = timeTriger;
            tr.FirstRun = timeTriger;
            tr.TTime.IntervalType = TimeClass.IntervalT.Hourly;
            tr.TTime.IntervalValue = interval;
            tr.Description = String.Format("Every {0} Hours", tr.TTime.IntervalValue);

            TaskClass ta = new TaskClass();
            ta.StoreSTDOut = true;
            ta.StoreSTDErr = true;
            ta.Execute = new TaskExecuteClass();
            ta.Execute.CmdLine = @"M:\ApplicationCode\ProdEXE\ProdCopy\bin\ProdCopy.exe";
            ta.Execute.Arguments = arguments;
            ta.ExecutionContext.UserName = "mlsjobs";
            ta.Name = arguments;

            j.Tasks.Add(ta);
Sponsor
Forum information
Support
2017-03-17T10:46:50Z
Hi,

it is this property:

ta.ExecutionContext.BeforeExecutionLogonCredential = credentialId;

Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Archibald P. Weatherby
2017-03-17T14:31:23Z
I've implemented your solution and I got the credential id from Server>Credentials>Copy Id to clipboard, but it still doesn't seem to be working. Am I missing anything else?

See Code below:
public JobClass CreateCronJob(string server, int interval, DateTime timeTriger, string arguments)
{
JobClass j = new JobClass();
j.Group = server;
j.Name = _mlsArea;
j.Description = GetDropDownValue(arguments);

// create interval trigger for last friday in month
TriggerClass tr = j.AddTrigger(TimeClass.TimeTriggerT.Interval);

tr.TTime.InitDate = timeTriger;
tr.FirstRun = timeTriger;
tr.TTime.IntervalType = TimeClass.IntervalT.Hourly;
tr.TTime.IntervalValue = interval;
tr.Description = String.Format("Every {0} Hours", tr.TTime.IntervalValue);

TaskClass ta = new TaskClass();
ta.StoreSTDOut = true;
ta.StoreSTDErr = true;
ta.Execute = new TaskExecuteClass();
ta.Execute.CmdLine = @"M:\ApplicationCode\ProdEXE\ProdCopy\bin\ProdCopy.exe";
ta.Execute.Arguments = arguments;
ta.ExecutionContext = new ExecutionContextClass();
ta.ExecutionContext.BeforeExecutionLogonCredential = "06c01f20-1a7e-4b82-b481-7c1c30b07ea6";
ta.Name = arguments;

j.Tasks.Add(ta);
return j;
Archibald P. Weatherby
2017-03-17T14:33:17Z
I also have this issue and I'm not so sure it's related but every time I create a new job/task through the .Net API, Visual Cron on the server hangs at 50% and I need to kill the VisualCron Service and restart it in order to see the job created via the API.
Support
2017-03-20T19:51:54Z
What I mean was that you perform serverObj.Jobs.Tasks.Update( after doing the change. Should not cause a hang.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Scroll to Top