/// <summary>
        /// Handles Messages sent from a host sub-engine to its clients
        /// </summary>
        public void HandleMessage(ICDEThing sender, object pIncoming)
        {
            if (!(pIncoming is TheProcessMessage pMsg))
            {
                return;
            }

            switch (pMsg.Message.TXT)
            {
            case "CDE_INITIALIZED":
                TheBaseAssets.MySYSLOG.WriteToLog(888, TSM.L(eDEBUG_LEVELS.FULLVERBOSE) ? null : new TSM("MiniRelayService", $"BackChannel Updated - ORG:{TheCommonUtils.GetDeviceIDML(pMsg.Message.GetLastRelay())}", eMsgLevel.l3_ImportantMessage));
                break;

            default:
                if (pMsg.Message.TXT.Equals("CDE_INITIALIZE"))
                {
                    TSM tRelayMsg = new TSM(MyBaseEngine.GetEngineName(), "CDE_INITIALIZED")
                    {
                        QDX = 3,
                        SID = pMsg.Message.SID
                    };
                    tRelayMsg.SetNoDuplicates(true);
                    TheBaseAssets.MySYSLOG.WriteToLog(888, TSM.L(eDEBUG_LEVELS.FULLVERBOSE) ? null : new TSM("MiniRelayService", $"Message Text {tRelayMsg.TXT} relayed - ORG:{TheCommonUtils.GetDeviceIDML(tRelayMsg.ORG)}", eMsgLevel.l3_ImportantMessage));    //ORG-OK
                    TheCommCore.PublishCentral(MyBaseEngine.GetEngineName() + pMsg.Message?.AddScopeIDFromTSM(), tRelayMsg);
                }
                break;
            }
        }
Example #2
0
        private void ShowKPI(int pFldOrder, string pLabel, string pUpdName, int MaxVal = 100, int AveVal = 50, string pUnits = "bytes")
        {
            TheNMIEngine.AddSmartControl(MyBaseThing, mMyForm, eFieldType.TileGroup, pFldOrder, 0, 0, null, null, new nmiCtrlTileGroup {
                ParentFld = 300, TileWidth = 6
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, mMyForm, eFieldType.SmartLabel, pFldOrder + 1, 0, 0, null, null, new nmiCtrlSmartLabel {
                ParentFld = pFldOrder, Text = pLabel, NoTE = true, TileFactorY = 2, TileHeight = 1, TileWidth = 5, ClassName = "cdeTileGroupHeaderSmall"
            });
            var tBut = TheNMIEngine.AddSmartControl(MyBaseThing, mMyForm, eFieldType.TileButton, pFldOrder + 2, 2, 0, "V-Tise", null, new nmiCtrlTileButton {
                ParentFld = pFldOrder, NoTE = true, TileFactorY = 2, TileHeight = 1, TileWidth = 1, ClassName = "cdeGlassButton"
            });

            tBut.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, $"But{pUpdName}", (sender, para) =>
            {
                TheThing tT = TheThingRegistry.GetThingByID(MyBaseEngine.GetEngineName(), $"ISO{MyBaseThing.cdeMID}:{pUpdName}");
                if (tT == null)
                {
                    TheKPIReport tRep = new TheKPIReport(null, MyPlugin);
                    TheThing.SetSafePropertyGuid(tRep, "RealSensorThing", MyBaseThing.cdeMID);
                    tRep.GetBaseThing().ID = $"ISO{MyBaseThing.cdeMID}:{pUpdName}";
                    MyBaseThing.GetProperty(pUpdName, true);
                    TheThing.SetSafePropertyString(tRep, "RealSensorProperty", pUpdName);
                    TheThing.SetSafePropertyNumber(tRep, "StateSensorMaxValue", MaxVal);
                    TheThing.SetSafePropertyNumber(tRep, "StateSensorAverage", AveVal);
                    TheThing.SetSafePropertyNumber(tRep, "StateSensorSteps", MaxVal / 15);
                    TheThing.SetSafePropertyString(tRep, "StateSensorValueName", pLabel);
                    TheThing.SetSafePropertyString(tRep, "StateSensorUnit", pUnits);
                    TheThing.SetSafePropertyString(tRep, "FriendlyName", MyBaseThing.FriendlyName);
                    TheThing.SetSafePropertyString(tRep, "ReportName", $"ISO-KPI: {MyBaseThing.FriendlyName} - {pLabel}");
                    TheThing.SetSafePropertyString(tRep, "ReportCategory", "ISO KPI Reports");
                    ThePluginInfo tI = MyPlugin.GetBaseEngine().GetPluginInfo();
                    if (tI != null)
                    {
                        TheThing.SetSafePropertyString(tRep, "SerialNumber", TheCommonUtils.CStr(tI.CurrentVersion));
                        TheThing.SetSafePropertyString(tRep, "VendorName", TheCommonUtils.CStr(tI.Developer));
                        TheThing.SetSafePropertyString(tRep, "ProductName", TheCommonUtils.CStr(tI.ServiceDescription));
                        TheThing.SetSafePropertyString(tRep, "ProductText", TheCommonUtils.CStr(tI.LongDescription));
                        TheThing.SetSafePropertyString(tRep, "VendorText", TheCommonUtils.CStr(tI.DeveloperUrl));
                        TheThing.SetSafePropertyString(tRep, "ProductID", TheCommonUtils.CStr(tI.cdeMID));
                    }
                    TheThingRegistry.RegisterThing(tRep);
                    MyBaseEngine.ProcessMessage(new TheProcessMessage(new TSM(MyBaseEngine.GetEngineName(), "REFRESH_DASH")));
                }
                else
                {
                    TheCommCore.PublishToOriginator((para as TheProcessMessage).Message, new TSM(eEngineName.NMIService, "NMI_TTS", tT.cdeMID.ToString()));
                }
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, mMyForm, eFieldType.SmartLabel, pFldOrder + 3, 0, 0, null, pUpdName, new nmiCtrlSingleEnded {
                ParentFld = pFldOrder, TileWidth = 2
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, mMyForm, eFieldType.BarChart, pFldOrder + 4, 0, 0, null, pUpdName, new nmiCtrlBarChart()
            {
                ParentFld = pFldOrder, MaxValue = MaxVal, TileWidth = 4, NoTE = true, Foreground = "blue"
            });
        }
Example #3
0
        public TheVTimer(TheThing pThing, IBaseEngine pEngine)
            : base(pThing)
        {
            if (pThing != null)
            {
                MyBaseThing = pThing;
            }
            else
            {
                MyBaseThing = new TheThing();
            }

            cdeP tfirstTrigger = MyBaseThing.DeclareNMIProperty("MsToTrigger", ePropertyTypes.TNumber);

            tfirstTrigger.RegisterEvent(eThingEvents.PropertySet, sinkLoopChanged);

            cdeP tLoop = MyBaseThing.DeclareNMIProperty("LoopPeriod", ePropertyTypes.TNumber);

            tLoop.RegisterEvent(eThingEvents.PropertySet, sinkLoopChanged);
            cdeP tTrigger = MyBaseThing.DeclareNMIProperty("TriggerTimer", ePropertyTypes.TString);

            tTrigger.RegisterEvent(eThingEvents.PropertySet, sinkTriggered);

            MyBaseEngine           = pEngine;
            MyBaseThing.DeviceType = eVThings.eVTimer;
            MyBaseThing.EngineName = pEngine.GetEngineName();
            MyBaseThing.SetIThingObject(this);
        }
Example #4
0
 public TheLoggerBase(TheThing tBaseThing, ICDEPlugin pPluginBase)
 {
     MyBaseThing            = tBaseThing ?? new TheThing();
     MyBaseEngine           = pPluginBase.GetBaseEngine();
     MyBaseThing.EngineName = MyBaseEngine.GetEngineName();
     MyBaseThing.SetIThingObject(this);
 }
        public bool CreateUX()
        {
            if (mIsUXInitCalled)
            {
                return(false);
            }
            mIsUXInitCalled = true;

            //NUI Definition for All clients
            mMyDashboard = TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "<i class='cl-font cl-Logo fa-5x'></i><br>Mesh Receiver")
            {
                PropertyBag = new ThePropertyBag()
                {
                    "Category=Connectors"
                }
            });

            TheFormInfo tAllCloudConnections = new TheFormInfo(MyBaseEngine)
            {
                cdeMID = TheThing.GetSafeThingGuid(MyBaseThing, "MeshR"), defDataSource = string.Format("TheThing;:;0;:;True;:;EngineName={0}", MyBaseEngine.GetEngineName()), FormTitle = "Mesh Receiver Connections", AddButtonText = "Add a Connection"
            };

            TheNMIEngine.AddFormToThingUX(MyBaseThing, tAllCloudConnections, "CMyTable", "Mesh Receivers", 1, 0x0D, 0xC0, TheNMIEngine.GetNodeForCategory(), null, new ThePropertyBag()
            {
                "Thumbnail=MicrosoftAzure.png;0.5"
            });
            TheNMIEngine.AddCommonTableColumns(MyBaseThing, tAllCloudConnections, MeshDeviceTypes.GetValues(), MeshDeviceTypes.MeshReceiver, false, true);

            TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo()
            {
                FldOrder = 5, cdeA = 0xC0, Flags = 6, Type = eFieldType.SingleCheck, FldWidth = 1, Header = "Auto-Connect", DataItem = "MyPropertyBag.AutoConnect.Value"
            });
            TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo()
            {
                FldOrder = 6, cdeA = 0xC0, Flags = 0, Type = eFieldType.SingleCheck, FldWidth = 1, Header = "Is Connected", DataItem = "MyPropertyBag.IsConnected.Value", PropertyBag = new nmiCtrlSingleCheck {
                    AreYouSure = "Are you sure you want to connect/disconnect?"
                }
            });
            TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo()
            {
                FldOrder = 7, cdeA = 0xC0, Flags = 0, Type = eFieldType.SingleCheck, FldWidth = 1, Header = "Connecting", DataItem = "MyPropertyBag.Connecting.Value"
            });
            TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo()
            {
                FldOrder = 8, cdeA = 0xC0, Flags = 0, Type = eFieldType.SingleCheck, FldWidth = 1, Header = "Disconnecting", DataItem = "MyPropertyBag.Disconnecting.Value"
            });
            TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo()
            {
                FldOrder = 50, cdeA = 0xFF, Type = eFieldType.DateTime, FldWidth = 2, Header = "Last Update", DataItem = "MyPropertyBag.LastUpdate.Value"
            });

            TheThingRegistry.UpdateEngineUX(MyBaseEngine.GetEngineName());

            TheNMIEngine.AddAboutButton(MyBaseThing, true, "REFRESH_DASH", 0xc0);
            TheNMIEngine.RegisterEngine(MyBaseEngine);

            mIsUXInitialized = true;
            return(true);
        }
