public static void AddMenuItemContext(string uniqueId, string descricao, int posicao) { SAPbouiCOM.MenuItem oMenuItem = null; SAPbouiCOM.Menus oMenus = null; try { SAPbouiCOM.MenuCreationParams oCreationPackage = null; oCreationPackage = ((SAPbouiCOM.MenuCreationParams)(B1AppDomain.Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams))); oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_STRING; oCreationPackage.UniqueID = uniqueId; oCreationPackage.String = descricao; oCreationPackage.Enabled = true; oCreationPackage.Position = posicao; oMenuItem = B1AppDomain.Application.Menus.Item("1280"); // Data' oMenus = oMenuItem.SubMenus; oMenus.AddEx(oCreationPackage); } catch { } }
private void setMenuItems() { Menus menus = AppContext.SBOApplication.Menus; MenuCreationParams creationParams = AppContext.SBOApplication.CreateObject(BoCreatableObjectType.cot_MenuCreationParams); SAPbouiCOM.MenuItem menuItem = AppContext.SBOApplication.Menus.Item("43520"); menus = menuItem.SubMenus; //Se agrega menu de add-on <<linea de Creditos>> if (AppContext.SBOApplication.Menus.Exists("Facturas")) { AppContext.SBOApplication.Menus.RemoveEx("Facturas"); } creationParams.Type = SAPbouiCOM.BoMenuType.mt_POPUP; creationParams.UniqueID = "Facturas"; creationParams.String = "Facturas"; creationParams.Enabled = true; creationParams.Position = 1; menus.AddEx(creationParams); //Se agrega submenu de formulario <<Aumento de Creditos>> menuItem = AppContext.SBOApplication.Menus.Item("Facturas"); menus = menuItem.SubMenus; creationParams.Type = SAPbouiCOM.BoMenuType.mt_STRING; creationParams.UniqueID = "FacturasDoc"; creationParams.String = "Facturas Documentos"; menus.AddEx(creationParams); }
/** * Adiciona um item de menu em um menu ja existente ou adicionado. * * * menuItemB1ID Id do menu pai onde o item de menu devera ser inserido * menuItemDescr Texto do item de menu * menuItemID ID do item de menu que esta sendo criado * position posicao na lista de itens dentro de um menu * type tipo... * imagePath caminho para o arquivo de imagem a ser utilizado como icone no menu * */ public static void AddMenuItem(string menuItemB1ID, string menuItemDescr, string menuItemID , int position, BoMenuType type, string imagePath = "", bool remove = true) { SAPbouiCOM.Menus oMenus = null; SAPbouiCOM.MenuItem oMenuItem = null; SAPbouiCOM.MenuCreationParams oCreationPackage = null; oCreationPackage = ((SAPbouiCOM.MenuCreationParams)(B1AppDomain.Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams))); oMenuItem = B1AppDomain.Application.Menus.Item(menuItemB1ID); oMenus = oMenuItem.SubMenus; bool exist = (oMenus != null) && oMenuItem.SubMenus.Exists(menuItemID); if (exist && remove) { oMenuItem.SubMenus.RemoveEx(menuItemID); exist = false; } else { exist = false; } if (!(exist && remove)) { oCreationPackage.Type = type; oCreationPackage.UniqueID = menuItemID; oCreationPackage.String = menuItemDescr; oCreationPackage.Enabled = true; oCreationPackage.Position = position; //posição onde vai criar o modulo oCreationPackage.Image = imagePath; try { if (oMenus == null) { oMenuItem.SubMenus.Add(menuItemID, menuItemDescr, type, position); oMenus = oMenuItem.SubMenus; } oMenus.AddEx(oCreationPackage); } catch (Exception ex) { // B1Exception.throwException("Erro ao criar Menu ::", ex); } } }
private void AddMenuItems() { SAPbouiCOM.Menus oMenus = null; SAPbouiCOM.MenuItem oMenuItem = null; int i = 0; int iAddAfter = 0; string sXML = null; string sPath = null; oMenus = oApplication.Menus; SAPbouiCOM.MenuCreationParams oMenuCreationParams = null; oMenuCreationParams = (SAPbouiCOM.MenuCreationParams)(oApplication.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams)); oMenuItem = oApplication.Menus.Item("43520"); sPath = Application.StartupPath; //sPath = sPath.Remove(sPath.Length - 9, 0); oMenuCreationParams.Type = BoMenuType.mt_POPUP; oMenuCreationParams.UniqueID = "menu01"; oMenuCreationParams.String = "Menu Exemplo"; oMenuCreationParams.Enabled = true; oMenuCreationParams.Image = sPath + @"\\UI.bmp"; oMenuCreationParams.Position = 99; oMenus = oMenuItem.SubMenus; try { oMenus.AddEx(oMenuCreationParams); oMenuItem = oApplication.Menus.Item("menu01"); oMenus = oMenuItem.SubMenus; oMenuCreationParams.Type = BoMenuType.mt_STRING; oMenuCreationParams.UniqueID = "menu02"; oMenuCreationParams.String = "Sub Menu Exemplo"; oMenus.AddEx(oMenuCreationParams); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
public override void initApp() { String XlsFile; String s; base.initApp(); String Local; Boolean bCargar = false; try { // compilacion SQL HANA GlobalSettings.SBO_f = SBOFunctions; GlobalSettings.SBOMeta = SBOMetaData; // //oLog.LogFile = "C:\\Visualk\\xxx.log"; oLog.LogFile = System.IO.Path.GetDirectoryName(TMultiFunctions.ParamStr(0)) + "\\VD.log"; SAPbobsCOM.Recordset oRecordSet; oRecordSet = (SAPbobsCOM.Recordset)(SBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)); try { if (GlobalSettings.RunningUnderSQLServer) { s = "SELECT SUPERUSER FROM OUSR WHERE USER_CODE = '{0}'"; } else { s = @"SELECT ""SUPERUSER"" FROM ""OUSR"" WHERE ""USER_CODE"" = '{0}'"; } s = String.Format(s, SBOCompany.UserName.Trim()); oRecordSet.DoQuery(s); if (((System.String)oRecordSet.Fields.Item("SUPERUSER").Value).Trim() == "Y") { bCargar = true; } } catch { if (bCargar == false) { SBOApplication.MessageBox("El addon se esta iniciando por primera vez, debe inicar con un super usuario"); } } finally { SBOFunctions._ReleaseCOMObject(oRecordSet); oRecordSet = null; } //if (SBOCompany.UserName == "manager") if (bCargar) { XlsFile = System.IO.Path.GetDirectoryName(TMultiFunctions.ParamStr(0)) + "\\Docs\\UDFFELEC.xls"; if (!SBOFunctions.ValidEstructSHA1(XlsFile)) { oLog.OutLog("InitApp: Estructura de datos 1 - Facturación Electronica"); SBOApplication.StatusBar.SetText("Inicializando AddOn Factura Electronica(1).", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); if (!SBOMetaData.SyncTablasUdos("1.1", XlsFile)) { SBOFunctions.DeleteSHA1FromTable("EDAG.xls"); oLog.OutLog("InitApp: sincronización de Estructura de datos fallo"); CloseSplash(); SBOApplication.MessageBox("Estructura de datos con problemas, consulte a soporte...", 1, "Ok", "", ""); Halt(0); } } XlsFile = System.IO.Path.GetDirectoryName(TMultiFunctions.ParamStr(0)) + "\\Docs\\UDFFELECCL.xls"; if (!SBOFunctions.ValidEstructSHA1(XlsFile)) { oLog.OutLog("InitApp: Estructura de datos 2 - Facturación Electronica CL"); SBOApplication.StatusBar.SetText("Inicializando AddOn Factura Electronica(2).", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); if (!SBOMetaData.SyncTablasUdos("1.1", XlsFile)) { SBOFunctions.DeleteSHA1FromTable("UDFFELECCL.xls"); oLog.OutLog("InitApp: sincronización de Estructura de datos fallo"); SBOApplication.MessageBox("Estructura de datos con problemas, consulte a soporte...", 1, "Ok", "", ""); } } XlsFile = System.IO.Path.GetDirectoryName(TMultiFunctions.ParamStr(0)) + "\\Docs\\UDFSAP.xls"; if (!SBOFunctions.ValidEstructSHA1(XlsFile)) { oLog.OutLog("InitApp: Estructura de datos 3 - Facturación Electronica CL"); SBOApplication.StatusBar.SetText("Inicializando AddOn Factura Electronica(3).", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); if (!SBOMetaData.SyncTablasUdos("1.1", XlsFile)) { SBOFunctions.DeleteSHA1FromTable("UDFSAP.xls"); oLog.OutLog("InitApp: sincronización de Estructura de datos fallo"); SBOApplication.MessageBox("Estructura de datos con problemas, consulte a soporte...", 1, "Ok", "", ""); } } } oLog.DebugLvl = 20; MainObj[0].GlobalSettings = GlobalSettings; MainObj[0].SBOApplication = SBOApplication; MainObj[0].SBOCompany = SBOCompany; MainObj[0].oLog = oLog; MainObj[0].SBOFunctions = SBOFunctions; //SetFiltros(); MainObj[0].AddMenus(); InitOK = true; oLog.OutLog("App SBO in C# - Init!"); SBOApplication.StatusBar.SetText("Aplicación Inicializada.", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Success); if (1 == 1) //(SBOFunctions.AccessStr.Substring(10,1) = 'P') then { GlobalSettings.SBO_f = SBOFunctions; MainObj[0].GlobalSettings = GlobalSettings; MainObj[0].SBOApplication = SBOApplication; MainObj[0].SBOCompany = SBOCompany; MainObj[0].oLog = oLog; MainObj[0].SBOFunctions = SBOFunctions; } SetFiltros(); if (1 == 1) // (SBOFunctions.AccessStr.Substring(10,1) = 'P') then { //MainObj[0].AddMenus(); SAPbouiCOM.Menus oMenus = null; SAPbouiCOM.MenuItem oMenuItem = null; System.Xml.XmlDocument oXmlDoc = null; oXmlDoc = new System.Xml.XmlDocument(); oXmlDoc.Load(System.IO.Path.GetDirectoryName(TMultiFunctions.ParamStr(0)) + "\\Menus\\RemoveMenu.xml"); string sXML = oXmlDoc.InnerXml.ToString(); SBOApplication.LoadBatchActions(ref sXML); oXmlDoc.Load(System.IO.Path.GetDirectoryName(TMultiFunctions.ParamStr(0)) + "\\Menus\\Menu.xml"); sXML = oXmlDoc.InnerXml.ToString(); SBOApplication.LoadBatchActions(ref sXML); //GlobalSettings.AddMenusRepAux(False); //GlobalSettings.AddMenusRepAux(True); } InitOK = true; oLog.OutLog("C# - Shine your crazy diamond!"); SBOApplication.StatusBar.SetText("Aplicación Inicializada.", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Success); } catch (Exception ex) { oLog.OutLog("Error iniApp, " + ex.Message + ", TRACE " + ex.StackTrace); } finally { CloseSplash(); } }