void sinkThingWasUpdated(ICDEThing sender, object pPara) { if (TheBaseAssets.MyServiceHostInfo.IsCloudService) { return; //TODO: Allow Cloud Rules } TheThing pThing = sender as TheThing; if (pThing != null && TheThing.GetSafePropertyString(pThing, "DeviceType") == eKnownDeviceTypes.TheThingRule) { TheRule tRule = pThing.GetObject() as TheRule; if (tRule == null) { tRule = new TheRule(pThing, this); tRule.RegisterEvent(eEngineEvents.ThingUpdated, sinkUpdated); RegisterRule(tRule); } { tRule.IsRuleWaiting = true; tRule.IsRuleRunning = false; TheSystemMessageLog.WriteLog(4445, TSM.L(eDEBUG_LEVELS.VERBOSE) ? null : new TSM(eKnownDeviceTypes.TheThingRule, $"Rule {tRule.FriendlyName} stopped on Rule Update"), false); TheThingRegistry.UpdateThing(tRule, false); } ActivateRules(); } }
private static TheMirrorCache <TheRequestData> ReqBuffer; //DIC-Allowed private void sinkScopeIDUpdate(bool DoReq) { List <TheThing> tDevList = TheThingRegistry.GetThingsOfEngine(MyBaseEngine.GetEngineName()); if (tDevList.Count > 0) { foreach (TheThing tDev in tDevList) { if (tDev.DeviceType == eWebAppTypes.TheWebApp) { TheRelayAppInfo tApp = tDev.GetObject() as TheRelayAppInfo; if (tApp != null && TheCommonUtils.IsUrlLocalhost(tApp.HostUrl)) // tApp.HostUrl.Equals(TheBaseAssets.MyServiceHostInfo.MyStation URL)) { tApp.SSID = TheScopeManager.GetScrambledScopeID(); TheThingRegistry.UpdateThing(tDev, true); } } } } }
public bool Init() { if (mIsInitCalled) { return(false); } mIsInitCalled = true; MyBaseThing.RegisterEvent(eEngineEvents.IncomingMessage, HandleMessage); MyBaseEngine.RegisterEvent(eEngineEvents.ThingDeleted, OnDeletedThing); MyBaseEngine.RegisterEvent(eEngineEvents.ThingRegistered, OnThingRegistered); MyBaseEngine.RegisterEvent(eEngineEvents.ShutdownEvent, OnShutdown); TheCommonUtils.cdeRunAsync("Init Mesh Receiver Connections", false, (state) => { // Migrate instances from previous versions List <TheThing> tLegacyDeviceList = TheThingRegistry.GetThingsOfEngine("CDMyCloudServices.cdeMyCloudService"); foreach (var tLegacyDevice in tLegacyDeviceList) { if (!tLegacyDevice.HasLiveObject) { switch (tLegacyDevice.DeviceType) { case "Mesh Receiver": tLegacyDevice.EngineName = MyBaseThing.EngineName; tLegacyDevice.DeviceType = MeshDeviceTypes.MeshReceiver; TheThingRegistry.UpdateThing(tLegacyDevice, false); break; } } } //await System.Threading.Tasks.Task.Delay(30000); InitServers(); mIsInitialized = true; FireEvent(eThingEvents.Initialized, this, true, true); MyBaseEngine.ProcessInitialized(); }, null); return(false); }