示例#1
0
        private void OnDownloadClick(ICDEThing pThing, object pPara)
        {
            TheProcessMessage pMSG = pPara as TheProcessMessage;

            if (pMSG == null || pMSG.Message == null)
            {
                return;
            }

            string[] cmd = pMSG.Message.PLS.Split(':');
            if (cmd.Length > 2)
            {
                TheThing tThing = TheThingRegistry.GetThingByMID("*", TheCommonUtils.CGuid(cmd[2]), true);
                if (tThing == null)
                {
                    return;
                }

                TSM tFilePush = new TSM(eEngineName.ContentService, string.Format("CDE_FILE:{0}.JSON:application/zip", tThing.FriendlyName))
                {
                    SID = pMSG.Message.SID,
                    PLS = "bin",
                    PLB = TheCommonUtils.CUTF8String2Array(TheCommonUtils.SerializeObjectToJSONString(tThing))
                };
                TheCommCore.PublishToOriginator(pMSG.Message, tFilePush);
            }
        }
示例#2
0
        void SetupModbusProperties(bool bReload, TheProcessMessage pMsg)
        {
            if (MyModConnectForm != null)
            {
                List <TheFieldInfo> tLst = TheNMIEngine.GetFieldsByFunc(s => s.FormID == MyModConnectForm.cdeMID);
                foreach (TheFieldInfo tInfo in tLst)
                {
                    if (tInfo.FldOrder >= 600 && TheCommonUtils.CInt(tInfo.PropBagGetValue("ParentFld")) == 500)
                    {
                        TheNMIEngine.DeleteFieldById(tInfo.cdeMID);
                    }
                }

                List <cdeP> props  = MyBaseThing.GetPropertiesMetaStartingWith("MODPROP");
                int         fldCnt = 600;
                foreach (var p in props)
                {
                    var field = MyModFieldStore.MyMirrorCache.GetEntryByFunc(s => s.PropertyName == p.Name);
                    if (field != null)
                    {
                        TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.SingleEnded, fldCnt++, field.AllowWrite ? 2 : 0, 0, p.Name, p.Name, new nmiCtrlSingleEnded()
                        {
                            TileWidth = 6, ParentFld = 500
                        });
                    }
                }
                MyModConnectForm.Reload(pMsg, bReload);
            }
        }
示例#3
0
        async void HandleMessageAsync(ICDEThing pSender, object para)
        {
            TheProcessMessage tMsg = para as TheProcessMessage;

            if (tMsg == null || tMsg.Message == null)
            {
                return;
            }

            var tCmd = tMsg.Message.TXT.Split(':');

            switch (tCmd[0])
            {
            case "MsgChatHello":
                try
                {
                    var t = TheCommonUtils.DeserializeJSONStringToObject <MsgChatHello>(tMsg.Message.PLS);
                    await UpdateLog($"{t.SenderName}: {t.Message}");
                } catch (Exception)
                {
                    await UpdateLog($"SOMEBODY SENT ILLEGAL JSON");
                }
                break;
            }
        }
        public void HandleMessage(ICDEThing sender, object pIncoming)
        {
            TheProcessMessage pMsg = pIncoming as TheProcessMessage;

            if (pMsg == null)
            {
                return;
            }

            var tCmd = pMsg.Message.TXT.Split(':');

            switch (tCmd[0])
            {
            case "CDE_NODETOPICS":
                sinkServiceInfo(pMsg?.Message);
                break;

            case "ADD_FOOTPRINT":
                var Tf = TheCommonUtils.DeserializeJSONStringToObject <NodeTypeScript>(pMsg.Message.PLS);
                if (Tf?.NodeTypes != null && Tf.NodeTypes.Count > 0)
                {
                    MyFootPrints.AddItems(Tf.NodeTypes, null);
                }
                TheCommCore.PublishToOriginator(pMsg.Message, new TSM(pMsg.Message.ENG, $"{tCmd[0]}_RESPONSE{(tCmd.Length>1?$":{tCmd[1]}":"")}", "{\"RESPONSE\":\"SUCCESS\"}"), true);
                break;
            }
        }
