コード例 #1
0
ファイル: MazeTaskWriter.cs プロジェクト: 5l1v3r1/Maze-1
        public MazeTaskWriter(XmlWriter xmlWriter, ITaskComponentResolver componentResolver, IXmlSerializerCache serializerCache)
        {
            _xmlWriter         = xmlWriter;
            _componentResolver = componentResolver;
            _serializerCache   = serializerCache;

            _namespaces = new XmlSerializerNamespaces();
            _namespaces.Add(string.Empty, string.Empty);
        }
コード例 #2
0
 public CommandExecutionManager(IRestClient restClient, ITaskComponentResolver taskComponentResolver, IXmlSerializerCache xmlSerializerCache,
                                IServiceProvider serviceProvider)
 {
     _restClient            = restClient;
     _taskComponentResolver = taskComponentResolver;
     _xmlSerializerCache    = xmlSerializerCache;
     _serviceProvider       = serviceProvider;
     PendingCommands        = new ObservableCollection <PendingCommandViewModel>();
 }
コード例 #3
0
        public async Task <IActionResult> ExecuteTask([FromServices] ITaskComponentResolver taskComponentResolver,
                                                      [FromServices] IXmlSerializerCache serializerCache, [FromServices] IExecuteTaskAction executeTaskAction)
        {
            var reader = new MazeTaskReader(Request.Body, taskComponentResolver, serializerCache);
            var task   = reader.ReadTask();

            var result = await executeTaskAction.BizActionAsync(task);

            return(BizActionStatus(executeTaskAction, () => Ok(result)));
        }
コード例 #4
0
        public async Task <IActionResult> CreateOrUpdateTask([FromServices] ITaskComponentResolver taskComponentResolver,
                                                             [FromServices] IXmlSerializerCache serializerCache)
        {
            var mazeTask = new MazeTaskReader(Request.Body, taskComponentResolver, serializerCache);
            var task     = mazeTask.ReadTask();

            await _clientTaskManager.AddOrUpdateTask(task);

            return(Ok());
        }
コード例 #5
0
 public ExecuteTaskAction(IMazeTaskManagerManagement management, IConnectionManager connectionManager, AppDbContext dbContext,
                          ITaskComponentResolver taskComponentResolver, IXmlSerializerCache xmlSerializerCache, IHubContext <AdministrationHub> hubContext)
 {
     _management            = management;
     _connectionManager     = connectionManager;
     _dbContext             = dbContext;
     _taskComponentResolver = taskComponentResolver;
     _xmlSerializerCache    = xmlSerializerCache;
     _hubContext            = hubContext;
 }
コード例 #6
0
 public static async Task <MazeTask> FetchTaskAsync(Guid taskId, ITaskComponentResolver taskComponentResolver,
                                                    IXmlSerializerCache xmlSerializerCache, IRestClient restClient)
 {
     using (var response = await CreateRequest(HttpVerb.Get, taskId.ToString("N")).Execute(restClient))
         using (var stream = await response.Content.ReadAsStreamAsync())
         {
             var taskReader = new MazeTaskReader(stream, taskComponentResolver, xmlSerializerCache);
             return(taskReader.ReadTask());
         }
 }
コード例 #7
0
        public async Task <IActionResult> CreateTask([FromServices] ITaskComponentResolver taskComponentResolver,
                                                     [FromServices] IXmlSerializerCache serializerCache, [FromServices] ICreateTaskAction createTaskAction, [FromServices] IHubContext <AdministrationHub> hubContext)
        {
            var reader = new MazeTaskReader(Request.Body, taskComponentResolver, serializerCache);
            var task   = reader.ReadTask();

            await createTaskAction.BizActionAsync(task);

            return(await BizActionStatus(createTaskAction, async() =>
            {
                await hubContext.Clients.All.SendAsync(HubEventNames.TaskCreated, task.Id);
                return Ok();
            }));
        }
コード例 #8
0
        public static async Task <TaskSessionsInfo> ExecuteTask(MazeTask mazeTask, ITaskComponentResolver componentResolver,
                                                                IXmlSerializerCache xmlCache, IRestClient restClient)
        {
            using (var taskMemoryStream = new MemoryStream())
            {
                var taskWriter = new MazeTaskWriter(taskMemoryStream, componentResolver, xmlCache);
                taskWriter.Write(mazeTask, TaskDetails.Client);

                taskMemoryStream.Position = 0;

                var stream = new StreamContent(taskMemoryStream);
                stream.Headers.ContentEncoding.Add("xml");

                return(await CreateRequest(HttpVerb.Post, "execute", stream).Execute(restClient).Return <TaskSessionsInfo>());
            }
        }
