116 lines
4.6 KiB
C#
116 lines
4.6 KiB
C#
using Google.Protobuf;
|
|
using Google.Protobuf.WellKnownTypes;
|
|
|
|
|
|
using ServerCore;
|
|
using ServerBase;
|
|
using ServerCommon;
|
|
using ServerCommon.BusinessLogDomain;
|
|
using MetaAssets;
|
|
|
|
|
|
namespace GameServer;
|
|
|
|
public class DBQQuestPeriodRepeatReadAll : QueryExecutorBase
|
|
{
|
|
private string m_combination_key_for_pk = string.Empty;
|
|
private string m_pk = string.Empty;
|
|
|
|
private readonly List<QuestPeriodRepeatCheckDoc> m_to_quest_period_repeat_doc = new();
|
|
|
|
public DBQQuestPeriodRepeatReadAll(string combinationKeyForPK /*onwer_guid*/)
|
|
: base(typeof(DBQQuestPeriodRepeatReadAll).Name)
|
|
{
|
|
m_combination_key_for_pk = combinationKeyForPK;
|
|
}
|
|
|
|
//===================================================================================================
|
|
// DB 쿼리 직전에 준비해야 할 로직들을 작성한다.
|
|
//===================================================================================================
|
|
public override Task<Result> onPrepareQuery()
|
|
{
|
|
var result = new Result();
|
|
|
|
var player = getOwner();
|
|
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
|
|
|
var doc = new QuestPeriodRepeatCheckDoc(m_combination_key_for_pk);
|
|
var error_code = doc.onApplyPKSK();
|
|
if (error_code.isFail())
|
|
{
|
|
var err_msg = $"Failed to onApplyPKSK() !!! : {error_code.toBasicString()} - {toBasicString()}, {player.toBasicString()}";
|
|
result.setFail(error_code, err_msg);
|
|
|
|
Log.getLogger().error(result.toBasicString());
|
|
return Task.FromResult(result);
|
|
}
|
|
|
|
m_pk = doc.getPK();
|
|
|
|
return Task.FromResult(result);
|
|
}
|
|
|
|
//===================================================================================================
|
|
// onPrepareQuery()를 성공할 경우 호출된다.
|
|
//===================================================================================================
|
|
public override async Task<Result> onQuery()
|
|
{
|
|
var result = new Result();
|
|
var err_msg = string.Empty;
|
|
|
|
var query_batch = getQueryBatch();
|
|
NullReferenceCheckHelper.throwIfNull(query_batch, () => "query_batch is null !!!");
|
|
|
|
var db_connector = query_batch.getDynamoDbConnector();
|
|
|
|
var owner = getOwner();
|
|
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
|
|
|
var quest_period_repeat_check_attribute = owner.getEntityAttribute<QuestPeriodRepeatCheckAttribute>();
|
|
NullReferenceCheckHelper.throwIfNull(quest_period_repeat_check_attribute, () => "quest_period_repeat_check_attribute is null !!!");
|
|
|
|
var query_config = db_connector.makeQueryConfigForReadByPKSK(m_pk);
|
|
(result, var read_docs) = await db_connector.simpleQueryDocTypesWithQueryOperationConfig<QuestPeriodRepeatCheckDoc>(query_config, eventTid: query_batch.getTransId());
|
|
if (result.isFail())
|
|
{
|
|
//데이터 없으면 여기서 그냥 메모리에만 넣어준다.
|
|
Log.getLogger().warn($"QuestPeriodRepeatCheckDoc not exitst, so make new Data {result.toBasicString()}");
|
|
|
|
return new();
|
|
}
|
|
m_to_quest_period_repeat_doc.AddRange(read_docs);
|
|
|
|
var quest_action = owner.getEntityAction<QuestAction>();
|
|
NullReferenceCheckHelper.throwIfNull(quest_action, () => "quest_action is null !!!");
|
|
|
|
foreach (var read_doc in read_docs)
|
|
{
|
|
var set_result = quest_action.setPeriodRepeatQuestFromDoc(read_doc);
|
|
if (set_result.isFail())
|
|
{
|
|
Log.getLogger().error(result.toBasicString());
|
|
continue;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
//===================================================================================================
|
|
// DB 쿼리를 성공하고, doFnCommit()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
|
//===================================================================================================
|
|
public override Task onQueryResponseCommit()
|
|
{
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
//===================================================================================================
|
|
// DB 쿼리를 실패하고, doFnRollback()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
|
//===================================================================================================
|
|
public override Task onQueryResponseRollback(Result errorResult)
|
|
{
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
private new Player? getOwner() => getQueryBatch()?.getLogActor() as Player;
|
|
} |