Ejemplo n.º 1
0
 /// <summary>
 /// Converts the STRING database type to SAPbobsCOM.BoDataServerTypes
 /// </summary>
 /// <returns></returns>
 public SAPbobsCOM.BoDataServerTypes boDataServerType()
 {
     SAPbobsCOM.BoDataServerTypes st = SAPbobsCOM.BoDataServerTypes.dst_HANADB;
     if (this.DbServerType.Equals("MSSQL2017"))
     {
         st = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2017;
     }
     else if (this.DbServerType.Equals("MSSQL2016"))
     {
         st = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2016;
     }
     else if (this.DbServerType.Equals("MSSQL2014"))
     {
         st = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2014;
     }
     else if (this.DbServerType.Equals("MSSQL2012"))
     {
         st = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2012;
     }
     else if (this.DbServerType.Equals("MSSQL2008"))
     {
         st = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2008;
     }
     else if (this.DbServerType.Equals("MSSQL2005"))
     {
         st = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2005;
     }
     return(st);
 }
Ejemplo n.º 2
0
        public static string consultaTablaConfiguracion(SAPbobsCOM.BoDataServerTypes bo_ServerTypes, string NAddon, string Version, bool Ordenamiento)
        {
            m_sSQL.Length = 0;

            switch (bo_ServerTypes)
            {
            case SAPbobsCOM.BoDataServerTypes.dst_HANADB:
                m_sSQL.AppendFormat("SELECT * FROM \"@{0}\"", NAddon.ToUpper());
                if (NAddon != "" || Version != "")
                {
                    m_sSQL.Append(" WHERE ");
                    if (NAddon != "")
                    {
                        m_sSQL.AppendFormat("\"Name\" Like '{0}%'", NAddon);
                        if (Version != "")
                        {
                            m_sSQL.AppendFormat(" AND \"Code\" = '{0}'", Version);
                        }
                    }
                    else if (Version != "")
                    {
                        m_sSQL.AppendFormat("\"Code\" = '{0}'", Version);
                    }
                }
                if (Ordenamiento)
                {
                    m_sSQL.Append(" ORDER BY LENGTH(\"Code\") DESC, \"Code\" DESC");
                }

                break;

            default:
                m_sSQL.AppendFormat("SELECT * FROM [@{0}]", NAddon.ToUpper());
                if (NAddon != "" || Version != "")
                {
                    m_sSQL.Append(" WHERE ");
                    if (NAddon != "")
                    {
                        m_sSQL.AppendFormat("Name Like '{0}%'", NAddon);
                        if (Version != "")
                        {
                            m_sSQL.AppendFormat(" AND Code = '{0}'", Version);
                        }
                    }
                    else if (Version != "")
                    {
                        m_sSQL.AppendFormat("Code = '{0}'", Version);
                    }
                }
                if (Ordenamiento)
                {
                    m_sSQL.Append(" ORDER BY LEN(Code) DESC, Code DESC");
                }
                break;
            }

            return(m_sSQL.ToString());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Connect only DI Api
        /// </summary>
        /// <param name="serverName">SQL Server Name</param>
        /// <param name="serverType">Server type</param>
        /// <param name="companyDb"></param>
        /// <param name="dbUsername"></param>
        /// <param name="dbPassword"></param>
        /// <param name="username">SBO Username</param>
        /// <param name="password">SBO Password</param>
        /// <param name="licenceServer">Licence Server</param>
        public static void DiConnect(string serverName, SAPbobsCOM.BoDataServerTypes serverType, string companyDb,
                                     string dbUsername = null, string dbPassword = null, string username = null, string password = null, string licenceServer = null)
        {
            _diCompany = new SAPbobsCOM.Company
            {
                Server       = serverName,
                DbServerType = serverType,
                CompanyDB    = companyDb
            };

            if (licenceServer != null)
            {
                _diCompany.LicenseServer = licenceServer;
            }

            if (username == null)
            {
                _diCompany.UseTrusted = true;
            }
            else
            {
                _diCompany.UseTrusted = false;
                _diCompany.UserName   = username;
                _diCompany.Password   = password;
                _diCompany.DbUserName = dbUsername;
                _diCompany.DbPassword = dbPassword;
            }

            var connectResponse = _diCompany.Connect();

            if (connectResponse != 0)
            {
                int    errCode;
                string errMsg;
                _diCompany.GetLastError(out errCode, out errMsg);

                Logger.Debug($"Servername={serverName}, CompanyDb={companyDb}, ServerType={serverType}, " +
                             $"DbUsername={dbUsername}, DbPassword={dbPassword}, " +
                             $"SboUsername={username}, SboPassword={password}, " +
                             $"LicenceServer={licenceServer}");

                throw new Exception($"DI Connect Error: {errCode} {errMsg}");
            }
        }
Ejemplo n.º 4
0
    public static void ConnectViaDI(string server, string licSrv, SAPbobsCOM.BoDataServerTypes dbType, string companyDB, string dbUser, string dbPassword, string userName, string password, SAPbobsCOM.BoSuppLangs language, string addonID = "")
    {
        try
        {
            oCompany               = new SAPbobsCOM.Company();
            oCompany.Server        = server;
            oCompany.LicenseServer = licSrv;
            oCompany.DbServerType  = dbType;
            oCompany.DbUserName    = dbUser;
            oCompany.DbPassword    = dbPassword;
            oCompany.CompanyDB     = companyDB;
            oCompany.UserName      = userName;
            oCompany.Password      = password;
            oCompany.language      = SAPbobsCOM.BoSuppLangs.ln_English;

            if (string.IsNullOrEmpty(addonID) == false)
            {
                oCompany.AddonIdentifier = addonID;
            }

            oCompany.XmlExportType = SAPbobsCOM.BoXmlExportTypes.xet_ExportImportMode;

            lRetCode = oCompany.Connect();

            DIErrHandler("Connectiong Company");

            CompDB = oCompany.CompanyDB;
        }

        // If lRetCode <> 0 Then
        // oCompany.GetLastError()
        // End If

        catch (Exception ex)
        {
            throw ex;
        }
    }
Ejemplo n.º 5
0
        public SAPbobsCOM.Company Connect(string pServer, string pDBName, string pDBUser, string pDBPassword, SAPbobsCOM.BoDataServerTypes pServerType,
                                          string pSAPUser, string pSAPPassword, ref int iErr)
        {
            if (pDBName == "")
            {
                iErr = 1;
            }

            if (iErr != 0)
            {
                return(null);
            }

            //oConnTrg = SQLDirect.oConnectToSql(txbDBServerTrg.Text, cmbSAPDBTrg.Text.Substring(0, cmbSAPDBTrg.Text.IndexOf(" - ")), txbDBUserTrg.Text, txbDBPassTrg.Text, true, bErr);
            oComp.Server = pServer;
            if (pServer == "")
            {
                oComp.Server = scServer;
            }

            oComp.DbUserName = pDBUser;
            if (pDBUser == "")
            {
                oComp.DbUserName = scSQLName;
            }

            oComp.DbPassword = pDBPassword;
            if (pDBPassword == "")
            {
                oComp.DbPassword = scSQLPass;
            }

            oComp.DbServerType = pServerType;
            //if (pServerType == null) oComp.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2008;

            oComp.CompanyDB = pDBName;

            oComp.UserName = pSAPUser;
            if (pSAPUser == "")
            {
                oComp.UserName = scSAPName;
            }

            oComp.Password = pSAPPassword;
            if (pSAPPassword == "")
            {
                oComp.Password = scSAPPass;
            }

            iErr = oComp.Connect();
            if (iErr == 0)
            {
                return(oComp);
            }
            else
            {
                DImsg.MessageERR(iErr, oComp.GetLastErrorDescription());
                return(null);
            }
        }