public static Trigger Read(XmlNode Node) { Trigger result = null; if (Node.Attributes != null) { result = new Trigger(); if (Node.Attributes["link_type"] != null) { switch (Node.Attributes["link_type"].Value.ToString().ToLower()) { case "type": result.LinkType = TriggerLinkType.Type; break; default: result.LinkType = TriggerLinkType.ID; break; } } if (Node.Attributes["link"] != null) result.Link = Node.Attributes["link"].Value; if (Node.Attributes["value"] != null) result.Value = Node.Attributes["value"].Value; // Added modifier to enable being able to say != to 'value' (ex. Message != "") if (Node.Attributes["modifier"] != null) { switch (Node.Attributes["modifier"].Value.ToString().ToLower()) { case "not": result.Modifier = TriggerModifier.NOT; break; case "greater_than": result.Modifier = TriggerModifier.GREATER_THAN; break; case "less_than": result.Modifier = TriggerModifier.LESS_THAN; break; case "contains": result.Modifier = TriggerModifier.CONTAINS; break; case "contains_match_case": result.Modifier = TriggerModifier.CONTAINS_MATCH_CASE; break; case "contains_whole_word": result.Modifier = TriggerModifier.CONTAINS_WHOLE_WORD; break; case "contains_whole_word_match_case": result.Modifier = TriggerModifier.CONTAINS_WHOLE_WORD_MATCH_CASE; break; } } } return result; }
private static bool FindTrigger(Instance.DataItemValue value, Trigger trigger) { if (trigger.Link != null) { if (trigger.LinkType == TriggerLinkType.Type) { return FormatDataItemType(value) == trigger.Link.ToLower(); } else { return value.Id == trigger.Link; } } return false; }
private static DateTime GetTimestampFromTrigger(Trigger trigger, List<DataItem> dataItems) { var result = DateTime.MinValue; DataItem item = dataItems.Find(x => x.DataItemId == trigger.Link); if (item != null) if (item.Timestamp > result) result = item.Timestamp; return result; }