public HttpResponseMessage PutJob(Guid id, Job job) { if (ModelState.IsValid && id == job.Id) { DJob djob = _ctx.DJobs.Single(d => d.Id == id); if (djob == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } MapToDB(job, djob); try { _ctx.SaveChanges(); } catch (DbUpdateConcurrencyException) { return Request.CreateResponse(HttpStatusCode.InternalServerError); } return Request.CreateResponse(HttpStatusCode.OK); } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }
public JsonResult SimulationStart() { var solverData = GetSolverData(); var job = new Job { Id = Guid.NewGuid(), Started = DateTime.UtcNow, Owner = User.Identity.Name, Name = StandardCases.CfdCase, State = JobState.Started, }; var jobZip = CreateJobPath(job.Owner, job.Id); var jobPath = jobZip.Replace(".zip", ""); solverData.MakeJobFS(jobPath); SharpZipUtils.CompressFolder(jobPath, jobZip, null); new JobsController().AddJobManually(job); _procTime = (solverData.ControlDict.endTime - solverData.ControlDict.startTime).ToString( CultureInfo.InvariantCulture); SetCaseJob(job.Id); return Json(new object[] {job.Id, _procTime}); }
public HttpResponseMessage PostJob(Job job) { try { var njob = PostJobManually(job); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, njob); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = njob.Id })); return response; } catch (DbUpdateConcurrencyException) { return Request.CreateResponse(HttpStatusCode.InternalServerError); } }
public JsonResult Update(Job job) { DJob djob = _ctx.DJobs.Single(d => d.Id == job.Id); if (djob == null) { return JsonX(HttpStatusCode.NotFound); } MapToDB(job, djob); try { _ctx.SaveChanges(); } catch (DbUpdateConcurrencyException) { return JsonX(HttpStatusCode.InternalServerError); } return JsonX(HttpStatusCode.OK); }
private static void MapToDB(Job job, DJob djob) { djob.Started = job.Started; djob.Finished = job.Finished; djob.Name = job.Name; djob.Owner = job.Owner; djob.State = job.State.ToString(); djob.Result = job.Result.ToString(); djob.ResultData = job.ResultData; }
public Job AddJobManually(Job job) { var dJob = new DJob(); dJob.Id = job.Id; //dJob.ProcTime = job.ProcTime.ToString(CultureInfo.InvariantCulture); MapToDB(job, dJob); _ctx.DJobs.AddObject(dJob); _ctx.SaveChanges(); return MapFromDB(dJob); }
public JsonResult Add(Job job) { try { var njob = AddJobManually(job); return JsonX(HttpStatusCode.Created, njob); } catch (DbUpdateConcurrencyException) { return JsonX(HttpStatusCode.InternalServerError); } }
public Job PostJobManually(Job job) { var dJob = new DJob(); dJob.Id = job.Id; MapToDB(job, dJob); _ctx.DJobs.AddObject(dJob); _ctx.SaveChanges(); return MapFromDB(dJob); }