초기커밋
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 BuildingProfitHistoryAction : EntityActionBase
|
||||
{
|
||||
public BuildingProfitHistoryAction(BuildingProfitHistory 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 tryLoadBuildingProfitHistoryFromDoc(BuildingProfitHistoryDoc buildingProfitHistoryDoc)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var building_profit_history = getOwner() as BuildingProfitHistory;
|
||||
NullReferenceCheckHelper.throwIfNull(building_profit_history, () => $"building_profit_history is null !!!");
|
||||
|
||||
var building_profit_history_attribute = building_profit_history.getEntityAttribute<BuildingProfitHistoryAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(building_profit_history_attribute, () => $"building_profit_history_attribute is null !!!");
|
||||
|
||||
if (!building_profit_history_attribute.copyEntityAttributeFromDoc(buildingProfitHistoryDoc))
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!! to:{building_profit_history_attribute.getTypeName()}, from:{buildingProfitHistoryDoc.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 BuildingProfitHistoryAgentAction : EntityActionBase
|
||||
{
|
||||
ConcurrentBag<BuildingProfitHistory> m_building_profit_historys = new();
|
||||
|
||||
public BuildingProfitHistoryAgentAction(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> tryLoadBuildingProfitHistoryFromDb(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 BuildingProfitHistoryDoc();
|
||||
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(), BuildingProfitHistoryDoc.getPrefixOfSK());
|
||||
|
||||
(result, var read_docs) = await db_client.simpleQueryDocTypesWithQueryOperationConfig<BuildingProfitHistoryDoc>(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_profit_history = new BuildingProfitHistory(building);
|
||||
await building_profit_history.onInit();
|
||||
|
||||
var building_profit_history_action = building_profit_history.getEntityAction<BuildingProfitHistoryAction>();
|
||||
NullReferenceCheckHelper.throwIfNull(building_profit_history_action, () => $"building_profit_history_attribute is null !!!");
|
||||
|
||||
result = building_profit_history_action.tryLoadBuildingProfitHistoryFromDoc(read_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to tryLoadBuildingProfitHistoryFromDoc() !!! : {result.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
var building_profit_history_attribute = building_profit_history.getEntityAttribute<BuildingProfitHistoryAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(building_profit_history_attribute, () => $"building_profit_history_attribute is null !!!");
|
||||
|
||||
m_building_profit_historys.Add(building_profit_history);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<BuildingProfitHistoryInfo> getBuildingProfitHistoryInfos()
|
||||
{
|
||||
var building_profit_story_infos = new List<BuildingProfitHistoryInfo>();
|
||||
|
||||
foreach (var building_profit_history in m_building_profit_historys)
|
||||
{
|
||||
var building_profit_history_info = building_profit_history.toBuildingProfitHistoryInfo();
|
||||
building_profit_story_infos.Add(building_profit_history_info);
|
||||
}
|
||||
|
||||
return building_profit_story_infos;
|
||||
}
|
||||
|
||||
public void addBuildingProfitHistory(BuildingProfitHistory buildingProfitHistory)
|
||||
{
|
||||
m_building_profit_historys.Add(buildingProfitHistory);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
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 BuildingProfitHistory : EntityBase
|
||||
{
|
||||
public BuildingProfitHistory(Building building)
|
||||
: base(EntityType.BuildingProfitHistory, building)
|
||||
{
|
||||
}
|
||||
|
||||
public override async Task<Result> onInit()
|
||||
{
|
||||
addEntityAttribute(new BuildingProfitHistoryAttribute(this));
|
||||
addEntityAction(new BuildingProfitHistoryAction(this));
|
||||
|
||||
return await base.onInit();
|
||||
}
|
||||
|
||||
public override string toBasicString()
|
||||
{
|
||||
return $"{this.getTypeName()}, BuildingMetaId:{getOriginEntityAttribute<BuildingFloorAttribute>()?.BuildingMetaId}, Floor:{getOriginEntityAttribute<BuildingFloorAttribute>()?.Floor}";
|
||||
}
|
||||
|
||||
public override string toSummaryString()
|
||||
{
|
||||
return $"{this.getTypeName()}, {getEntityAttribute<BuildingFloorAttribute>()?.toBasicString()}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
internal static class BuildingProfitHistoryHelper
|
||||
{
|
||||
public static BuildingProfitHistoryInfo toBuildingProfitHistoryInfo(this BuildingProfitHistory buildingProfitHistory)
|
||||
{
|
||||
var building_profit_history_attribute = buildingProfitHistory.getEntityAttribute<BuildingProfitHistoryAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(building_profit_history_attribute, () => $"building_profit_history_attribute is null !!!");
|
||||
|
||||
var building_profit_history_info = new BuildingProfitHistoryInfo
|
||||
{
|
||||
HistoryDate = building_profit_history_attribute.ProfitTime.ToTimestamp(),
|
||||
Floor = (int)building_profit_history_attribute.Floor,
|
||||
ProfitHistoryType = building_profit_history_attribute.ProfitHistoryType,
|
||||
FloorProfit = new FloorProfitInfo()
|
||||
};
|
||||
|
||||
foreach (var (currency_type, currency_amount) in building_profit_history_attribute.Profits)
|
||||
{
|
||||
var money = new Money();
|
||||
money.Amount = currency_amount;
|
||||
|
||||
building_profit_history_info.FloorProfit.Profits.Add((int)currency_type, money);
|
||||
}
|
||||
|
||||
return building_profit_history_info;
|
||||
}
|
||||
|
||||
public static async Task<(Result, BuildingProfitHistory?, DynamoDbDocBase?)> tryMakeBuildingProfitHistory(Building building, int buildingMetaId, int floor, DateTime profitTime, ProfitHistoryType profitHistoryType, Dictionary<CurrencyType, double> profits)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var building_profit_history = new BuildingProfitHistory(building);
|
||||
await building_profit_history.onInit();
|
||||
|
||||
var building_profit_history_attribute = building_profit_history.getEntityAttribute<BuildingProfitHistoryAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(building_profit_history_attribute, () => $"building_profit_history_attribute is null !!!");
|
||||
|
||||
building_profit_history_attribute.BuildingMetaId = buildingMetaId;
|
||||
building_profit_history_attribute.Floor = floor;
|
||||
building_profit_history_attribute.ProfitTime = profitTime;
|
||||
building_profit_history_attribute.ProfitHistoryType = profitHistoryType;
|
||||
building_profit_history_attribute.Profits = profits;
|
||||
building_profit_history_attribute.newEntityAttribute();
|
||||
|
||||
(result, var building_profit_history_doc) = await building_profit_history_attribute.toDocBase();
|
||||
if (result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to toDocBase() !!! : {result.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
|
||||
return (result, null, null);
|
||||
}
|
||||
|
||||
return (result, building_profit_history, building_profit_history_doc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static ServerMessage.Types;
|
||||
|
||||
namespace GameServer
|
||||
{
|
||||
internal static class BuildingProfitHistoryNotifyHelper
|
||||
{
|
||||
public static bool send_GS2GS_NTF_ADD_BUILDING_PROFIT_HISTORY(BuildingProfitHistory buildingProfitHistory)
|
||||
{
|
||||
var server_logic = GameServerApp.getServerLogic();
|
||||
|
||||
var building_profit_history_attribute = buildingProfitHistory.getEntityAttribute<BuildingProfitHistoryAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(building_profit_history_attribute, () => $"building_profit_history_attribute is null !!!");
|
||||
|
||||
var message = new ServerMessage();
|
||||
message.NtfAddBuildingProfitHistory = new GS2GS_NTF_ADD_BUILDING_PROFIT_HISTORY();
|
||||
|
||||
message.NtfAddBuildingProfitHistory.ExceptServerName = server_logic.getServerName();
|
||||
message.NtfAddBuildingProfitHistory.BuildingMetaId = building_profit_history_attribute.BuildingMetaId;
|
||||
message.NtfAddBuildingProfitHistory.Floor = building_profit_history_attribute.Floor;
|
||||
message.NtfAddBuildingProfitHistory.ProfitTime = building_profit_history_attribute.ProfitTime.ToTimestamp();
|
||||
message.NtfAddBuildingProfitHistory.ProfitHistoryType = building_profit_history_attribute.ProfitHistoryType;
|
||||
message.NtfAddBuildingProfitHistory.FloorProfit = new FloorProfitInfo();
|
||||
|
||||
foreach (var (currency_type, currency_amount) in building_profit_history_attribute.Profits)
|
||||
{
|
||||
var money = new Money();
|
||||
money.Amount = currency_amount;
|
||||
|
||||
message.NtfAddBuildingProfitHistory.FloorProfit.Profits.Add((int)currency_type, money);
|
||||
}
|
||||
|
||||
var rabbit_mq = server_logic.getRabbitMqConnector() as RabbitMQ4Game;
|
||||
NullReferenceCheckHelper.throwIfNull(rabbit_mq, () => $"rabbit_mq is null !!!");
|
||||
|
||||
rabbit_mq.sendMessageToExchangeAllGame(message);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user