Esempio n. 1
0
        /// <summary>
        /// Finds the task in folder.
        /// </summary>
        /// <param name="fld">The folder.</param>
        /// <param name="filter">The filter to use when looking for tasks.</param>
        /// <param name="results">The results.</param>
        /// <param name="recurse">if set to <c>true</c> recurse folders.</param>
        /// <returns>True if any tasks are found, False if not.</returns>
        private bool FindTaskInFolder([NotNull] TaskFolder fld, Predicate <Task> filter, ref System.Collections.Generic.List <Task> results, bool recurse = true)
        {
            foreach (Task t in fld.GetTasks())
            {
                try
                {
                    if (filter(t))
                    {
                        results.Add(t);
                    }
                }
                catch
                {
                    System.Diagnostics.Debug.WriteLine($"Unable to evaluate filter for task '{t.Path}'.");
                }
            }

            if (recurse)
            {
                foreach (var f in fld.SubFolders)
                {
                    if (FindTaskInFolder(f, filter, ref results))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 2
0
        /// <summary>
        /// Finds the task in folder.
        /// </summary>
        /// <param name="fld">The folder.</param>
        /// <param name="taskName">The wildcard expression to compare task names with.</param>
        /// <param name="results">The results.</param>
        /// <param name="recurse">if set to <c>true</c> recurse folders.</param>
        /// <returns>True if any tasks are found, False if not.</returns>
        private bool FindTaskInFolder([NotNull] TaskFolder fld, System.Text.RegularExpressions.Regex taskName, ref System.Collections.Generic.List <Task> results, bool recurse = true)
        {
            results.AddRange(fld.GetTasks(taskName));

            if (recurse)
            {
                foreach (var f in fld.SubFolders)
                {
                    if (FindTaskInFolder(f, taskName, ref results))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 3
0
        public static Report GetScheduledReport(TaskFolder taskFolder, string reportPath, string reportGUID, string scheduleGUID, Repository repository)
        {
            Report report = null;
            if (File.Exists(reportPath)) report = Report.LoadFromFile(reportPath, repository);

            if (!File.Exists(reportPath) || (report != null && report.GUID != reportGUID))
            {
                //Report has been moved or renamed: search report from its GUID in the report folder
                report = repository.FindReport(repository.ReportsFolder, reportGUID);
                if (report == null)
                {
                    //Remove the schedules of the report
                    foreach (Task oldTask in taskFolder.GetTasks().Where(i => i.Definition.RegistrationInfo.Source.EndsWith(scheduleGUID)))
                    {
                        taskFolder.DeleteTask(oldTask.Name);
                    }
                }
            }
            return report;
        }
Esempio n. 4
0
 public static ReportSchedule GetReportSchedule(TaskFolder taskFolder, Report report, string scheduleGUID)
 {
     ReportSchedule schedule = report.Schedules.FirstOrDefault(i => i.GUID == scheduleGUID);
     if (schedule == null)
     {
         //Remove the schedule
         foreach (Task oldTask in taskFolder.GetTasks().Where(i => i.Definition.RegistrationInfo.Source.EndsWith(scheduleGUID)))
         {
             taskFolder.DeleteTask(oldTask.Name);
         }
     }
     return schedule;
 }
Esempio n. 5
0
 private static Task loadTask(string name, TaskFolder folder = null) {
     if (folder == null)
         folder = loadTaskFolder();
     TaskCollection tasks = folder.GetTasks();
     return tasks.FirstOrDefault(x => x.Name == name);
 }
        /// <summary>
        /// Finds the task in folder.
        /// </summary>
        /// <param name="fld">The folder.</param>
        /// <param name="taskName">The wildcard expression to compare task names with.</param>
        /// <param name="results">The results.</param>
        /// <param name="recurse">if set to <c>true</c> recurse folders.</param>
        /// <returns>True if any tasks are found, False if not.</returns>
        private bool FindTaskInFolder(TaskFolder fld, System.Text.RegularExpressions.Regex taskName, ref System.Collections.Generic.List<Task> results, bool recurse = true)
        {
            results.AddRange(fld.GetTasks(taskName));

            if (recurse)
            {
                foreach (var f in fld.SubFolders)
                {
                    if (FindTaskInFolder(f, taskName, ref results, recurse))
                        return true;
                }
            }
            return false;
        }