Example #6
0
        void sinkUpdateUX(cdeP pProp)
        {
            int i = MyBaseThing.StatusLevel; //Optimizing that GetProperty is not called 3 times

            SummaryForm?.SetUXProperty(Guid.Empty, string.Format("Background={0}", TheNMIEngine.GetStatusColor(i)));

            MyBaseEngine.ProcessMessage(new TheProcessMessage(new TSM(MyBaseEngine.GetEngineName(), "UPDATE_VALUE")));
        }
Example #7
0
 public TheMemoryTag(TheThing pThing, IBaseEngine pEngine)
 {
     MyBaseThing            = pThing ?? new TheThing();
     MyBaseEngine           = pEngine;
     MyBaseThing.DeviceType = eVThings.eMemoryTag;
     MyBaseThing.EngineName = pEngine.GetEngineName();
     MyBaseThing.SetIThingObject(this);
 }
Example #8
0
 public TheVStateSensor(TheThing pThing, IBaseEngine pEngine)
     : base(pThing)
 {
     MyBaseThing            = pThing ?? new TheThing();
     MyBaseThing.DeviceType = eVThings.eVStateSensor;
     MyBaseThing.EngineName = pEngine.GetEngineName();
     MyBaseThing.SetIThingObject(this);
 }
Example #9
0
 public TheSineWave(TheThing pThing, IBaseEngine pEngine) : base(pThing)
 {
     MyBaseThing            = pThing ?? new TheThing();
     MyBaseEngine           = pEngine;
     MyBaseThing.DeviceType = eVThings.eSineWave;
     MyBaseThing.EngineName = pEngine.GetEngineName();
     MyBaseThing.SetIThingObject(this);
 }
Example #10
0
 public TheDemoBase(TheThing tBaseThing, ICDEPlugin pPluginBase)
 {
     MyBaseThing            = tBaseThing ?? new TheThing();
     MyBaseEngine           = pPluginBase.GetBaseEngine();
     MyBaseThing.EngineName = MyBaseEngine.GetEngineName();
     MyBaseThing.SetIThingObject(this);
     TheThingRegistry.RegisterThing(this);
 }
Example #11
0
 public TheBitmapImage(TheThing tBaseThing, ICDEPlugin pPluginBase)
 {
     MyBaseThing            = tBaseThing ?? new TheThing();
     MyBaseEngine           = pPluginBase.GetBaseEngine();
     MyBaseThing.EngineName = MyBaseEngine.GetEngineName();
     MyBaseThing.SetIThingObject(this);
     MyBaseThing.DeviceType = eImageTypes.Bitmap;
     TheThing.SetSafePropertyBool(MyBaseThing, "IsCamera", true);
 }
        /// <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;
            }
        }
Example #13
0
        public TheNMIElement(TheThing pThing, IBaseEngine pEngine)
            : base(pThing)
        {
            MyBaseThing            = pThing ?? new TheThing();
            MyBaseEngine           = pEngine;
            MyBaseThing.DeviceType = eVThings.eNMIElement;
            MyBaseThing.EngineName = pEngine.GetEngineName();
            MyBaseThing.SetIThingObject(this);

            TheBaseEngine.WaitForEnginesStarted(sinkUpdateControls);
        }
Example #14
0
 public TheDataVerifier(TheThing pThing, IBaseEngine pEngine)
 {
     MyBaseThing            = pThing ?? new TheThing();
     MyBaseEngine           = pEngine;
     MyBaseThing.DeviceType = eVThings.eDataVerifier;
     MyBaseThing.EngineName = pEngine.GetEngineName();
     MyBaseThing.SetIThingObject(this);
     if (TheThing.GetSafePropertyBool(MyBaseThing, "AutoStart"))
     {
         StartVerifier();
     }
 }
Example #15
0
 public TheISOlaterKPIs(TheThing tBaseThing, ICDEPlugin pPluginBase, string pEngineName)
 {
     MyBaseThing            = tBaseThing ?? new TheThing();
     MyBaseEngine           = pPluginBase.GetBaseEngine();
     MyPlugin               = pPluginBase;
     MyBaseThing.EngineName = MyBaseEngine.GetEngineName();
     MyBaseThing.DeviceType = eDeviceType;
     TheThing.SetSafePropertyString(MyBaseThing, "ISOLaterName", pEngineName);
     if (string.IsNullOrEmpty(MyBaseThing.FriendlyName))
     {
         MyBaseThing.FriendlyName = pEngineName;
     }
     MyBaseThing.SetIThingObject(this);
 }
 public TheMessageAddress(TheThing targetThing)
 {
     if (targetThing == null || (_baseEngine = targetThing.GetBaseEngine()) == null)
     {
         Node       = Guid.Empty;
         EngineName = "";
         ThingMID   = Guid.Empty;
         return;
     }
     Node          = targetThing.cdeN;
     EngineName    = _baseEngine.GetEngineName();
     ThingMID      = targetThing.cdeMID;
     FirstNodeOnly = false;
     ServiceOnly   = true;
 }
Example #17
0
 public TheDataGenerator(TheThing pThing, IBaseEngine pEngine)
 {
     if (pThing != null)
     {
         MyBaseThing = pThing;
     }
     else
     {
         MyBaseThing = new TheThing();
     }
     MyBaseEngine           = pEngine;
     MyBaseThing.DeviceType = eVThings.eDataGenerator;
     MyBaseThing.EngineName = pEngine.GetEngineName();
     MyBaseThing.SetIThingObject(this);
 }
Example #18
0
        public TheVCountdown(TheThing pThing, IBaseEngine pEngine)
            : base(pThing)
        {
            if (pThing != null)
            {
                MyBaseThing = pThing;
            }
            else
            {
                MyBaseThing = new TheThing();
            }

            MyBaseThing.DeviceType = eVThings.eVCountdown;
            MyBaseThing.EngineName = pEngine.GetEngineName();
            MyBaseThing.SetIThingObject(this);
            IsActive = false;
        }
