public FilteredGroupTypes ( List |
||
configuredGroupTypes | List |
The current group types. |
Результат | List |
/// <summary> /// Gets the checkin status. /// </summary> /// <param name="checkInState">State of the check in.</param> /// <returns></returns> public static CheckinStatus GetCheckinStatus(CheckInState checkInState) { KioskDevice kiosk = checkInState.Kiosk; List <int> configuredGroupTypeIds = checkInState.ConfiguredGroupTypes; bool hasGroupTypes = kiosk.FilteredGroupTypes(configuredGroupTypeIds).Any(); if (!hasGroupTypes) { return(CheckinStatus.Inactive); } if (IsTemporarilyClosed(kiosk, configuredGroupTypeIds, checkInState)) { return(CheckinStatus.TemporarilyClosed); } else if (IsClosed(kiosk, configuredGroupTypeIds, checkInState)) { return(CheckinStatus.Closed); } else { return(CheckinStatus.Active); } }
/// <summary> /// Reads the device by id. /// </summary> /// <param name="id">The id.</param> /// <param name="configuredGroupTypes">The configured group types.</param> /// <returns></returns> public static KioskDevice Read(int id, List <int> configuredGroupTypes) { string cacheKey = KioskDevice.CacheKey(id); ObjectCache cache = Rock.Web.Cache.RockMemoryCache.Default; KioskDevice device = cache[cacheKey] as KioskDevice; // If the kioskdevice is currently inactive, but has a next active time prior to now, force a refresh if (device != null && device.FilteredGroupTypes(configuredGroupTypes).Count > 0 && !device.HasLocations(configuredGroupTypes)) { if (device.KioskGroupTypes.Select(g => g.NextActiveTime).Min().CompareTo(RockDateTime.Now) < 0) { device = null; } } if (device != null) { return(device); } else { using (var rockContext = new RockContext()) { var campusLocations = new Dictionary <int, int>(); Rock.Web.Cache.CampusCache.All() .Where(c => c.LocationId.HasValue) .Select(c => new { CampusId = c.Id, LocationId = c.LocationId.Value }) .ToList() .ForEach(c => campusLocations.Add(c.CampusId, c.LocationId)); var deviceModel = new DeviceService(rockContext) .Queryable("Locations") .Where(d => d.Id == id) .FirstOrDefault(); if (deviceModel != null) { device = new KioskDevice(deviceModel); foreach (Location location in deviceModel.Locations) { LoadKioskLocations(device, location, campusLocations, rockContext); } var cachePolicy = new CacheItemPolicy(); cachePolicy.AbsoluteExpiration = DateTimeOffset.Now.AddSeconds(60); cache.Set(cacheKey, device, cachePolicy); return(device); } } } return(null); }
/// <summary> /// Reads the device by id. /// </summary> /// <param name="id">The id.</param> /// <param name="configuredGroupTypes">The configured group types.</param> /// <returns></returns> public static KioskDevice Read(int id, List <int> configuredGroupTypes) { string cacheKey = KioskDevice.CacheKey(id); ObjectCache cache = MemoryCache.Default; KioskDevice device = cache[cacheKey] as KioskDevice; // If the kioskdevice is currently inactive, but has a next active time prior to now, force a refresh if (device != null && device.FilteredGroupTypes(configuredGroupTypes).Count > 0 && !device.HasLocations(configuredGroupTypes)) { if (device.KioskGroupTypes.Select(g => g.NextActiveTime).Min().CompareTo(DateTimeOffset.Now) < 0) { device = null; } } if (device != null) { return(device); } else { var deviceModel = new DeviceService().Get(id); if (deviceModel != null) { device = new KioskDevice(deviceModel); using (new Rock.Data.UnitOfWorkScope()) { foreach (Location location in deviceModel.Locations) { LoadKioskLocations(device, location); } } var cachePolicy = new CacheItemPolicy(); cachePolicy.AbsoluteExpiration = DateTimeOffset.Now.AddSeconds(60); cache.Set(cacheKey, device, cachePolicy); return(device); } } return(null); }