Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append output to the table using MQ #1767

Closed
zhang1446802857 opened this issue Feb 28, 2025 · 1 comment
Closed

Append output to the table using MQ #1767

zhang1446802857 opened this issue Feb 28, 2025 · 1 comment

Comments

@zhang1446802857
Copy link

Hello. My current requirement is to summarize logs into tables for display, but when I add new content through mq, multiple tables will be output. I know I can clear it, but I have so many tables that I can't clear everything at once.
` public class ProjectConsoleService(IEventBus eventBus) : IHostedService
{
private readonly IEventBus eventBus = eventBus;

    private Table _logTable;
    private LiveDisplay _live;

    public Task StartAsync(CancellationToken cancellationToken)
    {
        eventBus.Subscribe<Event>(LogConsoleUI);
        ProjectUI();
        return Task.CompletedTask;
    }

    public Task StopAsync(CancellationToken cancellationToken)
    {
        return Task.CompletedTask;
    }

    public void ProjectUI()
    {
        var table = new Table { Expand = true, Title = new TableTitle("VerEasyCore", Color.Red) };
        table.Border(TableBorder.Double);

        table.AddColumn(new TableColumn(new Text($"{ConsoleSettings.ProjectName}", Color.Red) { Justification = Justify.Center }));
        table.AddColumn(new TableColumn(new Text($"服务启动日志", Color.Red) { Justification = Justify.Center }));
        table.AddColumn(new TableColumn(new Text($"1446802857@qq.com", Color.Red) { Justification = Justify.Center }));

        var services = string.Join("\n", ConsoleSettings.ServiceNames);
        Panel servicePanel = new(new Text(services, Color.Red) { Justification = Justify.Left })
        {
            Border = BoxBorder.Heavy,
            BorderStyle = Color.SeaGreen1,
            Expand = true,
            Header = new PanelHeader("服务集合").Centered(),
        };

        Panel descPanel = new(new Text(@"这是一个基于.NET-Core的易开发的框架,附vue3前端框架。提供了一个高效可扩展的API程序。支持JWT认证、数据库操作、日志记录、异步处理等特性,能够满足大多数业务需求。该项目可以与前端应用、移动应用和其他服务进行无缝集成,为开发者提供灵活、高效的解决方案。", Color.DodgerBlue1))
        {
            Border = BoxBorder.Heavy,
            BorderStyle = Color.SeaGreen1,
            Expand = true,
            Header = new PanelHeader("项目描述").Centered()
        };

        table.AddRow(servicePanel, new Text("1"), descPanel);

        var logTable = new Table { Expand = true };
        logTable.AddColumns(new TableColumn(new Text("日志输出", Color.Red)) { Alignment = Justify.Center });
        table.Border(TableBorder.Double);

        _logTable = logTable;
        _live = AnsiConsole.Live(_logTable);

        AnsiConsole.Write(table);
    }

    private void LogConsoleUI(Event @event)
    {
        _logTable.AddRow($"[SeaGreen1]{@event.MessageMQ}[/]");

        _live.Start(ctx =>
        {
            ctx.Refresh();
            Thread.Sleep(1000);
        });
    }
}

`

@github-project-automation github-project-automation bot moved this to Todo 🕑 in Spectre Console Feb 28, 2025
@spectreconsole spectreconsole locked and limited conversation to collaborators Feb 28, 2025
@patriksvensson patriksvensson converted this issue into a discussion Feb 28, 2025
@github-project-automation github-project-automation bot moved this from In Progress 👨‍💻 to Done 🚀 in Spectre Console Feb 28, 2025
@github-project-automation github-project-automation bot moved this from Todo 🕑 to In Progress 👨‍💻 in Spectre Console Feb 28, 2025
@patriksvensson patriksvensson converted this issue into a discussion Feb 28, 2025
@github-project-automation github-project-automation bot moved this from Done 🚀 to In Progress 👨‍💻 in Spectre Console Feb 28, 2025
@patriksvensson patriksvensson converted this issue into a discussion Mar 3, 2025
@patriksvensson patriksvensson reopened this Mar 3, 2025
@github-project-automation github-project-automation bot moved this from Done 🚀 to In Progress 👨‍💻 in Spectre Console Mar 3, 2025
@github-project-automation github-project-automation bot moved this from In Progress 👨‍💻 to Done 🚀 in Spectre Console Mar 3, 2025
@patriksvensson
Copy link
Contributor

For some reason I cannot seem to move this over to our Q/A discussion forum (getting an error from GitHub), so please open this question there instead.

@github-project-automation github-project-automation bot moved this from In Progress 👨‍💻 to Done 🚀 in Spectre Console Mar 3, 2025
@patriksvensson patriksvensson reopened this Mar 3, 2025
@github-project-automation github-project-automation bot moved this from Done 🚀 to In Progress 👨‍💻 in Spectre Console Mar 3, 2025
@patriksvensson patriksvensson closed this as not planned Won't fix, can't repro, duplicate, stale Mar 3, 2025
@github-project-automation github-project-automation bot moved this from In Progress 👨‍💻 to Done 🚀 in Spectre Console Mar 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Status: Done 🚀
Development

No branches or pull requests

2 participants