コード例 #1
0
ファイル: Connection.cs プロジェクト: AviiNL/fiveliferp
 private void Connection_StateChange(object sender, System.Data.StateChangeEventArgs e)
 {
     if (e.CurrentState == System.Data.ConnectionState.Open)
     {
         TriggerEvent("fivelife.database.connected");
     }
 }
コード例 #2
0
ファイル: SQLHandler.cs プロジェクト: BlockBuilder57/Bot57Ag
 private void StateChange(object sender, System.Data.StateChangeEventArgs e)
 {
     if (!(e.CurrentState == System.Data.ConnectionState.Closed || e.CurrentState == System.Data.ConnectionState.Broken))
     {
         HasConnected = true;
     }
 }
コード例 #3
0
 private void MySqlConnection_StateChange(object sender, System.Data.StateChangeEventArgs e)
 {
     if (mySqlConnection.State == System.Data.ConnectionState.Broken || mySqlConnection.State == System.Data.ConnectionState.Closed)
     {
         Open();
     }
 }
コード例 #4
0
ファイル: ConnectionContainers.cs プロジェクト: xxdoc/SKS
 /// <summary>
 /// Event that notifies the current state of a change.
 /// </summary>
 /// <param name="sender">The object where the event was raised.</param>
 /// <param name="e">Additional event information.</param>
 void result_StateChange(object sender, System.Data.StateChangeEventArgs e)
 {
     if (e.CurrentState == System.Data.ConnectionState.Closed)
     {
         connections.Remove((DbConnection)sender);
     }
 }
コード例 #5
0
        //
        private void conn_StateChange(object sender, System.Data.StateChangeEventArgs e)
        {
            var context = GlobalHost.ConnectionManager.GetHubContext <TicketsHub>();

            // Broadcast if connection state changed ( client function showMessage (see init.js)
            context.Clients.All.showMessage("Current State: " + e.CurrentState.ToString() + " Original State: " + e.OriginalState.ToString(), "connection state changed");
        }
コード例 #6
0
 private void Con_StateChange(object sender, System.Data.StateChangeEventArgs e)
 {
     if (e.CurrentState == System.Data.ConnectionState.Open)
     {
         (sender as SQLiteConnection).EnableExtensions(true);
         (sender as SQLiteConnection).LoadExtension("idpsqlextensions");
     }
 }
コード例 #7
0
        private void _connection_StateChange(object sender, System.Data.StateChangeEventArgs e)
        {
            Logger.Info($"{_connection.Database}: {e.OriginalState} -> {e.CurrentState}.");

            //if (e.OriginalState == System.Data.ConnectionState.Open &&
            //    e.CurrentState != System.Data.ConnectionState.Broken)
            //    this.Reconnect();
        }
コード例 #8
0
        private void connection_StateChange(object sender, System.Data.StateChangeEventArgs e)
        {
            statusBar.Panels[0].Text = connection.State.ToString();

            bool closed = (connection.State == System.Data.ConnectionState.Closed);

            this.btConnect.Enabled    = closed;
            this.btDisconnect.Enabled = !closed;
        }
コード例 #9
0
 static void conn_StateChange(object sender, System.Data.StateChangeEventArgs e)
 {
     // Takes place when the connection state changes
     if (e.CurrentState == System.Data.ConnectionState.Closed)
     {
         //if (((SqlConnection)sender).StatisticsEnabled)
         //   LastStatistics = new ConnectionStatistics(((SqlConnection)sender).RetrieveStatistics());
     }
 }
コード例 #10
0
 void connection_StateChange(object sender, System.Data.StateChangeEventArgs e)
 {
     if (!isClosing && connection.State != System.Data.ConnectionState.Open && connection.State != System.Data.ConnectionState.Connecting)
     {
         string connectionString;
         connectionString = "SERVER=" + server + ";" + "DATABASE=" + database + ";" + "UID=" + uid + ";" + "PASSWORD="******";";
         connection       = new MySqlConnection(connectionString);
         OpenConnection();
     }
 }
コード例 #11
0
        public static void LogConnectionStateChange(object sender, System.Data.StateChangeEventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("Connection State Change Event: ");
            sb.Append(Environment.NewLine);
            sb.Append(" Original State: " + e.OriginalState);
            sb.Append(" Current State: " + e.CurrentState);

            LogMessage(sb.ToString());
        }
コード例 #12
0
        private void SqlConn_StateChange(object sender, System.Data.StateChangeEventArgs e)
        {
            var sqlConnInstance = sender as SqlConnection;

            if (sqlConnInstance != null)
            {
                Console.WriteLine(sqlConnInstance.State);
                Console.WriteLine(sqlConnInstance.DataSource);
                Console.WriteLine(sqlConnInstance.Database);
            }
        }
コード例 #13
0
ファイル: MySQL.cs プロジェクト: Dogma4b/Qlay
 private void Connection_StateChange(object sender, System.Data.StateChangeEventArgs ev)
 {
     if (ev.CurrentState == System.Data.ConnectionState.Open)
     {
         DynValue onConnect = db.Get("onConnect");
         if (onConnect != null)
         {
             onConnect.Function.Call(db);
         }
     }
 }
