42 lines
1.5 KiB
C#
42 lines
1.5 KiB
C#
|
using ET.EventType;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
namespace ET
|
|||
|
{
|
|||
|
public class VoucherLogComponentAwakeSystem : AwakeSystem<VoucherLogComponent>
|
|||
|
{
|
|||
|
public override void Awake(VoucherLogComponent self)
|
|||
|
{
|
|||
|
VoucherLogComponent.instance = self;
|
|||
|
}
|
|||
|
}
|
|||
|
public static class VoucherLogComponentSystem
|
|||
|
{
|
|||
|
class SavePer5Minute : AEvent<EventType.UpdatePer1MinuteOfDay>
|
|||
|
{
|
|||
|
public override async ETTask Run(UpdatePer1MinuteOfDay args)
|
|||
|
{
|
|||
|
using var listComponent = ListComponent<ETTask>.Create();
|
|||
|
foreach (var kv in VoucherLogComponent.instance.VoucherLogDic)
|
|||
|
{
|
|||
|
listComponent.List.Add(DBComponent.Instance.Save(kv.Value));
|
|||
|
}
|
|||
|
ETTaskHelper.WaitAll(listComponent.List).Coroutine();
|
|||
|
await ETTask.CompletedTask;
|
|||
|
}
|
|||
|
}
|
|||
|
public static void AddInfo(this VoucherLogComponent self,long id,string info)
|
|||
|
{
|
|||
|
if(!self.VoucherLogDic.TryGetValue(id,out var yuanBaoLog))
|
|||
|
{
|
|||
|
self.VoucherLogDic[id] = yuanBaoLog = EntityFactory.CreateWithId<VoucherLog>(self.DomainScene(),id);
|
|||
|
}
|
|||
|
var now = DateTime.UtcNow;
|
|||
|
int day = now.Year * 10000 + now.Month * 100 + now.Day;
|
|||
|
yuanBaoLog.logDic.TryGetValue(day, out string info_);
|
|||
|
yuanBaoLog.logDic[day] =$"{info_}{now:HH:mm:ss}: {info}\r\n";
|
|||
|
}
|
|||
|
}
|
|||
|
}
|