I need to add new job with single task that should be triggered just once in very specific date/time. Currently my code (sort of) works but I can't figure out why is job's Next run showing 'No Trigger specified' even though when I open edit trigger window there is shown the correct time in status bar. Please see the screenshot included to see what I mean:
I'm using VisualCron 6.0.9 (trial license still), tried 6.1.0 as well without success.
Desired
scheduleDate parameter for test case was May 31, 2012.
internal static void CreateVisualCronTask(DateTime scheduleDate, string packageCode)
{
Server server = null;
Client client = new Client();
client.LogToFile = false;
try
{
Connection connection = new Connection();
connection.ConnectionType = Connection.ConnectionT.Remote;
connection.Address = Configuration.VisualCronHostIP;
connection.Port = Configuration.VisualCronHostPort;
connection.UserName = Configuration.VisualCronUser;
connection.PassWord = Configuration.VisualCronUserPassword;
connection.UseADLogon = false;
connection.ClientType = ClientConnectionClass.ClientT.APIClient;
server = client.Connect(connection, true);
}
catch
{
throw;
}
if (server != null && server.Connected)
{
JobClass job = new JobClass();
job.Name = Configuration.VisualCronJobName;
job.Description = Configuration.VisualCronJobDescription;
job.Group = "MegaSign";
job.RunOnce = true;
#region Trigger definition
TriggerClass trigger = job.AddTrigger(TimeClass.TimeTriggerT.Custom);
trigger.Description = "Runs only once";
trigger.TTime.AllYears = false;
trigger.TTime.AllMonths = false;
trigger.TTime.AllDays = false;
trigger.TTime.AllHours = false;
trigger.TTime.AllMinutes = false;
trigger.TTime.AllSeconds = false;
//TTime indices are zero-based
trigger.TTime.YearBetweenStart = scheduleDate.Year;
trigger.TTime.YearBetweenStop = scheduleDate.Year;
trigger.TTime.YearIsBetween = true;
trigger.TTime.Months[scheduleDate.Month - 1] = true;
trigger.TTime.Days[scheduleDate.Day - 1] = true;
trigger.TTime.Hours[0] = true;
trigger.TTime.Minutes[0] = true;
trigger.TTime.Seconds[0] = true;
trigger.TTime.SpecificType = TimeClass.SpecificT.Days;
trigger.TTime.DayType = true;
trigger.FirstRun = scheduleDate;
#endregion
#region Task definition
TaskClass task = job.AddTask(TaskClass.TaskT.Execute);
task.Name = string.Format("Run Sender with PackageCode={0}", packageCode);
#if DEBUG
task.Execute.CmdLine = "C:\\FakeSender.cmd";
#else
task.Execute.CmdLine = Configuration.PathToEchoSignSenderApp;
#endif
task.Execute.Arguments = packageCode;
task.ExecutionContext.ExecutionType = ExecutionContextClass.ExecutionT.Foreground;
var newJob = server.Jobs.Add(job);
#endregion
if (Configuration.StartPastPackagesImmediately && scheduleDate < DateTime.Now)
server.Jobs.Run(newJob, true);
server.Disconnect();
}
}
TIA for any solution, it's quite urgent and we have the first release deployed to customer already.
Edited by moderator
2012-12-20T08:04:41Z
|
Reason: Not specified