示例#1
0
        public void DeleteTask(TaskParams taskParams)
        {
            var ts   = new TaskService();
            var task = ts.RootFolder.GetTasks().Where(a => a.Name.ToLower() == taskParams.Name.ToLower()).FirstOrDefault();

            if (task != null)
            {
                ts.RootFolder.DeleteTask(taskParams.Name);
            }
        }
示例#2
0
        public TaskParams GetTaskState(TaskParams taskParams)
        {
            var ts   = new TaskService();
            var task = ts.RootFolder.GetTasks().Where(a => a.Name.ToLower() == taskParams.Name.ToLower()).FirstOrDefault();

            if (task == null)
            {
                return(null);
            }
            else
            {
                return(new TaskParams()
                {
                    Name = task.Name, IsSet = true, time = task.NextRunTime
                });
            }
        }
示例#3
0
        public void SetTask(TaskParams taskParams)
        {
            using (TaskService ts = new TaskService())
            {
                // Create a new task definition and assign properties
                TaskDefinition td = ts.NewTask();
                td.RegistrationInfo.Description = "Update GisMeteo";
                td.RegistrationInfo.Author      = "Mirg0r0d";

                // Create a trigger that will fire the task at this time every other day
                td.Triggers.Add(new DailyTrigger {
                    StartBoundary = taskParams.time
                });

                string filePath = Path.Combine(new DirectoryInfo(HostingEnvironment.ApplicationPhysicalPath).Parent.FullName, @"GisMeteoParser\bin\Debug\GisMeteoParser.exe");
                if (File.Exists(filePath))
                {
                    td.Actions.Add(new ExecAction(filePath));

                    ts.RootFolder.RegisterTaskDefinition(taskParams.Name, td);
                }
            }
        }