Esempio n. 1
0
        private void SetApplication()
        {
            SAPbouiCOM.SboGuiApi oSboGuiApi = null;
            string sConnectionString        = null;

            oSboGuiApi = new SAPbouiCOM.SboGuiApi();

            sConnectionString = System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(1));

            try
            {
                oSboGuiApi.Connect(sConnectionString);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
                System.Environment.Exit(0);
            }
            oApplication = oSboGuiApi.GetApplication(-1);

            oApplication.SetStatusBarMessage(string.Format("Addon {0} Conectado com sucesso!!!);",
                                                           System.Windows.Forms.Application.ProductName),
                                             BoMessageTime.bmt_Medium
                                             , false);
        }
Esempio n. 2
0
        static void Main(String[] Args)
        {
            try
            {
                SAPbouiCOM.SboGuiApi oGUI = new SAPbouiCOM.SboGuiApi();
                if (Args.Length == 0)
                {
                    oGUI.Connect("0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056");
                }
                else
                {
                    oGUI.Connect(Args[0]);
                }

                eCommon.SetApplication(oGUI.GetApplication(-1), gcAddOnName, true);

                // To add additional DB
                SBOAddon_DB addOnDb = new SBOAddon_DB();
                SBOAddon    oAddOn  = new SBOAddon();

                String str_directory = Environment.CurrentDirectory.ToString();
                String parent        = System.IO.Directory.GetParent(System.IO.Directory.GetParent(System.IO.Directory.GetParent(str_directory).FullName).FullName).FullName + "\\";


                if (oAddOn.Connected)
                {
                    System.Windows.Forms.Application.Run();
                }
            }
            catch (Exception Ex)
            {
                System.Windows.Forms.MessageBox.Show("ERROR - Connection failed: " + Ex.Message);;
            }
        }
        /// <summary>
        /// Inicia a aplicação
        /// </summary>
        public void InitializeApplication()
        {
            var oSboGuiApi = new SAPbouiCOM.SboGuiApi();

            try
            {
                // Conecta a uma aplicação do SBO que esteja rodando
                oSboGuiApi.Connect(Connection);

                // Obtém o objeto da aplicação inicializada pelo método Connect acima executado
                Application = oSboGuiApi.GetApplication(-1);

                Application.StatusBar.SetText("Conexão do add-on: " + System.Windows.Forms.Application.ProductName, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);

                // Obtém a companhia da aplicação
                Company = (SAPbobsCOM.Company)Application.Company.GetDICompany();

                Translator = new TranslatorTool();

                // Inicializa informações de formato conforme informações da aplicação
                FormatInitializer();

                this.SetEvents();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Não foi possível conectar ao SAP Business One: " + ex.Message, "Erro na conexão", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);

                // Finalização do add-on
                System.Environment.Exit(0);
            }
        }
        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);
        }
Esempio n. 5
0
File: Conn.cs Progetto: bagundes/sui
        public static void Connect(string commandLineArg = null, int appId = -1)
        {
            klib.Shell.WriteLine(R.Project.ID, LOG, $"SUI - Connecting ...");
            if (String.IsNullOrEmpty(commandLineArg))
            {
                commandLineArg = R.CommandLineArg;
            }

            var sga = new SAPbouiCOM.SboGuiApi();

            sga.Connect(commandLineArg);
            UI = sga.GetApplication(appId);

            klib.Shell.WriteLine(R.Project.ID, LOG, $"SUI - Connected");
        }
