private void dependency_OnChange(object sender, SqlNotificationEventArgs e)
 {
     if (NewMessage != null)
         NewMessage(sender, e);
     //subscribe again to notifier
     RegisterForNotifications();
 }
Esempio n. 2
0
        // NOTE: If you recieve Subscribe notification immediatly after execution, it's possibly because of "The statement is not valid for notificationThe statement is not valid for notification"
        // For more information read http://www.codeproject.com/Articles/12335/Using-SqlDependency-for-data-change-events
        private static void SqlDependencyOnChange(object sender, SqlNotificationEventArgs eventArgs)
        {
            Console.WriteLine($"Notification recieved. Source = {eventArgs.Source}, Type = {eventArgs.Type}, Info = {eventArgs.Info}");
            if (eventArgs.Type != SqlNotificationType.Change) return;

            _RegisterDependency();
        }
Esempio n. 3
0
 private void Dependency_OnChange(object sender, System.Data.SqlClient.SqlNotificationEventArgs e)
 {
     if (e.Info != SqlNotificationInfo.Invalid)
     {
         dgFill(QR);
     }
 }
 private void dependency_OnChange(object sender, SqlNotificationEventArgs e)
 {
     if (e.Type == SqlNotificationType.Change)
     {
         MessagesHub.SendMessages();
     }
 }
        private void dependency_OnChange(object sender, SqlNotificationEventArgs e)
        {
            if (e.Type == SqlNotificationType.Change && e.Info == SqlNotificationInfo.Insert)
            {
                MessagesChat[] messages = GetMessagesChat().ToArray();
                List<string> users = null;

                foreach (MessagesChat mess in messages)
                {
                    MessagesChat arr = GetMessagesChatFull(mess.Id);
                    if (mess.Type.Equals("G", StringComparison.OrdinalIgnoreCase))
                    {
                        users = GetListUserOfGroup(arr.GroupId);
                    }
                    else
                    {
                        users = GetListUser(arr.Id);
                    }
                    MobiChatHub.lsUsers = users;
                    MobiChatHub.SendMessages(new MessagesChat { Id = arr.Id, Content = arr.Content, SenderId = arr.SenderId, UserName = arr.UserName, SendDate = arr.SendDate, Type = arr.Type, GroupId = arr.GroupId });

                    WebChatHub.lsUsers = users;
                    WebChatHub.SendMessages(new MessagesChat { Id = arr.Id, Content = arr.Content, SenderId = arr.SenderId, UserName = arr.UserName, SendDate = arr.SendDate, Type = arr.Type, GroupId = arr.GroupId });

                    UpdateStatusMessage(mess.Id, DateTime.Now);

                }
            }

            RegisterMessages();
        }
		static void dependency_OnChange(object sender, SqlNotificationEventArgs e)
		{
			if (e.Info == SqlNotificationInfo.Invalid)
			{
				Debug.Print("SqlNotification:  A statement was provided that cannot be notified.");
				return;
			}
			try{
			var id =((SqlDependency)sender).Id;
			IEnumerable collection;
			if (collections.TryGetValue(id, out collection))
			{
				collections.Remove(id);
				AutoRefresh(collection);
				var notifyRefresh = collection as INotifyRefresh;
				if (notifyRefresh != null)
					System.Windows.Application.Current.Dispatcher.BeginInvoke(
					 (Action)(notifyRefresh.OnRefresh));
			}
			}
			catch (Exception ex)
			{
				System.Diagnostics.Debug.Print("Error in OnChange: {0}", ex.Message);
			}
		}
Esempio n. 7
0
 private void OnDependencyChanged(object sender, SqlNotificationEventArgs e)
 {
     if (_eventHandler != null)
         _eventHandler.Invoke(this, e);
     _dependency = null;
     Start();
 }
Esempio n. 8
0
 private void dependency_OnChange(object sender, SqlNotificationEventArgs e)
 {
     if (e.Type == SqlNotificationType.Change) {
         //MessagesHub test = new MessagesHub(services);
         //test.SendMessages();
         MessagesHub.SendMessages();
     }
 }
Esempio n. 9
0
        private void dependency_OnChange(object sender, SqlNotificationEventArgs e)
        {
            if (e.Type == SqlNotificationType.Change)
               {

               SendNotifications();
               }
        }
