In SRM, is it possible to obtain a list of conflicting resources (or bookings using conflicting resources) when trying to confirm a booking, or extend/adjust the time of a booking?
Currently I'm using methods like bookingManager.TryExtendEvent or bookingManager.TryStartEvent but its not clear which resources or bookings are causing conflicts. Ideally this can be gathered and displayed to better understand why time adjustments are not possible.
Thanks in advance.
Hi Blake,
To do that you will need to catch the exception that is thrown, so instead of using TryStart or TryExtend you need to use Start and Extend methods.
You can find below example code for start, but the extend should be similar.
var conflictResources = new List<Guid>();
try
{
booking = this.bookingManager.Start(Engine, booking, false);
}
catch (Exception e)
{
if (e is ResourceManagerTraceDataException exception)
{
var errorData = exception.TraceData.ErrorData.Cast<ResourceManagerErrorData>();
foreach (var error in errorData)
{
if (error.ErrorReason == ResourceManagerErrorData.Reason.ReservationUpdateCausedReservationsToGoToQuarantine)
{
foreach (var item in error.MustBeMovedToQuarantine.SelectMany(x => x.QuarantinedUsages))
{
conflictResources.Add(item.QuarantinedResourceUsage.GUID);
}
}
}
}
}
foreach (var item in conflictResources)
{
engine.GenerateInformation($"Resource in conflict: {item}");
}

Thanks Jorge!