초기커밋
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
internal class BuildingRentalHistoryAction : EntityActionBase
|
||||
{
|
||||
public BuildingRentalHistoryAction(BuildingRentalHistory owner)
|
||||
: base(owner)
|
||||
{ }
|
||||
|
||||
public override async Task<Result> onInit()
|
||||
{
|
||||
var result = new Result();
|
||||
return await Task.FromResult(result);
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public Result tryLoadBuildingRentalHistoryFromDoc(BuildingRentalHistoryDoc buildingRentalHistoryDoc)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var building_rental_history = getOwner() as BuildingRentalHistory;
|
||||
NullReferenceCheckHelper.throwIfNull(building_rental_history, () => $"building_rental_history is null !!!");
|
||||
|
||||
var building_rental_history_attribute = building_rental_history.getEntityAttribute<BuildingRentalHistoryAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(building_rental_history_attribute, () => $"building_rental_history_attribute is null !!!");
|
||||
|
||||
if (!building_rental_history_attribute.copyEntityAttributeFromDoc(buildingRentalHistoryDoc))
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!! to:{building_rental_history_attribute.getTypeName()}, from:{buildingRentalHistoryDoc.getTypeName()} : {this.getTypeName()}";
|
||||
result.setFail(ServerErrorCode.DynamoDbDocCopyToEntityAttributeFailed, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
internal class BuildingRentalHistoryAgentAction : EntityActionBase
|
||||
{
|
||||
ConcurrentBag<BuildingRentalHistory> m_building_rental_historys = new();
|
||||
|
||||
public BuildingRentalHistoryAgentAction(Building owner)
|
||||
: base(owner)
|
||||
{ }
|
||||
|
||||
public override async Task<Result> onInit()
|
||||
{
|
||||
var result = new Result();
|
||||
return await Task.FromResult(result);
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public async Task<Result> tryLoadBuildingRentalHistoryFromDb(int buildingMetaId)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
var db_client = server_logic.getDynamoDbClient();
|
||||
|
||||
var doc = new BuildingRentalHistoryDoc();
|
||||
doc.setCombinationKeyForPK(buildingMetaId.ToString());
|
||||
|
||||
var error_code = doc.onApplyPKSK();
|
||||
if (error_code.isFail())
|
||||
{
|
||||
err_msg = $"Failed to onApplyPKSK() !!! : {error_code.toBasicString()}";
|
||||
result.setFail(error_code, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
var query_config = db_client.makeQueryConfigWithPKSKBySKBeginWith(doc.getPK(), BuildingRentalHistoryDoc.getPrefixOfSK());
|
||||
|
||||
(result, var read_docs) = await db_client.simpleQueryDocTypesWithQueryOperationConfig<BuildingRentalHistoryDoc>(query_config);
|
||||
if (result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to simpleQueryDocTypesWithQueryOperationConfig() !!! : {result.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
var building = getOwner() as Building;
|
||||
NullReferenceCheckHelper.throwIfNull(building, () => $"building is null !!!");
|
||||
|
||||
foreach (var read_doc in read_docs)
|
||||
{
|
||||
var building_rental_history = new BuildingRentalHistory(building);
|
||||
await building_rental_history.onInit();
|
||||
|
||||
var building_rental_history_action = building_rental_history.getEntityAction<BuildingRentalHistoryAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(building_rental_history_action, () => $"building_rental_history_action is null !!!");
|
||||
|
||||
result = building_rental_history_action.tryLoadBuildingRentalHistoryFromDoc(read_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to tryLoadBuildingRentalHistoryFromDoc() !!! : {result.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
var building_rental_history_attribute = building_rental_history.getEntityAttribute<BuildingRentalHistoryAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(building_rental_history_attribute, () => $"building_rental_history_attribute is null !!!");
|
||||
|
||||
m_building_rental_historys.Add(building_rental_history);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<List<BuildingRentalHistoryInfo>> getBuildingRentalHistoryInfos()
|
||||
{
|
||||
var building_rental_story_infos = new List<BuildingRentalHistoryInfo>();
|
||||
|
||||
foreach (var building_rental_history in m_building_rental_historys)
|
||||
{
|
||||
var building_rental_history_info = await building_rental_history.toBuildingRentalHistoryInfo();
|
||||
building_rental_story_infos.Add(building_rental_history_info);
|
||||
}
|
||||
|
||||
return building_rental_story_infos;
|
||||
}
|
||||
|
||||
public void addBuildingRentalHistory(BuildingRentalHistory buildingRentalHistory)
|
||||
{
|
||||
m_building_rental_historys.Add(buildingRentalHistory);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user