コード例 #1
0
        private static void MonitorPrinter(string printerName, NotifyOptions printerNotifyOptions, PRINTER_CHANGE change)
        {
            if (printerNotifyOptions == null && change == 0)
            {
                throw new Exception("Either or both of printer changes or fields to monitor must be set.");
            }

            using var printerChangeNotification = ChangeNotification.Create(change,
                                                                            printerName,
                                                                            PRINTER_NOTIFY_CATEGORY.PRINTER_NOTIFY_CATEGORY_ALL, printerNotifyOptions);

            while (true)
            {
                printerChangeNotification.WaitHandle.WaitOne();
                NotifyInfo printerNotifyInfo;
                bool       refresh = false;

                do
                {
                    printerNotifyInfo = printerChangeNotification.FindNextPrinterChangeNotification(refresh);
                    WriteToConsole(printerNotifyInfo);

                    refresh = true; // For next iteration if data overflowed
                } while ((printerNotifyInfo.Flags & NotifyInfo.PRINTER_NOTIFY_INFO_DISCARDED) != 0);
            }
        }
コード例 #2
0
        /// <summary>
        /// Handles the HTTP POST requests from Facebook for updates.
        /// </summary>
        public virtual async Task <HttpResponseMessage> Post()
        {
            IEnumerable <string> headerValues;

            if (Request.Headers.TryGetValues(XHubSignatureHeaderName, out headerValues))
            {
                string signatureHeaderValue = headerValues.FirstOrDefault();
                try
                {
                    string contentString = await Request.Content.ReadAsStringAsync();

                    FacebookClient     client       = FacebookConfiguration.ClientProvider.CreateClient();
                    ChangeNotification notification = client.VerifyPostSubscription(signatureHeaderValue, contentString, typeof(ChangeNotification)) as ChangeNotification;
                    await HandleUpdateAsync(notification);
                }
                catch (ArgumentException argumentException)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, argumentException));
                }
                catch (HttpResponseException responseException)
                {
                    return(responseException.Response);
                }
            }
            else
            {
                return(Request.CreateErrorResponse(
                           HttpStatusCode.BadRequest,
                           String.Format(CultureInfo.CurrentCulture, Resources.MissingRequiredHeader, XHubSignatureHeaderName)));
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
コード例 #3
0
 public override void HandlePushNotification(string func, object args)
 {
     try
     {
         if (Application.Current == null)
         {
             return; // not ready yet
         }
         if (func == "ActivityNotification")
         {
             Application.Current.Dispatcher.BeginInvoke(new Action(() => {
                 ActivityNotification?.Invoke(this, (Priv10Engine.FwEventArgs)args);
             }));
         }
         else if (func == "ChangeNotification")
         {
             Application.Current.Dispatcher.BeginInvoke(new Action(() => {
                 ChangeNotification?.Invoke(this, (Priv10Engine.ChangeArgs)args);
             }));
         }
         else
         {
             throw new Exception("Unknown Notificacion");
         }
     }
     catch (Exception err)
     {
         AppLog.Exception(err);
     }
 }
コード例 #4
0
            public bool Register(string connectionId, Action <string[]> onChanged)
            {
                ConcurrentDictionary <string, IDisposable> dict;

                if (!Listeners.TryGetValue(typeof(TDomainObject), out dict))
                {
                    dict = new ConcurrentDictionary <string, IDisposable>();
                    if (!Listeners.TryAdd(typeof(TDomainObject), dict))
                    {
                        return(false);
                    }
                }
                var name     = typeof(TDomainObject).FullName;
                var listener = ChangeNotification.Track <TDomainObject>().Subscribe(kv => onChanged(kv.Key));

                if (!dict.TryAdd(connectionId, listener))
                {
                    listener.Dispose();
                }
                else
                {
                    ConcurrentBag <Type> bag;
                    if (!Connections.TryGetValue(connectionId, out bag))
                    {
                        bag = new ConcurrentBag <Type>();
                        Connections.TryAdd(connectionId, bag);
                    }
                    bag.Add(typeof(TDomainObject));
                }
                return(true);
            }
コード例 #5
0
        /// <summary>
        ///  Reset's the delivery queue for the airing
        /// </summary>
        /// <param name="statusQueues"></param>
        /// <param name="airing"></param>
        /// <returns>list of status change notifications</returns>
        private List <ChangeNotification> ResetDeliveryQueue(List <Queue> statusQueues, Airing airing)
        {
            IList <string> queuesTobeNotified = new List <string>();
            List <string>  airingStatusNames  = airing.Status.Keys.ToList();

            List <ChangeNotification> changeNotifications = new List <ChangeNotification>();

            foreach (string statusname in airingStatusNames)
            {
                var subscribedQueues = statusQueues.Where(x => x.StatusNames.Contains(statusname));
                foreach (var deliveryQueue in subscribedQueues.Select(e => e.Name))
                {
                    if (airing.DeliveredTo.Contains(deliveryQueue) || airing.IgnoredQueues.Contains(deliveryQueue) || airing.ChangeNotifications.Select(x => x.QueueName).Contains(deliveryQueue))
                    {
                        if (changeNotifications.Select(x => x.QueueName).Contains(deliveryQueue))
                        {
                            var existingChangeNotification = changeNotifications.Where(x => x.QueueName == deliveryQueue).FirstOrDefault();
                            existingChangeNotification.ChangedProperties.Add(statusname);
                        }
                        else
                        {
                            ChangeNotification newChangeNotification = new ChangeNotification();
                            newChangeNotification.QueueName = deliveryQueue;
                            newChangeNotification.ChangeNotificationType = ChangeNotificationType.Status.ToString();
                            newChangeNotification.ChangedProperties.Add(statusname);
                            newChangeNotification.ChangedDateTime = DateTime.UtcNow;
                            changeNotifications.Add(newChangeNotification);
                        }
                    }
                }
            }
            return(changeNotifications);
        }
コード例 #6
0
ファイル: BoardPortion.cs プロジェクト: palaniappa/dummy
 public void notify(ChangeNotification change, int i, int j, uint val)
 {
     if (change == ChangeNotification.VALUE_SET)
     {
         this.setNumberPresence(val);
         this.remainingCount--;
     }
 }
コード例 #7
0
ファイル: Board.cs プロジェクト: palaniappa/dummy
 public void notify(ChangeNotification change, int i, int j, uint val)
 {
     if (change == ChangeNotification.VALUE_SET)
     {
         this.remainingCount--;
         valCountInBoard[val] = valCountInBoard[val] + 1;
     }
 }
コード例 #8
0
 public void Send(ChangeNotification localChangeNotification)
 {
     OnChangeNotification(this, localChangeNotification);
     foreach (var connectionState in connections)
     {
         connectionState.Value.CounterStorage.Send(localChangeNotification);
     }
 }
コード例 #9
0
 public void NotifyChange(Guid guid)
 {
     Application.Current.Dispatcher.BeginInvoke(new Action(() => {
         ChangeNotification?.Invoke(this, new ProgramList.ChangeArgs()
         {
             guid = guid
         });
     }));
 }
コード例 #10
0
 public override void HandlePushNotification(string func, List <byte[]> args)
 {
     //try
     {
         if (Application.Current == null)
         {
             return; // not ready yet
         }
         if (func == "ActivityNotification")
         {
             Application.Current.Dispatcher.BeginInvoke(new Action(() =>
             {
                 ActivityNotification?.Invoke(this, new Priv10Engine.FwEventArgs()
                 {
                     guid     = GetGuid(args[0]),
                     entry    = GetLogEntry(args[1]),
                     progID   = GetProgID(args[2]),
                     services = GetStrList(args[3]),
                     update   = GetBool(args[4])
                 });
             }));
         }
         else if (func == "ChangeNotification")
         {
             Application.Current.Dispatcher.BeginInvoke(new Action(() =>
             {
                 ChangeNotification?.Invoke(this, new Priv10Engine.ChangeArgs()
                 {
                     prog   = GetProg(args[0]),
                     rule   = GetRule(args[1]),
                     type   = GetEnum <Priv10Engine.RuleEventType>(args[2]),
                     action = GetEnum <Priv10Engine.RuleFixAction>(args[3])
                 });
             }));
         }
         else if (func == "UpdateNotification")
         {
             Application.Current.Dispatcher.BeginInvoke(new Action(() =>
             {
                 UpdateNotification?.Invoke(this, new Priv10Engine.UpdateArgs()
                 {
                     guid = GetGuid(args[0]),
                     type = GetEnum <Priv10Engine.UpdateArgs.Types>(args[1])
                 });
             }));
         }
         else
         {
             throw new Exception("Unknown Notificacion");
         }
     }
     //catch (Exception err)
     //{
     //    AppLog.Exception(err);
     //}
 }
コード例 #11
0
        public void MultipleFields()
        {
            // Use a random comment then we don't have t worry about it being set from a previous run.
            var  randomComment = DateTime.Now.Ticks.ToString();
            uint priority;

            var options = new NotifyOptions
            {
                Types = new List <NotifyOptionsType>
                {
                    new NotifyOptionsType()
                    {
                        Fields = new List <ushort>
                        {
                            (ushort)PRINTER_NOTIFY_FIELD.PRINTER_NOTIFY_FIELD_COMMENT,
                            (ushort)PRINTER_NOTIFY_FIELD.PRINTER_NOTIFY_FIELD_LOCATION,
                            (ushort)PRINTER_NOTIFY_FIELD.PRINTER_NOTIFY_FIELD_PRIORITY,
                        },
                        Type = NOTIFY_TYPE.PRINTER_NOTIFY_TYPE,
                    }
                }
            };

            using var changeNotification = ChangeNotification.Create(0, NameConstants.PrinterName, PRINTER_NOTIFY_CATEGORY.PRINTER_NOTIFY_CATEGORY_ALL, options);

            // If we don't close the printer handle before calling WaitOne then WaitOne can block indefinitely
            using (var printer = new SafePrinter(NameConstants.PrinterName))
            {
                // This should trigger a change
                var pi2 = printer.GetPrinter();
                pi2.pComment  = randomComment + "Comment";
                pi2.pLocation = randomComment + "Location";
                priority      = ++pi2.Priority & 0xFF;
                printer.SetPrinter(pi2, 0);
            }

            changeNotification.WaitHandle.WaitOne();

            var change = changeNotification.FindNextPrinterChangeNotification(true);

            Assert.That(change.Change == 0); // We didn't request change monitoring

            Assert.That(change.Data.Count, Is.EqualTo(3));

            var comment = change.Data.First(d => d.Field == (int)PRINTER_NOTIFY_FIELD.PRINTER_NOTIFY_FIELD_COMMENT).Value;

            Assert.That(comment, Is.EqualTo(randomComment + "Comment"));

            var location = change.Data.First(d => d.Field == (int)PRINTER_NOTIFY_FIELD.PRINTER_NOTIFY_FIELD_LOCATION).Value;

            Assert.That(location, Is.EqualTo(randomComment + "Location"));

            var newPriority = change.Data.First(d => d.Field == (int)PRINTER_NOTIFY_FIELD.PRINTER_NOTIFY_FIELD_PRIORITY).Value;

            Assert.That(newPriority, Is.EqualTo(priority));
        }
コード例 #12
0
 internal static SignalRChangeNotification Create(ChangeNotification original)
 {
     return(new SignalRChangeNotification
     {
         ChangeType = original.ChangeType,
         SourceFieldNames = original.SourceFieldNames,
         EntityType = original.EntityType.FullName,
         EntityKeys = original.EntityKeys
     });
 }
コード例 #13
0
        /// <summary>
        /// Sends a ChangeNotification message to a customer.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="change">The object change.</param>
        /// <returns>The message identifier.</returns>
        public long ChangeNotification(IMessageHeader request, ObjectChange change)
        {
            var header = CreateMessageHeader(Protocols.StoreNotification, MessageTypes.StoreNotification.ChangeNotification, request.MessageId);

            var notification = new ChangeNotification()
            {
                Change = change
            };

            return(Session.SendMessage(header, notification));
        }
コード例 #14
0
 public override void ReceiverChange(ChangeNotification notifier)
 {
     base.ReceiverChange(notifier);
     if (Convert.ToDouble(notifier.Item.NewValue) > Convert.ToDouble(maxValue))
     {
         if (Notifier != null)
         {
             Notifier(this, notifier);
         }
     }
 }
コード例 #15
0
        public override Task HandleUpdateAsync(ChangeNotification notification)
        {
            if (notification.Object == "user")
            {
                foreach (var entry in notification.Entry)
                {
                    // 업데이트를 처리하기 위한 사용자의 논리를 입력함
                }
            }

            throw new NotImplementedException();
        }
コード例 #16
0
 public override void ReceiverChange(ChangeNotification notifier)
 {
     base.ReceiverChange(notifier);
     if (Convert.ToDouble(notifier.Item.NewValue) > Convert.ToDouble(minValue))
     {
         if (Notifier != null)
         {
             Notifier(this, notifier);
         }
         Console.WriteLine("Alarm!!!!!!!!!!!!!!!!");
     }
 }
コード例 #17
0
        public override Task HandleUpdateAsync(ChangeNotification notification)
        {
            if (notification.Object == "user")
            {
                foreach (var entry in notification.Entry)
                {
                    // Your logic to handle the update here
                }
            }

            throw new NotImplementedException();
        }
コード例 #18
0
        public override void ReceiverChange(ChangeNotification notifier)
        {
            double dif = Convert.ToDouble(notifier.Item.NewValue) - Convert.ToDouble(_Value);

            base.ReceiverChange(notifier);
            if (Convert.ToDouble(vChange) < dif)
            {
                if (Notifier != null)
                {
                    Notifier(this, notifier);
                }

                Console.WriteLine("Alarm!!!!!!!!!!!!!!!!");
            }
        }
コード例 #19
0
            public bool Register(string connectionId, Type type, string specificationJson, Action <string> onMatched)
            {
                Func <TDomainObject, bool> isMatched;

                try
                {
                    ISpecification <TDomainObject> specification = (ISpecification <TDomainObject>)Newtonsoft.Json.JsonConvert.DeserializeObject(specificationJson, type);
                    isMatched = specification.IsSatisfied.Compile();
                }
                catch { return(false); }
                ConcurrentDictionary <string, IDisposable> dict;

                if (!Listeners.TryGetValue(typeof(TDomainObject), out dict))
                {
                    dict = new ConcurrentDictionary <string, IDisposable>();
                    if (!Listeners.TryAdd(typeof(TDomainObject), dict))
                    {
                        return(false);
                    }
                }
                var name     = typeof(TDomainObject).FullName;
                var listener = ChangeNotification.Track <TDomainObject>().Subscribe(kv =>
                {
                    foreach (var v in kv.Value.Value)
                    {
                        if (isMatched(v))
                        {
                            onMatched(v.URI);
                        }
                    }
                });

                if (!dict.TryAdd(connectionId, listener))
                {
                    listener.Dispose();
                }
                else
                {
                    ConcurrentBag <Type> bag;
                    if (!Connections.TryGetValue(connectionId, out bag))
                    {
                        bag = new ConcurrentBag <Type>();
                        Connections.TryAdd(connectionId, bag);
                    }
                    bag.Add(typeof(TDomainObject));
                }
                return(true);
            }
コード例 #20
0
        public Task <TEntity> GetOrAdd <TEntity>(string key, Func <Task <TEntity> > valueGetter,
                                                 MemoryCacheEntryOptions cacheOptions, Dictionary <string, string> tags = null)
        {
            if (!_settings.IsEnabled || string.IsNullOrWhiteSpace(key))
            {
                return(valueGetter());
            }

            _cacheKeyUsage.AddOrUpdate(key,
                                       v => new CacheItemUsage {
                Type = typeof(TEntity), UsageCounter = 0
            },
                                       (k, v) =>
            {
                v.UsageCounter += 1;
                return(v);
            });

            return(_memoryCache.GetOrCreateAsync(key, v =>
            {
                if (tags?.Count > 0)
                {
                    var cancelationSource = new CancellationTokenSource();

                    foreach (var tag in tags)
                    {
                        var sources = GetCancelationTokens(tag.Key, tag.Value);
                        sources.TryAdd(key, cancelationSource);
                    }
                    var changeNotification = new ChangeNotification {
                        Source = cancelationSource, Tags = tags
                    };

                    cacheOptions.AddExpirationToken(new CancellationChangeToken(cancelationSource.Token));
                    cacheOptions.RegisterPostEvictionCallback(PostEvictionCallback, changeNotification);
                }
                else
                {
                    cacheOptions.RegisterPostEvictionCallback(PostEvictionCallback);
                }

                v.SetOptions(cacheOptions);
                return valueGetter();
            }));
        }
コード例 #21
0
ファイル: QueueCommand.cs プロジェクト: nirmalasubu/sample
        private IList <ChangeNotification> GetChangeNotifications(IList <string> queueNames, Airing currentAiring)
        {
            IList <ChangeNotification> changeNotifications = new List <ChangeNotification>();

            foreach (var queueName in queueNames)
            {
                if (currentAiring.DeliveredTo.Contains(queueName) || currentAiring.ChangeNotifications.Select(x => x.QueueName).Contains(queueName) ||
                    currentAiring.IgnoredQueues.Contains(queueName))
                {
                    ChangeNotification changenotification = new ChangeNotification();
                    changenotification.QueueName = queueName;
                    changenotification.ChangeNotificationType = ChangeNotificationType.Package.ToString();
                    changenotification.ChangedDateTime        = DateTime.UtcNow;
                    changeNotifications.Add(changenotification);
                }
            }

            return(changeNotifications);
        }
コード例 #22
0
        public void AddJob()
        {
            var options = new NotifyOptions
            {
                Types = new List <NotifyOptionsType>
                {
                    new NotifyOptionsType
                    {
                        Fields = new List <ushort> {
                            (ushort)JOB_NOTIFY_FIELD.JOB_NOTIFY_FIELD_PRINTER_NAME
                        },
                        Type = NOTIFY_TYPE.JOB_NOTIFY_TYPE,
                    }
                }
            };

            using var changeNotification = ChangeNotification.Create(0, NameConstants.PrinterName, PRINTER_NOTIFY_CATEGORY.PRINTER_NOTIFY_CATEGORY_ALL, options);

            using var localPrintServer = new LocalPrintServer();
            var defaultPrintQueue = localPrintServer.GetPrintQueue(NameConstants.PrinterName);

            var myPrintJob = defaultPrintQueue.AddJob();

            // Write a Byte buffer to the JobStream and close the stream
            var myByteBuffer = Encoding.Unicode.GetBytes("This is a test string for the print job stream.");

            using var myStream = myPrintJob.JobStream;
            myStream.Write(myByteBuffer, 0, myByteBuffer.Length);
            myStream.Close();

            using var myStream2 = myPrintJob.JobStream;
            myStream2.Write(myByteBuffer, 0, myByteBuffer.Length);
            myStream2.Close();

            changeNotification.WaitHandle.WaitOne();

            var changes = changeNotification.FindNextPrinterChangeNotification(false);

            Assert.That(changes.Data.Count, Is.EqualTo(1));
            Assert.That(changes.Data.First().Value, Is.EqualTo(NameConstants.PrinterName));
        }
コード例 #23
0
        public void Comment()
        {
            // Use a random comment then we don't have t worry about it being set from a previous run.
            var randomComment = DateTime.Now.Ticks.ToString();

            var options = new NotifyOptions
            {
                Types = new List <NotifyOptionsType>
                {
                    new NotifyOptionsType()
                    {
                        Fields = new List <ushort> {
                            (ushort)PRINTER_NOTIFY_FIELD.PRINTER_NOTIFY_FIELD_COMMENT
                        },
                        Type = NOTIFY_TYPE.PRINTER_NOTIFY_TYPE,
                    }
                }
            };

            using var changeNotification = ChangeNotification.Create(0, NameConstants.PrinterName, PRINTER_NOTIFY_CATEGORY.PRINTER_NOTIFY_CATEGORY_ALL, options);

            // If we don't close the printer handle before calling WaitOne then WaitOne can block indefinitely
            using (var printer = new SafePrinter(NameConstants.PrinterName))
            {
                // This should trigger a change
                var pi2 = printer.GetPrinter();
                pi2.pComment            = randomComment;
                pi2.pSecurityDescriptor = IntPtr.Zero;
                printer.SetPrinter(pi2, 0);
            }

            changeNotification.WaitHandle.WaitOne();

            var change = changeNotification.FindNextPrinterChangeNotification(false);

            Assert.That(change.Change == 0); // We didn't request change monitoring

            Assert.That(change.Data.Count, Is.EqualTo(1));
            Assert.That(change.Data[0].Value, Is.EqualTo(randomComment));
        }
コード例 #24
0
        public void Send(ChangeNotification notification)
        {
            var counterPrefix = CounterUtils.GetFullCounterName(notification.GroupName, notification.CounterName);

            if (watchAllCounters > 0 || matchingChanges.Contains(counterPrefix))
            {
                var value = new { Value = notification, Type = changeNotificationType };
                enqueue(value);
            }

            if (matchingPrefixes.Any(prefix => counterPrefix.StartsWith(prefix)))
            {
                var value = new { Value = notification, Type = startingWithNotification };
                enqueue(value);
            }

            if (matchingGroups.Contains(notification.GroupName))
            {
                var value = new { Value = notification, Type = inGroupNotificationType };
                enqueue(value);
            }
        }
コード例 #25
0
        private async Task ProcessNotification(ChangeNotification notification, ILogger log)
        {
            var graphClient = _clientService.GetAppGraphClient(log);

            // The resource field in the notification has the URL to the
            // message, including the user ID and message ID. Since we
            // have the URL, use a MessageRequestBuilder instead of the fluent
            // API
            var msgRequestBuilder = new MessageRequestBuilder(
                $"https://graph.microsoft.com/v1.0/{notification.Resource}",
                graphClient);

            var message = await msgRequestBuilder.Request()
                          .Select(m => new
            {
                m.Subject
            })
                          .GetAsync();

            log.LogInformation($"The following message was {notification.ChangeType}:");
            log.LogInformation($"Subject: {message.Subject}, ID: {message.Id}");
        }
コード例 #26
0
        public void SetPrinter()
        {
            using var changeNotification = ChangeNotification.Create(PRINTER_CHANGE.PRINTER_CHANGE_PRINTER, NameConstants.PrinterName, PRINTER_NOTIFY_CATEGORY.PRINTER_NOTIFY_CATEGORY_ALL, null);

            // Make sure changeNotification isn't signaled before we start
            Assert.That(changeNotification.WaitHandle.WaitOne(0), Is.False);

            // If we don't close the printer handle before calling WaitOne then WaitOne can block indefinitely
            using (var printer = new SafePrinter(NameConstants.PrinterName))
            {
                // This should trigger a change
                var pi2 = printer.GetPrinter();
                pi2.pComment = "A printer comment";
                printer.SetPrinter(pi2, 0);
            }

            changeNotification.WaitHandle.WaitOne();

            var change = changeNotification.FindNextPrinterChangeNotification(false);

            Assert.That(change.Change == PRINTER_CHANGE.PRINTER_CHANGE_SET_PRINTER);
        }
コード例 #27
0
 public abstract Task HandleUpdateAsync(ChangeNotification notification);
コード例 #28
0
        /// <summary>
        /// Retrieve status notifications for both file/video and filetype/status. Both
        /// are based on queue settings
        /// </summary>
        /// <param name="statusQueues"></param>
        /// <param name="airing"></param>
        /// <returns>list of status change notifications</returns>
        private List <ChangeNotification> GetNotificationList(Airing airing, List <string> statuses)
        {
            List <Queue>              activeQueues        = _queueSvc.GetByStatus(true);
            IList <string>            queuesTobeNotified  = new List <string>();
            List <string>             notifiableStatuses  = statuses;
            List <ChangeNotification> changeNotifications = new List <ChangeNotification>();

            // Prepare for file/video notification
            // Find all queues that are subscribed for video change notification
            // and prepare for notification
            List <string> videoQueueNames = activeQueues
                                            .Where(q => q.DetectVideoChanges)
                                            .Select(q => q.Name).ToList();

            foreach (string queue in videoQueueNames)
            {
                if (airing.DeliveredTo.Contains(queue) || airing.IgnoredQueues.Contains(queue) ||
                    airing.ChangeNotifications.Select(x => x.QueueName).Contains(queue))
                {
                    ChangeNotification newChangeNotification = new ChangeNotification();
                    newChangeNotification.QueueName = queue;
                    newChangeNotification.ChangeNotificationType = ChangeNotificationType.File.ToString();
                    newChangeNotification.ChangedDateTime        = DateTime.UtcNow;
                    changeNotifications.Add(newChangeNotification);
                }
            }


            // Prepare for filetype/status notifications
            foreach (string statusname in notifiableStatuses)
            {
                List <Queue> subscribedQueues = activeQueues.Where(x => x.StatusNames.Contains(statusname)).ToList();

                foreach (string deliveryQueue in subscribedQueues.Select(e => e.Name))
                {
                    if (airing.DeliveredTo.Contains(deliveryQueue) || airing.IgnoredQueues.Contains(deliveryQueue) || airing.ChangeNotifications.Select(x => x.QueueName).Contains(deliveryQueue))
                    {
                        if (!changeNotifications
                            .Where(c =>
                        {
                            return(c.QueueName.Contains(deliveryQueue) &&
                                   c.ChangeNotificationType == ChangeNotificationType.Status.ToString());
                        }).IsNullOrEmpty())
                        {
                            ChangeNotification existingChangeNotification = changeNotifications.Where(c =>
                            {
                                return(c.QueueName.Contains(deliveryQueue) &&
                                       c.ChangeNotificationType == ChangeNotificationType.Status.ToString());
                            }).FirstOrDefault();
                            existingChangeNotification.ChangedProperties.Add(statusname);
                        }
                        else
                        {
                            ChangeNotification newChangeNotification = new ChangeNotification();
                            newChangeNotification.QueueName = deliveryQueue;
                            newChangeNotification.ChangeNotificationType = ChangeNotificationType.Status.ToString();
                            newChangeNotification.ChangedProperties.Add(statusname);
                            newChangeNotification.ChangedDateTime = DateTime.UtcNow;
                            changeNotifications.Add(newChangeNotification);
                        }
                    }
                }
            }

            return(changeNotifications);
        }
コード例 #29
0
        public void Send(ChangeNotification changeNotification)
        {
            var onCounterChangeNotification = OnChangeNotification;

            onCounterChangeNotification?.Invoke(changeNotification);
        }
コード例 #30
0
 public static void MiMetodo(object sender, ChangeNotification var)
 {
     Console.WriteLine("Alarm!!!!!  " + var.Item.Name + "  " + var.Item.NewValue);
 }