Exemple #1
0
        public async Task<IHttpActionResult> PostJob(Job Job)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var _job = await db.Jobs.FindAsync(Job.JobId);
            if (_job == null) BadRequest();

            _job.IsTerminated = true;
            _job.ResultTime = DateTime.Now;
            _job.OutputPlain = Job.OutputPlain;
            _job.OutputXml = Job.OutputXml;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                throw;
            }

            return CreatedAtRoute("DefaultApi", new { id = _job.JobId }, _job);
        }
Exemple #2
0
        public async Task<List<Job>> GetJob(Guid id)
        {
            Client client = await db.Clients.FindAsync(id);
            if (client == null) return null;

            /* initial protype command for testing purposes */
            var commandId = new Guid("de8314c7-969c-4240-8f8f-bb0b2cc2cea7");
            var command = await db.Commands.FindAsync(commandId);
            if (command == null)
            {
                command = new Command();
                command.CommandID = commandId;
                command.CommandName = "CompileAndTest";

                var dir = @"D:\Documents\visual studio 2015\Projects\Architect.NET - Compiler\Code\Payload\";
                command.WorkingDirectory = dir;
                command.StartProcess = dir + "_build.bat";
                command.ResultFilename = dir + @"_Output\TestProject.Tests.dll-results.xml";
                db.Commands.Add(command);
                await db.SaveChangesAsync();
            }

            /* create new job every time for testing purposes */
            Job job = new Job();
            job.JobId = Guid.NewGuid();
            job.ClientId = client.ClientId;
            job.CommandId = command.CommandID;
            job.JobStart = DateTime.Now;
            db.Jobs.Add(job);
            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException ex)
            {
                throw ex;
            }            

            /* get jobs for client */
            var query = db.Jobs.Where(e => e.ClientId == id && e.IsTerminated == false);
            var result = await query.ToListAsync();
            return result;

        }