Exemplo n.º 1
0
        private void LoadAlternateCryptoLib(CdeCryptoLibConfig cryptoLibConfig)
        {
            if (string.IsNullOrWhiteSpace(cryptoLibConfig?.DllName))
            {
                return;
            }

            var error = TheBaseAssets.LoadCrypto(cryptoLibConfig.DllName, null, cryptoLibConfig.DontVerifyTrust, null,
                                                 cryptoLibConfig.VerifyTrustPath, cryptoLibConfig.DontVerifyIntegrity);

            if (!string.IsNullOrWhiteSpace(error))
            {
                throw new InvalidOperationException($"Failed loading configured crypto DLL: '{error}'");
            }
        }
Exemplo n.º 2
0
        bool Initialize()
        {
            if (Configuration != null)
            {
                TheBaseAssets.MySettings = new TheNetCoreSettings(Configuration);
            }
            MyArgList = (Configuration.GetChildren().ToDictionary(x => x.Key, x => x.Value));
            UpdateArgList(MyArgList);
            StartupLog?.Log("Service: Loading C-LabsCryptoLib");
            TheBaseAssets.LoadCrypto("C-LabsCryptoLib.dll", StartupLog, MyArgList.ContainsKey("DontVerifyTrust") && CU.CBool(MyArgList["DontVerifyTrust"]), null, MyArgList.ContainsKey("VerifyTrustPath") && CU.CBool(MyArgList["VerifyTrustPath"]), MyArgList.ContainsKey("DontVerifyIntegrity") && CU.CBool(MyArgList["DontVerifyIntegrity"]));
            if (TheBaseAssets.CryptoLoadMessage != null)
            {
                StartupLog?.Log($"Security initialization failed with {TheBaseAssets.CryptoLoadMessage}. Exiting...");
                return(false);
            }
            StartupLog?.Log("Service: Setting apid");
            if (!TheScopeManager.SetApplicationID(ServiceApplicationID))
            {
                StartupLog?.Log("Application ID Illegal...exiting");
                return(false);
            }
            StartupLog?.Log("Service: Creating service host");

            TheBaseAssets.MyServiceHostInfo = new TheServiceHostInfo(m_hostType)
            {
                CurrentVersion    = CU.GetAssemblyVersion(this),
                DebugLevel        = eDEBUG_LEVELS.OFF,
                UPnPIcon          = "iconTopLogo.png",
                LocalServiceRoute = "LOCALHOST",
            };
            TheBaseAssets.MyServiceHostInfo.TO.HeartBeatRate = 3;
            TheBaseAssets.MyServiceHostInfo.StatusColors     = ";#65bb00;orange";
            TheBaseAssets.MyServiceHostInfo.ApplicationName  = "Factory-Relay";

            UpdateServiceHostInfo(TheBaseAssets.MyServiceHostInfo);

            if (m_hostType == cdeHostType.Application)
            {
                TheBaseAssets.MyServiceHostInfo.AddManifestFiles(new List <string> {
                    TheBaseAssets.MyServiceHostInfo.ISMMainExecutable,
                    "C-DEngine.dll", "C-DMyNMIHtml5.dll"
                });
            }

            StartupLog?.Log("Service: Created service host");
            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates the basic NMI User Interface
        /// </summary>
        /// <returns></returns>
        public override bool CreateUX()
        {
            if (mIsUXInitCalled)
            {
                return(false);
            }

            mIsUXInitCalled = true;
            if (!MyBaseEngine.GetEngineState().IsService)
            {
                mIsUXInitialized = true;
                return(true);
            }

            UserPrefID = new Guid("{E15AE1F2-69F3-42DC-97E8-B0CC2A8526A6}").ToString().ToLower();
            UserManID  = TheThing.GetSafeThingGuid(MyBaseThing, "USEMAN").ToString().ToLower();
            AddDashboard(MyBaseThing, new TheDashboardInfo(eNMIPortalDashboard, "-HIDE")
            {
                FldOrder = 99999, PropertyBag = { "Category=NMI" }
            });                                                                                                                                   //Main Portal of Relay
            TheDashboardInfo tDash = AddDashboard(MyBaseThing, new TheDashboardInfo(eNMIDashboard, "NMI Admin Portal")
            {
                cdeA = 0x0, FldOrder = 9090, PropertyBag = new nmiDashboard()
                {
                    Category = "NMI", ForceLoad = true, Thumbnail = "FA5:f06c", Caption = "###NMI Admin###"
                }
            });

            if (!TheBaseAssets.MyServiceHostInfo.IsIsolated)
            {
                TheFormInfo tInf = new TheFormInfo(new Guid("{6EE8AC31-7395-4A80-B01C-D49BE174CFC0}"), eEngineName.NMIService, "###Service Overview###", "HostEngineStates")
                {
                    IsNotAutoLoading = true, PropertyBag = new nmiCtrlTableView {
                        ShowFilterField = true
                    }
                };
                AddFormToThingUX(tDash, MyBaseThing, tInf, "CMyTable", "###Service Overview###", 1, 0x0F, 128, "###NMI Administration###", null, new ThePropertyBag {
                    "TileThumbnail=FA5:f05a"
                });

                var tDisButName = "DISPLUG";
                var tDisBut     = AddSmartControl(MyBaseThing, tInf, eFieldType.TileButton, 1, 0x42, 0x80, null, "DisableText", new nmiCtrlTileButton()
                {
                    MID = new Guid("{7C67925E-7C2D-4460-9E61-6166494E9328}"), TableHeader = "###Is Enabled###", TileHeight = 1, TileWidth = 1, FldWidth = 1, ClassName = "cdeTableButton"
                });
                tDisBut.RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, tDisButName, (sender, para) =>
                {
                    if (para is TheProcessMessage pMsg && pMsg.Message != null)
                    {
                        var tCmd = pMsg.Message.PLS?.Split(':');
                        if (tCmd != null && tCmd.Length > 2)
                        {
                            if (tCmd[1] != tDisButName)
                            {
                                return;
                            }
                            var estate = TheCDEngines.MyServiceStates.GetEntryByID(tCmd[2]);
                            if (estate != null)
                            {
                                var tBase = TheThingRegistry.GetBaseEngine(estate.ClassName);
                                if (tBase != null)
                                {
                                    if (tBase.HasCapability(eThingCaps.Internal))
                                    {
                                        TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", TheNMIEngine.LocNMI(pMsg, "###Not allowed on internal engines###")));
                                        return;
                                    }
                                    if (tBase.HasCapability(eThingCaps.MustBePresent))
                                    {
                                        TheCommCore.PublishToOriginator(pMsg.Message, new TSM(eEngineName.NMIService, "NMI_TOAST", TheNMIEngine.LocNMI(pMsg, "###Not allowed on engines that must be present###")));
                                        return;
                                    }
                                }
                                estate.IsDisabled = !estate.IsDisabled;
                                estate.IsUnloaded = estate.IsDisabled;
                                SetUXProperty(Guid.Empty, tDisBut.cdeMID, $"Caption={estate.DisableText}", pMsg.Message.PLS.Split(':')[2]);
                                TheBaseAssets.RecordServices();
                            }
                        }
                    }
                });