示例#5
0
        bool Connect(TheProcessMessage pMsg)
        {
            bool bSuccess = false;

            try
            {
                MyBaseThing.StatusLevel = 4; // ReaderThread will set statuslevel to 1
                foreach (var field in MyModFieldStore.TheValues)
                {
                    var p = MyBaseThing.GetProperty(field.PropertyName, true);
                    p.cdeM = "MODPROP";
                    p.UnregisterEvent(eThingEvents.PropertyChangedByUX, null);
                    p.RegisterEvent(eThingEvents.PropertyChangedByUX, sinkPChanged);
                }
                SetupModbusProperties(true, pMsg);
                IsConnected             = true;
                MyBaseThing.LastMessage = $"{DateTime.Now} - Device Connecting";
                TheBaseAssets.MySYSLOG.WriteToLog(10000, TSM.L(eDEBUG_LEVELS.ESSENTIALS) ? null : new TSM(MyBaseThing.EngineName, MyBaseThing.LastMessage, eMsgLevel.l4_Message));
                TheCommonUtils.cdeRunAsync($"ModRunThread{MyBaseThing.FriendlyName}", true, (o) =>
                {
                    ReaderThread();
                });
                bSuccess = true;
            }
            catch (Exception e)
            {
                MyBaseThing.StatusLevel = 3;
                string error = $"Error connecting: {e.Message}";
                MyBaseThing.LastMessage = $"{DateTimeOffset.Now}: {error}";
                TheBaseAssets.MySYSLOG.WriteToLog(10000, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM(MyBaseThing.EngineName, error, eMsgLevel.l1_Error, e.ToString()));
                IsConnected = false;
            }
            return(bSuccess);
        }
示例#6
0
        /// <summary>
        /// Handles Messages sent from a host sub-engine to its clients
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="pIncoming"></param>
        public override void HandleMessage(ICDEThing sender, object pIncoming)
        {
            TheProcessMessage pMsg = pIncoming as TheProcessMessage;

            if (pMsg == null)
            {
                return;
            }

            string[] cmd = pMsg.Message.TXT.Split(':');
            switch (cmd[0])
            {
            case "CDE_INITIALIZED":
                MyBaseEngine.SetInitialized(pMsg.Message);
                break;

            case "GET_CHARTDATA":
                Type td = typeof(CDMyC3.TheC3ChartsFactory);
                TheChartFactory.PushChartsData(TheCommonUtils.CGuid(pMsg.Message.PLS), pMsg.Message.GetOriginator(), td.AssemblyQualifiedName);
                break;

            default:
                break;
            }
        }
示例#7
0
 public virtual void Connect(TheProcessMessage pMsg)
 {
     IsConnected             = true;
     MyBaseThing.StatusLevel = 1;
     MyBaseThing.LastMessage = $"Connected to Logger at {DateTimeOffset.Now}";
     TheBaseAssets.MySYSLOG.RegisterEvent2("NewLogEntry", OnNewEvent);
 }
示例#8
0
 public virtual void Disconnect(TheProcessMessage pMsg)
 {
     IsConnected             = false;
     MyBaseThing.StatusLevel = 0;
     MyBaseThing.LastMessage = $"Disconnected from Logger at {DateTimeOffset.Now}";
     TheBaseAssets.MySYSLOG.UnregisterEvent2("NewLogEntry", OnNewEvent);
 }
