protected override async void Run(Session session, DBSaveBatchRequest message, Action <DBSaveBatchResponse> reply) { DBSaveBatchResponse response = new DBSaveBatchResponse(); try { DBCacheComponent dbCacheComponent = Game.Scene.GetComponent <DBCacheComponent>(); if (message.CollectionName == "") { message.CollectionName = message.Entitys[0].GetType().Name; } if (message.NeedCache) { foreach (Entity entity in message.Entitys) { dbCacheComponent.AddToCache(entity, message.CollectionName); } } await dbCacheComponent.AddBatch(message.Entitys, message.CollectionName); reply(response); } catch (Exception e) { ReplyError(response, e, reply); } }
protected async ETVoid RunAsync(Session session, DBSaveBatchRequest message, Action <DBSaveBatchResponse> reply) { DBSaveBatchResponse response = new DBSaveBatchResponse(); try { DBCacheComponent dbCacheComponent = Game.Scene.GetComponent <DBCacheComponent>(); if (string.IsNullOrEmpty(message.CollectionName)) { message.CollectionName = message.Components[0].GetType().Name; } if (message.NeedCache) { foreach (ComponentWithId component in message.Components) { dbCacheComponent.AddToCache(component, message.CollectionName); } } await dbCacheComponent.AddBatch(message.Components, message.CollectionName); reply(response); } catch (Exception e) { ReplyError(response, e, reply); } }
protected override async void Run(Session session, DBSaveBatchRequest message, Action <DBSaveBatchResponse> reply) { DBSaveBatchResponse response = new DBSaveBatchResponse(); try { DBCacheComponent dbCacheComponent = Game.Scene.GetComponent <DBCacheComponent>(); if (string.IsNullOrEmpty(message.CollectionName)) { message.CollectionName = message.Disposers[0].GetType().Name; } if (message.NeedCache) { foreach (Disposer disposer in message.Disposers) { dbCacheComponent.AddToCache(disposer, message.CollectionName); } } await dbCacheComponent.AddBatch(message.Disposers, message.CollectionName); reply(response); } catch (Exception e) { ReplyError(response, e, reply); } }
protected override async ETTask Run(Session session, DBSaveBatchRequest request, DBSaveBatchResponse response, Action reply) { try { DBCacheComponent dbCacheComponent = Game.Scene.GetComponent <DBCacheComponent>(); if (string.IsNullOrEmpty(request.CollectionName)) { request.CollectionName = request.Components[0].GetType().Name; } if (request.NeedCache) { foreach (ComponentWithId component in request.Components) { dbCacheComponent.AddToCache(component, request.CollectionName); } } await dbCacheComponent.AddBatch(request.Components, request.CollectionName); reply(); await ETTask.CompletedTask; } catch (Exception e) { ReplyError(response, e, reply); } }