private void OnEventsUpdated()
        {
            List <Event> EventsList = new List <Event>();

            Array.ForEach(SSDPs, SSDPComponent => EventsList.Add(SSDPComponent.DiscoveryEvent));
            Events = EventsList.ToArray();
            EventsUpdated?.Invoke();
        }
Esempio n. 2
0
        private void OnEventsUpdated()
        {
            List <Event> EventsList = new List <Event>();

            Array.ForEach(SocketClients, s => EventsList.Add(s.ReadEvent));
            Array.ForEach(SocketEndpoints, s => EventsList.Add(s.ReadEvent));
            Events = EventsList.ToArray();
            EventsUpdated?.Invoke();
        }
Esempio n. 3
0
        private void ConstructEvents()
        {
            var EventsList = new List <Event>();

            EventsList.Add(m_Devices.Event);
            Array.ForEach(Devices, Device => EventsList.AddRange(Device.Events));
            EventsList.Add(Discovery.Properties.StartDeviceDiscovery);
            Events = EventsList.ToArray();
            EventsUpdated?.Invoke(this, Events);
        }
Esempio n. 4
0
        private void ConstructEvents()
        {
            var list = new List <Event>();

            list.Add(ConnectButtonEvent);
            list.Add(RestartButtonEvent);
            list.Add(Connection.Status.Event);
            list.AddRange(IOEvents);
            list.AddRange(Outputs.Select(o => o.UIToggleEvent));
            m_Events = list.ToArray();
            EventsUpdated?.Invoke(this, EventArgs.Empty);
        }
Esempio n. 5
0
        public void UpdateProperties(SSDPProperties theProperties)
        {
            bool EventUpdatedFlag        = false;
            bool SubscriptionUpdatedFlag = false;

            if (theProperties.DiscoveryEvent.Id != DiscoveryEvent.Id)
            {
                DiscoveryEvent.Id = theProperties.DiscoveryEvent.Id;
                EventUpdatedFlag  = true;
            }

            if (theProperties.DiscoveryEvent.Description != DiscoveryEvent.Description)
            {
                DiscoveryEvent.Description = theProperties.DiscoveryEvent.Description;
                EventUpdatedFlag           = true;
            }

            if (theProperties.DiscoveryTarget != DiscoveryTarget)
            {
                DiscoveryTarget = theProperties.DiscoveryTarget;
            }

            if (theProperties.SearchSubscription != null && theProperties.SearchSubscription.Id != SearchSubscription.Id)
            {
                SearchSubscription.Id   = theProperties.SearchSubscription.Id;
                SubscriptionUpdatedFlag = true;
            }



            ///
            /// ...
            ///

            if (EventUpdatedFlag)
            {
                EventsUpdated?.Invoke();
            }

            if (SubscriptionUpdatedFlag)
            {
                SubscriptionsUpdated?.Invoke();
            }
        }