示例#9
0
        public override void HandleMessage(ICDEThing sender, object pIncoming)
        {
            TheProcessMessage pMsg = pIncoming as TheProcessMessage;

            if (pMsg == null || pMsg.Message == null)
            {
                return;
            }

            var cmd = TheCommonUtils.cdeSplit(pMsg.Message.TXT, ":", false, false);

            switch (cmd[0])
            {
            case nameof(MsgAddConnectionThing <TConnectionThingParam>):
                var addMsg = TheCommRequestResponse.ParseRequestMessageJSON <MsgAddConnectionThing <TConnectionThingParam> >(pMsg.Message);

                var responseMsg = new MsgAddConnectionThingResponse {
                    Error = "Unexpected"
                };
                if (addMsg != null)
                {
                    var thingToAdd = addMsg.ThingToAdd;

                    if (thingToAdd != null)
                    {
                        var currentThing = MyConnectionThings.MyMirrorCache.GetEntryByID(thingToAdd.cdeMID);
                        var newThing     = new TConnectionThing();
                        newThing.Initialize(thingToAdd);

                        if (currentThing == null)
                        {
                            MyConnectionThings.AddAnItem(newThing);
                            responseMsg.Error = null;
                        }
                        else
                        {
                            if (!newThing.IsEqual(currentThing))
                            {
                                UpdateConnectionThing(currentThing, newThing);
                                MyConnectionThings.UpdateItem(newThing);
                                Connect();
                            }
                            responseMsg.Error = null;
                        }
                    }
                    else
                    {
                        responseMsg.Error = "INVALIDARGS";
                    }
                }
                TheCommRequestResponse.PublishResponseMessageJson(pMsg.Message, responseMsg);
                break;

            default:
                base.HandleMessage(sender, pIncoming);
                break;
            }
        }
        /// <summary>
        /// If this is a service the SimplexProc event will be called when the C-DEngine receives a new event sent by a subscriber to this service
        /// </summary>
        /// <param name="pMsg">The Message to be Processed</param>
        private void ProcessServiceMessage(TheProcessMessage pMsg)
        {
            string[] cmd = pMsg.Message.TXT.Split(':');
            switch (cmd[0]) //string 2 cases
            {
            case "WEBRELAY_RESPONSE":
                TheRequestData tState = TheCommonUtils.DeserializeJSONStringToObject <TheRequestData>(pMsg.Message.PLS);
                if (pMsg.Message.PLB != null && pMsg.Message.PLB.Length > 0)
                {
                    tState.ResponseBuffer = pMsg.Message.PLB;
                }
                tState.RequestUri = new Uri(tState.RequestUriString);
                //tState.SessionState = new TheSessionState() { SScopeID = pMsg.SID };
                sinkResults(tState);
                break;

            case "WEBRELAY_REQUEST":
                TheRequestData tData = TheCommonUtils.DeserializeJSONStringToObject <TheRequestData>(pMsg.Message.PLS);
                if (tData != null)
                {
                    tData.RequestUri = new Uri(tData.RequestUriString);
                    //tData.SessionState = new TheSessionState() { SScopeID = pMsg.SID };
                    if (pMsg.Message.PLB != null && pMsg.Message.PLB.Length > 0)
                    {
                        tData.PostData = pMsg.Message.PLB;
                    }
                    tData.CookieObject = pMsg.Message;
                    ReadHttpPage(tData, tData.SessionState.ARApp, null, sinkProcessResponse);
                    //InterceptHttpRequest(tData,tData.SessionState.ARApp);
                }
                break;

            case "WEBRELAY_REQUESTWRA":
                TSM             tTSM    = new TSM();
                List <TheThing> webApps = TheThingRegistry.GetThingsOfEngine(MyBaseEngine.GetEngineName());
                foreach (TheThing tApp in webApps)
                {
                    if (tApp.Address.Equals(pMsg.Message.PLS))
                    {
                        tTSM.PLS = $"/CDEWRA{tApp.cdeMID}" + TheThing.GetSafePropertyString(tApp, "HomePage");
                        break;
                    }
                }
                if (!string.IsNullOrEmpty(tTSM.PLS))
                {
                    string[]    org          = pMsg.Message.ORG.Split(':');
                    TheThing    senderThing  = TheThingRegistry.GetThingByMID(TheCommonUtils.CGuid(org[1]), true);
                    IBaseEngine senderEngine = TheThingRegistry.GetBaseEngine(senderThing, true);
                    tTSM.ENG = senderEngine.GetEngineName();
                    tTSM.TXT = "RESPONSEWRA";
                    TheCommCore.PublishToOriginator(pMsg.Message, tTSM, true);
                }
                break;
            }
        }
示例#11
0
 bool Disconnect(TheProcessMessage pMsg)
 {
     CloseModBus();
     MyBaseThing.StatusLevel = 0;
     if (MyBaseThing.LastMessage.Contains("- Device Connected"))
     {
         MyBaseThing.LastMessage = $"{DateTime.Now} - Device Disconnected";
     }
     IsConnected = false;
     return(true);
 }
示例#12
0
 void sinkConnect(TheProcessMessage pMsg, bool isConnected)
 {
     if (isConnected)
     {
         Connect(pMsg);
     }
     else
     {
         Disconnect(pMsg);
     }
 }
示例#13
0
 void sinkConnect(TheProcessMessage pMsg, bool DoConnect)
 {
     if (DoConnect)
     {
         Connect(pMsg);
     }
     else
     {
         Disconnect(pMsg);
     }
 }
