November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
In CMS 12 configuration settings are exposed as options classes which are already registered in the IOC container.
I haven't tried this but you should be able to simply inject IOptions<SchedulerOptions> as such
public TestClass(IOptions<SchedulerOptions> options)
{
_options = options.Value;
}
You can then use the value for _options.Enabled for your logic
See below documentation for details
https://docs.developers.optimizely.com/content-management-system/docs/configuration
I can confirm this approach works.
In addition, there is a transformation step in the DXP deploy that force sets this value to Enabled = true for the scheduler instance and Enabled = false for all other instances (valid for preprod and prod), which means that you can trust this setting. If it is enabled, you're on the scheduler. Do note though that there is no scheduler instance in integration, but unless you deliberately change the value, it will be correct for integration too, since scheduler is by default enabled.
To visualize what both Ronil and Johan said, check the scheduler property
Or if you prefer the programmatic approach
services.Configure<SchedulerOptions>(options =>
{
options.Enabled = true;
});
And use something like this in your code
public class SchedulerEnabled
{
private readonly IOptions<SchedulerOptions> _options;
public SchedulerEnabled(IOptions<SchedulerOptions> options)
{
_options = options;
}
public bool Value { get { return _options.Value.Enabled; } }
}
we are upgrading to CMS 12, previously we used
to tell if the current instance in DXC is the instance running the scheduler, we would like to do the same in the upgrade, but i cant find that property or an alternative in version 12.
Same question has asked about previous versions.
How can we programatically know if this is the instance in DXC running the scheduler.