Skip to content

Commit

Permalink
adds object tracking (#398)
Browse files Browse the repository at this point in the history
Co-authored-by: Oğuzhan Koral <45078678+oguzhankoral@users.noreply.github.com>
  • Loading branch information
dogukankaratas and oguzhankoral authored Nov 21, 2024
1 parent 85abeaf commit 1e5cca5
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,22 @@ private void SubscribeToTeklaEvents()
_events.Register();
}

// subscribes the all changes in a modelobject
private void ModelHandler_OnChange(List<ChangeData> changes)
{
foreach (var change in changes)
{
if (change.Object is { } modelObj)
{
ChangedObjectIds[modelObj.Identifier.ID.ToString()] = 1;
ChangedObjectIds[modelObj.Identifier.GUID.ToString()] = 1;
}
}

if (changes.Count > 0)
{
_idleManager.SubscribeToIdle(nameof(TeklaSendBinding), () => RunExpirationChecks());
// directly calling the RunExpirationChecks, not triggering the idle
// TODO: Figure out how idleing works in Tekla
Task.FromResult(RunExpirationChecks());
}
}

Expand Down Expand Up @@ -183,7 +186,7 @@ private async Task RunExpirationChecks()

foreach (SenderModelCard modelCard in senders)
{
var intersection = modelCard.SendFilter.NotNull().RefreshObjectIds().Intersect(objectIdsList).ToList();
var intersection = modelCard.SendFilter.NotNull().SelectedObjectIds.Intersect(objectIdsList).ToList();
var isExpired = intersection.Count != 0;
if (isExpired)
{
Expand All @@ -192,7 +195,8 @@ private async Task RunExpirationChecks()
}

await Commands.SetModelsExpired(expiredSenderIds).ConfigureAwait(false);
ChangedObjectIds = new();

ChangedObjectIds = new ConcurrentDictionary<string, byte>();
}

private bool _disposed;
Expand Down

0 comments on commit 1e5cca5

Please sign in to comment.