public void Deploy(int enviromentId, int applicationId, string version, ICollection<DeploymentTasksDto> tasks) { using (var session = WebApiApplication.Store.OpenSession()) { var deploy = new Deployment() { EnviromentId = enviromentId, ApplicationId = applicationId, Status = Status.Queud, Version = version, UserId = User.Identity.GetUserId() }; if (tasks != null && tasks.Count > 0) { foreach (var task in tasks) { deploy.Tasks.Add(new DeploymentTask() { DeployTaskId = task.DeployTaskId, DeployType = (int)task.DeployType }); } } session.Save(deploy); session.Flush(); BackgroundJob.Enqueue(() => DeployJob.Execute(deploy.Id)); }; }
public void Schedule(int enviromentId, int applicationId, string version, DateTime start, ICollection<DeploymentTasksDto> tasks) { using (var session = WebApiApplication.Store.OpenSession()) { var deploy = new Deployment() { EnviromentId = enviromentId, Status = Status.Scheduled, ApplicationId = applicationId, Version = version, UserId = User.Identity.GetUserId(), StartDate = start, Scheduled = true }; if (tasks != null && tasks.Count > 0) { foreach (var task in tasks) { deploy.Tasks.Add(new DeploymentTask() { DeployTaskId = task.DeployTaskId, DeployType = (int)task.DeployType }); } } session.Save(deploy); session.Flush(); BackgroundJob.Schedule(() => DeployJob.Execute(deploy.Id), start.ToUniversalTime() - DateTime.UtcNow); }; }