private void StorageHasStarted(ICDEThing sender, object pReady)
 {
     if (pReady != null)
     {
         if (MyServiceHealthDataStore == null)
         {
             MyServiceHealthDataStore = new TheStorageMirror <TheThingStore>(TheCDEngines.MyIStorageService)
             {
                 IsRAMStore        = "RAM".Equals(pReady.ToString()),
                 IsCachePersistent = "RAM".Equals(pReady.ToString()) && !TheBaseAssets.MyServiceHostInfo.IsCloudService,
                 CacheTableName    = "TheHealthHistory"
             };
             if (MyServiceHealthDataStore.IsRAMStore)
             {
                 MyServiceHealthDataStore.SetRecordExpiration(86400, null);   //RAM stores for 1 day
                 MyServiceHealthDataStore.InitializeStore(true, false);
             }
             else
             {
                 MyServiceHealthDataStore.SetRecordExpiration(604800, null); //Storage stores for 7 days
                 MyServiceHealthDataStore.CreateStore("C-DMyComputer: DeviceHealthData", "All health Data of a Device/Service", null, true, false);
             }
             TheBaseAssets.MySYSLOG.WriteToLog(8002, TSM.L(eDEBUG_LEVELS.ESSENTIALS) ? null : new TSM("jcHealth", "Health Storage Started", eMsgLevel.l3_ImportantMessage));
         }
     }
 }
        private void sinkStorageStationIsReadyFired(ICDEThing sender, object pReady)
        {
            if (pReady != null)
            {
                if (MyRuleEventLog == null)
                {
                    MyRuleEventLog = new TheStorageMirror <TheEventLogData>(TheCDEngines.MyIStorageService);
                    MyRuleEventLog.CacheTableName = "EventLog";
                    MyRuleEventLog.UseSafeSave    = true;
                    MyRuleEventLog.SetRecordExpiration(604800, null);
                    MyRuleEventLog.CacheStoreInterval       = 15;
                    MyRuleEventLog.IsStoreIntervalInSeconds = true;
                    MyRuleEventLog.AppendOnly = true;

                    if (!MyRuleEventLog.IsRAMStore)
                    {
                        MyRuleEventLog.CreateStore("The Event Log", "History of events fired by the RulesEngine", null, true, TheBaseAssets.MyServiceHostInfo.IsNewDevice);
                    }
                    else
                    {
                        MyRuleEventLog.InitializeStore(true, TheBaseAssets.MyServiceHostInfo.IsNewDevice);
                    }
                    LogEvent(new TheEventLogData
                    {
                        EventCategory = eLoggerCategory.EngineEvent,
                        EventTime     = DateTimeOffset.Now,
                        StationName   = TheBaseAssets.MyServiceHostInfo?.GetPrimaryStationURL(false),
                        EventName     = "Event Log Started"
                    });
                }
            }
        }
 private void sinkStorageStationIsReadyFired(ICDEThing sender, object pReady)
 {
     if (pReady != null)
     {
         if (MyTagLog == null)
         {
             MyTagLog = new TheStorageMirror <TheNMITagLogEntry>(TheCDEngines.MyIStorageService)
             {
                 IsRAMStore = true
             };
             MyTagLog.SetRecordExpiration(600, null);
             MyTagLog.IsCachePersistent        = true;
             MyTagLog.CacheStoreInterval       = 50;
             MyTagLog.IsStoreIntervalInSeconds = true;
             MyTagLog.CacheTableName           = "TagLog" + MyBaseThing.ID;
             if (!MyTagLog.IsRAMStore)
             {
                 MyTagLog.CreateStore("Live Tag Log", "Historian of Live Tags", null, true, false);
             }
             else
             {
                 MyTagLog.InitializeStore(true, false);
             }
         }
         mIsInitialized = true;
         FireEvent(eThingEvents.Initialized, this, true, true);
     }
 }
 private void sinkStorageStationIsReadyFired(ICDEThing sender, object pReady)
 {
     if (pReady != null)
     {
         if (MySensorStore == null)
         {
             MySensorStore = new TheStorageMirror <TheSensorValue>(TheCDEngines.MyIStorageService);
             if (MyBaseEngine.GetEngineState().IsSimulated || "RAM".Equals(pReady.ToString()))
             {
                 MySensorStore.IsRAMStore        = true;
                 MySensorStore.IsCachePersistent = true;
                 MySensorStore.SetRecordExpiration(10000, null);
             }
             else
             {
                 MySensorStore.IsRAMStore = false;
             }
             if (!MySensorStore.IsRAMStore && MyBaseEngine.GetEngineState().IsService)
             {
                 MySensorStore.CreateStore("Sensor Data: Sensor Data Store", "Data from sensors", null, true, false);
             }
             else
             {
                 MySensorStore.InitializeStore(true, false);
             }
         }
     }
 }
 public TheSessionStateManager(TheServiceHostInfo pSiteID)
 {
     MySite          = pSiteID;
     MySessionStates = new TheStorageMirror <TheSessionState>(TheCDEngines.MyIStorageService)
     {
         IsRAMStore = true, BlockWriteIfIsolated = true
     };
     MySessionStates.SetRecordExpiration(TheBaseAssets.MyServiceHostInfo.SessionTimeout, sinkExpired);
     MySessionStates.InitializeStore(true);
 }
        /// <summary>
        /// Returns false if stores could not be initalized - IStorageService failed and will be shutdown
        /// </summary>
        /// <returns></returns>
        private bool InitializeStores()
        {
            bool bInitialized = CreateStorageDAT();

            if (!bInitialized)
            {
                return(false);
            }
            bool Success = true;

#if JCR_TESTSTORE
            if (MyTESTBASE == null)
            {
                MyTESTBASE            = new TheStorageMirror <TheTestBase>(this);
                MyTESTBASE.IsRAMStore = MyBaseEngine.GetEngineState().IsSimulated;
                if (MyBaseEngine.GetEngineState().IsService)
                {
                    MyTESTBASE.CreateStore(TheBaseAssets.MyServiceHostInfo.ApplicationName + ": Test Store", "Test Push and other test messages", null);
                }
                else
                {
                    MyTESTBASE.InitializeStore();
                }
            }
#endif
            if (MyBaseEngine.GetEngineState().IsService&& TheBaseAssets.MyServiceHostInfo.StoreLoggedMessages)
            {
                EdgeDataCreateStore(typeof(TSM), null, TheBaseAssets.MyServiceHostInfo.ApplicationName + ": SystemMessageLog", "Log of all Application System Messages", false, null, null);
            }

            if (MyTimedCallbacks == null)
            {
                MyTimedCallbacks = new TheStorageMirror <TheTimedCallback>(TheCDEngines.MyIStorageService)
                {
                    IsRAMStore = true
                };
                MyTimedCallbacks.InitializeStore(true);
                MyTimedCallbacks.SetRecordExpiration(TheBaseAssets.MyServiceHostInfo.TO.ReceivedChunkTimeout, null);
            }
            if (TheCommonUtils.CBool(TheBaseAssets.MySettings.GetSetting("UseStorageForThingRegistry")))
            {
                Success = CreateThingRegistryStore();
            }
            return(Success);
        }