Example #19
0
 public ModbusTCPDevice(TheThing tBaseThing, ICDEPlugin pPluginBase, DeviceDescription pModDeviceDescription)
 {
     if (tBaseThing != null)
     {
         MyBaseThing = tBaseThing;
     }
     else
     {
         MyBaseThing = new TheThing();
     }
     MyBaseEngine           = pPluginBase.GetBaseEngine();
     MyBaseThing.DeviceType = eModbusType.ModbusTCPDevice;
     MyBaseThing.EngineName = MyBaseEngine.GetEngineName();
     MyBaseThing.SetIThingObject(this);
     MyDevice = pModDeviceDescription;
     if (MyDevice != null && !String.IsNullOrEmpty(MyDevice.Name))
     {
         MyBaseThing.FriendlyName = MyDevice.Name;
     }
     MyBaseThing.AddCapability(eThingCaps.SensorProvider);
 }
        private void InterceptHttpRequest(TheRequestData pRequest, Guid MyApp, IBaseEngine MyBaseEngine, int pRequestTimeout) // TheRelayAppInfo MyApp)
        {
            if (MyApp == Guid.Empty)
            {
                return;
            }
            TheRequestData tOutBuffer = null;
            //NEW BY CM
            string tMagixc = Guid.NewGuid().ToString();

            ReqBuffer.AddOrUpdateItem(TheCommonUtils.CGuid(tMagixc), null, null);
            if (!MyBaseEngine.GetEngineState().IsService) // || string.IsNullOrEmpty(MyApp.TargetUrl) || !TheCommonUtils.IsLocalhost(MyApp.HostUrl)) //  !MyApp.HostUrl.Equals(TheBaseAssets.MyServiceHostInfo.MyStation URL))
            {
                TSM tTSM = new TSM(MyBaseEngine.GetEngineName(), "WEBRELAY_REQUEST")
                {
                    PLB = pRequest.PostData
                };
                pRequest.PostData       = null;
                pRequest.ResponseBuffer = null;
                if (!string.IsNullOrEmpty(pRequest.CookieString))
                {
                    pRequest.CookieString += ";";
                }
                else
                {
                    pRequest.CookieString = "";
                }
                pRequest.CookieString += tMagixc;
                //if (string.IsNullOrEmpty(MyApp.CloudUrl)) MyApp.CloudUrl = TheBaseAssets.MyServiceHostInfo.GetPrimaryStationURL(false);
                if (string.IsNullOrEmpty(TheBaseAssets.MyServiceHostInfo.RootDir))
                {
                    pRequest.RequestUriString = pRequest.RequestUri.ToString();
                }
                else
                {
                    pRequest.RequestUriString = pRequest.RequestUri.Scheme + "://" + pRequest.RequestUri.Host + ":" + pRequest.RequestUri.Port + pRequest.cdeRealPage;
                    if (!string.IsNullOrEmpty(pRequest.RequestUri.Query))
                    {
                        pRequest.RequestUriString += "?" + pRequest.RequestUri.Query;
                    }
                }
                TheBaseAssets.MySYSLOG.WriteToLog(400, TSM.L(eDEBUG_LEVELS.ESSENTIALS) ? null : new TSM(MyBaseEngine.GetEngineName(), string.Format("Requesting Page:{0}", pRequest.RequestUriString), eMsgLevel.l6_Debug));

                tTSM.PLS = TheCommonUtils.SerializeObjectToJSONString(pRequest);
                tTSM.SID = pRequest.SessionState.GetSID(); //.SScopeID;
                TheCommCore.PublishCentral(tTSM);          //  .PublishToNode(MyApp.HostUrl, pRequest.SessionState.SScopeID, tTSM);
            }
            else
            {
                TheBaseAssets.MySYSLOG.WriteToLog(400, TSM.L(eDEBUG_LEVELS.VERBOSE) ? null : new TSM(MyBaseEngine.GetEngineName(), string.Format("AppID:{1} Requesting Page:{0}", pRequest.cdeRealPage, MyApp)));
                ReadHttpPage(pRequest, MyApp, tMagixc, sinkResults);
            }
            int SyncFailCount      = 0;
            ManualResetEvent MyMRE = new ManualResetEvent(false);

            do
            {
                try
                {
                    tOutBuffer = ReqBuffer.GetEntryByID(TheCommonUtils.CGuid(tMagixc));
                    if (tOutBuffer != null)
                    {
                        pRequest.ResponseBuffer   = tOutBuffer.ResponseBuffer;
                        pRequest.ResponseMimeType = tOutBuffer.ResponseMimeType;
                        if (pRequest.SessionState.StateCookies == null)
                        {
                            pRequest.SessionState.StateCookies = new cdeConcurrentDictionary <string, string>();
                        }
                        if (tOutBuffer.SessionState != null && tOutBuffer.SessionState.StateCookies != null && tOutBuffer != pRequest)
                        {
                            foreach (KeyValuePair <String, String> kvp in tOutBuffer.SessionState.StateCookies.GetDynamicEnumerable())
                            {
                                string value;
                                if (!pRequest.SessionState.StateCookies.TryGetValue(kvp.Key, out value))
                                {
                                    pRequest.SessionState.StateCookies.TryAdd(kvp.Key, kvp.Value);
                                }
                                else
                                {
                                    pRequest.SessionState.StateCookies[kvp.Key] = kvp.Value;
                                }
                            }
                        }

                        if (!string.IsNullOrEmpty(tOutBuffer.ResponseBufferStr))
                        {
                            pRequest.ResponseBufferStr = tOutBuffer.ResponseBufferStr;
                        }
                        else
                        {
                            if (pRequest.ResponseMimeType.StartsWith("text/html") || pRequest.ResponseMimeType.Contains("javascript"))  //OK
                            {
                                pRequest.ResponseBufferStr = TheCommonUtils.CArray2UTF8String(tOutBuffer.ResponseBuffer);
                            }
                        }
                        string tReqUri = pRequest.RequestUri.Host;
                        if (pRequest.RequestUri.Port != 80)
                        {
                            tReqUri += ":" + pRequest.RequestUri.Port;
                        }
                        TheBaseAssets.MySYSLOG.WriteToLog(400, TSM.L(eDEBUG_LEVELS.ESSENTIALS) ? null : new TSM(MyBaseEngine.GetEngineName(), string.Format("Got Response Page:{0}", tReqUri), eMsgLevel.l6_Debug));

                        if (!string.IsNullOrEmpty(pRequest.ResponseBufferStr) && (pRequest.ResponseMimeType.StartsWith("text/html") || pRequest.ResponseMimeType.Contains("javascript")) && pRequest.ResponseBufferStr.IndexOf(tReqUri, StringComparison.CurrentCultureIgnoreCase) >= 0)
                        {
                            if (pRequest.SessionState.ARApp != null && pRequest.SessionState.ARApp != Guid.Empty)
                            {
                                TheRelayAppInfo tMyApp = TheThingRegistry.GetThingObjectByMID(MyBaseEngine.GetEngineName(), pRequest.SessionState.ARApp) as TheRelayAppInfo;
                                //MyRelayApps.MyMirrorCache.GetEntryByFunc(s => s.cdeMID.Equals(pRequest.SessionState.ARApp));

                                if (tMyApp != null && tMyApp.CloudUrl != null)
                                {
                                    Uri tCloudUri = TheCommonUtils.CUri(tMyApp.CloudUrl, false);
                                    if (!string.IsNullOrEmpty(pRequest.NewLocation))
                                    {
                                        pRequest.NewLocation = pRequest.NewLocation.Replace(pRequest.RequestUri.Scheme + "://" + tReqUri, tCloudUri.Scheme + "://" + tCloudUri.Host + ":" + tCloudUri.Port);
                                    }
                                    TheBaseAssets.MySYSLOG.WriteToLog(400, TSM.L(eDEBUG_LEVELS.ESSENTIALS) ? null : new TSM(MyBaseEngine.GetEngineName(), string.Format("Patching Uri from:{0} to:{1}", tReqUri, tCloudUri), eMsgLevel.l6_Debug));

                                    pRequest.ResponseBufferStr = pRequest.ResponseBufferStr.Replace(pRequest.RequestUri.Scheme + "://" + tReqUri, tCloudUri.Scheme + "://" + tCloudUri.Host + ":" + tCloudUri.Port);
                                    pRequest.ResponseBuffer    = TheCommonUtils.CUTF8String2Array(pRequest.ResponseBufferStr);
                                }
                            }
                        }
                        break;
                    }
                    MyMRE.WaitOne(50);
                    SyncFailCount++; if (SyncFailCount > (pRequestTimeout * 20))
                    {
                        if (TheCommonUtils.IsMono())
                        {
                            TheBaseAssets.MySYSLOG.WriteToLog(400, new TSM(MyBaseEngine.GetEngineName(), string.Format("Requesting Page:{0} FAILED", pRequest.cdeRealPage), eMsgLevel.l1_Error));
                        }
                        else
                        {
                            TheBaseAssets.MySYSLOG.WriteToLog(400, TSM.L(eDEBUG_LEVELS.ESSENTIALS) ? null : new TSM(MyBaseEngine.GetEngineName(), string.Format("Requesting Page:{0} FAILED", pRequest.cdeRealPage), eMsgLevel.l1_Error));
                        }
                        break;
                    }
                }
                catch (Exception ee)
                {
                    TheBaseAssets.MySYSLOG.WriteToLog(400, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM(MyBaseEngine.GetEngineName(), string.Format("Error during HttpIntercept for Page:{0}", pRequest.cdeRealPage), eMsgLevel.l1_Error, ee.ToString()));
                }
            } while (tOutBuffer == null);
            if (MyMRE != null)
            {
                MyMRE = null; //.Dispose();
            }
            if ((pRequest.ResponseBuffer == null && string.IsNullOrEmpty(pRequest.ResponseBufferStr)) || pRequest.StatusCode != 0)
            {
                if (pRequest.StatusCode == 0)
                {
                    pRequest.StatusCode = 404;
                }
            }
            else
            {
                pRequest.AllowStatePush = true;
                pRequest.StatusCode     = 200;
            }
            ReqBuffer.RemoveAnItemByID(TheCommonUtils.CGuid(tMagixc), null);
        }