Esempio n. 10
0
 //event fired whenever db entites in the select list change
 private void dependency_OnChange(object sender, SqlNotificationEventArgs e)
 {
     if (e.Type == SqlNotificationType.Change)
     {
         //calls to hub message to broadvast changes
         MessagesHub.SendMessages();
     }
 }
        private void dependency_OnChange(object sender, SqlNotificationEventArgs e)
        {
            if (e.Type == SqlNotificationType.Change && e.Info == SqlNotificationInfo.Insert)
            {
                
            }

            RegisterDiscussMessages();
        }
Esempio n. 12
0
 static void  kmoDependency_OnChange(object sender, SqlNotificationEventArgs e)
 {
     Console.WriteLine("change happened");
     Console.WriteLine(e.Info.ToString());
     Console.WriteLine(e.Source.ToString());
     Console.WriteLine(e.Type.ToString());
     Console.WriteLine("restarting dependency watch...");
     m_restartWatch = true;
 }
Esempio n. 13
0
 private void Dependency_OnChange(object sender, System.Data.SqlClient.SqlNotificationEventArgs e)
 {
     //Если отклик не равен бездействию, то перевыполняем метод
     //Заполения данных о клиенте
     if (e.Info != System.Data.SqlClient.SqlNotificationInfo.Invalid)
     {
         Klient_Data_Fill();
     }
 }
Esempio n. 14
0
 internal void NewMessageRecieved(object sender, SqlNotificationEventArgs e)
 {
     IEnumerable<Message> newMessages = FetchMessagesFromDb();
     _dispatcher(newMessages.Select(lm => lm.MessageTest));
     using (ApplicationDbContext db = new ApplicationDbContext())
     {
         //Mark all dispatched messages as sent
         newMessages.ToList().ForEach(lm => { db.Messages.Attach(lm); lm.IsSend = true; });
         db.SaveChanges();
     }
 }
Esempio n. 15
0
        private void dependency_OnChange(object sender, SqlNotificationEventArgs e)
        {
            if (e.Type == SqlNotificationType.Change)
            {
                var context = GlobalHost.ConnectionManager.GetHubContext<PingResultHub>();
                PingResultRepository repo = new PingResultRepository();
                var res = repo.GetAllPingResults();
                context.Clients.All.addPingResultToPage(res);
            }

            RegisterNotification();
        }
Esempio n. 16
0
 public void dependency_OnChange(object sender, SqlNotificationEventArgs e)
 {
     if (e.Type == SqlNotificationType.Change)
     {
         // We reach this point if a change is observed
         SendNotifications();
     }
     if (e.Type == SqlNotificationType.Subscribe)
     {
         // We reach this point if a change is observed
         SendNotifications();
     }
 }
Esempio n. 17
0
        private void _dependency_OnChange(object sender, SqlNotificationEventArgs e)
        {
            if (e.Info == SqlNotificationInfo.Invalid)
            {
                System.Diagnostics.Debug.WriteLine("SqlNotification:  A statement was provided that cannot be notified.");
                return;
            }
            SqlDependency dependency = (SqlDependency)sender;
            dependency.OnChange -= _dependency_OnChange; 

            OnRefreshEntityEvent();
            RegisterDependency();
        }
Esempio n. 18
0
        void NotificationHandler(object sender, SqlNotificationEventArgs e)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new OnChangeEventHandler(NotificationHandler), new object[]{sender, e});
                return;
            }

            var sqlDep = sender as SqlDependency;
            sqlDep.OnChange -= new OnChangeEventHandler(NotificationHandler);

            dataGridView.DataSource = notification.SomeMethod(NotificationHandler);
        }
        private void dependency_OnChange(object sender, SqlNotificationEventArgs e)
        {
            if (e.Type == SqlNotificationType.Change && e.Info == SqlNotificationInfo.Insert)
            {
                List<DiscussMessageModel> lsDiscussMessage = GetDiscussMessages();
                foreach (DiscussMessageModel model in lsDiscussMessage)
                {

                }
            }

            RegisterDiscussMessages();
        }
 private void OnDependencyChange(Object o, SqlNotificationEventArgs args)
 {
     if ((args.Source.ToString() == "Data") || (args.Source.ToString() == "Timeout"))
     {
         Console.WriteLine(Environment.NewLine + "Refreshing data due to {0}", args.Source);
         Notify(CacheDependencyChangeTypes.Changed);
         ListenForChanges();
     }
     else
     {
         Console.WriteLine(Environment.NewLine + "Data not refreshed due to unexpected SqlNotificationEventArgs: Source={0}, Info={1}, Type={2}", args.Source, args.Info, args.Type.ToString());
     }
 }
        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)
                {
                    hub.SendDiscussMessage(model.Username, model.FilePath, model.Message);
                }
            }

            RegisterDiscussMessages();
        }
