Exemplo n.º 1
0
 /// <summary>
 /// Creates the standard settings.
 /// </summary>
 /// <param name="server">The server.</param>
 /// <param name="dbUserName">Name of the database user.</param>
 /// <param name="dbPassword">The database password.</param>
 /// <param name="userName">Company username.</param>
 /// <param name="password">Company password.</param>
 /// <param name="language">The language.</param>
 /// <param name="licenseServer">The license server in &lt;ServerName:Port&gt; format.</param>
 /// <param name="dbServerType">Type of the database server.</param>
 /// <param name="companyDb">The company database.</param>
 /// <returns></returns>
 public static DiApiConnectionSettings CreateStandardSettings(
     string server,
     string dbUserName,
     string dbPassword,
     string userName,
     string password,
     BoSuppLangs language,
     string licenseServer,
     BoDataServerTypes dbServerType,
     string companyDb)
 {
     return(new DiApiConnectionSettings
     {
         Server = server,
         UseTrusted = false,
         DbUserName = dbUserName,
         DbPassword = dbPassword,
         UserName = userName,
         Password = password,
         Language = language,
         LicenseServer = licenseServer,
         DbServerType = dbServerType,
         CompanyDb = companyDb
     });
 }
        private void metroButtonConnect_Click(object sender, EventArgs e)
        {
            try
            {
                metroLinkWaiting.Visible = true;
                metroLinkWaiting.Refresh();
                ValidFields();
                _selectedServerType = (BoDataServerTypes)metroComboBoxServerType.SelectedItem;
                //Thread thread = new Thread(ConnectOnSAP);
                //thread.Start();

                ConnectOnSAP();

                SaveConnectionParam();
                EnableSelecionTables();
                FillSAPTables();

                this.ShowSucess("Conexão realizada com sucesso!");

                metroTabControl1.SelectedIndex      = 1;
                metroTabControlFields.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                this.ShowError(ex.Message);
            }
            finally
            {
                metroLinkWaiting.Visible = false;

                this.Select();
            }
        }
Exemplo n.º 3
0
        public DIApiConnector()
        {
            String      baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location.ToString());
            XmlDocument xmlDoc  = new XmlDocument();

            xmlDoc.Load(baseDir + @"\Xml\DataAccess.xml");
            XmlNodeList       nodeList      = xmlDoc.ChildNodes[1].ChildNodes;
            XmlNode           sqlServerNode = null;
            XmlNode           sapB1Node     = null;
            BoDataServerTypes sqlServerType = BoDataServerTypes.dst_MSSQL;

            foreach (XmlNode node in nodeList)
            {
                if (node.Attributes["name"].Value == "SQL Server 2005")
                {
                    sqlServerNode = node;
                    sqlServerType = BoDataServerTypes.dst_MSSQL2005;
                }
                if (node.Attributes["name"].Value == "SQL Server 2008")
                {
                    sqlServerNode = node;
                    sqlServerType = BoDataServerTypes.dst_MSSQL2008;
                }
                if (node.Attributes["name"].Value == "SAP B1")
                {
                    sapB1Node = node;
                }
            }
            if (sqlServerNode == null)
            {
                return;
            }
            if (sapB1Node == null)
            {
                return;
            }
            String dbServer    = sqlServerNode.SelectSingleNode("server").InnerText;
            String dbUsername  = sqlServerNode.SelectSingleNode("username").InnerText;
            String dbPassword  = sqlServerNode.SelectSingleNode("password").InnerText;
            String database    = sapB1Node.SelectSingleNode("database").InnerText;
            String sapUsername = sapB1Node.SelectSingleNode("username").InnerText;
            String sapPassword = sapB1Node.SelectSingleNode("password").InnerText;

            sboCompany = new SAPbobsCOM.Company();
            sboCompany.DbServerType = sqlServerType;
            sboCompany.Server       = dbServer;
            sboCompany.DbUserName   = dbUsername;
            sboCompany.DbPassword   = dbPassword;
            sboCompany.CompanyDB    = database;
            sboCompany.UserName     = sapUsername;
            sboCompany.Password     = sapPassword;
            sboCompany.UseTrusted   = false;
            sboCompany.language     = BoSuppLangs.ln_Portuguese_Br;
        }
