This commit is contained in:
Justinas K. 2022-01-03 11:36:54 +02:00
commit 1790f65436
1 changed files with 21 additions and 20 deletions

View File

@ -1,17 +1,13 @@
using System;
using System.Threading.Tasks;
using MDP.SID.Scripting.Service;
using GrpcScriptService;
using Newtonsoft.Json;
using System.Threading;
using System.Net.Http;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MDP.SID.Scripting.Grpc;
using Newtonsoft.Json;
using Event = MDP.SID.Scripting.Grpc.Event;
using Timer = System.Timers.Timer;
public class Interval
@ -24,25 +20,25 @@ public class Interval
private readonly Interval[] _accessIntervals =
{
// Explanation -> TimeSpan(int hours, int minutes, int seconds)
new Interval {Start = new TimeSpan(16, 55, 0), End = new TimeSpan(17, 00, 0), Name = "Breakfast"},
new Interval {Start = new TimeSpan(17, 00, 0), End = new TimeSpan(17, 05, 0), Name = "Lunch"},
new Interval {Start = new TimeSpan(17, 05, 0), End = new TimeSpan(17, 10, 0), Name = "Dinner"}
new() {Start = new TimeSpan(16, 23, 0), End = new TimeSpan(16, 24, 0), Name = "Breakfast"},
new() {Start = new TimeSpan(16, 24, 0), End = new TimeSpan(16, 25, 0), Name = "Lunch"},
new() {Start = new TimeSpan(16, 25, 0), End = new TimeSpan(16, 26, 0), Name = "Dinner"}
};
private readonly string[] _canteenDoors =
{
"CANTEEN", "CANTEEN-DOOR-R-TUR-2 Ent"
"Mr-1&3", "CANTEEN-DOOR-R-TUR-2 Ent"
};
private string _path;
private SemaphoreSlim _semaphoreSlim = new(1);
private readonly SemaphoreSlim _semaphoreSlim = new(1);
public readonly TimeSpan AccessLevelsResetTime = new(17, 11, 0);
public readonly TimeSpan AccessLevelsResetTime = new(16, 27, 0);
private Timer _timer;
private static ConcurrentDictionary<int, IList<string>> _failedAddOrUpdate = new();
private static readonly ConcurrentDictionary<int, IList<string>> _failedAddOrUpdate = new();
private async Task ResetUsersAccessLevelsAsync()
{
@ -63,7 +59,12 @@ private async Task ResetUsersAccessLevelsAsync()
var updateEntities = accessLevels
.Where(a => alNames.Contains(a.Name))
.Select(a => new EntityUpdate { Id = a.Id, Update = true });
.Select(a => new EntityUpdate { Id = a.Id, Update = true })
.ToList();
updateEntities.AddRange(accessLevels
.Where(a => alNames.Contains(a.Name) is false)
.Select(a => new EntityUpdate { Id = a.Id}));
var text = await File.ReadAllTextAsync(_path);