Esempio n. 22
0
        private void dependency_OnChange(
   object sender, SqlNotificationEventArgs e)
        {
            // This event will occur on a thread pool thread.
            // Updating the UI from a worker thread is not permitted.
            // The following code checks to see if it is safe to
            // update the UI.
            ISynchronizeInvoke i = (ISynchronizeInvoke)this;

            // If InvokeRequired returns True, the code
            // is executing on a worker thread.
            if (i.InvokeRequired)
            {
                // Create a delegate to perform the thread switch.
                OnChangeEventHandler tempDelegate =
                    new OnChangeEventHandler(dependency_OnChange);

                object[] args = { sender, e };

                // Marshal the data from the worker thread
                // to the UI thread.
                i.BeginInvoke(tempDelegate, args);

                return;
            }

            // Remove the handler, since it is only good
            // for a single notification.
            SqlDependency dependency =
                (SqlDependency)sender;

            dependency.OnChange -= dependency_OnChange;

            // At this point, the code is executing on the
            // UI thread, so it is safe to update the UI.
            ++changeCount;
            label1.Text = String.Format(statusMessage, changeCount);

            // Add information from the event arguments to the list box
            // for debugging purposes only.
            listBox1.Items.Clear();
            listBox1.Items.Add("Info:   " + e.Info.ToString());
            listBox1.Items.Add("Source: " + e.Source.ToString());
            listBox1.Items.Add("Type:   " + e.Type.ToString());

            // Reload the dataset that is bound to the grid.
            GetData();
        }
Esempio n. 23
0
 private static void Dep_OnChange(object sender, SqlNotificationEventArgs e)
 {
     //清除相關快取
     List<string> keys = new List<string>();
     var cache = MemoryCache.Default;
     foreach (var item in cache)
     {
         if (item.Key.StartsWith("MaintenanceMode_"))
             keys.Add(item.Key);
     }
     foreach (var key in keys)
     {
         cache.Remove(key);
     }
     SetMonitor();
 }