Example #21
0
        public virtual bool CreateUX()
        {
            if (mIsUXInitCalled)
            {
                return(false);
            }
            mIsUXInitCalled = true;

            var tFlds = TheNMIEngine.AddStandardForm(MyBaseThing, null, 12, null, "Value");

            MyStatusForm            = tFlds["Form"] as TheFormInfo;
            SummaryForm             = tFlds["DashIcon"] as TheDashPanelInfo;
            SummaryForm.PropertyBag = new ThePropertyBag()
            {
                string.Format("Format={0}<br>{{0}} Properties", MyBaseThing.FriendlyName)
            };
            SummaryForm.RegisterPropertyChanged(sinkStatChanged);

            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 21, 0, 0x0, "###CDMyVThings.TheVThings#CountOfProperties598472#Count of Properties###", "Value", new nmiCtrlNumber()
            {
                ParentFld = 1
            });
            TheFieldInfo mSendbutton = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TileButton, 22, 2, 0, "###CDMyVThings.TheVThings#Reload598472#Reload###", false, "", null, new nmiCtrlTileButton()
            {
                ParentFld = 1, NoTE = true, ClassName = "cdeGoodActionButton"
            });

            mSendbutton.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "", (pThing, pPara) =>
            {
                TheProcessMessage pMsg = pPara as TheProcessMessage;
                if (pMsg?.Message == null)
                {
                    return;
                }
                sinkStatChanged(null, null);
                MyStatusForm.Reload(pMsg, true);
            });
            PropTable = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Table, 40, 0xA0, 0x80, "All Properties", "mypropertybag;0", new TheNMIBaseControl()
            {
                NoTE = true, ParentFld = 1, TileWidth = 12, TileHeight = 16
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleEnded, 30, 0x0A, 0, "New Property Name", "ScratchName", new nmiCtrlSingleEnded()
            {
                ParentFld = 1
            });
            TheFieldInfo tBut = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TileButton, 35, 0x0A, 0, "Add Property", false, null, null, new nmiCtrlTileButton()
            {
                ParentFld = 1, NoTE = true
            });

            tBut.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "AddProp", (pThing, pObj) =>
            {
                TheProcessMessage pMsg = pObj as TheProcessMessage;
                if (pMsg?.Message == null)
                {
                    return;
                }
                string[] parts = pMsg.Message.PLS.Split(':');
                TheThing tOrg  = TheThingRegistry.GetThingByMID(MyBaseEngine.GetEngineName(), TheCommonUtils.CGuid(parts[2]));
                if (tOrg == null)
                {
                    return;
                }

                string tNewPropName = TheThing.GetSafePropertyString(tOrg, "ScratchName");
                if (string.IsNullOrEmpty(tNewPropName))
                {
                    TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", "Please specify a new property name"));
                }
                else
                {
                    if (tOrg.GetProperty(tNewPropName) != null)
                    {
                        TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", "Property already exists"));
                    }
                    else
                    {
                        tOrg.DeclareNMIProperty(tNewPropName, ePropertyTypes.TString);
                        TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", "Property Added"));
                        MyStatusForm.Reload(pMsg, false);
                    }
                }
                tOrg.RemoveProperty("ScratchName");
            });
            mIsUXInitialized = true;
            return(true);
        }
