예제 #1
0
        /// <summary>
        /// Initializes the task manager with the property values specified in the configuration file.
        /// </summary>
        public void Initialize()
        {
            this._taskThreads.Clear();

            var taskService   = EngineContext.Current.Resolve <IScheduleTaskService>();
            var scheduleTasks = taskService
                                .GetAllTasks()
                                .OrderBy(x => x.Seconds)
                                .ToList();

            var eventPublisher = EngineContext.Current.Resolve <IEventPublisher>();

            eventPublisher.Publish(new AppInitScheduledTasksEvent {
                ScheduledTasks = scheduleTasks
            });

            // group by threads with the same seconds
            foreach (var scheduleTaskGrouped in scheduleTasks.GroupBy(x => x.Seconds))
            {
                // create a thread
                var taskThread = new TaskThread();
                taskThread.Seconds = scheduleTaskGrouped.Key;

                foreach (var scheduleTask in scheduleTaskGrouped)
                {
                    var taskType = System.Type.GetType(scheduleTask.Type);
                    if (taskType != null)
                    {
                        var isActiveModule = PluginManager.IsActivePluginAssembly(taskType.Assembly);
                        if (isActiveModule)
                        {
                            var task = new Job(scheduleTask);
                            taskThread.AddJob(task);
                        }
                    }
                }

                if (taskThread.HasJobs)
                {
                    this._taskThreads.Add(taskThread);
                }
            }


            //one thread, one task
            //foreach (var scheduleTask in scheduleTasks)
            //{
            //    var taskThread = new TaskThread(scheduleTask);
            //    this._taskThreads.Add(taskThread);
            //    var task = new Task(scheduleTask);
            //    taskThread.AddTask(task);
            //}
        }
예제 #2
0
        /// <summary>
        /// Initializes the task manager with the property values specified in the configuration file.
        /// </summary>
        public void Initialize()
        {
            this._taskThreads.Clear();

            var taskService = EngineContext.Current.Resolve<IScheduleTaskService>();
            var scheduleTasks = taskService
                .GetAllTasks()
                .OrderBy(x => x.Seconds)
                .ToList();

            var eventPublisher = EngineContext.Current.Resolve<IEventPublisher>();
            eventPublisher.Publish(new AppInitScheduledTasksEvent {
                ScheduledTasks = scheduleTasks
            });

            // group by threads with the same seconds
            foreach (var scheduleTaskGrouped in scheduleTasks.GroupBy(x => x.Seconds))
            {
                // create a thread
                var taskThread = new TaskThread();
                taskThread.Seconds = scheduleTaskGrouped.Key;

                foreach (var scheduleTask in scheduleTaskGrouped)
                {
                    var taskType = System.Type.GetType(scheduleTask.Type);
                    if (taskType != null)
                    {
                        var isActiveModule = PluginManager.IsActivePluginAssembly(taskType.Assembly);
                        if (isActiveModule)
                        {
                            var task = new Job(scheduleTask);
                            taskThread.AddJob(task);
                        }
                    }
                }

                if (taskThread.HasJobs)
                {
                    this._taskThreads.Add(taskThread);
                }
            }

            //one thread, one task
            //foreach (var scheduleTask in scheduleTasks)
            //{
            //    var taskThread = new TaskThread(scheduleTask);
            //    this._taskThreads.Add(taskThread);
            //    var task = new Task(scheduleTask);
            //    taskThread.AddTask(task);
            //}
        }
예제 #3
0
        /// <summary>
        /// Initializes the task manager with the property values specified in the configuration file.
        /// </summary>
        public void Initialize()
        {
            this._taskThreads.Clear();

            var taskService   = EngineContext.Current.Resolve <IScheduleTaskService>();
            var scheduleTasks = taskService
                                .GetAllTasks()
                                .OrderBy(x => x.Seconds)
                                .ToList();

            // codehint: sm-add
            var eventPublisher = EngineContext.Current.Resolve <IEventPublisher>();

            eventPublisher.Publish(new AppInitScheduledTasksEvent {
                ScheduledTasks = scheduleTasks
            });

            //group by threads with the same seconds
            foreach (var scheduleTaskGrouped in scheduleTasks.GroupBy(x => x.Seconds))
            {
                //create a thread
                var taskThread = new TaskThread();
                taskThread.Seconds = scheduleTaskGrouped.Key;
                this._taskThreads.Add(taskThread);
                foreach (var scheduleTask in scheduleTaskGrouped)
                {
                    var task = new Task(scheduleTask);
                    taskThread.AddTask(task);
                }
            }


            //one thread, one task
            //foreach (var scheduleTask in scheduleTasks)
            //{
            //    var taskThread = new TaskThread(scheduleTask);
            //    this._taskThreads.Add(taskThread);
            //    var task = new Task(scheduleTask);
            //    taskThread.AddTask(task);
            //}
        }
예제 #4
0
        /// <summary>
        /// Initializes the task manager with the property values specified in the configuration file.
        /// </summary>
        public void Initialize()
        {
            this._taskThreads.Clear();

            var taskService = EngineContext.Current.Resolve<IScheduleTaskService>();
            var scheduleTasks = taskService
                .GetAllTasks()
                .OrderBy(x => x.Seconds)
                .ToList();

			// codehint: sm-add
			var eventPublisher = EngineContext.Current.Resolve<IEventPublisher>();
			eventPublisher.Publish(new AppInitScheduledTasksEvent {
				ScheduledTasks = scheduleTasks
			});

            //group by threads with the same seconds
            foreach (var scheduleTaskGrouped in scheduleTasks.GroupBy(x => x.Seconds))
            {
                //create a thread
                var taskThread = new TaskThread();
                taskThread.Seconds = scheduleTaskGrouped.Key;
                this._taskThreads.Add(taskThread);
                foreach (var scheduleTask in scheduleTaskGrouped)
                {
                    var task = new Task(scheduleTask);
                    taskThread.AddTask(task);
                }
            }


            //one thread, one task
            //foreach (var scheduleTask in scheduleTasks)
            //{
            //    var taskThread = new TaskThread(scheduleTask);
            //    this._taskThreads.Add(taskThread);
            //    var task = new Task(scheduleTask);
            //    taskThread.AddTask(task);
            //}
        }