Esempio n. 24
0
        private void dependency_OnChange(object sender, SqlNotificationEventArgs e)
        {
            ISynchronizeInvoke i = this;
            if (i.InvokeRequired)
            {
                OnChangeEventHandler tempDelegate = dependency_OnChange;
                object[] args = { sender, e };
                i.BeginInvoke(tempDelegate, args);
                return;
            }

            SqlDependency dependency = (SqlDependency)sender;
            dependency.OnChange -= dependency_OnChange;

            GetData();
        }
        private static void sqlDependency_OnChange(object sender, SqlNotificationEventArgs e)
        {
            if (e.Info == SqlNotificationInfo.Insert)
            {
                var cntrl = new DotNetNuke.Services.Log.EventLog.EventLogController();

                int records = 0;
                int pageSize = 10;
                int pageIndex = 0;

                // Get DNN Logs
                //var dnnLogs = cntrl.GetLogs(PortalId, DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.HOST_ALERT.ToString(), pageSize, pageIndex, ref records);

                // else try manually
                var props = new DotNetNuke.Services.Log.EventLog.LogProperties();
                props.Deserialize("<LogProperties><LogProperty><PropertyName>Install Package:</PropertyName><PropertyValue>CCFileExplorer</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Starting Installation</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Starting Installation - CCFileExplorer</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Starting Installation - Script</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Begin Sql execution</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Creating backup of previous version - Providers\\DataProviders\\SqlDataProvider\\00.00.01.SqlDataProvider</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Created - Providers\\\\DataProviders\\SqlDataProvider\\00.00.01.SqlDataProvider</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Executing 00.00.01.SqlDataProvider</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Start Sql execution: 00.00.01.SqlDataProvider file</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>End Sql execution: 00.00.01.SqlDataProvider file</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Creating backup of previous version - Providers\\DataProviders\\SqlDataProvider\\Uninstall.SqlDataProvider</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Created - Providers\\DataProviders\\SqlDataProvider\\Uninstall.SqlDataProvider</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Finished Sql execution</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Component installed successfully - Script</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Starting Installation - ResourceFile</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Expanding Resource file</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Creating backup of previous version - Edit.ascx</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Created - Edit.ascx</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Creating backup of previous version - License.txt</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Created - License.txt</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Creating backup of previous version - module.css</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Created - module.css</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Creating backup of previous version - ReleaseNotes.txt</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Created - ReleaseNotes.txt</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Creating backup of previous version - Settings.ascx</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Created - Settings.ascx</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Creating backup of previous version - View.ascx</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Created - View.ascx</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Creating backup of previous version - App_LocalResources\\Edit.ascx.resx</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Created - App_LocalResources/Edit.ascx.resx</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Creating backup of previous version - App_LocalResources\\Settings.ascx.resx</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Created - App_LocalResources/Settings.ascx.resx</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Creating backup of previous version - App_LocalResources\\View.ascx.resx</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Created - App_LocalResources/View.ascx.resx</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Creating backup of previous version - Documentation\\Documentation.css</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Created - Documentation/Documentation.css</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Creating backup of previous version - Documentation\\Documentation.html</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Created - Documentation/Documentation.html</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Resource Files created</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Component installed successfully - ResourceFile</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Starting Installation - Module</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Module registered successfully - CCFileExplorer</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Component installed successfully - Module</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Starting Installation - Assembly</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Assembly registered - bin\\CCFileExplorer.dll</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Creating backup of previous version - bin\\CCFileExplorer.dll</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Created - bin\\CCFileExplorer.dll</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Component installed successfully - Assembly</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Installation committed</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Installation successful. - CCFileExplorer</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Deleted temporary install folder</PropertyValue></LogProperty><LogProperty><PropertyName>Info:</PropertyName><PropertyValue>Installation successful.</PropertyValue></LogProperty></LogProperties>");

                var dnnLog = new DotNetNuke.Services.Log.EventLog.LogInfo() {
                    LogGUID = Guid.NewGuid().ToString()
                   ,LogTypeKey = "HOST_ALERT"
                   ,LogConfigID = "95"
                   ,LogUserID = 0
                   ,LogUserName ="******"
                   ,LogPortalID = 0
                   ,LogPortalName = null
                   ,LogCreateDate = DateTime.UtcNow
                   ,LogServerName = "Cass"
                   ,LogProperties = props
                };
                var dnnLogs = new List<DotNetNuke.Services.Log.EventLog.LogInfo>(){dnnLog};

                // Convert to EventLogs
                var logs = dnnLogs.Where(log => log.LogCreateDate >= SinceDate).Select(x => new EventLog(x)).ToList();
                // Broadcast
                LogHubController.Instance.BroadcastLogs(logs);

                SinceDate = DateTime.UtcNow;
            }

            //Call the RegisterNotification method again
            RegisterDependency();
        }
Esempio n. 26
0
        public static void LogSqlNotificationData(SqlNotificationEventArgs p_args, Type p_type)
        {
            if (p_args != null)
              {
            string sMessage = string.Format(
            "SqlNotification received.\n\tNotification Info: {0}\n\tNotification Source: {1}\n\tNotification Type: {2}\nEntity:{3}\n",
            p_args.Info, p_args.Source,
            p_args.Type, p_type.FullName);

            if (p_args.Info == SqlNotificationInfo.Invalid ||
            p_args.Info == SqlNotificationInfo.Error ||
            p_args.Info == SqlNotificationInfo.Options ||
            p_args.Info == SqlNotificationInfo.Resource ||
            p_args.Info == SqlNotificationInfo.TemplateLimit ||
            p_args.Info == SqlNotificationInfo.Unknown)
              AssistLogger.WriteInformation(
              sMessage, AssistLogger.Category.Database);
            AssistLogger.WriteDebugInformation(sMessage, "Sql Notification");
              }
        }
        private static void Dep_OnChange(object sender, SqlNotificationEventArgs e)
        {
            Console.WriteLine("UpdateCallback-Info:" + e.Info);
            Console.WriteLine("UpdateCallback-Source:" + e.Source);
            //TODO:Clear all of the relative caches
            List<string> keys = new List<string>();

            var cache = MemoryCache.Default;
            Console.WriteLine("cacheClear-before:" + cache.Count());

            foreach (var item in cache)
            {
                keys.Add(item.Key);

            }

            foreach (var key in keys)
            {
                cache.Remove(key);
            }
            Console.WriteLine("cacheClear-after:" + cache.Count());
        }