Esempio n. 6
0
        public void Connect(Type[] types)
        {
            SAPbouiCOM.SboGuiApi   objGUIApi      = null;
            SAPbouiCOM.Application objApplication = null;
            SAPbobsCOM.Company     objCompany     = null;
            B1AppDomain.ConnectionString = (string)Environment.GetCommandLineArgs().GetValue(1);
            //"0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056";
            //"0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056";
            try
            {
                objGUIApi = new SAPbouiCOM.SboGuiApi();
                objGUIApi.Connect(B1AppDomain.ConnectionString);
                objApplication = objGUIApi.GetApplication(-1);
                objCompany     = (SAPbobsCOM.Company)objApplication.Company.GetDICompany();

                b1Connected = objCompany.Connected;
                if (b1Connected)
                {
                    B1AppDomain.Application = objApplication;
                    B1AppDomain.Company     = objCompany;
                    B1AppDomain.Connected   = true;
                    B1AppDomain.Application.SetStatusBarMessage("Conexão estabelecida com sucesso!", BoMessageTime.bmt_Short, false);
                    new Events();
                    B1AppDomain.Application.SetStatusBarMessage("Carregando Aplicação...", BoMessageTime.bmt_Short, false);
                    CriaInstanciaClasses(types);
                    B1AppDomain.Application.SetStatusBarMessage("Carregamento Concluido!", BoMessageTime.bmt_Short, false);
                }
                else
                {
                    B1AppDomain.Connected = false;
                }
            }
            catch (Exception er)
            {
                B1AppDomain.Connected = false;
                B1Exception.throwException("Erro ao conectar no SAP B1: ", er);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Connect to SAP
        /// </summary>
        private void SetupApplication()
        {
            SAPbouiCOM.SboGuiApi oSboGuiApi = null;
            string sConnectionString        = null;

            oSboGuiApi        = new SAPbouiCOM.SboGuiApi();
            sConnectionString = System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(1));
            //sConnectionString = "0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056";

            oSboGuiApi.Connect(sConnectionString);

            oSBOApplication = oSboGuiApi.GetApplication();
            oSBOCompany     = oSBOApplication.Company.GetDICompany();

            if (oSBOCompany.DbServerType == SAPbobsCOM.BoDataServerTypes.dst_HANADB)
            {
                GeneralVariables.SQLHandler = new HANAQueries();
            }
            else
            {
                GeneralVariables.SQLHandler = new SQLQueries();
            }
        }
Esempio n. 8
0
        public int EnableSAPConnection()
        {
            SAPbouiCOM.SboGuiApi SboGuiApi = null;
            string sCon = String.Empty;

            SboGuiApi = new SAPbouiCOM.SboGuiApi();

            // Mehr zur Verbindugen:  https://archive.sap.com/discussions/thread/1732991, 2018-09-03
            // Verbindung über DEBUG-Modus
            if (Environment.GetCommandLineArgs().Length > 1)
            {
                sCon = System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(1));
            } // Verbindung über Release - Modus
            else
            {
                sCon = System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(0));
            }


            if (!(SetConnectionContext() == 0))
            {
                return(-1);
            }

            // //*************************************************************
            // // Connect To The Company Data Base
            // //*************************************************************

            if (!(ConnectToCompany() == 0))
            {
                return(-2);
            }
            _orec = (SAPbobsCOM.Recordset) this._oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

            return(0);
        }
Esempio n. 9
0
        static void Main(String[] Args)
        {
            //Create an Event Log
            if (Args.Length == 0)
            {
                SAPbouiCOM.SboGuiApi oGUI = new SAPbouiCOM.SboGuiApi();
                oGUI.Connect(eCommon.SBOConnectionString);
                try
                {
                    eCommon.SetApplication(oGUI.GetApplication(-1), gcAddOnName, true);
                    //SBOAddon_DB addOnDb = new SBOAddon_DB();

                    SBOAddon oAddOn = new SBOAddon();
                    if (oAddOn.Connected)
                    {
                        System.Windows.Forms.Application.Run();
                    }
                }
                catch (Exception Ex)
                {
                    System.Windows.Forms.MessageBox.Show("ERROR - Connection failed: " + Ex.Message);;
                }
            }
            else
            {
                switch (Args[0].ToUpper())
                {
                case "READNUPDATE":
                    eCommon.CreateLogFileNoUI();
                    try
                    {
                        SAPbobsCOM.BoDataServerTypes ServerType = BoDataServerTypes.dst_MSSQL2012;
                        String Server     = null;
                        String LicServer  = null;
                        String CompDB     = null;
                        String UserName   = null;
                        String Password   = null;
                        String UseTrusted = "0";
                        String DBUserName = null;
                        String DBPassword = null;
                        InitializeServerVariables(out ServerType, out CompDB, out Server, out LicServer, out UserName, out Password, out UseTrusted, out DBUserName, out DBPassword);
                        eCommon.InitCompany(ServerType, Server, LicServer, CompDB, UserName, Password);
                    }
                    catch (Exception Ex)
                    {
                        eCommon.WriteEventLog("Could not connect to company. " + Ex.Message);
                    }

                    if (eCommon.oCompany.Connected)
                    {
                        ReadAndUpdateDB _rnu = new ReadAndUpdateDB();
                    }

                    break;

                case "SETTING":
                    frmSetting frm = new frmSetting();
                    frm.ShowDialog();
                    break;
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Inicia a aplicação
        /// </summary>
        public void InitializeApplication()
        {
            var oSboGuiApi = new SAPbouiCOM.SboGuiApi();

            try
            {
                // Conecta a uma aplicação do SBO que esteja rodando                                                    
                oSboGuiApi.Connect(Connection);
                
                // Obtém o objeto da aplicação inicializada pelo método Connect acima executado                
                Application = oSboGuiApi.GetApplication(-1);

                Application.StatusBar.SetText("Conexão do add-on: " + System.Windows.Forms.Application.ProductName, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);

                // Obtém a companhia da aplicação 
                Company = (SAPbobsCOM.Company)Application.Company.GetDICompany();

                Translator = new TranslatorTool();

				// Inicializa informações de formato conforme informações da aplicação
				FormatInitializer();

                this.SetEvents();

            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Não foi possível conectar ao SAP Business One: " + ex.Message, "Erro na conexão", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);

                // Finalização do add-on                                                                 
                System.Environment.Exit(0);
            }
        }