CodeLiturgy.Dashboard/CodeLiturgy/Artefacts/AccountArtefact.cs

73 lines
1.9 KiB
C#
Raw Normal View History

2021-12-06 02:49:27 +03:00
using System;
using BlueWest.Core.ComponentSystem;
using BlueWest.Tools;
2022-08-13 20:15:43 +03:00
using PerformanceSolution.Core.System;
2021-12-06 02:49:27 +03:00
namespace PerformanceSolution.Artefacts
{
public enum CommandRequestEventType
{
GetUsers, GetUserById
}
public readonly struct CommandRequestEvent
{
public readonly CommandRequestEventType CommandRequestEventType;
public readonly int Id;
public CommandRequestEvent(CommandRequestEventType commandRequestEventType, int id = 0)
{
CommandRequestEventType = commandRequestEventType;
Id = id;
}
}
public class AccountArtefact : Artefact, EventListener<CommandRequestEvent>
{
public AccountArtefact()
{
Frequency = ArtefactFrequency.T10Hz;
LoopEnabled = false;
}
protected override void Start()
{
_eventManager.EventStartListening(this);
}
private void GetAllUsersInConsole()
{
2022-08-04 03:59:04 +03:00
/*var data = MemoryData.UserList;
2021-12-06 02:49:27 +03:00
if (data != null)
{
Console.WriteLine(MemoryData.UserList.ToString());
2022-08-04 03:59:04 +03:00
}*/
2021-12-06 02:49:27 +03:00
}
private void GetUserByIdInConsole(int id)
{
2022-08-04 03:59:04 +03:00
/*var user = MemoryData.GetUserById(id);
2021-12-06 02:49:27 +03:00
if (user != null)
{
Console.WriteLine(user.ToString());
2022-08-04 03:59:04 +03:00
}*/
2021-12-06 02:49:27 +03:00
}
public void OnEvent(CommandRequestEvent commandRequestEvent)
{
switch (commandRequestEvent.CommandRequestEventType)
{
case CommandRequestEventType.GetUserById:
GetUserByIdInConsole(commandRequestEvent.Id);
break;
case CommandRequestEventType.GetUsers:
GetAllUsersInConsole();
break;
}
}
}
}