예제 #1
0
        /// <summary>
        /// Initializers EF database connection from given parameters
        /// </summary>
        public static void InitDatabaseConnection(GHostDatabaseInfo databaseInfo)
        {
            // Initialize the connection string builder for the
            // underlying provider.
            var sqlBuilder =
                new MySqlConnectionStringBuilder
            {
                Server              = databaseInfo.DatabaseServer,
                Port                = databaseInfo.DatabasePort,
                UserID              = databaseInfo.DatabaseUserName,
                Password            = databaseInfo.DatabasePassword,
                PersistSecurityInfo = true,
                Database            = databaseInfo.DatabaseName
            };
            // Set the properties for the data source.
            // Build the SqlConnection connection string.
            string providerString = sqlBuilder.ToString();

            // Initialize the EntityConnectionStringBuilder.
            _entityBuilder = new EntityConnectionStringBuilder
            {
                ProviderConnectionString = providerString,
                Provider = "MySql.Data.MySqlClient",
                Metadata = @"res://*/ghostAsia.csdl|res://*/ghostAsia.ssdl|res://*/ghostAsia.msl",
            };
        }
예제 #2
0
        public static void LoadConfig(string configFilePath)
        {
            _configFilePath = configFilePath;
            if (File.Exists(configFilePath))
            {
                _fileContent = new List <string>(File.ReadAllLines(configFilePath));
            }

            uint parsedInt;

            if (uint.TryParse(GetConfigString("webserverport"), out parsedInt))
            {
                WebServerPort = parsedInt;
            }

            DatabaseServer = GetConfigString("databaseserver");
            if (uint.TryParse(GetConfigString("databaseport"), out parsedInt))
            {
                DatabasePort = parsedInt;
            }
            DatabaseUserName   = GetConfigString("databaseusername");
            DatabasePassword   = GetConfigString("databasepassword");
            DatabaseName       = GetConfigString("databasename");
            MapName            = GetConfigString("mapname");
            ReplayFileLocation = GetConfigString("replayfilelocation");

            // Read database information first
            int databaseIdx = 1;

            while (true)
            {
                string databaseLocation = GetConfigString("ghost_databaselocation" + databaseIdx);
                if (String.IsNullOrEmpty(databaseLocation))
                {
                    break;
                }

                GHostDatabaseInfo ghostDbInfo = new GHostDatabaseInfo
                {
                    DatabaseLocation = databaseLocation,
                    DatabaseServer   = GetConfigString("ghost_databaseserver" + databaseIdx),
                    DatabaseUserName = GetConfigString("ghost_databaseusername" + databaseIdx),
                    DatabasePassword = GetConfigString("ghost_databasepassword" + databaseIdx),
                    DatabaseName     = GetConfigString("ghost_databasename" + databaseIdx)
                };

                if (uint.TryParse(GetConfigString("ghost_databaseport" + databaseIdx), out parsedInt))
                {
                    ghostDbInfo.DatabasePort = parsedInt;
                }

                GhostDatabaseList.Add(ghostDbInfo);
                databaseIdx++;
            }

            // Read server information second
            int serverIdx = 1;

            while (true)
            {
                string serverName = GetConfigString("ghost_servername" + serverIdx);
                if (String.IsNullOrEmpty(serverName))
                {
                    break;
                }
                GhostServerInfo ghostServerInfo = new GhostServerInfo
                {
                    ServerName = serverName,
                    IP         = GetConfigString("ghost_serverIP" + serverIdx)
                };
                GHostServerList.Add(ghostServerInfo);
                serverIdx++;
            }
        }