Esempio n. 28
0
        void dep_OnChange(object sender, SqlNotificationEventArgs e)
        {
            using (var conn = GetConnection())
              {
            var sql = @"
            SELECT [Id]
              ,[Url]
              ,[AppName]
              ,[UserName]
              ,[Running]
              ,[LastModified]
              ,[Version]
              FROM [prototypes].[dbo].[Applications]";

            var r = conn.Query<Application>(sql).ToList();
            hub.Clients.All.updateApplicationList(r);

            //resubscribe

            this.Start();
              }
        }
Esempio n. 29
0
        private void dependency_OnChange(object sender, SqlNotificationEventArgs e)
        {
            if (e.Type == SqlNotificationType.Subscribe || e.Info == SqlNotificationInfo.Error)
                return;
            string jsonCajero;

            if (e.Info == SqlNotificationInfo.Delete)
            {
                var dbnn = _listInstances.Find(dbn => dbn.IdCondicional == IdCondicional);
                _listInstances.Remove(dbnn);
                return;
            }

            using (var db = new ApplicationDbContext())
            {
                var cajero = db.Cajeros.Find(IdCondicional).ToSimpleCajero();
                jsonCajero = JsonConvert.SerializeObject(cajero);
            }

            if (OnNewChange != null) OnNewChange(jsonCajero, e);

            ResgisterNotification();
        }
        public void SendCashLevels(object sender, SqlNotificationEventArgs e)
        {
            var cajero = JsonConvert.DeserializeObject<Cajero>((string)sender);
            var userList = new List<string>();

            using (var db = new ApplicationDbContext())
            {
                    userList = db.Cajeros.Find(cajero.IdCajero).Users.Select(u => u.UserName).ToList();
                    var AdminList =
                        db.Users.Where(u => u.Roles.Select(r => r.RoleId).Contains("A"))
                            .ToList()
                            .Select(uu => uu.UserName);
                userList.AddRange(AdminList);
            }

            var cashLevels = JsonConvert.SerializeObject(new
            {
                cajero.IdCajero,
                cajero.EfectivoActual,
                cajero.NivelBajoEfectivo
            });

            Clients.Users(userList).CashLevels(cashLevels);
        }
Esempio n. 31
0
    private void OnChange(object sender, SqlNotificationEventArgs e)
    {
        SqlDependency dependency = (SqlDependency)sender;

        // Notices are only a one shot deal
        // so remove the existing one so a new
        // one can be added
        if (dependency != null) dependency.OnChange -= OnChange;

        IConnectionManager connectionManager = AspNetHost.DependencyResolver.Resolve<IConnectionManager>();
        IConnection connection = connectionManager.GetConnection<MyConnection>();

        connection.Broadcast("Update!");

        try
        {
            StartNotifying();
        }
        catch (Exception ex)
        {
            broadCastException(ex);
            throw;
        }
    }
