Beispiel #1
0
 public void ReceiverChange(ChangeNotification notifier)
 {
     for (int i = 0; i < Alarms.Count; i++)
     {
         if (Alarms[i].VariableName == notifier.Item.Name)
         {
             Alarms[i].ReceiverChange(notifier);
         }
     }
 }
 private static void SendNotification(INotifierReceiverChange receiver, ChangeNotification notification)
 {
     try
     {
         receiver.ReceiverChange(notification);
     }
     catch (Exception exc)
     {
         Console.WriteLine(exc.Message);
     }
 }
//        public IChangeNotifier NotificationReceiver;

        public void NotifyChange(ChangeNotification notification, INotifierReceiverChange NotificationReceiver)
        {
            lock (lckPendantNotifications)

                pendantNotifications.Enqueue(new ParChangeNotification_Receiver()
                {
                    ChangeNotificationReceiver = NotificationReceiver,
                    ChangeNotification         = notification
                });
            waitPendantNotifications.Set();
        }
Beispiel #4
0
        public void ActionAlarmNotifier(object sender, ChangeNotification var)
        {
            try
            {
                Alarms.Alarm alarmOcurr = (sender as Alarms.Alarm);

                alarm.Add(alarmOcurr.Comment + "     " + alarmOcurr.When + "   " + alarmOcurr.VariableName + "     " + var.Item.NewValue);
                if (alarm.Count > 100)
                {
                    alarm.RemoveAt(0);
                }
            }
            catch { }

            //Console.WriteLine("Alarm!!!!!  " + var.Item.Name + "  " + var.Item.NewValue);
        }
Beispiel #5
0
        public void ReceiverChange(ChangeNotification notifier)
        {
            Type      valueType = notifier.Item.NewValue.GetType();
            SqlDbType dbType    = DBTypeConvertor.ToSqlDbType(valueType);

            if (!InsertCommands.ContainsKey(valueType))
            {
                CreateLogTable(valueType, dbType);
                SqlCommand sqlInsertCommand = GetInsertCommand(valueType, dbType);
                InsertCommands.Add(valueType, sqlInsertCommand);
            }

            SqlCommand insertCommand = InsertCommands[valueType];

            insertCommand.Parameters["@LogDate"].Value = notifier.When;
            insertCommand.Parameters["@VarName"].Value = notifier.Item.Name;
            insertCommand.Parameters["@Data"].Value    = notifier.Item.NewValue;
            try
            {
                insertCommand.ExecuteNonQuery();
            }
            catch {}
        }