Table of Contents

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

value Rule

The copied Rule.

Rule(Id?)

Initializes a new instance of the Rule class.Constructor.

public Rule(Id? id)

Parameters

id Id

Id

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 Id

The Id.

version long?

The version.

name string

The name.

color Color

The color.

comment string

The comment.

nodes IList<Group>

Group collection this ExceptionRule belongs to.

baseType ExceptionRuleBaseType?

The ExceptionRuleBaseType for this ExceptionRule.

activeFrom DateTime?

The end DateTime of the Rule.

activeTo DateTime?

The start DateTime of the Rule.

Properties

ActiveFrom

Gets or sets start date of the Rule's notification activity period. The events with earlier date than this date will not be reported through the notification engine.

public DateTime? ActiveFrom { get; set; }

Property Value

DateTime?

DateTime

ActiveTo

Gets or sets end date of the Rule's notification activity period.

public DateTime? ActiveTo { get; set; }

Property Value

DateTime?

DateTime

BaseType

Gets or sets the ExceptionRuleBaseType of the rule; either Custom, Stock or ZoneStop.

public ExceptionRuleBaseType? BaseType { get; set; }

Property Value

ExceptionRuleBaseType?

ExceptionRuleBaseType

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

Color

Color

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

string

string

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

Condition

Condition

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. Device conditions will override devices in the assigned groups.

[ExcelColumnHeader(new ReportHeading[] { ReportHeading.ExceptionRuleGroup }, IsList = true)]
public IList<Group>? Groups { get; set; }

Property Value

IList<Group>

IList<T>

Id

Gets or sets the unique identifier for this entity.

[ExcelColumnHeader(new ReportHeading[] { ReportHeading.ExceptionRuleId })]
public override Id? Id { get; set; }

Property Value

Id

Id

Monitors

Gets or sets the RuleMonitor(s).

public IList<RuleMonitor>? Monitors { get; set; }

Property Value

IList<RuleMonitor>

IList<T>

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

string

string

Methods

CleanRule(bool)

Lightens the rule and the associated condition.

public void CleanRule(bool includeConditionTree)

Parameters

includeConditionTree bool

bool

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

bool

true if the rule contains conditions of the specified condition kinds; otherwise, false.

ContainsZoneRelatedConditions()

false Determines whether the Exception Rule is a Zone or ZoneType based rule.

public bool ContainsZoneRelatedConditions()

Returns

bool

bool

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

List<Condition>

IList<T>

GetConditions()

Gets or Sets children Condition(s).

public IList<Condition> GetConditions()

Returns

IList<Condition>

IList<T>

GetZoneConditions()

Gets Zone Condition. The zone conditions include both conditions for Zones and ZoneTypes.

public List<Condition> GetZoneConditions()

Returns

List<Condition>

IList<T>

HasRuleMonitor(RuleMonitorType, MonitorPredicate)

Determines whether this Rule contains the specified RuleMonitorType and MonitorPredicate.

public bool HasRuleMonitor(RuleMonitorType monitorType, MonitorPredicate monitorPredicate)

Parameters

monitorType RuleMonitorType

Rule Monitor Type

monitorPredicate MonitorPredicate

Rule 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

action Func<Condition, bool>

A func where the input is a Condition, output is a bool.

optimize bool

Optimize out empty conditions (slower).

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>>

A func where the input is a Condition, output is a bool.

optimize bool

Optimize out empty conditions (slower).

cancellationToken CancellationToken

Reference to the cancellation token.

Returns

Task

A task representing the asynchronous operation.