//The event handler for the change notification public static void OnNotificationReceived(object src, OracleNotificationEventArgs arg) { DataTable changeDetails = arg.Details; _NotificationRaised = true; MessageBox.Show("Table has changed: " + changeDetails.Rows[0]["ResourceName"]); }
public void OnNotificationReceived(object src, OracleNotificationEventArgs arg) { DataTable changeDetails = arg.Details; _NotificationRaised = true; DisplayDataInGrid(changeDetails); }
private void Dependency_OnChange(object sender, OracleNotificationEventArgs eventArgs) { //DataTable dt = eventArgs.Details; //Debug.WriteLine("The following database objects were changed:"); //foreach (string resource in eventArgs.ResourceNames) //{ // Debug.WriteLine(resource); //} //Debug.WriteLine("\n Details:"); //Debug.Write(new string('*', 80)); //for (int rows = 0; rows < dt.Rows.Count; rows++) //{ // Debug.WriteLine("Resource name: " + dt.Rows[rows].ItemArray[0]); // string type = Enum.GetName(typeof(OracleNotificationInfo), dt.Rows[rows].ItemArray[1]); // Debug.WriteLine("Change type: " + type); // Debug.Write(new string('*', 80)); //} if (this.OnChanged != null && this.EnableRaisingEvents) { this.OnChanged(this, eventArgs.Details); } }
private void OnChangeNotifyError(object sender, OracleNotificationEventArgs eventArgs) { try { string rowid = ""; foreach (System.Data.DataRow item in eventArgs.Details.Rows) { rowid = item.ItemArray[2].ToString(); break; } string sql = "SELECT A.ID FROM TABLE_NAME A WHERE A.ROWID LIKE '%" + rowid + "%'"; returnId = db.ExecuteScalar(sql).ToString(); if (!String.IsNullOrEmpty(returnId)) { byte[] response = Encoding.ASCII.GetBytes(" TABLE_NAME_HATA:" + returnId); response[0] = 0x81; // denotes this is the final message and it is in text response[1] = (byte)(response.Length - 2); // payload size = message - header size notifyObservers(response); } } catch (Exception e) { } }
private void dependency_OnChangeOracle(object sender, OracleNotificationEventArgs ea) { if (_client.bConnectionOK == true) { try { if (!mre_dependency_backup.IsSet) { return; } mre_dependency_backup.Reset(); DateTime dtStartProcessDB = DateTime.Now; ProcessDB(); DateTime dtEndProcessDB = DateTime.Now; TimeSpan tsProcessDB = dtStartProcessDB - dtEndProcessDB; if (tsProcessDB.TotalMilliseconds > 500) { ServiceBaseX._logger.Log(Category.Warning, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ": time to process DB over 500ms. Time in ms {0}.", tsProcessDB); } } catch (Exception ex) { ServiceBaseX._logger.Log(Category.Error, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ": " + ex.Message); } finally { mre_dependency.Set(); } } }
/// <summary> /// 监听数据改变事件 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> static void Data_OnChange(object sender, OracleNotificationEventArgs eventArgs) { lock (lockObject) { DictListen[(sender as OracleDependency).Id] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } }
private void OracleListenerCallback(object sender, OracleNotificationEventArgs events) { logger.Info(AppConst.A("OracleListenerCallback Event", events.Info.ToString())); if (events.Info == OracleNotificationInfo.Insert || events.Info == OracleNotificationInfo.Update) { PushSMSToQueue(); } }
public void OnTableChange(Object sender, OracleNotificationEventArgs args) { //Get data Changed before......................... if (args.Type == OracleNotificationType.Change) { int start = 0; if (args.Info.ToString() == "Update") { start = 1; } for (int i = start; i < args.Details.Rows.Count; i++) { DataRow detailRow = args.Details.Rows[i]; string rowid = detailRow["Rowid"].ToString(); DataSet ds = new DataSet(); using (System.Data.OracleClient.OracleDataAdapter da = new System.Data.OracleClient.OracleDataAdapter(NotificationNameAdapter, constr)) { try { da.SelectCommand.CommandType = CommandType.StoredProcedure; da.SelectCommand.Parameters.Add("MY_ID", System.Data.OracleClient.OracleType.VarChar).Value = rowid; da.SelectCommand.Parameters.Add("Info", System.Data.OracleClient.OracleType.VarChar).Value = args.Info.ToString(); System.Data.OracleClient.OracleParameter ret = new System.Data.OracleClient.OracleParameter("my_cursor", System.Data.OracleClient.OracleType.Cursor); ret.Direction = ParameterDirection.ReturnValue; da.SelectCommand.Parameters.Add(ret); da.Fill(ds); } catch (Exception ex) { } } string data = JsonConvert.SerializeObject(ds); try { Message messageObject = new Message(); for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { messageObject.message = ds.Tables[0].Rows[j]["MESSAGE"].ToString(); messageObject.url = ds.Tables[0].Rows[j]["URL"].ToString();; messageObject.type = ds.Tables[0].Rows[j]["TYPE"].ToString(); var jsonMessage = JsonConvert.SerializeObject(messageObject); //after get two paramters of notification fire it... string successMessage = sendNotification(ds.Tables[0].Rows[j]["NID"].ToString(), jsonMessage); } } catch (Exception e) { } } } }
private void DisablesNotificatonListener(object sender, OracleNotificationEventArgs args) { string query = null; for (int index = 0; index < args.Details.Rows.Count; ++index) { query = this.DisabledNotificationQuery + " where rowid = '" + args.Details.Rows[index]["Rowid"].ToString() + "'"; this.disableMachineTriggered((object)this.GetDisabledDataUsingNotificationQuery(query), new EventArgs()); } }
/// <summary> /// Called when dataset result is changed /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void OnOracleDependencyChanged(object sender, OracleNotificationEventArgs eventArgs) { // Either there is no rowid retrieved, or there are rowids in list and one of it matches with // the rowid of row changed if ((this._rowids.Count == 0 || Contains(eventArgs.Details.Rows)) && eventArgs.Info != OracleNotificationInfo.Startup && eventArgs.Info != OracleNotificationInfo.Shutdown) { base.OnDependencyChanged( (eventArgs.Type == OracleNotificationType.Change || eventArgs.Type == OracleNotificationType.Query), // data set changed false, eventArgs.Info == OracleNotificationInfo.Error, false); // some error occurred on server Oracle does not have invalid in Notification info } }
void SlotUpdateNotificatonListener(object sender, OracleNotificationEventArgs args) { DataRow detailRow = args.Details.Rows[0]; string rowid = detailRow["Rowid"].ToString(); string sqlUpdateQry = FloorNotificationQuery + " where rowid = \'" + rowid + "\'"; for (int i = 1; i < args.Details.Rows.Count; i++) { detailRow = args.Details.Rows[i]; rowid = detailRow["Rowid"].ToString(); sqlUpdateQry = sqlUpdateQry + " or rowid = \'" + rowid + "\'"; } SlotData objSlotData = GetSlotDataUsingNotificationQuery(sqlUpdateQry); triggerSlotUpdate(objSlotData, new EventArgs()); }
void OnNotification(object sender, OracleNotificationEventArgs args) { if (args.Type != OracleNotificationType.Change || args.Info != OracleNotificationInfo.Insert) { return; } var rowIds = new List <string>(); foreach (DataRow row in args.Details.Rows) { rowIds.Add((string)row["rowId"]); } using (var conn = this.CreateConnection()) { using (var cmd = conn.CreateCommand()) { cmd.CommandText = "SELECT MESSAGE, FROM_USER, DATE_CREATED, RECEIVED FROM CHATS WHERE ROWID IN ("; for (var i = 0; i < rowIds.Count; i++) { if (i > 0) { cmd.CommandText += ","; } cmd.CommandText += $"'{rowIds[i]}'"; } cmd.CommandText += ")"; using (var reader = cmd.ExecuteReader(CommandBehavior.CloseConnection)) { while (reader.Read()) { this.OnDbNotification(new OraMessage { Message = reader.GetString(0), From = reader.GetString(1), DateCreated = reader.GetDateTime(2), Received = reader.GetInt32(3) == 1 }); } } } } }
private void dependency_OnChange(object sender, OracleNotificationEventArgs eventArgs) { try { // ConsoleTable.From() Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Table has been Changed"); Console.WriteLine(eventArgs.Source.ToString()); Console.WriteLine(eventArgs.Info.ToString()); Console.WriteLine(eventArgs.Source.ToString()); Console.WriteLine(eventArgs.Type.ToString()); DataTable dt = eventArgs.Details; // PrintDataTable(dt); Console.ForegroundColor = ConsoleColor.White; } catch (Exception exception) { Console.WriteLine(exception.Message); } }
public void OnChange(object sender, OracleNotificationEventArgs eventArgs) { Log("Database changed", "#000000"); Dispatcher.Invoke(() => { try { listBox_files.ItemsSource = db.loadFiles(); string filename = listBox_files.SelectedItem as string; if (filename != null) { string content = db.LoadContent(filename); Display(filename, content); } } catch (Exception ex) { Log(ex.Message + ex.StackTrace, "#000000"); } }); }
static void AlertUser(Object sender, OracleNotificationEventArgs args) { DataTable dt = args.Details; string msg = ""; msg = "The following database objects were changed: "; foreach (string resource in args.ResourceNames) { msg += resource; } msg += "\n\n Details: "; for (int rows = 1; rows < dt.Rows.Count; rows++) { msg += "Resource name: " + dt.Rows[rows].ItemArray[0]; string type = Enum.GetName(typeof(OracleNotificationInfo), dt.Rows[rows].ItemArray[1]); msg += "\n\nChange type: " + type; msg += " "; } Notify("Oracle", msg); }
public static void JSON_Notification(object src, OracleNotificationEventArgs args) { //Each time event handler launches, it retrieves the updated purchase order details //Note that the LastUpdated entry has been changed. Console.WriteLine(); Console.WriteLine("Change detected."); using (OracleConnection con = new OracleConnection(Constants.ConString)) { using (OracleCommand cmd = con.CreateCommand()) { try { con.Open(); cmd.CommandText = Constants.Query; OracleDataAdapter da = new OracleDataAdapter(cmd); using (DataSet ds = new DataSet()) { da.Fill(ds); foreach (DataTable table in ds.Tables) { foreach (DataRow row in table.Rows) { Console.WriteLine(row[Constants.JsonColumn].ToString()); } } } da.Dispose(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } }
void dependency_OnChange(object sender, OracleNotificationEventArgs eventArgs) { try { if (Observers.Count != 0) { if (Notifications != null) { foreach (System.Data.DataRow detailsRow in eventArgs.Details.Rows) { string rowId = detailsRow["rowid"].ToString(); if (string.IsNullOrEmpty(rowId)) { UpdateNotifications(); break; } else { string resourceName = detailsRow["resourcename"].ToString().ToLower(); OracleNotificationInfo oracleNotificationInfo = (OracleNotificationInfo)detailsRow["info"]; NotificationType notificationType = NotificationType.None; if ((oracleNotificationInfo & OracleNotificationInfo.Insert) == OracleNotificationInfo.Insert) { notificationType = NotificationType.Insert; } else if ((oracleNotificationInfo & OracleNotificationInfo.Update) == OracleNotificationInfo.Update) { notificationType = NotificationType.Update; } else if ((oracleNotificationInfo & OracleNotificationInfo.Delete) == OracleNotificationInfo.Delete) { notificationType = NotificationType.Delete; } else { notificationType = NotificationType.Table; } if (notificationType != NotificationType.None) { if (Query.NotificationLevel == NotificationLevel.Row || Query.NotificationMechanism == NotificationMechanism.Poll) { Key surrogateKey = new Key(rowId); Key key; if (notificationType == NotificationType.Delete) { key = _dataIndex[surrogateKey].Key; _dataIndex.Remove(surrogateKey); } else { UpdateDataIndex(surrogateKey, notificationType); key = _dataIndex[surrogateKey].Key; } Notifications.Add(new Notification(notificationType, Query.Name, Query.KeyFieldNames, key.Values)); } else { Notifications.Add(new Notification(notificationType, Query.Name, null, null)); } } } } RaiseNotifications(); } } } catch (Exception ex) { if (_log.IsErrorEnabled) { _log.ErrorFormat("Failed to process database notification for query '{0}' - {1}", Query.Name, ex.Message); } } }
void dep_OnChange(object sender, OracleNotificationEventArgs e) { w.Dispatcher.Invoke(new Action(w.Refresh)); }
public SignalRDbNotificationEventArgs(OracleNotificationEventArgs e) { _e = e; }
// в OnChange выставлять флаг что нужно обновлять SharedData - далее в одновном цикле анализировать флаг private void Dependency_OnChange(object sender, OracleNotificationEventArgs e) { StringBuilder Tables = new StringBuilder(); foreach (var Name in e.ResourceNames) { if (Name.ToUpper().Contains(NotifierCheckTable)) { NotifierCheckState = NotifierCheckStates.CheckSuccess; } else { Tables.AppendFormat("{0} ", Name); Interlocked.Increment(ref Notifications); } } if (Notifications > 0) { EventHandle.Set(); // wake up load thread Log.Message("Уведомление об изменениях: " + Tables); } }
public void OnDBNotificationHandler(object src, OracleNotificationEventArgs args) { List <StepInstance> changedData = new List <StepInstance>(); //collect all rowIds that changed List <string> rowIdList = new List <string>(); foreach (DataRow row in args.Details.Rows) { rowIdList.Add(string.Format("'{0}'", row["Rowid"].ToString())); } string query = string.Format("select Process_ID, INTERFACE_ID, RUN_INSTANCE_ID, START_TIME, END_TIME, STATUS, MESSAGE from INTERFACE_RUN_TIMES WHERE rowid IN ({0})", string.Join(",", rowIdList)); using (OracleConnection conn = new OracleConnection(_connString)) using (OracleCommand cmd = new OracleCommand(query, conn)) { conn.Open(); try { using (OracleDataReader dr = cmd.ExecuteReader()) { if (dr.HasRows) { var processIdCol = dr.GetOrdinal("Process_ID"); var interfaceIdCol = dr.GetOrdinal("INTERFACE_ID"); var runInstanceIdCol = dr.GetOrdinal("RUN_INSTANCE_ID"); var startTimeCol = dr.GetOrdinal("START_TIME"); var endTimeCol = dr.GetOrdinal("END_TIME"); var statusCol = dr.GetOrdinal("STATUS"); var messageCol = dr.GetOrdinal("MESSAGE"); while (dr.Read()) { var stepInstance = new StepInstance(); stepInstance.ParentRunInstanceId = dr.GetInt64(runInstanceIdCol); stepInstance.Id = dr.GetInt64(interfaceIdCol); if (dr.IsDBNull(startTimeCol) == false) { stepInstance.StartTime = dr.GetDateTime(startTimeCol); } if (dr.IsDBNull(endTimeCol) == false) { stepInstance.EndTime = dr.GetDateTime(endTimeCol); } stepInstance.Status = dr.IsDBNull(statusCol) ? string.Empty : dr.GetString(statusCol); stepInstance.Message = dr.IsDBNull(messageCol) ? string.Empty : dr.GetString(messageCol); changedData.Add(stepInstance); } } } } catch { } finally { conn.Close(); } } changeNotificationCallback.NotifyItemChanged(changedData.ToArray()); }
private void OnNotificaton(object sender, OracleNotificationEventArgs e) { try { Console.WriteLine("Info: {0} Type: {1} Source: {2}", e.Info, e.Type, e.Source); if (e.Type == OracleNotificationType.Change) { // Submit the SQL back to the server, } } catch (Exception ex) { throw ex; } }
void dep_OnChange(object sender, OracleNotificationEventArgs eventArgs) { RefreshGrid(); }
void OnTriggerNotification(object sender, OracleNotificationEventArgs eventArgs) { RefreshGrid(); }
//The event handler for the change notification. Here we initiate a refresh of the grid data public void OnNotificationReceived(object src, OracleNotificationEventArgs arg) { RefreshGrid(); }
void dep_OnChange(object sender, OracleNotificationEventArgs eventArgs) { MessageBox.Show("Database changed"); w.Dispatcher.Invoke(new Action(w.refresh)); }
void DependencyChange(object sender, OracleNotificationEventArgs eventArgs) { if (OnChanged != null) OnChanged(); }
void dep_OnChange(object sender, OracleNotificationEventArgs eventArgs) { this.Dispatcher.Invoke(new Action(() => GetCurrentParks())); }