Example #22
0
        public virtual bool CreateUX()
        {
            if (mIsUXInitCalled)
            {
                return(false);
            }
            mIsUXInitCalled = true;

            var tFlds = TheNMIEngine.AddStandardForm(MyBaseThing, null, 12, null, "Value");

            MyStatusForm            = tFlds["Form"] as TheFormInfo;
            SummaryForm             = tFlds["DashIcon"] as TheDashPanelInfo;
            SummaryForm.PropertyBag = new ThePropertyBag()
            {
                string.Format("Format={0}<br>{{0}} Properties", MyBaseThing.FriendlyName), "TileWidth=2"
            };
            SummaryForm.RegisterPropertyChanged(sinkStatChanged);

            var ts = TheNMIEngine.AddStatusBlock(MyBaseThing, MyStatusForm, 10);

            ts["Group"].SetParent(1);

            var tc = TheNMIEngine.AddStartingBlock(MyBaseThing, MyStatusForm, 200, async(pMsg, DoStart) =>
            {
                if (DoStart)
                {
                    await StartPlaybackAsync(false);
                }
                else
                {
                    await StopPlaybackAsync(null);
                }
            });

            tc["Group"].SetParent(49);
            //ts["Group"].Header = "Settings...";

            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.CollapsibleGroup, 49, 2, 0x0, "###CDMyVThings.TheVThings#Settings#Settings...###", null, new nmiCtrlCollapsibleGroup()
            {
                ParentFld = 1, DoClose = true, IsSmall = true
            });


            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 50, 2, 0x0, "###CDMyVThings.TheVThings#PlaybackSpeedFactor#Speed Factor###", nameof(PlaybackSpeedFactor), new nmiCtrlNumber()
            {
                DefaultValue = "1", TileWidth = 3, ParentFld = 49
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 60, 2, 0x0, "###CDMyVThings.TheVThings#PlaybackMaxItemDelay#Maximum Delay###", nameof(MaxItemDelay), new nmiCtrlNumber()
            {
                TileWidth = 3, ParentFld = 49
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 70, 2, 0x0, "###CDMyVThings.TheVThings#PlaybackItemDelay#Item Delay###", nameof(PlaybackItemDelay), new nmiCtrlNumber()
            {
                TileWidth = 3, ParentFld = 49
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 75, 2, 0x0, "###CDMyVThings.TheVThings#AutoStartDelay#Auto Start Delay###", nameof(AutoStartDelay), new nmiCtrlSingleCheck()
            {
                TileWidth = 3, ParentFld = 49
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleCheck, 80, 2, 0x0, "###CDMyVThings.TheVThings#PlaybackRestart#Restart###", nameof(RestartPlayback), new nmiCtrlSingleCheck()
            {
                TileWidth = 3, ParentFld = 49
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleCheck, 85, 2, 0x0, "###CDMyVThings.TheVThings#PlaybackAdjustTimestamps#Adjust times###", nameof(AdjustTimestamps), new nmiCtrlSingleCheck()
            {
                TileWidth = 3, ParentFld = 49
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 87, 2, 0x0, "###CDMyVThings.TheVThings#ReplayCount#Replay Count###", nameof(ReplayCount), new nmiCtrlNumber()
            {
                TileWidth = 3, ParentFld = 49, DefaultValue = "1"
            });

            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleEnded, 90, 2, 0x0, "###CDMyVThings.TheVThings#PlaybackInputFileName#Input File###", nameof(InputFileName), new nmiCtrlSingleEnded()
            {
                ParentFld = 49
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 86, 2, 0x0, "###CDMyVThings.TheVThings#PlaybackNumberThings#Number Things###", nameof(ParallelPlaybackCount), new nmiCtrlNumber()
            {
                TileWidth = 3, ParentFld = 49
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleEnded, 110, 2, 0x0, "###CDMyVThings.TheVThings#PlaybackEngineName#Engine Name###", nameof(PlaybackEngineName), new nmiCtrlSingleEnded()
            {
                ParentFld = 49
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.SingleEnded, 115, 2, 0x0, "###CDMyVThings.TheVThings#PlaybackDeviceType#Device Type###", nameof(PlaybackDeviceType), new nmiCtrlSingleEnded()
            {
                ParentFld = 49
            });


            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.CollapsibleGroup, 120, 2, 0x0, "###CDMyVThings.TheVThings#Settings#Upload file...###", null, new nmiCtrlCollapsibleGroup()
            {
                ParentFld = 49, DoClose = true, IsSmall = true
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.DropUploader, 125, 2, 0x0, "###CDMyVThings.TheVThings#PlaybackInputFileDropper#Drop Input File here###", null,
                                         new nmiCtrlDropUploader {
                TileHeight = 6, NoTE = true, TileWidth = 6, EngineName = MyBaseEngine.GetEngineName(), MaxFileSize = 100000000, ParentFld = 120
            });


            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.CollapsibleGroup, 20, 2, 0x0, "###CDMyVThings.TheVThings#KPIs#KPIs...###", null, new nmiCtrlCollapsibleGroup()
            {
                ParentFld = 1, TileWidth = 6, IsSmall = true
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 135, 0, 0x0, "###CDMyVThings.TheVThings#PropertiesperSecond546134#Properties per Second###", nameof(Gen_Stats_PropertiesPerSecond), new nmiCtrlNumber()
            {
                ParentFld = 20
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.Number, 140, 0, 0x0, "###CDMyVThings.TheVThings#Propertycount904939#Property count###", nameof(Gen_Stats_PropertyCounter), new nmiCtrlNumber()
            {
                ParentFld = 20
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.DateTime, 150, 0, 0x0, "###CDMyVThings.TheVThings#PlaybackUpdateTime#Update time###", nameof(Gen_StatsLastUpdateTime), new nmiCtrlDateTime()
            {
                ParentFld = 20
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TimeSpan, 160, 0, 0x0, "###CDMyVThings.TheVThings#PlaybackLoadDuration#Load duration###", nameof(LoadDuration), new nmiCtrlDateTime()
            {
                ParentFld = 20
            });
            TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TimeSpan, 170, 0, 0x0, "###CDMyVThings.TheVThings#PlaybackDuration#Playback duration###", nameof(PlaybackDuration), new nmiCtrlDateTime()
            {
                ParentFld = 20
            });


            TheFieldInfo mResetCounterButton = TheNMIEngine.AddSmartControl(MyBaseThing, MyStatusForm, eFieldType.TileButton, 180, 2, 0, "###CDMyVThings.TheVThings#ResetCounter741318#Reset Counter###", false, "", null, new nmiCtrlTileButton()
            {
                ParentFld = 130, ClassName = "cdeGoodActionButton"
            });

            mResetCounterButton.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "", (pThing, pPara) =>
            {
                if (!(pPara is TheProcessMessage pMsg) || pMsg.Message == null)
                {
                    return;
                }
                this.Gen_Stats_PropertyCounter = 0;
                Interlocked.Exchange(ref _propertyCounter, 0);
                sinkStatChanged(null, null);
            });
Example #23
0
        public override bool CreateUX()
        {
            if (!mIsUXInitStarted)
            {
                mIsUXInitStarted = true;

                // Creates a "portal" for each rule. This is how we create
                // a tile for each rule on the rules engine's main page.
                mThisFormFields = TheNMIEngine.AddStandardForm(MyBaseThing, MyBaseThing.FriendlyName, 18);

                // Update our status.
                TheFormInfo tFormGuid = mThisFormFields["Form"] as TheFormInfo;
                tFormGuid.RegisterEvent2(eUXEvents.OnShow, (pMSG, para) => {
                    UpdateStatus();
                });

                // Create "Rule Status" settings group
                // Field Order = 10
                // Parent = 1 (main form)
                // Get standard Status Block.
                var tstFlds = TheNMIEngine.AddStatusBlock(MyBaseThing, tFormGuid, idGroupStatus);
                tstFlds["Group"].SetParent(idForm);
                tstFlds["Group"].Header = "Rule Status";
                // tstFlds["Group"].PropertyBag = new ThePropertyBag { "DoClose=true" };
                tstFlds["FriendlyName"].Header = "Rule Name";

                // When the Friendly Name changes, propogate to the other UI elements that use it.
                tstFlds["FriendlyName"].RegisterUXEvent(MyBaseThing, eUXEvents.OniValueChanged, null, (psender, pPara) =>
                {
                    (mThisFormFields["Header"] as TheFieldInfo).SetUXProperty(Guid.Empty, $"Title={MyBaseThing.FriendlyName}");
                    (mThisFormFields["DashIcon"] as TheDashPanelInfo).SetUXProperty(Guid.Empty, $"Caption={MyBaseThing.FriendlyName}");
                });

                // Add fields to Status Block that are specific to this plugin.
                TheNMIEngine.AddSmartControl(MyBaseThing, tFormGuid, eFieldType.SingleCheck, 60, 2, 0, "Activate Rule", "IsRuleActive", new nmiCtrlSingleCheck {
                    ParentFld = idGroupStatus, TileWidth = 3
                });
                TheNMIEngine.AddSmartControl(MyBaseThing, tFormGuid, eFieldType.SingleCheck, 70, 2, 0, "Log Action", "IsRuleLogged", new nmiCtrlSingleCheck {
                    ParentFld = idGroupStatus, TileWidth = 3
                });
                TheNMIEngine.AddSmartControl(MyBaseThing, tFormGuid, eFieldType.SingleCheck, 75, 2, 0, "Log Action to Eventlog", "IsEVTLogged", new nmiCtrlSingleCheck {
                    ParentFld = idGroupStatus, TileWidth = 3
                });
                TheFieldInfo tTriggerBut = TheNMIEngine.AddSmartControl(MyBaseThing, tFormGuid, eFieldType.TileButton, 65, 2, 0xC0, "Trigger Now", null, new nmiCtrlTileButton {
                    ParentFld = idGroupStatus, ClassName = "cdeGoodActionButton", NoTE = true, TileWidth = 3
                });
                tTriggerBut.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "TriggerNow", (psender, 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]));
                        if (tThing == null)
                        {
                            return;
                        }
                        TheRule tRule = tThing.GetObject() as TheRule;
                        if (tRule != null)
                        {
                            //FireAction(tRule, true);
                            tRule.FireAction(true);
                            MyBaseEngine.ProcessMessage(new TheProcessMessage(new TSM(MyBaseEngine.GetEngineName(), "FIRE_RULE", MyBaseThing.cdeMID.ToString())));
                            TheCommCore.PublishToOriginator(pMSG.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", string.Format("Rule {0} triggered", tRule.GetBaseThing().FriendlyName)));
                        }
                    }
                });

                // Create "Trigger Object" settings group (Field Order = idGroupTriggerObject (100), Parent = 1)
                TheNMIEngine.AddSmartControl(MyBaseThing, tFormGuid, eFieldType.CollapsibleGroup, idGroupTriggerObject, 2, 0, "Trigger Object", null, new nmiCtrlCollapsibleGroup {
                    ParentFld = idForm, TileWidth = 6, IsSmall = true
                });

                // Create "Action Settings" settings group (Field Order = idGroupActionSettings (500), Parent = 1)
                TheNMIEngine.AddSmartControl(MyBaseThing, tFormGuid, eFieldType.CollapsibleGroup, idGroupActionSettings, 2, 0, "Action Settings", null, new nmiCtrlCollapsibleGroup {
                    ParentFld = idForm, TileWidth = 6, IsSmall = true
                });

                // Create "Thing Property Action" settings group (Field Order = idGroupThingPropAction (550), Parent = 500)
                TheNMIEngine.AddSmartControl(MyBaseThing, tFormGuid, eFieldType.CollapsibleGroup, idGroupThingPropAction, 2, 0, "Thing/Property Action", null, new nmiCtrlCollapsibleGroup {
                    ParentFld = idGroupActionSettings, TileWidth = 6, IsSmall = true
                });

                // Create "TSM Action" settings group (Field Order = idGroupTSMAction (600), Parent = 500)
                TheNMIEngine.AddSmartControl(MyBaseThing, tFormGuid, eFieldType.CollapsibleGroup, idGroupTSMAction, 2, 0, "TSM Action", null, new nmiCtrlCollapsibleGroup {
                    ParentFld = idGroupActionSettings, TileWidth = 6, IsSmall = true, DoClose = true
                });

                // Create all other (non-group header) fields.
                TheNMIEngine.AddFields(tFormGuid, new List <TheFieldInfo>
                {
                    /* Trigger Object Group */
                    { new TheFieldInfo()
                      {
                          FldOrder = 140, DataItem = "MyPropertyBag.TriggerObject.Value", Flags = 2, Type = eFieldType.ThingPicker, Header = "Trigger Object", PropertyBag = new nmiCtrlThingPicker()
                          {
                              ParentFld = idGroupTriggerObject, HelpText = "If this objects...", IncludeEngines = true
                          }
                      } },
                    { new TheFieldInfo()
                      {
                          FldOrder = 150, DataItem = "MyPropertyBag.TriggerProperty.Value", Flags = 2, Type = eFieldType.PropertyPicker, Header = "Trigger Property", DefaultValue = "Value", PropertyBag = new nmiCtrlPropertyPicker()
                          {
                              ParentFld = idGroupTriggerObject, HelpText = "...property is...", ThingFld = 140
                          }
                      } },
                    { new TheFieldInfo()
                      {
                          FldOrder = 160, DataItem = "MyPropertyBag.TriggerCondition.Value", Flags = 2, Type = eFieldType.ComboBox, Header = "Trigger Condition", DefaultValue = "2", PropertyBag = new nmiCtrlComboBox()
                          {
                              ParentFld = idGroupTriggerObject, HelpText = "... then this value, this rule will fire...", DefaultValue = "2", Options = "Fire:0;State:1;Equals:2;Larger:3;Smaller:4;Not:5;Contains:6;Set:7;StartsWith:8;EndsWith:9;Flank:10"
                          }
                      } },
                    { new TheFieldInfo()
                      {
                          FldOrder = 170, DataItem = "MyPropertyBag.TriggerValue.Value", Flags = 2, Type = eFieldType.SingleEnded, Header = "Trigger Value", PropertyBag = new ThePropertyBag()
                          {
                              "ParentFld=100", "HelpText=...this objects..."
                          }
                      } },

                    /* Action Settings Group */
                    { new TheFieldInfo()
                      {
                          FldOrder = 505, DataItem = "MyPropertyBag.ActionObjectType.Value", Flags = 2, Type = eFieldType.ComboBox, Header = "Action Object Type", PropertyBag = new nmiCtrlComboBox()
                          {
                              ParentFld = idGroupActionSettings, Options = "Set Property on a Thing:CDE_THING;Publish Central:CDE_PUBLISHCENTRAL;Publish to Service:CDE_PUBLISH2SERVICE", DefaultValue = "CDE_THING"
                          }
                      } },
                    { new TheFieldInfo()
                      {
                          FldOrder = 506, DataItem = "MyPropertyBag.ActionDelay.Value", Flags = 2, Type = eFieldType.Number, Header = "Delay", DefaultValue = "0", PropertyBag = new ThePropertyBag()
                          {
                              "ParentFld=500", "HelpText=...after a delay of these seconds..."
                          }
                      } },

                    /* Thing / Property Action Sub-Group */
                    { new TheFieldInfo()
                      {
                          FldOrder = 560, DataItem = "MyPropertyBag.ActionObject.Value", Flags = 2, Type = eFieldType.ThingPicker, Header = "Action Object", PropertyBag = new nmiCtrlThingPicker()
                          {
                              ParentFld = 550, HelpText = "...this objects...", IncludeEngines = true
                          }
                      } },
                    { new TheFieldInfo()
                      {
                          FldOrder = 562, DataItem = "MyPropertyBag.ActionProperty.Value", Flags = 2, Type = eFieldType.PropertyPicker, Header = "Action Property", DefaultValue = "Value", PropertyBag = new nmiCtrlPropertyPicker()
                          {
                              ParentFld = idGroupThingPropAction, HelpText = "...property will change to...", ThingFld = 560
                          }
                      } },
                    { new TheFieldInfo()
                      {
                          FldOrder = 563, DataItem = "MyPropertyBag.ActionValue.Value", Flags = 2, Type = eFieldType.SingleEnded, Header = "Action Value", PropertyBag = new nmiCtrlSingleEnded {
                              ParentFld = idGroupThingPropAction, HelpText = "...this value", Style = "text-overflow:ellipsis;overflow:hidden; max-width:400px"
                          }
                      } },

                    /* TSM Action Sub-Group */
                    { new TheFieldInfo()
                      {
                          FldOrder = 630, DataItem = "MyPropertyBag.TSMEngine.Value", Flags = 2, Type = eFieldType.ThingPicker, Header = "TSM Engine", PropertyBag = new nmiCtrlThingPicker()
                          {
                              ParentFld = 600, ValueProperty = "EngineName", IncludeEngines = true, Filter = "DeviceType=IBaseEngine"
                          }
                      } },
                    { new TheFieldInfo()
                      {
                          FldOrder = 631, DataItem = "MyPropertyBag.TSMText.Value", Flags = 2, Type = eFieldType.SingleEnded, Header = "TSM Text", PropertyBag = new ThePropertyBag()
                          {
                              "ParentFld=600", "HelpText=Command of the TSM"
                          }
                      } },
                    { new TheFieldInfo()
                      {
                          FldOrder = 632, DataItem = "MyPropertyBag.TSMPayload.Value", Flags = 2, Type = eFieldType.TextArea, Header = "TSM Payload", PropertyBag = new nmiCtrlTextArea()
                          {
                              ParentFld = idGroupTSMAction, TileHeight = 2, HelpText = "Body of the TSM"
                          }
                      } },
                });

                mIsUXInitCompleted = true;
            }
            return(true);
        }
        public bool CreateUX()
        {
            if (mIsUXInitCalled)
            {
                return(false);
            }
            mIsUXInitCalled = true;

            //NUI Definition for All clients
            mMyDashboard = TheNMIEngine.AddDashboard(MyBaseThing, new TheDashboardInfo(MyBaseEngine, "MQTT Sender")
            {
                PropertyBag = new ThePropertyBag()
                {
                    "Category=Connectors"
                }
            });

            TheFormInfo tAllCloudConnections = new TheFormInfo(MyBaseEngine)
            {
                cdeMID = TheThing.GetSafeThingGuid(MyBaseThing, "MQTTC"), defDataSource = string.Format("TheThing;:;0;:;True;:;EngineName={0}", MyBaseEngine.GetEngineName()), FormTitle = "Cloud Connections", AddButtonText = "Add a Connection"
            };

            TheNMIEngine.AddFormToThingUX(MyBaseThing, tAllCloudConnections, "CMyTable", "MQTT Connections", 1, 0x0D, 0xC0, TheNMIEngine.GetNodeForCategory(), null, new ThePropertyBag()
            {
            });


            TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo()
            {
                FldOrder = 5, cdeA = 0xC0, Flags = 6, Type = eFieldType.SingleCheck, FldWidth = 1, Header = "Auto-Connect", DataItem = "MyPropertyBag.AutoConnect.Value"
            });
            TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo()
            {
                FldOrder = 6, cdeA = 0xC0, Flags = 2, Type = eFieldType.SingleCheck, FldWidth = 1, Header = "Is Connected", DataItem = "MyPropertyBag.IsConnected.Value", PropertyBag = new nmiCtrlSingleCheck {
                    AreYouSure = "Are you sure you want to connect/disconnect?"
                }
            });
            TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo()
            {
                FldOrder = 7, cdeA = 0xC0, Flags = 0, Type = eFieldType.SingleCheck, FldWidth = 1, Header = "Connecting", DataItem = "MyPropertyBag.Connecting.Value"
            });
            TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo()
            {
                FldOrder = 8, cdeA = 0xC0, Flags = 0, Type = eFieldType.SingleCheck, FldWidth = 1, Header = "Disconnecting", DataItem = "MyPropertyBag.Disconnecting.Value"
            });
            TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo()
            {
                FldOrder = 12, cdeA = 0xFF, Flags = 2, Type = eFieldType.ComboBox, PropertyBag = new nmiCtrlComboBox()
                {
                    Options = MqttDeviceTypes.GetValues(), FldWidth = 3
                }, DefaultValue = MqttDeviceTypes.MqttSender, Header = "DeviceType", DataItem = "MyPropertyBag.DeviceType.Value"
            });
            TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo()
            {
                FldOrder = 13, Flags = 2, cdeA = 0xFF, Type = eFieldType.SingleEnded, FldWidth = 3, Header = "Friendly Name", DataItem = "MyPropertyBag.FriendlyName.Value"
            });
            TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo()
            {
                FldOrder = 14, Flags = 0, cdeA = 0xC0, Type = eFieldType.SingleEnded, FldWidth = 2, Header = "Address", DataItem = "MyPropertyBag.Address.Value"
            });

            TheNMIEngine.AddField(tAllCloudConnections, new TheFieldInfo()
            {
                FldOrder = 50, cdeA = 0xFF, Type = eFieldType.DateTime, FldWidth = 2, Header = "Last Update", DataItem = "MyPropertyBag.LastUpdate.Value"
            });
            TheNMIEngine.AddTableButtons(tAllCloudConnections, true, 100);

            TheThingRegistry.UpdateEngineUX(MyBaseEngine.GetEngineName());

            TheNMIEngine.AddAboutButton(MyBaseThing, true, "REFRESH_DASH", 0xc0);
            TheNMIEngine.RegisterEngine(MyBaseEngine);

            mIsUXInitialized = true;
            return(true);
        }