示例#14
0
        public override void Disconnect(TheProcessMessage pMsg)
        {
            IsConnected             = false;
            MyBaseThing.StatusLevel = 0;
            var tList = TheThingRegistry.GetBaseEngines(true);

            foreach (var tEng in tList)
            {
                tEng.GetBaseThing()?.UnregisterStatusChanged(sinkSTChange);
                tEng.GetBaseThing()?.GetProperty("LastMessage", true).UnregisterEvent(eThingEvents.PropertyChanged, sinkLMChange);
            }
            MyBaseThing.LastMessage = $"Disconnected from Logger at {DateTimeOffset.Now}";
        }
示例#15
0
        public override bool DoCreateUX()
        {
            return(true); //TODO: Make much better UX here...Remove Controls first then create (see OPC DA Plugin)

#pragma warning disable CS0162
            MyStatusForm = TheNMIEngine.AddForm(new TheFormInfo(MyBaseThing)
            {
                FormTitle = MyBaseThing.FriendlyName, DefaultView = eDefaultView.Form
            });
            SummaryForm = TheNMIEngine.AddFormToThingUX(MyBaseThing, MyStatusForm, "CMyForm", MyBaseThing.FriendlyName, 3, 1, 0x0, "OPC UA Methods", "FriendlyName", new ThePropertyBag()
            {
            });

            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleEnded, 1, 0, MyBaseThing.cdeA, "OPC UA Method Name", "FriendlyName");

            TheFieldInfo mSendbutton = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TileButton, 2, 0x82, 0, "Call", false, "", null, new ThePropertyBag()
            {
                "PreventDefault", "TileWidth=2", "TileHeight=1", "Style=background-image:url('GlasButton.png');"
            });
            mSendbutton.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "", (pThing, pObj) =>
            {
                TheProcessMessage pMsg = pObj as TheProcessMessage;
                if (m_Method == null || m_Method.MyOPCServer == null || !m_Method.MyOPCServer.IsConnected)
                {
                    TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", "Server not connected - please connect first"));
                    return;
                }
                HandleMessage(this, new TheProcessMessage(new TSM(MyBaseThing.EngineName, "CALL_METHOD:" + TheCommonUtils.cdeGuidToString(Guid.NewGuid()))));
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TextArea, 3, 0, 0xC0, "Last MSG", false, "LastMessage", null, new ThePropertyBag()
            {
                "TileWidth=6", "TileHeight=3"
            });

            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SmartLabel, 100, 0, MyBaseThing.cdeA, "", false, null, null, new ThePropertyBag()
            {
                "Format=Input Arguments", "Style=font-size:20px;text-align: left;float:none;clear:left;background-color:black;color:white;"
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SmartLabel, 200, 0, MyBaseThing.cdeA, "", false, null, null, new ThePropertyBag()
            {
                "Format=Output Arguments", "Style=font-size:20px;text-align: left;float:none;clear:left;background-color:black;color:white;"
            });

            CreateDynUX(false);
            return(true);

#pragma warning restore CS0162
        }
示例#16
0
 public override void Disconnect(TheProcessMessage pMsg)
 {
     base.Disconnect(pMsg);
     if (TheCommCore.MyHttpService != null)
     {
         TheCommCore.MyHttpService.UnregisterHttpInterceptorB4("/EVTLOG.RSS");
         if (!string.IsNullOrEmpty(MyBaseThing.Address))
         {
             TheCommCore.MyHttpService.UnregisterHttpInterceptorB4(MyBaseThing.Address);
         }
         else
         {
             TheCommCore.MyHttpService.UnregisterHttpInterceptorB4("/SYSLOG.RSS");
         }
     }
 }
示例#17
0
        public override void HandleMessage(ICDEThing sender, object pIncoming)
        {
            TheProcessMessage pMsg = pIncoming as TheProcessMessage;

            if (pMsg == null || pMsg.Message == null)
            {
                return;
            }

            switch (pMsg.Message.TXT)
            {
            default:
                base.HandleMessage(sender, pIncoming);
                break;
            }
        }
示例#18
0
        void sinkFileReceived(ICDEThing pThing, object pFileName)
        {
            TheProcessMessage pMsg = pFileName as TheProcessMessage;

            if (pMsg?.Message == null)
            {
                return;
            }

            var tb = new TheBitmapImage(null, this);

            TheThing.SetSafePropertyString(tb, "CurrentImage", pMsg.Message.TXT);
            tb.GetBaseThing().FriendlyName = pMsg.Message.TXT.Substring(pMsg.Message.TXT.IndexOf('\\') + 1);
            TheThingRegistry.RegisterThing(tb);
            TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", string.Format("###Image-File ({0}) received!###", pMsg.Message.TXT)));
        }
