예제 #1
0
        public List <AlarmEvent> ViewEvents(int UserLevel = 0)
        {
            List <AlarmEvent> result = new List <AlarmEvent>();

            foreach (var alarmEvent in AlarmEvents.FindAll(x => x.MinUserLevelToRemove < UserLevel))
            {
                result.Add(new AlarmEvent
                {
                    AlarmID = alarmEvent.AlarmID,
                    EndTime = new DateTime(alarmEvent.EndTime.Year,
                                           alarmEvent.EndTime.Month,
                                           alarmEvent.EndTime.Day,
                                           alarmEvent.EndTime.Hour,
                                           alarmEvent.EndTime.Minute,
                                           alarmEvent.EndTime.Second),
                    StartTime = new DateTime(alarmEvent.StartTime.Year,
                                             alarmEvent.StartTime.Month,
                                             alarmEvent.StartTime.Day,
                                             alarmEvent.StartTime.Hour,
                                             alarmEvent.StartTime.Minute,
                                             alarmEvent.StartTime.Second),
                    MinUserLevelToRemove = alarmEvent.MinUserLevelToRemove
                });
                if (alarmEvent.EndTime != DateTime.MaxValue)
                {
                    AlarmEvents.Remove(alarmEvent);
                }
            }

            return(result);
        }
예제 #2
0
 public void RemoveEvent(AlarmEvent alarmEvent, int levelSecurity = 0)
 {
     if (alarmEvent.MinUserLevelToRemove > levelSecurity)
     {
         throw new ArgumentException(string.Format("Don't have permission to remove alarm {0}", alarmEvent.AlarmID));
     }
     else
     {
         AlarmEvents.Remove(alarmEvent);
     }
 }