Exemplo n.º 4
0
        public static void ConnectViaDI(String dbServer,
                                        BoDataServerTypes dbServerType,
                                        String companyDb, String user,
                                        String password,
                                        String licenseServer,
                                        BoSuppLangs language = BoSuppLangs.ln_English)
        {
            try
            {
                // 1. Initiate the company instance for the first time
                if (oCompany == null)
                {
                    oCompany = new SAPbobsCOM.Company();
                }
                // 2. Set Company Property for login
                oCompany.Server        = dbServer;
                oCompany.DbServerType  = dbServerType;
                oCompany.CompanyDB     = companyDb;
                oCompany.UserName      = user;
                oCompany.Password      = password;
                oCompany.LicenseServer = licenseServer;
                oCompany.language      = language;
                oCompany.UseTrusted    = false;

                IRetCode = oCompany.Connect();

                // 4. Error Handling
                if (IRetCode != 0)
                {
                    MsgBoxWrapper(oCompany.GetLastErrorDescription());
                }

                // 5. (Optional) XML Export Configuration
                oCompany.XmlExportType = BoXmlExportTypes.xet_ExportImportMode;
            }
            catch (Exception ex)
            {
                MsgBoxWrapper(ex.Message + " " + ex.StackTrace);
            }
        }
Exemplo n.º 5
0
        public static void ConnectViaDI()
        {
            String serverName, databaseName, sapUserName, sapPassword, licenseServer;

            //if (Resources.AppStage.ToString().ToLower() == "deployment")
            //{
            //    // lcm assignment - Parameters | lcm_deployment - shared parameters
            //    serverName = oApplication.Company.GetExtensionProperty(connectionString, SAPbouiCOM.BoExtensionLCMStageType.lcm_assignment, "servername");
            //    databaseName = oApplication.Company.GetExtensionProperty(connectionString, SAPbouiCOM.BoExtensionLCMStageType.lcm_assignment, "databasename");
            //    sapUserName = oApplication.Company.GetExtensionProperty(connectionString, SAPbouiCOM.BoExtensionLCMStageType.lcm_assignment, "username");
            //    sapPassword = oApplication.Company.GetExtensionProperty(connectionString, SAPbouiCOM.BoExtensionLCMStageType.lcm_assignment, "password");
            //    licenseServer = oApplication.Company.GetExtensionProperty(connectionString, SAPbouiCOM.BoExtensionLCMStageType.lcm_assignment, "licenseserver");
            //}
            //else
            //{
            //    serverName = AccessMatrix.Properties.Settings.Default.ServerName.ToString();
            //    databaseName = AccessMatrix.Properties.Settings.Default.DatabaseName.ToString();
            //    sapUserName = AccessMatrix.Properties.Settings.Default.SAPUserName.ToString();
            //    sapPassword = AccessMatrix.Properties.Settings.Default.SAPPassword.ToString();
            //    licenseServer = AccessMatrix.Properties.Settings.Default.LicenseServer.ToString();
            //}
            serverName    = ConfigurationManager.AppSettings["ServerName"];
            databaseName  = ConfigurationManager.AppSettings["DatabaseName"];
            sapUserName   = ConfigurationManager.AppSettings["SAPUserName"];
            sapPassword   = ConfigurationManager.AppSettings["SAPPassword"];
            licenseServer = ConfigurationManager.AppSettings["LicenseServer"];

            BoDataServerTypes dbType = BoDataServerTypes.dst_HANADB;

            if (ConfigurationManager.AppSettings["DbType"] == "SQL")
            {
                dbType = ConfigurationManager.AppSettings["DbType"] == "2012" ? BoDataServerTypes.dst_MSSQL2012 : BoDataServerTypes.dst_MSSQL2014;
            }
            else
            {
                dbType = BoDataServerTypes.dst_HANADB;
            }
            ConnectViaDI(serverName, dbType, databaseName, sapUserName, sapPassword, licenseServer, BoSuppLangs.ln_English);
        }