Exemple #7
0
 private void StorageHasStarted(ICDEThing sender, object pReady)
 {
     if (pReady != null)
     {
         if (MyVisitorLogStore == null)
         {
             MyVisitorLogStore = new TheStorageMirror <TheVisitorLogData>(TheCDEngines.MyIStorageService);
             MyVisitorLogStore.RegisterEvent(eStoreEvents.StoreReady, StoreIsUp);
         }
         MyVisitorLogStore.IsRAMStore = TheCDEngines.MyIStorageService == null || TheCDEngines.MyIStorageService.GetBaseEngine().GetEngineState().IsSimulated;
         if (MyVisitorLogStore.IsRAMStore)
         {
             MyVisitorLogStore.IsCachePersistent = true;
             MyVisitorLogStore.CacheTableName    = "VisitorLog";
             MyVisitorLogStore.SetRecordExpiration(1000000, null);
         }
         MyVisitorLogStore.CreateStore(TheBaseAssets.MyServiceHostInfo.ApplicationName + ": The Visitor Log", "Logs all visitors to the Site " + TheBaseAssets.MyServiceHostInfo.ApplicationName, null, true, false);
     }
 }
Exemple #8
0
        private void StartUPnPDiscovery(string pLiveEngines)
        {
            if (MyUPnPDiscoveryPast != null)
            {
                TheBaseAssets.MySYSLOG.WriteToLog(109, new TSM("UPnP", "DISCO aready running!"));
                return;
            }
            MyUPnPDiscoveryPast = new TheStorageMirror <TheUPnPDeviceInfo>(Engines.TheCDEngines.MyIStorageService)
            {
                IsRAMStore = true, BlockWriteIfIsolated = true
            };
            MyUPnPDiscoveryPast.SetRecordExpiration(DISCOExpireTime, sinkDeviceExpired);
            //MyUPnPDiscoveryPast.CacheStoreInterval = 60;
            //MyUPnPDiscoveryPast.IsStoreIntervalInSeconds = true;
            //MyUPnPDiscoveryPast.IsCachePersistent = true;
            MyUPnPDiscoveryPast.InitializeStore(true, true);

            var tCDEConnectUrl = TheBaseAssets.MyServiceHostInfo.GetPrimaryStationURL(false);

            TheBaseAssets.MySYSLOG.WriteToLog(107, TSM.L(eDEBUG_LEVELS.ESSENTIALS) ? null : new TSM("UPnP", "Starting Device", eMsgLevel.l3_ImportantMessage));
            MyDeviceUPnPInfo = new TheUPnPDeviceInfo()
            {
                FriendlyName    = TheBaseAssets.MyServiceHostInfo.ApplicationTitle + " at: " + tCDEConnectUrl + " - Services:" + pLiveEngines,// pStationEngines;
                Manufacturer    = TheBaseAssets.MyServiceHostInfo.VendorName,
                ManufacturerUrl = TheBaseAssets.MyServiceHostInfo.VendorUrl,
                ModelName       = TheBaseAssets.MyServiceHostInfo.ApplicationName,
                ModelNumber     = string.Format("V{0:0.0000}", TheBaseAssets.MyServiceHostInfo.CurrentVersion),
                SerialNumber    = TheBaseAssets.CurrentVersionInfo,
                PacketString    = "",
                RawMetaXml      = "",
                LocationURL     = tCDEConnectUrl,
                ST            = "C-DEngine",
                CDEConnectUrl = tCDEConnectUrl,
                CDENodeID     = TheBaseAssets.MyServiceHostInfo.MyDeviceInfo.DeviceID,
                UUID          = TheBaseAssets.MyServiceHostInfo.MyDeviceInfo.DeviceID.ToString(),
                USN           = TheBaseAssets.MyServiceHostInfo.MyDeviceInfo.DeviceID.ToString(),
                IsCDEngine    = true
            };
            if (!TheBaseAssets.MyServiceHostInfo.RequiresConfiguration)
            {
                MyDeviceUPnPInfo.CDEContextID = TheBaseAssets.MyScopeManager.GetScrambledScopeID();     //GRSI: rare
            }
            if (TheCommonUtils.IsHostADevice())
            {
                MyDeviceUPnPInfo.HasPresentation = false;
            }
            else
            {
                if (!TheBaseAssets.MyServiceHostInfo.DisableWebSockets && TheBaseAssets.MyServiceHostInfo.MyStationWSPort > 0)
                {
                    var builder = new UriBuilder(TheBaseAssets.MyServiceHostInfo.GetPrimaryStationURL(false));
                    builder.Scheme = builder.Scheme == "https" ? "wss" : "ws";
                    builder.Port   = TheBaseAssets.MyServiceHostInfo.MyStationWSPort;
                    MyDeviceUPnPInfo.CDEConnectWsUrl = TheCommonUtils.TruncTrailingSlash(builder.Uri.ToString());
                }
                MyDeviceUPnPInfo.HasPresentation = true;
            }
            eventDiscoReady?.Invoke(true);

            TheQueuedSenderRegistry.RegisterHealthTimer(DoScan4Devices);
            TheBaseAssets.MySYSLOG.WriteToLog(108, TSM.L(eDEBUG_LEVELS.ESSENTIALS) ? null : new TSM("UPnP", "DISCO engine ready..."));
        }