//Inicializa aplicacion public static void SetApplication() { //Se obtiene string de conexion de Cliente SAP B1 if (Environment.GetCommandLineArgs().Count() == 1) { throw new Exception("No se agregaron los parametros de conexión...", new Exception("No se encontro string de conexión SAP B1")); } ConnectionString = Environment.GetCommandLineArgs().GetValue(1).ToString(); //Se realiza conexion SAPbouiCOM.SboGuiApi client = new SAPbouiCOM.SboGuiApi(); client.Connect(ConnectionString); SBOApplication = client.GetApplication(-1); //Se carga <<Company>> de aplicacion SBOCompany = new SAPbobsCOM.Company(); string cookies = SBOCompany.GetContextCookie(); string connectionContext = SBOApplication.Company.GetConnectionContext(SBOCompany.GetContextCookie()); SBOCompany.SetSboLoginContext(connectionContext); //Conexion con sociedad if (SBOCompany.Connect() != 0) { throw new Exception(SBOError); } }
private SAPbouiCOM.Application instanciarAplicacion() { var guiApi = new SAPbouiCOM.SboGuiApi(); guiApi.Connect(Environment.GetCommandLineArgs().GetValue(1).ToString()); return(guiApi.GetApplication()); }
/// <summary> /// Connect sap using UI API. /// </summary> /// <param name="connString">If you not define the string connection, the string connection will be default</param> public static void Connect(string connString = null) { try { SAPbouiCOM.SboGuiApi SboGuiApi = null; string sConnectionString = null; SboGuiApi = new SAPbouiCOM.SboGuiApi(); sConnectionString = connString ?? sap.ui.E.ConnString; SboGuiApi.Connect(sConnectionString); conn = SboGuiApi.GetApplication(-1); var debug = false; #if DEBUG debug = true; #endif if (R.DebugMode && !debug) { conn.MessageBox("Addon is connected as debug mode."); } else { conn.SetStatusBarMessage($"{R.CompanyName} addon is connected.", SAPbouiCOM.BoMessageTime.bmt_Short, false); } } catch (Exception ex) { k.Diagnostic.Error(LOG, ex); throw new Exception($"Error to connect SAP using DI UIAPI.", ex); } }
private void SetApplication() { // ******************************************************************* // Use an SboGuiApi object to establish connection // with the SAP Business One application and return an // initialized appliction object // ******************************************************************* SAPbouiCOM.SboGuiApi SboGuiApi = null; string sConnectionString = null; SboGuiApi = new SAPbouiCOM.SboGuiApi(); // by following the steps specified above, the following // statment should be suficient for either development or run mode sConnectionString = System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(1)); // connect to a running SBO Application SboGuiApi.Connect(sConnectionString); // get an initialized application object SBO_Application = SboGuiApi.GetApplication(-1); }
public static void ConnectViaUI() { try { SAPbouiCOM.SboGuiApi uiAPI = new SAPbouiCOM.SboGuiApi(); string sConnStr = Environment.GetCommandLineArgs().GetValue(1).ToString(); uiAPI.Connect(sConnStr); oApp = uiAPI.GetApplication(); // delegate the event handler oApp4AppEventHandler = oApp; oApp4ItemEvent = oApp; oApp4FormData = oApp; oApp4MenuEvent = oApp; oEventFilters = new SAPbouiCOM.EventFilters(); MsgBoxWrapper("UI API Connected.", MsgBoxType.B1StatusBarMsg, SAPbouiCOM.BoStatusBarMessageType.smt_Success); } // uiAPI = Nothing catch (Exception ex) { MsgBoxWrapper(ex.Message); } }
public void SetApplication() { SAPbouiCOM.SboGuiApi SboGuiApi = null; string sConnectionString = null; SboGuiApi = new SAPbouiCOM.SboGuiApi(); sConnectionString = System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(1)); // connect to a running SBO Application try { SboGuiApi.Connect(sConnectionString); // get an initialized application object SBO_Application = SboGuiApi.GetApplication(); SBO_Application.SetStatusBarMessage("Se ha iniciado el Add-on de FE_DIAN", SAPbouiCOM.BoMessageTime.bmt_Short, false); oCompany = new SAPbobsCOM.Company(); //get DI company (via UI) oCompany = (SAPbobsCOM.Company)SBO_Application.Company.GetDICompany(); } catch (Exception ex) { // Connection failed System.Windows.Forms.MessageBox.Show("Error al iniciar el Add-on de Youse" + ex.Message, "Error de conexión", System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Error, System.Windows.Forms.MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly); System.Environment.Exit(0); } }
public void SetApplication() { string connectionstring = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056"; SAPbouiCOM.SboGuiApi oGuiApi = new SAPbouiCOM.SboGuiApi(); oGuiApi.Connect(connectionstring); Global.oapplication = oGuiApi.GetApplication(1); }
private void setApplication() { SAPbouiCOM.ISboGuiApi sboGuiApi = null; string sConnectionString = null; sboGuiApi = new SAPbouiCOM.SboGuiApi(); sConnectionString = Interaction.Command(); sboGuiApi.Connect(sConnectionString); SBO_Application = sboGuiApi.GetApplication(-1); }
private void SetApplication() { SAPbouiCOM.SboGuiApi oSboGuiApi = null; string sConnectionString = null; oSboGuiApi = new SAPbouiCOM.SboGuiApi(); sConnectionString = System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(1)); oSboGuiApi.Connect(sConnectionString); oApplication = oSboGuiApi.GetApplication(-1); }
public static void Conectar_Aplicacion() { SAPbouiCOM.SboGuiApi SboGuiApi = new SAPbouiCOM.SboGuiApi(); oCompany = new SAPbobsCOM.Company(); SboGuiApi.Connect("0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056"); oApplication = SboGuiApi.GetApplication(); oCompany = (SAPbobsCOM.Company)oApplication.Company.GetDICompany(); sCodUsuActual = oCompany.UserSignature.ToString(); sNomUsuActual = Funciones.Nombre_Usuario_Actual(); sAliasUsuActual = oCompany.UserName; sCurrentCompanyDB = oCompany.CompanyDB; }
/// <summary> /// Metodo para conectarse a la Aplicacion SBO que se esta ejecutando (UIAPI) /// </summary> private void ObtenerAplicacion() { try { string strConexion = ""; //variable que almacena el codigo de identificacion de conexion con SBO string[] strArgumentos = new string[4]; SAPbouiCOM.SboGuiApi oSboGuiApi = null; //Variable para obtener la instacia activa de SBO oSboGuiApi = new SAPbouiCOM.SboGuiApi(); //Instancia nueva para la gestion de la conexion strArgumentos = System.Environment.GetCommandLineArgs(); //obtenemos el codigo de conexion del entorno configurado en "Propiedades -> Depurar -> Argumentos de la linea de comandos" if (strArgumentos.Length > 0) { if (strArgumentos.Length > 1) { //Verificamos que la aplicacion se este ejecutando en un ambiente SBO if (strArgumentos[0].LastIndexOf("\\") > 0) { strConexion = strArgumentos[1]; } else { strConexion = strArgumentos[0]; } } else { //Verificamos que la aplicacion se este ejecutando en un ambiente SBO if (strArgumentos[0].LastIndexOf("\\") > -1) { strConexion = strArgumentos[0]; } else { Comunes.Msj_Appl.Errores(1, ""); //mensaje de erro por no tener SBO activo } } } else { Comunes.Msj_Appl.Errores(1, ""); //mensaje de erro por no tener SBO activo } oSboGuiApi.Connect(strConexion); //Establecemos la conexion m_SBO_Appl = oSboGuiApi.GetApplication(-1); //Asignamos la conexion a la aplicacion } catch (Exception ex) { Comunes.Msj_Appl.Errores(-2, ex.Message); } }
public static void Conectar_Aplicacion() { SAPbouiCOM.SboGuiApi SboGuiApi = new SAPbouiCOM.SboGuiApi(); oCompany = new SAPbobsCOM.Company(); SboGuiApi.Connect("0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056"); oApplication = SboGuiApi.GetApplication(); oCompany = (SAPbobsCOM.Company)oApplication.Company.GetDICompany(); oSBObob = (SAPbobsCOM.SBObob)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge); sCodUsuActual = oCompany.UserSignature.ToString(); sNomUsuActual = Funciones.Current_User_Name(); sAliasUsuActual = oCompany.UserName; sCurrentCompanyDB = oCompany.CompanyDB; }
/// <summary> /// Establece la aplicación /// </summary> private void EstablecerAplicacion() { SAPbouiCOM.SboGuiApi _oSboGuiApi; string _oConnectionString; _oSboGuiApi = new SAPbouiCOM.SboGuiApi(); try { _oConnectionString = Environment.GetCommandLineArgs().GetValue(1).ToString(); _oSboGuiApi.Connect(_oConnectionString); SBO_Application = _oSboGuiApi.GetApplication(); } catch (Exception ex) { throw new Exception(ex.Message); } }
private void SetApplication() { SAPbouiCOM.SboGuiApi sboGuiApi; string sConnectionString; sboGuiApi = new SAPbouiCOM.SboGuiApi(); // by following the steps specified above, the following // statment should be suficient for either development or run mode sConnectionString = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056"; // connect to a running SBO Application sboGuiApi.Connect(sConnectionString); // get an initialized application object SBO_Application = sboGuiApi.GetApplication(-1); }
private void SetApplication() { SAPbouiCOM.SboGuiApi SboGuiApi = null; string sConnectionString = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056"; try { sConnectionString = Environment.GetCommandLineArgs().GetValue(1).ToString(); } catch { } SboGuiApi = new SAPbouiCOM.SboGuiApi(); // sConnectionString = System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(1)); SboGuiApi.Connect(sConnectionString); oApplication = SboGuiApi.GetApplication(-1); }
/// <summary> /// Connect UI and DI API /// </summary> /// <param name="connectionString">Connection String from SBO Main Application</param> /// <param name="loggingEnabled">Is SBO Common Logging enabled</param> public static void Connect(string connectionString = null, bool loggingEnabled = true) { //connectionString = DebugConnectionString; if (connectionString == null) { connectionString = Environment.GetCommandLineArgs().Length > 1 ? Convert.ToString(Environment.GetCommandLineArgs().GetValue(1)) : string.Empty; } var sboGuiApi = new SAPbouiCOM.SboGuiApi(); _diCompany = new SAPbobsCOM.Company(); try { sboGuiApi.Connect(connectionString); _application = sboGuiApi.GetApplication(); var contextCookie = _diCompany.GetContextCookie(); var diCompanyConnectionString = _application.Company.GetConnectionContext(contextCookie); var responseCode = _diCompany.SetSboLoginContext(diCompanyConnectionString); ErrorHelper.HandleErrorWithException(responseCode, "DI API Could not Set Sbo Login Context", _diCompany); var connectResponse = _diCompany.Connect(); ErrorHelper.HandleErrorWithException(connectResponse, $"DI API Could not connect.", _diCompany); if (loggingEnabled) { SboAppLogger.Enable(); } var assemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name; Logger.Info($"{assemblyName} connected"); SetAppEvents(); } catch (Exception ex) { Logger.Error($"SboApp UI Connect Error: {ex.Message}", ex); throw; } }
public void conectarGuiApi(ref SAPbouiCOM.Application app) { try { SAPbouiCOM.SboGuiApi conn = new SAPbouiCOM.SboGuiApi(); //string cadena = System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(1)); string cadena = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056"; //string cadena = ""; conn.Connect(cadena); conn.AddonIdentifier = "5645523035496D706C656D656E746174696F6E3A5331343030393633343339891936B4434B1E01D7DD48DAB7C6A050FD7D3F35"; app = conn.GetApplication(-1); } catch (Exception e) { app.StatusBar.SetText("config_method_conectarGuiApi " + e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); } }
public SAPbouiCOM.Application SetApplication() { SAPbouiCOM.SboGuiApi SboGuiApi = null; string sConnectionString = null; SboGuiApi = new SAPbouiCOM.SboGuiApi(); sConnectionString = System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(1)); try { SboGuiApi.Connect(sConnectionString); } catch { System.Windows.Forms.MessageBox.Show("SDK:No SAP Business One Application was found"); System.Environment.Exit(0); } SBO_Application = SboGuiApi.GetApplication(-1); return(SBO_Application); }
/// <summary> /// Method to connect to UI API /// </summary> public static void ConnectUI() { SAPbouiCOM.SboGuiApi SboGuiApi = null; string sConnectionString = null; SboGuiApi = new SAPbouiCOM.SboGuiApi(); sConnectionString = Convert.ToString(Environment.GetCommandLineArgs().GetValue(1)); try { // If there's no active application the connection will fail //SboGuiApi.AddonIdentifier = "56455230354241534953303030303030383639313A56313933383937363435301821FA2EA03BDD5BDED09A772C9FF0AE7D4EE6AF"; SboGuiApi.Connect(sConnectionString); } catch (Exception ex) { // Connection failed MessageBox.Show(ex.Message, "Equipment Management - Warning", MessageBoxButtons.OK, MessageBoxIcon.Information); Environment.Exit(0); } PublicVariable.oApplication = SboGuiApi.GetApplication(-1); }
public int Connect() { try { __GUI = new SAPbouiCOM.SboGuiApi(); __GUI.Connect(Environment.GetCommandLineArgs().GetValue(1).ToString()); __app = __GUI.GetApplication(-1); __app.MenuEvent += new SAPbouiCOM._IApplicationEvents_MenuEventEventHandler(__app_MenuEvent); __app.ItemEvent += new SAPbouiCOM._IApplicationEvents_ItemEventEventHandler(__app_ItemEvent); __app.AppEvent += new SAPbouiCOM._IApplicationEvents_AppEventEventHandler(__app_AppEvent); __app.FormDataEvent += new SAPbouiCOM._IApplicationEvents_FormDataEventEventHandler(__app_FormDataEvent); //return 0; int i = 0; //Check For License //string LicenseKey = ConfigurationManager.AppSettings["LicenseDate"].ToString(); //DateTime LicenseDate = DateTime.Parse(LicenseKey); //if (DateTime.Now.Date <= LicenseDate) //{ ____bobCompany = (SAPbobsCOM.Company)__app.Company.GetDICompany(); TableCreation(); //int RetVal = ____bobCompany.Connect(); //Int32 ErrorCode = 0; //string ErrorMessage = ""; //if (RetVal == 0) //{ XmlDocument oXMLDoc = new XmlDocument(); string MenuPath = Application.StartupPath + "\\FileGen_Menu.xml"; if (__app.Menus.Exists("MDC_MNU")) { __app.Menus.RemoveEx("MDC_MNU"); } oXMLDoc.Load(MenuPath); __app.LoadBatchActions(oXMLDoc.InnerXml); i = 0; return(i); } catch (COMException e) { if (e.ErrorCode == -7201) { return(e.ErrorCode); } else { __app.MessageBox(e.Message, 0, "Ok", null, null); return(0); } } }
public void B1Connect(bool stopEvents) { SAPbouiCOM.SboGuiApi objGUIApi = null; SAPbobsCOM.Company objCompany = null; try { _Logger.Debug("Starting SAP Connection"); objGUIApi = new SAPbouiCOM.SboGuiApi(); _Logger.Debug("Retrieving connection string from Cache"); objGUIApi.Connect((string)T1.CacheManager.CacheManager.Instance.getFromCache(T1.CacheManager.Settings._Main.connStringCacheName)); _Logger.Debug("Connectong to current company"); objApplication = objGUIApi.GetApplication(-1); objApplication.EventLevel = SAPbouiCOM.BoEventLevelType.elf_Both; if (Settings._Main.useCompatibilityConnection) { _Logger.Info("Connecting to DI API using Compatibility mode (cookies)"); objCompany = new SAPbobsCOM.Company(); string strContextCookie = objCompany.GetContextCookie(); string strConnectionString = objApplication.Company.GetConnectionContext(strContextCookie); _Logger.Debug("Setting Login Context"); if (objCompany.SetSboLoginContext(strConnectionString) == 0) { if (objCompany.Connect() != 0) { string strError = objCompany.GetLastErrorCode() + ":" + objCompany.GetLastErrorDescription(); _Logger.Error(strError); } else { bool isHANA = objCompany.DbServerType == SAPbobsCOM.BoDataServerTypes.dst_HANADB ? true : false; T1.CacheManager.CacheManager.Instance.addToCache(T1.CacheManager.Settings._Main.isHANACacheName, isHANA, CacheManager.CacheManager.objCachePriority.NotRemovable); } } else { string strError = objCompany.GetLastErrorCode() + ":" + objCompany.GetLastErrorDescription(); _Logger.Error(strError); } } else { _Logger.Info("Connecting to DI API using shared memory library"); objCompany = new SAPbobsCOM.Company(); if (Settings._Main.useCompanyApplication) { objCompany.Application = objApplication; if (objCompany.Connect() != 0) { string strError = objCompany.GetLastErrorCode() + ":" + objCompany.GetLastErrorDescription(); _Logger.Error(strError); } else { bool isHANA = objCompany.DbServerType == SAPbobsCOM.BoDataServerTypes.dst_HANADB ? true : false; T1.CacheManager.CacheManager.Instance.addToCache(T1.CacheManager.Settings._Main.isHANACacheName, isHANA, CacheManager.CacheManager.objCachePriority.NotRemovable); } } else { objCompany = objApplication.Company.GetDICompany(); bool isHANA = objCompany.DbServerType == SAPbobsCOM.BoDataServerTypes.dst_HANADB ? true : false; T1.CacheManager.CacheManager.Instance.addToCache(T1.CacheManager.Settings._Main.isHANACacheName, isHANA, CacheManager.CacheManager.objCachePriority.NotRemovable); } } _Logger.Debug("Checking connection status"); blConnected = objCompany.Connected; if (blConnected) { _Logger.Debug("Connected to company " + objCompany.CompanyName); objCompany.XmlExportType = SAPbobsCOM.BoXmlExportTypes.xet_ExportImportMode; objCompany.XMLAsString = true; T1.B1.MainObject.Instance.B1Application = objApplication; T1.B1.MainObject.Instance.B1Company = objCompany; SAPbobsCOM.CompanyService objServ = objCompany.GetCompanyService(); SAPbobsCOM.AdminInfo objAdmInfo = objServ.GetAdminInfo(); T1.B1.InternalClasses.AdminInfo B1AdmInfo = new InternalClasses.AdminInfo(); B1AdmInfo.DecimalSeparator = objAdmInfo.DecimalSeparator; B1AdmInfo.ThousandsSeparator = objAdmInfo.ThousandsSeparator; B1AdmInfo.DateSeparator = objAdmInfo.DateSeparator; B1AdmInfo.SystemCurrency = objAdmInfo.SystemCurrency; B1AdmInfo.RateAccuracy = objAdmInfo.RateAccuracy; B1AdmInfo.QueryAccuracy = objAdmInfo.QueryAccuracy; B1AdmInfo.AccuracyofQuantities = objAdmInfo.AccuracyofQuantities; B1AdmInfo.PercentageAccuracy = objAdmInfo.PercentageAccuracy; B1AdmInfo.PriceAccuracy = objAdmInfo.PriceAccuracy; B1AdmInfo.TotalsAccuracy = objAdmInfo.TotalsAccuracy; B1AdmInfo.LocalCurrency = objAdmInfo.LocalCurrency; B1AdmInfo.DateTemplate = objAdmInfo.DateTemplate; B1AdmInfo.DisplayCurrencyontheRight = objAdmInfo.DisplayCurrencyontheRight == SAPbobsCOM.BoYesNoEnum.tYES ? true : false; B1AdmInfo.FederalTaxID = objAdmInfo.FederalTaxID; B1AdmInfo.MeasuringAccuracy = objAdmInfo.MeasuringAccuracy; T1.B1.MainObject.Instance.B1AdminInfo = B1AdmInfo; } if (stopEvents) { objHandler1 = new SAPbouiCOM._IApplicationEvents_ItemEventEventHandler(objApplication_ItemEvent); objHandler2 = new SAPbouiCOM._IApplicationEvents_MenuEventEventHandler(objApplication_MenuEvent); objApplication.ItemEvent += objHandler1; objApplication.MenuEvent += objHandler2; } } catch (COMException comEx) { //Exception er = new Exception(Convert.ToString(comEx.ErrorCode + "::" + comEx.Message + "::" + comEx.StackTrace)); _Logger.Error("", comEx); } catch (Exception er) { _Logger.Error("", er); } }
private void SetApplication() { SAPbouiCOM.SboGuiApi SboGuiApi = null; string sConnectionString = null; SboGuiApi = new SAPbouiCOM.SboGuiApi(); sConnectionString = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056"; try { SboGuiApi.Connect(sConnectionString); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); System.Environment.Exit(0); } SBO_Application = SboGuiApi.GetApplication(-1); }
private void SetApplication() { SAPbouiCOM.SboGuiApi SboGuiApi = null; string sConnectionString = null; SboGuiApi = new SAPbouiCOM.SboGuiApi(); sConnectionString = System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(1)); SboGuiApi.Connect(sConnectionString); SBO_Application = SboGuiApi.GetApplication(-1); }