Beispiel #1
0
 internal void InterceptRSSEvtRequest(TheRequestData pRequest)
 {
     if (pRequest == null)
     {
         return;
     }
     try
     {
         TheStorageMirror <TheEventLogData> tEventLog = TheCDEngines.GetStorageMirror("EventLog") as TheStorageMirror <TheEventLogData>;
         if (tEventLog != null)
         {
             CreateEvtLogFeed(pRequest, tEventLog?.TheValues.OrderByDescending(s => s.cdeCTIM).ThenByDescending(s => s.cdeCTIM.Millisecond).ToList(), 200);
         }
         else
         {
             TheRSSGenerator.CreateRSS(pRequest, new List <TheEventLogData>()
             {
                 new TheEventLogData()
                 {
                     EventName = "No Eventlog on this Node"
                 }
             }, 1);
         }
     }
     catch
     {
         //ignored
     }
 }
Beispiel #2
0
        public static void CreateSysLogFeed(TheRequestData pRequest, int MaxCnt)
        {
            if (pRequest.RequestUri != null && !string.IsNullOrEmpty(pRequest.RequestUri.Query) && pRequest.RequestUri.Query.Length > 1)
            {
                var QParts = TheCommonUtils.ParseQueryString(pRequest.RequestUri.Query); //.Split('=');
                //if (QParts.ContainsKey("SID") && (!TheScopeManager.IsValidScopeID(TheScopeManager.GetScrambledScopeIDFromEasyID(QParts["SID"])) || QParts.ContainsKey("NID")))
                //{
                //    pRequest.SessionState.SScopeID = TheScopeManager.GetScrambledScopeIDFromEasyID(QParts["SID"]);
                //    Guid tTarget = Guid.Empty;
                //    if (QParts.ContainsKey("NID"))
                //        tTarget = TheCommonUtils.CGuid(QParts["NID"]);
                //    Communication.HttpService.TheHttpService.cdeStreamFile(pRequest, true, 10, tTarget);
                //    if (pRequest.ResponseBuffer == null)
                //        TheRSSGenerator.CreateRSS(pRequest, new List<TheEventLogData>() { new TheEventLogData() { EventName = "Relay did not answer" } }, 1);
                //    return;
                //}
            }
            TheStorageMirror <TheEventLogEntry> tEventLog = TheCDEngines.GetStorageMirror($"{typeof(TheEventLogEntry)}") as TheStorageMirror <TheEventLogEntry>;

            TheRSSGenerator.CreateRSS(pRequest, tEventLog.TheValues.OrderByDescending(s => s.cdeCTIM).ThenByDescending(s => s.cdeCTIM.Millisecond).ToList(), MaxCnt);
        }
        public override void HandleMessage(ICDEThing sender, object pIncoming)
        {
            if (TheCDEngines.MyIStorageService == null)
            {
                return;                                         //No processing if Storage is not active
            }
            TheProcessMessage pMsg = pIncoming as TheProcessMessage;

            if (pMsg == null)
            {
                return;
            }
            if (!mIsInitialized)
            {
                //InitializeStores(); //V4.106: we dont allow this anymore during runtime - the store is either initialized during startup or never available
                return;
            }
            if (MyBaseEngine.GetEngineState().IsService)
            {
                var tCmd = pMsg.Message.TXT.Split(':');
                switch (tCmd[0])
                {
                case "NEW_SENSOR_VALUE":
                    TheSensorValue tData = TheCommonUtils.DeserializeJSONStringToObject <TheSensorValue>(pMsg.Message.PLS);
                    if (tData != null && MySensorStore != null)
                    {
                        //TODO: tCmd[1] has the "ChartToken" that allows to put the value into different tables/charts. For now just one table for all charts
                        MySensorStore.AddAnItem(tData);
                    }
                    break;

                default:
                    ProcessStorageServiceCommands(pMsg.Message, pMsg.LocalCallback, false);
                    break;
                }
                return;
            }

            //CM: Next section is about Remote Storage Services. This will come in a later step
            string[]         reqGuid = pMsg.Message.TXT.Split(':');
            TheTimedCallback tCall   = null;

            if (reqGuid.Length > 1 && (tCall = MyTimedCallbacks.MyMirrorCache.GetEntryByID(TheCommonUtils.CGuid(reqGuid[1]))) != null)
            {
                tCall.MyCallback?.Invoke(pMsg.Message);
                MyTimedCallbacks.RemoveAnItem(tCall, null);
            }
            else
            {
                object tStorageMirror = TheCDEngines.GetStorageMirror(pMsg.Topic); //, out tStorageMirror);
                if (tStorageMirror != null)
                {
                    Type magicType = tStorageMirror.GetType();
#if CDE_STANDARD
                    MethodInfo magicMethod = magicType.GetTypeInfo().GetDeclaredMethod("sinkProcessServiceMessages");
#else
                    MethodInfo magicMethod = magicType.GetMethod("sinkProcessServiceMessages");
#endif
                    if (magicMethod != null)
                    {
                        magicMethod.Invoke(tStorageMirror, new object[] { pMsg.Message }); //object magicValue =
                    }
                }
            }
        }