Пример #1
0
        //===================================================================== Hub API

        public async Task <SnTask> GetTask(string machineName, string agentName, string[] capabilities)
        {
            SnTrace.TaskManagement.Write("AgentHub GetTask called. Agent: {0}, capabilities: {1}.", agentName, string.Join(", ", capabilities));

            try
            {
                var task = await _dataHandler.GetNextAndLock(machineName, agentName, capabilities, Context.ConnectionAborted)
                           .ConfigureAwait(false);

                SnTrace.TaskManagement.Write("AgentHub TaskDataHandler.GetNextAndLock returned: " + (task == null ? "null" : "task " + task.Id));

                // task details are not passed to the monitor yet
                if (task != null)
                {
                    await _monitorHub.OnTaskEvent(SnTaskEvent.CreateStartedEvent(task.Id, task.Title, null,
                                                                                 task.AppId, task.Tag, machineName, agentName)).ConfigureAwait(false);
                }

                return(task);
            }
            catch (Exception ex)
            {
                SnLog.WriteException(ex, "AgentHub GetTask failed.", EventId.TaskManagement.General);
            }

            return(null);
        }
Пример #2
0
        //===================================================================== Hub API

        public SnTask GetTask(string machineName, string agentName, string[] capabilities)
        {
            SnTrace.TaskManagement.Write("AgentHub GetTask called. Agent: {0}, capabilities: {1}.", agentName, string.Join(", ", capabilities));

            try
            {
                var task = TaskDataHandler.GetNextAndLock(machineName, agentName, capabilities);
                SnTrace.TaskManagement.Write("AgentHub TaskDataHandler.GetNextAndLock returned with: " + (task == null ? "null" : "task " + task.Id.ToString()));

                // task details are not passed to the monitor yet
                if (task != null)
                {
                    TaskMonitorHub.OnTaskEvent(SnTaskEvent.CreateStartedEvent(task.Id, task.Title, null, task.AppId, task.Tag, machineName, agentName));
                }

                return(task);
            }
            catch (Exception ex)
            {
                SnLog.WriteException(ex, "AgentHub GetTask failed.", EventId.TaskManagement.General);
            }

            return(null);
        }