Пример #1
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>IEnumerable{TaskInfo}.</returns>
        public object Get(GetScheduledTasks request)
        {
            IEnumerable <IScheduledTaskWorker> result = TaskManager.ScheduledTasks
                                                        .OrderBy(i => i.Name);

            if (request.IsHidden.HasValue)
            {
                var val = request.IsHidden.Value;

                result = result.Where(i =>
                {
                    var isHidden = false;

                    var configurableTask = i.ScheduledTask as IConfigurableScheduledTask;

                    if (configurableTask != null)
                    {
                        isHidden = configurableTask.IsHidden;
                    }

                    return(isHidden == val);
                });
            }

            var infos = result
                        .Select(ScheduledTaskHelpers.GetTaskInfo)
                        .ToList();

            return(ToOptimizedResult(infos));
        }
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>IEnumerable{TaskInfo}.</returns>
        public object Get(GetScheduledTasks request)
        {
            var result = TaskManager.ScheduledTasks.OrderBy(i => i.Name)
                         .Select(ScheduledTaskHelpers.GetTaskInfo).ToList();

            return(ToOptimizedResult(result));
        }
Пример #3
0
        /// <summary>
        /// Gets the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>IEnumerable{TaskInfo}.</returns>
        public object Get(GetScheduledTasks request)
        {
            IEnumerable <IScheduledTaskWorker> result = _taskManager.ScheduledTasks
                                                        .OrderBy(i => i.Name);

            if (request.IsHidden.HasValue)
            {
                var val = request.IsHidden.Value;

                result = result.Where(i =>
                {
                    var isHidden = false;

                    if (i.ScheduledTask is IConfigurableScheduledTask configurableTask)
                    {
                        isHidden = configurableTask.IsHidden;
                    }

                    return(isHidden == val);
                });
            }

            if (request.IsEnabled.HasValue)
            {
                var val = request.IsEnabled.Value;

                result = result.Where(i =>
                {
                    var isEnabled = true;

                    if (i.ScheduledTask is IConfigurableScheduledTask configurableTask)
                    {
                        isEnabled = configurableTask.IsEnabled;
                    }

                    return(isEnabled == val);
                });
            }

            var infos = result
                        .Select(ScheduledTaskHelpers.GetTaskInfo)
                        .ToArray();

            return(ToOptimizedResult(infos));
        }