void SendRuleTSM(bool serviceOnly) { string engine = TheCommonUtils.CStr(GetProperty("TSMEngine", false)); string text = TheCommonUtils.CStr(GetProperty("TSMText", false)); string payload = TheCommonUtils.CStr(GetProperty("TSMPayload", false)); //payload = payload.Replace("%DTO%", TheCommonUtils.CStr(DateTimeOffset.Now)); //text = text.Replace("%DTO%", TheCommonUtils.CStr(DateTimeOffset.Now)); ICDEThing triggerThing = TheThingRegistry.GetThingByMID("*", TheCommonUtils.CGuid(TriggerObject)) as ICDEThing; string escPayload = TheCommonUtils.GenerateFinalStr(payload, triggerThing); escPayload = TheCommonUtils.GenerateFinalStr(escPayload, MyBaseThing); string escText = TheCommonUtils.GenerateFinalStr(text, triggerThing); escText = TheCommonUtils.GenerateFinalStr(escText, MyBaseThing); if (!string.IsNullOrEmpty(engine) && !string.IsNullOrEmpty(text)) { TSM customTSM = new TSM(engine, escText, escPayload); if (serviceOnly) { customTSM.SetToServiceOnly(true); } TheCommCore.PublishCentral(customTSM, true); } if (IsRuleLogged) { LogEvent(escPayload); } if (TheThing.GetSafePropertyBool(MyBaseThing, "IsEVTLogged")) { TheLoggerFactory.LogEvent(eLoggerCategory.RuleEvent, TheCommonUtils.GenerateFinalStr(MyBaseThing.FriendlyName, MyBaseThing), eMsgLevel.l4_Message, TheBaseAssets.MyServiceHostInfo.GetPrimaryStationURL(false), escText, escPayload); } }
public bool LogEvent(TheEventLogData pData) { TheLoggerFactory.LogEvent(pData); return(false); }
internal void FireAction(bool FireNow) { if (TheCDEngines.MyThingEngine == null || !TheBaseAssets.MasterSwitch) { return; } if (!FireNow) { int tDelay = ActionDelay; if (tDelay > 0) { Timer tTimer = GetDelayTimer(); if (tTimer != null) { tTimer.Dispose(); tTimer = null; } tTimer = new Timer(sinkFireOnTimer, this, tDelay * 1000, Timeout.Infinite); SetDelayTimer(tTimer); return; } } switch (ActionObjectType) { case "CDE_PUBLISHCENTRAL": SendRuleTSM(false); break; case "CDE_PUBLISH2SERVICE": SendRuleTSM(true); break; default: //case "CDE_THING": TheThing tActionThing = TheThingRegistry.GetThingByMID("*", TheCommonUtils.CGuid(ActionObject)); if (tActionThing != null) { string tActionValue = ActionValue; if (!string.IsNullOrEmpty(tActionValue)) { ICDEThing triggerThing = TheThingRegistry.GetThingByMID("*", TheCommonUtils.CGuid(TriggerObject)) as ICDEThing; tActionValue = TheCommonUtils.GenerateFinalStr(tActionValue, triggerThing); tActionValue = tActionValue.Replace("%OldValue%", TriggerOldValue); tActionValue = TheCommonUtils.GenerateFinalStr(tActionValue, MyBaseThing); } ICDEThing tObject = tActionThing.GetObject() as ICDEThing; if (tObject != null) { tObject.SetProperty(ActionProperty, tActionValue); } else { tActionThing.SetProperty(ActionProperty, tActionValue); } if (IsRuleLogged) { LogEvent(tActionValue); } if (TheThing.GetSafePropertyBool(MyBaseThing, "IsEVTLogged")) { TheLoggerFactory.LogEvent(eLoggerCategory.RuleEvent, TheCommonUtils.GenerateFinalStr(MyBaseThing.FriendlyName, MyBaseThing), eMsgLevel.l4_Message, TheBaseAssets.MyServiceHostInfo.GetPrimaryStationURL(false), TriggerObject, tActionValue); } } break; } TheThing.SetSafePropertyDate(MyBaseThing, "LastAction", DateTimeOffset.Now); FireEvent("RuleFired", this, this, true); }
public bool LogEvent(string pEventName, string tTrigger, string tAction) { TheLoggerFactory.LogEvent(eLoggerCategory.RuleEvent, pEventName, eMsgLevel.l4_Message, null, tTrigger, tAction); return(false); }