/// <summary> /// コンストラクタ /// </summary> /// <param name="maxDegreeOfParallelism">APIコールの最大同時実行数</param> public BuffettCodeAPI(int maxDegreeOfParallelism) { client = new BuffettCodeClientV2(); resolver = APIResolverFactory.Create(); cache = new CacheStore(); processor = new SemaphoreTaskProcessor <string>(maxDegreeOfParallelism); }
public PlayerEntity( int x, int y, IGameState gameState, ITaskProcessor taskProcessor, IToolset toolset) : base( EntityType.Player, x, y, MapLayer.Player, new[] { EntityProperty.PointIsBusy, EntityProperty.StopLazerRay }) { Condition.Requires(gameState, nameof(gameState)).IsNotNull(); Condition.Requires(taskProcessor, nameof(taskProcessor)).IsNotNull(); Condition.Requires(toolset, nameof(toolset)).IsNotNull(); this._state = PlayerState.Live; this._gameState = gameState; this._taskProcessor = taskProcessor; this._toolset = toolset; }
/// <summary> /// Create handler /// </summary> /// <param name="discovery"></param> /// <param name="processor"></param> /// <param name="logger"></param> public DiscoveryRequestHandler(IDiscoveryServices discovery, ITaskProcessor processor, ILogger logger) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _discovery = discovery ?? throw new ArgumentNullException(nameof(discovery)); _processor = processor ?? throw new ArgumentNullException(nameof(processor)); }
public EntityFactory( IGameState gameState, IMap map, ITaskProcessor taskProcessor, IToolset toolset) { Condition.Requires(gameState, nameof(gameState)).IsNotNull(); Condition.Requires(map, nameof(map)).IsNotNull(); Condition.Requires(taskProcessor, nameof(taskProcessor)).IsNotNull(); Condition.Requires(toolset, nameof(toolset)).IsNotNull(); this._gameState = gameState; this._map = map; this._taskProcessor = taskProcessor; this._toolset = toolset; this._types = new Dictionary <EntityType, Type> { { EntityType.Finish, typeof(GroundEntities.FinishEntity) }, { EntityType.Ground, typeof(GroundEntities.GroundEntity) }, { EntityType.Wall, typeof(GroundEntities.WallEntity) }, { EntityType.PlayerMover, typeof(PlayerMoverEntity) }, { EntityType.ToolsetSelector, typeof(ToolsetSelectorEntity) }, { EntityType.Torch, typeof(TorchEntity) }, { EntityType.RotateToLeft, typeof(RotateToLeftEntity) }, { EntityType.RotateToRight, typeof(RotateToRightEntity) }, }; }
public LazerEntity( int x, int y, LazerDirection glowDirection, IMap map, ITaskProcessor taskProcessor) : base( EntityType.Lazer, x, y, MapLayer.PlayerBody, new[] { EntityProperty.PointIsBusy, EntityProperty.StopLazerRay }) { Condition.Requires(map, nameof(map)).IsNotNull(); Condition.Requires(taskProcessor, nameof(taskProcessor)).IsNotNull(); this._map = map; this._taskProcessor = taskProcessor; this.GlowDirection = glowDirection; this.State = LazerState.Works; }
static void Main(string[] args) { logger.Info($"TaskProcessor Started..."); var databaseName = ConfigurationManager.AppSettings["databaseName"]; var client = new MongoClient(); var mongoDB = client.GetDatabase(databaseName); logger.Info($"Connected to {databaseName}"); var tasksRepo = new ServerTasksRepository(mongoDB); List <ServerTask> tasks = tasksRepo.GetEntitiesByExpression(t => t.Status != ServerTask.TaskStatus.Completed).ToList(); logger.Info($"Retrived {tasks.Count} to process"); foreach (var task in tasks) { try { logger.Info($"Process\n{task}"); ITaskProcessor processor = TaskProcessorFactory.GetTaskProcessor(task.Type, mongoDB); processor.ProcessTask(task); } catch (Exception e) { logger.Error($"{e}"); } } logger.Info($"TaskProcessor Finished..."); }
public FireEntity( int x, int y, IEntityFactory entityFactory, IMap map, ITaskProcessor taskProcessor) : base( EntityType.Fire, x, y, MapLayer.PlayerBody) { Condition.Requires(map, nameof(map)).IsNotNull(); Condition.Requires(taskProcessor, nameof(taskProcessor)).IsNotNull(); var mapPoint = map.At(this.X, this.Y); taskProcessor.Add( new BombMapPointTask(mapPoint)); taskProcessor.Add( new RemoveEntityFromMapTask( this, map, delayInMilliseconds: 300)); }
/// <summary> /// Create listener /// </summary> /// <param name="events"></param> /// <param name="processor"></param> /// <param name="serializer"></param> /// <param name="logger"></param> public ProgressPublisher(IEventEmitter events, ITaskProcessor processor, IJsonSerializer serializer, ILogger logger) : base(logger) { _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); _events = events ?? throw new ArgumentNullException(nameof(events)); _processor = processor ?? throw new ArgumentNullException(nameof(processor)); }
public Game( // Game objects: IGameState gameState, IMap map, IToolset toolset, // Processors: IDrawMapProcessor drawMapProcessor, IDrawToolsetProcessor drawToolsetProcessor, ITaskProcessor taskProcessor, // Settings: IDrawSettings drawSettings, IEntityFactory entityFactory, ILevelBuilder levelBuilder) { #region Arguments Validation Condition.Requires(gameState, nameof(gameState)).IsNotNull(); Condition.Requires(map, nameof(map)).IsNotNull(); Condition.Requires(toolset, nameof(toolset)).IsNotNull(); Condition.Requires(drawMapProcessor, nameof(drawMapProcessor)).IsNotNull(); Condition.Requires(drawToolsetProcessor, nameof(drawToolsetProcessor)).IsNotNull(); Condition.Requires(taskProcessor, nameof(taskProcessor)).IsNotNull(); Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull(); Condition.Requires(entityFactory, nameof(entityFactory)).IsNotNull(); Condition.Requires(levelBuilder, nameof(levelBuilder)).IsNotNull(); #endregion Arguments Validation this._levelBuilder = levelBuilder; this._state = gameState; this._map = map; this._toolset = toolset; this._drawMapProcessor = drawMapProcessor; this._drawToolsetProcessor = drawToolsetProcessor; this._taskProcessor = taskProcessor; this._gameProcessorsBasket = new GameProcessorsBasket( this._state, this._map, this._toolset); this.MapLeftButtonMouseController = new MapLeftButtonMouseController( drawSettings, entityFactory, this._map, this._taskProcessor, this._toolset); this.MapRightButtonMouseController = new MapRightButtonMouseController( this._toolset); this.ToolsLeftButtonMouseController = new ToolsLeftButtonMouseController( drawSettings, this._toolset); }
private void UpdateSessionTasks() { var session = gameData.GetSession(sessionToken.SessionId); var characters = gameData.GetSessionCharacters(session); var villageProcessor = GetTaskProcessor(VillageProcessorName); villageProcessor.Handle(integrityChecker, gameData, session, null, null); foreach (var character in characters) { var state = gameData.GetState(character.StateId); if (state == null) { continue; } if (state.InArena || state.InRaid || state.Island == "War" || !string.IsNullOrEmpty(state.DuelOpponent)) { continue; } ITaskProcessor taskProcessor = GetTaskProcessor(state.Task); if (taskProcessor != null) { taskProcessor.Handle(integrityChecker, gameData, session, character, state); } } }
/// <summary> /// Create listener /// </summary> /// <param name="logger"></param> /// <param name="events"></param> /// <param name="processor"></param> public DiscoveryMessagePublisher(ILogger logger, IEventEmitter events, ITaskProcessor processor) : base(logger) { _events = events ?? throw new ArgumentNullException(nameof(events)); _processor = processor ?? throw new ArgumentNullException(nameof(processor)); _supervisorId = SupervisorModelEx.CreateSupervisorId(_events.DeviceId, _events.ModuleId); }
public TaskSchedulerService(ISettingService setting, ILogger <TaskSchedulerService> logger, ITaskProcessor taskProcessor, IBackgroundTaskQueue backgroundTaskQueue) { _setting = setting; _logger = logger; _taskProcessor = taskProcessor; _backgroundTaskQueue = backgroundTaskQueue; }
/// <summary> /// Removes a processor from the list of active processors /// </summary> /// <param name="processor">a processor that is being stopped</param> internal void UnRegisterProcessor(ITaskProcessor processor) { lock (processors) { processors.Remove(processor); ((IDisposable)processor).Dispose(); } }
/// <summary> /// /// </summary> /// <param name="current"></param> /// <returns></returns> private ITaskProcessor GetTaskProcessor(ITask current) { IDevice device = current.Device; IDPU dpu = device.Dpu; ITaskProcessor processor = dpu.Processor; return(processor); }
/// <summary> /// Create broker /// </summary> /// <param name="bus"></param> /// <param name="processor"></param> public GatewayEventBroker(IEventBus bus, ITaskProcessor processor = null) { _processor = processor; _listeners = new ConcurrentDictionary <string, IGatewayRegistryListener>(); _listeners.TryAdd("v2", new Events.v2.GatewayEventBusPublisher(bus)); // ... }
/// <summary> /// Create broker /// </summary> /// <param name="bus"></param> /// <param name="processor"></param> public CertificateRequestEventBroker(IEventBus bus, ITaskProcessor processor = null) { _processor = processor; _listeners = new ConcurrentDictionary <string, ICertificateRequestListener>(); _listeners.TryAdd("v2", new v2.CertificateRequestEventPublisher(bus)); // ... }
/// <summary> /// Create services /// </summary> /// <param name="client"></param> /// <param name="events"></param> /// <param name="processor"></param> /// <param name="listener"></param> /// <param name="logger"></param> public DiscoveryServices(IEndpointDiscovery client, IEventEmitter events, ITaskProcessor processor, ILogger logger, IDiscoveryListener listener = null) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _client = client ?? throw new ArgumentNullException(nameof(client)); _events = events ?? throw new ArgumentNullException(nameof(events)); _processor = processor ?? throw new ArgumentNullException(nameof(processor)); _listener = listener ?? new DiscoveryLogger(_logger); }
public static void Run() { for (int i = 0; i < Hallocation.ProduceCount; i += 1) { Spider spider = new Spider(i); Spiders.Add(spider); } for (int i = 0; i < Hallocation.ProduceCount; i += 1) { Spider spider = Spiders[i]; ThreadPool.QueueUserWorkItem((obj => { #if DEBUG Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("[Runner]\t{0}号蜘蛛被唤醒\r\n", spider.Index); #endif spider.Start(); })); } ThreadPool.QueueUserWorkItem((obj) => { CheckEnd(); }); for (int i = 0; i < Hallocation.CustomerCount; i += 1) { int j = i; ThreadPool.QueueUserWorkItem((obj) => { while (true) { SpiderTask task = GetResult(); if (task == null) { Thread.Sleep(400); continue; } #if DEBUG Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("[Executor]\t拿到结果并交给{0}来处理\r\n", task.ProcessorKey); #endif if (!String.IsNullOrEmpty(task.FilterKey)) { ITaskFilter filter = Filters[task.FilterKey]; filter.Run(task); } if (!String.IsNullOrEmpty(task.ProcessorKey)) { ITaskProcessor processor = Processors[task.ProcessorKey]; processor.Run(task); } PostTask(task); } }); } }
public void Configuration(IAppBuilder app) { var Container = new ContainerBuilder(); Container.RegisterAssemblyModules(typeof(MvcApplication).Assembly); var iContainer = Container.Build(); app.UseHangfireDashboard(); app.UseHangfireServer(); taskProcessor = iContainer.Resolve<ITaskProcessor>(); }
/// <summary> /// Initializes a new instance of the <see cref="ReminderController"/> class. /// </summary> /// <param name="reminderRepository"> /// The reminder repository. /// </param> /// <param name="userRepository"> /// The user repository. /// </param> /// <param name="taskProcessor"> /// The task processor. /// </param> public ReminderController( IReminderRepository reminderRepository, IUserRepository userRepository, ITaskProcessor taskProcessor, IReminderProcessor reminderProcessor) { this.reminderRepository = reminderRepository; this.userRepository = userRepository; this.taskProcessor = taskProcessor; this.reminderProcessor = reminderProcessor; }
/// <summary> /// Checks whether the given taskProcessor is alive and takes appropriate actions if the processor is corrupted /// </summary> /// <param name="processor"></param> public void WatchProcessor(ITaskProcessor processor) { if (processor.State == TaskProcessorState.Running) { WatchProcessorInstance(processor); } else { LogEnvironment.LogDebugEvent($"Skipping Worker in {processor.State} state.", LogSeverity.Warning); } }
public LandingController(IProjectRepository projectRepository, IUserRepository userRepository, ITaskProcessor taskProcessor, IStringExtensions stringExtensions, IProjectProcessor projectProcessor, INotifier notifier, INewsProcessor newsProcessor) { this.projectRepository = projectRepository; this.userRepository = userRepository; this.taskProcessor = taskProcessor; this.stringExtensions = stringExtensions; this.projectProcessor = projectProcessor; this.notifier = notifier; this.newsProcessor = newsProcessor; }
public ServiceBusConsumer(ITaskProcessor taskProcessor, IOptions <AzureServiceBusConfiguration> asureServiceBusOptions, ILogger <ServiceBusConsumer> logger) { _dataProcessor = taskProcessor; _logger = logger; var connectionString = asureServiceBusOptions.Value.ConnectionString; var queueName = asureServiceBusOptions.Value.QueueName; _queueClient = new QueueClient(connectionString, queueName); }
/// <summary> /// Initializes a new instance of the <see cref="QuickTaskController"/> class. /// </summary> /// <param name="userProcessor"> /// The user processor. /// </param> /// <param name="taskProcessor"> /// The task processor. /// </param> /// <param name="notifier"> /// The notifier. /// </param> /// <param name="newsProcessor"> /// The news processor. /// </param> /// <param name="stringExtensions"> /// The string extensions. /// </param> public QuickTaskController( IUserProcessor userProcessor, ITaskProcessor taskProcessor, INotifier notifier, INewsProcessor newsProcessor, IStringExtensions stringExtensions) { this.userProcessor = userProcessor; this.taskProcessor = taskProcessor; this.notifier = notifier; this.newsProcessor = newsProcessor; this.stringExtensions = stringExtensions; }
public static ITaskProcessor GetTaskProcessor(ServerTask.TaskType taskType, IMongoDatabase database) { ITaskProcessor taskProcessor = null; switch (taskType) { case ServerTask.TaskType.UserUpdated: taskProcessor = new UserUpdatedProcessor(database); break; default: throw new Exception("Unknown task Type"); } return(taskProcessor); }
public dynamic InvokeMethodByReflection(string fullddlNamePath, string type, string method, IDictionary <string, object> taskParameters) { dynamic jsonResponse = null; Assembly assembly = Assembly.LoadFrom(@"C:\Workspace\Projects\trunk\Application\DataLake\WorkFlowSubscriber\bin\Debug\WorkFlowCommon.dll"); Type assemblyGetType = assembly.GetType(type); if (assemblyGetType.IsAssignableFrom(assemblyGetType)) { ITaskProcessor taskProcessor = (ITaskProcessor)Activator.CreateInstance(assemblyGetType); jsonResponse = taskProcessor.ExecuteTask(taskParameters); } return(jsonResponse); }
public MapLeftButtonMouseController( IDrawSettings drawSettings, IEntityFactory entityFactory, IMap map, ITaskProcessor taskProcessor, IToolset toolset) { Condition.Requires(drawSettings, nameof(drawSettings)).IsNotNull(); Condition.Requires(entityFactory, nameof(entityFactory)).IsNotNull(); Condition.Requires(map, nameof(map)).IsNotNull(); Condition.Requires(taskProcessor, nameof(taskProcessor)).IsNotNull(); Condition.Requires(toolset, nameof(toolset)).IsNotNull(); this._drawSettings = drawSettings; this._entityFactory = entityFactory; this._map = map; this._taskProcessor = taskProcessor; this._toolset = toolset; }
/// <summary> /// Checks whether the given taskProcessor is alive and takes appropriate actions if the processor is corrupted /// </summary> /// <param name="processor">the processor that is being watched</param> protected override void WatchProcessorInstance(ITaskProcessor processor) { if (DateTime.Now.Subtract(processor.LastActivity).TotalMilliseconds > timeout) { bool statusFixed = false; var currentTask = processor.Worker.CurrentTask; if (UseRestart) { try { RestartProcessor(processor, ResetWorker); statusFixed = true; } catch (Exception ex) { LogEnvironment.LogEvent($"Restart of processor has failed: {ex.OutlineException()}", LogSeverity.Error); processor.Zombie(); } } if (!statusFixed && UseKill) { try { KillProcessor(processor, ReCreateOnKill); statusFixed = true; } catch (Exception ex) { LogEnvironment.LogEvent($"Kill of processor has failed: {ex.OutlineException()}", LogSeverity.Error); processor.Zombie(); } } HandleFailedTask(currentTask); if (!statusFixed) { LogEnvironment.LogDebugEvent("Processorstatus could not be fixed. Requesting application-shutdown...", LogSeverity.Error); Critical(); } } }
/// <summary> /// Kills the thread that is used by the processor and starts a new one /// </summary> /// <param name="processor">the processor on which to stop the worker-thread</param> /// <param name="resetWorker">indicates whether to re-set the used worker</param> protected void RestartProcessor(ITaskProcessor processor, bool resetWorker) { LogEnvironment.LogEvent($"Restarting WorkerThread of ParallelTaskProcessor {processor.Parent.Identifier}", LogSeverity.Warning); if (!(processor.Worker.CurrentTask?.ExecutingUnsafe ?? false)) { processor.KillThread(); if (resetWorker) { LogEnvironment.LogDebugEvent($"Resetting Worker-Instsance of ParallelTaskProcessor {processor.Parent.Identifier}", LogSeverity.Warning); processor.Worker.Reset(); } processor.StartupThread(); } else { LogEnvironment.LogDebugEvent($"The WorkerThread of ParallelTaskProcessor {processor.Parent.Identifier} is executing unsafe code. Processor can not be restarted.", LogSeverity.Error); throw new InvalidOperationException($"The WorkerThread of ParallelTaskProcessor {processor.Parent.Identifier} is executing unsafe code. Processor can not be restarted."); } }
/// <summary> /// Kills the given taskProcessor instance /// </summary> /// <param name="processor">the processor to kill</param> /// <param name="createNew">indicates whether to re-create the processor</param> protected void KillProcessor(ITaskProcessor processor, bool createNew) { LogEnvironment.LogEvent($"Killing a Worker-Thread of ParallelTaskProcessor {processor.Parent.Identifier}. {(!createNew?"Consider restarting the application soon. This action will cause the ParallelTaskProcessor to run with reduced capacity.":"")}", LogSeverity.Warning); if (!(processor.Worker.CurrentTask?.ExecutingUnsafe ?? false)) { processor.KillThread(); processor.Worker.Quit(); var parent = processor.Parent; parent.UnRegisterProcessor(processor); if (createNew) { LogEnvironment.LogDebugEvent($"Creating a new Worker-Thread for ParallelTaskProcessor {processor.Parent.Identifier}", LogSeverity.Warning); parent.CreateProcessor(processor.LowestPriority); } } else { LogEnvironment.LogDebugEvent($"The WorkerThread of ParallelTaskProcessor {processor.Parent.Identifier} is executing unsafe code. Processor can not be killed.", LogSeverity.Error); throw new InvalidOperationException($"The WorkerThread of ParallelTaskProcessor {processor.Parent.Identifier} is executing unsafe code. Processor can not be killed."); } }
public BombEntity( int x, int y, IEntityFactory entityFactory, IMap map, ITaskProcessor taskProcessor) : base( EntityType.Bomb, x, y, MapLayer.PlayerFeets, EntityProperty.PointIsBusy) { Condition.Requires(entityFactory, nameof(entityFactory)).IsNotNull(); Condition.Requires(map, nameof(map)).IsNotNull(); Condition.Requires(taskProcessor, nameof(taskProcessor)).IsNotNull(); this._entityFactory = entityFactory; this._map = map; this._taskProcessor = taskProcessor; this.State = BombState.Normal; }
public UserProcessor(IUserRepository userRepository, ICryptoProvider cryptoProvider, ITaskProcessor taskProcessor) { this.userRepository = userRepository; this.cryptoProvider = cryptoProvider; this.taskProcessor = taskProcessor; }
public void Teardown() { Processor = null; }
public void Setup() { Processor = new SequentialTaskProcessor<ITask>(new DependencyIgnoringStrategy()); }
public HumanTasksController(ITaskProcessor iTaskProcessor, IEmployeeRepository iEmployeeRepository) { this.iTaskProcessor = iTaskProcessor; this.iEmployeeRepository = iEmployeeRepository; }
protected virtual SchedulePostProcessingAction ProcessLocalServiceSource(ScheduledItem scheduledItem, Activity activity, string transactionId) { DataService dataService = ServiceManager.ValidateDataService(scheduledItem.SourceId, ServiceType.QueryOrSolicitOrExecuteOrTask); // Load the service plugin ISolicitProcessor solicitPlugin = null; IQueryProcessor queryPlugin = null; IExecuteProcessor executePlugin = null; ITaskProcessor taskPlugin = null; IPluginDisposer disposer; string flowName = FlowManager.GetDataFlowNameById(dataService.FlowId); RequestType requestType; SchedulePostProcessingAction postProcessingAction = SchedulePostProcessingAction.ContinueNormally; try { if ((dataService.Type & ServiceType.Task) == ServiceType.Task) { disposer = PluginLoader.LoadTaskProcessor(dataService, out taskPlugin); requestType = RequestType.Task; } else if ((dataService.Type & ServiceType.Execute) == ServiceType.Execute) { disposer = PluginLoader.LoadExecuteProcessor(dataService, out executePlugin); requestType = RequestType.Execute; } else if ((dataService.Type & ServiceType.Solicit) == ServiceType.Solicit) { disposer = PluginLoader.LoadSolicitProcessor(dataService, out solicitPlugin); requestType = RequestType.Solicit; } else { disposer = PluginLoader.LoadQueryProcessor(dataService, out queryPlugin); requestType = RequestType.Query; } } catch (Exception e) { throw new NotImplementedException(string.Format("Failed to load the service \"{0}\" for the scheduled item \"{1}\"", dataService.Name, scheduledItem.Name), e); } using (disposer) { string requestId = RequestManager.CreateDataRequest(transactionId, dataService.Id, 0, -1, requestType, activity.ModifiedById, scheduledItem.SourceArgs); if (taskPlugin != null) { LogActivity(activity, "Calling ProcessTask()"); try { ITaskProcessorEx taskPluginEx = taskPlugin as ITaskProcessorEx; if (taskPluginEx != null) { postProcessingAction = taskPluginEx.ProcessTask(requestId, scheduledItem.Id); } else { taskPlugin.ProcessTask(requestId); } } finally { activity.Append(taskPlugin.GetAuditLogEvents()); } LogActivity(activity, "Called ProcessTask()"); } else if (executePlugin != null) { LogActivity(activity, "Calling ProcessExecute()"); ExecuteContentResult result; try { result = executePlugin.ProcessExecute(requestId); } finally { activity.Append(executePlugin.GetAuditLogEvents()); } if (result.Content != null) { _documentManager.AddDocument(transactionId, result); } LogActivity(activity, "Called ProcessExecute()"); } else if (solicitPlugin != null) { LogActivity(activity, "Calling ProcessSolicit()"); try { solicitPlugin.ProcessSolicit(requestId); } finally { activity.Append(solicitPlugin.GetAuditLogEvents()); } LogActivity(activity, "Called ProcessSolicit()"); } else { LogActivity(activity, "Calling ProcessQuery()"); PaginatedContentResult result; try { result = queryPlugin.ProcessQuery(requestId); } finally { activity.Append(queryPlugin.GetAuditLogEvents()); } LogActivity(activity, "Called ProcessQuery()"); } } return(postProcessingAction); }
public virtual IPluginDisposer LoadTaskProcessor(DataService inDataService, out ITaskProcessor plugin) { return(LoadPluginInterface <ITaskProcessor>(inDataService, out plugin)); }
/// <summary> /// Initializes a new instance of the <see cref="HumanTasksController"/> class. /// </summary> /// <param name="taskProcessor"> /// The task processor. /// </param> /// <param name="userProcessor"> /// The user processor. /// </param> /// <param name="userRepository"> /// The user Repository. /// </param> public HumanTasksController(ITaskProcessor taskProcessor, IUserProcessor userProcessor, IUserRepository userRepository) { this.taskProcessor = taskProcessor; this.userProcessor = userProcessor; this.userRepository = userRepository; }
/// <summary> /// Initializes a new instance of the <see cref="HumanTasksController"/> class. /// </summary> /// <param name="taskProcessor">The task processor.</param> /// <param name="employeeRepository">The employee repository.</param> public HumanTasksController(ITaskProcessor taskProcessor, IEmployeeRepository employeeRepository, IUserProcessor userProcessor) { this.taskProcessor = taskProcessor; this.employeeRepository = employeeRepository; this.userProcessor = userProcessor; }
public override object Accept(ITaskProcessor processor) { if(processor == null) return null; return processor.Process(this); }
/// <summary> /// Initializes a new instance of the <see cref="HumanTasksController"/> class. /// </summary> /// <param name="taskProcessor">The task processor.</param> /// <param name="employeeRepository">The employee repository.</param> public HumanTasksController(ITaskProcessor taskProcessor, IEmployeeRepository employeeRepository) { this.taskProcessor = taskProcessor; this.employeeRepository = employeeRepository; }
/// <summary> /// /// </summary> /// <param name="current"></param> private void DoCurrentTask(ITask current) { TaskStatus status = current.Check(); switch (status) { case TaskStatus.Ready: { ICommuniPort cp = GetCommuniPort(current); if ((cp != null) && (!cp.IsOccupy)) //IsHighestLevel(headTask, cp)) { current.Begin(cp); } } break; case TaskStatus.Executing: break; case TaskStatus.Timeout: { ICommuniPort cp = GetCommuniPort(current); current.End(cp); DoCurrentTask(current); } break; case TaskStatus.Executed: { IParseResult pr = current.LastParseResult; ITaskProcessor processor = GetTaskProcessor(current); processor.Process(current, pr); DoCurrentTask(current); } break; case TaskStatus.Wating: { //ClearDeviceCurrentTask(current); //IDevice device = current.Device; //device.TaskManager.Tasks.Enqueue(current); TaskManager taskMan = current.Device.TaskManager; taskMan.ReleaseCurrent(); } break; case TaskStatus.Completed: { // clear current task // // current may not equal to current.Device.TaskManager.Current // so an other executing task will be remove // //ClearDeviceCurrentTask(current); TaskManager taskMan = current.Device.TaskManager; taskMan.ReleaseCurrent(); } break; default: { // // clear // throw new NotSupportedException(status.ToString()); } } #if DEBUG if (current.Strategy is CycleStrategy) { if (current.Device.TaskManager.Current == null) { bool b = current.Device.TaskManager.Tasks.Contains(current); Debug.Assert(b == true); } } #endif }
/// <summary> /// Initializes a new instance of the <see cref="ProjectController"/> class. /// </summary> /// <param name="taskProcessor"> /// The task processor. /// </param> /// <param name="userProcessor"> /// The user processor. /// </param> /// <param name="projectProcessor"> /// The project processor. /// </param> /// <param name="notifier"> /// The notifier. /// </param> /// <param name="newsProcessor"> /// The news processor. /// </param> /// <param name="stringExtensions"> /// The string extensions. /// </param> /// <param name="reminderProcessor"> /// The reminder processor. /// </param> public ProjectController(ITaskProcessor taskProcessor, IUserProcessor userProcessor, IProjectProcessor projectProcessor, INotifier notifier, INewsProcessor newsProcessor, IStringExtensions stringExtensions, IReminderProcessor reminderProcessor) { this.projectProcessor = projectProcessor; this.notifier = notifier; this.taskProcessor = taskProcessor; this.userProcessor = userProcessor; this.newsProcessor = newsProcessor; this.stringExtensions = stringExtensions; this.reminderProcessor = reminderProcessor; }
public abstract object Accept(ITaskProcessor processor);