|
|
@@ -7,13 +7,13 @@ using MongoDB.Driver;
|
|
|
namespace Model
|
|
|
{
|
|
|
[ObjectSystem]
|
|
|
- public class DbSaveBatchTaskSystem : ObjectSystem<DBSaveBatchTask>, IAwake<List<Entity>, string, TaskCompletionSource<bool>>
|
|
|
+ public class DbSaveBatchTaskSystem : ObjectSystem<DBSaveBatchTask>, IAwake<List<Disposer>, string, TaskCompletionSource<bool>>
|
|
|
{
|
|
|
- public void Awake(List<Entity> entitys, string collectionName, TaskCompletionSource<bool> tcs)
|
|
|
+ public void Awake(List<Disposer> disposers, string collectionName, TaskCompletionSource<bool> tcs)
|
|
|
{
|
|
|
DBSaveBatchTask self = this.Get();
|
|
|
|
|
|
- self.Entitys = entitys;
|
|
|
+ self.Disposers = disposers;
|
|
|
self.CollectionName = collectionName;
|
|
|
self.Tcs = tcs;
|
|
|
}
|
|
|
@@ -23,7 +23,7 @@ namespace Model
|
|
|
{
|
|
|
public string CollectionName { get; set; }
|
|
|
|
|
|
- public List<Entity> Entitys;
|
|
|
+ public List<Disposer> Disposers;
|
|
|
|
|
|
public TaskCompletionSource<bool> Tcs;
|
|
|
|
|
|
@@ -31,9 +31,9 @@ namespace Model
|
|
|
{
|
|
|
DBComponent dbComponent = Game.Scene.GetComponent<DBComponent>();
|
|
|
|
|
|
- foreach (Entity entity in this.Entitys)
|
|
|
+ foreach (Disposer disposer in this.Disposers)
|
|
|
{
|
|
|
- if (entity == null)
|
|
|
+ if (disposer == null)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
@@ -41,12 +41,12 @@ namespace Model
|
|
|
try
|
|
|
{
|
|
|
// 执行保存数据库任务
|
|
|
- await dbComponent.GetCollection(this.CollectionName).ReplaceOneAsync(s => s.Id == entity.Id, entity, new UpdateOptions { IsUpsert = true });
|
|
|
+ await dbComponent.GetCollection(this.CollectionName).ReplaceOneAsync(s => s.Id == disposer.Id, disposer, new UpdateOptions { IsUpsert = true });
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
- Log.Debug($"{entity.GetType().Name} {entity.ToJson()}" + e.ToString());
|
|
|
- this.Tcs.SetException(new Exception($"保存数据失败! {CollectionName} {this.Entitys.ListToString()}", e));
|
|
|
+ Log.Debug($"{disposer.GetType().Name} {disposer.ToJson()} {e}");
|
|
|
+ this.Tcs.SetException(new Exception($"保存数据失败! {CollectionName} {this.Disposers.ListToString()}", e));
|
|
|
}
|
|
|
}
|
|
|
this.Tcs.SetResult(true);
|