|
| 1 | +// Licensed to the .NET Foundation under one or more agreements. |
| 2 | +// The .NET Foundation licenses this file to you under the Apache 2.0 License |
| 3 | +// See the LICENSE file in the project root for more information. |
| 4 | +// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone |
| 5 | + |
| 6 | +using Longbow.Tasks; |
| 7 | + |
| 8 | +namespace BootstrapBlazor.Server.Services; |
| 9 | + |
| 10 | +class MockOnlineContributor(IDispatchService<Contributor> dispatchService) : BackgroundService |
| 11 | +{ |
| 12 | + /// <summary> |
| 13 | + /// 运行任务 |
| 14 | + /// </summary> |
| 15 | + /// <param name="stoppingToken"></param> |
| 16 | + /// <returns></returns> |
| 17 | + protected override Task ExecuteAsync(CancellationToken stoppingToken) |
| 18 | + { |
| 19 | + TaskServicesManager.GetOrAdd("OnlineSheet", (provider, token) => |
| 20 | + { |
| 21 | + dispatchService.Dispatch(new DispatchEntry<Contributor>() |
| 22 | + { |
| 23 | + Name = "OnlineSheet-Demo", |
| 24 | + Entry = new Contributor() |
| 25 | + { |
| 26 | + Name = "Argo Zhang", |
| 27 | + Avatar = "/images/Argo-C.png", |
| 28 | + Description = "正在更新单元格 A8", |
| 29 | + Data = new UniverSheetData() |
| 30 | + { |
| 31 | + CommandName = "UpdateRange", |
| 32 | + Data = new |
| 33 | + { |
| 34 | + Range = "A8", |
| 35 | + Value = $"{DateTime.Now: yyyy-MM-dd HH:mm:ss} Argo 更新此单元格" |
| 36 | + } |
| 37 | + } |
| 38 | + } |
| 39 | + }); |
| 40 | + return Task.CompletedTask; |
| 41 | + }, TriggerBuilder.Build(Cron.Secondly(5))); |
| 42 | + |
| 43 | + return Task.CompletedTask; |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +/// <summary> |
| 48 | +/// Contributor |
| 49 | +/// </summary> |
| 50 | +public class Contributor |
| 51 | +{ |
| 52 | + /// <summary> |
| 53 | + /// Gets or sets Name |
| 54 | + /// </summary> |
| 55 | + public string? Name { get; set; } |
| 56 | + |
| 57 | + /// <summary> |
| 58 | + /// Gets or sets Avatar |
| 59 | + /// </summary> |
| 60 | + public string? Avatar { get; set; } |
| 61 | + |
| 62 | + /// <summary> |
| 63 | + /// Gets or sets Description |
| 64 | + /// </summary> |
| 65 | + public string? Description { get; set; } |
| 66 | + |
| 67 | + /// <summary> |
| 68 | + /// Gets or sets Sheet data |
| 69 | + /// </summary> |
| 70 | + public UniverSheetData? Data { get; set; } |
| 71 | +} |
0 commit comments