sign out events by THEIR ids, not YOURS 🤦
This commit is contained in:
parent
7afdef665a
commit
d88ee494fa
29
Program.cs
29
Program.cs
@ -26,6 +26,7 @@ namespace director
|
||||
private static readonly AutoResetEvent _signal = new AutoResetEvent(false);
|
||||
private const int concurrentWorkers = 5;
|
||||
private static readonly ConcurrentBag<Guid> workerIds = new ConcurrentBag<Guid>();
|
||||
private static readonly ConcurrentDictionary<string, Guid> occurenceHandlers = new ConcurrentDictionary<string, Guid>();
|
||||
static void Main(string[] args)
|
||||
{
|
||||
if (!File.Exists("appsettings.json"))
|
||||
@ -92,29 +93,18 @@ namespace director
|
||||
if ((s.Showtime - TimeSpan.FromDays(1)) - DateTime.Now <= calendarNaptime)
|
||||
{
|
||||
var copy = JsonConvert.DeserializeObject<schedulable.Scheduled>(JsonConvert.SerializeObject(s));
|
||||
if(!occurenceHandlers.ContainsKey(copy.Occurrence._event.Uid) || !workerIds.Contains(occurenceHandlers[copy.Occurrence._event.Uid]))
|
||||
{
|
||||
workQueue.Enqueue(copy);
|
||||
_signal.Set();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"calendars checked, looks like event {copy.Occurrence._event.Uid} thing is handled");
|
||||
}
|
||||
}
|
||||
}
|
||||
Console.WriteLine("calendars checked");
|
||||
// #if (DEBUG)
|
||||
// //if(true)
|
||||
// {
|
||||
// Console.WriteLine("debug test");
|
||||
|
||||
// var psuedo = new schedulable.Scheduled();
|
||||
// psuedo.Showtime = DateTime.Now + TimeSpan.FromMinutes(30);
|
||||
// // foreach(var a in scratch.agenda){
|
||||
// // Console.WriteLine(a.Occurrence._event.Summary);
|
||||
// // }
|
||||
// var partiallyCopiable = scratch.agenda?.First(a => a.Occurrence._event.Summary == "Good Morning, Phyrexia (in the morning)!");
|
||||
// psuedo.Occurrence = partiallyCopiable.Occurrence;
|
||||
// psuedo.Occurrence.OccurrenceStart = psuedo.Showtime;
|
||||
// psuedo.Occurrence.OccurrenceEnd = psuedo.Showtime;
|
||||
// workQueue.Enqueue(psuedo);
|
||||
// _signal.Set();
|
||||
// }
|
||||
// #endif
|
||||
}
|
||||
|
||||
private static async Task checkCalendar(string calendarUri)
|
||||
@ -164,7 +154,8 @@ namespace director
|
||||
continue;
|
||||
}
|
||||
todo.HandledBy = threadId;
|
||||
Console.WriteLine($"signing it out, {todo.HandledBy}");
|
||||
occurenceHandlers[todo.Occurrence._event.Uid] = threadId;
|
||||
Console.WriteLine($"signing it out. i'm {todo.HandledBy}, handling {todo.Occurrence._event.Uid}");
|
||||
|
||||
todo.Configuration = findConfig(todo.Occurrence.CalendarSourceName, todo.Occurrence._event.Summary);
|
||||
if (todo.Configuration == null)
|
||||
|
Loading…
Reference in New Issue
Block a user