コード例 #9
0
ファイル: TasksResource.cs プロジェクト: 5l1v3r1/Maze-1
        public static async Task Update(MazeTask mazeTask, ITaskComponentResolver componentResolver, IXmlSerializerCache xmlCache,
                                        IRestClient restClient)
        {
            using (var taskMemoryStream = new MemoryStream())
            {
                var taskWriter = new MazeTaskWriter(taskMemoryStream, componentResolver, xmlCache);
                taskWriter.Write(mazeTask, TaskDetails.Server);

                taskMemoryStream.Position = 0;

                var stream = new StreamContent(taskMemoryStream);
                stream.Headers.ContentEncoding.Add("xml");

                await CreateRequest(HttpVerb.Put, mazeTask.Id, stream).Execute(restClient);
            }
        }
コード例 #10
0
        public async Task <IActionResult> ExecuteTask([FromServices] ITaskComponentResolver taskComponentResolver,
                                                      [FromServices] IXmlSerializerCache serializerCache)
        {
            var mazeTask = new MazeTaskReader(Request.Body, taskComponentResolver, serializerCache);
            var task     = mazeTask.ReadTask();

            var memoryStorage = new MemoryTaskStorage();
            await _clientTaskManager.TriggerNow(task, SessionKey.Create("Execute"), memoryStorage);

            return(Ok(new TaskSessionsInfo
            {
                Sessions = memoryStorage.Sessions.Select(x => new TaskSessionDto
                {
                    TaskReferenceId = x.TaskReferenceId,
                    TaskSessionId = x.TaskSessionId,
                    Description = x.Description,
                    CreatedOn = x.CreatedOn
                }).ToList(),
                Executions = memoryStorage.Executions.Select(x => new TaskExecutionDto
                {
                    TaskExecutionId = x.TaskExecutionId,
                    TaskReferenceId = x.TaskReferenceId,
                    TaskSessionId = x.TaskSessionId,
                    CreatedOn = x.CreatedOn
                }).ToList(),
                Results = memoryStorage.CommandResults.Select(x => new CommandResultDto
                {
                    CommandResultId = x.CommandResultId,
                    TaskExecutionId = x.TaskExecutionId,
                    CommandName = x.CommandName,
                    Result = x.Result,
                    Status = x.Status,
                    FinishedAt = x.FinishedAt
                }).ToList()
            }));
        }
コード例 #11
0
 /// <summary>
 ///     Maze task file reader
 /// </summary>
 /// <param name="stream">Maze task file stream.</param>
 /// <param name="componentResolver">The service resolver used to resolve the task services</param>
 /// <param name="leaveStreamOpen">Leave the stream open</param>
 /// <param name="xmlSerializerCache">The xml serializer cache for deserialization</param>
 public MazeTaskReader(Stream stream, ITaskComponentResolver componentResolver, IXmlSerializerCache xmlSerializerCache, bool leaveStreamOpen)
     : base(stream, leaveStreamOpen)
 {
     _componentResolver  = componentResolver;
     _xmlSerializerCache = xmlSerializerCache;
 }
コード例 #12
0
 /// <summary>
 ///     Maze task file reader
 /// </summary>
 /// <param name="xml">Maze task file xml data.</param>
 /// <param name="componentResolver">The service resolver used to resolve the task services</param>
 /// <param name="xmlSerializerCache">The xml serializer cache for deserialization</param>
 public MazeTaskReader(XDocument xml, ITaskComponentResolver componentResolver, IXmlSerializerCache xmlSerializerCache) : base(xml)
 {
     _componentResolver  = componentResolver;
     _xmlSerializerCache = xmlSerializerCache;
 }
コード例 #13
0
 /// <summary>
 ///     Maze task file reader
 /// </summary>
 /// <param name="stream">Maze task file stream.</param>
 /// <param name="componentResolver">The service resolver used to resolve the task services</param>
 /// <param name="xmlSerializerCache">The xml serializer cache for deserialization</param>
 public MazeTaskReader(Stream stream, ITaskComponentResolver componentResolver, IXmlSerializerCache xmlSerializerCache) : this(stream,
                                                                                                                               componentResolver, xmlSerializerCache, false)
 {
 }
コード例 #14
0
 /// <summary>
 ///     Maze task file reader.
 /// </summary>
 public MazeTaskReader(string path, ITaskComponentResolver componentResolver, IXmlSerializerCache xmlSerializerCache) : base(path)
 {
     _componentResolver  = componentResolver;
     _xmlSerializerCache = xmlSerializerCache;
 }
コード例 #15
0
ファイル: MazeTaskWriter.cs プロジェクト: 5l1v3r1/Maze-1
 public MazeTaskWriter(Stream stream, ITaskComponentResolver componentResolver, IXmlSerializerCache serializerCache) : this(
         XmlWriter.Create(stream, new XmlWriterSettings { OmitXmlDeclaration = false, Indent = false }), componentResolver, serializerCache)
 {
 }