using ET.EventType; using System; using System.Collections.Generic; namespace ET { public class VoucherLogComponentAwakeSystem : AwakeSystem { public override void Awake(VoucherLogComponent self) { VoucherLogComponent.instance = self; } } public static class VoucherLogComponentSystem { class SavePer5Minute : AEvent { public override async ETTask Run(UpdatePer1MinuteOfDay args) { using ListComponent listComponent = ListComponent.Create(); foreach (KeyValuePair 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 VoucherLog yuanBaoLog)) { self.VoucherLogDic[id] = yuanBaoLog = EntityFactory.CreateWithId(self.DomainScene(),id); } DateTime 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"; } } }