コード例 #14
0
 private void ActiveConnection_StateChange(object sender, System.Data.StateChangeEventArgs e)
 {
     if (ActiveConnection.State == System.Data.ConnectionState.Open)
     {
         this.IsConnectionActive = true;
     }
     else
     {
         this.IsConnectionActive = false;
     }
 }
コード例 #15
0
        static void StoreModel_Connection_StateChange(object sender, System.Data.StateChangeEventArgs e)
        {
            if (e.CurrentState == System.Data.ConnectionState.Broken)
            {
                _storeModel.Database.Connection.Close();
            }

            if (e.CurrentState == System.Data.ConnectionState.Closed)
            {
                _storeModel.Database.Connection.Open();
            }
        }
コード例 #16
0
ファイル: DataBase.cs プロジェクト: diamondo25/MWLR_Logging
        static void mConnection_StateChange(object sender, System.Data.StateChangeEventArgs e)
        {
            if (e.CurrentState == System.Data.ConnectionState.Open)
            {
                Logger.WriteLine("Connected to MySQL server! Changing timestamp to UTC");

                using (MySqlCommand cmd = new MySqlCommand("SET time_zone = '+00:00';", _connection))
                {
                    cmd.ExecuteNonQuery();
                }
            }
        }
コード例 #17
0
 void Connection_StateChange(object sender, System.Data.StateChangeEventArgs e)
 {
     if (e.CurrentState == System.Data.ConnectionState.Closed && !mShuttingDown)
     {
         Console.WriteLine("MySQL Connection closed. Reconnecting!");
         Connection.StateChange -= Connection_StateChange;
         Connect();
     }
     else if (e.CurrentState == System.Data.ConnectionState.Open)
     {
         Console.WriteLine("MySQL Connection opened!");
     }
 }
コード例 #18
0
        /// <summary>
        /// Remove SqlConnection Instance.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        static void ConnStateChange(object sender, System.Data.StateChangeEventArgs e)
        {
            SqlConnection obj = (SqlConnection)sender;

            if (e.CurrentState == System.Data.ConnectionState.Closed || e.CurrentState == System.Data.ConnectionState.Broken)
            {
                lock (_conns)
                {
                    _conns.Remove(obj);
                    Console.WriteLine("** Connection Closed ** " + ConnectionCount + " " + ++_closeCount);
                }
            }
        }
コード例 #19
0
 /// <summary>
 /// Event that notifies the current state of a change.
 /// </summary>
 /// <param name="sender">The object where the event was raised.</param>
 /// <param name="e">Additional event information.</param>
 void result_StateChange(object sender, System.Data.StateChangeEventArgs e)
 {
     if (e.CurrentState == System.Data.ConnectionState.Closed)
     {
         foreach (DAODatabaseHelper db in connections)
         {
             if (db.Connection == sender)
             {
                 connections.Remove(db);
                 break;
             }
         }
     }
 }
コード例 #20
0
 /// <summary>
 /// Event that notifies the current state of a change.
 /// </summary>
 /// <param name="sender">The object where the event was raised.</param>
 /// <param name="e">Additional event information.</param>
 void result_StateChange(object sender, System.Data.StateChangeEventArgs e)
 {
     if (e.CurrentState == System.Data.ConnectionState.Closed)
     {
         foreach (T connectionContainer in _connections)
         {
             if (connectionContainer.Connection == sender)
             {
                 _connections.Remove(connectionContainer);
                 break;
             }
         }
     }
 }
コード例 #21
0
        static void Connection_StateChange(object sender, System.Data.StateChangeEventArgs e)
        {
            SqlConnection connection = sender as SqlConnection;

            Console.WriteLine();

            Console.WriteLine                 //вывод информации о соединении и его состоянии
            (
                "Connection to" + Environment.NewLine +
                "Data Source: " + connection.DataSource + Environment.NewLine +
                "Database: " + connection.Database + Environment.NewLine +
                "State: " + connection.State
            );
        }
コード例 #22
0
        static void connection_StateChange(object sender, System.Data.StateChangeEventArgs e)
        {
            SqlConnection connection = sender as SqlConnection;

            Console.WriteLine();

            Console.WriteLine
            (
                "Connection to" + Environment.NewLine +
                "Data Source: " + connection.DataSource + Environment.NewLine +
                "Database: " + connection.Database + Environment.NewLine +
                "State: " + connection.State
            );
        }
コード例 #23
0
 void Connection_StateChange(object sender, System.Data.StateChangeEventArgs e)
 {
     if (e.CurrentState == System.Data.ConnectionState.Closed && !mShuttingDown)
     {
         Logger.WriteLog(Logger.LogTypes.Info, "MySQL Connection lost, reconnecting...");
         Connection.StateChange -= Connection_StateChange;
         Connect();
     }
     else if (e.CurrentState == System.Data.ConnectionState.Open)
     {
         //empty lines pzl
         Console.WriteLine();
     }
 }