示例#19
0
        public virtual void HandleMessage(ICDEThing sender, object pIncoming)
        {
            TheProcessMessage pMsg = pIncoming as TheProcessMessage;

            if (pMsg == null)
            {
                return;
            }

            string[] cmd = pMsg.Message.TXT.Split(':');
            switch (cmd[0])
            {
            default:
                break;
            }
        }
示例#20
0
        void sinkFileReceived(ICDEThing pThing, object pFileName)
        {
            TheProcessMessage pMsg = pFileName as TheProcessMessage;

            if (pMsg?.Message == null)
            {
                return;
            }

            var tIm = TheThing.GetSafePropertyString(MyBaseThing, "CurrentImage");

            if (!string.IsNullOrEmpty(tIm) && tIm != pMsg.Message.TXT)
            {
                File.Delete(TheCommonUtils.cdeFixupFileName(tIm));
            }
            TheThing.SetSafePropertyString(MyBaseThing, "CurrentImage", pMsg.Message.TXT);
            TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", string.Format("Update to Image-File ({0}) received!", pMsg.Message.TXT)));
        }
示例#21
0
        /// <summary>
        /// Handles Messages sent from a host sub-engine to its clients
        /// </summary>
        public override void HandleMessage(ICDEThing sender, object pIncoming)
        {
            TheProcessMessage pMsg = pIncoming as TheProcessMessage;

            if (pMsg == null)
            {
                return;
            }
            string[] cmd = pMsg.Message.TXT.Split(':');
            switch (cmd[0])
            {
            case "CDE_INITIALIZED":
                MyBaseEngine.SetInitialized(pMsg.Message);
                break;

            case "CDE_INITIALIZE":
                if (MyBaseEngine.GetEngineState().IsService&& MyBaseEngine.GetEngineState().IsLiveEngine)
                {
                    if (!MyBaseEngine.GetEngineState().IsEngineReady)
                    {
                        MyBaseEngine.SetEngineReadiness(true, null);
                    }
                }
                MyBaseEngine.ReplyInitialized(pMsg.Message);
                break;

            case "REFFRESHME":
                InitServers();
                if (MyDash != null)
                {
                    MyDash.Reload(pMsg, false);
                }
                break;

            case "SET_LAST_MSG":
                SetLastMessage(TheScopeManager.GetTokenFromScrambledScopeID(pMsg.Message.SID), pMsg.Message.PLS);
                break;

            case "GET_LAST_MSG":
                TheCommCore.PublishToOriginator(pMsg.Message, new TSM(MyBaseEngine.GetEngineName(), "SET_LAST_MSG", ReturnLastMessage()));
                break;
            }
        }
示例#22
0
        public override void HandleMessage(ICDEThing sender, object pIncoming)
        {
            TheProcessMessage pMsg = pIncoming as TheProcessMessage;

            if (pMsg == null)
            {
                return;
            }

            string[] cmd = pMsg.Message.TXT.Split(':');

            switch (cmd[0])
            {
            case "UPDATE_VALUE":
                ScanAllServices();
                break;

            case "REFRESH_DASH":
                InitNetworkServices();
                mMyDashboard.Reload(pMsg, false);
                break;

            case "CDE_INITIALIZED":
                MyBaseEngine.SetInitialized(pMsg.Message);
                break;

            case "CDE_INITIALIZE":
                if (MyBaseEngine.GetEngineState().IsService)
                {
                    if (!MyBaseEngine.GetEngineState().IsEngineReady)
                    {
                        MyBaseEngine.SetEngineReadiness(true, null);
                    }
                    MyBaseEngine.ReplyInitialized(pMsg.Message);
                }
                break;

            default:
                TheThing tt = TheThingRegistry.GetThingByProperty(MyBaseEngine.GetEngineName(), Guid.Empty, "ID", pMsg.Message.PLS);
                tt?.HandleMessage(sender, pMsg);
                break;
            }
        }
