protected virtual void RemoveButtom_ClickAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal) { for (int i = 0; i < moduleGrid.Rows.SelectedRows.Count; i++) { int rowId = moduleGrid.Rows.SelectedRows.Item(i, BoOrderType.ot_RowOrder); string moduleName = (string)moduleDT.GetValue("Name", rowId); string type = (string)moduleDT.GetValue("Type", rowId); if (type == "AddIn") { FrameworkAddinManager.ShutdownAddin(moduleName); AsmLoader.RemoveAddIn(moduleName); } } UpdateInstallGrid(); UpdateLicenseGrid(); moduleGrid_ClickAfter(sboObject, pVal); }
/// <summary> /// The loaded Assembly will be unloaded together with the AppDomain, when a new Assembly is loaded. /// Requires all used types to be Serializable. /// </summary> public void Reload() { // Requires all types to be Serializable, System.Net.Sockets.Socket is not! if (_appDomain != null) { AppDomain.Unload(_appDomain); } byte[] bytes = File.ReadAllBytes(_dllPath); _appDomain = AppDomain.CreateDomain(ASSEMBLY_NAME); AsmLoader asm = new AsmLoader() { Data = bytes }; _appDomain.DoCallBack(asm.LoadAsm); AsyncSocketFactory = (IAsyncSocketFactory)asm.Assembly.CreateInstance(FULLY_QUALIFIED_TYPE_NAME); }
protected virtual void InstallUpdateModule_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent) { BubbleEvent = true; if (string.IsNullOrEmpty(modulePath.Value)) { Logger.Error(Messages.AdminEmptyFile); } else { string confirmation; Logger.Info(Messages.AdminCreatingAppDomain); try { SAPAppender.SilentMode = true; // Prevent messy log. if (AsmLoader.AddInIsValid(modulePath.Value, out confirmation)) { if (string.IsNullOrEmpty(confirmation)) { InstallAddin(); } else { GetUserConfirmation(confirmation); } } else { SAPAppender.SilentMode = false; Logger.Error(Messages.AdminInvalidAddin); } } finally { SAPAppender.SilentMode = false; } } }
internal void InstallAddin() { string addinName = AsmLoader.SaveAddIn(modulePath.Value); if (addinName == "Framework") { if (app.MessageBox(Messages.AdminConfirmReboot, 1, Messages.AdminOK, Messages.AdminCancel) == 1) { appEventHandler.Reboot(); } } else { if (FrameworkAddinManager.GetAddinStatus(addinName) == AddinStatus.Running) { FrameworkAddinManager.ShutdownAddin(addinName); FrameworkAddinManager.StartAddin(addinName); } UpdateInstallGrid(); UpdateLicenseGrid(); SAPAppender.SilentMode = false; Logger.Info(Messages.AdminSuccessInstall); } }