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 void InitStateManager()
 {
     if (!IsStoreInitialized && TheCDEngines.MyIStorageService != null)
     {
         IsStoreInitialized = true;
         MySessionStates.SetStorageService(TheCDEngines.MyIStorageService);
         MySessionStates.CreateStore(TheBaseAssets.MyServiceHostInfo.ApplicationName + ": Session State", "Log of all Session Activities", null, true, false);
     }
 }
        /// <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);
     }
 }