示例#23
0
        void sinkFileReceived(ICDEThing pThing, object pFileName)
        {
            TheProcessMessage pMsg = pFileName as TheProcessMessage;

            if (pMsg?.Message == null)
            {
                return;
            }
            try
            {
                LoadXMLDefinition(pMsg.Message.TXT);
                TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", string.Format("Modbus Definition File ({0}) received - Creating UX", pMsg.Message.TXT)));
                mMyDashboard.Reload(pMsg, true);
            }
            catch (Exception)
            {
                TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_ERROR", $"Modbus Definition File ({pMsg.Message.TXT}) received but creating UX failed!"));
            }
        }
示例#24
0
 public void HandleMessage(TheProcessMessage msg)
 {
     if (msg.Message.TXT.StartsWith(MessageToken.RegistryAlive) ||
         msg.Message.TXT.StartsWith(MessageToken.DiscoveryResponse) ||
         msg.Message.TXT.StartsWith(MessageToken.SubscribeTrigger))
     {
         var registryIdentity = TheCommonUtils.DeserializeJSONStringToObject <RegistryIdentity>(msg.Message.PLS);
         HandleMessage(msg.Message.ORG, registryIdentity.instanceId, msg.Message.TXT, msg.Message);
     }
     else if (msg.Message.TXT.StartsWith(MessageToken.SubscribeResponse))
     {
         var subscribeResponse = TheCommonUtils.DeserializeJSONStringToObject <RegistrySubscriptionResponse>(msg.Message.PLS);
         HandleMessage(msg.Message.ORG, subscribeResponse.instanceId, msg.Message.TXT, msg.Message);
     }
     else
     {
         HandleMessage(msg.Message.ORG, null, msg.Message.TXT, msg.Message);
     }
 }
示例#25
0
//TODO: Step 4: Write your Business Logic

        #region Message Handling
        /// <summary>
        /// Handles Messages sent from a host sub-engine to its clients
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="pIncoming"></param>
        public void HandleMessage(ICDEThing sender, object pIncoming)
        {
            TheProcessMessage pMsg = pIncoming as TheProcessMessage;

            if (pMsg == null)
            {
                return;
            }

            string[] cmd = pMsg.Message.TXT.Split(':');
            switch (cmd[0])
            {
            case "CDE_INITIALIZED":
                MyBaseEngine.SetInitialized(pMsg.Message);
                break;

            default:
                break;
            }
        }
示例#26
0
 public override void Connect(TheProcessMessage pMsg)
 {
     base.Connect(pMsg);
     if (TheCommCore.MyHttpService != null)
     {
         if (!string.IsNullOrEmpty(MyBaseThing.Address))
         {
             if (!MyBaseThing.Address.StartsWith("/"))
             {
                 MyBaseThing.Address = $"/{MyBaseThing.Address}";
             }
             TheCommCore.MyHttpService.RegisterHttpInterceptorB4(MyBaseThing.Address, InterceptRSSRequest);
         }
         else
         {
             TheCommCore.MyHttpService.RegisterHttpInterceptorB4("/SYSLOG.RSS", InterceptRSSRequest);
         }
         TheCommCore.MyHttpService.RegisterHttpInterceptorB4("/EVTLOG.RSS", InterceptRSSEvtRequest);
     }
 }
示例#27
0
        void sinkFileReceived(ICDEThing pThing, object pFileName)
        {
            TheProcessMessage pMsg = pFileName as TheProcessMessage;

            if (pMsg?.Message == null)
            {
                return;
            }
            try
            {
                string tGuid = $"THH{Guid.NewGuid()}";
                //File.Copy(TheCommonUtils.cdeFixupFileName(pMsg.Message.TXT), TheCommonUtils.cdeFixupFileName($"/cache/{tGuid}"));
                CreateTHHUx(tGuid, TheCommonUtils.cdeFixupFileName(pMsg.Message.TXT));
                TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", string.Format("KPI File ({0}) received - Creating UX", pMsg.Message.TXT)));
                MyPCVitalsDashboard.Reload(pMsg, true);
            }
            catch (Exception)
            {
                TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_ERROR", $"KPI File ({pMsg.Message.TXT}) received but creating UX failed!"));
            }
        }