Esempio n. 6
0
        private void MainLoop()
        {
            log.LogInformation("MainLoop Started");

            // TODO: Make last scraping time persistent
            // Scraping logic not so good, scraping duplicate or not updating frequently

            DateTime lastScraped = DateTime.MinValue;

            do
            {
                try
                {
                    using (var scope = serviceScopeFactory.CreateScope()) // Used becuse DI disposing scoped service on background worker
                    {
                        var _eventsService = scope.ServiceProvider.GetService <IGenericService <EventModel> >();
                        var scrapedEvents  = habimaScrapper.ScrapeFromDate(lastScraped);
                        if (!scrapedEvents.Any())
                        {
                            continue;
                        }

                        foreach (var e in scrapedEvents)
                        {
                            _eventsService.Insert(e); // We need to deny insert of duplicates on base64Id
                        }
                        EventsUpdated?.Invoke(this, null);

                        lastScraped = scrapedEvents.OrderByDescending(e => e.Start).First().Start.ToUniversalTime();
                    }
                }
                catch (Exception ex)
                {
                    log.LogError(ex, "Failed to add events from scrapper");
                }
            }while (!_cancellationToken.Token.WaitHandle.WaitOne());

            log.LogInformation("MainLoop Ended");
        }
        internal void UpdateProperties(SocketEndpointProperties theNewProperties)
        {
            bool SubscriptionsUpdatedFlag = false;
            bool EventsUpdatedFlag        = false;
            bool ForceInitialise          = false;

            if (theNewProperties.Guid == null || theNewProperties.Guid != Guid)
            {
                return;
            }

            if (theNewProperties.ReadEvent != null)
            {
                if (Event.Merge(ReadEvent, theNewProperties.ReadEvent))
                {
                    EventsUpdatedFlag = true;
                }
            }

            if (theNewProperties.IPAddress != null && theNewProperties.IPAddress != IPAddress)
            {
                IPAddress       = theNewProperties.IPAddress;
                ForceInitialise = true;
            }

            if (theNewProperties.Port != -1 && theNewProperties.Port != Port)
            {
                Port            = theNewProperties.Port;
                ForceInitialise = true;
            }

            if (theNewProperties.Backlog != -1 && theNewProperties.Backlog != Backlog)
            {
                Backlog         = theNewProperties.Backlog;
                ForceInitialise = true;
            }

            if (theNewProperties.LoggingLevel != -1 && theNewProperties.LoggingLevel != LoggingLevel)
            {
                LoggingLevel = theNewProperties.LoggingLevel;
            }

            if (theNewProperties.NICIndex != -1 && theNewProperties.NICIndex != NICIndex)
            {
                NICIndex = theNewProperties.NICIndex;
            }

            int NICIndexSearch = LocalIPAddressList.GetIndex(IPAddress);

            if (NICIndexSearch != -1)
            {
                NICIndex = NICIndexSearch;
            }

            if (theNewProperties.WriteSubscriptions != null)
            {
                List <Subscription> NewSubscriptions = new List <Subscription>();

                foreach (Subscription Subscription in theNewProperties.WriteSubscriptions)
                {
                    Subscription Search = WriteSubscriptions.FirstOrDefault(ne => ne.Guid == Subscription.Guid);

                    if (Search == null)
                    {
                        NewSubscriptions.Add(Subscription);
                    }
                    else
                    {
                        if (Subscription.Merge(Search, Subscription))
                        {
                            SubscriptionsUpdatedFlag = true;
                        }
                    }
                }

                if (NewSubscriptions.Count() > 0)
                {
                    SubscriptionsUpdatedFlag = true;
                }

                foreach (Subscription Subscription in NewSubscriptions)
                {
                    Subscription.Guid   = System.Guid.NewGuid().ToString();
                    Subscription.Event += m_Listener.OnSubscriptionEvent;
                }

                List <Subscription> List = WriteSubscriptions == null ? new List <Subscription>() : WriteSubscriptions.ToList();

                List.AddRange(NewSubscriptions);
                WriteSubscriptions = List.ToArray();
            }

            if (EventsUpdatedFlag)
            {
                EventsUpdated?.Invoke();
            }

            if (SubscriptionsUpdatedFlag)
            {
                SubscriptionsUpdated?.Invoke();
            }

            if (ForceInitialise)
            {
                InitialiseSetup();
            }
        }
Esempio n. 8
0
        internal void UpdateProperties(SocketClientProperties theNewProperties)
        {
            bool SubscriptionsUpdatedFlag = false;
            bool EventsUpdatedFlag        = false;

            bool ForceInitialise = false;

            if (theNewProperties.Guid == null || theNewProperties.Guid != Guid)
            {
                return;
            }

            if (theNewProperties.ReadEvent != null)
            {
                if (Event.Merge(ReadEvent, theNewProperties.ReadEvent))
                {
                    EventsUpdatedFlag = true;
                }
            }

            if (theNewProperties.HostName != null && theNewProperties.HostName != HostName)
            {
                HostName        = theNewProperties.HostName;
                ForceInitialise = true;
            }
            if (theNewProperties.Port != -1 && theNewProperties.Port != Port)
            {
                Port            = theNewProperties.Port;
                ForceInitialise = true;
            }

            if (theNewProperties.LoggingLevel != -1 && theNewProperties.LoggingLevel != LoggingLevel)
            {
                LoggingLevel = theNewProperties.LoggingLevel;
            }

            if (theNewProperties.WriteSubscriptions != null)
            {
                List <Subscription> NewSubscriptions = new List <Subscription>();

                foreach (Subscription Subscription in theNewProperties.WriteSubscriptions)
                {
                    Subscription Search = WriteSubscriptions.FirstOrDefault(ne => ne.Guid == Subscription.Guid);

                    if (Search == null)
                    {
                        NewSubscriptions.Add(Subscription);
                    }
                    else
                    {
                        if (Subscription.Merge(Search, Subscription))
                        {
                            SubscriptionsUpdatedFlag = true;
                        }
                    }
                }

                if (NewSubscriptions.Count() > 0)
                {
                    SubscriptionsUpdatedFlag = true;
                }

                foreach (Subscription Subscription in NewSubscriptions)
                {
                    Subscription.Guid   = System.Guid.NewGuid().ToString();
                    Subscription.Event += OnSubscriptionEvent;
                }

                List <Subscription> List = WriteSubscriptions == null ? new List <Subscription>() : WriteSubscriptions.ToList();

                List.AddRange(NewSubscriptions);
                WriteSubscriptions = List.ToArray();
            }

            if (EventsUpdatedFlag)
            {
                EventsUpdated?.Invoke();
            }

            if (SubscriptionsUpdatedFlag)
            {
                SubscriptionsUpdated?.Invoke();
            }

            if (ForceInitialise)
            {
                InitialiseSetup();
            }
        }