コード例 #24
0
 void Connection_StateChange(object sender, System.Data.StateChangeEventArgs e)
 {
     // Set ANSI_NULLS OFF when any connection is opened. This is needed because of a bug in Entity Framework
     // that is not fixed in EF 5 when using DbContext.
     if (e.CurrentState == System.Data.ConnectionState.Open)
     {
         var connection = (System.Data.Common.DbConnection)sender;
         using (var cmd = connection.CreateCommand())
         {
             cmd.CommandText = "SET ANSI_NULLS OFF";
             cmd.ExecuteNonQuery();
         }
     }
 }
コード例 #25
0
        private static void MSSQL_Connection_StateChange(object sender, System.Data.StateChangeEventArgs e)
        {
            if (e.CurrentState == System.Data.ConnectionState.Closed)
            {
reconnect:
                if (!MSSQL_Connection.TryOpen())
                {
                    switch (MessageBox.Show("Не удалось переподключиться к БД!", "Ошибка!", MessageBoxButton.YesNo))
                    {
                    case MessageBoxResult.Yes:
                        goto reconnect;
                    }
                }
            }
        }
コード例 #26
0
        private static void Connection_StateChange(object sender, System.Data.StateChangeEventArgs e)
        {
            switch (e.CurrentState)
            {
            case System.Data.ConnectionState.Open:
                ConnectionState = ConnectionStateEnum.CONNECTED;
                break;

            case System.Data.ConnectionState.Closed:
                ConnectionState = ConnectionStateEnum.DISCONNECTED;
                break;

            case System.Data.ConnectionState.Broken:
                ConnectionState = ConnectionStateEnum.BROKEN;
                break;

            default:
                break;
            }
        }
コード例 #27
0
 private void Dbconnect_StateChange(object sender, System.Data.StateChangeEventArgs e)
 {
     if (e.CurrentState == System.Data.ConnectionState.Open)
     {
         panel5.BackColor = Color.LimeGreen;
         label1.ForeColor = Color.LimeGreen;
         label1.Text      = "Connected";
     }
     if (e.CurrentState == System.Data.ConnectionState.Connecting)
     {
         panel5.BackColor = Color.Yellow;
         label1.ForeColor = Color.Yellow;
         label1.Text      = "Connecting...";
     }
     if (e.CurrentState == System.Data.ConnectionState.Closed)
     {
         panel5.BackColor = Color.Red;
         label1.ForeColor = Color.Red;
         label1.Text      = "Not Connected";
     }
     if (e.CurrentState == System.Data.ConnectionState.Broken)
     {
         panel5.BackColor = Color.DarkRed;
         label1.ForeColor = Color.DarkRed;
         label1.Text      = "Error";
     }
     if (e.CurrentState == System.Data.ConnectionState.Executing)
     {
         panel5.BackColor = Color.Yellow;
         label1.ForeColor = Color.Yellow;
         label1.Text      = "Running Command";
     }
     if (e.CurrentState == System.Data.ConnectionState.Fetching)
     {
         panel5.BackColor = Color.Yellow;
         label1.ForeColor = Color.Yellow;
         label1.Text      = "Fetching...";
     }
 }
コード例 #28
0
 void connection_StateChange(object sender, System.Data.StateChangeEventArgs e)
 {
     if (e.CurrentState == System.Data.ConnectionState.Closed)
     {
         if (Stop)
         {
             return;
         }
         ////Console.WriteLine("MySQL connection closed. Reconnecting!");
         _logFile.WriteLine("Lost connection (connection Closed). Reconnecting.");
         _connection.StateChange -= connection_StateChange;
         Connect();
     }
     else if (e.CurrentState == System.Data.ConnectionState.Open)
     {
         _logFile.WriteLine("Connected to server!");
         ////Console.WriteLine("MySQL connection opened!");
     }
     else
     {
         _logFile.WriteLine("State change: " + e.CurrentState);
     }
 }
コード例 #29
0
        void MySqlConnection_StateChange(object sender, System.Data.StateChangeEventArgs e)
        {
            ConnectionState new_state = ConnectionState.Disconnected;

            if (mDatabaseDisabled)
            {
                new_state = ConnectionState.Disabled;
            }
            else
            {
                switch (e.CurrentState)
                {
                case System.Data.ConnectionState.Broken:
                case System.Data.ConnectionState.Closed:
                    new_state = ConnectionState.Disconnected;
                    break;

                case System.Data.ConnectionState.Connecting:
                    new_state = ConnectionState.Connecting;
                    break;

                default:
                    new_state = ConnectionState.Connected;
                    break;
                }
            }

            if (new_state != mConnectionState)
            {
                Utility.Log.LogFormat("Database connection state changed.  Old = {0}, new = {1}", mConnectionState, new_state);
                mConnectionState = new_state;
                if (OnConnectionStateChanged != null)
                {
                    OnConnectionStateChanged(new_state);
                }
            }
        }
コード例 #30
0
ファイル: Program.cs プロジェクト: TenYearsADream/course
 //连接的状态改变事件
 static void con_StateChange(object sender, System.Data.StateChangeEventArgs e)
 {
     Console.WriteLine(e.CurrentState.ToString());
 }