Exemplo n.º 1
0
        public MySqlClient(DatabaseManager dbManager)
        {
            _dbManager = dbManager;

            switch (DatabaseManager.DatabaseConnectionType.ToLower())
            {
                case "pgsql":
                    _pgSqlConnection = new NpgsqlConnection(dbManager.GetConnectionString());
                    break;
                case "ingress":
                case "ingres":
                    _inGressConnection = new IngresConnection(dbManager.GetConnectionString());
                    break;
                case "firebird":
                    _fireBirdConnection = new FbConnection(dbManager.GetConnectionString());
                    break;
                default: // mySql
                    _mySqlConnection = new MySqlConnection(dbManager.GetConnectionString());
                    break;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Saves this instance.
 /// </summary>
 internal static void Save()
 {
     if (!_enabled)
         return;
     lock (_loggedMessages.SyncRoot)
     {
         if (_loggedMessages.Count <= 0)
             return;
         var databaseManager = new DatabaseManager(1u, 1u);
         using (var queryReactor = databaseManager.GetQueryReactor())
             while (_loggedMessages.Count > 0)
             {
                 var message = (Message)_loggedMessages.Dequeue();
                 queryReactor.SetQuery(
                     "INSERT INTO system_packetlog (connectionid, timestamp, data) VALUES @connectionid @timestamp, @data");
                 queryReactor.AddParameter("connectionid", message.ConnectionId);
                 queryReactor.AddParameter("timestamp", message.GetTimestamp);
                 queryReactor.AddParameter("data", message.GetData);
                 queryReactor.RunQuery();
             }
     }
 }