Ejemplo n.º 1
0
        public void ExecuteAction()
        {
            if (_firstTriggered != null && (DateTime.UtcNow - TriggerPeriod) > _firstTriggered)
            {
                //  make sure no recent action was taken on this
                foreach (var actionItem in ActionHistory)
                {
                    if (actionItem.TriggerItem.Application.Properties.ApplicationName == _triggeringItem.Application.Properties.ApplicationName &&
                        actionItem.TriggerItem.Service.Properties.ServiceName == _triggeringItem.Service.Properties.ServiceName &&
                        (DateTime.UtcNow - ActionGracePeriod) < actionItem.TimeTriggeredUtc)
                    {
                        // we should do any new action yet - we have a grace period
                        return;
                    }
                }

                TriggerAction.Execute(_triggeringItem);
                WatchdogEventSource.Current.ActionFired(TriggerAction.GetType().FullName, this.ToString(_triggeringItem), _triggeringItem.ToString());

                ActionHistory.Add(new RuleActionItem()
                {
                    TimeTriggeredUtc = DateTime.UtcNow,
                    TriggerItem      = _triggeringItem,
                    TriggerAction    = TriggerAction
                });
            }
        }
Ejemplo n.º 2
0
 public string ToString(TriggerItem triggerItem)
 {
     return($"RuleFilter={RuleFilter.ToString(triggerItem)}; Expression={TriggerExpression.ToString(triggerItem)}; TriggerPeriod={TriggerPeriod.ToString()}; " +
            $"GracePeriod={ActionGracePeriod.ToString()}; Action={TriggerAction.GetType().FullName}");
 }