public static void AddToBatch(IDbConnection db, DatabaseDialect dialect, Batch batch, ScheduledJob job) { const string sql = "INSERT INTO BatchJob (BatchId, ScheduledJobId) VALUES (@BatchId, @ScheduledJobId)"; db.Execute(sql, new { BatchId = batch.Id, ScheduledJobId = job.Id }); }
public Batch CreateBatch(string name, IEnumerable<ScheduledJob> jobs) { var db = _connectionBuilder(); var batch = new Batch { Name = name, Jobs = jobs }; Queries.InsertBatch(db, _dialect, batch); foreach(var job in batch.Jobs) { if (job.Priority != batch.Priority) { job.Priority = batch.Priority; Save(job); } Queries.AddToBatch(db, _dialect, batch, job); } return batch; }
public static void InsertBatch(IDbConnection db, DatabaseDialect dialect, Batch batch) { var sql = "INSERT INTO Batch (Name) VALUES (@Name);"; sql = AddInsertIdentity(dialect, sql); batch.Id = db.Execute(sql, batch); batch.CreatedAt = db.Query<DateTime>("SELECT CreatedAt FROM Batch WHERE Id = @Id", new { batch.Id }).Single(); }