Пример #1
0
        }         // FillFromWindowsScheduler

        private void ProcessTasks(IEnumerable <Task> schedulerTasks, TaskListBuildOptions options, IDictionary <string, TaskData> tasks)
        {
            TaskData   taskData;
            RecordTask recordTask;

            foreach (var schedulerTask in schedulerTasks)
            {
                if (!Scheduler.IsRecordSchedulerTask(schedulerTask, out recordTask))
                {
                    continue;
                }

                if (!tasks.TryGetValue(schedulerTask.Name, out taskData))
                {
                    if (options.AddAllWindowsSchedulerTaks)
                    {
                        AddSchedulerTask(schedulerTask, recordTask);
                    } // if
                }
                else
                {
                    if ((taskData.SchedulerName != schedulerTask.Name) ||
                        (taskData.SchedulerPath != schedulerTask.Folder.Path))
                    {
                        taskData.Status = TaskStatus.WindowsTaskMoved;
                    }
                    else
                    {
                        taskData.Status = (recordTask != null) ? TaskStatus.Ok : TaskStatus.WindowsTaskXmlError;
                    } // if-else
                }     // if-else
            }         // foreach
        }             // ProcessTasks
Пример #2
0
        } // TaskList

        public static TaskList Build(TaskListBuildOptions options)
        {
            TaskList result;

            if (options == null)
            {
                throw new ArgumentNullException();
            }
            if (string.IsNullOrEmpty(options.RecordTaskFolder))
            {
                throw new ArgumentNullException();
            }
            if (!Directory.Exists(options.RecordTaskFolder))
            {
                throw new DirectoryNotFoundException(options.RecordTaskFolder);
            }


            result = new TaskList();
            result.FillFromFolder(options.RecordTaskFolder);
            if ((options.SchedulerFolders != null) || (options.ScanAllWindowsSchedulerTasks))
            {
                result.FillFromWindowsScheduler(options);
            } // if

            return(result);
        } // Build
Пример #3
0
        }             // FillFromFolder

        private void FillFromWindowsScheduler(TaskListBuildOptions options)
        {
            IDictionary <string, TaskData> tasks;
            TaskService service;
            TaskFolder  schedulerFolder;

            tasks = new Dictionary <string, TaskData>(Count);
            foreach (var task in List)
            {
                if (task.Status != TaskStatus.XmlError)
                {
                    tasks.Add(task.SchedulerName, task);
                } // if
            }     // foreach

            service = new TaskService();

            if (options.ScanAllWindowsSchedulerTasks)
            {
                var schedulerTasks = service.AllTasks;
                ProcessTasks(schedulerTasks, options, tasks);
            }
            else if (options.SchedulerFolders != null)
            {
                foreach (var folder in options.SchedulerFolders)
                {
                    try
                    {
                        schedulerFolder = service.GetFolder(folder);
                    }
                    catch (FileNotFoundException)
                    {
                        continue;
                    } // try-catch

                    var schedulerTasks = schedulerFolder.Tasks;
                    ProcessTasks(schedulerTasks, options, tasks);
                } // foreach
            }     // if-else if
        }         // FillFromWindowsScheduler