초기커밋
This commit is contained in:
@@ -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