What is the most efficient way in SRM to receive all available resources from a specific resource pool during a specific timeslot?
This is the code I currently use but not sure if this is the best/optimal way:
private List<Resource> GetAvailableResourcesFromPool(Engine engine, String ResourpoolName)
{
//SRM call to get available resources from a resourcepool in a certain timerange
var resourceManagerHelper = new ResourceManagerHelper();
resourceManagerHelper.RequestResponseEvent += (sender, e) => e.responseMessage = engine.SendSLNetSingleResponseMessage(e.requestMessage);
var resourcePool = resourceManagerHelper.GetResourcePools(new ResourcePool { Name = ResourpoolName }).FirstOrDefault();
var context = new EligibleResourceContext
{
ResourceFilter = ResourceExposers.PoolGUIDs.Contains(resourcePool.ID),
TimeRange = new Skyline.DataMiner.Net.Time.TimeRangeUtc(startTime, endTime),
};
return resourceManagerHelper.GetEligibleResources(context).EligibleResources;
}
Hi Martijn,
Your code is fine, though if you use that method multiple times in the same script it may be worth to cache the resource pools to avoid calls for pools that you already queried before.
Also be aware that resourceManagerHelper.GetResourcePools can return null so better check on that.