Final touches
This commit is contained in:
parent
6bda3d3dfb
commit
7075b5fdef
|
@ -219,6 +219,12 @@ private async void EventReceived(Event received)
|
|||
{
|
||||
if (received.UserId.HasValue is false) return;
|
||||
|
||||
var eventTime = received.Time.ToDateTime().ToLocalTime().TimeOfDay;
|
||||
|
||||
var interval = _accessIntervals.FirstOrDefault(a => a.End >= eventTime && a.Start <= eventTime);
|
||||
|
||||
if (interval is null) return;
|
||||
|
||||
_lastAccessGrantedUserId = received.UserId.Value;
|
||||
|
||||
if (RemoveUserAlThenDoorOpened)
|
||||
|
@ -228,20 +234,13 @@ private async void EventReceived(Event received)
|
|||
await Context.SetEventsDescriptionAsync(new List<int> { (int)_lastAccessGrantedId }, "Ignore");
|
||||
}
|
||||
|
||||
var eventTime = received.Time.ToDateTime().ToLocalTime().TimeOfDay;
|
||||
_lastAccessGrantedId = received.Id;
|
||||
|
||||
var interval = _accessIntervals.FirstOrDefault(a => a.End >= eventTime && a.Start <= eventTime);
|
||||
if (_lastAccessGrantTimer is not null && _lastAccessGrantTimer.Enabled) return;
|
||||
|
||||
if (interval is not null)
|
||||
{
|
||||
_lastAccessGrantedId = received.Id;
|
||||
var timeToIntervalEnd = interval.End - eventTime;
|
||||
|
||||
if (_lastAccessGrantTimer is not null && _lastAccessGrantTimer.Enabled) return;
|
||||
|
||||
var timeToIntervalEnd = interval.End - eventTime;
|
||||
|
||||
StartLastAccessGrantTimer(timeToIntervalEnd);
|
||||
}
|
||||
StartLastAccessGrantTimer(timeToIntervalEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -260,17 +259,6 @@ private async Task RemoveUserAccessLevelAsync(Event received)
|
|||
|
||||
try
|
||||
{
|
||||
var accessTime = received.Time.ToDateTime().ToLocalTime().TimeOfDay;
|
||||
|
||||
var interval = _accessIntervals.FirstOrDefault(a => a.End >= accessTime && a.Start <= accessTime);
|
||||
|
||||
if (interval is null)
|
||||
{
|
||||
Context.LogDebug($"Al interval by access time not found. Access time: {accessTime}");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var userAccessLevels = await Context.GetUserAccessLevelsAsync(_lastAccessGrantedUserId.Value);
|
||||
|
||||
var userAccessLevel = userAccessLevels.FirstOrDefault(a => a.Name == interval.Name);
|
||||
|
|
Loading…
Reference in New Issue