Hi,
I'm currently working with DOM and try to validate some fields. One of them is a resource select field. I would like to check if the resource is available (as in not currently in use.) what is the best way to get the current state of an resource?
Hi Gerwin,
There might be some better codes but the following code working.
private bool ResourceInUse( Engine engine, string resrouceName )
{
ResourceManagerHelper rmHelper = new ResourceManagerHelper();
rmHelper.RequestResponseEvent += ( sender, e ) => e.responseMessage = engine.SendSLNetSingleResponseMessage( e.requestMessage );
Resource resource = rmHelper.GetResources( ResourceExposers.Name.Equal( resrouceName ) ).FirstOrDefault();
Resource[] availableResources = rmHelper.GetEligibleResources( DateTime.Now, DateTime.Now, new List<MultiResourceCapacityUsage>(), new List<ResourceCapabilityUsage>() );
return !availableResources.Contains( resource );
}