Class Rule
- Namespace
- Geotab.Checkmate.ObjectModel.Exceptions
- Assembly
- Geotab.Checkmate.ObjectModel.dll
A rule is the definition of conditions that, when "violated", will generate an ExceptionEvent. The rule's logic is defined by it's tree of Condition (s). It's condition tree will be evaluated against data for device(s) that are members of the rule's assigned group(s) or the device(s)/driver(s) defined in the rule condition tree. The conditions will be evaluated independently against the assets in the selected groups.
[ReportClass]
public class Rule : NameEntityWithVersion, IEntity, IComparable, IIdentifiable, IVersion, IGroupLinked, IConditionContainer, IDefaultable
- Inheritance
-
Rule
- Implements
- Derived
- Inherited Members
Constructors
Rule()
Initializes a new instance of the Rule class.
public Rule()
Rule(Rule)
Initializes a new instance of the Rule class.Initializes a copy instance of the Rule class.
protected Rule(Rule value)
Parameters
Rule(Id?)
Initializes a new instance of the Rule class.Constructor.
public Rule(Id? id)
Parameters
Rule(Id?, long?, string?, Color?, string?, IList<Group>?, ExceptionRuleBaseType?, DateTime?, DateTime?)
Initializes a new instance of the Rule class.
public Rule(Id? id, long? version, string? name, Color? color, string? comment, IList<Group>? nodes, ExceptionRuleBaseType? baseType, DateTime? activeFrom, DateTime? activeTo)
Parameters
id
IdThe Id.
version
long?The version.
name
stringThe name.
color
ColorThe color.
comment
stringThe comment.
nodes
IList<Group>Group collection this ExceptionRule belongs to.
baseType
ExceptionRuleBaseType?The ExceptionRuleBaseType for this ExceptionRule.
activeFrom
DateTime?activeTo
DateTime?
Properties
ActiveFrom
Gets or sets start date of the Rule's notification activity period.
public DateTime? ActiveFrom { get; set; }
Property Value
ActiveTo
Gets or sets end date of the Rule's notification activity period.
public DateTime? ActiveTo { get; set; }
Property Value
BaseType
Gets or sets the ExceptionRuleBaseType of the rule; either Custom, Stock or ZoneStop.
public ExceptionRuleBaseType? BaseType { get; set; }
Property Value
Color
Gets or sets the Color associated with this rule. Used when rendering ExceptionEvent(s) related to this rule. Color is defined by the parameters "Red", "Green" and "Blue".
public Color? Color { get; set; }
Property Value
Comment
Gets or sets free text field where any user information can be stored and referenced for this entity.
[ExcelColumnHeader(new ReportHeading[] { ReportHeading.ExceptionRuleComment })]
public string? Comment { get; set; }
Property Value
Condition
Gets or sets the hierarchical tree of Condition(s) defining the logic of a rule. A rule should have one or more conditions in it's tree.
public Condition? Condition { get; set; }
Property Value
Groups
Gets or sets a list of Group(s) assigned to the rule. Device in these groups
will have the rule evaluated against their data.
[ExcelColumnHeader(new ReportHeading[] { ReportHeading.ExceptionRuleGroup }, IsList = true)]
public IList<Group>? Groups { get; set; }
Property Value
Id
Gets or sets the unique identifier for this entity.
[ExcelColumnHeader(new ReportHeading[] { ReportHeading.ExceptionRuleId })]
public override Id? Id { get; set; }
Property Value
Monitors
Gets or sets the RuleMonitor(s).
public IList<RuleMonitor>? Monitors { get; set; }
Property Value
Name
Gets or sets the name of this entity which identifies it and is used when displaying this entity.
[ExcelColumnHeader(new ReportHeading[] { ReportHeading.ExceptionRuleName })]
public override string? Name { get; set; }
Property Value
Methods
CleanRule(bool)
Lightens the rule and the associated condition.
public void CleanRule(bool includeConditionTree)
Parameters
Clone()
Creates a new object that is a copy of the current instance.
public override IEntity Clone()
Returns
- IEntity
A new object that is a copy of this instance.
ContainsCondition(params ConditionType[])
Determines whether this rule contains any of the specified condition kinds in its tree.
public bool ContainsCondition(params ConditionType[] conditionKinds)
Parameters
conditionKinds
ConditionType[]The condition kinds.
Returns
ContainsZoneRelatedConditions()
public bool ContainsZoneRelatedConditions()
Returns
FindConditions(params ConditionType[])
Finds all conditions in the rule true that are of a particular list of kinds.
public List<Condition> FindConditions(params ConditionType[] conditionKinds)
Parameters
conditionKinds
ConditionType[]The condition kinds.
Returns
GetConditions()
Gets or Sets children Condition(s).
public IList<Condition> GetConditions()
Returns
GetZoneConditions()
Gets Zone Condition. The zone conditions include both conditions for Zones and ZoneTypes.
public List<Condition> GetZoneConditions()
Returns
HasRuleMonitor(RuleMonitorType, MonitorPredicate)
Determines whether this Rule contains the specified RuleMonitorType and MonitorPredicate.
public bool HasRuleMonitor(RuleMonitorType monitorType, MonitorPredicate monitorPredicate)
Parameters
monitorType
RuleMonitorTypeRule Monitor Type
monitorPredicate
MonitorPredicateRule Monitor Predicate
Returns
- bool
true if the rule has both RuleMonitorType and MonitorPredicate
PopulateDefaults()
Populate non-required empty (null) properties with default values.
public void PopulateDefaults()
TraverseConditions(Func<Condition, bool>, bool)
Enumerates the conditions tree.
public void TraverseConditions(Func<Condition, bool> action, bool optimize = false)
Parameters
TraverseConditionsAsync(Func<Condition, CancellationToken, Task<bool>>, bool, CancellationToken)
Enumerates the conditions tree.
public Task TraverseConditionsAsync(Func<Condition, CancellationToken, Task<bool>> action, bool optimize = false, CancellationToken cancellationToken = default)
Parameters
action
Func<Condition, CancellationToken, Task<bool>>optimize
boolOptimize out empty conditions (slower).
cancellationToken
CancellationTokenReference to the cancellation token.
Returns
- Task
A task representing the asynchronous operation.