Ejemplo n.º 1
0
        /// <summary> Initializes the provider, and allocates PlayerInfo objects for all players. </summary>
        public IEnumerable <PlayerInfo> Load()
        {
            connection = new MySqlConnection();

            if (PlayerDB.MySqlProviderSettings != null)
            {
                try {
                    config = new MySqlPlayerDBProviderConfig(PlayerDB.MySqlProviderSettings);
                } catch (Exception ex) {
                    throw new MisconfigurationException("MySqlPlayerDBProvider: Error parsing configuration: " + ex.Message, ex);
                }
            }
            else
            {
                throw new MisconfigurationException("MySqlPlayerDBProvider: Configuration missing from config file.");
            }

            connection.Host     = config.Host;
            connection.Port     = config.Port;
            connection.Database = config.Database;
            connection.UserId   = config.UserID;
            connection.Password = config.Password;
            connection.Open();

            CheckSchema();

            PrepareCommands();

            using (MySqlCommand cmd = new MySqlCommand(LoadAllQuery, connection)) {
                using (MySqlDataReader reader = cmd.ExecuteReader()) {
                    while (reader.Read())
                    {
                        yield return(LoadInfo(reader));
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary> Initializes the provider, and allocates PlayerInfo objects for all players. </summary>
        public IEnumerable<PlayerInfo> Load() {
            connection = new MySqlConnection();

            if(PlayerDB.MySqlProviderSettings!=null){
                try {
                    config = new MySqlPlayerDBProviderConfig( PlayerDB.MySqlProviderSettings );
                } catch( Exception ex ) {
                    throw new MisconfigurationException( "MySqlPlayerDBProvider: Error parsing configuration: " + ex.Message, ex );
                }
            } else {
                throw new MisconfigurationException( "MySqlPlayerDBProvider: Configuration missing from config file." );
            }

            connection.Host = config.Host;
            connection.Port = config.Port;
            connection.Database = config.Database;
            connection.UserId = config.UserID;
            connection.Password = config.Password;
            connection.Open();

            CheckSchema();

            PrepareCommands();

            using( MySqlCommand cmd = new MySqlCommand( LoadAllQuery, connection ) ) {
                using( MySqlDataReader reader = cmd.ExecuteReader() ) {
                    while( reader.Read() ) {
                        yield return LoadInfo( reader );
                    }
                }
            }
        }
Ejemplo n.º 3
0
 private void bPlayerDBProviderConfig_Click( object sender, EventArgs e ) {
     if( PlayerDB.ProviderType == PlayerDBProviderType.MySql ) {
         MySqlPlayerDBProviderConfig config;
         if( PlayerDB.MySqlProviderSettings != null ) {
             try {
                 config = new MySqlPlayerDBProviderConfig( PlayerDB.MySqlProviderSettings );
             } catch( Exception ex ) {
                 MessageBox.Show( ex.ToString(), "Error parsing MySql PlayerDB provider settings." );
                 config = new MySqlPlayerDBProviderConfig();
             }
         } else {
             config = new MySqlPlayerDBProviderConfig();
         }
         PropertyGridPopup popup = new PropertyGridPopup( "MySql PlayerDB provider settings", config );
         if( popup.ShowDialog() == DialogResult.OK ) {
             PlayerDB.MySqlProviderSettings = config.Serialize();
         }
     }
 }