Пример #1
0
        private static string GetConnectionString(string DataBaseKeyID)
        {
            string    cnnString  = "";
            DBManager _dbManager = DBManager.GetInstance();

            //evaluates if the key id exisit already in the connections string list
            if (!_dbManager._connectionsStringList.ContainsKey(DataBaseKeyID))
            {
                //get acces to configuration file handler
                ConfigurationFileHandler configFile = default(ConfigurationFileHandler);
                configFile = ConfigurationFileHandlerProxyServer.GetInstance().GetFileHandler();

                KeyValue configurationKey = default(KeyValue);
                configurationKey = (KeyValue)(configFile.GetValue("DATABASE_FRAMEWORK/CONNECTION_STRINGS/" + DataBaseKeyID));

                if (configurationKey == null)
                {
                    string message = "";
                    message = "Not connection string defined for DataBaseID : " + DataBaseKeyID + Constants.vbNewLine + "Or not configuration Exists in Route : DATABASE_FRAMEWORK/CONNECTION_STRINGS/";
                    throw (new Exception(message));
                }

                //adds the new connection string
                cnnString = configurationKey.Value;
                _dbManager._connectionsStringList.Add(DataBaseKeyID, configurationKey.Value);
            }
            else
            {
                cnnString = System.Convert.ToString(_dbManager._connectionsStringList[DataBaseKeyID]);
            }
            return(cnnString);
        }
Пример #2
0
        private static void GetUserNameAndPasswordFromConfigurationFile()
        {
            try
            {
                ConfigurationFileHandler configfileHndlr = default(ConfigurationFileHandler);
                configfileHndlr = ConfigurationFileHandlerProxyServer.GetInstance().GetFileHandler();
                KeyValue key = default(KeyValue);
                key = (KeyValue)(configfileHndlr.GetValue("UTILITIES_FRAMEWORK/SQLSERVER_DB_ATTACHER/USER"));
                if (!(key == null))
                {
                    UserId = key.Value;
                }
                else
                {
                    Console.Write("User Name : ");
                    UserId = Console.ReadLine();
                }

                key = (KeyValue)(configfileHndlr.GetValue("UTILITIES_FRAMEWORK/SQLSERVER_DB_ATTACHER/PASSWORD"));
                if (!(key == null))
                {
                    password = key.Value;
                }
                else
                {
                    Console.Write("Password : "******"User Name : ");
                UserId = Console.ReadLine();
                Console.Write("Password : ");
                password = Console.ReadLine();
            }
        }