Hi Dojo,
When confirming a job I need to confirm all reservations belonging to that job. In case one of the reservations can't be confirmed, I need to go back to the previous state.
I'm using the SRM framework to confirm my reservations, but I don't see a method to go back to pending state. Will below approach work where I clone my original reservation, confirm the reservation by using the framework and revert back using the ResourceManagerHelper? Or are some specific SRM related properties not covered by this?
var reverseActions = false;
StringBuilder sb = null;
var originalReservations = new List<ReservationInstance>();var jobReservations = GetJobReservations();
try
{
foreach (var reservation in jobReservations)
{
var originalReservation = reservation.Clone() as ReservationInstance;var bookingManager = reservation.FindBookingManager();
bookingManager.ChangeStateToConfirmed((Engine)engine, reservation);originalReservations.Add(originalReservation);
}
}
catch (Exception ex)
{
reverseActions = true;sb = new StringBuilder();
sb.AppendLine("Failed to confirm all reservations.");
sb.AppendLine(ex.ToString());
}if (reverseActions && originalReservations.Count > 0)
{
SrmHelpers.ResourceManagerHelper.AddOrUpdateReservationInstances(originalReservations.ToArray());
}
Hi Jens,
Your code snippet should work without problems.
Hi Jens,
You can use the "BookingManager.ChangeStateToOnHold()" method to move a booking from the confirmed state to the partial state.