Example #25
0
        void SendEmail(string pText)
        {
            try
            {
                MailMessage mail       = new MailMessage();
                SmtpClient  SmtpServer = new SmtpClient(MyBaseThing.Address);

                mail.From = new MailAddress(FromAddress);
                string receipt     = Recipient;
                string credentials = Credentials;
                if (TheCommonUtils.IsNullOrWhiteSpace(receipt))
                {
                    receipt = "*****@*****.**";
                }
                mail.To.Add(receipt);
                if (string.IsNullOrEmpty(SubjectText))
                {
                    mail.Subject = TheBaseAssets.MyServiceHostInfo.ApplicationName + " Message";
                }
                else
                {
                    mail.Subject = SubjectText;
                }
                if (!TheCommonUtils.IsNullOrWhiteSpace(pText))
                {
                    mail.Body = pText;
                }
                else
                {
                    mail.Body = MessageText;
                }
                if (credentials.Equals("Admin"))
                {
                    string AdminUsername = MyBaseEngine.GetBaseThing().GetProperty("AdminUsername", false).ToString();
                    string AdminServer   = MyBaseEngine.GetBaseThing().GetProperty("AdminServer", false).ToString();
                    string AdminPassword = MyBaseEngine.GetBaseThing().GetProperty("AdminPassword", false).GetValue().ToString();
                    int    AdminPort     = int.Parse(MyBaseEngine.GetBaseThing().GetProperty("AdminPort", false).ToString());
                    SmtpServer.Credentials = new System.Net.NetworkCredential(AdminUsername, AdminPassword);
                    SmtpServer.Host        = AdminServer;
                    SmtpServer.Port        = AdminPort;
                    string AdminSsl = MyBaseEngine.GetBaseThing().GetProperty("AdminSsl", false).ToString();
                    if (AdminSsl.Equals("True"))
                    {
                        SmtpServer.EnableSsl = true;
                    }
                }
                else
                {
                    SmtpServer.Port        = Port;
                    SmtpServer.Credentials = new System.Net.NetworkCredential(UserName, Password);
                    if (UseSsl)
                    {
                        SmtpServer.EnableSsl = true;
                    }
                }

                SmtpServer.Send(mail);
                ResultText = "Mail Sent to " + Recipient;

                TSM tTSM = new TSM(MyBaseEngine.GetEngineName(), "SET_LAST_MSG", string.Format("eMail: Subject:{2} Body:{3} From {0} at {1}", TheBaseAssets.MyServiceHostInfo.MyStationName, DateTimeOffset.Now, SubjectText, mail.Body));
                MyBaseEngine.ProcessMessage(new TheProcessMessage(tTSM));
                TheCommCore.PublishCentral(tTSM);
            }
            catch (Exception ex)
            {
                ResultText = ex.ToString();
            }
        }
