コード例 #1
0
        private static void InitializeServerVariables(out SAPbobsCOM.BoDataServerTypes dbType, out String DatabaseName, out String Server, out String LicenseServer, out String User, out String Password
                                                      , out String sUseTrusted, out String dbUserName, out String dbPassword)
        {
            TWM_Licence.TWM_SAP oEncrypter = new TWM_Licence.TWM_SAP(new Byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 10, 73, 1, 5, 75, 1, 8 });
            //Initialize all the environment variable for config file.
            //If nonspecified strings, write the default to config file.

            //Get the dbServerType
            if (frmSetting.GetConfigLine(sConfig_File, "dbServerType") != null)
            {
                dbType = (SAPbobsCOM.BoDataServerTypes) int.Parse(frmSetting.GetConfigLine(sConfig_File, "dbServerType"));
            }
            else
            {
                dbType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2008;
                frmSetting.WriteConfigFile(sConfig_File, "dbServerType", ((int)dbType).ToString(), frmSetting.WriteType.Append);
            }


            //Get the DatabaseName
            if (frmSetting.GetConfigLine(sConfig_File, "DatabaseName") != null)
            {
                DatabaseName = frmSetting.GetConfigLine(sConfig_File, "DatabaseName");
            }
            else
            {
                DatabaseName = "UNZA";
                frmSetting.WriteConfigFile(sConfig_File, "DatabaseName", DatabaseName, frmSetting.WriteType.Append);
            }


            //Get the Server
            if (frmSetting.GetConfigLine(sConfig_File, "ServerName") != null)
            {
                Server = frmSetting.GetConfigLine(sConfig_File, "ServerName");
            }
            else
            {
                Server = "sapserver";
                frmSetting.WriteConfigFile(sConfig_File, "ServerName", Server, frmSetting.WriteType.Append);
            }


            //Get the License Server
            if (frmSetting.GetConfigLine(sConfig_File, "LicenseServer") != null)
            {
                LicenseServer = frmSetting.GetConfigLine(sConfig_File, "LicenseServer");
            }
            else
            {
                LicenseServer = "sapserver:30000";
                frmSetting.WriteConfigFile(sConfig_File, "LicenseServer", LicenseServer, frmSetting.WriteType.Append);
            }


            //Get the User
            if (frmSetting.GetConfigLine(sConfig_File, "User") != null)
            {
                User = frmSetting.GetConfigLine(sConfig_File, "User");
            }
            else
            {
                User = "******";
                frmSetting.WriteConfigFile(sConfig_File, "User", User, frmSetting.WriteType.Append);
            }

            //Get the Password
            if (frmSetting.GetConfigLine(sConfig_File, "Password") != null)
            {
                Password = frmSetting.GetConfigLine(sConfig_File, "Password");
                Password = oEncrypter.Decrypt(Password);
            }
            else
            {
                Password = "******";
                String EncryptedPass = oEncrypter.Encrypt(Password);
                frmSetting.WriteConfigFile(sConfig_File, "Password", EncryptedPass, frmSetting.WriteType.Append);
            }


            //Get the UseTrusted
            if (frmSetting.GetConfigLine(sConfig_File, "UseTrusted") != null)
            {
                sUseTrusted = frmSetting.GetConfigLine(sConfig_File, "UseTrusted");
            }
            else
            {
                sUseTrusted = "0";
                frmSetting.WriteConfigFile(sConfig_File, "UseTrusted", sUseTrusted, frmSetting.WriteType.Append);
            }


            //if Not UseTrusted, Get The DBUserName And DBPassword
            if (sUseTrusted != "1")
            {
                //Get the User
                if (frmSetting.GetConfigLine(sConfig_File, "DBUserName") != null)
                {
                    dbUserName = frmSetting.GetConfigLine(sConfig_File, "DBUserName");
                }
                else
                {
                    dbUserName = "******";
                    frmSetting.WriteConfigFile(sConfig_File, "DBUserName", dbUserName, frmSetting.WriteType.Append);
                }


                //Get the Password
                if (frmSetting.GetConfigLine(sConfig_File, "DBPassword") != null)
                {
                    dbPassword = frmSetting.GetConfigLine(sConfig_File, "DBPassword");
                    dbPassword = oEncrypter.Decrypt(dbPassword);
                }
                else
                {
                    dbPassword = "******";
                    String EncryptedPass = oEncrypter.Encrypt(dbPassword);
                    frmSetting.WriteConfigFile(sConfig_File, "DBPassword", EncryptedPass, frmSetting.WriteType.Append);
                }
            }
            else
            {
                dbUserName = "";
                dbPassword = "";
            }
        }