/// <summary> /// Calculates the <see cref="EventWarningType"/> enum value from the given <see cref="Event"/>. /// </summary> /// <param name="e">The <see cref="Event"/> to check the warnings of.</param> /// <returns>The applicable <see cref="EventWarningType"/> for the given <see cref="Event"/>.</returns> private async Task <EventWarningType> GetWarningTypeFromEvent(Event e) { var staff = await _context.EventStaff .Include(x => x.Staff) .Include(x => x.Event) .Where(x => x.EventId == e.Id && !x.Event.Cancelled) .Select(x => x.Staff) .ToListAsync(); EventWarningType type = EventWarningType.None; if (!staff.Any(x => x.FirstAider)) { type = EventWarningType.NoFirstAider; } var bookings = await _context.Guests .Where(x => x.EventId == e.Id) .ToListAsync(); int count = bookings.Count / 10; if (staff.Count <= count) { type |= EventWarningType.InsufficientStaff; } return(type); }
/// <summary> /// Gets a <see cref="List{T}"/> of <see cref="string"/> definitions for the warnings /// that apply to the given value of <paramref name="type"/>. /// <para/> /// See also: <seealso cref="EventWarningType"/> /// </summary> /// <param name="type">The <see cref="EventWarningType"/> given.</param> /// <returns>A list of definitions for the warnings in <paramref name="type"/></returns> public static List <string> GetWarnings(EventWarningType type) { List <string> outList = new List <string>(); foreach (EventWarningType warI in Types.Keys) { if (ContainsWarning(type, warI)) { outList.Add(Types[warI]); } } return(outList); }
/// <summary> /// <see cref="ISpcmsService.GetEventLog(int,int,SrcType,DateTime?,DateTime?,EventWarningType,string)"/> /// </summary> public async Task <ListBaseResponse <EventLogResponse> > GetEventLog(int pageNo, int pageSize, SrcType srcType, DateTime?startTime, DateTime?endTime, EventWarningType eventType, string srcName) { var data = await _spcmsApi.AppendFormatToHik("/api/scpms/v1/eventLogs/searches") .SetHiKSecreity() .PostAsync(new { pageNo, pageSize, srcType = srcType.ToString(), startTime = startTime?.TimeToString(), endTime = endTime?.TimeToString(), eventType, srcName }) .ReciveJsonResultAsync <HikVisionResponse <ListBaseResponse <EventLogResponse> > >(); return(data?.Data); }
public async Task <ListBaseResponse <EventLogResponse> > GetEventLog(int pageNo, int pageSize, SrcType srcType, DateTime?startTime, DateTime?endTime, EventWarningType eventType, string srcName) { return(await _spcmsService.GetEventLog(pageNo, pageSize, srcType, startTime, endTime, eventType, srcName)); }
/// <summary> /// Checks whether the given <see cref="EventWarningType"/> contains the value given /// via <paramref name="secondType"/>. /// </summary> /// <param name="type">The initial <see cref="EventWarningType"/></param> /// <param name="secondType">The <see cref="EventWarningType"/> to check against the first.</param> /// <returns>True if the first <see cref="EventWarningType"/> contains the second; false otherwise.</returns> public static bool ContainsWarning(EventWarningType type, EventWarningType secondType) { return((type & secondType) == secondType); }