Example #26
0
        public override bool CreateUX()
        {
            if (!mIsUXInitCalled)
            {
                mIsUXInitCalled = true;

                var tMyForm2 = TheNMIEngine.AddStandardForm(MyBaseThing, MyBaseThing.FriendlyName, 6, MyBaseThing.cdeMID.ToString(), null, 0xC0, "Images");
                (tMyForm2["DashIcon"] as TheDashPanelInfo)?.SetUXProperty(Guid.Empty, $"BackgroundImage={TheThing.GetSafePropertyString(MyBaseThing,"CurrentImage").Replace('\\','/')}");
                var tMyForm = tMyForm2["Form"] as TheFormInfo;
                tMyForm.RegisterEvent2(eUXEvents.OnShow, (sender, para) =>
                {
                    (tMyForm2["DashIcon"] as TheDashPanelInfo)?.SetUXProperty(Guid.Empty, $"BackgroundImage={TheThing.GetSafePropertyString(MyBaseThing, "CurrentImage").Replace('\\', '/')}");
                });
                TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.TileGroup, 10, 0, 0, null, null, new nmiCtrlPicture {
                    ParentFld = 1, TileWidth = 6
                });
                TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.DropUploader, 20, 2, 0, "###Drop an image-file here###", "CurrentImage",
                                             new nmiCtrlDropUploader {
                    TileHeight = 6, ParentFld = 10, NoTE = true, TileWidth = 6, EngineName = MyBaseEngine.GetEngineName(), MaxFileSize = 500000
                });
                TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleEnded, 30, 2, 0, "###Image Name###", "FriendlyName", new nmiCtrlSingleEnded {
                    ParentFld = 10
                });
                mIsUXInitialized = true;
            }
            return(true);
        }