Esempio n. 32
0
        private void DependencyObj_OnChange(object sender, SqlNotificationEventArgs e)
        {
            if (e.Info == SqlNotificationInfo.Invalid || e.Info == SqlNotificationInfo.Error ||
                e.Type == SqlNotificationType.Subscribe)
            {
                Print.Error(e.Info.ToString(), e.Source.ToString(), e.Type.ToString());
                Scan.ContinueExit("Press enter to Exit to the Application");
            }
            using (var db = new AtmTestDbContext())
            {
                var id = _query.Substring(_query.LastIndexOf('=') + 1).Trim();
                if (_query.Contains("Dispensadores"))
                {
                    var com = db.Dispensadores.Find(id);

                    ClientHub.HubProxy.Invoke("DispensadorData", com.EfectivoActual, com.EfectivoDispensado, com.EfectivoInicial, com.Status, com.Error, com.Cajero.First().NsCajero);
                    Print.NewLine($"DataSent: Dispensador-> {com.EfectivoActual},{com.EfectivoDispensado},{com.EfectivoInicial},{com.Status},{com.Error},{com.Cajero.First().NsCajero}");
                }
                else if (_query.Contains("TonelerosA"))
                {
                    var com = db.TonelerosA.Find(id);

                    ClientHub.HubProxy.Invoke("ToneleroAData", com.EfectivoActual, com.EfectivoDispensado, com.EfectivoInicial, com.Status, com.Error, com.Cajero.First().NsCajero);
                    Print.NewLine($"DataSent: ToneleroA-> {com.EfectivoActual},{com.EfectivoDispensado},{com.EfectivoInicial},{com.Status},{com.Error},{com.Cajero.First().NsCajero}");
                }
                else if (_query.Contains("TonelerosB"))
                {
                    var com = db.TonelerosB.Find(id);

                    ClientHub.HubProxy.Invoke("ToneleroBData", com.EfectivoActual, com.EfectivoDispensado, com.EfectivoInicial, com.Status, com.Error, com.Cajero.First().NsCajero);
                    Print.NewLine($"DataSent: ToneleroB-> {com.EfectivoActual},{com.EfectivoDispensado},{com.EfectivoInicial},{com.Status},{com.Error},{com.Cajero.First().NsCajero}");
                }
                else if (_query.Contains("Impresoras"))
                {
                    var com = db.Impresoras.Find(id);

                    ClientHub.HubProxy.Invoke("ImpresoraData", com.Papel, com.Status, com.Error, com.Cajero.First().NsCajero);
                    Print.NewLine($"DataSent: Impresora-> {com.Papel},{com.Status},{com.Error},{com.Cajero.First().NsCajero}");
                }
                else if (_query.Contains("Scanners"))
                {
                    var com = db.Scanners.Find(id);

                    ClientHub.HubProxy.Invoke("ScannerData", com.Status, com.Error, com.Cajero.First().NsCajero);
                    Print.NewLine($"DataSent: Scanner-> {com.Status},{com.Error},{com.Cajero.First().NsCajero}");
                }
                else if (_query.Contains("Tarjetas"))
                {
                    var com = db.Tarjetas.Find(id);

                    ClientHub.HubProxy.Invoke("TarjetaData", com.Status, com.Error, com.Cajero.First().NsCajero);
                    Print.NewLine($"DataSent: Tarjeta-> {com.Status},{com.Error},{com.Cajero.First().NsCajero}");
                }
                else if (_query.Contains("AceptadoresBilletes"))
                {
                    var com = db.AceptadoresBilletes.Find(id);

                    ClientHub.HubProxy.Invoke("AceptadorBilletesData", com.Status, com.Error, com.Cajero.First().NsCajero);
                    Print.NewLine($"DataSent: Billetero-> {com.Status},{com.Error},{com.Cajero.First().NsCajero}");
                }
                else if (_query.Contains("AceptadoresMonedas"))
                {
                    var com = db.AceptadoresMonedas.Find(id);

                    ClientHub.HubProxy.Invoke("AceptadorMonedasData", com.Status, com.Error, com.Cajero.First().NsCajero);
                    Print.NewLine($"DataSent: Moneder-> {com.Status},{com.Error},{com.Cajero.First().NsCajero}");
                }
            }

            RegisterQuery();
        }
Esempio n. 33
0
 internal static Exception SqlNotificationException(SqlNotificationEventArgs notify)
 {
     return(ADP.InvalidOperation(Res.GetString("SQLNotify_ErrorFormat", new object[] { notify.Type, notify.Info, notify.Source })));
 }
Esempio n. 34
0
 internal void Invoke(SqlNotificationEventArgs args)
 {
     _args = args;
     ExecutionContext.Run(_context, s_contextCallback, this);
 }