private void dependency_OnChange(object sender, SqlNotificationEventArgs e) { if (e.Type == SqlNotificationType.Change && e.Info == SqlNotificationInfo.Insert) { List<DiscussMessageModel> lsDiscussMessage = GetDiscussMessages(); LotteryResultHub hub = new LotteryResultHub(); foreach (DiscussMessageModel model in lsDiscussMessage) { if (model.Status.Equals("A")){ hub.SendDiscussMessage(model.Username, model.FilePath, model.Message); } } } RegisterDiscussMessages(); }
private void dependency_OnChange(object sender, SqlNotificationEventArgs e) { SqlDependency dependency = sender as SqlDependency; dependency.OnChange -= new OnChangeEventHandler(dependency_OnChange); if (e.Type == SqlNotificationType.Change && e.Info == SqlNotificationInfo.Insert) { List<DiscussMessageModel> lsDiscussMessage = GetDiscussMessages(); LotteryResultHub hub = new LotteryResultHub(); foreach (DiscussMessageModel model in lsDiscussMessage) { if (model.Status.Equals("A")){ hub.SendDiscussMessage(model.Username, model.FilePath, model.Message, model.CreatedDate); UpdateDiscussMessagesSent(model.Id); } } } RegisterDiscussMessages(); }