示例#28
0
        public override void Connect(TheProcessMessage pMsg)
        {
            if (IsConnected)
            {
                return;
            }
            IsConnected             = true;
            MyBaseThing.StatusLevel = 1;
            MyBaseThing.LastMessage = $"Connected to Logger at {DateTimeOffset.Now}";

            mLogFilePath    = Address;
            mMaxLogFileSize = (int)TheThing.GetSafePropertyNumber(MyBaseThing, "MaxLogFileSize");
            mWriteToConsole = TheThing.GetSafePropertyBool(MyBaseThing, "WriteToConsole");
            MyCurLog        = TheThing.GetSafePropertyString(MyBaseThing, "LogFilePath");
            mLogFileDate    = TheThing.GetSafePropertyDate(MyBaseThing, "LogFileDate");
            if (string.IsNullOrEmpty(MyCurLog) || (mLogFileDate != DateTimeOffset.MinValue && mLogFileDate.Day != DateTimeOffset.Now.Day))
            {
                LogFilePath = MyCurLog = TheCommonUtils.cdeFixupFileName(mLogFilePath + string.Format("\\LOG_{0:yyyMMdd_HHmmss}.txt", DateTime.Now));
                LogFileDate = mLogFileDate = DateTimeOffset.Now;
            }
            TheCommonUtils.CreateDirectories(MyCurLog);
            TheCDEngines.MyContentEngine.RegisterEvent(eEngineEvents.NewEventLogEntry, sinkNewEvent);

#if !CDE_NET4 && !CDE_NET35
            if (TheBaseAssets.MyCmdArgs?.ContainsKey("CreateEventLog") != true)
            {
                // CODE REVIEW: What is the purpose of this export?
                var pipelineConfig = MyBaseThing.GetThingPipelineConfigurationAsync(false).Result;
                if (pipelineConfig != null)
                {
                    var tWrite = TheCommonUtils.SerializeObjectToJSONString(pipelineConfig);
                    TheCommonUtils.CreateDirectories(TheCommonUtils.cdeFixupFileName($"\\ConfigTemplates\\{MyBaseThing.FriendlyName}.cdeConfig"));
                    using (System.IO.StreamWriter fs = new System.IO.StreamWriter(TheCommonUtils.cdeFixupFileName($"\\ConfigTemplates\\{MyBaseThing.FriendlyName}.cdeConfig"), false))
                    {
                        fs.Write(tWrite);
                    }
                }
            }
#endif
        }
示例#29
0
        public void HandleMessage(ICDEThing sender, object pIncoming)
        {
            TheProcessMessage pMsg = pIncoming as TheProcessMessage;

            if (pMsg == null)
            {
                return;
            }

            string[] cmd = pMsg.Message.TXT.Split(':');
            switch (cmd[0])
            {
            case "CDE_INITIALIZED":
                MyBaseEngine.SetInitialized(pMsg.Message);          //Sets the Service to "Ready". ProcessInitialized() internally contains a call to this Handler and allows for checks right before SetInitialized() is called.
                break;

            case "REFFRESHME":
                InitServices();
                mMyDashboard.Reload(pMsg, false);
                break;
            }
        }
示例#30
0
        public override void DoCreateUX()
        {
            TheFormInfo tMyLiveForm = new TheFormInfo(new Guid("{CCCCCCCC-978D-4443-BC88-543962366B81}"), eEngineName.NMIService, "BTMid:" + MyBaseThing.cdeMID.ToString(), null)
            {
                DefaultView = eDefaultView.IFrame, PropertyBag = new nmiCtrlIFrameView {
                    TileWidth = 18, TileHeight = 11, Source = "http://www.chrisan.me:8080", OnIFrameLoaded = "NOWN:IFRA"
                }
            };

            TheNMIEngine.AddFormToThingUX(MyBaseThing, tMyLiveForm, "CMyForm", $"IFrame Demo:{MyBaseThing.cdeMID}", 1, 3, 0, "..Demos", null, new ThePropertyBag()
            {
            });
            MyBaseThing.RegisterEvent($"OnLoaded:{tMyLiveForm.cdeMID}:IFRA", (sender, obj) => {
                TheProcessMessage t = obj as TheProcessMessage;
                if (t == null || t.Message.PLS == "http://www.c-labs.com")
                {
                    return;
                }
                TheNMIEngine.SetUXProperty(t.Message.GetOriginator(), tMyLiveForm.cdeMID, "Source=http://www.c-labs.com");
                //TheCommCore.PublishToOriginator(t.Message, new TSM(eEngineName.NMIService, "Something"));
            });
        }