public ActionResult <List <AreaEvent> > getAreaEvents(AreaEventType eventType, Enums.ControlledAreas area)
        {
            //_logger.LogInformation($"getAreaEvents() Entered.");
            List <AreaEvent> events = EventLogger.getAreaEvents(eventType, area);

            return(events);
        }
Esempio n. 2
0
        /// <summary>
        /// Get Events for a specific Area
        /// </summary>
        /// <param name="area">The Area for which to return events</param>
        /// <param name="eventType">The type of even such as Motion, SwitchOn, SwitchOff, e.g. All Event types are returned for this area when no parameter is passed.</param>
        /// <returns>Events for a specific Area</returns>
        internal static List <AreaEvent> getAreaEvents(AreaEventType eventType = AreaEventType.None, Enums.ControlledAreas area = Enums.ControlledAreas.None)

        {
            List <AreaEvent> retVal = new List <AreaEvent>();

            if (File.Exists(_xmlPath))
            {
                lock (lockObject)
                {
                    using (StreamReader sr = new StreamReader(_xmlPath))
                    {
                        string _typeSearch = eventType.ToString();
                        string _searchArea = area.ToString();
                        while (!sr.EndOfStream)
                        {
                            string line = sr.ReadLine();
                            try
                            {
                                //eventType:area:deviceName:eventStatus:mcuIPAddress:startTick:endTick:cameraHost:dataFile
                                //No parameters specified so add this event
                                if (area == Enums.ControlledAreas.None && eventType == AreaEventType.None)
                                {
                                    retVal.Add(new AreaEvent(line));
                                }
                                else                                 //if (eventType == AreaEventType.None) {
                                {
                                    //Area parameter was passed so only search in second field for Area
                                    int    p1         = line.IndexOf(':');
                                    string _eventType = line.Substring(0, p1);

                                    if (eventType == AreaEventType.None || _typeSearch == _eventType)
                                    {
                                        if (area == Enums.ControlledAreas.None)
                                        {
                                            retVal.Add(new AreaEvent(line));
                                        }
                                        else
                                        {
                                            int p2 = line.IndexOf(':', p1 + 1);

                                            string _area = line.Substring(p1 + 1, p2 - p1 - 1);
                                            if (_area == _searchArea)
                                            {
                                                retVal.Add(new AreaEvent(line));
                                            }
                                        }
                                    }
                                }
                            }
                            finally { }
                        }
                    }
                    //retVal.Add(new AreaEvent(line));
                }
            }
            return(retVal);
        }
Esempio n. 3
0
        internal void setState(int _swState, bool logEvent = false)
        {
            swState = _swState;
            AreaEventType aet = swState > 0 ? AreaEventType.SwitchOn : AreaEventType.SwitchOff;
            AreaEvent     evt = new AreaEvent(area, deviceName, aet, mcu.ipAddress, AreaEventStatus.Complete);

            Events.Add(evt);
            EventLogger.logEvent(evt);
        }
Esempio n. 4
0
        internal void setState(int _swState, bool logEvent = false)
        {
            swState = _swState;
            if (swState > 0)
            {
                lastOnState = DateTime.Now.Ticks;
            }
            else
            {
                lastOffState = DateTime.Now.Ticks;
            }

            AreaEventType aet = swState > 0 ? AreaEventType.SwitchOn : AreaEventType.SwitchOff;
            AreaEvent     evt = new AreaEvent(area, deviceName, aet, mcu.ipAddress, AreaEventStatus.Complete);

            Events.Add(evt);
            EventLogger.logEvent(evt);
        }
Esempio n. 5
0
        public AreaEvent(Enums.ControlledAreas areaId, string _deviceName, AreaEventType _eventType, string _mcuIPAddress, AreaEventStatus _eventStatus = AreaEventStatus.InProgress)
        {
            this.area       = areaId;
            this.deviceName = _deviceName;
            this._startTick = DateTime.Now.Ticks;

            this.eventType    = _eventType;
            this.mcuIPAddress = _mcuIPAddress;
            this.eventStatus  = _eventStatus;

            this.dataFile = string.Empty;

            if (_eventStatus == AreaEventStatus.Complete)
            {
                _endTick = _startTick;
            }
            else if (_eventStatus == AreaEventStatus.InProgress)
            {
                _endTick = 0;
            }
        }
Esempio n. 6
0
 public AreaEventArgs(IPlayer p, AreaEventType eventType)
 {
     Player    = p;
     EventType = eventType;
 }