Example #27
0
        /// <summary>
        /// Handles Messages sent from a host sub-engine to its clients
        /// </summary>
        /// <param name="Command"></param>
        /// <param name="pMessage"></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 nameof(TheThing.MsgBrowseSensors):
                var browseRequest  = TheCommRequestResponse.ParseRequestMessageJSON <TheThing.MsgBrowseSensors>(pMsg.Message);
                var browseResponse = new TheThing.MsgBrowseSensorsResponse {
                    Error = "Internal error", Sensors = new List <TheThing.TheSensorSourceInfo>()
                };
                foreach (FieldMapping fld in MyModFieldStore.TheValues)
                {
                    browseResponse.Sensors.Add(new TheThing.TheSensorSourceInfo
                    {
                        SourceType    = fld.SourceType,
                        cdeType       = ePropertyTypes.TNumber,
                        SensorId      = TheCommonUtils.CStr(fld.cdeMID),
                        ExtensionData = new Dictionary <string, object>
                        {
                            { nameof(FieldMapping.SourceOffset), fld.SourceOffset },
                            { nameof(FieldMapping.SourceSize), fld.SourceSize },
                            { nameof(FieldMapping.AllowWrite), fld.AllowWrite }
                        },
                        DisplayNamePath = new string[] { MyBaseEngine.GetEngineName(), MyBaseThing.FriendlyName, fld.PropertyName }
                    });
                }
                browseResponse.Error = null;
                TheCommRequestResponse.PublishResponseMessageJson(pMsg.Message, browseResponse);
                break;

            case nameof(TheThing.MsgSubscribeSensors):
                var subscribeRequest  = TheCommRequestResponse.ParseRequestMessageJSON <TheThing.MsgSubscribeSensors>(pMsg.Message);
                var subscribeResponse = new TheThing.MsgSubscribeSensorsResponse {
                    Error = "Internal error", SubscriptionStatus = new List <TheThing.TheSensorSubscriptionStatus>()
                };
                if (subscribeRequest.ReplaceAll)
                {
                    MyModFieldStore.RemoveAllItems();
                }
                var subscriptionStatus = new List <TheThing.TheSensorSubscriptionStatus>();
                foreach (TheThing.TheSensorSubscription sub in subscribeRequest.SubscriptionRequests)
                {
                    FieldMapping fld = new FieldMapping()
                    {
                        PropertyName = sub.TargetProperty,
                        cdeMID       = TheCommonUtils.CGuid(sub.SensorId)
                    };
                    if (fld.cdeMID == Guid.Empty)
                    {
                        fld.cdeMID = Guid.NewGuid();
                    }
                    object sourceType;
                    if (sub.ExtensionData != null)
                    {
                        if (sub.ExtensionData.TryGetValue(nameof(TheThing.TheSensorSourceInfo.SourceType), out sourceType))
                        {
                            fld.SourceType = TheCommonUtils.CStr(sourceType);
                        }
                        object offset;
                        if (sub.ExtensionData.TryGetValue("SourceOffset", out offset))
                        {
                            fld.SourceOffset = TheCommonUtils.CInt(offset);
                        }
                        object size;
                        if (sub.ExtensionData.TryGetValue("SourceSize", out size))
                        {
                            fld.SourceSize = TheCommonUtils.CInt(size);
                        }
                        object allowWrite;
                        if (sub.ExtensionData.TryGetValue("AllowWrite", out allowWrite))
                        {
                            fld.AllowWrite = TheCommonUtils.CBool(allowWrite);
                        }
                        MyModFieldStore.AddAnItem(fld);
                        subscriptionStatus.Add(CreateSubscriptionStatusFromFieldMapping(fld));
                    }
                    else
                    {
                        subscriptionStatus.Add(new TheThing.TheSensorSubscriptionStatus
                        {
                            Error        = "Missing source info",
                            Subscription = sub,
                        });
                    }
                }
                subscribeResponse.SubscriptionStatus = subscriptionStatus;
                subscribeResponse.Error = null;
                TheCommRequestResponse.PublishResponseMessageJson(pMsg.Message, subscribeResponse);
                break;

            case nameof(TheThing.MsgGetSensorSubscriptions):
                var getResponse = new TheThing.MsgGetSensorSubscriptionsResponse {
                    Error = "Internal error"
                };
                getResponse.Subscriptions = MyModFieldStore.TheValues.Select(fld => CreateSubscriptionStatusFromFieldMapping(fld).Subscription).ToList();
                getResponse.Error         = null;
                TheCommRequestResponse.PublishResponseMessageJson(pMsg.Message, getResponse);
                break;

            case nameof(TheThing.MsgUnsubscribeSensors):
                var unsubscribeRequest  = TheCommRequestResponse.ParseRequestMessageJSON <TheThing.MsgUnsubscribeSensors>(pMsg.Message);
                var unsubscribeResponse = new TheThing.MsgUnsubscribeSensorsResponse {
                    Error = "Internal error", Failed = new List <TheThing.TheSensorSubscriptionStatus>()
                };
                if (unsubscribeRequest.UnsubscribeAll)
                {
                    MyModFieldStore.RemoveAllItems();
                    if (MyModFieldStore.GetCount() > 0)
                    {
                        unsubscribeResponse.Failed = MyModFieldStore.TheValues.Select(fld => CreateSubscriptionStatusFromFieldMapping(fld)).ToList();
                    }
                }
                else
                {
                    List <FieldMapping> toRemove = MyModFieldStore.TheValues.FindAll(fld => unsubscribeRequest.SubscriptionIds.Contains(fld.cdeMID));
                    MyModFieldStore.RemoveItems(toRemove, null);
                    foreach (FieldMapping fld in MyModFieldStore.TheValues)
                    {
                        if (toRemove.Any(t => t.cdeMID == fld.cdeMID))
                        {
                            unsubscribeResponse.Failed.Add(CreateSubscriptionStatusFromFieldMapping(fld));
                        }
                    }
                }
                unsubscribeResponse.Error = null;
                TheCommRequestResponse.PublishResponseMessageJson(pMsg.Message, unsubscribeResponse);
                break;

            case nameof(TheThing.MsgExportConfig):
                var exportRequest  = TheCommRequestResponse.ParseRequestMessageJSON <TheThing.MsgExportConfig>(pMsg.Message);
                var exportResponse = new TheThing.MsgExportConfigResponse {
                    Error = "Internal error"
                };

                // No custom config beyond config properties and subscriptions
                exportResponse.Error = null;

                TheCommRequestResponse.PublishResponseMessageJson(pMsg.Message, exportResponse);
                break;

            case nameof(TheThing.MsgApplyConfig):
                break;

            default:
                break;
            }

            TheThing.TheSensorSubscriptionStatus CreateSubscriptionStatusFromFieldMapping(FieldMapping fld)
            {
                return(new TheThing.TheSensorSubscriptionStatus
                {
                    Subscription = new TheThing.TheSensorSubscription
                    {
                        TargetProperty = fld.PropertyName,
                        SensorId = TheCommonUtils.CStr(fld.cdeMID),
                        SubscriptionId = fld.cdeMID,
                        ExtensionData = new Dictionary <string, object>
                        {
                            { nameof(FieldMapping.SourceType), fld.SourceType },
                            { nameof(FieldMapping.SourceOffset), fld.SourceOffset },
                            { nameof(FieldMapping.SourceSize), fld.SourceSize },
                            { nameof(FieldMapping.AllowWrite), fld.AllowWrite }
                        },
                        TargetThing = new TheThingReference(MyBaseThing),
                        SampleRate = (int?)this.Interval
                    },
                    Error = null,
                });
            }
        }
Example #28
0
        void SendSMS(string pText)
        {
            try
            {
                MailMessage mail       = new MailMessage();
                SmtpClient  SmtpServer = new SmtpClient(MyBaseThing.Address);

                mail.From = new MailAddress(FromAddress);
                string receipt     = Recipient;
                string credentials = Credentials;
                if (TheCommonUtils.IsNullOrWhiteSpace(receipt))
                {
                    receipt = "*****@*****.**";
                }
                string carrier = Carrier;

                // Code to handle carrier
                //TODO: Set Server name and SSL/Server and Port per Carrier
                #region Handle Carrier
                switch (carrier.ToLower())
                {
                case "t-mobile":
                    receipt += "@tmomail.net";
                    break;

                case "at&t":
                    receipt += "@txt.att.net";
                    break;

                case "sprint":
                    receipt += "@messaging.sprintpcs.com";
                    break;

                case "verizon":
                    receipt += "@vtext.com";
                    break;

                case "virgin mobile":
                    receipt += "@vmobl.com";
                    break;

                case "metro pcs":
                    receipt += "@MyMetroPcs";
                    break;

                case "alltel":
                    receipt += "@message.alltel.com";
                    break;

                case "powertel":
                    receipt += "@ptel.net";
                    break;

                case "suncom":
                    receipt += "@tms.suncom.com";
                    break;

                case "nextel":
                    receipt += "@messaging.nextel.com";
                    break;

                case "us cellular":
                    receipt += "@email.uscc.net";
                    break;

                case "boost mobile":
                    receipt += "@myboostmobile.com";
                    break;

                case "cingular":
                    receipt += "@cingularme.com";
                    break;
                }
                #endregion

                mail.To.Add(receipt);
                if (string.IsNullOrEmpty(SubjectText))
                {
                    mail.Subject = TheBaseAssets.MyServiceHostInfo.ApplicationName + " Message";
                }
                else
                {
                    mail.Subject = SubjectText;
                }
                if (!TheCommonUtils.IsNullOrWhiteSpace(pText))
                {
                    mail.Body = pText;
                }
                else
                {
                    mail.Body = MessageText;
                }

                if (credentials.Equals("Admin"))
                {
                    string AdminUsername = MyBaseEngine.GetBaseThing().GetProperty("AdminUsername", false).ToString();
                    string AdminServer   = MyBaseEngine.GetBaseThing().GetProperty("AdminServer", false).ToString();
                    string AdminPassword = MyBaseEngine.GetBaseThing().GetProperty("AdminPassword", false).GetValue().ToString();
                    int    AdminPort     = int.Parse(MyBaseEngine.GetBaseThing().GetProperty("AdminPort", false).ToString());
                    SmtpServer.Credentials = new System.Net.NetworkCredential(AdminUsername, AdminPassword);
                    SmtpServer.Host        = AdminServer;
                    SmtpServer.Port        = AdminPort;
                    string AdminSsl = MyBaseEngine.GetBaseThing().GetProperty("AdminSsl", false).ToString();
                    if (AdminSsl.Equals("True"))
                    {
                        SmtpServer.EnableSsl = true;
                    }
                }
                else
                {
                    SmtpServer.Credentials = new System.Net.NetworkCredential(UserName, Password);
                    SmtpServer.Port        = Port;
                    if (UseSsl)
                    {
                        SmtpServer.EnableSsl = true;
                    }
                }
                SmtpServer.Send(mail);
                ResultText = "SMS Sent to " + Recipient;

                TSM tTSM = new TSM(MyBaseEngine.GetEngineName(), "SET_LAST_MSG", string.Format("SMS: Subject:{2} Body:{3} From {0} at {1}", TheBaseAssets.MyServiceHostInfo.MyStationName, DateTimeOffset.Now, SubjectText, mail.Body));
                MyBaseEngine.ProcessMessage(new TheProcessMessage(tTSM));
                TheCommCore.PublishCentral(tTSM);
            }
            catch (Exception ex)
            {
                ResultText = ex.ToString();
            }
        }