I am creating a job upload program in c#. I have all the job information maintained in the config file.
When I create a job, I do pass an unique argument for that job.
using (TaskService ts = new TaskService())
{
TaskDefinition td = ts.NewTask();
TimeTrigger trigger = new TimeTrigger();
var startTime = TimeSpan.Parse(section1["ScheduledTime"]);
trigger.StartBoundary = DateTime.Today + startTime;
trigger.Repetition.Interval = TimeSpan.FromDays(1);
trigger.StartBoundary = DateTime.Now;
trigger.Id = "XXX";
trigger.Repetition.Interval = TimeSpan.FromDays(1);
td.Triggers.Add(trigger);
td.Actions.Add(new ExecAction(@"C:/JobUpload.exe", argument, ""));
var foldername = ts.GetFolder(@"\Data");
foldername.RegisterTaskDefinition(section1["JobName"], td);
}
In the program, I have to check whether the job has any arguments. If no arguments are present (this occurs when the exe file is triggered manually), then I have to trigger the method A.
On the other hand, if the exe file is triggered through the job in task scheduler, then it has arguments associated with it, so I have to trigger the method B.
I am not sure on how to check whether a job has any arguments in C#.
Any help would be appreciated.
Edit:
if (args.Length > 0)
{
Console.WriteLine("more than 1");
Logger.Info("More than 1");
Debug.WriteLine("More than 1");
}