Skip to content
DataMiner DoJo

More results...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages
Search in posts
Search in pages
Log in
Menu
  • Blog
  • Questions
  • Learning
    • E-learning Courses
    • Open Classroom Training
    • Certification
      • DataMiner Fundamentals
      • DataMiner Configurator
      • DataMiner Automation
      • Scripts & Connectors Developer: HTTP Basics
      • Scripts & Connectors Developer: SNMP Basics
      • Visual Overview – Level 1
      • Verify a certificate
    • Tutorials
    • Video Library
    • Books We Like
    • >> Go to DataMiner Docs
  • Expert Center
    • Solutions & Use Cases
      • Solutions
      • Use Case Library
    • Markets & Industries
      • Media production
      • Government & defense
      • Content distribution
      • Service providers
      • Partners
      • OSS/BSS
    • DataMiner Insights
      • Security
      • Integration Studio
      • System Architecture
      • DataMiner Releases & Updates
      • DataMiner Apps
    • Agile
      • Agile Webspace
      • Everything Agile
        • The Agile Manifesto
        • Best Practices
        • Retro Recipes
      • Methodologies
        • The Scrum Framework
        • Kanban
        • Extreme Programming
      • Roles
        • The Product Owner
        • The Agile Coach
        • The Quality & UX Coach (QX)
    • DataMiner DevOps Professional Program
  • Downloads
  • More
    • Feature Suggestions
    • Climb the leaderboard!
    • Swag Shop
    • Contact
      • General Inquiries
      • DataMiner DevOps Support
      • Commercial Requests
    • Global Feedback Survey
  • PARTNERS
    • All Partners
    • Technology Partners
    • Strategic Partner Program
    • Deal Registration
  • >> Go to dataminer.services

Check if resource is in use

Solved759 views17th May 2024Automation Script DOM automion script resource
1
Gerwin van der Kamp [DevOps Enabler]2.91K 15th May 2024 0 Comments

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?

Seppe Vanhee [SLC] [DevOps Member] Answered question 17th May 2024

2 Answers

  • Active
  • Voted
  • Newest
  • Oldest
0
Seppe Vanhee [SLC] [DevOps Member]326 Posted 17th May 2024 1 Comment

Hi Gerwin,

The answer of Hideyuki is correct, but I would like to give some additions that might be useful.

The GetEligibleResources method will return all resources that meet the requirements as defined in the context. If you already have the id of the resource, you can limit the scope of GetEligibleResources to one resource with a filter, which will reduce the processing the server needs to do. Without a filter the availability of all resources is calculated. Furthermore, the example of Hideyuki will calculate the availability of the resource now, not for a later timerange. I assume the intention is to create a booking that uses the resource, in which case you need to pass the timerange of the booking to GetEligibleResources. An example with a filter:

private bool IsResourceInUse(Guid resourceId, DateTime start, DateTime end)
{
var context = new EligibleResourceContext(start, end)
{
ResourceFilter = ResourceExposers.ID.Equal(resourceId)
};

    // You  can add capacities or capabilities to the context if you want to make sure
// the resource has certain capacities and capabilities available in the time range as well.
// context.RequiredCapabilities.Add(new ResourceCapabilityUsage()
// {
//     CapabilityProfileID = Guid.NewGuid(), // ID of the capability parameter
//     RequiredDiscreet = "Example" // Discreet capability value that is required
// });
// context.RequiredCapacities.Add(new MultiResourceCapacityUsage()
// {
//     CapacityProfileID = Guid.NewGuid(), // ID of the capacity parameter
//     DecimalQuantity = 100 // Amount of capacity required
// });

var result = rmHelper.GetEligibleResources(context);

    // Result should only contain one resource since we filter on ID.
var resourceInResult = result.EligibleResources.FirstOrDefault(resource => resource.ID == resourceId);
return resourceInResult != null;
}

Some other remarks that might be important:

  • If the resource is already in use by another booking, but there is still concurrency left, and the filtered capacities and capabilities are still available, the resource will still be returned in the result, since another booking can make use of it in that timerange. If you also want to make sure there is not a single booking in the passed timerange using the resource, you can check if the 'ConcurrencyLeft' for the resource is different from the max concurrency on the resource. The concurrency left per resource can be found in the 'UsageDetails' list of the result:

var result = rmHelper.GetEligibleResources(context);
var usageDetails = result.UsageDetails.FirstOrDefault(resource => resource.ID == resourceId);
return usageDetails.ConcurrencyLeft == resource.GetEffectiveMaxConcurrency();

  • If you have multiple resources to validate, don't filter on one ID but filter on multiple IDs in the filter of the context. Requesting the availability of multiple resources in one call is more efficient than making multiple calls.
  • If you call GetEligibleResources but don't create a booking with the resource, there is nothing stopping a different script from 'stealing' the resource and creating a booking with it. GetEligibleResources only calculates availability of resources, it does not book resources. It might be interesting if you share how or where you validate these DOM fields, as there is (as far as I know) no built-in mechanism to validate fields based on custom logic.
Gerwin van der Kamp [DevOps Enabler] Posted new comment 17th May 2024
Gerwin van der Kamp [DevOps Enabler] commented 17th May 2024

Hi,

Thanks for the extra explanations. It’s an basic validation to catch any user errors in an early stage, after this validation step an booking can be triggered. But it is to catch user config/copy paste errors (duplicate names, resources, other config items)

You are viewing 1 out of 2 answers, click here to view all answers.
Please login to be able to comment or post an answer.

My DevOps rank

DevOps Members get more insights on their profile page.

My user earnings

0 Dojo credits

Spend your credits in our swag shop.

0 Reputation points

Boost your reputation, climb the leaderboard.

Promo banner DataMiner DevOps Professiona Program
DataMiner Integration Studio (DIS)
Empower Katas

Recent questions

Alarm Dashboard PDF/CSV Export 1 Answer | 0 Votes
Is the Microsoft SharePoint Connector Still Usable 0 Answers | 0 Votes
Is the Microsoft SharePoint Connector Still Usable 0 Answers | 0 Votes

Question Tags

adl2099 (115) alarm (62) Alarm Console (82) alarms (100) alarm template (83) Automation (223) automation scipt (111) Automation script (167) backup (71) Cassandra (180) Connector (108) Correlation (68) Cube (150) Dashboard (194) Dashboards (188) database (83) DataMiner Cube (57) DIS (81) DMS (71) DOM (139) driver (65) DVE (55) Elastic (83) Elasticsearch (115) elements (80) Failover (104) GQI (159) HTTP (76) IDP (74) LCA (151) low code app (166) low code apps (93) lowcodeapps (75) MySQL (53) protocol (203) QAction (83) security (88) services (51) SNMP (86) SRM (337) table (54) trending (87) upgrade (62) Visio (539) Visual Overview (345)
Privacy Policy • Terms & Conditions • Contact

© 2025 Skyline Communications. All rights reserved.

DOJO Q&A widget

Can't find what you need?

? Explore the Q&A DataMiner Docs

[ Placeholder content for popup link ] WordPress Download Manager - Best Download Management Plugin