public IEnumerable <Event> PlanMaintenanceJob(PlanMaintenanceJob command) { // check business rules // maintenance jobs may not span multiple days if (command.StartTime.Date != command.EndTime.Date) { throw new BusinessRuleViolationException("Start-time and end-time of a Maintenance Job must be within a 1 day."); } // no more than 3 jobs can be planned at the same time (limited resources) if (Jobs.Count(j => (j.StartTime >= command.StartTime && j.StartTime <= command.EndTime) || (j.EndTime >= command.StartTime && j.EndTime <= command.EndTime)) >= MAX_PARALLEL_JOBS) { throw new BusinessRuleViolationException($"Maintenancejob overlaps with more than {MAX_PARALLEL_JOBS} other jobs."); } // only 1 maintenance job can be executed on a vehicle during a certain time-slot if (Jobs.Any(j => j.Vehicle.Matricula == command.VehicleInfo.Matricula && (j.StartTime >= command.StartTime && j.StartTime <= command.EndTime || j.EndTime >= command.StartTime && j.EndTime <= command.EndTime))) { throw new BusinessRuleViolationException($"Only 1 maintenance job can be executed on a vehicle during a certain time-slot."); } // handle event MaintenanceJobPlanned e = Mapper.Map <MaintenanceJobPlanned>(command); return(HandleEvent(e)); }
private void newEntryToolStripMenuItem_Click(object sender, EventArgs e) { using (var new_entry = new New_Entry()) { new_entry.ShowDialog(); if (new_entry.DialogResult == DialogResult.OK) { Jobs.Add(new_entry.NewJob); int index; if (dataGridView1.Rows.Count == 0) { index = 1; } else { DataGridViewRow LastRow = dataGridView1.Rows[dataGridView1.Rows.Count - 1]; index = Convert.ToInt16(LastRow.Cells[0].Value) + 1; } ListOfIds.Add(index); int num = Jobs.Count(); DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dataGridView1); row.Cells[0].Value = index.ToString(); row.Cells[1].Value = Jobs[num - 1].Started.ToString("yyyy-MM-dd HH:mm:ss"); row.Cells[2].Value = Jobs[num - 1].Finished.ToString("yyyy-MM-dd HH:mm:ss"); row.Cells[3].Value = Jobs[num - 1].Total; row.Cells[4].Value = Jobs[num - 1].Assigned_by; row.Cells[5].Value = Jobs[num - 1].Comment; dataGridView1.Rows.Add(row); using (var con = new SQLiteConnection(ConnectionString)) { con.Open(); var sql = "INSERT INTO times(Started,Finished,Total,Assigned_by,Comment) VALUES('" + new_entry.NewJob.Started.ToString("yyyy-MM-dd HH:mm:ss") + "','" + new_entry.NewJob.Finished.ToString("yyyy-MM-dd HH:mm:ss") + "','" + new_entry.NewJob.Total + "','" + new_entry.NewJob.Assigned_by + "','" + new_entry.NewJob.Comment + "')"; var cmd = new SQLiteCommand(sql, con); cmd.ExecuteNonQuery(); con.Close(); } if (dataGridView1.Rows.Count > 0) { editSelectedToolStripMenuItem.Enabled = true; deleteSelectedToolStripMenuItem.Enabled = true; } } } }
public bool HasNext() => Desc == true && Jobs.Count() == Limit;
public bool HasPrev() => (Desc == false && Jobs.Count() == Limit) || Job != null;