초기커밋
This commit is contained in:
470
ServerCommon/Entity/Attribute/AccountAttribute.cs
Normal file
470
ServerCommon/Entity/Attribute/AccountAttribute.cs
Normal file
@@ -0,0 +1,470 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID_STRING = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
using System.Runtime.InteropServices;
|
||||
using Amazon.S3.Model;
|
||||
using Amazon.Runtime.Telemetry;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
|
||||
public class AccountAttribute : EntityAttributeBase, ICopyEntityAttributeFromMeta, ICopyEntityAttributeFromCache, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public AccountType AccountType { get; set; } = AccountType.None;
|
||||
[JsonProperty]
|
||||
public PlatformType PlatformType { get; set; } = PlatformType.None;
|
||||
[JsonProperty]
|
||||
public ACCOUNT_ID_STRING AccountIdString { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public ACCOUNT_ID AccountId { get; set; } = string.Empty;
|
||||
|
||||
|
||||
[JsonProperty]
|
||||
public string UserId { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public USER_GUID UserGuid { get; set; } = string.Empty;
|
||||
|
||||
|
||||
public UInt64 AccessToken { get; set; } = 0;
|
||||
public string SsoAccountAuthJWT { get; set; } = string.Empty;
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
public LanguageType LanguageType { get; set; } = LanguageType.None;
|
||||
|
||||
|
||||
public AccountCreationType AccountCreationType { get; set; } = AccountCreationType.Normal;
|
||||
public META_ID AccountCreationMetaId { get; set; } = 0;
|
||||
public AuthAdminLevelType AuthAdminLevelType { get; set; } = AuthAdminLevelType.None;
|
||||
|
||||
|
||||
public DateTime LoginDateTime { get; set; } = DateTimeHelper.MaxTime;
|
||||
public DateTime LogoutDateTime { get; set; } = DateTimeHelper.MaxTime;
|
||||
|
||||
|
||||
public NetworkAddress ToConnectGameServerAddress { get; set; } = new();
|
||||
public string ToConnectGameServerName { get; set; } = string.Empty;
|
||||
public string OtpForServerConnect { get; set; } = string.Empty;
|
||||
|
||||
|
||||
|
||||
public AccountAttribute(EntityBase owner)
|
||||
: base(owner, owner)
|
||||
{
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !! ");
|
||||
}
|
||||
|
||||
public USER_GUID newUserGuid()
|
||||
{
|
||||
UserGuid = System.Guid.NewGuid().ToString("N");
|
||||
return UserGuid;
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
AccountType = AccountType.None;
|
||||
PlatformType = PlatformType.None;
|
||||
AccountIdString = string.Empty;
|
||||
AccountId = string.Empty;
|
||||
AccessToken = 0;
|
||||
Password = string.Empty;
|
||||
UserId = string.Empty;
|
||||
UserGuid = string.Empty;
|
||||
LanguageType = LanguageType.None;
|
||||
AccountCreationType = AccountCreationType.None;
|
||||
AuthAdminLevelType = AuthAdminLevelType.None;
|
||||
LoginDateTime = DateTimeHelper.MaxTime;
|
||||
LogoutDateTime = DateTimeHelper.MaxTime;
|
||||
ToConnectGameServerAddress.reset();
|
||||
OtpForServerConnect = string.Empty;
|
||||
SsoAccountAuthJWT = string.Empty;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var cloned = new AccountAttribute(owner);
|
||||
cloned.AccountType = AccountType;
|
||||
cloned.PlatformType = PlatformType;
|
||||
cloned.AccountIdString = AccountIdString;
|
||||
cloned.AccountId = AccountId;
|
||||
cloned.AccessToken = AccessToken;
|
||||
cloned.Password = Password;
|
||||
cloned.UserId = UserId;
|
||||
cloned.UserGuid = UserGuid;
|
||||
cloned.LanguageType = LanguageType;
|
||||
cloned.AuthAdminLevelType = AuthAdminLevelType;
|
||||
cloned.AccountCreationType = AccountCreationType;
|
||||
cloned.LoginDateTime = LoginDateTime;
|
||||
cloned.LogoutDateTime = LogoutDateTime;
|
||||
cloned.ToConnectGameServerAddress.IP = ToConnectGameServerAddress.IP;
|
||||
cloned.ToConnectGameServerAddress.Port = ToConnectGameServerAddress.Port;
|
||||
cloned.OtpForServerConnect = OtpForServerConnect;
|
||||
cloned.SsoAccountAuthJWT = SsoAccountAuthJWT;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new AccountAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as AccountBaseDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new AccountBaseDoc(AccountId);
|
||||
|
||||
var origin_doc = getOriginDocBase<AccountAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var account_base_attrib = try_pending_doc.getAttrib<AccountBaseAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(account_base_attrib, () => $"account_base_attrib is null !!!");
|
||||
|
||||
account_base_attrib.AccountId = AccountId;
|
||||
account_base_attrib.UserGuid = UserGuid;
|
||||
account_base_attrib.Password = Password;
|
||||
account_base_attrib.LanguageType = LanguageType;
|
||||
account_base_attrib.AuthAdminLevelType = AuthAdminLevelType;
|
||||
account_base_attrib.AccountCreationType = AccountCreationType;
|
||||
account_base_attrib.AccountCreationMetaId = AccountCreationMetaId;
|
||||
account_base_attrib.LoginDateTime = LoginDateTime;
|
||||
account_base_attrib.LogoutDateTime = LogoutDateTime;
|
||||
account_base_attrib.AccessToken = AccessToken;
|
||||
account_base_attrib.SsoAccountAuthJWT = SsoAccountAuthJWT;
|
||||
|
||||
if(false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if(result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
NullReferenceCheckHelper.throwIfNull(to_query_doc, () => $"to_query_doc is null !!!");
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var other_account_attribute = otherEntityAttribute as AccountAttribute;
|
||||
if (null == other_account_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast AccountAttribute !!!, other_account_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
AccountId = other_account_attribute.AccountId;
|
||||
UserId = other_account_attribute.UserId;
|
||||
UserGuid = other_account_attribute.UserGuid;
|
||||
LanguageType = other_account_attribute.LanguageType;
|
||||
Password = other_account_attribute.Password;
|
||||
AuthAdminLevelType = other_account_attribute.AuthAdminLevelType;
|
||||
AccountCreationType = other_account_attribute.AccountCreationType;
|
||||
AccountCreationMetaId = other_account_attribute.AccountCreationMetaId;
|
||||
LoginDateTime = other_account_attribute.LoginDateTime;
|
||||
LogoutDateTime = other_account_attribute.LogoutDateTime;
|
||||
ToConnectGameServerAddress.IP = other_account_attribute.ToConnectGameServerAddress.IP;
|
||||
ToConnectGameServerAddress.Port = other_account_attribute.ToConnectGameServerAddress.Port;
|
||||
OtpForServerConnect = other_account_attribute.OtpForServerConnect;
|
||||
AccessToken = other_account_attribute.AccessToken;
|
||||
SsoAccountAuthJWT = other_account_attribute.SsoAccountAuthJWT;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_account_attribute.getTryPendingDocBase() as AccountBaseDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_account_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<AccountAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<AccountAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var account_base_attrib = origin_doc_base.getAttrib<AccountBaseAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(account_base_attrib, () => $"account_base_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
account_base_attrib.AccountId = AccountId;
|
||||
account_base_attrib.UserGuid = UserGuid;
|
||||
account_base_attrib.LanguageType = LanguageType;
|
||||
account_base_attrib.Password = Password;
|
||||
account_base_attrib.AuthAdminLevelType = AuthAdminLevelType;
|
||||
account_base_attrib.AccountCreationType = AccountCreationType;
|
||||
account_base_attrib.AccountCreationMetaId = AccountCreationMetaId;
|
||||
account_base_attrib.LoginDateTime = LoginDateTime;
|
||||
account_base_attrib.LogoutDateTime = LogoutDateTime;
|
||||
account_base_attrib.AccessToken = AccessToken;
|
||||
account_base_attrib.SsoAccountAuthJWT = SsoAccountAuthJWT;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromMeta(MetaAssets.IMetaData customMeta)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(customMeta, () => $"customMeta is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var err_msg = string.Empty;
|
||||
|
||||
bool is_success = false;
|
||||
|
||||
var test_user_create_data = customMeta as MetaAssets.TestUserCreateMetaData;
|
||||
if (null != test_user_create_data)
|
||||
{
|
||||
is_success = copyEntityAttributeFromTestUserCreateData(test_user_create_data);
|
||||
}
|
||||
|
||||
var user_create_data = customMeta as MetaAssets.UserCreateMetaData;
|
||||
if (null != user_create_data)
|
||||
{
|
||||
is_success = copyEntityAttributeFromUserCreateData(user_create_data);
|
||||
}
|
||||
|
||||
if (false == is_success)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromMeta() !!! : {customMeta.getTypeName()} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool copyEntityAttributeFromTestUserCreateData(MetaAssets.TestUserCreateMetaData customMeta)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(MetaAssets.TestUserCreateMetaData).Name;
|
||||
if (null == customMeta)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromTestUserCreateData() !!!, customMeta is null : {to_cast_string}";
|
||||
Log.getLogger().warn(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
Password = customMeta.Password;
|
||||
LanguageType = customMeta.Language;
|
||||
AccountCreationType = AccountCreationType.Test;
|
||||
AccountCreationMetaId = (UInt32)customMeta.MetaId;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool copyEntityAttributeFromUserCreateData(MetaAssets.UserCreateMetaData customMeta)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(MetaAssets.UserCreateMetaData).Name;
|
||||
if (null == customMeta)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromUserCreateData() !!!, customMeta is null : {to_cast_string}";
|
||||
Log.getLogger().warn(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
AccountCreationType = AccountCreationType.Normal;
|
||||
AccountCreationMetaId = (UInt32)customMeta.MetaId;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromCache(CacheBase? cacheBase)
|
||||
{
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(cacheBase, () => $"cacheBase is null !!!");
|
||||
var err_msg = string.Empty;
|
||||
var to_cast_string = typeof(LoginCache).Name;
|
||||
|
||||
var login_cache = cacheBase as LoginCache;
|
||||
if(null == login_cache)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromCache() !!!, login_cache is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Cache => Attribute
|
||||
//=====================================================================================
|
||||
AccountId = login_cache.AccountId;
|
||||
UserGuid = login_cache.UserGuid;
|
||||
LanguageType = login_cache.LanguageType;
|
||||
LoginDateTime = login_cache.LoginDateTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(docBase, () => $"docBase is null !!!");
|
||||
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(AccountBaseDoc).Name;
|
||||
|
||||
var account_base_doc = docBase as AccountBaseDoc;
|
||||
if (null == account_base_doc)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, account_base_doc is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<AccountAttribute>(account_base_doc);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
|
||||
var account_base_attrib = account_base_doc.getAttrib<AccountBaseAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(account_base_attrib, () => $"account_base_attrib is null !!!");
|
||||
AccountId = account_base_attrib.AccountId;
|
||||
Password = account_base_attrib.Password;
|
||||
UserGuid = account_base_attrib.UserGuid;
|
||||
LanguageType = account_base_attrib.LanguageType;
|
||||
AuthAdminLevelType = account_base_attrib.AuthAdminLevelType;
|
||||
AccountCreationType = account_base_attrib.AccountCreationType;
|
||||
AccountCreationMetaId = account_base_attrib.AccountCreationMetaId;
|
||||
LoginDateTime = account_base_attrib.LoginDateTime;
|
||||
AccessToken = account_base_attrib.AccessToken;
|
||||
SsoAccountAuthJWT = account_base_attrib.SsoAccountAuthJWT;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override string toBasicString()
|
||||
{
|
||||
return $"{base.toBasicString()}, UserGuid:{UserGuid}, AccountId:{AccountId}, UserId:{UserId}";
|
||||
}
|
||||
}
|
||||
|
||||
public class AccountAttributeTransactor : EntityAttributeTransactorBase<AccountAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public AccountAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase entityAttributeBase)
|
||||
{
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(entityAttributeBase, () => $"item is null !!! - {toBasicString()}");
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(AccountAttribute).Name;
|
||||
|
||||
var copy_from_account_attribute = entityAttributeBase as AccountAttribute;
|
||||
if (null == copy_from_account_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_account_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_account_attribute = getClonedEntityAttribute() as AccountAttribute;
|
||||
if (null == copy_to_account_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_account_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_account_attribute.AccountType = copy_from_account_attribute.AccountType;
|
||||
copy_to_account_attribute.AccountId = copy_from_account_attribute.AccountId;
|
||||
copy_to_account_attribute.AccessToken = copy_from_account_attribute.AccessToken;
|
||||
copy_to_account_attribute.UserId = copy_from_account_attribute.UserId;
|
||||
copy_to_account_attribute.UserGuid = copy_from_account_attribute.UserGuid;
|
||||
copy_to_account_attribute.LanguageType = copy_from_account_attribute.LanguageType;
|
||||
copy_to_account_attribute.AccountCreationType = copy_from_account_attribute.AccountCreationType;
|
||||
copy_to_account_attribute.AccountCreationMetaId = copy_from_account_attribute.AccountCreationMetaId;
|
||||
copy_to_account_attribute.AuthAdminLevelType = copy_from_account_attribute.AuthAdminLevelType;
|
||||
copy_to_account_attribute.LoginDateTime = copy_from_account_attribute.LoginDateTime;
|
||||
copy_to_account_attribute.LogoutDateTime = copy_from_account_attribute.LogoutDateTime;
|
||||
copy_to_account_attribute.ToConnectGameServerAddress.IP = copy_from_account_attribute.ToConnectGameServerAddress.IP;
|
||||
copy_to_account_attribute.ToConnectGameServerAddress.Port = copy_from_account_attribute.ToConnectGameServerAddress.Port;
|
||||
copy_to_account_attribute.OtpForServerConnect = copy_from_account_attribute.OtpForServerConnect;
|
||||
copy_to_account_attribute.SsoAccountAuthJWT = copy_from_account_attribute.SsoAccountAuthJWT;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
220
ServerCommon/Entity/Attribute/AiChatAttribute.cs
Normal file
220
ServerCommon/Entity/Attribute/AiChatAttribute.cs
Normal file
@@ -0,0 +1,220 @@
|
||||
using Newtonsoft.Json;
|
||||
using ServerCore; using ServerBase;
|
||||
using USER_GUID = System.String;
|
||||
using META_ID = System.UInt32;
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class AiChatAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public DateTime LastIncentiveProvideTime { get; set; } = new();
|
||||
|
||||
public AiChatAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
LastIncentiveProvideTime = new();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new AiChatAttribute(getOwner());
|
||||
cloned.LastIncentiveProvideTime = LastIncentiveProvideTime;
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new AiChatAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null");
|
||||
|
||||
var root_parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(root_parent, () => "root_parent is null");
|
||||
|
||||
var acoount_attribute = owner.getRootParent().getEntityAttribute<AccountAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(acoount_attribute, () => "acoount_attribute is null");
|
||||
|
||||
USER_GUID user_guid = acoount_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as AiChatDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new AiChatDoc(user_guid);
|
||||
var origin_doc = getOriginDocBase<AiChatAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var ai_chat_attrib = try_pending_doc.getAttrib<AiChatAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(ai_chat_attrib, () => $"ai_chat_attrib is null !!!");
|
||||
|
||||
ai_chat_attrib.LastIncentiveProvideTime = LastIncentiveProvideTime;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(AiChatDoc).Name;
|
||||
|
||||
var ai_chat_doc_base = docBase as AiChatDoc;
|
||||
if (null == ai_chat_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, ai_chat_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<AiChatAttribute>(ai_chat_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Doc, Attribute
|
||||
//=====================================================================================
|
||||
var ai_chat_attrib = ai_chat_doc_base.getAttrib<AiChatAttrib>();
|
||||
if (ai_chat_attrib == null)
|
||||
{
|
||||
err_msg = $"Failed to get ai chat attrib : {nameof(AiChatAttrib)}";
|
||||
result.setFail(ServerErrorCode.EntityAttributeIsNull, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
LastIncentiveProvideTime = ai_chat_attrib.LastIncentiveProvideTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var ai_chat_attribute = otherEntityAttribute as AiChatAttribute;
|
||||
if (null == ai_chat_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast Attribute !!!, ai_chat_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
LastIncentiveProvideTime = ai_chat_attribute.LastIncentiveProvideTime;
|
||||
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = ai_chat_attribute.getTryPendingDocBase() as AiChatDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
ai_chat_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<AiChatAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<AiChatAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var ai_chat_attrib = origin_doc_base.getAttrib<AiChatAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(ai_chat_attrib, () => $"ai_chat_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
ai_chat_attrib.LastIncentiveProvideTime = LastIncentiveProvideTime;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public class AiChatAttributeTransactor : EntityAttributeTransactorBase<AiChatAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public AiChatAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(AiChatAttribute).Name;
|
||||
|
||||
var copy_from_attribute = entityAttributeBase as AiChatAttribute;
|
||||
if (null == copy_from_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_ai_chat_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_attribute = getClonedEntityAttribute() as AiChatAttribute;
|
||||
if (null == copy_to_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_ai_chat_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_attribute.LastIncentiveProvideTime = copy_from_attribute.LastIncentiveProvideTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
287
ServerCommon/Entity/Attribute/AppearanceCustomizeAttribute.cs
Normal file
287
ServerCommon/Entity/Attribute/AppearanceCustomizeAttribute.cs
Normal file
@@ -0,0 +1,287 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
using Amazon.S3.Model;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID_STRING = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class AppearanceCustomizeAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public Int32 BasicStyle { get; set; } = 0;
|
||||
[JsonProperty]
|
||||
public Int32 BodyShape { get; set; } = 0;
|
||||
[JsonProperty]
|
||||
public Int32 HairStyle { get; set; } = 0;
|
||||
|
||||
public List<Int32> CustomValues { get; set; } = new();
|
||||
|
||||
|
||||
|
||||
public AppearanceCustomizeAttribute(EntityBase owner)
|
||||
: base(owner, owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
BasicStyle = 0;
|
||||
BodyShape = 0;
|
||||
HairStyle = 0;
|
||||
CustomValues.Clear();
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var cloned = new AppearanceCustomizeAttribute(owner);
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.BasicStyle = BasicStyle;
|
||||
cloned.BodyShape = BodyShape;
|
||||
cloned.HairStyle = HairStyle;
|
||||
cloned.CustomValues = CustomValues;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new AppearanceCustomizeAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as AppearanceCustomizeDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
(result, var owner_entity_type, var owner_guid) = onToOwnerEntity4Db(owner);
|
||||
if(result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
var to_copy_doc = new AppearanceCustomizeDoc(owner_entity_type, owner_guid);
|
||||
|
||||
var origin_doc = getOriginDocBase<AppearanceCustomizeAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<AppearanceCustomizeAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!!");
|
||||
|
||||
to_copy_doc_attrib.BasicStyle = BasicStyle;
|
||||
to_copy_doc_attrib.BodyShape = BodyShape;
|
||||
to_copy_doc_attrib.HairStyle = HairStyle;
|
||||
to_copy_doc_attrib.CustomValues = CustomValues;
|
||||
|
||||
if(false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if(result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
NullReferenceCheckHelper.throwIfNull(to_query_doc, () => $"to_query_doc is null !!!");
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public override (Result, OwnerEntityType, OWNER_GUID) onToOwnerEntity4Db(EntityBase ownerEntity)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner_entity_type = ownerEntity.getEntityType().toOwnerEntityType();
|
||||
if(OwnerEntityType.None == owner_entity_type)
|
||||
{
|
||||
return (result, OwnerEntityType.None, string.Empty);
|
||||
}
|
||||
|
||||
return (result, owner_entity_type, ownerEntity.onGetDbGuid());
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var other_appearance_customize_attribute = otherEntityAttribute as AppearanceCustomizeAttribute;
|
||||
if (null == other_appearance_customize_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast AppearanceCustomizeAttribute !!!, other_appearance_customize_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
BasicStyle = other_appearance_customize_attribute.BasicStyle;
|
||||
BodyShape = other_appearance_customize_attribute.BodyShape;
|
||||
HairStyle = other_appearance_customize_attribute.HairStyle;
|
||||
CustomValues = other_appearance_customize_attribute.CustomValues;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_appearance_customize_attribute.getTryPendingDocBase() as AppearanceCustomizeDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_appearance_customize_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<AppearanceCustomizeAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<AppearanceCustomizeAttribute>();
|
||||
if(null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var appearance_customize_attrib = origin_doc_base.getAttrib<AppearanceCustomizeAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(appearance_customize_attrib, () => $"appearance_customize_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
appearance_customize_attrib.BasicStyle = BasicStyle;
|
||||
appearance_customize_attrib.BodyShape = BodyShape;
|
||||
appearance_customize_attrib.HairStyle = HairStyle;
|
||||
appearance_customize_attrib.CustomValues = CustomValues;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(AppearanceCustomizeDoc).Name;
|
||||
|
||||
var appearance_customize_doc = docBase as AppearanceCustomizeDoc;
|
||||
if (null == appearance_customize_doc)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, appearance_customize_doc is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<AppearanceCustomizeAttribute>(appearance_customize_doc);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var appearance_customize_attrib = appearance_customize_doc.getAttrib<AppearanceCustomizeAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(appearance_customize_attrib, () => $"appearance_customize_attrib is null !!! - {toBasicString()}");
|
||||
|
||||
BasicStyle = appearance_customize_attrib.BasicStyle;
|
||||
BodyShape = appearance_customize_attrib.BodyShape;
|
||||
HairStyle = appearance_customize_attrib.HairStyle;
|
||||
CustomValues = appearance_customize_attrib.CustomValues;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class AppearanceCustomizeAttributeTransactor : EntityAttributeTransactorBase<AppearanceCustomizeAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public AppearanceCustomizeAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase entityAttributeBase)
|
||||
{
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(entityAttributeBase, () => $"entityAttributeBase is null !!!");
|
||||
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(AppearanceCustomizeAttribute).Name;
|
||||
|
||||
var copy_from_appearance_customize_attribute = entityAttributeBase as AppearanceCustomizeAttribute;
|
||||
if (null == copy_from_appearance_customize_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_appearance_customize_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_appearance_customize_attribute = getClonedEntityAttribute() as AppearanceCustomizeAttribute;
|
||||
if (null == copy_to_appearance_customize_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_appearance_customize_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_appearance_customize_attribute.BasicStyle = copy_from_appearance_customize_attribute.BasicStyle;
|
||||
copy_to_appearance_customize_attribute.BodyShape = copy_from_appearance_customize_attribute.BodyShape;
|
||||
copy_to_appearance_customize_attribute.HairStyle = copy_from_appearance_customize_attribute.HairStyle;
|
||||
copy_to_appearance_customize_attribute.CustomValues = copy_from_appearance_customize_attribute.CustomValues.ToList();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
274
ServerCommon/Entity/Attribute/BeaconShopItemAttribute.cs
Normal file
274
ServerCommon/Entity/Attribute/BeaconShopItemAttribute.cs
Normal file
@@ -0,0 +1,274 @@
|
||||
using Newtonsoft.Json;
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using BEACON_GUID = System.String;
|
||||
using META_ID = System.UInt32;
|
||||
using USER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
using Amazon.S3.Model;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class BeaconShopItemAttribute : ItemAttributeBase
|
||||
{
|
||||
[JsonProperty]
|
||||
public USER_GUID UserGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public BEACON_GUID BeaconGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public DateTime SellingFinishTime { get; set; } = new();
|
||||
|
||||
[JsonProperty]
|
||||
public double PriceForUnit { get; set; } = 0.0;
|
||||
|
||||
|
||||
public BeaconShopItemAttribute(ItemBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
base.onClear();
|
||||
|
||||
UserGuid = string.Empty;
|
||||
BeaconGuid = string.Empty;
|
||||
ItemGuid = string.Empty;
|
||||
SellingFinishTime = new();
|
||||
PriceForUnit = 0;
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner() as ItemBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var entity_of_owner_entity_type = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(entity_of_owner_entity_type, () => $"entity_of_owner_entity_type is null !!!");
|
||||
|
||||
var cloned = new BeaconShopItemAttribute(owner, entity_of_owner_entity_type);
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.UserGuid = UserGuid;
|
||||
cloned.BeaconGuid = BeaconGuid;
|
||||
cloned.SellingFinishTime = SellingFinishTime;
|
||||
cloned.PriceForUnit = PriceForUnit;
|
||||
|
||||
cloned.ItemGuid = ItemGuid;
|
||||
cloned.ItemMetaId = ItemMetaId;
|
||||
cloned.ItemStackCount = ItemStackCount;
|
||||
cloned.Level = Level;
|
||||
cloned.Attributes = Attributes.Select(x => x).ToList();
|
||||
cloned.EquipedIvenType = EquipedIvenType;
|
||||
cloned.EquipedPos = EquipedPos;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
var owner = getOwner() as ItemBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
return new BeaconShopItemAttributeTransactor(owner);
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as BeaconShopItemDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new BeaconShopItemDoc(getOwnerEntityType(), BeaconGuid, UserGuid, ItemGuid);
|
||||
|
||||
var origin_doc = getOriginDocBase<BeaconShopItemAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<BeaconShopItemAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!!");
|
||||
|
||||
to_copy_doc_attrib.BeaconGuid = BeaconGuid;
|
||||
to_copy_doc_attrib.SellingFinishTime = SellingFinishTime;
|
||||
to_copy_doc_attrib.PriceForUnit = PriceForUnit;
|
||||
|
||||
to_copy_doc_attrib.ItemGuid = ItemGuid;
|
||||
to_copy_doc_attrib.ItemMetaId = ItemMetaId;
|
||||
to_copy_doc_attrib.ItemStackCount = ItemStackCount;
|
||||
to_copy_doc_attrib.Level = Level;
|
||||
to_copy_doc_attrib.Attributes = Attributes.Select(x => x).ToList();
|
||||
to_copy_doc_attrib.EquipedIvenType = EquipedIvenType;
|
||||
to_copy_doc_attrib.EquipedPos = EquipedPos;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public override bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(BeaconShopItemDoc).Name;
|
||||
|
||||
var beacon_shop_doc_base = docBase as BeaconShopItemDoc;
|
||||
if (null == beacon_shop_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, beacon_shop_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<BeaconShopItemAttribute>(beacon_shop_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = beacon_shop_doc_base.getAttrib<BeaconShopItemAttrib>();
|
||||
if (doc_attrib == null)
|
||||
{
|
||||
err_msg = $"Failed to get beacon_shop attrib : {nameof(BeaconShopItemAttrib)}";
|
||||
result.setFail(ServerErrorCode.EntityAttributeIsNull, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
UserGuid = doc_attrib.UserGuid;
|
||||
BeaconGuid = doc_attrib.BeaconGuid;
|
||||
SellingFinishTime = doc_attrib.SellingFinishTime;
|
||||
PriceForUnit = doc_attrib.PriceForUnit;
|
||||
|
||||
ItemGuid = doc_attrib.ItemGuid;
|
||||
ItemMetaId = doc_attrib.ItemMetaId;
|
||||
ItemStackCount = doc_attrib.ItemStackCount;
|
||||
Level = doc_attrib.Level;
|
||||
Attributes = doc_attrib.Attributes.Select(x => x).ToList();
|
||||
EquipedIvenType = doc_attrib.EquipedIvenType;
|
||||
EquipedPos = doc_attrib.EquipedPos;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var beacon_shop_attribute = otherEntityAttribute as BeaconShopItemAttribute;
|
||||
if (null == beacon_shop_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast Attribute !!!, beacon_shop_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
UserGuid = beacon_shop_attribute.UserGuid;
|
||||
BeaconGuid = beacon_shop_attribute.BeaconGuid;
|
||||
SellingFinishTime = beacon_shop_attribute.SellingFinishTime;
|
||||
PriceForUnit = beacon_shop_attribute.PriceForUnit;
|
||||
|
||||
ItemGuid = beacon_shop_attribute.ItemGuid;
|
||||
ItemMetaId = beacon_shop_attribute.ItemMetaId;
|
||||
ItemStackCount = beacon_shop_attribute.ItemStackCount;
|
||||
Level = beacon_shop_attribute.Level;
|
||||
Attributes = beacon_shop_attribute.Attributes.Select(x => x).ToList();
|
||||
EquipedIvenType = beacon_shop_attribute.EquipedIvenType;
|
||||
EquipedPos = beacon_shop_attribute.EquipedPos;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = beacon_shop_attribute.getTryPendingDocBase() as BeaconShopItemDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
beacon_shop_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<BeaconShopItemAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<BeaconShopItemAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var beacon_shop_attrib = origin_doc_base.getAttrib<BeaconShopItemAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(beacon_shop_attrib, () => $"beaconshop_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
beacon_shop_attrib.UserGuid = UserGuid;
|
||||
beacon_shop_attrib.BeaconGuid = BeaconGuid;
|
||||
beacon_shop_attrib.SellingFinishTime = SellingFinishTime;
|
||||
beacon_shop_attrib.PriceForUnit = PriceForUnit;
|
||||
|
||||
beacon_shop_attrib.ItemGuid = ItemGuid;
|
||||
beacon_shop_attrib.ItemMetaId = ItemMetaId;
|
||||
beacon_shop_attrib.ItemStackCount = ItemStackCount;
|
||||
beacon_shop_attrib.Level = Level;
|
||||
beacon_shop_attrib.Attributes = Attributes.Select(x => x).ToList(); ;
|
||||
beacon_shop_attrib.EquipedIvenType = EquipedIvenType;
|
||||
beacon_shop_attrib.EquipedPos = EquipedPos;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public class BeaconShopItemAttributeTransactor : ItemAttributeBaseTransactor<BeaconShopItemAttribute>
|
||||
{
|
||||
public BeaconShopItemAttributeTransactor(ItemBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
235
ServerCommon/Entity/Attribute/BeaconShopProfileAttribute.cs
Normal file
235
ServerCommon/Entity/Attribute/BeaconShopProfileAttribute.cs
Normal file
@@ -0,0 +1,235 @@
|
||||
using Newtonsoft.Json;
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
using BEACON_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class BeaconShopProfileAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public BEACON_GUID BeaconGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public Int32 DailyRegisterCount { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public DateTime RegisterUpdateDay { get; set; } = new();
|
||||
|
||||
|
||||
public BeaconShopProfileAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
BeaconGuid = string.Empty;
|
||||
DailyRegisterCount = 0;
|
||||
RegisterUpdateDay = new();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new BeaconShopProfileAttribute(getOwner());
|
||||
cloned.BeaconGuid = BeaconGuid;
|
||||
cloned.DailyRegisterCount = DailyRegisterCount;
|
||||
cloned.RegisterUpdateDay = RegisterUpdateDay;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new BeaconShopProfileAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as BeaconShopProfileDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new BeaconShopProfileDoc(BeaconGuid);
|
||||
|
||||
var origin_doc = getOriginDocBase<BeaconShopProfileAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<BeaconShopProfileAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!!");
|
||||
|
||||
to_copy_doc_attrib.BeaconGuid = BeaconGuid;
|
||||
to_copy_doc_attrib.DailyRegisterCount = DailyRegisterCount;
|
||||
to_copy_doc_attrib.RegisterUpdateDay = RegisterUpdateDay;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(BeaconShopProfileDoc).Name;
|
||||
|
||||
var beacon_shop_profile_doc_base = docBase as BeaconShopProfileDoc;
|
||||
if (null == beacon_shop_profile_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, beacon_shop_profile_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<BeaconShopProfileAttribute>(beacon_shop_profile_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = beacon_shop_profile_doc_base.getAttrib<BeaconShopProfileAttrib>();
|
||||
if (doc_attrib == null)
|
||||
{
|
||||
err_msg = $"Failed to get beacon_shop attrib : {nameof(BeaconShopProfileAttrib)}";
|
||||
result.setFail(ServerErrorCode.EntityAttributeIsNull, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
BeaconGuid = doc_attrib.BeaconGuid;
|
||||
DailyRegisterCount = doc_attrib.DailyRegisterCount;
|
||||
RegisterUpdateDay = doc_attrib.RegisterUpdateDay;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var beacon_shop_profile_attribute = otherEntityAttribute as BeaconShopProfileAttribute;
|
||||
if (null == beacon_shop_profile_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast Attribute !!!, beacon_shop_profile_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
BeaconGuid = beacon_shop_profile_attribute.BeaconGuid;
|
||||
DailyRegisterCount = beacon_shop_profile_attribute.DailyRegisterCount;
|
||||
RegisterUpdateDay = beacon_shop_profile_attribute.RegisterUpdateDay;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = beacon_shop_profile_attribute.getTryPendingDocBase() as BeaconShopProfileDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
beacon_shop_profile_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<BeaconShopProfileAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<BeaconShopProfileAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var beacon_shop_profile_attrib = origin_doc_base.getAttrib<BeaconShopProfileAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(beacon_shop_profile_attrib, () => $"beacon_shop_profile_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
beacon_shop_profile_attrib.BeaconGuid = BeaconGuid;
|
||||
beacon_shop_profile_attrib.DailyRegisterCount = DailyRegisterCount;
|
||||
beacon_shop_profile_attrib.RegisterUpdateDay = RegisterUpdateDay;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public class BeaconShopProfileAttributeTransactor : EntityAttributeTransactorBase<BeaconShopProfileAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public BeaconShopProfileAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(BeaconShopProfileAttribute).Name;
|
||||
|
||||
var copy_from_attribute = entityAttributeBase as BeaconShopProfileAttribute;
|
||||
if (null == copy_from_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_attribute = getClonedEntityAttribute() as BeaconShopProfileAttribute;
|
||||
if (null == copy_to_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_attribute.BeaconGuid = copy_from_attribute.BeaconGuid;
|
||||
copy_to_attribute.DailyRegisterCount = copy_from_attribute.DailyRegisterCount;
|
||||
copy_to_attribute.RegisterUpdateDay = copy_from_attribute.RegisterUpdateDay;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
228
ServerCommon/Entity/Attribute/BeaconShopSoldPriceAttribute.cs
Normal file
228
ServerCommon/Entity/Attribute/BeaconShopSoldPriceAttribute.cs
Normal file
@@ -0,0 +1,228 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
using BEACON_GUID = System.String;
|
||||
using META_ID = System.UInt32;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class BeaconShopSoldPriceAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public USER_GUID UserGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public BEACON_GUID BeaconGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public double TaxPrice { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public double GivenPrice { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public int NumOfReceiptNotReceived { get; set; } = 0;
|
||||
|
||||
public BeaconShopSoldPriceAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
UserGuid = string.Empty;
|
||||
BeaconGuid = string.Empty;
|
||||
TaxPrice = 0;
|
||||
GivenPrice = 0;
|
||||
NumOfReceiptNotReceived = 0;
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new BeaconShopSoldPriceAttribute(getOwner());
|
||||
cloned.UserGuid = UserGuid;
|
||||
cloned.BeaconGuid = BeaconGuid;
|
||||
cloned.TaxPrice = TaxPrice;
|
||||
cloned.GivenPrice = GivenPrice;
|
||||
cloned.NumOfReceiptNotReceived = NumOfReceiptNotReceived;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new BeaconShopSoldPriceAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as BeaconShopSoldPriceDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new BeaconShopSoldPriceDoc(UserGuid);
|
||||
|
||||
var origin_doc = getOriginDocBase<BeaconShopSoldPriceAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<BeaconShopSoldPriceAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!!");
|
||||
|
||||
to_copy_doc_attrib.UserGuid = UserGuid;
|
||||
to_copy_doc_attrib.BeaconGuid = BeaconGuid;
|
||||
to_copy_doc_attrib.GivenPrice = GivenPrice;
|
||||
to_copy_doc_attrib.TaxPrice = TaxPrice;
|
||||
to_copy_doc_attrib.NumOfReceiptNotReceived = NumOfReceiptNotReceived;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(BeaconShopSoldPriceDoc).Name;
|
||||
|
||||
var beacon_shop_item_history_doc_base = docBase as BeaconShopSoldPriceDoc;
|
||||
if (null == beacon_shop_item_history_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, beacon_shop_item_history_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<BeaconShopSoldPriceAttribute>(beacon_shop_item_history_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = beacon_shop_item_history_doc_base.getAttrib<BeaconShopSoldPriceAttrib>();
|
||||
if (doc_attrib == null)
|
||||
{
|
||||
err_msg = $"Failed to get beacon_shop attrib : {nameof(BeaconShopSoldPriceAttrib)}";
|
||||
result.setFail(ServerErrorCode.EntityAttributeIsNull, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
UserGuid = doc_attrib.UserGuid;
|
||||
BeaconGuid = doc_attrib.BeaconGuid;
|
||||
GivenPrice = doc_attrib.GivenPrice;
|
||||
TaxPrice = doc_attrib.TaxPrice;
|
||||
NumOfReceiptNotReceived = doc_attrib.NumOfReceiptNotReceived;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var beacon_shop_item_history_attribute = otherEntityAttribute as BeaconShopSoldPriceAttribute;
|
||||
if (null == beacon_shop_item_history_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast Attribute !!!, beacon_shop_item_history_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
UserGuid = beacon_shop_item_history_attribute.UserGuid;
|
||||
BeaconGuid = beacon_shop_item_history_attribute.BeaconGuid;
|
||||
GivenPrice = beacon_shop_item_history_attribute.GivenPrice;
|
||||
TaxPrice = beacon_shop_item_history_attribute.TaxPrice;
|
||||
NumOfReceiptNotReceived = beacon_shop_item_history_attribute.NumOfReceiptNotReceived;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = beacon_shop_item_history_attribute.getTryPendingDocBase() as BeaconShopSoldPriceDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
beacon_shop_item_history_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<BeaconShopSoldPriceAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<BeaconShopSoldPriceAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var beacon_shop_item_history_attrib = origin_doc_base.getAttrib<BeaconShopSoldPriceAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(beacon_shop_item_history_attrib, () => $"beacon_shop_item_history_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
beacon_shop_item_history_attrib.UserGuid = UserGuid;
|
||||
beacon_shop_item_history_attrib.BeaconGuid = BeaconGuid;
|
||||
beacon_shop_item_history_attrib.GivenPrice = GivenPrice;
|
||||
beacon_shop_item_history_attrib.TaxPrice = TaxPrice;
|
||||
beacon_shop_item_history_attrib.NumOfReceiptNotReceived = NumOfReceiptNotReceived;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class BeaconShopSoldPriceAttributeTransactor : EntityAttributeTransactorBase<BeaconShopSoldPriceAttribute>
|
||||
{
|
||||
public BeaconShopSoldPriceAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
}
|
||||
271
ServerCommon/Entity/Attribute/BeaconShopSoldRecordAttribute.cs
Normal file
271
ServerCommon/Entity/Attribute/BeaconShopSoldRecordAttribute.cs
Normal file
@@ -0,0 +1,271 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
using BEACON_GUID = System.String;
|
||||
using META_ID = System.UInt32;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class BeaconShopSoldRecordAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public USER_GUID UserGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public BEACON_GUID BeaconGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public META_ID ItemMetaId { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public string BuyerNickName { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public double PriceForUnit { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public int Amount { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public DateTime SalesTime { get; set; } = new();
|
||||
|
||||
[JsonProperty]
|
||||
public double SoldPrice { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public double TaxPrice { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public double GivenPrice { get; set; } = 0;
|
||||
|
||||
public BeaconShopSoldRecordAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
UserGuid = string.Empty;
|
||||
BeaconGuid = string.Empty;
|
||||
ItemMetaId = 0;
|
||||
BuyerNickName = string.Empty;
|
||||
PriceForUnit = 0;
|
||||
Amount = 0;
|
||||
SalesTime = new();
|
||||
SoldPrice = 0;
|
||||
TaxPrice = 0;
|
||||
GivenPrice = 0;
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new BeaconShopSoldRecordAttribute(getOwner());
|
||||
cloned.UserGuid = UserGuid;
|
||||
cloned.BeaconGuid = BeaconGuid;
|
||||
cloned.ItemMetaId = ItemMetaId;
|
||||
cloned.BuyerNickName = BuyerNickName;
|
||||
cloned.PriceForUnit = PriceForUnit;
|
||||
cloned.Amount = Amount;
|
||||
cloned.SalesTime = SalesTime;
|
||||
cloned.SoldPrice = SoldPrice;
|
||||
cloned.TaxPrice = TaxPrice;
|
||||
cloned.GivenPrice = GivenPrice;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new BeaconShopSoldRecordAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as BeaconShopSoldRecordDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new BeaconShopSoldRecordDoc(UserGuid, SalesTime);
|
||||
|
||||
var origin_doc = getOriginDocBase<BeaconShopSoldRecordAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<BeaconShopSoldRecordAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!!");
|
||||
|
||||
to_copy_doc_attrib.UserGuid = UserGuid;
|
||||
to_copy_doc_attrib.BeaconGuid = BeaconGuid;
|
||||
to_copy_doc_attrib.ItemMetaId = ItemMetaId;
|
||||
to_copy_doc_attrib.BuyerNickName = BuyerNickName;
|
||||
to_copy_doc_attrib.PriceForUnit = PriceForUnit;
|
||||
to_copy_doc_attrib.Amount = Amount;
|
||||
to_copy_doc_attrib.SalesTime = SalesTime;
|
||||
to_copy_doc_attrib.SoldPrice = SoldPrice;
|
||||
to_copy_doc_attrib.TaxPrice = TaxPrice;
|
||||
to_copy_doc_attrib.GivenPrice = GivenPrice;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(BeaconShopSoldRecordDoc).Name;
|
||||
|
||||
var beacon_shop_item_history_doc_base = docBase as BeaconShopSoldRecordDoc;
|
||||
if (null == beacon_shop_item_history_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, beacon_shop_item_history_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<BeaconShopSoldRecordAttribute>(beacon_shop_item_history_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = beacon_shop_item_history_doc_base.getAttrib<BeaconShopSoldRecordAttrib>();
|
||||
if (doc_attrib == null)
|
||||
{
|
||||
err_msg = $"Failed to get beacon_shop attrib : {nameof(BeaconShopSoldRecordAttrib)}";
|
||||
result.setFail(ServerErrorCode.EntityAttributeIsNull, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
UserGuid = doc_attrib.UserGuid;
|
||||
BeaconGuid = doc_attrib.BeaconGuid;
|
||||
ItemMetaId = doc_attrib.ItemMetaId;
|
||||
BuyerNickName = doc_attrib.BuyerNickName;
|
||||
PriceForUnit = doc_attrib.PriceForUnit;
|
||||
Amount = doc_attrib.Amount;
|
||||
SalesTime = doc_attrib.SalesTime;
|
||||
SoldPrice = doc_attrib.SoldPrice;
|
||||
TaxPrice = doc_attrib.TaxPrice;
|
||||
GivenPrice = doc_attrib.GivenPrice;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var beacon_shop_item_history_attribute = otherEntityAttribute as BeaconShopSoldRecordAttribute;
|
||||
if (null == beacon_shop_item_history_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast Attribute !!!, beacon_shop_item_history_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
UserGuid = beacon_shop_item_history_attribute.UserGuid;
|
||||
BeaconGuid = beacon_shop_item_history_attribute.BeaconGuid;
|
||||
ItemMetaId = beacon_shop_item_history_attribute.ItemMetaId;
|
||||
BuyerNickName = beacon_shop_item_history_attribute.BuyerNickName;
|
||||
PriceForUnit = beacon_shop_item_history_attribute.PriceForUnit;
|
||||
Amount = beacon_shop_item_history_attribute.Amount;
|
||||
SalesTime = beacon_shop_item_history_attribute.SalesTime;
|
||||
SoldPrice = beacon_shop_item_history_attribute.SoldPrice;
|
||||
TaxPrice = beacon_shop_item_history_attribute.TaxPrice;
|
||||
GivenPrice = beacon_shop_item_history_attribute.GivenPrice;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = beacon_shop_item_history_attribute.getTryPendingDocBase() as BeaconShopSoldRecordDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
beacon_shop_item_history_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<BeaconShopSoldRecordAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<BeaconShopSoldRecordAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var beacon_shop_item_history_attrib = origin_doc_base.getAttrib<BeaconShopSoldRecordAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(beacon_shop_item_history_attrib, () => $"beacon_shop_item_history_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
beacon_shop_item_history_attrib.UserGuid = UserGuid;
|
||||
beacon_shop_item_history_attrib.BeaconGuid = BeaconGuid;
|
||||
beacon_shop_item_history_attrib.ItemMetaId = ItemMetaId;
|
||||
beacon_shop_item_history_attrib.BuyerNickName = BuyerNickName;
|
||||
beacon_shop_item_history_attrib.PriceForUnit = PriceForUnit;
|
||||
beacon_shop_item_history_attrib.Amount = Amount;
|
||||
beacon_shop_item_history_attrib.SalesTime = SalesTime;
|
||||
beacon_shop_item_history_attrib.SoldPrice = SoldPrice;
|
||||
beacon_shop_item_history_attrib.TaxPrice = TaxPrice;
|
||||
beacon_shop_item_history_attrib.GivenPrice = GivenPrice;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public class BeaconShopSoldRecordAttributeTransactor : EntityAttributeTransactorBase<BeaconShopSoldRecordAttribute>
|
||||
{
|
||||
public BeaconShopSoldRecordAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
}
|
||||
238
ServerCommon/Entity/Attribute/BlockUserAttribute.cs
Normal file
238
ServerCommon/Entity/Attribute/BlockUserAttribute.cs
Normal file
@@ -0,0 +1,238 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
using ServerControlCenter;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class BlockUserAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public USER_GUID UserGuid { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public USER_GUID BlockGuid { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public string Nickname { get; set; } = string.Empty;
|
||||
|
||||
public Int32 IsNew { get; set; } = 0;
|
||||
|
||||
public DateTime CreateTime { get; set; } = DateTimeHelper.MinTime;
|
||||
|
||||
|
||||
|
||||
public BlockUserAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
UserGuid = string.Empty;
|
||||
BlockGuid = string.Empty;
|
||||
Nickname = string.Empty;
|
||||
IsNew = 0;
|
||||
CreateTime = DateTimeHelper.MinTime;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!! - {toBasicString()}");
|
||||
var root_parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(root_parent, () => $"root_parent is null !!! - {toBasicString()}");
|
||||
var acoount_attribute = root_parent.getEntityAttribute<AccountAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(acoount_attribute, () => $"acoount_attribute is null !!! - {toBasicString()}");
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
USER_GUID user_guid = acoount_attribute.UserGuid;
|
||||
|
||||
var try_pending_doc = getTryPendingDocBase() as BlockUserDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new BlockUserDoc(user_guid, BlockGuid);
|
||||
|
||||
var origin_doc = getOriginDocBase<BlockUserAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_block_user_attrib = try_pending_doc.getAttrib<BlockUserAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_block_user_attrib, () => $"to_copy_block_user_attrib is null !!! - {toBasicString()}");
|
||||
to_copy_block_user_attrib.BlockGuid = BlockGuid;
|
||||
to_copy_block_user_attrib.IsNew = IsNew;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!! - {toBasicString()}");
|
||||
|
||||
|
||||
var cloned = new BlockUserAttribute(owner);
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.BlockGuid = BlockGuid;
|
||||
cloned.IsNew = IsNew;
|
||||
cloned.CreateTime = CreateTime;
|
||||
cloned.Nickname = Nickname;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!! - {toBasicString()}");
|
||||
|
||||
var result = new Result();
|
||||
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
|
||||
var other_attribute = otherEntityAttribute as BlockUserAttribute;
|
||||
if (null == other_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast BlockUserAttribute !!!, other_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
UserGuid = other_attribute.UserGuid;
|
||||
BlockGuid = other_attribute.BlockGuid;
|
||||
Nickname = other_attribute.Nickname;
|
||||
IsNew = other_attribute.IsNew;
|
||||
CreateTime = other_attribute.CreateTime;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_attribute.getTryPendingDocBase() as BlockUserDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<BlockUserAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<BlockUserAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var block_user_attrib = origin_doc_base.getAttrib<BlockUserAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(block_user_attrib, () => $"block_user_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
block_user_attrib.BlockGuid = BlockGuid;
|
||||
block_user_attrib.IsNew = IsNew;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var block_user_doc_base = docBase as BlockUserDoc;
|
||||
if (null == block_user_doc_base)
|
||||
{
|
||||
var to_cast_string = typeof(BlockUserDoc).Name;
|
||||
var err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, item_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<BlockUserAttribute>(block_user_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = block_user_doc_base.getAttrib<BlockUserAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_attrib, () => $"doc_attrib is null !!! - {toBasicString()}");
|
||||
|
||||
BlockGuid = doc_attrib.BlockGuid;
|
||||
IsNew = doc_attrib.IsNew;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new BlockUsersAtrributeTransactor(getOwner());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class BlockUsersAtrributeTransactor : EntityAttributeTransactorBase<BlockUserAttribute>
|
||||
{
|
||||
public BlockUsersAtrributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorBaseFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
//아직 미사용
|
||||
Log.getLogger().info("copyEntityDbTransactBaseFromEntityAttribute call");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
193
ServerCommon/Entity/Attribute/BuffAttribute.cs
Normal file
193
ServerCommon/Entity/Attribute/BuffAttribute.cs
Normal file
@@ -0,0 +1,193 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using NeoSmart.AsyncLock;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using META_ID = System.UInt32;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class BuffAttribute : EntityAttributeBase, ICopyEntityAttributeFromCache
|
||||
{
|
||||
public class BuffInfo
|
||||
{
|
||||
[JsonProperty]
|
||||
public META_ID BuffMetaID { get; set; } = 0;
|
||||
[JsonProperty]
|
||||
public DateTime BuffStartTime { get; set; } = new();
|
||||
|
||||
public BuffInfo()
|
||||
{ }
|
||||
|
||||
public BuffInfo(BuffInfo buffInfo)
|
||||
{
|
||||
BuffMetaID = buffInfo.BuffMetaID;
|
||||
BuffStartTime = buffInfo.BuffStartTime;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[JsonProperty]
|
||||
public Dictionary<MetaAssets.EBuffCategory, Dictionary<int, BuffInfo>> BuffInfos = new();
|
||||
|
||||
private AsyncLock m_lock = new();
|
||||
|
||||
public BuffAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
foreach (MetaAssets.EBuffCategory category in System.Enum.GetValues(typeof(MetaAssets.EBuffCategory)))
|
||||
{
|
||||
var buff_channel_Info = new Dictionary<int, BuffInfo>();
|
||||
BuffInfos.TryAdd(category, buff_channel_Info);
|
||||
}
|
||||
}
|
||||
public override void onClear()
|
||||
{
|
||||
foreach(var buff_infos in BuffInfos.Values)
|
||||
{
|
||||
buff_infos.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromCache(CacheBase cacheBase)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
var to_cast_string = typeof(BuffCache).Name;
|
||||
|
||||
var buff_cache = cacheBase as BuffCache;
|
||||
if (null == buff_cache)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromCache() !!!, buff_cache is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Cache => Attribute
|
||||
//=====================================================================================
|
||||
|
||||
foreach(var channel_buff in buff_cache.buff_cache_Infos)
|
||||
{
|
||||
foreach(var buff_info_cache in channel_buff.Value)
|
||||
{
|
||||
if (false == MetaData.Instance._BuffTable.TryGetValue((int)buff_info_cache.Value.BuffMetaID, out var buffMetaData))
|
||||
{
|
||||
err_msg = $"Not found BuffMeta !!! : buffMetaId:{buff_info_cache.Value.BuffMetaID}";
|
||||
result.setFail(ServerErrorCode.BuffMetaDataNotFound, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (BuffInfos.TryGetValue(channel_buff.Key, out var attribute_channel_buffs) == false)
|
||||
{
|
||||
attribute_channel_buffs = new Dictionary<int, BuffInfo>();
|
||||
BuffInfos.TryAdd(channel_buff.Key, attribute_channel_buffs);
|
||||
}
|
||||
|
||||
var buff = new BuffInfo();
|
||||
buff.BuffMetaID = buff_info_cache.Value.BuffMetaID;
|
||||
buff.BuffStartTime = buff_info_cache.Value.BuffStartTime;
|
||||
|
||||
attribute_channel_buffs.TryAdd(buff_info_cache.Key, buff);
|
||||
{
|
||||
err_msg = $"Duplicated buff in channel !!! : buffMetaId:{buff_info_cache.Value.BuffMetaID}";
|
||||
result.setFail(ServerErrorCode.BuffCacheLoadDuplicatedBuff, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool AddBuff(MetaAssets.EBuffCategory eBuffCategory, int channel, int buffId, [MaybeNullWhen(false)] out BuffInfo addBuff)
|
||||
{
|
||||
addBuff = null;
|
||||
if (BuffInfos.TryGetValue(eBuffCategory, out var buffchannelInfo) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var buff = new BuffInfo();
|
||||
buff.BuffMetaID = (META_ID)buffId;
|
||||
buff.BuffStartTime = DateTimeHelper.Current;
|
||||
|
||||
using (m_lock.Lock())
|
||||
{
|
||||
if (buffchannelInfo.TryAdd(channel, buff) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
addBuff = buff;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool RemoveBuff(MetaAssets.EBuffCategory eBuffCategory, int channel, [MaybeNullWhen(false)] out BuffInfo delBuff)
|
||||
{
|
||||
delBuff = null;
|
||||
if (BuffInfos.TryGetValue(eBuffCategory, out var buffchannelInfo) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
using (m_lock.Lock())
|
||||
{
|
||||
if (buffchannelInfo.Remove(channel, out delBuff) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var buff_attribute = new BuffAttribute(getOwner());
|
||||
|
||||
foreach (var buff_channels in BuffInfos)
|
||||
{
|
||||
buff_attribute.BuffInfos[buff_channels.Key] = new Dictionary<int, BuffInfo>(buff_channels.Value.ToDictionary(a => a.Key, b => new BuffInfo(b.Value)));
|
||||
}
|
||||
|
||||
return buff_attribute;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var player = owner.getRootParent() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
return new BuffAttributeTransactor(player);
|
||||
}
|
||||
}
|
||||
|
||||
public class BuffAttributeTransactor : EntityAttributeTransactorBase<BuffAttribute>
|
||||
{
|
||||
public BuffAttributeTransactor(UserBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
303
ServerCommon/Entity/Attribute/BuildingAttribute.cs
Normal file
303
ServerCommon/Entity/Attribute/BuildingAttribute.cs
Normal file
@@ -0,0 +1,303 @@
|
||||
using Amazon.S3.Model;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using BUILDING_GUID = System.String;
|
||||
using META_ID = System.UInt32;
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class BuildingAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public BUILDING_GUID BuildingGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public META_ID BuildingMetaId { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public string BuildingName { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public string OwnerUserGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public CurrencyType RentalCurrencyType { get; set; } = CurrencyType.None;
|
||||
|
||||
[JsonProperty]
|
||||
public double RentalCurrencyAmount { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public bool IsRentalOpen { get; set; } = false;
|
||||
|
||||
public bool IsLoadFromDb = false;
|
||||
|
||||
|
||||
public BuildingAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void newEntityAttribute()
|
||||
{
|
||||
BuildingGuid = System.Guid.NewGuid().ToString("N");
|
||||
base.newEntityAttribute();
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new BuildingAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
BuildingGuid = string.Empty;
|
||||
BuildingMetaId = 0;
|
||||
BuildingName = string.Empty;
|
||||
Description = string.Empty;
|
||||
OwnerUserGuid = string.Empty;
|
||||
RentalCurrencyType = CurrencyType.None;
|
||||
RentalCurrencyAmount = 0;
|
||||
IsRentalOpen = false;
|
||||
IsLoadFromDb = false;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new BuildingAttribute(getOwner());
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.BuildingGuid = BuildingGuid;
|
||||
cloned.BuildingMetaId = BuildingMetaId;
|
||||
cloned.BuildingName = BuildingName;
|
||||
cloned.Description = Description;
|
||||
cloned.OwnerUserGuid = OwnerUserGuid;
|
||||
cloned.RentalCurrencyType = RentalCurrencyType;
|
||||
cloned.RentalCurrencyAmount = RentalCurrencyAmount;
|
||||
cloned.IsRentalOpen = IsRentalOpen;
|
||||
cloned.IsLoadFromDb = IsLoadFromDb;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as BuildingDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new BuildingDoc(BuildingMetaId);
|
||||
|
||||
var origin_doc = getOriginDocBase<BuildingAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var building_attrib = try_pending_doc.getAttrib<BuildingAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(building_attrib, () => $"building_attrib is null !!!");
|
||||
|
||||
building_attrib.BuildingGuid = BuildingGuid;
|
||||
building_attrib.BuildingMetaId = BuildingMetaId;
|
||||
building_attrib.BuildingName = BuildingName;
|
||||
building_attrib.Description = Description;
|
||||
building_attrib.OwnerUserGuid = OwnerUserGuid;
|
||||
building_attrib.RentalCurrencyType = RentalCurrencyType;
|
||||
building_attrib.RentalCurrencyAmount = RentalCurrencyAmount;
|
||||
building_attrib.IsRentalOpen = IsRentalOpen;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(BuildingDoc).Name;
|
||||
|
||||
var building_doc_base = docBase as BuildingDoc;
|
||||
if (null == building_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, building_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<BuildingAttribute>(building_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var building_attrib = building_doc_base.getAttrib<BuildingAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(building_attrib, () => $"building_attrib is null !!!");
|
||||
|
||||
BuildingGuid = building_attrib.BuildingGuid;
|
||||
BuildingMetaId = building_attrib.BuildingMetaId;
|
||||
BuildingName = building_attrib.BuildingName;
|
||||
Description = building_attrib.Description;
|
||||
OwnerUserGuid = building_attrib.OwnerUserGuid;
|
||||
RentalCurrencyType = building_attrib.RentalCurrencyType;
|
||||
RentalCurrencyAmount = building_attrib.RentalCurrencyAmount;
|
||||
IsRentalOpen = building_attrib.IsRentalOpen;
|
||||
IsLoadFromDb = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var building_attribute = otherEntityAttribute as BuildingAttribute;
|
||||
if (null == building_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast BuildingAttribute !!!, building_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
BuildingGuid = building_attribute.BuildingGuid;
|
||||
BuildingMetaId = building_attribute.BuildingMetaId;
|
||||
BuildingName = building_attribute.BuildingName;
|
||||
Description = building_attribute.Description;
|
||||
OwnerUserGuid = building_attribute.OwnerUserGuid;
|
||||
RentalCurrencyType = building_attribute.RentalCurrencyType;
|
||||
RentalCurrencyAmount = building_attribute.RentalCurrencyAmount;
|
||||
IsRentalOpen = building_attribute.IsRentalOpen;
|
||||
IsLoadFromDb = building_attribute.IsLoadFromDb;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
|
||||
var try_pending_doc = building_attribute.getTryPendingDocBase() as AccountBaseDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
building_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<BuildingAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<BuildingAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var building_attrib = origin_doc_base.getAttrib<BuildingAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(building_attrib, () => $"building_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
building_attrib.BuildingGuid = BuildingGuid;
|
||||
building_attrib.BuildingMetaId = BuildingMetaId;
|
||||
building_attrib.BuildingName = BuildingName;
|
||||
building_attrib.Description = Description;
|
||||
building_attrib.OwnerUserGuid = OwnerUserGuid;
|
||||
building_attrib.RentalCurrencyType = RentalCurrencyType;
|
||||
building_attrib.RentalCurrencyAmount = RentalCurrencyAmount;
|
||||
building_attrib.IsRentalOpen = IsRentalOpen;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class BuildingAttributeTransactor : EntityAttributeTransactorBase<BuildingAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public BuildingAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(BuildingAttribute).Name;
|
||||
|
||||
var copy_from_building_attribute = entityAttributeBase as BuildingAttribute;
|
||||
if (null == copy_from_building_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_from_building_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_building_attribute = getClonedEntityAttribute() as BuildingAttribute;
|
||||
if (null == copy_to_building_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_to_building_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_building_attribute.BuildingGuid = copy_from_building_attribute.BuildingGuid;
|
||||
copy_to_building_attribute.BuildingMetaId = copy_from_building_attribute.BuildingMetaId;
|
||||
copy_to_building_attribute.BuildingName = copy_from_building_attribute.BuildingName;
|
||||
copy_to_building_attribute.Description = copy_from_building_attribute.Description;
|
||||
copy_to_building_attribute.OwnerUserGuid = copy_from_building_attribute.OwnerUserGuid;
|
||||
copy_to_building_attribute.RentalCurrencyType = copy_from_building_attribute.RentalCurrencyType;
|
||||
copy_to_building_attribute.RentalCurrencyAmount = copy_from_building_attribute.RentalCurrencyAmount;
|
||||
copy_to_building_attribute.IsRentalOpen = copy_from_building_attribute.IsRentalOpen;
|
||||
copy_to_building_attribute.IsLoadFromDb = copy_from_building_attribute.IsLoadFromDb;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
324
ServerCommon/Entity/Attribute/BuildingFloorAttribute.cs
Normal file
324
ServerCommon/Entity/Attribute/BuildingFloorAttribute.cs
Normal file
@@ -0,0 +1,324 @@
|
||||
using Amazon.S3.Model;
|
||||
using Newtonsoft.Json;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class BuildingFloorAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public int LandMetaId { get; set; }
|
||||
[JsonProperty]
|
||||
public int BuildingMetaId { get; set; }
|
||||
[JsonProperty]
|
||||
public int Floor { get; set; }
|
||||
[JsonProperty]
|
||||
public string OwnerGuid { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public string MyhomeGuid { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public string InstanceName { get; set; } = string.Empty;
|
||||
|
||||
public int ThumbnailImageId { get; set; }
|
||||
|
||||
public int ListImageId { get; set; }
|
||||
[JsonProperty]
|
||||
public int EnterPlayerCount { get; set; }
|
||||
|
||||
public TimeSpan RentalPeriod { get; set; } = new();
|
||||
|
||||
[JsonProperty]
|
||||
public DateTime RentalStartTime { get; set; } = new();
|
||||
[JsonProperty]
|
||||
public DateTime RentalFinishTime { get; set; } = new();
|
||||
|
||||
|
||||
public BuildingFloorAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void newEntityAttribute()
|
||||
{
|
||||
base.newEntityAttribute();
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new BuildingFloorAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
LandMetaId = 0;
|
||||
BuildingMetaId = 0;
|
||||
Floor = 0;
|
||||
OwnerGuid = string.Empty;
|
||||
MyhomeGuid = string.Empty;
|
||||
InstanceName = string.Empty;
|
||||
ThumbnailImageId = 0;
|
||||
ListImageId = 0;
|
||||
EnterPlayerCount = 0;
|
||||
RentalPeriod = new();
|
||||
RentalStartTime = new();
|
||||
RentalFinishTime = new();
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new BuildingFloorAttribute(getOwner());
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.LandMetaId = LandMetaId;
|
||||
cloned.BuildingMetaId = BuildingMetaId;
|
||||
cloned.Floor = Floor;
|
||||
cloned.OwnerGuid = OwnerGuid;
|
||||
cloned.MyhomeGuid = MyhomeGuid;
|
||||
cloned.InstanceName = InstanceName;
|
||||
cloned.ThumbnailImageId = ThumbnailImageId;
|
||||
cloned.ListImageId = ListImageId;
|
||||
cloned.EnterPlayerCount = EnterPlayerCount;
|
||||
cloned.RentalPeriod = RentalPeriod;
|
||||
cloned.RentalStartTime = RentalStartTime;
|
||||
cloned.RentalFinishTime = RentalFinishTime;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as BuildingFloorDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var ttl_seconds = DynamoDbClientHelper.makeTTLTimeForDynamoDB(RentalFinishTime);
|
||||
|
||||
var to_copy_doc = new BuildingFloorDoc(BuildingMetaId, Floor, ttl_seconds);
|
||||
|
||||
var origin_doc = getOriginDocBase<BuildingFloorAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var building_floor_attrib = try_pending_doc.getAttrib<BuildingFloorAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(building_floor_attrib, () => $"building_floor_attrib is null !!!");
|
||||
|
||||
building_floor_attrib.LandMetaId = LandMetaId;
|
||||
building_floor_attrib.BuildingMetaId = BuildingMetaId;
|
||||
building_floor_attrib.Floor = Floor;
|
||||
building_floor_attrib.OwnerGuid = OwnerGuid;
|
||||
building_floor_attrib.MyhomeGuid = MyhomeGuid;
|
||||
building_floor_attrib.InstanceName = InstanceName;
|
||||
building_floor_attrib.ThumbnailImageId = ThumbnailImageId;
|
||||
building_floor_attrib.ListImageId = ListImageId;
|
||||
building_floor_attrib.EnterPlayerCount = EnterPlayerCount;
|
||||
building_floor_attrib.RentalPeriod = RentalPeriod;
|
||||
building_floor_attrib.RentalStartTime = RentalStartTime;
|
||||
building_floor_attrib.RentalFinishTime = RentalFinishTime;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(BuildingFloorDoc).Name;
|
||||
|
||||
var building_floor_doc_base = docBase as BuildingFloorDoc;
|
||||
if (null == building_floor_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, building_floor_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<BuildingFloorAttribute>(building_floor_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var building_floor_attrib = building_floor_doc_base.getAttrib<BuildingFloorAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(building_floor_attrib, () => $"building_floor_attrib is null !!!");
|
||||
|
||||
LandMetaId = building_floor_attrib.LandMetaId;
|
||||
BuildingMetaId = building_floor_attrib.BuildingMetaId;
|
||||
Floor = building_floor_attrib.Floor;
|
||||
OwnerGuid = building_floor_attrib.OwnerGuid;
|
||||
MyhomeGuid = building_floor_attrib.MyhomeGuid;
|
||||
InstanceName = building_floor_attrib.InstanceName;
|
||||
ThumbnailImageId = building_floor_attrib.ThumbnailImageId;
|
||||
ListImageId = building_floor_attrib.ListImageId;
|
||||
EnterPlayerCount = building_floor_attrib.EnterPlayerCount;
|
||||
RentalPeriod = building_floor_attrib.RentalPeriod;
|
||||
RentalStartTime = building_floor_attrib.RentalStartTime;
|
||||
RentalFinishTime = building_floor_attrib.RentalFinishTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var building_floor_attribute = otherEntityAttribute as BuildingFloorAttribute;
|
||||
if (null == building_floor_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast BuildingFloorAttribute !!!, building_floor_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
LandMetaId = building_floor_attribute.LandMetaId;
|
||||
BuildingMetaId = building_floor_attribute.BuildingMetaId;
|
||||
Floor = building_floor_attribute.Floor;
|
||||
OwnerGuid = building_floor_attribute.OwnerGuid;
|
||||
MyhomeGuid = building_floor_attribute.MyhomeGuid;
|
||||
InstanceName = building_floor_attribute.InstanceName;
|
||||
ThumbnailImageId = building_floor_attribute.ThumbnailImageId;
|
||||
ListImageId = building_floor_attribute.ListImageId;
|
||||
EnterPlayerCount = building_floor_attribute.EnterPlayerCount;
|
||||
RentalPeriod = building_floor_attribute.RentalPeriod;
|
||||
RentalStartTime = building_floor_attribute.RentalStartTime;
|
||||
RentalFinishTime = building_floor_attribute.RentalFinishTime;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = building_floor_attribute.getTryPendingDocBase() as AccountBaseDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
building_floor_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<BuildingFloorAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<BuildingFloorAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var building_floor_attrib = origin_doc_base.getAttrib<BuildingFloorAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(building_floor_attrib, () => $"building_floor_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
building_floor_attrib.LandMetaId = LandMetaId;
|
||||
building_floor_attrib.BuildingMetaId = BuildingMetaId;
|
||||
building_floor_attrib.Floor = Floor;
|
||||
building_floor_attrib.OwnerGuid = OwnerGuid;
|
||||
building_floor_attrib.MyhomeGuid = MyhomeGuid;
|
||||
building_floor_attrib.InstanceName = InstanceName;
|
||||
building_floor_attrib.ThumbnailImageId = ThumbnailImageId;
|
||||
building_floor_attrib.ListImageId = ListImageId;
|
||||
building_floor_attrib.EnterPlayerCount = EnterPlayerCount;
|
||||
building_floor_attrib.RentalPeriod = RentalPeriod;
|
||||
building_floor_attrib.RentalStartTime = RentalStartTime;
|
||||
building_floor_attrib.RentalFinishTime = RentalFinishTime;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class BuildingFloorAttributeTransactor : EntityAttributeTransactorBase<BuildingFloorAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public BuildingFloorAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(BuildingFloorAttribute).Name;
|
||||
|
||||
var copy_from_building_floor_attribute = entityAttributeBase as BuildingFloorAttribute;
|
||||
if (null == copy_from_building_floor_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_from_building_floor_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_building_floor_attribute = getClonedEntityAttribute() as BuildingFloorAttribute;
|
||||
if (null == copy_to_building_floor_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_to_building_floor_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_building_floor_attribute.LandMetaId = copy_from_building_floor_attribute.LandMetaId;
|
||||
copy_to_building_floor_attribute.BuildingMetaId = copy_from_building_floor_attribute.BuildingMetaId;
|
||||
copy_to_building_floor_attribute.Floor = copy_from_building_floor_attribute.Floor;
|
||||
copy_to_building_floor_attribute.OwnerGuid = copy_from_building_floor_attribute.OwnerGuid;
|
||||
copy_to_building_floor_attribute.MyhomeGuid = copy_from_building_floor_attribute.MyhomeGuid;
|
||||
copy_to_building_floor_attribute.InstanceName = copy_from_building_floor_attribute.InstanceName;
|
||||
copy_to_building_floor_attribute.ThumbnailImageId = copy_from_building_floor_attribute.ThumbnailImageId;
|
||||
copy_to_building_floor_attribute.ListImageId = copy_from_building_floor_attribute.ListImageId;
|
||||
copy_to_building_floor_attribute.EnterPlayerCount = copy_from_building_floor_attribute.EnterPlayerCount;
|
||||
copy_to_building_floor_attribute.RentalPeriod = copy_from_building_floor_attribute.RentalPeriod;
|
||||
copy_to_building_floor_attribute.RentalStartTime = copy_from_building_floor_attribute.RentalStartTime;
|
||||
copy_to_building_floor_attribute.RentalFinishTime = copy_from_building_floor_attribute.RentalFinishTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
233
ServerCommon/Entity/Attribute/BuildingProfitAttribute.cs
Normal file
233
ServerCommon/Entity/Attribute/BuildingProfitAttribute.cs
Normal file
@@ -0,0 +1,233 @@
|
||||
using Amazon;
|
||||
using Newtonsoft.Json;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class BuildingProfitAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public int BuildingMetaId { get; set; }
|
||||
[JsonProperty]
|
||||
public int Floor { get; set; }
|
||||
[JsonProperty]
|
||||
public Dictionary<CurrencyType, double> Profits { get; set; } = new();
|
||||
|
||||
public BuildingProfitAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void newEntityAttribute()
|
||||
{
|
||||
base.newEntityAttribute();
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new BuildingProfitAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
BuildingMetaId = 0;
|
||||
Floor = 0;
|
||||
Profits = new();
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new BuildingProfitAttribute(getOwner());
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.BuildingMetaId = BuildingMetaId;
|
||||
cloned.Floor = Floor;
|
||||
cloned.Profits = new(Profits);
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as BuildingProfitDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new BuildingProfitDoc(BuildingMetaId, Floor);
|
||||
|
||||
var origin_doc = getOriginDocBase<BuildingProfitAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<BuildingProfitAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!!");
|
||||
|
||||
to_copy_doc_attrib.BuildingMetaId = BuildingMetaId;
|
||||
to_copy_doc_attrib.Floor = Floor;
|
||||
to_copy_doc_attrib.Profits = new(Profits);
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(BuildingProfitDoc).Name;
|
||||
|
||||
var building_profit_doc_base = docBase as BuildingProfitDoc;
|
||||
if (null == building_profit_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, building_profit_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<BuildingProfitAttribute>(building_profit_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = building_profit_doc_base.getAttrib<BuildingProfitAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_attrib, () => $"doc_attrib is null !!!");
|
||||
|
||||
BuildingMetaId = doc_attrib.BuildingMetaId;
|
||||
Floor = doc_attrib.Floor;
|
||||
Profits = new(doc_attrib.Profits);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var building_profit_attribute = otherEntityAttribute as BuildingProfitAttribute;
|
||||
if (null == building_profit_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast BuildingProfitAttribute !!!, building_profit_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
BuildingMetaId = building_profit_attribute.BuildingMetaId;
|
||||
Floor = building_profit_attribute.Floor;
|
||||
Profits = new(building_profit_attribute.Profits);
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = building_profit_attribute.getTryPendingDocBase() as BuildingProfitDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
building_profit_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<BuildingProfitAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<BuildingProfitAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var building_profit_attrib = origin_doc_base.getAttrib<BuildingProfitAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(building_profit_attrib, () => $"building_profit_attrib is null !!!");
|
||||
|
||||
building_profit_attrib.BuildingMetaId = BuildingMetaId;
|
||||
building_profit_attrib.Floor = Floor;
|
||||
building_profit_attrib.Profits = new(Profits);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class BuildingProfitAttributeTransactor : EntityAttributeTransactorBase<BuildingProfitAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public BuildingProfitAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(BuildingProfitAttribute).Name;
|
||||
|
||||
var copy_from_building_profit_attribute = entityAttributeBase as BuildingProfitAttribute;
|
||||
if (null == copy_from_building_profit_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_from_building_profit_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_building_profit_attribute = getClonedEntityAttribute() as BuildingProfitAttribute;
|
||||
if (null == copy_to_building_profit_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_to_building_profit_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_building_profit_attribute.BuildingMetaId = copy_from_building_profit_attribute.BuildingMetaId;
|
||||
copy_to_building_profit_attribute.Floor = copy_from_building_profit_attribute.Floor;
|
||||
copy_to_building_profit_attribute.Profits = new(copy_from_building_profit_attribute.Profits);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
251
ServerCommon/Entity/Attribute/BuildingProfitHistoryAttribute.cs
Normal file
251
ServerCommon/Entity/Attribute/BuildingProfitHistoryAttribute.cs
Normal file
@@ -0,0 +1,251 @@
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Newtonsoft.Json;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class BuildingProfitHistoryAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public int BuildingMetaId { get; set; }
|
||||
[JsonProperty]
|
||||
public int Floor { get; set; } = 0;
|
||||
[JsonProperty]
|
||||
public DateTime ProfitTime { get; set; } = new();
|
||||
[JsonProperty]
|
||||
public ProfitHistoryType ProfitHistoryType { get; set; } = ProfitHistoryType.None;
|
||||
[JsonProperty]
|
||||
public Dictionary<CurrencyType, double> Profits { get; set; } = new();
|
||||
|
||||
public BuildingProfitHistoryAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void newEntityAttribute()
|
||||
{
|
||||
base.newEntityAttribute();
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new BuildingProfitHistoryAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
BuildingMetaId = 0;
|
||||
Floor = 0;
|
||||
ProfitTime = new();
|
||||
ProfitHistoryType = ProfitHistoryType.None;
|
||||
Profits = new();
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new BuildingProfitHistoryAttribute(getOwner());
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.BuildingMetaId = BuildingMetaId;
|
||||
cloned.Floor = Floor;
|
||||
cloned.ProfitTime = ProfitTime;
|
||||
cloned.ProfitHistoryType = ProfitHistoryType;
|
||||
cloned.Profits = new(Profits);
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as BuildingProfitHistoryDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new BuildingProfitHistoryDoc(BuildingMetaId, ProfitTime.ToTimestamp());
|
||||
|
||||
var origin_doc = getOriginDocBase<BuildingProfitHistoryAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<BuildingProfitHistoryAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!!");
|
||||
|
||||
to_copy_doc_attrib.BuildingMetaId = BuildingMetaId;
|
||||
to_copy_doc_attrib.Floor = Floor;
|
||||
to_copy_doc_attrib.ProfitTime = ProfitTime;
|
||||
to_copy_doc_attrib.ProfitHistoryType = ProfitHistoryType;
|
||||
to_copy_doc_attrib.Profits = new(Profits);
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(BuildingProfitHistoryDoc).Name;
|
||||
|
||||
var building_profit_history_doc_base = docBase as BuildingProfitHistoryDoc;
|
||||
if (null == building_profit_history_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, building_profit_history_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<BuildingProfitHistoryAttribute>(building_profit_history_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = building_profit_history_doc_base.getAttrib<BuildingProfitHistoryAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_attrib, () => $"doc_attrib is null !!!");
|
||||
|
||||
BuildingMetaId = doc_attrib.BuildingMetaId;
|
||||
Floor = doc_attrib.Floor;
|
||||
ProfitTime = doc_attrib.ProfitTime;
|
||||
ProfitHistoryType = doc_attrib.ProfitHistoryType;
|
||||
Profits = new(doc_attrib.Profits);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var building_profit_history_attribute = otherEntityAttribute as BuildingProfitHistoryAttribute;
|
||||
if (null == building_profit_history_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast BuildingProfitHistoryAttribute !!!, building_profit_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
BuildingMetaId = building_profit_history_attribute.BuildingMetaId;
|
||||
Floor = building_profit_history_attribute.Floor;
|
||||
ProfitTime = building_profit_history_attribute.ProfitTime;
|
||||
ProfitHistoryType = building_profit_history_attribute.ProfitHistoryType;
|
||||
Profits = new(building_profit_history_attribute.Profits);
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = building_profit_history_attribute.getTryPendingDocBase() as BuildingProfitHistoryDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
building_profit_history_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<BuildingProfitHistoryAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<BuildingProfitHistoryAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var building_profit_history_attrib = origin_doc_base.getAttrib<BuildingProfitHistoryAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(building_profit_history_attrib, () => $"building_profit_attrib is null !!!");
|
||||
|
||||
building_profit_history_attrib.BuildingMetaId = BuildingMetaId;
|
||||
building_profit_history_attrib.Floor = Floor;
|
||||
building_profit_history_attrib.ProfitTime = ProfitTime;
|
||||
building_profit_history_attrib.ProfitHistoryType = ProfitHistoryType;
|
||||
building_profit_history_attrib.Profits = new(Profits);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class BuildingProfitHistoryAttributeTransactor : EntityAttributeTransactorBase<BuildingProfitHistoryAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public BuildingProfitHistoryAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(BuildingProfitHistoryAttribute).Name;
|
||||
|
||||
var copy_from_building_profit_history_attribute = entityAttributeBase as BuildingProfitHistoryAttribute;
|
||||
if (null == copy_from_building_profit_history_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_from_building_profit_history_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_building_profit_history_attribute = getClonedEntityAttribute() as BuildingProfitHistoryAttribute;
|
||||
if (null == copy_to_building_profit_history_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_to_building_profit_history_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_building_profit_history_attribute.BuildingMetaId = copy_from_building_profit_history_attribute.BuildingMetaId;
|
||||
copy_to_building_profit_history_attribute.Floor = copy_from_building_profit_history_attribute.Floor;
|
||||
copy_to_building_profit_history_attribute.ProfitTime = copy_from_building_profit_history_attribute.ProfitTime;
|
||||
copy_to_building_profit_history_attribute.ProfitHistoryType = copy_from_building_profit_history_attribute.ProfitHistoryType;
|
||||
copy_to_building_profit_history_attribute.Profits = new(copy_from_building_profit_history_attribute.Profits);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
252
ServerCommon/Entity/Attribute/BuildingRentalHistoryAttribute.cs
Normal file
252
ServerCommon/Entity/Attribute/BuildingRentalHistoryAttribute.cs
Normal file
@@ -0,0 +1,252 @@
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Newtonsoft.Json;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class BuildingRentalHistoryAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public int BuildingMetaId { get; set; }
|
||||
[JsonProperty]
|
||||
public int Floor { get; set; } = 0;
|
||||
[JsonProperty]
|
||||
public string RenteeUserGuid { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public DateTime RentalTime { get; set; } = new();
|
||||
[JsonProperty]
|
||||
public int RentalPeriod { get; set; } = 0;
|
||||
|
||||
|
||||
public BuildingRentalHistoryAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void newEntityAttribute()
|
||||
{
|
||||
base.newEntityAttribute();
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new BuildingRentalHistoryAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
BuildingMetaId = 0;
|
||||
Floor = 0;
|
||||
RenteeUserGuid = string.Empty;
|
||||
RentalTime = new();
|
||||
RentalPeriod = 0;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new BuildingRentalHistoryAttribute(getOwner());
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.BuildingMetaId = BuildingMetaId;
|
||||
cloned.Floor = Floor;
|
||||
cloned.RenteeUserGuid = RenteeUserGuid;
|
||||
cloned.RentalTime = RentalTime;
|
||||
cloned.RentalPeriod = RentalPeriod;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as BuildingRentalHistoryDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new BuildingRentalHistoryDoc(BuildingMetaId, RentalTime.ToTimestamp());
|
||||
|
||||
var origin_doc = getOriginDocBase<BuildingRentalHistoryAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<BuildingRentalHistoryAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!!");
|
||||
|
||||
to_copy_doc_attrib.BuildingMetaId = BuildingMetaId;
|
||||
to_copy_doc_attrib.Floor = Floor;
|
||||
to_copy_doc_attrib.RenteeUserGuid = RenteeUserGuid;
|
||||
to_copy_doc_attrib.RentalTime = RentalTime;
|
||||
to_copy_doc_attrib.RentalPeriod = RentalPeriod;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(BuildingRentalHistoryDoc).Name;
|
||||
|
||||
var building_rental_history_doc_base = docBase as BuildingRentalHistoryDoc;
|
||||
if (null == building_rental_history_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, building_rental_history_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<BuildingRentalHistoryAttribute>(building_rental_history_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = building_rental_history_doc_base.getAttrib<BuildingRentalHistoryAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_attrib, () => $"doc_attrib is null !!!");
|
||||
|
||||
BuildingMetaId = doc_attrib.BuildingMetaId;
|
||||
Floor = doc_attrib.Floor;
|
||||
RenteeUserGuid = doc_attrib.RenteeUserGuid;
|
||||
RentalTime = doc_attrib.RentalTime;
|
||||
RentalPeriod = doc_attrib.RentalPeriod;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var building_rental_history_attribute = otherEntityAttribute as BuildingRentalHistoryAttribute;
|
||||
if (null == building_rental_history_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast BuildingRentalHistoryAttribute !!!, building_rental_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
BuildingMetaId = building_rental_history_attribute.BuildingMetaId;
|
||||
Floor = building_rental_history_attribute.Floor;
|
||||
RenteeUserGuid = building_rental_history_attribute.RenteeUserGuid;
|
||||
RentalTime = building_rental_history_attribute.RentalTime;
|
||||
RentalPeriod = building_rental_history_attribute.RentalPeriod;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = building_rental_history_attribute.getTryPendingDocBase() as BuildingRentalHistoryDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
building_rental_history_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<BuildingRentalHistoryAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<BuildingRentalHistoryAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var building_rental_history_attrib = origin_doc_base.getAttrib<BuildingRentalHistoryAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(building_rental_history_attrib, () => $"building_rental_attrib is null !!!");
|
||||
|
||||
building_rental_history_attrib.BuildingMetaId = BuildingMetaId;
|
||||
building_rental_history_attrib.Floor = Floor;
|
||||
building_rental_history_attrib.RenteeUserGuid = RenteeUserGuid;
|
||||
building_rental_history_attrib.RentalTime = RentalTime;
|
||||
building_rental_history_attrib.RentalPeriod = RentalPeriod;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class BuildingRentalHistoryAttributeTransactor : EntityAttributeTransactorBase<BuildingRentalHistoryAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public BuildingRentalHistoryAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(BuildingRentalHistoryAttribute).Name;
|
||||
|
||||
var copy_from_building_rental_history_attribute = entityAttributeBase as BuildingRentalHistoryAttribute;
|
||||
if (null == copy_from_building_rental_history_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_from_building_rental_history_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_building_rental_history_attribute = getClonedEntityAttribute() as BuildingRentalHistoryAttribute;
|
||||
if (null == copy_to_building_rental_history_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_to_building_rental_history_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_building_rental_history_attribute.BuildingMetaId = copy_from_building_rental_history_attribute.BuildingMetaId;
|
||||
copy_to_building_rental_history_attribute.Floor = copy_from_building_rental_history_attribute.Floor;
|
||||
copy_to_building_rental_history_attribute.RenteeUserGuid = copy_from_building_rental_history_attribute.RenteeUserGuid;
|
||||
copy_to_building_rental_history_attribute.RentalTime = copy_from_building_rental_history_attribute.RentalTime;
|
||||
copy_to_building_rental_history_attribute.RentalPeriod = copy_from_building_rental_history_attribute.RentalPeriod;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
204
ServerCommon/Entity/Attribute/CaliumAttribute.cs
Normal file
204
ServerCommon/Entity/Attribute/CaliumAttribute.cs
Normal file
@@ -0,0 +1,204 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class CaliumAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public double DailyCalium
|
||||
{
|
||||
get { return m_daily_calium; }
|
||||
set
|
||||
{
|
||||
var recorder = getEntityRecorder();
|
||||
if (null != recorder)
|
||||
{
|
||||
recorder.applyDeltaCounter(EntityDeltaType.MoneyCalium, value - m_daily_calium, value);
|
||||
}
|
||||
|
||||
m_daily_calium = value;
|
||||
}
|
||||
}
|
||||
|
||||
private double m_daily_calium = 0.0;
|
||||
|
||||
[JsonProperty]
|
||||
public DateTime ProvidedDate { get; set; }
|
||||
|
||||
public CaliumAttribute(UserBase owner) : base(owner, false){}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
DailyCalium = 0.0;
|
||||
ProvidedDate = DateTimeHelper.MinTime;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var cloned = new CaliumAttribute(owner);
|
||||
cloned.DailyCalium = DailyCalium;
|
||||
cloned.ProvidedDate = ProvidedDate;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new CaliumAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
var owner = getOwner();
|
||||
|
||||
var user_attribute = owner.getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var user_guid = user_attribute.UserGuid;
|
||||
|
||||
var to_copy_doc = new CaliumDoc(user_guid);
|
||||
if (false == getAttributeState().hasFlag(StateType.Created))
|
||||
{
|
||||
var origin_doc_base = getOriginDocBase<CaliumAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(origin_doc_base, () => $"origin_doc_base is null !!! - {owner.toBasicString()}");
|
||||
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc_base);
|
||||
}
|
||||
|
||||
var to_copy_calium_attrib = to_copy_doc.getAttrib<CaliumAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_calium_attrib, () => $"to_copy_calium_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
to_copy_calium_attrib.DailyCalium = DailyCalium;
|
||||
to_copy_calium_attrib.ProvidedDate = ProvidedDate;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, to_copy_doc);
|
||||
}
|
||||
|
||||
(result, var to_query_doc) = await applyDoc4Query(to_copy_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(otherEntityAttribute, () => $"otherEntityAttribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var result = new Result();
|
||||
string err_msg;
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var calium_attribute = otherEntityAttribute as CaliumAttribute;
|
||||
if (null == calium_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast CaliumAttribute !!!, calium_attribute is null - {toBasicString()}, {owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DailyCalium = calium_attribute.DailyCalium;
|
||||
ProvidedDate = calium_attribute.ProvidedDate;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => Origin Doc
|
||||
//=====================================================================================
|
||||
var origin_doc = getOriginDocBase<CaliumAttribute>() as CaliumDoc;
|
||||
if (null == origin_doc)
|
||||
{
|
||||
err_msg = $"getOriginDocBase<CaliumAttribute>() is null !!! - docName:{nameof(CaliumDoc)} - {toBasicString()}";
|
||||
Log.getLogger().warn(err_msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
var calium_attrib = origin_doc.getAttrib<CaliumAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(calium_attrib, () => $"calium_attrib is null !!! - {toBasicString()}");
|
||||
|
||||
calium_attrib.DailyCalium = DailyCalium;
|
||||
calium_attrib.ProvidedDate = ProvidedDate;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? newDocBase)
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var calium_doc = newDocBase as CaliumDoc;
|
||||
if (null == calium_doc)
|
||||
{
|
||||
var err_msg = $"calium_doc is null !!!, in copyEntityAttributeFromDoc() - docName:{nameof(CaliumDoc)} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<CaliumAttribute>(calium_doc);
|
||||
|
||||
//=====================================================================================
|
||||
// Origin Doc => Attribute
|
||||
//=====================================================================================
|
||||
var calium_attrib = calium_doc.getAttrib<CaliumAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(calium_attrib, () => $"calium_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
DailyCalium = calium_attrib.DailyCalium;
|
||||
ProvidedDate = calium_attrib.ProvidedDate;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class CaliumAttributeTransactor : EntityAttributeTransactorBase<CaliumAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public CaliumAttributeTransactor(EntityBase owner) : base(owner) { }
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
string err_msg;
|
||||
|
||||
var copy_from_calium_attribute = entityAttributeBase as CaliumAttribute;
|
||||
|
||||
if (null == copy_from_calium_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_calium_attribute is null :{nameof(CaliumAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_calium_attribute = getClonedEntityAttribute() as CaliumAttribute;
|
||||
if (null == copy_to_calium_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_calium_attribute is null :{nameof(CaliumAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_calium_attribute.DailyCalium = copy_from_calium_attribute.DailyCalium;
|
||||
copy_to_calium_attribute.ProvidedDate = copy_from_calium_attribute.ProvidedDate;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
154
ServerCommon/Entity/Attribute/CaliumStorageAttribute.cs
Normal file
154
ServerCommon/Entity/Attribute/CaliumStorageAttribute.cs
Normal file
@@ -0,0 +1,154 @@
|
||||
using Newtonsoft.Json;
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class CaliumStorageAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public double ConverterTotalCalium { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public double DailyConvertRate { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public double OperatorTotalCalium { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public int DailyApplyEpoch { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public double DailyInflationRate { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public DateTime DailyPivotDate { get; set; } = DateTimeHelper.MinTime;
|
||||
|
||||
public CaliumStorageAttribute(EntityBase owner) : base(owner, false) {}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
ConverterTotalCalium = 0.0;
|
||||
DailyConvertRate = 0.0;
|
||||
OperatorTotalCalium = 0.0;
|
||||
DailyApplyEpoch = 0;
|
||||
DailyInflationRate = 0.0;
|
||||
DailyPivotDate = DateTimeHelper.MinTime;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new CaliumStorageAttribute(getOwner());
|
||||
cloned.ConverterTotalCalium = ConverterTotalCalium;
|
||||
cloned.DailyConvertRate = DailyConvertRate;
|
||||
cloned.OperatorTotalCalium = OperatorTotalCalium;
|
||||
cloned.DailyApplyEpoch = DailyApplyEpoch;
|
||||
cloned.DailyInflationRate = DailyInflationRate;
|
||||
cloned.DailyPivotDate = DailyPivotDate;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new CaliumStorageAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(otherEntityAttribute, () => $"otherEntityAttribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var result = new Result();
|
||||
string err_msg;
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var calium_storage_attribute = otherEntityAttribute as CaliumStorageAttribute;
|
||||
if (null == calium_storage_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast CaliumAttribute !!!, calium_storage_attribute is null - {toBasicString()}, {owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ConverterTotalCalium = calium_storage_attribute.ConverterTotalCalium;
|
||||
DailyConvertRate = calium_storage_attribute.DailyConvertRate;
|
||||
OperatorTotalCalium = calium_storage_attribute.OperatorTotalCalium;
|
||||
DailyApplyEpoch = calium_storage_attribute.DailyApplyEpoch;
|
||||
DailyInflationRate = calium_storage_attribute.DailyInflationRate;
|
||||
DailyPivotDate = calium_storage_attribute.DailyPivotDate;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? newDocBase)
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var calium_storage_doc = newDocBase as CaliumStorageDoc;
|
||||
if (null == calium_storage_doc)
|
||||
{
|
||||
var err_msg = $"calium_doc is null !!!, in copyEntityAttributeFromDoc() - docName:{nameof(CaliumStorageDoc)} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Origin Doc => Attribute
|
||||
//=====================================================================================
|
||||
var calium_storage_attrib = calium_storage_doc.getAttrib<CaliumStorageAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(calium_storage_attrib, () => $"calium_storage_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
ConverterTotalCalium = calium_storage_attrib.ConverterStorage.TotalCalium;
|
||||
DailyConvertRate = calium_storage_attrib.ConverterStorage.DailyConvertRate;
|
||||
DailyPivotDate = calium_storage_attrib.DailyPivotDate;
|
||||
DailyApplyEpoch = calium_storage_attrib.DailyEpoch;
|
||||
|
||||
OperatorTotalCalium = calium_storage_attrib.OperatorStorage.TotalCalium;
|
||||
|
||||
DailyInflationRate = calium_storage_attrib.ExchangerStorage.DailyInflationRate;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class CaliumStorageAttributeTransactor : EntityAttributeTransactorBase<CaliumAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public CaliumStorageAttributeTransactor(EntityBase owner) : base(owner) { }
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
string err_msg;
|
||||
|
||||
var copy_from_calium_storage_attribute = entityAttributeBase as CaliumStorageAttribute;
|
||||
|
||||
if (null == copy_from_calium_storage_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_calium_storage_attribute is null :{nameof(CaliumAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_calium_storage_attribute = getClonedEntityAttribute() as CaliumStorageAttribute;
|
||||
if (null == copy_to_calium_storage_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_calium_storage_attribute is null :{nameof(CaliumAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_calium_storage_attribute.ConverterTotalCalium = copy_from_calium_storage_attribute.ConverterTotalCalium;
|
||||
copy_to_calium_storage_attribute.DailyConvertRate = copy_from_calium_storage_attribute.DailyConvertRate;
|
||||
copy_to_calium_storage_attribute.OperatorTotalCalium = copy_from_calium_storage_attribute.OperatorTotalCalium;
|
||||
copy_to_calium_storage_attribute.DailyApplyEpoch = copy_from_calium_storage_attribute.DailyApplyEpoch;
|
||||
copy_to_calium_storage_attribute.DailyInflationRate = copy_from_calium_storage_attribute.DailyInflationRate;
|
||||
copy_to_calium_storage_attribute.DailyPivotDate = copy_from_calium_storage_attribute.DailyPivotDate;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
247
ServerCommon/Entity/Attribute/CartAttribute.cs
Normal file
247
ServerCommon/Entity/Attribute/CartAttribute.cs
Normal file
@@ -0,0 +1,247 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Numerics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
using META_ID = System.UInt32;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class CartAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public Dictionary<CurrencyType, Dictionary<META_ID/*ItemMetaID*/, Int32/*Count*/>> CartItems { get; set; } = new();
|
||||
|
||||
public CartAttribute(EntityBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
var currencyTypes = EnumHelper.getValues<CurrencyType>();
|
||||
foreach (var currencyType in currencyTypes)
|
||||
{
|
||||
CartItems.TryAdd(currencyType, new());
|
||||
}
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
foreach (var value in CartItems.Values)
|
||||
{
|
||||
value.Clear();
|
||||
}
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
var player = getOwner().getRootParent() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
return new CartAttributeTransactor(player);
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner().getRootParent() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var entity_of_owner_entity_type = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(entity_of_owner_entity_type, () => $"entity_of_owner_entity_type is null !!!");
|
||||
|
||||
var cloned = new CartAttribute(owner, entity_of_owner_entity_type);
|
||||
cloned.CartItems = CartItems.ToDictionary(x => x.Key, y => new Dictionary<META_ID, Int32>(y.Value.ToDictionary(x => x.Key, y => y.Value)));
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner().getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var acoount_attribute = owner.getEntityAttribute<AccountAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(acoount_attribute, () => $"acoount_attribute is null !!!");
|
||||
|
||||
USER_GUID user_guid = acoount_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as CartDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new CartDoc(user_guid);
|
||||
|
||||
var origin_doc = getOriginDocBase<CartAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<CartAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!!");
|
||||
|
||||
to_copy_doc_attrib.CartItems = CartItems.ToDictionary(x => x.Key, y => new Dictionary<META_ID, Int32>(y.Value.ToDictionary(x => x.Key, y => y.Value)));
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(CartDoc).Name;
|
||||
|
||||
var cart_doc_base = docBase as CartDoc;
|
||||
if (null == cart_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, cart_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<CartAttribute>(cart_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = cart_doc_base.getAttrib<CartAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_attrib, () => $"doc_attrib is null !!!");
|
||||
|
||||
CartItems = doc_attrib.CartItems.ToDictionary(x => x.Key, y => new Dictionary<META_ID, Int32>(y.Value.ToDictionary(x => x.Key, y => y.Value)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var cart_attribute = otherEntityAttribute as CartAttribute;
|
||||
if (null == cart_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast CartAttribute !!!, cart_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CartItems = cart_attribute.CartItems.ToDictionary(x => x.Key, y => new Dictionary<META_ID, Int32>(y.Value.ToDictionary(x => x.Key, y => y.Value)));
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = cart_attribute.getTryPendingDocBase() as CartDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
cart_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<CartAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<CartAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var cart_attrib = origin_doc_base.getAttrib<CartAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(cart_attrib, () => $"cart_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
cart_attrib.CartItems = CartItems.ToDictionary(x => x.Key, y => new Dictionary<META_ID, Int32>(y.Value.ToDictionary(x => x.Key, y => y.Value)));
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class CartAttributeTransactor : EntityAttributeTransactorBase<CartAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public CartAttributeTransactor(UserBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(CartAttribute).Name;
|
||||
|
||||
var copy_from_cart_attribute = entityAttributeBase as CartAttribute;
|
||||
if (null == copy_from_cart_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_cart_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_cart_attribute = getClonedEntityAttribute() as CartAttribute;
|
||||
if (null == copy_to_cart_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_cart_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_cart_attribute.CartItems = copy_from_cart_attribute.CartItems.ToDictionary(x => x.Key, y => new Dictionary<META_ID, Int32>(y.Value.ToDictionary(x => x.Key, y => y.Value)));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
398
ServerCommon/Entity/Attribute/CharacterAttribute.cs
Normal file
398
ServerCommon/Entity/Attribute/CharacterAttribute.cs
Normal file
@@ -0,0 +1,398 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
using ServerControlCenter;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class CharacterAttribute : EntityAttributeBase, ICopyEntityAttributeFromMeta, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
public class AppearanceProfile
|
||||
{
|
||||
public UInt32 BasicStyle { get; set; } = 0;
|
||||
|
||||
public UInt32 BodyShape { get; set; } = 0;
|
||||
|
||||
public UInt32 HairStyle { get; set; } = 0;
|
||||
|
||||
public List<int> CustomValues { get; set; } = new();
|
||||
|
||||
// 캐릭터 외형 커스터마이징 절차 완료 여부를 설정 한다. 서버 주도로 관리되어야 하는 정보 !!!
|
||||
public bool IsCustomCompleted { get; set; } = false;
|
||||
|
||||
public void reset()
|
||||
{
|
||||
BasicStyle = 0;
|
||||
BodyShape = 0;
|
||||
HairStyle = 0;
|
||||
CustomValues.Clear();
|
||||
IsCustomCompleted = false;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
var clone = new AppearanceProfile();
|
||||
clone.BasicStyle = BasicStyle;
|
||||
clone.BodyShape = BodyShape;
|
||||
clone.HairStyle = HairStyle;
|
||||
clone.CustomValues = CustomValues.Select(x => x).ToList();
|
||||
clone.IsCustomCompleted = IsCustomCompleted;
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
public void copyFromAppearanceProfile(CharacterBaseAttrib.AppearanceProfile docAttrib)
|
||||
{
|
||||
BasicStyle = docAttrib.BasicStyle;
|
||||
BodyShape = docAttrib.BodyShape;
|
||||
HairStyle = docAttrib.HairStyle;
|
||||
CustomValues = docAttrib.CustomValues.Select(x => x).ToList();
|
||||
IsCustomCompleted = docAttrib.IsCustomCompleted;
|
||||
}
|
||||
}
|
||||
|
||||
[JsonProperty]
|
||||
public CHARACTER_GUID CharacterGuid { get; set; } = string.Empty;
|
||||
|
||||
|
||||
public EntityStateInfo StateInfo { get; set; } = new();
|
||||
|
||||
public AppearanceProfile AppearanceProfileValue { get; set; } = new();
|
||||
|
||||
|
||||
public CharacterAttribute(EntityBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
}
|
||||
|
||||
public override void newEntityAttribute()
|
||||
{
|
||||
CharacterGuid = System.Guid.NewGuid().ToString("N");
|
||||
base.newEntityAttribute();
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
CharacterGuid = string.Empty;
|
||||
|
||||
AppearanceProfileValue.reset();
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var entity_of_owner_entity_type = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(entity_of_owner_entity_type, () => $"entity_of_owner_entity_type is null !!!");
|
||||
var cloned = new CharacterAttribute(owner, entity_of_owner_entity_type);
|
||||
|
||||
cloned.CharacterGuid = CharacterGuid;
|
||||
var cloned_appearance_profile = (AppearanceProfile)AppearanceProfileValue.Clone();
|
||||
NullReferenceCheckHelper.throwIfNull(cloned_appearance_profile, () => $"parent cloned_appearance_profile null !!! - {owner.toBasicString()}");
|
||||
|
||||
cloned.AppearanceProfileValue = cloned_appearance_profile;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new CharacterAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!! - {owner.toBasicString()}");
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var user_attribute = parent.getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var user_guid = user_attribute.UserGuid;
|
||||
|
||||
var try_pending_doc = getTryPendingDocBase() as CharacterBaseDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new CharacterBaseDoc(user_guid, CharacterGuid);
|
||||
|
||||
var origin_doc = getOriginDocBase<CharacterAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => Doc
|
||||
//=====================================================================================
|
||||
var to_copy_doc_character_base_attrib = try_pending_doc.getAttrib<CharacterBaseAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_character_base_attrib, () => $"to_copy_doc_character_base_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
to_copy_doc_character_base_attrib.CharacterGuid = CharacterGuid;
|
||||
to_copy_doc_character_base_attrib.UserGuid = user_guid;
|
||||
to_copy_doc_character_base_attrib.StateInfo = StateInfo;
|
||||
to_copy_doc_character_base_attrib.ApperanceProfileValue.copyFromAppearanceProfile(AppearanceProfileValue);
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!! - {owner.toBasicString()}");
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null - {owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
var user_attribute = parent.getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {owner.toBasicString()}");
|
||||
var user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var other_character_attribute = otherEntityAttribute as CharacterAttribute;
|
||||
if (null == other_character_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast !!!, other_character_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CharacterGuid = other_character_attribute.CharacterGuid;
|
||||
StateInfo = other_character_attribute.StateInfo;
|
||||
AppearanceProfileValue = (AppearanceProfile)other_character_attribute.AppearanceProfileValue.Clone();
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_character_attribute.getTryPendingDocBase() as CharacterBaseDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_character_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<CharacterAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<CharacterAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var character_base_attrib = origin_doc_base.getAttrib<CharacterBaseAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(character_base_attrib, () => $"character_base_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
character_base_attrib.CharacterGuid = CharacterGuid;
|
||||
character_base_attrib.StateInfo = StateInfo;
|
||||
character_base_attrib.ApperanceProfileValue.copyFromAppearanceProfile(AppearanceProfileValue);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromMeta(MetaAssets.IMetaData customMeta)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
bool is_success = false;
|
||||
|
||||
var test_user_create_data = customMeta as MetaAssets.TestUserCreateMetaData;
|
||||
if (null != test_user_create_data)
|
||||
{
|
||||
is_success = copyEntityAttributeFromTestUserCreateData(test_user_create_data);
|
||||
}
|
||||
|
||||
var user_create_data = customMeta as MetaAssets.UserCreateMetaData;
|
||||
if(null != user_create_data)
|
||||
{
|
||||
is_success = copyEntityAttributeFromUserCreateData(user_create_data);
|
||||
}
|
||||
|
||||
if (false == is_success)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromMeta() !!! : {customMeta.getTypeName()} - {getOwner().toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool copyEntityAttributeFromTestUserCreateData(MetaAssets.TestUserCreateMetaData testUserCreateData)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(MetaAssets.TestUserCreateMetaData).Name;
|
||||
if (null == testUserCreateData)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromTestUserCreateData() !!!, testUserCreateData is null : {to_cast_string} - {getOwner().toBasicString()}";
|
||||
Log.getLogger().warn(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
AppearanceProfileValue.BasicStyle = (UInt32)testUserCreateData.BasicStyle;
|
||||
AppearanceProfileValue.BodyShape = (UInt32)testUserCreateData.BodyShape;
|
||||
AppearanceProfileValue.HairStyle = (UInt32)testUserCreateData.HairStyle;
|
||||
AppearanceProfileValue.CustomValues = testUserCreateData.CustomValues.Select(x => x).ToList();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool copyEntityAttributeFromUserCreateData(MetaAssets.UserCreateMetaData userCreateData)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(MetaAssets.UserCreateMetaData).Name;
|
||||
if (null == userCreateData)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromUserCreateData() !!!, userCreateData is null : {to_cast_string}";
|
||||
Log.getLogger().warn(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var to_cast_string = typeof(CharacterBaseDoc).Name;
|
||||
var character_doc_base = docBase as CharacterBaseDoc;
|
||||
if (null == character_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, character_doc_base is null :{to_cast_string} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<CharacterAttribute>(character_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_character_base_attrib = character_doc_base.getAttrib<CharacterBaseAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_character_base_attrib, () => $"doc_character_base_attrib is null !!! - {owner.toBasicString()}");
|
||||
CharacterGuid = doc_character_base_attrib.CharacterGuid;
|
||||
StateInfo = doc_character_base_attrib.StateInfo;
|
||||
AppearanceProfileValue.copyFromAppearanceProfile(doc_character_base_attrib.ApperanceProfileValue);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class CharacterAttributeTransactor : EntityAttributeTransactorBase<CharacterAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public CharacterAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(CharacterAttribute).Name;
|
||||
|
||||
var copy_from_character_attribute = entityAttributeBase as CharacterAttribute;
|
||||
if (null == copy_from_character_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_character_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_character_attribute = getClonedEntityAttribute() as CharacterAttribute;
|
||||
if (null == copy_to_character_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_character_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_character_attribute.CharacterGuid = copy_from_character_attribute.CharacterGuid;
|
||||
copy_to_character_attribute.StateInfo = copy_from_character_attribute.StateInfo;
|
||||
copy_to_character_attribute.AppearanceProfileValue = (CharacterAttribute.AppearanceProfile)(copy_from_character_attribute.AppearanceProfileValue.Clone());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
260
ServerCommon/Entity/Attribute/CharacterProfileAttribute.cs
Normal file
260
ServerCommon/Entity/Attribute/CharacterProfileAttribute.cs
Normal file
@@ -0,0 +1,260 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
using Amazon.S3.Model;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class CharacterProfileAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
public string SNSLick { get; set; } = string.Empty;
|
||||
public string Message { get; set; } = string.Empty;
|
||||
|
||||
public CharacterProfileAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
SNSLick = string.Empty;
|
||||
Message = string.Empty;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public CharacterProfileAttribute Cloned()
|
||||
{
|
||||
var owner = getOwner() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var cloned = new CharacterProfileAttribute(owner);
|
||||
cloned.SNSLick = SNSLick;
|
||||
cloned.Message = Message;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var cloned = new CharacterProfileAttribute(owner);
|
||||
cloned.SNSLick = SNSLick;
|
||||
cloned.Message = Message;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
var owner = getOwner() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
return new CharacterProfileAttributeTransactor(owner);
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var acoount_attribute = owner.getEntityAttribute<AccountAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(acoount_attribute, () => $"acoount_attribute is null !!!");
|
||||
|
||||
USER_GUID user_guid = acoount_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as CharacterProfileDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new CharacterProfileDoc(user_guid);
|
||||
|
||||
var origin_doc = getOriginDocBase<CharacterProfileAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<CharacterProfileAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!!");
|
||||
|
||||
to_copy_doc_attrib.SNSLick = SNSLick;
|
||||
to_copy_doc_attrib.Message = Message;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(CharacterProfileDoc).Name;
|
||||
|
||||
var character_profile_doc_base = docBase as CharacterProfileDoc;
|
||||
if (null == character_profile_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, character_profile_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<CharacterProfileAttribute>(character_profile_doc_base);
|
||||
|
||||
var doc_attrib = character_profile_doc_base.getAttrib<CharacterProfileAttrib>();
|
||||
if (doc_attrib == null)
|
||||
{
|
||||
err_msg = $"Failed to get character profile attrib : {nameof(CharacterProfileAttrib)}";
|
||||
result.setFail(ServerErrorCode.EntityAttributeIsNull, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
SNSLick = doc_attrib.SNSLick;
|
||||
Message = doc_attrib.Message;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var character_profile_attribute = otherEntityAttribute as CharacterProfileAttribute;
|
||||
if (null == character_profile_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast CharacterProfileAttribute !!!, character_profile_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
|
||||
SNSLick = character_profile_attribute.SNSLick;
|
||||
Message = character_profile_attribute.Message;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = character_profile_attribute.getTryPendingDocBase() as CharacterProfileDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
character_profile_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<CharacterProfileAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<CharacterProfileAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var character_profile_attrib = origin_doc_base.getAttrib<CharacterProfileAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(character_profile_attrib, () => $"character_profile_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
character_profile_attrib.SNSLick = SNSLick;
|
||||
character_profile_attrib.Message = Message;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class CharacterProfileAttributeTransactor : EntityAttributeTransactorBase<CharacterProfileAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public CharacterProfileAttributeTransactor(UserBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(CharacterProfileAttribute).Name;
|
||||
|
||||
var copy_from_character_profile_attribute = entityAttributeBase as CharacterProfileAttribute;
|
||||
if (null == copy_from_character_profile_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_character_profile_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_character_profile_attribute = getClonedEntityAttribute() as CharacterProfileAttribute;
|
||||
if (null == copy_to_character_profile_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_character_profile_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_character_profile_attribute.SNSLick = copy_from_character_profile_attribute.SNSLick;
|
||||
copy_to_character_profile_attribute.Message = copy_from_character_profile_attribute.Message;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
242
ServerCommon/Entity/Attribute/ClaimAttribute.cs
Normal file
242
ServerCommon/Entity/Attribute/ClaimAttribute.cs
Normal file
@@ -0,0 +1,242 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Amazon.S3.Model;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerControlCenter;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class ClaimAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public MetaAssets.ClaimType ClaimType { get; set; } = MetaAssets.ClaimType.None;
|
||||
[JsonProperty]
|
||||
public int ClaimId { get; set; } = 0;
|
||||
[JsonProperty]
|
||||
public int ActiveRewardIdx { get; set; } = 0;
|
||||
|
||||
public DateTime ActiveTime { get; set; } = new();
|
||||
|
||||
[JsonProperty]
|
||||
public DateTime CreateTime { get; set; } = new();
|
||||
[JsonProperty]
|
||||
public DateTime CompleteTime { get; set; } = new();
|
||||
|
||||
public int IsComplete { get; set; } = 0;
|
||||
|
||||
|
||||
public ClaimAttribute( EntityBase owner, MetaAssets.ClaimType type
|
||||
, EntityBase entityOfOwnerEntityType )
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
ClaimType = type;
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
ClaimType = MetaAssets.ClaimType.None;
|
||||
ClaimId = 0;
|
||||
ActiveRewardIdx = 0;
|
||||
ActiveTime = DateTimeHelper.MinTime;
|
||||
CreateTime = DateTimeHelper.MinTime;
|
||||
CompleteTime = DateTimeHelper.MaxTime;
|
||||
IsComplete = 0;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var user_attribute = owner.getRootParent().getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!!");
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as ClaimDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new ClaimDoc(user_attribute.UserGuid, ClaimType, ClaimId);
|
||||
|
||||
var origin_doc = getOriginDocBase<ClaimAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_claim_attrib = try_pending_doc.getAttrib<ClaimAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_claim_attrib, () => $"to_copy_claim_attrib is null !!!");
|
||||
|
||||
to_copy_claim_attrib.ClaimType = ClaimType;
|
||||
to_copy_claim_attrib.ClaimId = ClaimId;
|
||||
to_copy_claim_attrib.ActiveRewardIdx = ActiveRewardIdx;
|
||||
to_copy_claim_attrib.ActiveTime = ActiveTime;
|
||||
to_copy_claim_attrib.CreateTime = CreateTime;
|
||||
to_copy_claim_attrib.CompleteTime = CompleteTime;
|
||||
to_copy_claim_attrib.IsComplete = IsComplete;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var entity_of_owner_entity_type = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(entity_of_owner_entity_type, () => $"entity_of_owner_entity_type is null !!!");
|
||||
|
||||
var cloned = new ClaimAttribute(owner, ClaimType, entity_of_owner_entity_type);
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.ActiveTime = ActiveTime;
|
||||
cloned.ClaimType = ClaimType;
|
||||
cloned.ClaimId = ClaimId;
|
||||
cloned.ActiveRewardIdx = ActiveRewardIdx;
|
||||
cloned.CompleteTime = CompleteTime;
|
||||
cloned.IsComplete = IsComplete;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
|
||||
var other_attribute = otherEntityAttribute as ClaimAttribute;
|
||||
if (null == other_attribute)
|
||||
{
|
||||
var err_msg = $"Failed to cast ClaimAttribute !!!, other_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
ClaimType = other_attribute.ClaimType;
|
||||
ClaimId = other_attribute.ClaimId;
|
||||
ActiveRewardIdx = other_attribute.ActiveRewardIdx;
|
||||
ActiveTime = other_attribute.ActiveTime;
|
||||
CreateTime = other_attribute.CreateTime;
|
||||
CompleteTime = other_attribute.CompleteTime;
|
||||
IsComplete = other_attribute.IsComplete;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_attribute.getTryPendingDocBase() as ClaimDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<ClaimAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<ClaimAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var claim_attrib = origin_doc_base.getAttrib<ClaimAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(claim_attrib, () => $"claim_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
claim_attrib.ClaimType = ClaimType;
|
||||
claim_attrib.ClaimId = ClaimId;
|
||||
claim_attrib.ActiveRewardIdx = ActiveRewardIdx;
|
||||
claim_attrib.ActiveTime = ActiveTime;
|
||||
claim_attrib.CreateTime = CreateTime;
|
||||
claim_attrib.CompleteTime = CompleteTime;
|
||||
claim_attrib.IsComplete = IsComplete;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase customDoc)
|
||||
{
|
||||
var claim_doc_base = customDoc as ClaimDoc;
|
||||
if (null == claim_doc_base)
|
||||
{
|
||||
var to_cast_string = typeof(ClaimDoc).Name;
|
||||
var err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, claime_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<ClaimAttribute>(claim_doc_base);
|
||||
|
||||
var claim_attrib = claim_doc_base.getAttrib<ClaimAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(claim_attrib, () => $"claim_attrib is null !!!");
|
||||
|
||||
ClaimType = claim_attrib.ClaimType;
|
||||
ClaimId = claim_attrib.ClaimId;
|
||||
ActiveRewardIdx = claim_attrib.ActiveRewardIdx;
|
||||
ActiveTime = claim_attrib.ActiveTime;
|
||||
CreateTime = claim_attrib.CreateTime;
|
||||
CompleteTime = claim_attrib.CompleteTime;
|
||||
IsComplete = claim_attrib.IsComplete;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new ClaimAtrributeTransactor(getOwner());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class ClaimAtrributeTransactor : EntityAttributeTransactorBase<ClaimAttribute>
|
||||
{
|
||||
public ClaimAtrributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorBaseFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
//아직 미사용
|
||||
Log.getLogger().info("copyEntityAttributeTransactorBaseFromEntityAttribute call");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
273
ServerCommon/Entity/Attribute/CraftAttribute.cs
Normal file
273
ServerCommon/Entity/Attribute/CraftAttribute.cs
Normal file
@@ -0,0 +1,273 @@
|
||||
using Newtonsoft.Json;
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
|
||||
using BEACON_GUID = System.String;
|
||||
using META_ID = System.UInt32;
|
||||
using ANCHOR_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using Amazon.S3.Model;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class CraftAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public ANCHOR_GUID AnchorGuid { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public META_ID CraftMetaId { get; set; } = 0;
|
||||
[JsonProperty]
|
||||
public DateTime CraftStartTime { get; set; } = new();
|
||||
[JsonProperty]
|
||||
public DateTime CraftFinishTime { get; set; } = new();
|
||||
[JsonProperty]
|
||||
public BEACON_GUID BeaconGuid { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public int CraftCount { get; set; } = 1;
|
||||
|
||||
|
||||
public CraftAttribute(EntityBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
AnchorGuid = string.Empty;
|
||||
CraftMetaId = 0;
|
||||
CraftStartTime = new();
|
||||
CraftFinishTime = new();
|
||||
BeaconGuid = string.Empty;
|
||||
CraftCount = 1;
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var entity_of_owner_entity_type = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(entity_of_owner_entity_type, () => $"entity_of_owner_entity_type is null !!!");
|
||||
|
||||
var cloned = new CraftAttribute(getOwner(), entity_of_owner_entity_type);
|
||||
cloned.AnchorGuid = AnchorGuid;
|
||||
cloned.CraftMetaId = CraftMetaId;
|
||||
cloned.CraftStartTime = CraftStartTime;
|
||||
cloned.CraftFinishTime = CraftFinishTime;
|
||||
cloned.BeaconGuid = BeaconGuid;
|
||||
cloned.CraftCount = CraftCount;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new CraftAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var acoount_attribute = getOwner().getRootParent().getEntityAttribute<AccountAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(acoount_attribute, () => $"acoount_attribute is null !!!");
|
||||
|
||||
USER_GUID user_guid = acoount_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as CraftDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new CraftDoc(user_guid, AnchorGuid);
|
||||
|
||||
var origin_doc = getOriginDocBase<CraftAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<CraftAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!!");
|
||||
|
||||
to_copy_doc_attrib.AnchorGuid = AnchorGuid;
|
||||
to_copy_doc_attrib.CraftMetaId = CraftMetaId;
|
||||
to_copy_doc_attrib.CraftStartTime = CraftStartTime;
|
||||
to_copy_doc_attrib.CraftFinishTime = CraftFinishTime;
|
||||
to_copy_doc_attrib.BeaconGuid = BeaconGuid;
|
||||
to_copy_doc_attrib.CraftCount = CraftCount;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(CraftDoc).Name;
|
||||
|
||||
var craft_doc_base = docBase as CraftDoc;
|
||||
if (null == craft_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, craft_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<CraftAttribute>(craft_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = craft_doc_base.getAttrib<CraftAttrib>();
|
||||
if (doc_attrib == null)
|
||||
{
|
||||
err_msg = $"Failed to get craft attrib : {nameof(CraftAttrib)}";
|
||||
result.setFail(ServerErrorCode.EntityAttributeIsNull, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
AnchorGuid = doc_attrib.AnchorGuid;
|
||||
CraftMetaId = doc_attrib.CraftMetaId;
|
||||
CraftStartTime = doc_attrib.CraftStartTime;
|
||||
CraftFinishTime = doc_attrib.CraftFinishTime;
|
||||
BeaconGuid = doc_attrib.BeaconGuid;
|
||||
CraftCount = doc_attrib.CraftCount;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var craft_attribute = otherEntityAttribute as CraftAttribute;
|
||||
if (null == craft_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast Attribute !!!, craft_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
AnchorGuid = craft_attribute.AnchorGuid;
|
||||
CraftMetaId = craft_attribute.CraftMetaId;
|
||||
CraftStartTime = craft_attribute.CraftStartTime;
|
||||
CraftFinishTime = craft_attribute.CraftFinishTime;
|
||||
BeaconGuid = craft_attribute.BeaconGuid;
|
||||
CraftCount = craft_attribute.CraftCount;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = craft_attribute.getTryPendingDocBase() as CraftDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
craft_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<CraftAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<CraftAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var craft_attrib = origin_doc_base.getAttrib<CraftAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(craft_attrib, () => $"craft_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
craft_attrib.AnchorGuid = AnchorGuid;
|
||||
craft_attrib.CraftMetaId = CraftMetaId;
|
||||
craft_attrib.CraftStartTime = CraftStartTime;
|
||||
craft_attrib.CraftFinishTime = CraftFinishTime;
|
||||
craft_attrib.BeaconGuid = BeaconGuid;
|
||||
craft_attrib.CraftCount = CraftCount;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public class CraftAttributeTransactor : EntityAttributeTransactorBase<CraftAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public CraftAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(CraftAttribute).Name;
|
||||
|
||||
var copy_from_attribute = entityAttributeBase as CraftAttribute;
|
||||
if (null == copy_from_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_craft_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_attribute = getClonedEntityAttribute() as CraftAttribute;
|
||||
if (null == copy_to_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_craft_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_attribute.AnchorGuid = copy_from_attribute.AnchorGuid;
|
||||
copy_to_attribute.CraftMetaId = copy_from_attribute.CraftMetaId;
|
||||
copy_to_attribute.CraftStartTime = copy_from_attribute.CraftStartTime;
|
||||
copy_to_attribute.CraftFinishTime = copy_from_attribute.CraftFinishTime;
|
||||
copy_to_attribute.BeaconGuid = copy_from_attribute.BeaconGuid;
|
||||
copy_to_attribute.CraftCount = copy_from_attribute.CraftCount;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
241
ServerCommon/Entity/Attribute/CraftHelpAttribute.cs
Normal file
241
ServerCommon/Entity/Attribute/CraftHelpAttribute.cs
Normal file
@@ -0,0 +1,241 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class CraftHelpAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public List<USER_GUID> HelpUserGuids { get; set; } = new();
|
||||
[JsonProperty]
|
||||
public List<USER_GUID> HelpedUserGuids { get; set; } = new();
|
||||
[JsonProperty]
|
||||
public DateTime CraftHelpUpdateDay { get; set; } = DateTime.UtcNow;
|
||||
|
||||
|
||||
public CraftHelpAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
HelpUserGuids.Clear();
|
||||
HelpedUserGuids.Clear();
|
||||
CraftHelpUpdateDay = new();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new CraftHelpAttribute(getOwner());
|
||||
cloned.HelpUserGuids = HelpUserGuids.Select(x => x).ToList();
|
||||
cloned.HelpedUserGuids = HelpedUserGuids.Select(x => x).ToList();
|
||||
cloned.CraftHelpUpdateDay = CraftHelpUpdateDay;
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new CraftHelpAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var acoount_attribute = getOwner().getRootParent().getEntityAttribute<AccountAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(acoount_attribute, () => $"acoount_attribute is null !!!");
|
||||
|
||||
USER_GUID user_guid = acoount_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as CraftHelpDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new CraftHelpDoc(user_guid);
|
||||
|
||||
var origin_doc = getOriginDocBase<CraftHelpAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<CraftHelpAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!!");
|
||||
|
||||
to_copy_doc_attrib.HelpUserGuids = HelpUserGuids.Select(x => x).ToList();
|
||||
to_copy_doc_attrib.HelpedUserGuids = HelpedUserGuids.Select(x => x).ToList();
|
||||
to_copy_doc_attrib.CraftHelpUpdateDay = CraftHelpUpdateDay;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(CraftHelpDoc).Name;
|
||||
|
||||
var craft_help_doc_base = docBase as CraftHelpDoc;
|
||||
if (null == craft_help_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, craft_help_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<CraftHelpAttribute>(craft_help_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = craft_help_doc_base.getAttrib<CraftHelpAttrib>();
|
||||
if (doc_attrib == null)
|
||||
{
|
||||
err_msg = $"Failed to get craft help attrib : {nameof(CraftHelpAttrib)}";
|
||||
result.setFail(ServerErrorCode.EntityAttributeIsNull, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
HelpUserGuids = doc_attrib.HelpUserGuids.Select(x => x).ToList();
|
||||
HelpedUserGuids = doc_attrib.HelpedUserGuids.Select(x => x).ToList();
|
||||
CraftHelpUpdateDay = doc_attrib.CraftHelpUpdateDay;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var craft_help_attribute = otherEntityAttribute as CraftHelpAttribute;
|
||||
if (null == craft_help_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast Attribute !!!, craft_help_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
HelpUserGuids = craft_help_attribute.HelpUserGuids.Select(x => x).ToList();
|
||||
HelpedUserGuids = craft_help_attribute.HelpedUserGuids.Select(x => x).ToList();
|
||||
CraftHelpUpdateDay = craft_help_attribute.CraftHelpUpdateDay;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = craft_help_attribute.getTryPendingDocBase() as CraftHelpDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
craft_help_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<CraftHelpAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<CraftHelpAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var craft_help_attrib = origin_doc_base.getAttrib<CraftHelpAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(craft_help_attrib, () => $"craft_help_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
craft_help_attrib.HelpUserGuids = HelpUserGuids.Select(x => x).ToList();
|
||||
craft_help_attrib.HelpedUserGuids = HelpedUserGuids.Select(x => x).ToList();
|
||||
craft_help_attrib.CraftHelpUpdateDay = CraftHelpUpdateDay;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public class CraftHelpAttributeTransactor : EntityAttributeTransactorBase<CraftHelpAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public CraftHelpAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(CraftHelpAttribute).Name;
|
||||
|
||||
var copy_from_help_attribute = entityAttributeBase as CraftHelpAttribute;
|
||||
if (null == copy_from_help_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_craft_help_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_help_attribute = getClonedEntityAttribute() as CraftHelpAttribute;
|
||||
if (null == copy_to_help_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_craft_help_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_help_attribute.HelpUserGuids = copy_from_help_attribute.HelpUserGuids.Select(x => x).ToList();
|
||||
copy_to_help_attribute.HelpedUserGuids = copy_from_help_attribute.HelpedUserGuids.Select(x => x).ToList();
|
||||
copy_to_help_attribute.CraftHelpUpdateDay = copy_from_help_attribute.CraftHelpUpdateDay;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
227
ServerCommon/Entity/Attribute/CraftRecipeAttribute.cs
Normal file
227
ServerCommon/Entity/Attribute/CraftRecipeAttribute.cs
Normal file
@@ -0,0 +1,227 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using META_ID = System.UInt32;
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class CraftRecipeAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public META_ID CraftMetaId { get; set; } = 0;
|
||||
|
||||
public CraftRecipeAttribute(EntityBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
CraftMetaId = 0;
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var entity_of_owner_entity_type = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(entity_of_owner_entity_type, () => $"entity_of_owner_entity_type is null !!!");
|
||||
|
||||
var cloned = new CraftRecipeAttribute(getOwner(), entity_of_owner_entity_type);
|
||||
cloned.CraftMetaId = CraftMetaId;
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new RecipeAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var acoount_attribute = getOwner().getRootParent().getEntityAttribute<AccountAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(acoount_attribute, () => $"acoount_attribute is null !!!");
|
||||
|
||||
USER_GUID user_guid = acoount_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as CraftRecipeDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new CraftRecipeDoc(user_guid, CraftMetaId);
|
||||
|
||||
var origin_doc = getOriginDocBase<CraftRecipeAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<CraftRecipeAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!!");
|
||||
|
||||
to_copy_doc_attrib.CraftMetaId = CraftMetaId;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_docs) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, to_query_docs);
|
||||
}
|
||||
|
||||
return (result, to_query_docs);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(CraftRecipeDoc).Name;
|
||||
|
||||
var recipe_doc_base = docBase as CraftRecipeDoc;
|
||||
if (null == recipe_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, recipe_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<CraftRecipeAttribute>(recipe_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = recipe_doc_base.getAttrib<CraftRecipeAttrib>();
|
||||
if (doc_attrib == null)
|
||||
{
|
||||
err_msg = $"Failed to get craft recipe attrib : {nameof(CraftRecipeAttrib)}";
|
||||
result.setFail(ServerErrorCode.EntityAttributeIsNull, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
CraftMetaId = doc_attrib.CraftMetaId;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var recipe_attribute = otherEntityAttribute as CraftRecipeAttribute;
|
||||
if (null == recipe_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast RecipeAttribute !!!, recipe_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CraftMetaId = recipe_attribute.CraftMetaId;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = recipe_attribute.getTryPendingDocBase() as CraftRecipeDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
recipe_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<CraftRecipeAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<CraftRecipeAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var craft_recipe_attrib = origin_doc_base.getAttrib<CraftRecipeAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(craft_recipe_attrib, () => $"craft_recipe_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
craft_recipe_attrib.CraftMetaId = CraftMetaId;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class RecipeAttributeTransactor : EntityAttributeTransactorBase<CraftRecipeAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public RecipeAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(CraftRecipeAttribute).Name;
|
||||
|
||||
var copy_from_recipe_attribute = entityAttributeBase as CraftRecipeAttribute;
|
||||
if (null == copy_from_recipe_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_recipe_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_recipe_attribute = getClonedEntityAttribute() as CraftRecipeAttribute;
|
||||
if (null == copy_to_recipe_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_recipe_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_recipe_attribute.CraftMetaId = copy_from_recipe_attribute.CraftMetaId;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
261
ServerCommon/Entity/Attribute/CustomDefinedDataAttribute.cs
Normal file
261
ServerCommon/Entity/Attribute/CustomDefinedDataAttribute.cs
Normal file
@@ -0,0 +1,261 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Microsoft.AspNetCore.DataProtection.KeyManagement;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
using UI_KEY = System.String;
|
||||
using DATA_KEY = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
//=============================================================================================
|
||||
//
|
||||
// 클라이언트 Data 전용 DB 저장 정보
|
||||
//
|
||||
// - 서버측에서 로직 관여 하지 않는다. (읽기, 쓰기 only)
|
||||
// - 추후 String 타입으로 하나의 변수로 저장 하도록 수정 한다. (전용 패킷 추가, 클라이언트와 협의)
|
||||
//
|
||||
//=============================================================================================
|
||||
|
||||
public class CustomDefinedDataAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
public DATA_KEY DataKey { get; set; } = string.Empty;
|
||||
public string CustomDefinedData { get; set; } = string.Empty;
|
||||
|
||||
|
||||
public CustomDefinedDataAttribute(EntityBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new CustomDefinedDataAttributeTransactor(getOwner().getRootParent());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
DataKey = string.Empty;
|
||||
CustomDefinedData = string.Empty;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var entity_of_owner_entity_type = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(entity_of_owner_entity_type, () => $"entity_of_owner_entity_type is null !!!");
|
||||
|
||||
var cloned = new CustomDefinedDataAttribute(owner, entity_of_owner_entity_type);
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.DataKey = DataKey;
|
||||
cloned.CustomDefinedData = CustomDefinedData;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var owner = getOwner();
|
||||
var parent = owner.getRootParent();
|
||||
|
||||
var result = new Result();
|
||||
|
||||
var user_attribute = parent.getOriginEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {parent.toBasicString()}");
|
||||
|
||||
var user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as CustomDefinedDataDoc ;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new CustomDefinedDataDoc(OwnerEntityType.User, user_guid, DataKey);
|
||||
|
||||
var origin_doc = getOriginDocBase<CustomDefinedDataAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_custom_defined_data_attrib = try_pending_doc.getAttrib<CustomDefinedDataAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_custom_defined_data_attrib, () => $"to_copy_doc_custom_defined_data_attrib is null !!! - {parent.toBasicString()}");
|
||||
|
||||
to_copy_doc_custom_defined_data_attrib.CustomDefinedData = CustomDefinedData;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var owner = getOwner();
|
||||
var parent = owner.getRootParent();
|
||||
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(CustomDefinedUiDoc).Name;
|
||||
|
||||
var custom_defined_data_doc = docBase as CustomDefinedDataDoc;
|
||||
if (null == custom_defined_data_doc)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, custom_defined_ui_doc is null :{to_cast_string} - {parent.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<CustomDefinedDataAttribute>(custom_defined_data_doc);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Doc, Attribute
|
||||
//=====================================================================================
|
||||
var doc_custom_defined_data_attrib = custom_defined_data_doc.getAttrib<CustomDefinedDataAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_custom_defined_data_attrib, () => $"doc_custom_defined_data_attrib is null !!! - {parent.toBasicString()}");
|
||||
|
||||
DataKey = doc_custom_defined_data_attrib.DataKey;
|
||||
CustomDefinedData = doc_custom_defined_data_attrib.CustomDefinedData;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
var parent = owner.getRootParent();
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null - {parent.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var custom_defined_data_attribute = otherEntityAttribute as CustomDefinedDataAttribute;
|
||||
if (null == custom_defined_data_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast CustomDefinedDataAttribute !!!, custom_defined_data_attribute is null - {parent.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CustomDefinedData = custom_defined_data_attribute.CustomDefinedData;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = custom_defined_data_attribute.getTryPendingDocBase() as CustomDefinedDataDoc ;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
custom_defined_data_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<CustomDefinedDataAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<CustomDefinedDataAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var custom_defined_data_attrib = origin_doc_base.getAttrib<CustomDefinedDataAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(custom_defined_data_attrib, () => $"custom_defined_data_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
custom_defined_data_attrib.CustomDefinedData = CustomDefinedData;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class CustomDefinedDataAttributeTransactor : EntityAttributeTransactorBase<CustomDefinedDataAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public CustomDefinedDataAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(CustomDefinedUiAttribute).Name;
|
||||
|
||||
var copy_from_custom_defined_data_attribute = entityAttributeBase as CustomDefinedDataAttribute;
|
||||
if (null == copy_from_custom_defined_data_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_custom_defined_data_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_custom_defined_data_attribute = getClonedEntityAttribute() as CustomDefinedDataAttribute;
|
||||
if (null == copy_to_custom_defined_data_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_to_custom_defined_data_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_custom_defined_data_attribute.DataKey = copy_from_custom_defined_data_attribute.DataKey;
|
||||
copy_to_custom_defined_data_attribute.CustomDefinedData = copy_from_custom_defined_data_attribute.CustomDefinedData;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
271
ServerCommon/Entity/Attribute/CustomDefinedUiAttribute.cs
Normal file
271
ServerCommon/Entity/Attribute/CustomDefinedUiAttribute.cs
Normal file
@@ -0,0 +1,271 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Xml.Linq;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Microsoft.AspNetCore.DataProtection.KeyManagement;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
using UI_KEY = System.String;
|
||||
using DATA_KEY = System.String;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
//=============================================================================================
|
||||
//
|
||||
// 클라이언트 UI 전용 DB 저장 정보
|
||||
//
|
||||
// - 서버측에서 로직 관여 하지 않는다. (읽기, 쓰기 only)
|
||||
// - 추후 String 타입으로 하나의 변수로 저장 하도록 수정 한다. (전용 패킷 추가, 클라이언트와 협의)
|
||||
//
|
||||
//=============================================================================================
|
||||
|
||||
public class CustomDefinedUiAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
public UI_KEY UiKey { get; set; } = string.Empty;
|
||||
public string CustomDefinedUi { get; set; } = string.Empty;
|
||||
|
||||
|
||||
public CustomDefinedUiAttribute(EntityBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new CustomDefinedUiAttributeTransactor(getOwner().getRootParent());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
UiKey = string.Empty;
|
||||
CustomDefinedUi = string.Empty;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var entity_of_owner_entity_type = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(entity_of_owner_entity_type, () => $"entity_of_owner_entity_type is null !!!");
|
||||
|
||||
var cloned = new CustomDefinedUiAttribute(owner, entity_of_owner_entity_type);
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.UiKey = UiKey;
|
||||
cloned.CustomDefinedUi = CustomDefinedUi;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var owner = getOwner();
|
||||
var parent = owner.getRootParent();
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (false == parent.isValidOwnerEntityType())
|
||||
{
|
||||
err_msg = $"Invalid OwnerEntityType Invalid !!! - {parent.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.OwnerEntityTypeInvalid, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as CustomDefinedUiDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new CustomDefinedUiDoc( parent.getEntityType().toOwnerEntityType(), parent.onGetDbGuid()
|
||||
, UiKey);
|
||||
|
||||
var origin_doc = getOriginDocBase<CustomDefinedUiAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_custom_defined_ui_attrib = try_pending_doc.getAttrib<CustomDefinedUiAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_custom_defined_ui_attrib, () => $"to_copy_doc_custom_defined_ui_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
to_copy_doc_custom_defined_ui_attrib.CustomDefinedUi = CustomDefinedUi;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var owner = getOwner();
|
||||
var parent = owner.getRootParent();
|
||||
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(CustomDefinedUiDoc).Name;
|
||||
|
||||
var custom_defined_ui_doc = docBase as CustomDefinedUiDoc;
|
||||
if (null == custom_defined_ui_doc)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, custom_defined_ui_doc is null :{to_cast_string} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<CustomDefinedUiAttribute>(custom_defined_ui_doc);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_custom_defined_ui_attrib = custom_defined_ui_doc.getAttrib<CustomDefinedUiAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_custom_defined_ui_attrib, () => $"doc_custom_defined_ui_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
UiKey = doc_custom_defined_ui_attrib.UiKey;
|
||||
CustomDefinedUi = doc_custom_defined_ui_attrib.CustomDefinedUi;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
var parent = owner.getRootParent();
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null - {parent.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var custom_defined_ui_attribute = otherEntityAttribute as CustomDefinedUiAttribute;
|
||||
if (null == custom_defined_ui_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast CustomDefinedUISaveAttribute !!!, custom_defined_ui_attribute is null - {parent.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
CustomDefinedUi = custom_defined_ui_attribute.CustomDefinedUi;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = custom_defined_ui_attribute.getTryPendingDocBase() as CustomDefinedUiDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
custom_defined_ui_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<CustomDefinedUiAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<CustomDefinedUiAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var custom_defined_ui_attrib = origin_doc_base.getAttrib<CustomDefinedUiAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(custom_defined_ui_attrib, () => $"custom_defined_ui_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
custom_defined_ui_attrib.CustomDefinedUi = CustomDefinedUi;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class CustomDefinedUiAttributeTransactor : EntityAttributeTransactorBase<CustomDefinedUiAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public CustomDefinedUiAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(CustomDefinedUiAttribute).Name;
|
||||
|
||||
var copy_from_custom_defined_ui_attribute = entityAttributeBase as CustomDefinedUiAttribute;
|
||||
if (null == copy_from_custom_defined_ui_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_from_custom_defined_ui_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_custom_defined_ui_attribute = getClonedEntityAttribute() as CustomDefinedUiAttribute;
|
||||
if (null == copy_to_custom_defined_ui_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_to_custom_defined_ui_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_custom_defined_ui_attribute.UiKey = copy_from_custom_defined_ui_attribute.UiKey;
|
||||
copy_to_custom_defined_ui_attribute.CustomDefinedUi = copy_from_custom_defined_ui_attribute.CustomDefinedUi;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
213
ServerCommon/Entity/Attribute/DailyQuestCheckAttribute.cs
Normal file
213
ServerCommon/Entity/Attribute/DailyQuestCheckAttribute.cs
Normal file
@@ -0,0 +1,213 @@
|
||||
using System.Collections.Concurrent;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class DailyQuestCheckAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
public HashSet<UInt32> m_daily_sended_quest { get; set; } = new();
|
||||
|
||||
public DateTime m_next_refresh_time { get; set; } = DateTimeHelper.Current.Date.AddDays(-1);
|
||||
|
||||
public DailyQuestCheckDoc? m_daily_quest_check_doc_nullable { get; set; } = null;
|
||||
|
||||
|
||||
|
||||
public DailyQuestCheckAttribute(EntityBase owner) : base(owner)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var daily_quest_check_attribute = owner.getEntityAttribute<DailyQuestCheckAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(daily_quest_check_attribute, () => $"daily_quest_check_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var user_attribute = owner.getRootParent().getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
USER_GUID user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as DailyQuestCheckDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new DailyQuestCheckDoc(user_guid);
|
||||
|
||||
var origin_doc = getOriginDocBase<DailyQuestCheckAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_daily_quest_check_attrib = try_pending_doc.getAttrib<DailyQuestCheckAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_daily_quest_check_attrib, () => $"to_copy_daily_quest_check_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
foreach (var id in m_daily_sended_quest)
|
||||
{
|
||||
to_copy_daily_quest_check_attrib.m_daily_sended_quest.Add(id);
|
||||
}
|
||||
to_copy_daily_quest_check_attrib.m_next_refresh_time = m_next_refresh_time;
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(var result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new DailyQuestCheckAttribute(getOwner());
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.m_next_refresh_time = m_next_refresh_time;
|
||||
foreach (var id in m_daily_sended_quest)
|
||||
{
|
||||
cloned.m_daily_sended_quest.Add(id);
|
||||
}
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (getAttributeState().hasFlag(StateType.Removed))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
var owner = getOwner();
|
||||
|
||||
var other_attribute = otherEntityAttribute as DailyQuestCheckAttribute;
|
||||
if (null == other_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast DailyQuestCheckAttribute !!!, other_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
foreach (var id in other_attribute.m_daily_sended_quest)
|
||||
{
|
||||
m_daily_sended_quest.Add(id);
|
||||
}
|
||||
m_next_refresh_time = other_attribute.m_next_refresh_time;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_attribute.getTryPendingDocBase() as DailyQuestCheckDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<DailyQuestCheckAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<DailyQuestCheckAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var daily_quest_check_attrib = origin_doc_base.getAttrib<DailyQuestCheckAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(daily_quest_check_attrib, () => $"daily_quest_check_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
foreach (var id in m_daily_sended_quest)
|
||||
{
|
||||
daily_quest_check_attrib.m_daily_sended_quest.Add(id);
|
||||
}
|
||||
daily_quest_check_attrib.m_next_refresh_time = m_next_refresh_time;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(DailyQuestCheckDoc).Name;
|
||||
|
||||
var daily_quest_check_doc = docBase as DailyQuestCheckDoc;
|
||||
if (null == daily_quest_check_doc)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, daily_quest_check_doc is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<DailyQuestCheckAttribute>(daily_quest_check_doc);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var daily_quest_check_attrib = daily_quest_check_doc.getAttrib<DailyQuestCheckAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(daily_quest_check_attrib, () => $"daily_quest_check_attrib is null !!!");
|
||||
|
||||
foreach (var id in daily_quest_check_attrib.m_daily_sended_quest)
|
||||
{
|
||||
m_daily_sended_quest.Add(id);
|
||||
}
|
||||
m_next_refresh_time = daily_quest_check_attrib.m_next_refresh_time;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new DailyQuestCheckTransactor(getOwner());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class DailyQuestCheckTransactor : EntityAttributeTransactorBase<DailyQuestCheckAttribute>
|
||||
{
|
||||
public DailyQuestCheckTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorBaseFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
209
ServerCommon/Entity/Attribute/EndQuestAttribute.cs
Normal file
209
ServerCommon/Entity/Attribute/EndQuestAttribute.cs
Normal file
@@ -0,0 +1,209 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class EndQuestAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public UInt32 QuestId { get; set; } = 0;
|
||||
[JsonProperty]
|
||||
public UInt32 QuestRevision { get; set; } = 0;
|
||||
[JsonProperty]
|
||||
public Int32 EndCount { get; set; } = 0;
|
||||
[JsonProperty]
|
||||
public DateTime LastEndTime { get; set; } = DateTimeHelper.MinTime;
|
||||
[JsonProperty]
|
||||
public string m_user_guid { get; set; } = string.Empty;
|
||||
|
||||
|
||||
public EndQuestAttribute( EntityBase owner
|
||||
, string userGuid, UInt32 questId, UInt32 questRevision
|
||||
, EntityBase entityOfOwnerEntityType )
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
m_user_guid = userGuid;
|
||||
QuestId = questId;
|
||||
QuestRevision = questRevision;
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
m_user_guid = string.Empty;
|
||||
QuestId = 0;
|
||||
QuestRevision = 0;
|
||||
EndCount = 0;
|
||||
LastEndTime = DateTimeHelper.MinTime;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var end_quest_attribute = owner.getEntityAttribute<EndQuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(end_quest_attribute, () => $"end_quest_attribute is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as EndQuestDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new EndQuestDoc(m_user_guid, QuestId, QuestRevision);
|
||||
|
||||
var origin_doc = getOriginDocBase<EndQuestAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_quest_attrib = try_pending_doc.getAttrib<EndQuestAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_quest_attrib, () => $"to_copy_quest_attrib is null !!!");
|
||||
|
||||
to_copy_quest_attrib.m_quest_id = end_quest_attribute.QuestId;
|
||||
to_copy_quest_attrib.m_quest_revision = end_quest_attribute.QuestRevision;
|
||||
to_copy_quest_attrib.m_end_count = end_quest_attribute.EndCount;
|
||||
to_copy_quest_attrib.m_last_end_time = end_quest_attribute.LastEndTime;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_docs) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, to_query_docs);
|
||||
}
|
||||
|
||||
return (result, to_query_docs);
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var entity_of_owner_entity_type = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(entity_of_owner_entity_type, () => $"entity_of_owner_entity_type is null !!!");
|
||||
|
||||
var cloned = new EndQuestAttribute( getOwner()
|
||||
, m_user_guid, QuestId, QuestRevision
|
||||
, entity_of_owner_entity_type );
|
||||
cloned.deepCopyFromBase(this);
|
||||
cloned.QuestId = QuestId;
|
||||
cloned.QuestRevision = QuestRevision;
|
||||
cloned.EndCount = EndCount;
|
||||
cloned.LastEndTime = LastEndTime;
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
|
||||
var other_attribute = otherEntityAttribute as EndQuestAttribute;
|
||||
if (null == other_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast EndQuestAttribute !!!, other_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
QuestId = other_attribute.QuestId;
|
||||
QuestRevision = other_attribute.QuestRevision;
|
||||
EndCount = other_attribute.EndCount;
|
||||
LastEndTime = other_attribute.LastEndTime;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_attribute.getTryPendingDocBase() as EndQuestDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<EndQuestAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<EndQuestAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var end_quest_attrib = origin_doc_base.getAttrib<EndQuestAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(end_quest_attrib, () => $"end_quest_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
end_quest_attrib.m_quest_id = QuestId;
|
||||
end_quest_attrib.m_quest_revision = QuestRevision;
|
||||
end_quest_attrib.m_end_count = EndCount;
|
||||
end_quest_attrib.m_last_end_time = LastEndTime;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase customDoc)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new EndQuestAtrributeTransactor(getOwner());
|
||||
}
|
||||
}
|
||||
|
||||
public class EndQuestAtrributeTransactor : EntityAttributeTransactorBase<EndQuestAttribute>
|
||||
{
|
||||
public EndQuestAtrributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorBaseFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
//아직 미사용
|
||||
Log.getLogger().info("copyEntityDbTransactBaseFromEntityAttribute call");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
247
ServerCommon/Entity/Attribute/EntityAlertRecordAttribute.cs
Normal file
247
ServerCommon/Entity/Attribute/EntityAlertRecordAttribute.cs
Normal file
@@ -0,0 +1,247 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using META_ID = System.UInt32;
|
||||
using ALERT_KEY = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class EntityAlertRecordAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public ALERT_KEY AlertKey { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public DateTime AlertedTime { get; set; } = DateTimeHelper.MinTime;
|
||||
|
||||
[JsonProperty]
|
||||
public OwnerEntityType OwnerEntityType { get; set; } = OwnerEntityType.None;
|
||||
[JsonProperty]
|
||||
public OWNER_GUID OwnerGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public EntityAlertTriggerType EntityAlertTriggerType { get; set; } = EntityAlertTriggerType.None;
|
||||
[JsonProperty]
|
||||
public META_ID MetaId { get; set; } = 0;
|
||||
|
||||
public EntityAlertRecordAttribute(EntityBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new EntityAlertHistoryAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
AlertKey = string.Empty;
|
||||
AlertedTime = DateTimeHelper.MinTime;
|
||||
OwnerEntityType = OwnerEntityType.None;
|
||||
OwnerGuid = string.Empty;
|
||||
EntityAlertTriggerType = EntityAlertTriggerType.None;
|
||||
MetaId = 0;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner_entity_type = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(owner_entity_type, () => $"Owner Entity Type is null !!! ");
|
||||
|
||||
var cloned = new EntityAlertRecordAttribute(getOwner(), owner_entity_type);
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.AlertKey = AlertKey;
|
||||
cloned.AlertedTime = AlertedTime;
|
||||
cloned.OwnerEntityType = OwnerEntityType;
|
||||
cloned.OwnerGuid = OwnerGuid;
|
||||
cloned.EntityAlertTriggerType = EntityAlertTriggerType;
|
||||
cloned.MetaId = MetaId;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var owner_entity_type = owner.onGetOwnerEntityType();
|
||||
var owner_guid = owner.onGetGuidOfOwnerEntityType();
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as EntityAlertRecordDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new EntityAlertRecordDoc( owner_guid, EntityAlertRecordDoc.makeALERT_KEY(EntityAlertTriggerType, MetaId), AlertedTime
|
||||
, owner_entity_type, EntityAlertTriggerType, MetaId );
|
||||
|
||||
var origin_doc = getOriginDocBase<EntityAlertRecordAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<EntityAlertRecordAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
to_copy_doc_attrib.AlertKey = AlertKey;
|
||||
to_copy_doc_attrib.AlertedTime = AlertedTime;
|
||||
to_copy_doc_attrib.OwnerEntityType = OwnerEntityType;
|
||||
to_copy_doc_attrib.OwnerGuid = OwnerGuid;
|
||||
to_copy_doc_attrib.EntityAlertTriggerType = EntityAlertTriggerType;
|
||||
to_copy_doc_attrib.MetaId = MetaId;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_docs) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_docs);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(EntityAlertRecordDoc).Name;
|
||||
|
||||
var alert_record_doc = docBase as EntityAlertRecordDoc;
|
||||
if (null == alert_record_doc)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, alert_record_doc is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<EntityAlertRecordAttribute>(alert_record_doc);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = alert_record_doc.getAttrib<EntityAlertRecordAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_attrib, () => $"doc_attrib is null !!! - {getOwner().toBasicString()}");
|
||||
|
||||
AlertKey = doc_attrib.AlertKey;
|
||||
AlertedTime = doc_attrib.AlertedTime;
|
||||
OwnerEntityType = doc_attrib.OwnerEntityType;
|
||||
OwnerGuid = doc_attrib.OwnerGuid;
|
||||
EntityAlertTriggerType = doc_attrib.EntityAlertTriggerType;
|
||||
MetaId = doc_attrib.MetaId;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var alert_record_attribute = otherEntityAttribute as EntityAlertRecordAttribute;
|
||||
if (null == alert_record_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast EntityAlertHistoryAttribute !!!, alert_record_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
AlertKey = alert_record_attribute.AlertKey;
|
||||
AlertedTime = alert_record_attribute.AlertedTime;
|
||||
OwnerEntityType = alert_record_attribute.OwnerEntityType;
|
||||
OwnerGuid = alert_record_attribute.OwnerGuid;
|
||||
EntityAlertTriggerType = alert_record_attribute.EntityAlertTriggerType;
|
||||
MetaId = alert_record_attribute.MetaId;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = alert_record_attribute.getTryPendingDocBase() as EntityAlertRecordDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
alert_record_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<EntityAlertRecordAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<EntityAlertRecordAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var alert_record_attrib = origin_doc_base.getAttrib<EntityAlertRecordAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(alert_record_attrib, () => $"alert_record_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
alert_record_attrib.AlertKey = AlertKey;
|
||||
alert_record_attrib.AlertedTime = AlertedTime;
|
||||
alert_record_attrib.OwnerEntityType = OwnerEntityType;
|
||||
alert_record_attrib.OwnerGuid = OwnerGuid;
|
||||
alert_record_attrib.EntityAlertTriggerType = EntityAlertTriggerType;
|
||||
alert_record_attrib.MetaId = MetaId;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class EntityAlertHistoryAttributeTransactor : EntityAttributeTransactorBase<EntityAlertRecordAttribute>
|
||||
{
|
||||
public EntityAlertHistoryAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
220
ServerCommon/Entity/Attribute/EscapePositionAttribute.cs
Normal file
220
ServerCommon/Entity/Attribute/EscapePositionAttribute.cs
Normal file
@@ -0,0 +1,220 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
using META_ID = System.UInt32;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class EscapePositionAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public DateTime escape_available_time = new();
|
||||
|
||||
public EscapePositionAttribute(UserBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(EscapePositionDoc).Name;
|
||||
|
||||
var escape_position_doc_base = docBase as EscapePositionDoc;
|
||||
if (null == escape_position_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, escape_position_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<EscapePositionAttribute>(escape_position_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Doc, Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = escape_position_doc_base.getAttrib<EscapePositionAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_attrib, () => $"doc_attrib is null !!!");
|
||||
|
||||
escape_available_time = doc_attrib.escape_available_time;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
escape_available_time = new();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var cloned = new EscapePositionAttribute(owner);
|
||||
cloned.escape_available_time = escape_available_time;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var escape_position_attribute = otherEntityAttribute as EscapePositionAttribute;
|
||||
if (null == escape_position_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast EscapePositionAttribute !!!, escape_position_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
escape_available_time = escape_position_attribute.escape_available_time;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = escape_position_attribute.getTryPendingDocBase() as EscapePositionDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
escape_position_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<EscapePositionAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<EscapePositionAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var escape_position_attrib = origin_doc_base.getAttrib<EscapePositionAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(escape_position_attrib, () => $"escape_position_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
escape_position_attrib.escape_available_time = escape_available_time;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
var owner = getOwner() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
return new EscapePositionAttributeTransactor(owner);
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var acoount_attribute = owner.getEntityAttribute<AccountAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(acoount_attribute, () => $"acoount_attribute is null !!!");
|
||||
|
||||
USER_GUID user_guid = acoount_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as EscapePositionDoc;
|
||||
if (try_pending_doc == null)
|
||||
{
|
||||
var to_copy_doc = new EscapePositionDoc(user_guid);
|
||||
|
||||
var origin_doc = getOriginDocBase<EscapePositionAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var escape_position_attrib = try_pending_doc.getAttrib<EscapePositionAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(escape_position_attrib, () => $"escape_position_attrib is null !!!");
|
||||
|
||||
escape_position_attrib.escape_available_time = escape_available_time;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
}
|
||||
public class EscapePositionAttributeTransactor : EntityAttributeTransactorBase<EscapePositionAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public EscapePositionAttributeTransactor(UserBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(EscapePositionAttribute).Name;
|
||||
|
||||
var copy_from_escape_position_attribute = entityAttributeBase as EscapePositionAttribute;
|
||||
if (null == copy_from_escape_position_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_escape_position_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_escape_position_attribute = getClonedEntityAttribute() as EscapePositionAttribute;
|
||||
if (null == copy_to_escape_position_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_escape_position_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_escape_position_attribute.escape_available_time = copy_from_escape_position_attribute.escape_available_time;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
390
ServerCommon/Entity/Attribute/FarmingEffectAttribute.cs
Normal file
390
ServerCommon/Entity/Attribute/FarmingEffectAttribute.cs
Normal file
@@ -0,0 +1,390 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
using ENTITY_UNIQUE_ID = System.String;
|
||||
using ANCHOR_META_GUID = System.String;
|
||||
using NPC_UNIQUE_ID = System.String;
|
||||
using FARMING_ENTITY_GUID = System.String;
|
||||
using LOCATION_UNIQUE_ID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class FarmingEffectAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public ANCHOR_META_GUID AnchorMetaGuid { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public LOCATION_UNIQUE_ID LocationUniqueId { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public META_ID FarmingPropMetaId { get; set; } = 0;
|
||||
|
||||
// 파밍 효과를 요청한 OwnerEntityType.User
|
||||
[JsonProperty]
|
||||
public OwnerEntityType OwnerEntityType { get; set; } = OwnerEntityType.None;
|
||||
// 파밍 효과를 요청한 OwnerEntityType.User GUID
|
||||
[JsonProperty]
|
||||
public OWNER_GUID OwnerGuid { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public FarmingSummonedEntityType FarmingSummonedEntityType { get; set; } = FarmingSummonedEntityType.None;
|
||||
|
||||
// FarmingSummonedEntityType.User: UserGuid, FarmingSummonedEntityType.Beacon: UgcNpcMetaGuid:
|
||||
[JsonProperty]
|
||||
public FARMING_ENTITY_GUID FarmingEntityGuid { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public FarmingStateType FarmingState { get; set; } = FarmingStateType.None;
|
||||
|
||||
[JsonProperty]
|
||||
public Int16 FarmingActionReqTryCount { get; set; } = 0;
|
||||
[JsonProperty]
|
||||
public Int16 CompletedRewardCount { get; set; } = 0;
|
||||
|
||||
public DateTime FarmingLastUpdateTime { get; set; } = DateTimeHelper.MinTime;
|
||||
[JsonProperty]
|
||||
public DateTime FarmingStartTime { get; set; } = DateTimeHelper.MinTime;
|
||||
[JsonProperty]
|
||||
public DateTime FarmingEndTime { get; set; } = DateTimeHelper.MinTime;
|
||||
|
||||
public DateTime FarmingRespawnTime { get; set; } = DateTimeHelper.MinTime;
|
||||
|
||||
|
||||
|
||||
public FarmingEffectAttribute(EntityBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
OwnerEntityType = entityOfOwnerEntityType.onGetOwnerEntityType();
|
||||
OwnerGuid = entityOfOwnerEntityType.onGetGuidOfOwnerEntityType();
|
||||
FarmingState = FarmingStateType.StandBy;
|
||||
}
|
||||
|
||||
public async Task<(Result, EntityHelper.MasterProfile?)> getMasterProfile<TMasterEntity>()
|
||||
where TMasterEntity : EntityBase
|
||||
{
|
||||
var owner = getOwner();
|
||||
var root_parent = owner.getRootParent();
|
||||
|
||||
var server_logic = ServerLogicApp.getServerLogicApp();
|
||||
var server_config = server_logic.getServerConfig();
|
||||
var dynamo_db_client = server_logic.getDynamoDbClient();
|
||||
|
||||
var table_name = ServerBase.DynamoDbDefine.TableNames.Main;
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
(result, var master_profile) = EntityHelper.getMasterProfile<TMasterEntity>(root_parent);
|
||||
if (result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to EntityHelper.getMasterProfile<TMasterEntity>() !!! : {result.toBasicString()} - {owner.toBasicString()}";
|
||||
Log.getLogger().debug(err_msg);
|
||||
|
||||
if(OwnerEntityType.User != OwnerEntityType)
|
||||
{
|
||||
err_msg = $"Invalid OwnerEntityType !!! : OwnerEntityType.User == OwnerEntityType - {owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.OwnerEntityTypeInvalid, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
if (true == OwnerGuid.isNullOrWhiteSpace())
|
||||
{
|
||||
err_msg = $"Invalid OwnerGuid !!! : OwnerGuid:{OwnerGuid} - {owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.OwnerGuidInvalid, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
(result, var found_nickname_attrib) = await dynamo_db_client.simpleQueryDocTypeToAttrib<NicknameDoc, NicknameAttrib>(table_name, OwnerGuid);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
NullReferenceCheckHelper.throwIfNull(found_nickname_attrib, () => $"found_nickname_attrib in null !!! - {owner.toBasicString()}");
|
||||
|
||||
master_profile = new EntityHelper.MasterProfile();
|
||||
master_profile.MasterGuid = OwnerGuid;
|
||||
master_profile.MasterNickname = found_nickname_attrib.Nickname;
|
||||
}
|
||||
|
||||
return (result, master_profile);
|
||||
}
|
||||
|
||||
public override void newEntityAttribute()
|
||||
{
|
||||
base.newEntityAttribute();
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
AnchorMetaGuid = string.Empty;
|
||||
LocationUniqueId = string.Empty;
|
||||
FarmingPropMetaId = 0;
|
||||
OwnerEntityType = OwnerEntityType.None;
|
||||
OwnerGuid = string.Empty;
|
||||
|
||||
FarmingSummonedEntityType = FarmingSummonedEntityType.None;
|
||||
FarmingEntityGuid = string.Empty;
|
||||
FarmingState = FarmingStateType.None;
|
||||
|
||||
FarmingActionReqTryCount = 0;
|
||||
CompletedRewardCount = 0;
|
||||
FarmingLastUpdateTime = DateTimeHelper.MinTime;
|
||||
|
||||
FarmingStartTime = DateTimeHelper.MinTime;
|
||||
FarmingEndTime = DateTimeHelper.MinTime;
|
||||
FarmingRespawnTime = DateTimeHelper.MinTime;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var entity_of_owner_entity_type = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(entity_of_owner_entity_type, () => $"entity_of_owner_entity_type is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var cloned = new FarmingEffectAttribute(getOwner(), entity_of_owner_entity_type);
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.AnchorMetaGuid = AnchorMetaGuid;
|
||||
cloned.LocationUniqueId = LocationUniqueId;
|
||||
cloned.FarmingPropMetaId = FarmingPropMetaId;
|
||||
cloned.OwnerEntityType = OwnerEntityType;
|
||||
cloned.OwnerGuid = OwnerGuid;
|
||||
cloned.FarmingSummonedEntityType = FarmingSummonedEntityType;
|
||||
cloned.FarmingEntityGuid = FarmingEntityGuid;
|
||||
cloned.FarmingState = FarmingState;
|
||||
cloned.FarmingActionReqTryCount = FarmingActionReqTryCount;
|
||||
cloned.CompletedRewardCount = CompletedRewardCount;
|
||||
cloned.FarmingLastUpdateTime = FarmingLastUpdateTime;
|
||||
cloned.FarmingStartTime = FarmingStartTime;
|
||||
cloned.FarmingEndTime = FarmingEndTime;
|
||||
cloned.FarmingRespawnTime = FarmingRespawnTime;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new FarmingEffectAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as FarmingEffectDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new FarmingEffectDoc( AnchorMetaGuid, LocationUniqueId
|
||||
, FarmingPropMetaId
|
||||
, FarmingSummonedEntityType, FarmingEntityGuid
|
||||
, FarmingState
|
||||
, FarmingActionReqTryCount
|
||||
, FarmingStartTime, FarmingEndTime);
|
||||
|
||||
var origin_doc = getOriginDocBase<FarmingEffectAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_farming_effect_attrib = try_pending_doc.getAttrib<FarmingEffectAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_farming_effect_attrib, () => $"to_copy_doc_farming_effect_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
to_copy_doc_farming_effect_attrib.AnchorMetaGuid = AnchorMetaGuid;
|
||||
to_copy_doc_farming_effect_attrib.LocationUniqueId = LocationUniqueId;
|
||||
to_copy_doc_farming_effect_attrib.FarmingPropMetaId = FarmingPropMetaId;
|
||||
to_copy_doc_farming_effect_attrib.FarmingSummonedEntityType = FarmingSummonedEntityType;
|
||||
to_copy_doc_farming_effect_attrib.FarmingEntityGuid = FarmingEntityGuid;
|
||||
to_copy_doc_farming_effect_attrib.FarmingState = FarmingState;
|
||||
to_copy_doc_farming_effect_attrib.FarmingActionReqTryCount = FarmingActionReqTryCount;
|
||||
to_copy_doc_farming_effect_attrib.CompletedRewardCount = CompletedRewardCount;
|
||||
to_copy_doc_farming_effect_attrib.FarmingLastUpdateTime = FarmingLastUpdateTime;
|
||||
to_copy_doc_farming_effect_attrib.FarmingStartTime = FarmingStartTime;
|
||||
to_copy_doc_farming_effect_attrib.FarmingEndTime = FarmingEndTime;
|
||||
to_copy_doc_farming_effect_attrib.FarmingRespawnTime = FarmingRespawnTime;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Origin Attribute
|
||||
//=====================================================================================
|
||||
var other_farming_effect_attribute = otherEntityAttribute as FarmingEffectAttribute;
|
||||
if (null == other_farming_effect_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast FarmingEffectAttribute !!!, other_farming_effect_attribute is null - {owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
AnchorMetaGuid = other_farming_effect_attribute.AnchorMetaGuid;
|
||||
LocationUniqueId = other_farming_effect_attribute.LocationUniqueId;
|
||||
FarmingPropMetaId = other_farming_effect_attribute.FarmingPropMetaId;
|
||||
OwnerEntityType = other_farming_effect_attribute.OwnerEntityType;
|
||||
OwnerGuid = other_farming_effect_attribute.OwnerGuid;
|
||||
FarmingSummonedEntityType = other_farming_effect_attribute.FarmingSummonedEntityType;
|
||||
FarmingEntityGuid = other_farming_effect_attribute.FarmingEntityGuid;
|
||||
FarmingState = other_farming_effect_attribute.FarmingState;
|
||||
FarmingActionReqTryCount = other_farming_effect_attribute.FarmingActionReqTryCount;
|
||||
CompletedRewardCount = other_farming_effect_attribute.CompletedRewardCount;
|
||||
FarmingLastUpdateTime = other_farming_effect_attribute.FarmingLastUpdateTime;
|
||||
FarmingStartTime = other_farming_effect_attribute.FarmingStartTime;
|
||||
FarmingEndTime = other_farming_effect_attribute.FarmingEndTime;
|
||||
FarmingRespawnTime = other_farming_effect_attribute.FarmingRespawnTime;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_farming_effect_attribute.getTryPendingDocBase() as FarmingEffectDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_farming_effect_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<FarmingEffectAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<FarmingEffectAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var farming_effect_attrib = origin_doc_base.getAttrib<FarmingEffectAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(farming_effect_attrib, () => $"farming_effect_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
farming_effect_attrib.AnchorMetaGuid = AnchorMetaGuid;
|
||||
farming_effect_attrib.LocationUniqueId = LocationUniqueId;
|
||||
farming_effect_attrib.FarmingPropMetaId = FarmingPropMetaId;
|
||||
farming_effect_attrib.FarmingSummonedEntityType = FarmingSummonedEntityType;
|
||||
farming_effect_attrib.FarmingEntityGuid = FarmingEntityGuid;
|
||||
farming_effect_attrib.FarmingState = FarmingState;
|
||||
farming_effect_attrib.FarmingActionReqTryCount = FarmingActionReqTryCount;
|
||||
farming_effect_attrib.CompletedRewardCount = CompletedRewardCount;
|
||||
farming_effect_attrib.FarmingLastUpdateTime = FarmingLastUpdateTime;
|
||||
farming_effect_attrib.FarmingStartTime = FarmingStartTime;
|
||||
farming_effect_attrib.FarmingEndTime = FarmingEndTime;
|
||||
farming_effect_attrib.FarmingRespawnTime = FarmingRespawnTime;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
|
||||
var to_cast_string = typeof(FarmingEffectDoc).Name;
|
||||
|
||||
var farming_effect_doc = docBase as FarmingEffectDoc;
|
||||
if (null == farming_effect_doc)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, farming_effect_doc is null :{to_cast_string} - {owner.toBasicString}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<FarmingEffectAttribute>(farming_effect_doc);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var farming_effect_attrib = farming_effect_doc.getAttrib<FarmingEffectAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(farming_effect_attrib, () => $"farming_effect_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
AnchorMetaGuid = farming_effect_attrib.AnchorMetaGuid;
|
||||
LocationUniqueId = farming_effect_attrib.LocationUniqueId;
|
||||
FarmingPropMetaId = farming_effect_attrib.FarmingPropMetaId;
|
||||
FarmingSummonedEntityType = farming_effect_attrib.FarmingSummonedEntityType;
|
||||
FarmingEntityGuid = farming_effect_attrib.FarmingEntityGuid;
|
||||
FarmingState = farming_effect_attrib.FarmingState;
|
||||
FarmingActionReqTryCount = farming_effect_attrib.FarmingActionReqTryCount;
|
||||
CompletedRewardCount = farming_effect_attrib.CompletedRewardCount;
|
||||
FarmingLastUpdateTime = farming_effect_attrib.FarmingLastUpdateTime;
|
||||
FarmingStartTime = farming_effect_attrib.FarmingStartTime;
|
||||
FarmingEndTime = farming_effect_attrib.FarmingEndTime;
|
||||
FarmingRespawnTime = farming_effect_attrib.FarmingRespawnTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class FarmingEffectAttributeTransactor : EntityAttributeTransactorBase<FarmingEffectAttribute>
|
||||
{
|
||||
public FarmingEffectAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,264 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using USER_NICKNAME = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
using ENTITY_UNIQUE_ID = System.String;
|
||||
using ANCHOR_META_GUID = System.String;
|
||||
using NPC_UNIQUE_ID = System.String;
|
||||
using FARMING_ENTITY_GUID = System.String;
|
||||
using LOCATION_UNIQUE_ID = System.String;
|
||||
using FARMING_EFFECT_DOC_LINK_PKSK = System.String;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class FarmingEffectLocationInTargetAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public LOCATION_UNIQUE_ID LocationUniqueId { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public ANCHOR_META_GUID AnchorMetaGuid { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public USER_GUID UserGuid { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public USER_NICKNAME UserNickname { get; set; } = string.Empty;
|
||||
|
||||
public FARMING_EFFECT_DOC_LINK_PKSK FarmingEffectDocLinkPKSK { get; set; } = string.Empty;
|
||||
|
||||
|
||||
|
||||
public FarmingEffectLocationInTargetAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void newEntityAttribute()
|
||||
{
|
||||
base.newEntityAttribute();
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
LocationUniqueId = string.Empty;
|
||||
AnchorMetaGuid = string.Empty;
|
||||
UserGuid = string.Empty;
|
||||
UserNickname = string.Empty;
|
||||
FarmingEffectDocLinkPKSK = string.Empty;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var cloned = new FarmingEffectLocationInTargetAttribute(owner);
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.LocationUniqueId = LocationUniqueId;
|
||||
cloned.AnchorMetaGuid = AnchorMetaGuid;
|
||||
cloned.UserGuid = UserGuid;
|
||||
cloned.UserNickname = UserNickname;
|
||||
cloned.FarmingEffectDocLinkPKSK = FarmingEffectDocLinkPKSK;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new FarmingEffectLocationInTargetAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
|
||||
if(true == FarmingEffectDocLinkPKSK.isNullOrWhiteSpace())
|
||||
{
|
||||
err_msg = $"Not make FARMING_EFFECT_DOC_LINK_PKSK !!! - {toBasicString()}, {owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.FarmingEffectDocLinkPkSkNotSet, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as FarmingEffectLocationInTargetDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new FarmingEffectLocationInTargetDoc( LocationUniqueId
|
||||
, AnchorMetaGuid, UserGuid, UserNickname
|
||||
, FarmingEffectDocLinkPKSK );
|
||||
var origin_doc = getOriginDocBase<FarmingEffectLocationInTargetAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_farming_effect_location_in_target_attrib = try_pending_doc.getAttrib<FarmingEffectLocationInTargetAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_farming_effect_location_in_target_attrib, () => $"to_copy_doc_farming_effect_location_in_target_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
to_copy_doc_farming_effect_location_in_target_attrib.LocationUniqueId = LocationUniqueId;
|
||||
to_copy_doc_farming_effect_location_in_target_attrib.AnchorMetaGuid = AnchorMetaGuid;
|
||||
to_copy_doc_farming_effect_location_in_target_attrib.UserGuid = UserGuid;
|
||||
to_copy_doc_farming_effect_location_in_target_attrib.UserNickname = UserNickname;
|
||||
to_copy_doc_farming_effect_location_in_target_attrib.FarmingEffectDocLinkPKSK = FarmingEffectDocLinkPKSK;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Origin Attribute
|
||||
//=====================================================================================
|
||||
var other_farming_effect_location_in_target_attribute = otherEntityAttribute as FarmingEffectLocationInTargetAttribute;
|
||||
if (null == other_farming_effect_location_in_target_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast FarmingEffectLocationInTargetAttribute !!!, other_farming_effect_location_in_target_attribute is null - {owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
LocationUniqueId = other_farming_effect_location_in_target_attribute.LocationUniqueId;
|
||||
AnchorMetaGuid = other_farming_effect_location_in_target_attribute.AnchorMetaGuid;
|
||||
UserGuid = other_farming_effect_location_in_target_attribute.UserGuid;
|
||||
UserNickname = other_farming_effect_location_in_target_attribute.UserNickname;
|
||||
FarmingEffectDocLinkPKSK = other_farming_effect_location_in_target_attribute.FarmingEffectDocLinkPKSK;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_farming_effect_location_in_target_attribute.getTryPendingDocBase() as FarmingEffectLocationInTargetDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_farming_effect_location_in_target_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<FarmingEffectLocationInTargetAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<FarmingEffectLocationInTargetAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var farming_effect_location_target_attrib = origin_doc_base.getAttrib<FarmingEffectLocationInTargetAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(farming_effect_location_target_attrib, () => $"farming_effect_location_target_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
farming_effect_location_target_attrib.LocationUniqueId = LocationUniqueId;
|
||||
farming_effect_location_target_attrib.AnchorMetaGuid = AnchorMetaGuid;
|
||||
farming_effect_location_target_attrib.UserGuid = UserGuid;
|
||||
farming_effect_location_target_attrib.UserNickname = UserNickname;
|
||||
farming_effect_location_target_attrib.FarmingEffectDocLinkPKSK = FarmingEffectDocLinkPKSK;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
|
||||
var to_cast_string = typeof(FarmingEffectLocationInTargetDoc).Name;
|
||||
|
||||
var farming_location_in_target_doc = docBase as FarmingEffectLocationInTargetDoc;
|
||||
if (null == farming_location_in_target_doc)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, farming_location_in_target_doc is null :{to_cast_string} - {owner.toBasicString}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<FarmingEffectLocationInTargetAttribute>(farming_location_in_target_doc);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var farming_effect_location_in_target_attrib = farming_location_in_target_doc.getAttrib<FarmingEffectLocationInTargetAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(farming_effect_location_in_target_attrib, () => $"farming_effect_location_in_target_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
farming_effect_location_in_target_attrib.LocationUniqueId = farming_effect_location_in_target_attrib.LocationUniqueId;
|
||||
farming_effect_location_in_target_attrib.AnchorMetaGuid = farming_effect_location_in_target_attrib.AnchorMetaGuid;
|
||||
farming_effect_location_in_target_attrib.UserGuid = farming_effect_location_in_target_attrib.UserGuid;
|
||||
farming_effect_location_in_target_attrib.UserNickname = farming_effect_location_in_target_attrib.UserNickname;
|
||||
farming_effect_location_in_target_attrib.FarmingEffectDocLinkPKSK = farming_effect_location_in_target_attrib.FarmingEffectDocLinkPKSK;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class FarmingEffectLocationInTargetAttributeTransactor : EntityAttributeTransactorBase<FarmingEffectLocationInTargetAttribute>
|
||||
{
|
||||
public FarmingEffectLocationInTargetAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
247
ServerCommon/Entity/Attribute/FarmingEffectOwnerAttribute.cs
Normal file
247
ServerCommon/Entity/Attribute/FarmingEffectOwnerAttribute.cs
Normal file
@@ -0,0 +1,247 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
using ENTITY_UNIQUE_ID = System.String;
|
||||
using ANCHOR_META_GUID = System.String;
|
||||
using TARGET_UNIQUE_ID = System.String;
|
||||
using NPC_UNIQUE_ID = System.String;
|
||||
using FARMING_ENTITY_GUID = System.String;
|
||||
using LOCATION_UNIQUE_ID = System.String;
|
||||
using FARMING_EFFECT_DOC_LINK_PKSK = System.String;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class FarmingEffectOwnerAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
// 파밍을 하고 있는 OwnerEntityType.User or UgcNpc
|
||||
[JsonProperty]
|
||||
public OwnerEntityType OwnerEntityType { get; set; } = OwnerEntityType.None;
|
||||
// 파밍을 하고 있는 OwnerEntityType.User or UgcNpc GUID
|
||||
[JsonProperty]
|
||||
public OWNER_GUID OwnerGuid { get; set; } = string.Empty;
|
||||
|
||||
public FARMING_EFFECT_DOC_LINK_PKSK FarmingEffectDocLinkPKSK { get; set; } = string.Empty;
|
||||
|
||||
|
||||
|
||||
public FarmingEffectOwnerAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
OwnerEntityType = OwnerEntityType.None;
|
||||
OwnerGuid = string.Empty;
|
||||
FarmingEffectDocLinkPKSK = string.Empty;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var cloned = new FarmingEffectOwnerAttribute(owner);
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.OwnerEntityType = OwnerEntityType;
|
||||
cloned.OwnerGuid = OwnerGuid;
|
||||
cloned.FarmingEffectDocLinkPKSK = FarmingEffectDocLinkPKSK;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new FarmingEffectOwnerAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
|
||||
if (true == FarmingEffectDocLinkPKSK.isNullOrWhiteSpace())
|
||||
{
|
||||
err_msg = $"Not make FARMING_EFFECT_DOC_LINK_PKSK !!! - {toBasicString()}, {owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.FarmingEffectDocLinkPkSkNotSet, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as FarmingEffectOwnerDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new FarmingEffectOwnerDoc( OwnerEntityType, OwnerGuid
|
||||
, FarmingEffectDocLinkPKSK );
|
||||
|
||||
var origin_doc = getOriginDocBase<FarmingEffectOwnerAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_farming_effect_owner_attrib = try_pending_doc.getAttrib<FarmingEffectOwnerAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_farming_effect_owner_attrib, () => $"to_copy_doc_farming_effect_owner_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
to_copy_doc_farming_effect_owner_attrib.OwnerEntityType = OwnerEntityType;
|
||||
to_copy_doc_farming_effect_owner_attrib.OwnerGuid = OwnerGuid;
|
||||
to_copy_doc_farming_effect_owner_attrib.FarmingEffectDocLinkPKSK = FarmingEffectDocLinkPKSK;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Origin Attribute
|
||||
//=====================================================================================
|
||||
var other_farming_effect_owner_attribute = otherEntityAttribute as FarmingEffectOwnerAttribute;
|
||||
if (null == other_farming_effect_owner_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast FarmingEffectOwnerAttribute !!!, other_farming_effect_owner_attribute is null - {owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
OwnerEntityType = other_farming_effect_owner_attribute.OwnerEntityType;
|
||||
OwnerGuid = other_farming_effect_owner_attribute.OwnerGuid;
|
||||
FarmingEffectDocLinkPKSK = other_farming_effect_owner_attribute.FarmingEffectDocLinkPKSK;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_farming_effect_owner_attribute.getTryPendingDocBase() as FarmingEffectOwnerDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_farming_effect_owner_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<FarmingEffectOwnerAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<FarmingEffectOwnerAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var farming_effect_owner_attrib = origin_doc_base.getAttrib<FarmingEffectOwnerAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(farming_effect_owner_attrib, () => $"farming_effect_owner_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
farming_effect_owner_attrib.OwnerEntityType = OwnerEntityType;
|
||||
farming_effect_owner_attrib.OwnerGuid = OwnerGuid;
|
||||
farming_effect_owner_attrib.FarmingEffectDocLinkPKSK = FarmingEffectDocLinkPKSK;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
|
||||
var to_cast_string = typeof(FarmingEffectOwnerDoc).Name;
|
||||
|
||||
var farming_location_owner_doc = docBase as FarmingEffectOwnerDoc;
|
||||
if (null == farming_location_owner_doc)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, farming_location_owner_doc is null :{to_cast_string} - {owner.toBasicString}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<FarmingEffectOwnerAttribute>(farming_location_owner_doc);
|
||||
|
||||
var farming_effect_owner_attrib = farming_location_owner_doc.getAttrib<FarmingEffectOwnerAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(farming_effect_owner_attrib, () => $"farming_effect_owner_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
OwnerEntityType = farming_effect_owner_attrib.OwnerEntityType;
|
||||
OwnerGuid = farming_effect_owner_attrib.OwnerGuid;
|
||||
FarmingEffectDocLinkPKSK = farming_effect_owner_attrib.FarmingEffectDocLinkPKSK;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void makeFARMING_EFFECT_DOC_LINK_PKSK(LOCATION_UNIQUE_ID locationUniqueId, ANCHOR_META_GUID anchorMetaGuid)
|
||||
{
|
||||
FarmingEffectDocLinkPKSK = $"{locationUniqueId}#{anchorMetaGuid}";
|
||||
}
|
||||
}
|
||||
|
||||
public class FarmingEffectOwnerAttributeTransactor : EntityAttributeTransactorBase<FarmingEffectOwnerAttribute>
|
||||
{
|
||||
public FarmingEffectOwnerAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
255
ServerCommon/Entity/Attribute/FriendAttribute.cs
Normal file
255
ServerCommon/Entity/Attribute/FriendAttribute.cs
Normal file
@@ -0,0 +1,255 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Amazon.OpenSearchService.Model.Internal.MarshallTransformations;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerControlCenter;
|
||||
using ServerCore; using ServerBase;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
using Amazon.S3.Model;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
|
||||
public class FriendAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public USER_GUID UserGuid { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public USER_GUID FriendGuid { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public string Nickname { get; set; } = string.Empty;
|
||||
|
||||
public string FolderName { get; set; } = string.Empty;
|
||||
|
||||
public Int32 IsNew { get; set; } = 0;
|
||||
[JsonProperty]
|
||||
public DateTime CreateTime { get; set; } = DateTimeHelper.MinTime;
|
||||
|
||||
public Int16 IsChannel { get; set; } = 0; //1:채널서버, 0:인스턴스 서버
|
||||
|
||||
public Int32 Id { get; set; } = 0;
|
||||
|
||||
public Int32 ChannelNumber { get; set; } = 0;
|
||||
|
||||
public Int32 Language { get; set; } = 0;
|
||||
|
||||
|
||||
public FriendAttribute( EntityBase owner
|
||||
, string userGuid, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
UserGuid = userGuid;
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
UserGuid = string.Empty;
|
||||
FriendGuid = string.Empty;
|
||||
Nickname = string.Empty;
|
||||
FolderName = string.Empty;
|
||||
IsNew = 0;
|
||||
CreateTime = new();
|
||||
IsChannel = 0;
|
||||
Id = 0;
|
||||
ChannelNumber = 0;
|
||||
Language = 0;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var result = new Result();
|
||||
|
||||
var user_guid = UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as FriendDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new FriendDoc(user_guid, FriendGuid);
|
||||
|
||||
var origin_doc = getOriginDocBase<FriendAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_friend_attrib = try_pending_doc.getAttrib<FriendAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_friend_attrib, () => $"to_copy_friend_attrib is null !!!");
|
||||
|
||||
to_copy_friend_attrib.FriendGuid = FriendGuid;
|
||||
to_copy_friend_attrib.FolderName = FolderName;
|
||||
to_copy_friend_attrib.IsNew = IsNew;
|
||||
to_copy_friend_attrib.CreateTime = CreateTime;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var entity_of_owner_entity_type = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(entity_of_owner_entity_type, () => $"entity_of_owner_entity_type is null !!!");
|
||||
|
||||
var cloned = new FriendAttribute(owner, UserGuid, entity_of_owner_entity_type);
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.FriendGuid = FriendGuid;
|
||||
cloned.Nickname = Nickname;
|
||||
cloned.FolderName = FolderName;
|
||||
cloned.IsNew = IsNew;
|
||||
cloned.CreateTime = CreateTime;
|
||||
cloned.IsChannel = IsChannel;
|
||||
cloned.Id = Id;
|
||||
cloned.ChannelNumber = ChannelNumber;
|
||||
cloned.Language = Language;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
|
||||
var other_attribute = otherEntityAttribute as FriendAttribute;
|
||||
if (null == other_attribute)
|
||||
{
|
||||
var err_msg = $"Failed to cast FriendFolderAttribute !!!, other_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
UserGuid = other_attribute.UserGuid;
|
||||
FriendGuid = other_attribute.FriendGuid;
|
||||
FolderName = other_attribute.FolderName;
|
||||
Nickname = other_attribute.Nickname;
|
||||
IsNew = other_attribute.IsNew;
|
||||
CreateTime = other_attribute.CreateTime;
|
||||
IsChannel = other_attribute.IsChannel;
|
||||
Id = other_attribute.Id;
|
||||
ChannelNumber = other_attribute.ChannelNumber;
|
||||
Language = other_attribute.Language;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_attribute.getTryPendingDocBase() as FriendDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<FriendAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<FriendAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var friend_attrib = origin_doc_base.getAttrib<FriendAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(friend_attrib, () => $"friend_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var friend_doc_base = docBase as FriendDoc;
|
||||
if (null == friend_doc_base)
|
||||
{
|
||||
var to_cast_string = typeof(FriendDoc).Name;
|
||||
var err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, friend_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<FriendAttribute>(friend_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = friend_doc_base.getAttrib<FriendAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_attrib, () => $"doc_attrib is null !!!");
|
||||
|
||||
FriendGuid = doc_attrib.FriendGuid;
|
||||
FolderName = doc_attrib.FolderName;
|
||||
IsNew = doc_attrib.IsNew;
|
||||
CreateTime = doc_attrib.CreateTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new FriendsAttributeTransactor(getOwner());
|
||||
}
|
||||
}
|
||||
|
||||
public class FriendsAttributeTransactor : EntityAttributeTransactorBase<FriendAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public FriendsAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase entityAttributeBase)
|
||||
{
|
||||
//아직 미사용
|
||||
Log.getLogger().info("copyEntityDbTransactBaseFromEntityAttribute call");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
277
ServerCommon/Entity/Attribute/FriendFolderAttribute.cs
Normal file
277
ServerCommon/Entity/Attribute/FriendFolderAttribute.cs
Normal file
@@ -0,0 +1,277 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Amazon.Auth.AccessControlPolicy;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
using Amazon.S3.Model;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class FriendFolderAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public Int16 m_folder_order_type { get; set; } = 0;
|
||||
[JsonProperty]
|
||||
public ConcurrentDictionary<string, FriendFolder> m_folders { get; set; } = new();
|
||||
|
||||
public FriendFolderAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
m_folder_order_type = 0;
|
||||
m_folders.Clear();
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public void fillNewData()
|
||||
{
|
||||
FriendFolder folder = new();
|
||||
folder.FolderName = Constant.FRIEND_FOLDER_DEFUALT_NAME;
|
||||
folder.IsHold = 0;
|
||||
folder.HoldTime = DateTimeHelper.Current;
|
||||
folder.CreateTime = DateTimeHelper.Current;
|
||||
|
||||
m_folders.TryAdd(folder.FolderName, folder);
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var result = new Result();
|
||||
|
||||
var user_attribute = owner.getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!!");
|
||||
|
||||
USER_GUID user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as FriendFolderDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new FriendFolderDoc(user_guid);
|
||||
|
||||
var origin_doc = getOriginDocBase<FriendFolderAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_friend_folder_attrib = try_pending_doc.getAttrib<FriendFolderAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_friend_folder_attrib, () => $"to_copy_friend_folder_attrib is null !!!");
|
||||
|
||||
to_copy_friend_folder_attrib.FolderOrderType = m_folder_order_type;
|
||||
to_copy_friend_folder_attrib.Folders.Clear();
|
||||
foreach (var folder in m_folders.Values)
|
||||
{
|
||||
FriendFolder copy_folder = new();
|
||||
copy_folder.FolderName = folder.FolderName;
|
||||
copy_folder.IsHold = folder.IsHold;
|
||||
copy_folder.HoldTime = folder.HoldTime;
|
||||
copy_folder.CreateTime = folder.CreateTime;
|
||||
to_copy_friend_folder_attrib.Folders.TryAdd(copy_folder.FolderName, copy_folder);
|
||||
}
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
|
||||
var cloned = new FriendFolderAttribute(getOwner());
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.m_folder_order_type = m_folder_order_type;
|
||||
cloned.m_folders = new();
|
||||
foreach (var folder in m_folders)
|
||||
{
|
||||
FriendFolder new_folder = new();
|
||||
new_folder.FolderName = new (folder.Value.FolderName);
|
||||
new_folder.IsHold = folder.Value.IsHold;
|
||||
new_folder.HoldTime = folder.Value.HoldTime;
|
||||
new_folder.CreateTime = folder.Value.CreateTime;
|
||||
cloned.m_folders.TryAdd(folder.Key, new_folder);
|
||||
}
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new FriendFolderAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
var to_cast_string = typeof(FriendFolderDoc).Name;
|
||||
|
||||
var friend_folder_doc = docBase as FriendFolderDoc;
|
||||
if (null == friend_folder_doc)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, item_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<FriendFolderAttribute>(friend_folder_doc);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var friend_folder_attrib = friend_folder_doc.getAttrib<FriendFolderAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(friend_folder_attrib, () => $"friend_folder_attrib is null !!!");
|
||||
|
||||
m_folder_order_type = friend_folder_attrib.FolderOrderType;
|
||||
|
||||
m_folders = new();
|
||||
foreach (var folder in friend_folder_attrib.Folders.Values)
|
||||
{
|
||||
var clone_folder = new FriendFolder();
|
||||
clone_folder.FolderName = folder.FolderName;
|
||||
clone_folder.IsHold = folder.IsHold;
|
||||
clone_folder.HoldTime = folder.HoldTime;
|
||||
clone_folder.CreateTime = folder.CreateTime;
|
||||
|
||||
m_folders.TryAdd(folder.FolderName, clone_folder);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var other_attribute = otherEntityAttribute as FriendFolderAttribute;
|
||||
if (null == other_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast FriendFolderAttribute !!!, other_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
m_folder_order_type = other_attribute.m_folder_order_type;
|
||||
foreach (var folder in other_attribute.m_folders.Values)
|
||||
{
|
||||
var clone_folder = new FriendFolder();
|
||||
clone_folder.FolderName = folder.FolderName;
|
||||
clone_folder.IsHold = folder.IsHold;
|
||||
clone_folder.HoldTime = folder.HoldTime;
|
||||
clone_folder.CreateTime = folder.CreateTime;
|
||||
m_folders.TryAdd(folder.FolderName, clone_folder);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_attribute.getTryPendingDocBase() as FriendFolderDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<FriendFolderAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<FriendFolderAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var friend_folder_attrib = origin_doc_base.getAttrib<FriendFolderAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(friend_folder_attrib, () => $"friend_folder_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
friend_folder_attrib.FolderOrderType = m_folder_order_type;
|
||||
foreach (var folder in m_folders.Values)
|
||||
{
|
||||
var clone_folder = new FriendFolder();
|
||||
|
||||
clone_folder.FolderName = folder.FolderName;
|
||||
clone_folder.IsHold = folder.IsHold;
|
||||
clone_folder.HoldTime = folder.HoldTime;
|
||||
clone_folder.CreateTime = folder.CreateTime;
|
||||
|
||||
friend_folder_attrib.Folders.TryAdd(folder.FolderName, clone_folder);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class FriendFolderAttributeTransactor : EntityAttributeTransactorBase<FriendFolderAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public FriendFolderAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
241
ServerCommon/Entity/Attribute/GameOptionAttribute.cs
Normal file
241
ServerCommon/Entity/Attribute/GameOptionAttribute.cs
Normal file
@@ -0,0 +1,241 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Security.Cryptography.Xml;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
using Amazon.S3.Model;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class GameOptionAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public string options { get; set; } = string.Empty;
|
||||
|
||||
public GameOptionAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
options = string.Empty;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "UserBase is null !!!");
|
||||
|
||||
var cloned = new GameOptionAttribute(owner);
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
var owner = getOwner() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "UserBase is null !!!");
|
||||
|
||||
return new GameOptionAttributeTransactor(owner);
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "UserBase is null !!!");
|
||||
|
||||
var acoount_attribute = owner.getEntityAttribute<AccountAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(acoount_attribute, () => $"account attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
USER_GUID user_guid = acoount_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as GameOptionDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new GameOptionDoc(user_guid);
|
||||
|
||||
var origin_doc = getOriginDocBase<GameOptionAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<GameOptionAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"game option attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
to_copy_doc_attrib.options = options;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(GameOptionDoc).Name;
|
||||
|
||||
var game_option_doc_base = docBase as GameOptionDoc;
|
||||
if (null == game_option_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, game_option_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<GameOptionAttribute>(game_option_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = game_option_doc_base.getAttrib<GameOptionAttrib>();
|
||||
if (doc_attrib == null)
|
||||
{
|
||||
err_msg = $"Failed to get game option attrib : {nameof(GameOptionAttrib)}";
|
||||
result.setFail(ServerErrorCode.EntityAttributeIsNull, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
options = doc_attrib.options;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var game_option_attribute = otherEntityAttribute as GameOptionAttribute;
|
||||
if (null == game_option_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast GameOptionAttribute !!!, game_option_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
options = game_option_attribute.options;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = game_option_attribute.getTryPendingDocBase() as GameOptionDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
game_option_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<GameOptionAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<GameOptionAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var game_option_attrib = origin_doc_base.getAttrib<GameOptionAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(game_option_attrib, () => $"game_option_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
game_option_attrib.options = options;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class GameOptionAttributeTransactor : EntityAttributeTransactorBase<GameOptionAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public GameOptionAttributeTransactor(UserBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(GameOptionAttribute).Name;
|
||||
|
||||
var copy_from_game_option_attribute = entityAttributeBase as GameOptionAttribute;
|
||||
if (null == copy_from_game_option_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_game_option_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_game_option_attribute = getClonedEntityAttribute() as GameOptionAttribute;
|
||||
if (null == copy_to_game_option_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_game_option_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_game_option_attribute.options = copy_from_game_option_attribute.options;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
486
ServerCommon/Entity/Attribute/ItemAttributeBase.cs
Normal file
486
ServerCommon/Entity/Attribute/ItemAttributeBase.cs
Normal file
@@ -0,0 +1,486 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
using ServerControlCenter;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public abstract class ItemAttributeBase : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute, IWithCommonResultFiller
|
||||
{
|
||||
[JsonProperty]
|
||||
public ITEM_GUID ItemGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public META_ID ItemMetaId { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public UInt16 ItemStackCount
|
||||
{
|
||||
get { return m_item_stack_count; }
|
||||
set
|
||||
{
|
||||
var recorder = getEntityRecorder();
|
||||
if (null != recorder)
|
||||
{
|
||||
recorder.applyDeltaCounter(EntityDeltaType.ItemStackCount, value - m_item_stack_count, value);
|
||||
}
|
||||
m_item_stack_count = value;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
private UInt16 m_item_stack_count = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public UInt16 Level
|
||||
{
|
||||
get { return m_level; }
|
||||
set
|
||||
{
|
||||
var recorder = getEntityRecorder();
|
||||
if (null != recorder)
|
||||
{
|
||||
recorder.applyDeltaCounter(EntityDeltaType.ItemLevel, value - m_level, value);
|
||||
}
|
||||
m_level = value;
|
||||
}
|
||||
}
|
||||
private UInt16 m_level = 0;
|
||||
|
||||
public List<UInt16> Attributes { get; set; } = new();
|
||||
|
||||
// EquipedIvenType.None 일경우 EquipedPos = 0 이다 !!! - kangms
|
||||
[JsonProperty]
|
||||
public InvenEquipType EquipedIvenType { get; set; } = InvenEquipType.None;
|
||||
|
||||
[JsonProperty]
|
||||
public UInt16 EquipedPos { get; set; } = 0;
|
||||
|
||||
|
||||
//=========================================================================================
|
||||
// 기본 생성자
|
||||
//=========================================================================================
|
||||
public ItemAttributeBase(EntityBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType, true)
|
||||
{
|
||||
}
|
||||
|
||||
public override void newEntityAttribute()
|
||||
{
|
||||
ItemGuid = System.Guid.NewGuid().ToString("N");
|
||||
base.newEntityAttribute();
|
||||
}
|
||||
|
||||
public void newEntityAttributeWithItemGuid(string itemGuid)
|
||||
{
|
||||
ItemGuid = itemGuid;
|
||||
base.newEntityAttribute();
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
ItemGuid = string.Empty;
|
||||
ItemMetaId = 0;
|
||||
ItemStackCount = 0;
|
||||
Level = 0;
|
||||
Attributes.Clear();
|
||||
EquipedIvenType = InvenEquipType.None;
|
||||
EquipedPos = 0;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var root_parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(root_parent, () => $"root_parent is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var result = new Result();
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => Try Pending Item Doc (New Doc)
|
||||
// Origin Doc Timestamps => Try Pending Item Doc (New Doc)
|
||||
//=====================================================================================
|
||||
|
||||
var try_pending_item_doc = getTryPendingDocBase() as ItemDoc;
|
||||
if(null == try_pending_item_doc)
|
||||
{
|
||||
var to_copy_doc = onCreateDocBase() as ItemDoc;
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc, () => $"to_copy_doc is null !!! - {owner.toBasicString()}, {root_parent.toBasicString()}");
|
||||
|
||||
var origin_doc = getOriginDocBase<ItemAttributeBase>();
|
||||
if(null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_item_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_item_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_item_attrib = try_pending_item_doc.getAttrib<ItemAttrib>();
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(to_copy_doc_item_attrib, () => $"to_copy_doc_item_attrib is null !!! - {owner.toBasicString()}, {root_parent.toBasicString()}");
|
||||
|
||||
to_copy_doc_item_attrib.ItemGuid = ItemGuid;
|
||||
to_copy_doc_item_attrib.ItemMetaId = ItemMetaId;
|
||||
to_copy_doc_item_attrib.ItemStackCount = ItemStackCount;
|
||||
to_copy_doc_item_attrib.Level = Level;
|
||||
to_copy_doc_item_attrib.Attributes = Attributes.Select(x => x).ToList();
|
||||
to_copy_doc_item_attrib.EquipedIvenType = EquipedIvenType;
|
||||
to_copy_doc_item_attrib.EquipedPos = EquipedPos;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_item_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_item_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public async Task<(Result, ItemDoc?)> changeOwnerAndCreateItemDoc(OwnerEntityType toSetOwnerEntityType, OWNER_GUID toSetOwerGuid)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var root_parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(root_parent, () => $"root_parent is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var result = new Result();
|
||||
|
||||
var item_doc = new ItemDoc(toSetOwnerEntityType, toSetOwerGuid, ItemGuid);
|
||||
|
||||
result = await ServerBase.DataCopyHelper.copyDocFromEntityAttributes(item_doc, new List<EntityAttributeBase>() { this });
|
||||
if (result.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to copyDocFromEntityAttributes() !!!, to:{item_doc.getTypeName()}, from:{this.getTypeName()} - {owner.toBasicString()}, {root_parent.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.EntityAttributeCopyToDynamoDbDocFailed, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, item_doc);
|
||||
}
|
||||
|
||||
public void onFillCommonResult(EntityCommonResult commonResult, EntityAttributeBase origin, QueryBatchBase? queryBatch = null)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var before = origin as ItemAttributeBase;
|
||||
NullReferenceCheckHelper.throwIfNull(before, () => $"before is null !!! - {owner.toBasicString()}");
|
||||
var after = this as ItemAttributeBase;
|
||||
NullReferenceCheckHelper.throwIfNull(after, () => $"after is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var recorder = after.getEntityRecorder();
|
||||
NullReferenceCheckHelper.throwIfNull(recorder, () => $"recorder is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var item_result = commonResult.Item;
|
||||
NullReferenceCheckHelper.throwIfNull(item_result, () => $"item_result is null !!! - {owner.toBasicString()}");
|
||||
var exp_result = commonResult.Exp;
|
||||
NullReferenceCheckHelper.throwIfNull(exp_result, () => $"exp_result is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var item_guid = after.ItemGuid;
|
||||
var item_meta_id = after.ItemMetaId;
|
||||
|
||||
//=====================================================================================
|
||||
// 아이템 개수가 남아있는 경우에만 UpdatedItems 목록에 추가 - 클라이언트 요청 반영 - kangms
|
||||
//=====================================================================================
|
||||
if (after.ItemStackCount > 0)
|
||||
{
|
||||
item_result.UpdatedItems.TryAdd(item_guid, after.toItemData4Client());
|
||||
}
|
||||
|
||||
var target_types = EnumHelper.getValuesBeginEndBetweenWord<EntityDeltaType>("Item_");
|
||||
foreach (var type in target_types)
|
||||
{
|
||||
var found_delta_counter = recorder.findDeltaCounter(type);
|
||||
if (null != found_delta_counter)
|
||||
{
|
||||
(var item_log_result, var item_log_info) = after.toItemLogInfo();
|
||||
if (item_log_result.isFail())
|
||||
{
|
||||
var err_msg = $"Failed to toItemLogInfo() !!! : {item_log_result.toBasicString()} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
continue;
|
||||
}
|
||||
NullReferenceCheckHelper.throwIfNull(item_log_info, () => $"item_log_info is null !!! - {owner.toBasicString()}");
|
||||
|
||||
//=====================================================================================
|
||||
// 아이템 갯수 변화량
|
||||
//=====================================================================================
|
||||
if (EntityDeltaType.ItemStackCount == type)
|
||||
{
|
||||
var delta_count = (Int32)found_delta_counter.getDeltaCount();
|
||||
|
||||
item_result.DeltaPerItems.TryAdd(item_guid, delta_count);
|
||||
if (false == item_result.DeltaPerMeta.TryGetValue(item_meta_id, out var found_item_delta))
|
||||
{
|
||||
found_item_delta = new ItemDeltaAmount();
|
||||
found_item_delta.DeltaType = (delta_count >= 0 ? AmountDeltaType.Acquire : AmountDeltaType.Consume);
|
||||
found_item_delta.Delta = new ItemAmount();
|
||||
found_item_delta.Delta.MetaId = item_meta_id;
|
||||
|
||||
item_result.DeltaPerMeta.Add(item_meta_id, found_item_delta);
|
||||
}
|
||||
else
|
||||
{
|
||||
found_item_delta.DeltaType = AmountDeltaType.Merge;
|
||||
}
|
||||
found_item_delta.Delta.Amount += delta_count;
|
||||
|
||||
appendOrWriteBusinessLog4ItemStackCount(item_log_info, delta_count, after.ItemStackCount, queryBatch);
|
||||
}
|
||||
//=====================================================================================
|
||||
// 아이템 레벨 변화량
|
||||
//=====================================================================================
|
||||
else if (EntityDeltaType.ItemLevel == type)
|
||||
{
|
||||
var delta_level = (Int32)found_delta_counter.getDeltaCount();
|
||||
|
||||
var level_exp_type = (Int32)LevelExpType.Item;
|
||||
if (false == exp_result.LevelExps.TryGetValue(level_exp_type, out var found_level_by_meta_id))
|
||||
{
|
||||
found_level_by_meta_id = new LevelExpById();
|
||||
exp_result.LevelExps.Add(level_exp_type, found_level_by_meta_id);
|
||||
}
|
||||
if (false == found_level_by_meta_id.LevelExpsByGuid.TryGetValue(item_guid, out var found_level))
|
||||
{
|
||||
found_level = new LevelExp();
|
||||
found_level_by_meta_id.LevelExpsByGuid.Add(item_guid, found_level);
|
||||
}
|
||||
found_level.Level = after.Level;
|
||||
if (false == exp_result.LevelExpDeltas.TryGetValue(level_exp_type, out var found_exp_delta_amount_by_meta_id))
|
||||
{
|
||||
found_exp_delta_amount_by_meta_id = new LevelExpDeltaAmountById();
|
||||
exp_result.LevelExpDeltas.Add(level_exp_type, found_exp_delta_amount_by_meta_id);
|
||||
}
|
||||
if (false == found_exp_delta_amount_by_meta_id.DeltasByGuid.TryGetValue(item_guid, out var found_exp_delta_amount))
|
||||
{
|
||||
found_exp_delta_amount = new LevelExpDeltaAmount();
|
||||
found_exp_delta_amount_by_meta_id.DeltasByGuid.Add(item_guid, found_exp_delta_amount);
|
||||
}
|
||||
found_exp_delta_amount.ExpDeltaType = AmountDeltaType.Merge;
|
||||
found_exp_delta_amount.LevelAmount = delta_level;
|
||||
|
||||
appendOrWriteBusinessLog4ItemLevel(item_log_info, delta_level, after.Level, queryBatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void appendOrWriteBusinessLog4ItemStackCount( ItemLogInfo itemLogInfo
|
||||
, int deltaCount, int updatedCount
|
||||
, QueryBatchBase? queryBatch = null )
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var delta_type = CountDeltaType.None;
|
||||
if (deltaCount > 0)
|
||||
{
|
||||
delta_type = CountDeltaType.Acquire;
|
||||
}
|
||||
else if (deltaCount < 0)
|
||||
{
|
||||
delta_type = CountDeltaType.Consume;
|
||||
}
|
||||
|
||||
itemLogInfo.CountDeltaType = delta_type;
|
||||
itemLogInfo.DeltaCount = deltaCount;
|
||||
itemLogInfo.StackCount = updatedCount;
|
||||
|
||||
var item_delta_log = new ItemBusinessLog(itemLogInfo);
|
||||
if (null != queryBatch)
|
||||
{
|
||||
queryBatch.appendBusinessLog(item_delta_log);
|
||||
}
|
||||
else
|
||||
{
|
||||
var log_actor = owner as IWithLogActor;
|
||||
NullReferenceCheckHelper.throwIfNull(log_actor, () => $"log_actor is null !!! - {owner.toBasicString()}");
|
||||
|
||||
BusinessLogger.collectLog(log_actor, item_delta_log);
|
||||
}
|
||||
}
|
||||
|
||||
private void appendOrWriteBusinessLog4ItemLevel( ItemLogInfo itemLogInfo, int deltaLevel, int updatedLevel
|
||||
, QueryBatchBase? queryBatch = null )
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var delta_type = CountDeltaType.None;
|
||||
if (deltaLevel > 0)
|
||||
{
|
||||
delta_type = CountDeltaType.Acquire;
|
||||
}
|
||||
else if (deltaLevel < 0)
|
||||
{
|
||||
delta_type = CountDeltaType.Consume;
|
||||
}
|
||||
|
||||
itemLogInfo.CountDeltaType = delta_type;
|
||||
itemLogInfo.DeltaLevel = deltaLevel;
|
||||
itemLogInfo.Level = updatedLevel;
|
||||
|
||||
var item_delta_log = new ItemBusinessLog(itemLogInfo);
|
||||
if (null != queryBatch)
|
||||
{
|
||||
queryBatch.appendBusinessLog(item_delta_log);
|
||||
}
|
||||
else
|
||||
{
|
||||
var log_actor = owner as IWithLogActor;
|
||||
NullReferenceCheckHelper.throwIfNull(log_actor, () => $"log_actor is null !!! - {owner.toBasicString()}");
|
||||
|
||||
BusinessLogger.collectLog(log_actor, item_delta_log);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var root_parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(root_parent, () => $"root_parent is null !!! - {owner.toBasicString()}");
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(otherEntityAttribute, () => $"otherEntityAttribute is null !!! - {root_parent.toBasicString()}");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var other_item_attribute = otherEntityAttribute as ItemAttributeBase;
|
||||
if (null == other_item_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast ItemAttributeBase !!!, other_item_attribute is null - {owner.toBasicString()}, {root_parent.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ItemGuid = other_item_attribute.ItemGuid;
|
||||
ItemMetaId = other_item_attribute.ItemMetaId;
|
||||
ItemStackCount = other_item_attribute.ItemStackCount;
|
||||
Level = other_item_attribute.Level;
|
||||
Attributes = other_item_attribute.Attributes.Select(x => x).ToList();
|
||||
EquipedIvenType = other_item_attribute.EquipedIvenType;
|
||||
EquipedPos = other_item_attribute.EquipedPos;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Item Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
|
||||
var try_pending_item_doc = other_item_attribute.getTryPendingDocBase() as ItemDoc;
|
||||
if(null != try_pending_item_doc)
|
||||
{
|
||||
other_item_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<ItemAttributeBase>(try_pending_item_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<ItemAttributeBase>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var item_attrib = origin_doc_base.getAttrib<ItemAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(item_attrib, () => $"item_attrib is null !!! - {owner.toBasicString()}, {root_parent.toBasicString()}");
|
||||
|
||||
item_attrib.ItemGuid = ItemGuid;
|
||||
item_attrib.ItemMetaId = ItemMetaId;
|
||||
item_attrib.ItemStackCount = ItemStackCount;
|
||||
item_attrib.Level = Level;
|
||||
item_attrib.Attributes = Attributes.Select(x => x).ToList(); ;
|
||||
item_attrib.EquipedIvenType = EquipedIvenType;
|
||||
item_attrib.EquipedPos = EquipedPos;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public virtual bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var owner = getOwner();
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var root_parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(root_parent, () => $"root_parent is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(ItemDoc).Name;
|
||||
|
||||
var item_doc = docBase as ItemDoc;
|
||||
if (null == item_doc)
|
||||
{
|
||||
err_msg = $"item_doc is null !!!, in copyEntityAttributeFromDoc() : docName:{to_cast_string} - {owner.toBasicString()}, {root_parent.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<ItemAttributeBase>(item_doc);
|
||||
|
||||
//=====================================================================================
|
||||
// Origin Doc => Attribute
|
||||
//=====================================================================================
|
||||
var item_attrib = item_doc.getAttrib<ItemAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(item_attrib, () => $"item_attrib is null !!! - {owner.toBasicString()}, {root_parent.toBasicString()}");
|
||||
|
||||
ItemGuid = item_attrib.ItemGuid;
|
||||
ItemMetaId = item_attrib.ItemMetaId;
|
||||
ItemStackCount = item_attrib.ItemStackCount;
|
||||
Level = item_attrib.Level;
|
||||
Attributes = item_attrib.Attributes.Select(x => x).ToList();
|
||||
EquipedIvenType = item_attrib.EquipedIvenType;
|
||||
EquipedPos = item_attrib.EquipedPos;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class ItemAttributeBaseTransactor<TItemAttributeBase> : EntityAttributeTransactorBase<TItemAttributeBase>
|
||||
where TItemAttributeBase : ItemAttributeBase
|
||||
{
|
||||
public ItemAttributeBaseTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using META_ID = System.UInt32;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class ItemFirstPurchaseHistoryAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public META_ID ItemMetaId { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public DateTime FirstPurchaseTime { get; set; } = new();
|
||||
|
||||
public ItemFirstPurchaseHistoryAttribute(EntityBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new ItemFirstPurchaseHistoryAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
ItemMetaId = 0;
|
||||
FirstPurchaseTime = new();
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner_entity_type = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(owner_entity_type, () => $"Owner Entity Type is null !!! ");
|
||||
|
||||
var cloned = new ItemFirstPurchaseHistoryAttribute(getOwner(), owner_entity_type);
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.ItemMetaId = ItemMetaId;
|
||||
cloned.FirstPurchaseTime = FirstPurchaseTime;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var user_attribute = owner.getRootParent().getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as ItemFirstPurchaseHistoryDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new ItemFirstPurchaseHistoryDoc(user_guid, ItemMetaId);
|
||||
|
||||
var origin_doc = getOriginDocBase<ItemFirstPurchaseHistoryAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<ItemFirstPurchaseHistoryAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
to_copy_doc_attrib.ItemMetaId = ItemMetaId;
|
||||
to_copy_doc_attrib.FirstPurchaseTime = FirstPurchaseTime;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_docs) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_docs);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(ItemFirstPurchaseHistoryDoc).Name;
|
||||
|
||||
var item_first_purchase_history_doc_base = docBase as ItemFirstPurchaseHistoryDoc;
|
||||
if (null == item_first_purchase_history_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, item_first_purchase_history_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<ItemFirstPurchaseHistoryAttribute>(item_first_purchase_history_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = item_first_purchase_history_doc_base.getAttrib<ItemFirstPurchaseHistoryAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_attrib, () => $"doc_attrib is null !!! - {getOwner().toBasicString()}");
|
||||
|
||||
ItemMetaId = doc_attrib.ItemMetaId;
|
||||
FirstPurchaseTime = doc_attrib.FirstPurchaseTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var item_first_purchase_histroy_attribute = otherEntityAttribute as ItemFirstPurchaseHistoryAttribute;
|
||||
if (null == item_first_purchase_histroy_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast ItemFirstPurchaseHistoryAttribute !!!, item_first_purchase_histroy_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ItemMetaId = item_first_purchase_histroy_attribute.ItemMetaId;
|
||||
FirstPurchaseTime = item_first_purchase_histroy_attribute.FirstPurchaseTime;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = item_first_purchase_histroy_attribute.getTryPendingDocBase() as ItemFirstPurchaseHistoryDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
item_first_purchase_histroy_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<ItemFirstPurchaseHistoryAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<ItemFirstPurchaseHistoryAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var item_first_purchase_history_attrib = origin_doc_base.getAttrib<ItemFirstPurchaseHistoryAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(item_first_purchase_history_attrib, () => $"item_first_purchase_history_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
item_first_purchase_history_attrib.ItemMetaId = ItemMetaId;
|
||||
item_first_purchase_history_attrib.FirstPurchaseTime = FirstPurchaseTime;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class ItemFirstPurchaseHistoryAttributeTransactor : EntityAttributeTransactorBase<ItemFirstPurchaseHistoryAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public ItemFirstPurchaseHistoryAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(ItemFirstPurchaseHistoryAttribute).Name;
|
||||
|
||||
var copy_from_item_first_purchase_history_attribute = entityAttributeBase as ItemFirstPurchaseHistoryAttribute;
|
||||
if (null == copy_from_item_first_purchase_history_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_from_item_first_purchase_history_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_item_first_purchase_history_attribute = getClonedEntityAttribute() as ItemFirstPurchaseHistoryAttribute;
|
||||
if (null == copy_to_item_first_purchase_history_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_to_item_first_purchase_history_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_item_first_purchase_history_attribute.ItemMetaId = copy_from_item_first_purchase_history_attribute.ItemMetaId;
|
||||
copy_to_item_first_purchase_history_attribute.FirstPurchaseTime = copy_from_item_first_purchase_history_attribute.FirstPurchaseTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
262
ServerCommon/Entity/Attribute/LandAttribute.cs
Normal file
262
ServerCommon/Entity/Attribute/LandAttribute.cs
Normal file
@@ -0,0 +1,262 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using META_ID = System.UInt32;
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class LandAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public string OwnerUserGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public META_ID LandMetaId { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public string LandName { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
public bool IsLoadFromDb = false;
|
||||
|
||||
public LandAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new LandAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
LandMetaId = 0;
|
||||
LandName = string.Empty;
|
||||
Description = string.Empty;
|
||||
OwnerUserGuid = string.Empty;
|
||||
IsLoadFromDb = false;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new LandAttribute(getOwner());
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.LandMetaId = LandMetaId;
|
||||
cloned.LandName = LandName;
|
||||
cloned.Description = Description;
|
||||
cloned.OwnerUserGuid = OwnerUserGuid;
|
||||
cloned.IsLoadFromDb = IsLoadFromDb;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as LandDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new LandDoc(LandMetaId);
|
||||
|
||||
var origin_doc = getOriginDocBase<LandAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<LandAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
to_copy_doc_attrib.LandMetaId = LandMetaId;
|
||||
to_copy_doc_attrib.LandName = LandName;
|
||||
to_copy_doc_attrib.Description = Description;
|
||||
to_copy_doc_attrib.OwnerUserGuid = OwnerUserGuid;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(LandDoc).Name;
|
||||
|
||||
var land_doc_base = docBase as LandDoc;
|
||||
if (null == land_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, land_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<LandAttribute>(land_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = land_doc_base.getAttrib<LandAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_attrib, () => "doc_attrib is null !!!");
|
||||
|
||||
LandMetaId = doc_attrib.LandMetaId;
|
||||
LandName = doc_attrib.LandName;
|
||||
Description = doc_attrib.Description;
|
||||
OwnerUserGuid = doc_attrib.OwnerUserGuid;
|
||||
IsLoadFromDb = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var land_attribute = otherEntityAttribute as LandAttribute;
|
||||
if (null == land_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast LandAttribute !!!, land_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
LandMetaId = land_attribute.LandMetaId;
|
||||
LandName = land_attribute.LandName;
|
||||
Description = land_attribute.Description;
|
||||
OwnerUserGuid = land_attribute.OwnerUserGuid;
|
||||
IsLoadFromDb = land_attribute.IsLoadFromDb;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = land_attribute.getTryPendingDocBase() as LandDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
land_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<LandAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<LandAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var land_attrib = origin_doc_base.getAttrib<LandAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(land_attrib, () => $"land_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
land_attrib.LandMetaId = LandMetaId;
|
||||
land_attrib.LandName = LandName;
|
||||
land_attrib.Description = Description;
|
||||
land_attrib.OwnerUserGuid = OwnerUserGuid;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class LandAttributeTransactor : EntityAttributeTransactorBase<LandAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public LandAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(LandAttribute).Name;
|
||||
|
||||
var copy_from_land_attribute = entityAttributeBase as LandAttribute;
|
||||
if (null == copy_from_land_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_from_land_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_land_attribute = getClonedEntityAttribute() as LandAttribute;
|
||||
if (null == copy_to_land_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_to_land_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_land_attribute.LandMetaId = copy_from_land_attribute.LandMetaId;
|
||||
copy_to_land_attribute.LandName = copy_from_land_attribute.LandName;
|
||||
copy_to_land_attribute.Description = copy_from_land_attribute.Description;
|
||||
copy_to_land_attribute.OwnerUserGuid = copy_from_land_attribute.OwnerUserGuid;
|
||||
copy_to_land_attribute.IsLoadFromDb = copy_from_land_attribute.IsLoadFromDb;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
260
ServerCommon/Entity/Attribute/LandAuctionActivityAttribute.cs
Normal file
260
ServerCommon/Entity/Attribute/LandAuctionActivityAttribute.cs
Normal file
@@ -0,0 +1,260 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerCommon.Cache;
|
||||
|
||||
|
||||
using META_ID = System.UInt32;
|
||||
using LAND_AUCTION_NUBER = System.Int32;
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
//=============================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================================
|
||||
|
||||
public class LandAuctionActivityAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public META_ID LandMetaId { get; set; } = 0; // 경매 대상 LandData Meta Id
|
||||
|
||||
[JsonProperty]
|
||||
public LAND_AUCTION_NUBER AuctionNumber { get; set; } = 0; // 경매 번호
|
||||
|
||||
|
||||
public LandAuctionActivityAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public void resetActivity(META_ID landMetaId)
|
||||
{
|
||||
LandMetaId = landMetaId;
|
||||
AuctionNumber = 0;
|
||||
}
|
||||
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new LandAuctionActivityAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
LandMetaId = 0;
|
||||
AuctionNumber = 0;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new LandAuctionActivityAttribute(getOwner());
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.LandMetaId = LandMetaId;
|
||||
cloned.AuctionNumber = AuctionNumber;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as LandAuctionActivityDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new LandAuctionActivityDoc(LandMetaId);
|
||||
|
||||
var origin_doc = getOriginDocBase<LandAuctionActivityAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var land_auction_activity_attrib = try_pending_doc.getAttrib<LandAuctionActivityAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(land_auction_activity_attrib, () => $"land_auction_activity_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
land_auction_activity_attrib.LandMetaId = LandMetaId;
|
||||
land_auction_activity_attrib.AuctionNumber = AuctionNumber;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(LandAuctionActivityDoc).Name;
|
||||
|
||||
var land_auction_activity_doc = docBase as LandAuctionActivityDoc;
|
||||
if (null == land_auction_activity_doc)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, land_auction_activity_doc is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<LandAuctionActivityAttribute>(land_auction_activity_doc);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var land_auction_activity_attrib = land_auction_activity_doc.getAttrib<LandAuctionActivityAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(land_auction_activity_attrib, () => "land_auction_activity_attrib is null !!!");
|
||||
|
||||
LandMetaId = land_auction_activity_attrib.LandMetaId;
|
||||
AuctionNumber = land_auction_activity_attrib.AuctionNumber;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var land_auction_activity_attribute = otherEntityAttribute as LandAuctionActivityAttribute;
|
||||
if (null == land_auction_activity_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast land_auction_activity_attribute !!!, land_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
LandMetaId = land_auction_activity_attribute.LandMetaId;
|
||||
AuctionNumber = land_auction_activity_attribute.AuctionNumber;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = land_auction_activity_attribute.getTryPendingDocBase() as LandAuctionActivityDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
land_auction_activity_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<LandAuctionActivityAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<LandAuctionActivityAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var land_auction_activity_attrib = origin_doc_base.getAttrib<LandAuctionActivityAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(land_auction_activity_attrib, () => $"land_auction_activity_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
land_auction_activity_attrib.LandMetaId = LandMetaId;
|
||||
land_auction_activity_attrib.AuctionNumber = AuctionNumber;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string toBasicString()
|
||||
{
|
||||
return base.toBasicString() + $" LandMetaId:{LandMetaId}, AuctionNumber:{AuctionNumber}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class LandAuctionActivityAttributeTransactor : EntityAttributeTransactorBase<LandAuctionActivityAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public LandAuctionActivityAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(LandAuctionRegistryAttribute).Name;
|
||||
|
||||
var copy_from_land_auction_activity_attribute = entityAttributeBase as LandAuctionActivityAttribute;
|
||||
if (null == copy_from_land_auction_activity_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_from_land_auction_activity_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_land_auction_activity_attribute = getClonedEntityAttribute() as LandAuctionActivityAttribute;
|
||||
if (null == copy_to_land_auction_activity_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_to_land_auction_activity_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_land_auction_activity_attribute.LandMetaId = copy_from_land_auction_activity_attribute.LandMetaId;
|
||||
copy_to_land_auction_activity_attribute.AuctionNumber = copy_from_land_auction_activity_attribute.AuctionNumber;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,445 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Amazon.DynamoDBv2;
|
||||
using Amazon.DynamoDBv2.Model;
|
||||
using Amazon.DynamoDBv2.DocumentModel;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerCommon.Cache;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using LAND_AUCTION_NUMBER = System.Int32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
using System.Runtime.InteropServices;
|
||||
using ServerControlCenter;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class LandAuctionHighestBidUserAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute, ICopyEntityAttributeFromCache
|
||||
{
|
||||
[JsonProperty]
|
||||
public META_ID LandMetaId { get; set; } = 0; // 경매 대상 LandData Meta Id
|
||||
|
||||
[JsonProperty]
|
||||
public LAND_AUCTION_NUMBER AuctionNumber { get; set; } = 0; // 경매 번호
|
||||
|
||||
[JsonProperty]
|
||||
public CurrencyType BidCurrencyType { get; set; } = 0; // 입찰 재화의 종류
|
||||
|
||||
|
||||
//=============================================================================================
|
||||
// 현재 최고 입찰자 정보
|
||||
//=============================================================================================
|
||||
[JsonProperty]
|
||||
public double HighestBidPrice { get; set; } = 0; // 입찰 최고가
|
||||
|
||||
[JsonProperty]
|
||||
public string HighestBidUserGuid { get; set; } = string.Empty; // 입찰 최고가 유저 식별키
|
||||
|
||||
[JsonProperty]
|
||||
public string HighestBidUserNickname { get; set; } = string.Empty; // 입찰 최고가 유저 닉네임
|
||||
|
||||
|
||||
//=============================================================================================
|
||||
// 일반 입찰 최고 입찰자 정보
|
||||
//=============================================================================================
|
||||
[JsonProperty]
|
||||
public double NormalHighestBidPrice { get; set; } = 0; // 일반 입찰 최고가
|
||||
|
||||
[JsonProperty]
|
||||
public string NormalHighestBidUserGuid { get; set; } = string.Empty; // 일반 입찰 최고가 유저 식별키
|
||||
|
||||
[JsonProperty]
|
||||
public string NormalHighestBidUserNickname { get; set; } = string.Empty; // 일반 입찰 최고가 유저 닉네임
|
||||
|
||||
|
||||
|
||||
[JsonProperty]
|
||||
public DateTime HighestRankVersionTime { get; set; } = DateTimeHelper.MinTime; // 최고 입찰자 순위 버전 정보
|
||||
|
||||
|
||||
public LandAuctionHighestBidUserAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new LandAuctionHighestBidUserAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
LandMetaId = 0;
|
||||
AuctionNumber = 0;
|
||||
|
||||
BidCurrencyType = CurrencyType.None;
|
||||
|
||||
HighestBidPrice = 0;
|
||||
HighestBidUserGuid = string.Empty;
|
||||
HighestBidUserNickname = string.Empty;
|
||||
|
||||
NormalHighestBidPrice = 0;
|
||||
NormalHighestBidUserGuid = string.Empty;
|
||||
NormalHighestBidUserNickname = string.Empty;
|
||||
|
||||
HighestRankVersionTime = DateTimeHelper.MinTime;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new LandAuctionHighestBidUserAttribute(getOwner());
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.LandMetaId = LandMetaId;
|
||||
cloned.AuctionNumber = AuctionNumber;
|
||||
|
||||
cloned.BidCurrencyType = BidCurrencyType;
|
||||
|
||||
cloned.HighestBidPrice = HighestBidPrice;
|
||||
cloned.HighestBidUserGuid = HighestBidUserGuid;
|
||||
cloned.HighestBidUserNickname = HighestBidUserNickname;
|
||||
|
||||
cloned.NormalHighestBidPrice = NormalHighestBidPrice;
|
||||
cloned.NormalHighestBidUserGuid = NormalHighestBidUserGuid;
|
||||
cloned.NormalHighestBidUserNickname = NormalHighestBidUserNickname;
|
||||
|
||||
cloned.HighestRankVersionTime = HighestRankVersionTime;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as LandAuctionHighestBidUserDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new LandAuctionHighestBidUserDoc(LandMetaId, AuctionNumber);
|
||||
|
||||
var origin_doc = getOriginDocBase<LandAuctionHighestBidUserAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var highest_bid_user_attrib = try_pending_doc.getAttrib<LandAuctionHighestBidUserAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(highest_bid_user_attrib, () => $"highest_bid_user_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
highest_bid_user_attrib.LandMetaId = LandMetaId;
|
||||
highest_bid_user_attrib.AuctionNumber = AuctionNumber;
|
||||
|
||||
highest_bid_user_attrib.BidCurrencyType = BidCurrencyType;
|
||||
|
||||
highest_bid_user_attrib.HighestBidPrice = HighestBidPrice;
|
||||
highest_bid_user_attrib.HighestBidUserGuid = HighestBidUserGuid;
|
||||
highest_bid_user_attrib.HighestBidUserNickname = HighestBidUserNickname;
|
||||
|
||||
highest_bid_user_attrib.NormalHighestBidPrice = NormalHighestBidPrice;
|
||||
highest_bid_user_attrib.NormalHighestBidUserGuid = NormalHighestBidUserGuid;
|
||||
highest_bid_user_attrib.NormalHighestBidUserNickname = NormalHighestBidUserNickname;
|
||||
|
||||
highest_bid_user_attrib.HighestRankVersionTime = HighestRankVersionTime;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(LandAuctionHighestBidUserDoc).Name;
|
||||
|
||||
var highest_bid_user_doc = docBase as LandAuctionHighestBidUserDoc;
|
||||
if (null == highest_bid_user_doc)
|
||||
{
|
||||
err_msg = $"Failed to cast LandAuctionHighestBidUserDoc, highest_bid_user_doc is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<LandAuctionHighestBidUserAttribute>(highest_bid_user_doc);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var hightest_bid_user_attrib = highest_bid_user_doc.getAttrib<LandAuctionHighestBidUserAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(hightest_bid_user_attrib, () => "hightest_bid_user_attrib is null !!!");
|
||||
|
||||
LandMetaId = hightest_bid_user_attrib.LandMetaId;
|
||||
AuctionNumber = hightest_bid_user_attrib.AuctionNumber;
|
||||
|
||||
BidCurrencyType = hightest_bid_user_attrib.BidCurrencyType;
|
||||
|
||||
HighestBidPrice = hightest_bid_user_attrib.HighestBidPrice;
|
||||
HighestBidUserGuid = hightest_bid_user_attrib.HighestBidUserGuid;
|
||||
HighestBidUserNickname = hightest_bid_user_attrib.HighestBidUserNickname;
|
||||
|
||||
NormalHighestBidPrice = hightest_bid_user_attrib.NormalHighestBidPrice;
|
||||
NormalHighestBidUserGuid = hightest_bid_user_attrib.NormalHighestBidUserGuid;
|
||||
NormalHighestBidUserNickname = hightest_bid_user_attrib.NormalHighestBidUserNickname;
|
||||
|
||||
HighestRankVersionTime = hightest_bid_user_attrib.HighestRankVersionTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromCache(CacheBase cacheBase)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = string.Empty;
|
||||
|
||||
to_cast_string = typeof(LandAuctionTopBidderCache).Name;
|
||||
var top_bidder_cache = cacheBase as LandAuctionTopBidderCache;
|
||||
if (null != top_bidder_cache)
|
||||
{
|
||||
//=====================================================================================
|
||||
// LandAuctionTopBidderCache -> LandAuctionAttribute
|
||||
//=====================================================================================
|
||||
if (LandMetaId != top_bidder_cache.LandMetaId)
|
||||
{
|
||||
err_msg = $"Failed to copy from LandAuctionTopBidderCache !!!, Invalid LandMetaId !!! : currLandMetaId:{LandMetaId} == LandAuctionTopBidderCache.LandMetaId:{top_bidder_cache.LandMetaId} - {toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
HighestBidPrice = top_bidder_cache.HighestBidPrice;
|
||||
|
||||
if (HighestBidUserGuid != top_bidder_cache.HighestBidUserGuid)
|
||||
{
|
||||
HighestBidUserGuid = top_bidder_cache.HighestBidUserGuid;
|
||||
(var result, var nickname_attrib) = NicknameDoc.findNicknameFromGuid(HighestBidUserGuid).GetAwaiter().GetResult();
|
||||
if (result.isFail()) { Log.getLogger().error($"Failed to NicknameDoc.findNicknameFromGuid() !!! : {result.toBasicString()}, highestBidUserGuid:{HighestBidUserGuid} - {owner.toBasicString()}"); }
|
||||
else
|
||||
{
|
||||
NullReferenceCheckHelper.throwIfNull(nickname_attrib, () => $"nickname_attrib is null !!! - {owner.toBasicString()}");
|
||||
HighestBidUserNickname = nickname_attrib.Nickname;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
to_cast_string = typeof(NormalBidHighestUserCache).Name;
|
||||
var normal_bid_highest_user_cache = cacheBase as NormalBidHighestUserCache;
|
||||
if (null != normal_bid_highest_user_cache)
|
||||
{
|
||||
//=====================================================================================
|
||||
// LandAuctionTopBidderCache -> LandAuctionAttribute
|
||||
//=====================================================================================
|
||||
if (LandMetaId != normal_bid_highest_user_cache.LandMetaId)
|
||||
{
|
||||
err_msg = $"Failed to copy from NormalBidHighestUserCache !!!, Invalid LandMetaId !!! : currLandMetaId:{LandMetaId} == NormalBidHighestUserCache.LandMetaId:{normal_bid_highest_user_cache.LandMetaId} - {toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
NormalHighestBidPrice = normal_bid_highest_user_cache.NormalHighestBidPrice;
|
||||
NormalHighestBidUserGuid = normal_bid_highest_user_cache.NormalHighestBidUserGuid;
|
||||
NormalHighestBidUserNickname = normal_bid_highest_user_cache.NormalHighestBidUserNickname;
|
||||
|
||||
HighestRankVersionTime = normal_bid_highest_user_cache.HighestRankVersionTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var highest_bid_user_attribute = otherEntityAttribute as LandAuctionHighestBidUserAttribute;
|
||||
if (null == highest_bid_user_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast LandAuctionHighestBidUserAttribute !!!, highest_bid_user_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
LandMetaId = highest_bid_user_attribute.LandMetaId;
|
||||
AuctionNumber = highest_bid_user_attribute.AuctionNumber;
|
||||
|
||||
BidCurrencyType = highest_bid_user_attribute.BidCurrencyType;
|
||||
|
||||
HighestBidPrice = highest_bid_user_attribute.HighestBidPrice;
|
||||
HighestBidUserGuid = highest_bid_user_attribute.HighestBidUserGuid;
|
||||
HighestBidUserNickname = highest_bid_user_attribute.HighestBidUserNickname;
|
||||
|
||||
NormalHighestBidPrice = highest_bid_user_attribute.NormalHighestBidPrice;
|
||||
NormalHighestBidUserGuid = highest_bid_user_attribute.NormalHighestBidUserGuid;
|
||||
NormalHighestBidUserNickname = highest_bid_user_attribute.NormalHighestBidUserNickname;
|
||||
|
||||
HighestRankVersionTime = highest_bid_user_attribute.HighestRankVersionTime;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = highest_bid_user_attribute.getTryPendingDocBase() as LandAuctionHighestBidUserDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
highest_bid_user_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<LandAuctionHighestBidUserAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<LandAuctionHighestBidUserAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var highest_bid_user_attrib = origin_doc_base.getAttrib<LandAuctionHighestBidUserAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(highest_bid_user_attrib, () => $"highest_bid_user_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
highest_bid_user_attrib.LandMetaId = LandMetaId;
|
||||
highest_bid_user_attrib.AuctionNumber = AuctionNumber;
|
||||
|
||||
highest_bid_user_attrib.BidCurrencyType = BidCurrencyType;
|
||||
|
||||
highest_bid_user_attrib.HighestBidPrice = HighestBidPrice;
|
||||
highest_bid_user_attrib.HighestBidUserGuid = HighestBidUserGuid;
|
||||
highest_bid_user_attrib.HighestBidUserNickname = HighestBidUserNickname;
|
||||
|
||||
highest_bid_user_attrib.NormalHighestBidPrice = NormalHighestBidPrice;
|
||||
highest_bid_user_attrib.NormalHighestBidUserGuid = NormalHighestBidUserGuid;
|
||||
highest_bid_user_attrib.NormalHighestBidUserNickname = NormalHighestBidUserNickname;
|
||||
|
||||
highest_bid_user_attrib.HighestRankVersionTime = HighestRankVersionTime;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string toBasicString()
|
||||
{
|
||||
return base.toBasicString()
|
||||
+ $" LandMetaId:{LandMetaId}, AuctionNumber:{AuctionNumber}"
|
||||
+ $", BidCurrencyType:{BidCurrencyType}"
|
||||
+ $", HighestBidPrice:{HighestBidPrice}, HighestBidUserGuid:{HighestBidUserGuid}, HighestBidUserNickname:{HighestBidUserNickname}"
|
||||
+ $", registeredVersion:{HighestRankVersionTime}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class LandAuctionHighestBidUserAttributeTransactor : EntityAttributeTransactorBase<LandAuctionHighestBidUserAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public LandAuctionHighestBidUserAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(LandAuctionHighestBidUserAttribute).Name;
|
||||
|
||||
var copy_from_highest_bid_user_attribute = entityAttributeBase as LandAuctionHighestBidUserAttribute;
|
||||
if (null == copy_from_highest_bid_user_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast LandAuctionHighestBidUserAttribute !!!, copy_from_highest_bid_user_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_highest_bid_user_attribute = getClonedEntityAttribute() as LandAuctionHighestBidUserAttribute;
|
||||
if (null == copy_to_highest_bid_user_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast LandAuctionHighestBidUserAttribute() !!!, copy_to_highest_bid_user_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_highest_bid_user_attribute.LandMetaId = copy_from_highest_bid_user_attribute.LandMetaId;
|
||||
copy_to_highest_bid_user_attribute.AuctionNumber = copy_from_highest_bid_user_attribute.AuctionNumber;
|
||||
|
||||
copy_to_highest_bid_user_attribute.BidCurrencyType = copy_from_highest_bid_user_attribute.BidCurrencyType;
|
||||
|
||||
copy_to_highest_bid_user_attribute.HighestBidPrice = copy_from_highest_bid_user_attribute.HighestBidPrice;
|
||||
copy_to_highest_bid_user_attribute.HighestBidUserGuid = copy_from_highest_bid_user_attribute.HighestBidUserGuid;
|
||||
copy_to_highest_bid_user_attribute.HighestBidUserNickname = copy_from_highest_bid_user_attribute.HighestBidUserNickname;
|
||||
|
||||
copy_to_highest_bid_user_attribute.NormalHighestBidPrice = copy_from_highest_bid_user_attribute.NormalHighestBidPrice;
|
||||
copy_to_highest_bid_user_attribute.NormalHighestBidUserGuid = copy_from_highest_bid_user_attribute.NormalHighestBidUserGuid;
|
||||
copy_to_highest_bid_user_attribute.NormalHighestBidUserNickname = copy_from_highest_bid_user_attribute.NormalHighestBidUserNickname;
|
||||
|
||||
copy_to_highest_bid_user_attribute.HighestRankVersionTime = copy_from_highest_bid_user_attribute.HighestRankVersionTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
243
ServerCommon/Entity/Attribute/LandAuctionRecordAttribute.cs
Normal file
243
ServerCommon/Entity/Attribute/LandAuctionRecordAttribute.cs
Normal file
@@ -0,0 +1,243 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerCommon.Cache;
|
||||
|
||||
|
||||
using META_ID = System.UInt32;
|
||||
using LAND_AUCTION_NUBER = System.Int32;
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
//=============================================================================================
|
||||
// 랜드별 LandAuctionResult.Successed (낙찰)된 경매 정보
|
||||
//=============================================================================================
|
||||
|
||||
public class LandAuctionRecordAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public META_ID LandMetaId { get; set; } = 0; // 경매 대상 LandData Meta Id
|
||||
|
||||
[JsonProperty]
|
||||
public LAND_AUCTION_NUBER AuctionNumber { get; set; } = 0; // 경매 번호
|
||||
|
||||
public LandAuctionRecordAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new LandAuctionRecordAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
LandMetaId = 0;
|
||||
AuctionNumber = 0;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new LandAuctionRecordAttribute(getOwner());
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.LandMetaId = LandMetaId;
|
||||
cloned.AuctionNumber = AuctionNumber;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as LandAuctionRecordDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new LandAuctionRecordDoc(LandMetaId, AuctionNumber);
|
||||
|
||||
var origin_doc = getOriginDocBase<LandAuctionRecordAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var record_attrib = try_pending_doc.getAttrib<LandAuctionRecordAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(record_attrib, () => $"record_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
record_attrib.LandMetaId = LandMetaId;
|
||||
record_attrib.AuctionNumber = AuctionNumber;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(LandDoc).Name;
|
||||
|
||||
var land_doc_base = docBase as LandDoc;
|
||||
if (null == land_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, land_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<LandAuctionRecordAttribute>(land_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var record_attrib = land_doc_base.getAttrib<LandAuctionRecordAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(record_attrib, () => "record_attrib is null !!!");
|
||||
|
||||
LandMetaId = record_attrib.LandMetaId;
|
||||
AuctionNumber = record_attrib.AuctionNumber;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var record_attribute = otherEntityAttribute as LandAuctionRecordAttribute;
|
||||
if (null == record_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast LandAuctionRecordAttribute !!!, record_attribute is null - {owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
LandMetaId = record_attribute.LandMetaId;
|
||||
AuctionNumber = record_attribute.AuctionNumber;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = record_attribute.getTryPendingDocBase() as LandAuctionRecordDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
record_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<LandAuctionRecordAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<LandAuctionRecordAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var record_attrib = origin_doc_base.getAttrib<LandAuctionRecordAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(record_attrib, () => $"record_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
record_attrib.LandMetaId = LandMetaId;
|
||||
record_attrib.AuctionNumber = AuctionNumber;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class LandAuctionRecordAttributeTransactor : EntityAttributeTransactorBase<LandAuctionRecordAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public LandAuctionRecordAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(LandAuctionRegistryAttribute).Name;
|
||||
|
||||
var copy_from_record_attribute = entityAttributeBase as LandAuctionRecordAttribute;
|
||||
if (null == copy_from_record_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast LandAuctionRecordAttribute !!!, copy_from_record_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_record_attribute = getClonedEntityAttribute() as LandAuctionRecordAttribute;
|
||||
if (null == copy_to_record_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast LandAuctionRecordAttribute !!!, copy_to_record_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_record_attribute.LandMetaId = copy_from_record_attribute.LandMetaId;
|
||||
copy_to_record_attribute.AuctionNumber = copy_from_record_attribute.AuctionNumber;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,290 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Amazon.DynamoDBv2;
|
||||
using Amazon.DynamoDBv2.Model;
|
||||
using Amazon.DynamoDBv2.DocumentModel;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class LandAuctionRefundBidPriceAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc
|
||||
{
|
||||
[JsonProperty]
|
||||
public USER_GUID BidUserGuid { get; set; } = string.Empty; // 입찰 유저 식별키
|
||||
|
||||
|
||||
[JsonProperty]
|
||||
public META_ID LandMetaId { get; set; } = 0; // Land Meta Id
|
||||
[JsonProperty]
|
||||
public Int32 AuctionNumber { get; set; } = 0; // LandMetaId 기준 경매 번호 1 ~
|
||||
|
||||
|
||||
[JsonProperty]
|
||||
public LandAuctionBidType LastBidType { get; set; } = 0; // 마지막 입찰의 종류
|
||||
[JsonProperty]
|
||||
public CurrencyType BidCurrencyType { get; set; } = CurrencyType.None; // 입찰 재화의 종류
|
||||
[JsonProperty]
|
||||
public double LastBidPrice { get; set; } = 0; // 마지막 입찰금
|
||||
|
||||
|
||||
[JsonProperty]
|
||||
public double RefundableNormalBidPrice { get; set; } = 0; // 본인의 일반 환급 가능한 입찰금
|
||||
[JsonProperty]
|
||||
public double RefundableBlindBidPrice { get; set; } = 0; // 본인의 블라인드 환급 가능한 입찰금
|
||||
|
||||
|
||||
public LandAuctionRefundBidPriceAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new LandAuctionRefundBidPriceAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
BidUserGuid = string.Empty;
|
||||
LandMetaId = 0;
|
||||
AuctionNumber = 0;
|
||||
|
||||
LastBidType = LandAuctionBidType.None;
|
||||
BidCurrencyType = CurrencyType.None;
|
||||
LastBidPrice = 0;
|
||||
|
||||
RefundableNormalBidPrice = 0;
|
||||
RefundableBlindBidPrice = 0;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new LandAuctionRefundBidPriceAttribute(getOwner());
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.BidUserGuid = string.Empty;
|
||||
cloned.LandMetaId = LandMetaId;
|
||||
cloned.AuctionNumber = AuctionNumber;
|
||||
|
||||
cloned.LastBidType = LastBidType;
|
||||
cloned.BidCurrencyType = BidCurrencyType;
|
||||
cloned.LastBidPrice = LastBidPrice;
|
||||
|
||||
cloned.RefundableNormalBidPrice = RefundableNormalBidPrice;
|
||||
cloned.RefundableBlindBidPrice = RefundableBlindBidPrice;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as LandAuctionRefundBidPriceDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new LandAuctionRefundBidPriceDoc(BidUserGuid, LandMetaId, AuctionNumber);
|
||||
|
||||
var origin_doc = getOriginDocBase<LandAuctionRefundBidPriceAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var refund_bid_price_attrib = try_pending_doc.getAttrib<LandAuctionRefundBidPriceAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(refund_bid_price_attrib, () => $"refund_bid_price_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
refund_bid_price_attrib.BidUserGuid = BidUserGuid;
|
||||
refund_bid_price_attrib.LandMetaId = LandMetaId;
|
||||
refund_bid_price_attrib.AuctionNumber = AuctionNumber;
|
||||
|
||||
refund_bid_price_attrib.LastBidType = LastBidType;
|
||||
refund_bid_price_attrib.BidCurrencyType = BidCurrencyType;
|
||||
refund_bid_price_attrib.LastBidPrice = LastBidPrice;
|
||||
|
||||
refund_bid_price_attrib.RefundableNormalBidPrice = RefundableNormalBidPrice;
|
||||
refund_bid_price_attrib.RefundableBlindBidPrice = RefundableBlindBidPrice;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(LandAuctionRefundBidPriceDoc).Name;
|
||||
|
||||
var refund_bid_price_doc = docBase as LandAuctionRefundBidPriceDoc;
|
||||
if (null == refund_bid_price_doc)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, refund_bid_price_doc is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<LandAuctionRefundBidPriceAttribute>(refund_bid_price_doc);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var refund_bid_price_attrib = refund_bid_price_doc.getAttrib<LandAuctionRefundBidPriceAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(refund_bid_price_attrib, () => "refund_bid_price_attrib is null !!!");
|
||||
|
||||
BidUserGuid = refund_bid_price_attrib.BidUserGuid;
|
||||
LandMetaId = refund_bid_price_attrib.LandMetaId;
|
||||
AuctionNumber = refund_bid_price_attrib.AuctionNumber;
|
||||
|
||||
LastBidType = refund_bid_price_attrib.LastBidType;
|
||||
BidCurrencyType = refund_bid_price_attrib.BidCurrencyType;
|
||||
LastBidPrice = refund_bid_price_attrib.LastBidPrice;
|
||||
|
||||
RefundableNormalBidPrice = refund_bid_price_attrib.RefundableNormalBidPrice;
|
||||
RefundableBlindBidPrice = refund_bid_price_attrib.RefundableBlindBidPrice;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result copyFromOtherEntityAttribute(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var refund_bid_price_attribute = otherEntityAttribute as LandAuctionRefundBidPriceAttribute;
|
||||
if (null == refund_bid_price_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast LandAuctionRefundBidPriceAttribute !!!, refund_bid_price_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
BidUserGuid = refund_bid_price_attribute.BidUserGuid;
|
||||
LandMetaId = refund_bid_price_attribute.LandMetaId;
|
||||
AuctionNumber = refund_bid_price_attribute.AuctionNumber;
|
||||
|
||||
LastBidType = refund_bid_price_attribute.LastBidType;
|
||||
BidCurrencyType = refund_bid_price_attribute.BidCurrencyType;
|
||||
LastBidPrice = refund_bid_price_attribute.LastBidPrice;
|
||||
|
||||
RefundableNormalBidPrice = refund_bid_price_attribute.RefundableNormalBidPrice;
|
||||
RefundableBlindBidPrice = refund_bid_price_attribute.RefundableBlindBidPrice;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = refund_bid_price_attribute.getTryPendingDocBase() as LandAuctionRefundBidPriceDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
refund_bid_price_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<LandAuctionRefundBidPriceAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<LandAuctionRefundBidPriceAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var refund_bid_price_attrib = origin_doc_base.getAttrib<LandAuctionRefundBidPriceAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(refund_bid_price_attrib, () => $"refund_bid_price_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
refund_bid_price_attrib.BidUserGuid = BidUserGuid;
|
||||
refund_bid_price_attrib.LandMetaId = LandMetaId;
|
||||
refund_bid_price_attrib.AuctionNumber = AuctionNumber;
|
||||
|
||||
refund_bid_price_attrib.LastBidType = LastBidType;
|
||||
refund_bid_price_attrib.BidCurrencyType = BidCurrencyType;
|
||||
refund_bid_price_attrib.LastBidPrice = LastBidPrice;
|
||||
|
||||
refund_bid_price_attrib.RefundableNormalBidPrice = RefundableNormalBidPrice;
|
||||
refund_bid_price_attrib.RefundableBlindBidPrice = RefundableBlindBidPrice;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string toBasicString()
|
||||
{
|
||||
return base.toBasicString() + $" LandMetaId:{LandMetaId}, AuctionNumber:{AuctionNumber}, BidUserGuid:{BidUserGuid}";
|
||||
}
|
||||
}
|
||||
|
||||
public class LandAuctionRefundBidPriceAttributeTransactor : EntityAttributeTransactorBase<LandAuctionRefundBidPriceAttribute>
|
||||
{
|
||||
public LandAuctionRefundBidPriceAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
488
ServerCommon/Entity/Attribute/LandAuctionRegistryAttribute.cs
Normal file
488
ServerCommon/Entity/Attribute/LandAuctionRegistryAttribute.cs
Normal file
@@ -0,0 +1,488 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerCommon.Cache;
|
||||
|
||||
|
||||
using META_ID = System.UInt32;
|
||||
using LAND_AUCTION_NUMBER = System.Int32;
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class LandAuctionRegistryAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
//=============================================================================================
|
||||
// 랜드 경매 식별 정보
|
||||
//=============================================================================================
|
||||
[JsonProperty]
|
||||
public META_ID LandMetaId { get; set; } = 0; // 경매 대상 LandData Meta Id
|
||||
|
||||
[JsonProperty]
|
||||
public LAND_AUCTION_NUMBER AuctionNumber { get; set; } = 0; // 경매 번호
|
||||
|
||||
|
||||
|
||||
//=============================================================================================
|
||||
// 랜드 경매 등록 정보
|
||||
//=============================================================================================
|
||||
[JsonProperty]
|
||||
public DateTime AuctionReservationNoticeStartTime { get; set; } = DateTimeHelper.MinTime; // 경매 예약 공지 시작 시간
|
||||
|
||||
[JsonProperty]
|
||||
public CurrencyType BidCurrencyType { get; set; } = 0; // 입찰 재화의 종류
|
||||
|
||||
[JsonProperty]
|
||||
public double BidStartPrice { get; set; } = 0; // 입찰 시작가
|
||||
|
||||
[JsonProperty]
|
||||
public DateTime AuctionStartTime { get; set; } = DateTimeHelper.MinTime; // 경매 시작 시간
|
||||
|
||||
[JsonProperty]
|
||||
public DateTime AuctionEndTime { get; set; } = DateTimeHelper.MinTime; // 경매 종료 시간
|
||||
|
||||
[JsonProperty]
|
||||
public bool IsCancelAuction { get; set; } = false; // 경매 취소 여부 (취소:true, 미취소:false)
|
||||
|
||||
[JsonProperty]
|
||||
public DateTime RegisteredVersionTime { get; set; } = DateTimeHelper.MinTime; // 경매 등록 버전 정보 (시간), 랜드 경매 등록 정보가 변경되면 등록 버전 정보도 갱신 되어야 한다. !!!
|
||||
|
||||
|
||||
|
||||
//=============================================================================================
|
||||
// 랜드 경매 진행 정보
|
||||
//=============================================================================================
|
||||
[JsonProperty]
|
||||
public LandAuctionState LandAuctionState { get; set; } = LandAuctionState.None; // 경매 상태
|
||||
|
||||
[JsonProperty]
|
||||
public LandAuctionResult LandAuctionResult { get; set; } = LandAuctionResult.None; // 경매 결과
|
||||
|
||||
[JsonProperty]
|
||||
public DateTime ProcessVersionTime { get; set; } = DateTimeHelper.MinTime; // 경매 진행 버전 정보 (시간), 랜드 경매 진행 정보가 변경되면 진행 버전 정보도 갱신되어야 한다. !!!
|
||||
|
||||
|
||||
public LandAuctionRegistryAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public void resetWaiting(META_ID landMetaId)
|
||||
{
|
||||
onClear();
|
||||
|
||||
LandMetaId = landMetaId;
|
||||
LandAuctionState = LandAuctionState.Waiting;
|
||||
|
||||
ProcessVersionTime = DateTimeHelper.Current;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new LandAuctionRegistryAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
LandMetaId = 0;
|
||||
AuctionNumber = 0;
|
||||
|
||||
AuctionReservationNoticeStartTime = DateTimeHelper.MinTime;
|
||||
BidCurrencyType = CurrencyType.None;
|
||||
BidStartPrice = 0;
|
||||
AuctionStartTime = DateTimeHelper.MinTime;
|
||||
AuctionEndTime = DateTimeHelper.MinTime;
|
||||
IsCancelAuction = false;
|
||||
RegisteredVersionTime = DateTimeHelper.MinTime;
|
||||
|
||||
LandAuctionState = LandAuctionState.None;
|
||||
LandAuctionResult = LandAuctionResult.None;
|
||||
ProcessVersionTime = DateTimeHelper.MinTime;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new LandAuctionRegistryAttribute(getOwner());
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.LandMetaId = LandMetaId;
|
||||
cloned.AuctionNumber = AuctionNumber;
|
||||
|
||||
cloned.AuctionReservationNoticeStartTime = AuctionReservationNoticeStartTime;
|
||||
cloned.BidCurrencyType = BidCurrencyType;
|
||||
cloned.BidStartPrice = BidStartPrice;
|
||||
cloned.AuctionStartTime = AuctionStartTime;
|
||||
cloned.AuctionEndTime = AuctionEndTime;
|
||||
cloned.IsCancelAuction = IsCancelAuction;
|
||||
cloned.RegisteredVersionTime = RegisteredVersionTime;
|
||||
|
||||
cloned.LandAuctionState = LandAuctionState;
|
||||
cloned.LandAuctionResult = LandAuctionResult;
|
||||
cloned.ProcessVersionTime = ProcessVersionTime;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as LandAuctionRegistryDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new LandAuctionRegistryDoc(LandMetaId, AuctionNumber, DateTimeHelper.Current);
|
||||
|
||||
var origin_doc = getOriginDocBase<LandAuctionRegistryAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var land_auction_attrib = try_pending_doc.getAttrib<LandAuctionRegistryAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(land_auction_attrib, () => $"land_auction_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
land_auction_attrib.LandMetaId = LandMetaId;
|
||||
land_auction_attrib.AuctionNumber = AuctionNumber;
|
||||
|
||||
land_auction_attrib.AuctionReservationNoticeStartTime = AuctionReservationNoticeStartTime;
|
||||
land_auction_attrib.BidCurrencyType = BidCurrencyType;
|
||||
land_auction_attrib.BidStartPrice = BidStartPrice;
|
||||
land_auction_attrib.AuctionStartTime = AuctionStartTime;
|
||||
land_auction_attrib.AuctionEndTime = AuctionEndTime;
|
||||
land_auction_attrib.IsCancelAuction = IsCancelAuction;
|
||||
land_auction_attrib.RegisteredVersionTime = RegisteredVersionTime;
|
||||
|
||||
land_auction_attrib.LandAuctionState = LandAuctionState;
|
||||
land_auction_attrib.LandAuctionResult = LandAuctionResult;
|
||||
land_auction_attrib.ProcessVersionTime = ProcessVersionTime;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(LandAuctionRegistryDoc).Name;
|
||||
|
||||
var land_doc_base = docBase as LandAuctionRegistryDoc;
|
||||
if (null == land_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, land_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<LandAuctionRegistryAttribute>(land_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var land_auction_registry_attrib = land_doc_base.getAttrib<LandAuctionRegistryAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(land_auction_registry_attrib, () => "land_auction_registry_attrib is null !!!");
|
||||
|
||||
LandMetaId = land_auction_registry_attrib.LandMetaId;
|
||||
AuctionNumber = land_auction_registry_attrib.AuctionNumber;
|
||||
|
||||
AuctionReservationNoticeStartTime = land_auction_registry_attrib.AuctionReservationNoticeStartTime;
|
||||
BidCurrencyType = land_auction_registry_attrib.BidCurrencyType;
|
||||
BidStartPrice = land_auction_registry_attrib.BidStartPrice;
|
||||
AuctionStartTime = land_auction_registry_attrib.AuctionStartTime;
|
||||
AuctionEndTime = land_auction_registry_attrib.AuctionEndTime;
|
||||
IsCancelAuction = land_auction_registry_attrib.IsCancelAuction;
|
||||
RegisteredVersionTime = land_auction_registry_attrib.RegisteredVersionTime;
|
||||
|
||||
LandAuctionState = land_auction_registry_attrib.LandAuctionState;
|
||||
LandAuctionResult = land_auction_registry_attrib.LandAuctionResult;
|
||||
ProcessVersionTime = land_auction_registry_attrib.ProcessVersionTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var land_auction_attribute = otherEntityAttribute as LandAuctionRegistryAttribute;
|
||||
if (null == land_auction_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast land_auction_attribute !!!, land_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
LandMetaId = land_auction_attribute.LandMetaId;
|
||||
AuctionNumber = land_auction_attribute.AuctionNumber;
|
||||
|
||||
AuctionReservationNoticeStartTime = land_auction_attribute.AuctionReservationNoticeStartTime;
|
||||
BidCurrencyType = land_auction_attribute.BidCurrencyType;
|
||||
BidStartPrice = land_auction_attribute.BidStartPrice;
|
||||
AuctionStartTime = land_auction_attribute.AuctionStartTime;
|
||||
AuctionEndTime = land_auction_attribute.AuctionEndTime;
|
||||
IsCancelAuction = land_auction_attribute.IsCancelAuction;
|
||||
RegisteredVersionTime = land_auction_attribute.RegisteredVersionTime;
|
||||
|
||||
LandAuctionState = land_auction_attribute.LandAuctionState;
|
||||
LandAuctionResult = land_auction_attribute.LandAuctionResult;
|
||||
ProcessVersionTime = land_auction_attribute.ProcessVersionTime;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = land_auction_attribute.getTryPendingDocBase() as LandAuctionRegistryDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
land_auction_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<LandAuctionRegistryAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<LandAuctionRegistryAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var land_auction_registry_attrib = origin_doc_base.getAttrib<LandAuctionRegistryAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(land_auction_registry_attrib, () => $"land_auction_registry_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
land_auction_registry_attrib.LandMetaId = LandMetaId;
|
||||
land_auction_registry_attrib.AuctionNumber = AuctionNumber;
|
||||
|
||||
land_auction_registry_attrib.AuctionReservationNoticeStartTime = AuctionReservationNoticeStartTime;
|
||||
land_auction_registry_attrib.BidCurrencyType = BidCurrencyType;
|
||||
land_auction_registry_attrib.BidStartPrice = BidStartPrice;
|
||||
land_auction_registry_attrib.AuctionStartTime = AuctionStartTime;
|
||||
land_auction_registry_attrib.AuctionEndTime = AuctionEndTime;
|
||||
land_auction_registry_attrib.IsCancelAuction = IsCancelAuction;
|
||||
land_auction_registry_attrib.RegisteredVersionTime = RegisteredVersionTime;
|
||||
|
||||
land_auction_registry_attrib.LandAuctionState = LandAuctionState;
|
||||
land_auction_registry_attrib.LandAuctionResult = LandAuctionResult;
|
||||
land_auction_registry_attrib.ProcessVersionTime = ProcessVersionTime;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void copyProcessInfoFromCache(LandAuctionCache landAuctionCache)
|
||||
{
|
||||
//=====================================================================================
|
||||
// Cache => Attribute
|
||||
//=====================================================================================
|
||||
LandMetaId = landAuctionCache.LandMetaId;
|
||||
AuctionNumber = landAuctionCache.AuctionNumber;
|
||||
|
||||
LandAuctionState = landAuctionCache.LandAuctionState;
|
||||
LandAuctionResult = landAuctionCache.LandAuctionResult;
|
||||
ProcessVersionTime = landAuctionCache.ProcessVersionTime;
|
||||
|
||||
var origin_doc = getOriginDocBase<LandAuctionRegistryAttribute>();
|
||||
if(null == origin_doc)
|
||||
{
|
||||
Log.getLogger().error($"origin_doc is null !!! - {toBasicString()}");
|
||||
}
|
||||
else
|
||||
{
|
||||
var registry_attrib = origin_doc.getAttrib<LandAuctionRegistryAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(registry_attrib, () => "registry_attrib is null !!!");
|
||||
|
||||
registry_attrib.LandAuctionState = landAuctionCache.LandAuctionState;
|
||||
registry_attrib.LandAuctionResult = landAuctionCache.LandAuctionResult;
|
||||
registry_attrib.ProcessVersionTime = landAuctionCache.ProcessVersionTime;
|
||||
|
||||
|
||||
Log.getLogger().debug($"copyProcessInfoFromCache() !!! : {toBasicString()}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void copyProcessInfoFromDoc(LandAuctionRegistryDoc registryDoc)
|
||||
{
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var land_auction_registry_attrib = registryDoc.getAttrib<LandAuctionRegistryAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(land_auction_registry_attrib, () => "land_auction_registry_attrib is null !!!");
|
||||
|
||||
LandMetaId = land_auction_registry_attrib.LandMetaId;
|
||||
AuctionNumber = land_auction_registry_attrib.AuctionNumber;
|
||||
|
||||
LandAuctionState = land_auction_registry_attrib.LandAuctionState;
|
||||
LandAuctionResult = land_auction_registry_attrib.LandAuctionResult;
|
||||
ProcessVersionTime = land_auction_registry_attrib.ProcessVersionTime;
|
||||
|
||||
var origin_doc = getOriginDocBase<LandAuctionRegistryAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
var registry_attrib = origin_doc.getAttrib<LandAuctionRegistryAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(registry_attrib, () => "registry_attrib is null !!!");
|
||||
|
||||
LandAuctionState = land_auction_registry_attrib.LandAuctionState;
|
||||
LandAuctionResult = land_auction_registry_attrib.LandAuctionResult;
|
||||
ProcessVersionTime = land_auction_registry_attrib.ProcessVersionTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
syncOriginDocBaseWithNewDoc<LandAuctionRegistryAttribute>(registryDoc);
|
||||
}
|
||||
|
||||
Log.getLogger().debug($"copyProcessInfoFromDoc() !!! : {toBasicString()}");
|
||||
}
|
||||
|
||||
public void copyRegisteredInfoFromDoc(LandAuctionRegistryDoc registryDoc)
|
||||
{
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var land_auction_registry_attrib = registryDoc.getAttrib<LandAuctionRegistryAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(land_auction_registry_attrib, () => "land_auction_registry_attrib is null !!!");
|
||||
|
||||
LandMetaId = land_auction_registry_attrib.LandMetaId;
|
||||
AuctionNumber = land_auction_registry_attrib.AuctionNumber;
|
||||
|
||||
AuctionReservationNoticeStartTime = land_auction_registry_attrib.AuctionReservationNoticeStartTime;
|
||||
BidCurrencyType = land_auction_registry_attrib.BidCurrencyType;
|
||||
BidStartPrice = land_auction_registry_attrib.BidStartPrice;
|
||||
AuctionStartTime = land_auction_registry_attrib.AuctionStartTime;
|
||||
AuctionEndTime = land_auction_registry_attrib.AuctionEndTime;
|
||||
IsCancelAuction = land_auction_registry_attrib.IsCancelAuction;
|
||||
RegisteredVersionTime = land_auction_registry_attrib.RegisteredVersionTime;
|
||||
|
||||
var origin_doc = getOriginDocBase<LandAuctionRegistryAttribute>();
|
||||
if(null != origin_doc)
|
||||
{
|
||||
var registry_attrib = origin_doc.getAttrib<LandAuctionRegistryAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(registry_attrib, () => "registry_attrib is null !!!");
|
||||
|
||||
AuctionReservationNoticeStartTime = land_auction_registry_attrib.AuctionReservationNoticeStartTime;
|
||||
BidCurrencyType = land_auction_registry_attrib.BidCurrencyType;
|
||||
BidStartPrice = land_auction_registry_attrib.BidStartPrice;
|
||||
AuctionStartTime = land_auction_registry_attrib.AuctionStartTime;
|
||||
AuctionEndTime = land_auction_registry_attrib.AuctionEndTime;
|
||||
IsCancelAuction = land_auction_registry_attrib.IsCancelAuction;
|
||||
RegisteredVersionTime = land_auction_registry_attrib.RegisteredVersionTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
syncOriginDocBaseWithNewDoc<LandAuctionRegistryAttribute>(registryDoc);
|
||||
}
|
||||
|
||||
Log.getLogger().debug($"copyRegisteredInfoFromDoc() !!! : {toBasicString()}");
|
||||
}
|
||||
|
||||
public override string toBasicString()
|
||||
{
|
||||
return base.toBasicString() + $" LandMetaId:{LandMetaId}, AuctionNumber:{AuctionNumber}, auctionEndTime:{AuctionEndTime}, auctionState:{LandAuctionState}, auctionResult:{LandAuctionResult}, processVersion:{ProcessVersionTime}, registeredVersion:{RegisteredVersionTime}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class LandAuctionRegistryAttributeTransactor : EntityAttributeTransactorBase<LandAuctionRegistryAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public LandAuctionRegistryAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(LandAuctionRegistryAttribute).Name;
|
||||
|
||||
var copy_from_land_attribute = entityAttributeBase as LandAuctionRegistryAttribute;
|
||||
if (null == copy_from_land_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_from_land_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_land_attribute = getClonedEntityAttribute() as LandAuctionRegistryAttribute;
|
||||
if (null == copy_to_land_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_to_land_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_land_attribute.LandMetaId = copy_from_land_attribute.LandMetaId;
|
||||
copy_to_land_attribute.AuctionNumber = copy_from_land_attribute.AuctionNumber;
|
||||
|
||||
copy_to_land_attribute.AuctionReservationNoticeStartTime = copy_from_land_attribute.AuctionReservationNoticeStartTime;
|
||||
copy_to_land_attribute.BidCurrencyType = copy_from_land_attribute.BidCurrencyType;
|
||||
copy_to_land_attribute.BidStartPrice = copy_from_land_attribute.BidStartPrice;
|
||||
copy_to_land_attribute.AuctionStartTime = copy_from_land_attribute.AuctionStartTime;
|
||||
copy_to_land_attribute.AuctionEndTime = copy_from_land_attribute.AuctionEndTime;
|
||||
copy_to_land_attribute.IsCancelAuction = copy_from_land_attribute.IsCancelAuction;
|
||||
copy_to_land_attribute.RegisteredVersionTime = copy_from_land_attribute.RegisteredVersionTime;
|
||||
|
||||
copy_to_land_attribute.LandAuctionState = copy_from_land_attribute.LandAuctionState;
|
||||
copy_to_land_attribute.LandAuctionResult = copy_from_land_attribute.LandAuctionResult;
|
||||
copy_to_land_attribute.ProcessVersionTime = copy_from_land_attribute.ProcessVersionTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
275
ServerCommon/Entity/Attribute/LevelAttribute.cs
Normal file
275
ServerCommon/Entity/Attribute/LevelAttribute.cs
Normal file
@@ -0,0 +1,275 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
using Amazon.S3.Model;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class LevelAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public UInt64 Exp
|
||||
{
|
||||
get { return m_exp; }
|
||||
set
|
||||
{
|
||||
var recorder = getEntityRecorder();
|
||||
if(null != recorder)
|
||||
{
|
||||
recorder.applyDeltaCounter(EntityDeltaType.UserExp, (Int64)(value - m_exp), (Int64)value);
|
||||
}
|
||||
|
||||
m_exp = value;
|
||||
}
|
||||
}
|
||||
private UInt64 m_exp = 0;
|
||||
|
||||
|
||||
[JsonProperty]
|
||||
public UInt32 Level
|
||||
{
|
||||
get { return m_level; }
|
||||
set
|
||||
{
|
||||
var recorder = getEntityRecorder();
|
||||
if (null != recorder)
|
||||
{
|
||||
recorder.applyDeltaCounter(EntityDeltaType.UserLevel, value - m_level, value);
|
||||
}
|
||||
m_level = value;
|
||||
}
|
||||
}
|
||||
private UInt32 m_level = 0;
|
||||
|
||||
|
||||
|
||||
public LevelAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
Exp = 0;
|
||||
Level = 0;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new LevelAttribute(getOwner());
|
||||
cloned.Exp = Exp;
|
||||
cloned.Level = Level;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new LevelAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var user_attribute = owner.getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
USER_GUID user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as LevelDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new LevelDoc(OwnerEntityType.User, user_guid);
|
||||
|
||||
var origin_doc = getOriginDocBase<LevelAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<LevelAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
to_copy_doc_attrib.Exp = Exp;
|
||||
to_copy_doc_attrib.Level = Level;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var level_attribute = otherEntityAttribute as LevelAttribute;
|
||||
if (null == level_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast LevelAttribute !!!, level_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Exp = level_attribute.Exp;
|
||||
Level = level_attribute.Level;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = level_attribute.getTryPendingDocBase() as LevelDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
level_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<LevelAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<LevelAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var level_attrib = origin_doc_base.getAttrib<LevelAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(level_attrib, () => $"level_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
level_attrib.Exp = Exp;
|
||||
level_attrib.Level = Level;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(LevelDoc).Name;
|
||||
|
||||
var level_doc_base = docBase as LevelDoc;
|
||||
if (null == level_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, level_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<LevelAttribute>(level_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = level_doc_base.getAttrib<LevelAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_attrib, () => "LevelAttrib is null !!!");
|
||||
|
||||
Exp = doc_attrib.Exp;
|
||||
Level = doc_attrib.Level;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class LevelAttributeTransactor : EntityAttributeTransactorBase<LevelAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public LevelAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(LevelAttribute).Name;
|
||||
|
||||
var copy_from_level_attribute = entityAttributeBase as LevelAttribute;
|
||||
if (null == copy_from_level_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_level_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_level_attribute = getClonedEntityAttribute() as LevelAttribute;
|
||||
if (null == copy_to_level_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_level_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_level_attribute.Exp = copy_from_level_attribute.Exp;
|
||||
copy_to_level_attribute.Level = copy_from_level_attribute.Level;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
289
ServerCommon/Entity/Attribute/LocationAttribute.cs
Normal file
289
ServerCommon/Entity/Attribute/LocationAttribute.cs
Normal file
@@ -0,0 +1,289 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Amazon.S3.Model;
|
||||
using Newtonsoft.Json;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class LocationAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, ICopyEntityAttributeFromCache, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public ChannelServerLocation CurrentChannelServerLoaction { get; set; } = new();
|
||||
[JsonProperty]
|
||||
public ChannelServerLocation LastestChannelServerLocation { get; set; } = new();
|
||||
|
||||
|
||||
public IndunLocation ReJoinIndunLocation { get; set; } = new();
|
||||
public List<IndunLocation> ReturnIndunLocations { get; set; } = new();
|
||||
public IndunLocation EnterIndunLocation { get; set; } = new();
|
||||
public IndunLocation CurrentIndunLocation { get; set; } = new();
|
||||
|
||||
public Timestamp MoveChannelTime { get; set; } = DateTimeHelper.MinTime.ToTimestamp();
|
||||
|
||||
|
||||
public LocationAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new LocationAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
LastestChannelServerLocation.clear();
|
||||
ReJoinIndunLocation.clear();
|
||||
ReturnIndunLocations.Clear();
|
||||
EnterIndunLocation.clear();
|
||||
|
||||
CurrentIndunLocation.clear();
|
||||
MoveChannelTime = DateTimeHelper.MinTime.ToTimestamp();
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new LocationAttribute(getOwner());
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.LastestChannelServerLocation = LastestChannelServerLocation.clone();
|
||||
cloned.ReJoinIndunLocation = ReJoinIndunLocation.clone();
|
||||
cloned.ReturnIndunLocations = ReturnIndunLocations.Select(x => x.clone()).ToList();
|
||||
cloned.EnterIndunLocation = EnterIndunLocation.clone();
|
||||
|
||||
cloned.CurrentIndunLocation = CurrentIndunLocation.clone();
|
||||
|
||||
cloned.MoveChannelTime = MoveChannelTime;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var user_attribute = owner.getRootParent().getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
USER_GUID user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as LocationDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new LocationDoc(user_guid);
|
||||
|
||||
var origin_doc = getOriginDocBase<LocationAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<LocationAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
to_copy_doc_attrib.LastConnectedChannelServerLocation = LastestChannelServerLocation.clone();
|
||||
to_copy_doc_attrib.ReJoinIndunLocation = ReJoinIndunLocation.clone();
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(LocationDoc).Name;
|
||||
|
||||
var location_doc_base = docBase as LocationDoc;
|
||||
if (null == location_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, location_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<LocationAttribute>(location_doc_base);
|
||||
|
||||
var doc_attrib = location_doc_base.getAttrib<LocationAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_attrib, () => "doc_attrib is null !!!");
|
||||
|
||||
LastestChannelServerLocation = doc_attrib.LastConnectedChannelServerLocation.clone();
|
||||
ReJoinIndunLocation = doc_attrib.ReJoinIndunLocation.clone();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromCache(CacheBase? cacheBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
var to_cast_string = typeof(LocationCache).Name;
|
||||
|
||||
var location_cache = cacheBase as LocationCache;
|
||||
if (null == location_cache)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromCache() !!!, location_cache is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Cache => Attribute
|
||||
//=====================================================================================
|
||||
LastestChannelServerLocation = location_cache.LastestChannelServerLocation.clone();
|
||||
ReturnIndunLocations = location_cache.ReturnIndunLocations.Select(x => x.clone()).ToList();
|
||||
EnterIndunLocation = location_cache.EnterIndunLocation.clone();
|
||||
MoveChannelTime = location_cache.MoveChannelTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var location_attribute = otherEntityAttribute as LocationAttribute;
|
||||
if (null == location_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast MinimapMarkerAttribute !!!, minimap_marker_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
LastestChannelServerLocation = location_attribute.LastestChannelServerLocation.clone();
|
||||
ReturnIndunLocations = location_attribute.ReturnIndunLocations.Select(x => x.clone()).ToList();
|
||||
EnterIndunLocation = location_attribute.EnterIndunLocation.clone();
|
||||
|
||||
CurrentIndunLocation = location_attribute.CurrentIndunLocation.clone();
|
||||
MoveChannelTime = location_attribute.MoveChannelTime;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = location_attribute.getTryPendingDocBase() as LocationDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
location_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<LocationAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<LocationAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var location_attrib = origin_doc_base.getAttrib<LocationAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(location_attrib, () => $"location_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
location_attrib.LastConnectedChannelServerLocation = LastestChannelServerLocation.clone();
|
||||
location_attrib.ReJoinIndunLocation = ReJoinIndunLocation.clone();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class LocationAttributeTransactor : EntityAttributeTransactorBase<LocationAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public LocationAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(LocationAttribute).Name;
|
||||
|
||||
var copy_from_location_attribute = entityAttributeBase as LocationAttribute;
|
||||
if (null == copy_from_location_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_from_location_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_location_attribute = getClonedEntityAttribute() as LocationAttribute;
|
||||
if (null == copy_to_location_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_to_location_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_location_attribute.LastestChannelServerLocation = copy_from_location_attribute.LastestChannelServerLocation.clone();
|
||||
copy_to_location_attribute.ReJoinIndunLocation = copy_from_location_attribute.ReJoinIndunLocation.clone();
|
||||
copy_to_location_attribute.ReturnIndunLocations = copy_from_location_attribute.ReturnIndunLocations.Select(x => x.clone()).ToList();
|
||||
copy_to_location_attribute.EnterIndunLocation = copy_from_location_attribute.EnterIndunLocation.clone();
|
||||
|
||||
copy_to_location_attribute.CurrentIndunLocation = copy_from_location_attribute.CurrentIndunLocation.clone();
|
||||
copy_to_location_attribute.MoveChannelTime = copy_from_location_attribute.MoveChannelTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
404
ServerCommon/Entity/Attribute/MailAttribute.cs
Normal file
404
ServerCommon/Entity/Attribute/MailAttribute.cs
Normal file
@@ -0,0 +1,404 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
using MAIL_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
|
||||
public class MailAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public MAIL_GUID MailGuid { get; set; } = string.Empty;
|
||||
|
||||
|
||||
public bool IsRead { get; set; } = false;
|
||||
public bool IsGetItem { get; set; } = false;
|
||||
public bool IsSystemMail { get; set; } = false;
|
||||
|
||||
|
||||
[JsonProperty]
|
||||
public string SenderNickName { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public string SenderGuid { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public string ReceiverNickName { get; set; } = string.Empty;
|
||||
[JsonProperty]
|
||||
public string ReceiverGuid { get; set; } = string.Empty;
|
||||
|
||||
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string Text { get; set; } = string.Empty;
|
||||
|
||||
|
||||
[JsonProperty]
|
||||
public DateTime CreateTime { get; set; } = DateTimeHelper.MinTime;
|
||||
[JsonProperty]
|
||||
public DateTime ExpireTime { get; set; } = DateTimeHelper.MinTime;
|
||||
|
||||
|
||||
[JsonProperty]
|
||||
public bool IsTextByMetaData { get; set; } = false;
|
||||
[JsonProperty]
|
||||
public List<MailItem> ItemList { get; set; } = new();
|
||||
|
||||
|
||||
[JsonProperty]
|
||||
public string packageOrderId { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public List<string> ContentsArguments { get; set; } = new();
|
||||
|
||||
|
||||
|
||||
public MailAttribute(EntityBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
MailGuid = string.Empty;
|
||||
IsRead = false;
|
||||
IsGetItem = false;
|
||||
IsSystemMail = false;
|
||||
SenderNickName = string.Empty;
|
||||
SenderGuid = string.Empty;
|
||||
ReceiverNickName = string.Empty;
|
||||
ReceiverGuid = string.Empty;
|
||||
Title = string.Empty;
|
||||
Text = string.Empty;
|
||||
CreateTime = DateTimeHelper.MinTime;
|
||||
ExpireTime = DateTimeHelper.MinTime;
|
||||
IsTextByMetaData = false;
|
||||
ItemList = new List<MailItem>();
|
||||
packageOrderId = string.Empty;
|
||||
ContentsArguments.Clear();
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new MailAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var entity_type = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(entity_type, () => "Entity Type is null !!!");
|
||||
|
||||
var cloned = new MailAttribute(getOwner(), entity_type);
|
||||
cloned.MailGuid = MailGuid;
|
||||
cloned.IsRead = IsRead;
|
||||
cloned.IsGetItem = IsGetItem;
|
||||
cloned.IsSystemMail = IsSystemMail;
|
||||
cloned.SenderNickName = SenderNickName;
|
||||
cloned.SenderGuid = SenderGuid;
|
||||
cloned.ReceiverNickName = ReceiverNickName;
|
||||
cloned.ReceiverGuid = ReceiverGuid;
|
||||
cloned.Title = Title;
|
||||
cloned.Text = Text;
|
||||
cloned.CreateTime = CreateTime;
|
||||
cloned.ExpireTime = ExpireTime;
|
||||
cloned.IsTextByMetaData = IsTextByMetaData;
|
||||
cloned.ItemList = ItemList.Select(x => new MailItem() { ItemId = x.ItemId, Count = x.Count, ProductId = x.ProductId, isRepeatProduct = x.isRepeatProduct }).ToList();
|
||||
cloned.packageOrderId = packageOrderId;
|
||||
cloned.ContentsArguments = ContentsArguments.ToList(); //string 객체는 기본적으로 DeepCopy 처리 !!!
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var root_parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(root_parent, () => $"root_parent is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var acoount_attribute = root_parent.getEntityAttribute<AccountAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(acoount_attribute, () => $"account_attribute is null !!! - {root_parent.toBasicString()}");
|
||||
|
||||
USER_GUID user_guid = acoount_attribute.UserGuid;
|
||||
|
||||
var ttl_sec = DynamoDbClientHelper.makeTTLTimeForDynamoDB(ExpireTime);
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as MailDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
MailDoc? to_copy_doc;
|
||||
|
||||
if (SenderGuid == user_guid)
|
||||
{
|
||||
if (getAttributeState().hasFlag(StateType.Created) == true && ExpireTime != DateTimeHelper.MaxTime)
|
||||
{
|
||||
to_copy_doc = new SentMailDoc(user_guid, MailGuid, ttl_sec);
|
||||
}
|
||||
else
|
||||
{
|
||||
to_copy_doc = new SentMailDoc(user_guid, MailGuid);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (getAttributeState().hasFlag(StateType.Created) == true && ExpireTime != DateTimeHelper.MaxTime)
|
||||
{
|
||||
to_copy_doc = new ReceivedMailDoc(user_guid, MailGuid, ttl_sec);
|
||||
}
|
||||
else
|
||||
{
|
||||
to_copy_doc = new ReceivedMailDoc(user_guid, MailGuid);
|
||||
}
|
||||
}
|
||||
|
||||
var origin_doc = getOriginDocBase<MailAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<MailAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => "to_copy_doc_attrib is null !!!");
|
||||
|
||||
to_copy_doc_attrib.MailGuid = MailGuid;
|
||||
to_copy_doc_attrib.IsRead = IsRead;
|
||||
to_copy_doc_attrib.IsGetItem = IsGetItem;
|
||||
to_copy_doc_attrib.IsSystemMail = IsSystemMail;
|
||||
to_copy_doc_attrib.SenderNickName = SenderNickName;
|
||||
to_copy_doc_attrib.SenderGuid = SenderGuid;
|
||||
to_copy_doc_attrib.ReceiverNickName = ReceiverNickName;
|
||||
to_copy_doc_attrib.ReceiverGuid = ReceiverGuid;
|
||||
to_copy_doc_attrib.Title = Title;
|
||||
to_copy_doc_attrib.Text = Text;
|
||||
to_copy_doc_attrib.CreateTime = CreateTime;
|
||||
to_copy_doc_attrib.ExpireTime = ExpireTime;
|
||||
to_copy_doc_attrib.IsTextByMetaData = IsTextByMetaData;
|
||||
to_copy_doc_attrib.ItemList = ItemList.Select(x => new MailItem() { ItemId = x.ItemId, Count = x.Count, ProductId = x.ProductId, isRepeatProduct = x.isRepeatProduct }).ToList();
|
||||
to_copy_doc_attrib.packageOrderId = packageOrderId;
|
||||
to_copy_doc_attrib.ContentsArguments = ContentsArguments.ToList(); //string 객체는 기본적으로 DeepCopy 처리 !!!
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(MailDoc).Name;
|
||||
|
||||
var mail_doc_base = docBase as MailDoc;
|
||||
if (mail_doc_base == null)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, mail_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<MailAttribute>(mail_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = mail_doc_base.getAttrib<MailAttrib>();
|
||||
if (doc_attrib == null)
|
||||
{
|
||||
err_msg = $"Failed to get mail attrib : {nameof(MailAttrib)}";
|
||||
result.setFail(ServerErrorCode.EntityAttributeIsNull, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
MailGuid = doc_attrib.MailGuid;
|
||||
IsRead = doc_attrib.IsRead;
|
||||
IsGetItem = doc_attrib.IsGetItem;
|
||||
IsSystemMail = doc_attrib.IsSystemMail;
|
||||
SenderNickName = doc_attrib.SenderNickName;
|
||||
SenderGuid = doc_attrib.SenderGuid;
|
||||
ReceiverNickName = doc_attrib.ReceiverNickName;
|
||||
ReceiverGuid = doc_attrib.ReceiverGuid;
|
||||
Title = doc_attrib.Title;
|
||||
Text = doc_attrib.Text;
|
||||
CreateTime = doc_attrib.CreateTime;
|
||||
ExpireTime = doc_attrib.ExpireTime;
|
||||
IsTextByMetaData = doc_attrib.IsTextByMetaData;
|
||||
ItemList = doc_attrib.ItemList.Select(x => new MailItem() { ItemId = x.ItemId, Count = x.Count, ProductId = x.ProductId, isRepeatProduct = x.isRepeatProduct }).ToList();
|
||||
packageOrderId = doc_attrib.packageOrderId;
|
||||
ContentsArguments = doc_attrib.ContentsArguments.ToList(); //string 객체는 기본적으로 DeepCopy 처리 !!!
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (otherEntityAttribute == null)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var mail_attribute = otherEntityAttribute as MailAttribute;
|
||||
if (null == mail_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast MailAttribute !!!, mail_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
MailGuid = mail_attribute.MailGuid;
|
||||
IsRead = mail_attribute.IsRead;
|
||||
IsGetItem = mail_attribute.IsGetItem;
|
||||
IsSystemMail = mail_attribute.IsSystemMail;
|
||||
SenderNickName = mail_attribute.SenderNickName;
|
||||
SenderGuid = mail_attribute.SenderGuid;
|
||||
ReceiverNickName = mail_attribute.ReceiverNickName;
|
||||
ReceiverGuid = mail_attribute.ReceiverGuid;
|
||||
Title = mail_attribute.Title;
|
||||
Text = mail_attribute.Text;
|
||||
CreateTime = mail_attribute.CreateTime;
|
||||
ExpireTime = mail_attribute.ExpireTime;
|
||||
IsTextByMetaData = mail_attribute.IsTextByMetaData;
|
||||
ItemList = mail_attribute.ItemList.Select(x => new MailItem() { ItemId = x.ItemId, Count = x.Count, ProductId = x.ProductId, isRepeatProduct = x.isRepeatProduct }).ToList();
|
||||
packageOrderId = mail_attribute.packageOrderId;
|
||||
ContentsArguments = mail_attribute.ContentsArguments.ToList(); //string 객체는 기본적으로 DeepCopy 처리 !!!
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = otherEntityAttribute.getTryPendingDocBase() as MailDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
mail_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<MailAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<MailAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var mail_attrib = origin_doc_base.getAttrib<MailAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(mail_attrib, () => $"mail_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
mail_attrib.MailGuid = MailGuid;
|
||||
mail_attrib.IsRead = IsRead;
|
||||
mail_attrib.IsGetItem = IsGetItem;
|
||||
mail_attrib.IsSystemMail = IsSystemMail;
|
||||
mail_attrib.SenderNickName = SenderNickName;
|
||||
mail_attrib.SenderGuid = SenderGuid;
|
||||
mail_attrib.ReceiverNickName = ReceiverNickName;
|
||||
mail_attrib.ReceiverGuid = ReceiverGuid;
|
||||
mail_attrib.Title = Title;
|
||||
mail_attrib.Text = Text;
|
||||
mail_attrib.CreateTime = CreateTime;
|
||||
mail_attrib.ExpireTime = ExpireTime;
|
||||
mail_attrib.IsTextByMetaData = IsTextByMetaData;
|
||||
mail_attrib.ItemList = ItemList.Select(x => new MailItem() { ItemId = x.ItemId, Count = x.Count, ProductId = x.ProductId, isRepeatProduct = x.isRepeatProduct }).ToList();
|
||||
mail_attrib.packageOrderId = packageOrderId;
|
||||
mail_attrib.ContentsArguments = ContentsArguments.ToList(); //string 객체는 기본적으로 DeepCopy 처리 !!!
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class MailAttributeTransactor : EntityAttributeTransactorBase<MailAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public MailAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(MailAttribute).Name;
|
||||
|
||||
var copy_from_mail_attribute = entityAttributeBase as MailAttribute;
|
||||
if (copy_from_mail_attribute == null)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_mail_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_mail_attribute = getClonedEntityAttribute() as MailAttribute;
|
||||
if (copy_to_mail_attribute == null)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_mail_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_mail_attribute.MailGuid = copy_from_mail_attribute.MailGuid;
|
||||
copy_to_mail_attribute.IsRead = copy_from_mail_attribute.IsRead;
|
||||
copy_to_mail_attribute.IsGetItem = copy_from_mail_attribute.IsGetItem;
|
||||
copy_to_mail_attribute.IsSystemMail = copy_from_mail_attribute.IsSystemMail;
|
||||
copy_to_mail_attribute.SenderNickName = copy_from_mail_attribute.SenderNickName;
|
||||
copy_to_mail_attribute.SenderGuid = copy_from_mail_attribute.SenderGuid;
|
||||
copy_to_mail_attribute.ReceiverNickName = copy_from_mail_attribute.ReceiverNickName;
|
||||
copy_to_mail_attribute.ReceiverGuid = copy_from_mail_attribute.ReceiverGuid;
|
||||
copy_to_mail_attribute.Title = copy_from_mail_attribute.Title;
|
||||
copy_to_mail_attribute.Text = copy_from_mail_attribute.Text;
|
||||
copy_to_mail_attribute.CreateTime = copy_from_mail_attribute.CreateTime;
|
||||
copy_to_mail_attribute.ExpireTime = copy_from_mail_attribute.ExpireTime;
|
||||
copy_to_mail_attribute.IsTextByMetaData = copy_from_mail_attribute.IsTextByMetaData;
|
||||
copy_to_mail_attribute.ItemList = copy_from_mail_attribute.ItemList.Select(x => new MailItem() { ItemId = x.ItemId, Count = x.Count, ProductId = x.ProductId, isRepeatProduct = x.isRepeatProduct }).ToList();
|
||||
copy_to_mail_attribute.packageOrderId = copy_from_mail_attribute.packageOrderId;
|
||||
copy_to_mail_attribute.ContentsArguments = copy_from_mail_attribute.ContentsArguments.ToList(); //string 객체는 기본적으로 DeepCopy 처리 !!!
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
308
ServerCommon/Entity/Attribute/MailProfileAttribute.cs
Normal file
308
ServerCommon/Entity/Attribute/MailProfileAttribute.cs
Normal file
@@ -0,0 +1,308 @@
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class MailProfileAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public Int32 SendMailCount { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public Int64 SendMailUpdateDay { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public Int32 LastSystemMailId { get; set; } = 0;
|
||||
|
||||
public Dictionary<Int32, DateTime> ReceivedSystemMails { get; set; } = new();
|
||||
|
||||
|
||||
public MailProfileAttribute(UserBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
public override void onClear()
|
||||
{
|
||||
SendMailCount = 0;
|
||||
SendMailUpdateDay = 0;
|
||||
LastSystemMailId = 0;
|
||||
ReceivedSystemMails.Clear();
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
var owner = getOwner() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
return new MailProfileAttributeTransactor(owner);
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var cloned = new MailProfileAttribute(owner);
|
||||
cloned.SendMailCount = SendMailCount;
|
||||
cloned.SendMailUpdateDay = SendMailUpdateDay;
|
||||
cloned.LastSystemMailId = LastSystemMailId;
|
||||
|
||||
cloned.ReceivedSystemMails = new();
|
||||
foreach (var mail in ReceivedSystemMails)
|
||||
{
|
||||
if (false == cloned.ReceivedSystemMails.TryAdd(mail.Key, mail.Value))
|
||||
{
|
||||
Log.getLogger().warn($"ReceivedSystemMails add return false key : {mail.Key}, value : {mail.Value}");
|
||||
}
|
||||
}
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var acoount_attribute = owner.getEntityAttribute<AccountAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(acoount_attribute, () => $"account_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
USER_GUID user_guid = acoount_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as MailProfileDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new MailProfileDoc(user_guid);
|
||||
|
||||
var origin_doc = getOriginDocBase<MailProfileAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<MailProfileAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!! - user_guid: {user_guid}");
|
||||
|
||||
to_copy_doc_attrib.SendMailUpdateDay = SendMailUpdateDay;
|
||||
to_copy_doc_attrib.LastSystemMailId = LastSystemMailId;
|
||||
to_copy_doc_attrib.SendMailCount = SendMailCount;
|
||||
|
||||
to_copy_doc_attrib.ReceivedSystemMails = new();
|
||||
foreach (var mail in ReceivedSystemMails)
|
||||
{
|
||||
if (false == to_copy_doc_attrib.ReceivedSystemMails.TryAdd(mail.Key, mail.Value))
|
||||
{
|
||||
Log.getLogger().warn($"ReceivedSystemMails add return false key : {mail.Key}, value : {mail.Value}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(MailProfileDoc).Name;
|
||||
|
||||
var mail_profile_doc_base = docBase as MailProfileDoc;
|
||||
if (null == mail_profile_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, mail_profile_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<MailProfileAttribute>(mail_profile_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = mail_profile_doc_base.getAttrib<MailProfileAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_attrib, () => "doc_attrib is null !!!");
|
||||
|
||||
SendMailUpdateDay = doc_attrib.SendMailUpdateDay;
|
||||
LastSystemMailId = doc_attrib.LastSystemMailId;
|
||||
SendMailCount = doc_attrib.SendMailCount;
|
||||
|
||||
ReceivedSystemMails = new();
|
||||
foreach (var mail in doc_attrib.ReceivedSystemMails)
|
||||
{
|
||||
if (false == ReceivedSystemMails.TryAdd(mail.Key, mail.Value))
|
||||
{
|
||||
Log.getLogger().warn($"ReceivedSystemMails add return false key : {mail.Key}, value : {mail.Value}");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var mail_profile_attribute = otherEntityAttribute as MailProfileAttribute;
|
||||
if (null == mail_profile_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast MailProfileAttribute !!!, mail_profile_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SendMailUpdateDay = mail_profile_attribute.SendMailUpdateDay;
|
||||
LastSystemMailId = mail_profile_attribute.LastSystemMailId;
|
||||
SendMailCount = mail_profile_attribute.SendMailCount;
|
||||
|
||||
ReceivedSystemMails = new();
|
||||
foreach (var mail in mail_profile_attribute.ReceivedSystemMails)
|
||||
{
|
||||
if (false == ReceivedSystemMails.TryAdd(mail.Key, mail.Value))
|
||||
{
|
||||
Log.getLogger().warn($"ReceivedSystemMails add return false key : {mail.Key}, value : {mail.Value}");
|
||||
}
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = mail_profile_attribute.getTryPendingDocBase() as MailProfileDoc ;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
mail_profile_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<MailProfileAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<MailProfileAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var mail_profile_attrib = origin_doc_base.getAttrib<MailProfileAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(mail_profile_attrib, () => $"mail_profile_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
mail_profile_attrib.SendMailUpdateDay = SendMailUpdateDay;
|
||||
mail_profile_attrib.LastSystemMailId = LastSystemMailId;
|
||||
mail_profile_attrib.SendMailCount = SendMailCount;
|
||||
|
||||
foreach (var mail in ReceivedSystemMails)
|
||||
{
|
||||
mail_profile_attrib.ReceivedSystemMails.TryAdd(mail.Key, mail.Value);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class MailProfileAttributeTransactor : EntityAttributeTransactorBase<MailProfileAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public MailProfileAttributeTransactor(UserBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(MailProfileAttribute).Name;
|
||||
|
||||
var copy_from_mail_profile_attribute = entityAttributeBase as MailProfileAttribute;
|
||||
if (null == copy_from_mail_profile_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_mail_profile_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_mail_attribute = getClonedEntityAttribute() as MailProfileAttribute;
|
||||
if (null == copy_to_mail_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_mail_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_mail_attribute.SendMailCount = copy_from_mail_profile_attribute.SendMailCount;
|
||||
copy_to_mail_attribute.SendMailUpdateDay = copy_from_mail_profile_attribute.SendMailUpdateDay;
|
||||
copy_to_mail_attribute.LastSystemMailId = copy_from_mail_profile_attribute.LastSystemMailId;
|
||||
|
||||
copy_to_mail_attribute.ReceivedSystemMails = new();
|
||||
foreach (var mail in copy_from_mail_profile_attribute.ReceivedSystemMails)
|
||||
{
|
||||
if (false == copy_to_mail_attribute.ReceivedSystemMails.TryAdd(mail.Key, mail.Value))
|
||||
{
|
||||
Log.getLogger().warn($"ReceivedSystemMails add return false key : {mail.Key}, value : {mail.Value}");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
244
ServerCommon/Entity/Attribute/MinimapMarkerAttribute.cs
Normal file
244
ServerCommon/Entity/Attribute/MinimapMarkerAttribute.cs
Normal file
@@ -0,0 +1,244 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerControlCenter;
|
||||
|
||||
|
||||
using META_ID = System.UInt32;
|
||||
using USER_GUID = System.String;
|
||||
using Amazon.S3.Model;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class MinimapMarkerAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public META_ID WorldMetaId { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public Vector3 MarkerPos { get; set; } = new();
|
||||
|
||||
public MinimapMarkerAttribute(EntityBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new MinimapMarkerAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
WorldMetaId = 0;
|
||||
MarkerPos = new();
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var entity_type = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(entity_type, () => "Entity Type is null");
|
||||
|
||||
var cloned = new MinimapMarkerAttribute(getOwner(), entity_type);
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.WorldMetaId = WorldMetaId;
|
||||
cloned.MarkerPos = MarkerPos;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
|
||||
var user_attribute = owner.getRootParent().getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
USER_GUID user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as MinimapMarkerDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new MinimapMarkerDoc(user_guid, WorldMetaId);
|
||||
|
||||
var origin_doc = getOriginDocBase<MinimapMarkerAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<MinimapMarkerAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
to_copy_doc_attrib.WorldMetaId = WorldMetaId;
|
||||
to_copy_doc_attrib.MarkerPos = MarkerPos;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(MinimapMarkerDoc).Name;
|
||||
|
||||
var minimap_marker_doc_base = docBase as MinimapMarkerDoc;
|
||||
if (null == minimap_marker_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, minimap_marker_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<MinimapMarkerAttribute>(minimap_marker_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = minimap_marker_doc_base.getAttrib<MinimapMarkerAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_attrib, () => "doc_attrib is null !!!");
|
||||
|
||||
WorldMetaId = doc_attrib.WorldMetaId;
|
||||
MarkerPos = doc_attrib.MarkerPos;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var minimap_marker_attribute = otherEntityAttribute as MinimapMarkerAttribute;
|
||||
if (null == minimap_marker_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast MinimapMarkerAttribute !!!, minimap_marker_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
WorldMetaId = minimap_marker_attribute.WorldMetaId;
|
||||
MarkerPos = minimap_marker_attribute.MarkerPos;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = minimap_marker_attribute.getTryPendingDocBase() as MinimapMarkerDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
minimap_marker_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<MinimapMarkerAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<MinimapMarkerAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var minimap_marker_attrib = origin_doc_base.getAttrib<MinimapMarkerAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(minimap_marker_attrib, () => $"minimap_marker_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
minimap_marker_attrib.WorldMetaId = WorldMetaId;
|
||||
minimap_marker_attrib.MarkerPos = MarkerPos;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class MinimapMarkerAttributeTransactor : EntityAttributeTransactorBase<MinimapMarkerAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public MinimapMarkerAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(MinimapMarkerAttribute).Name;
|
||||
|
||||
var copy_from_minimap_marker_attribute = entityAttributeBase as MinimapMarkerAttribute;
|
||||
if (null == copy_from_minimap_marker_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_from_minimap_marker_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_minimap_marker_attribute = getClonedEntityAttribute() as MinimapMarkerAttribute;
|
||||
if (null == copy_to_minimap_marker_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_to_minimap_marker_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_minimap_marker_attribute.WorldMetaId = copy_from_minimap_marker_attribute.WorldMetaId;
|
||||
copy_to_minimap_marker_attribute.MarkerPos = copy_from_minimap_marker_attribute.MarkerPos;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
432
ServerCommon/Entity/Attribute/MoneyAttribute.cs
Normal file
432
ServerCommon/Entity/Attribute/MoneyAttribute.cs
Normal file
@@ -0,0 +1,432 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
using Amazon.S3.Model;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public static class MoneyAttributeExtensions
|
||||
{
|
||||
public static double getCurrencyFromType(this MoneyAttribute attribute, CurrencyType type)
|
||||
{
|
||||
var currency = type switch
|
||||
{
|
||||
CurrencyType.Gold => attribute.Gold,
|
||||
CurrencyType.Sapphire => attribute.Sapphire,
|
||||
CurrencyType.Calium => attribute.Calium,
|
||||
CurrencyType.Ruby => attribute.Ruby,
|
||||
_ => 0
|
||||
};
|
||||
|
||||
return currency;
|
||||
}
|
||||
|
||||
public static void setCurrencyFromType(this MoneyAttribute attribute, CurrencyType type, double currency)
|
||||
{
|
||||
var result = type switch
|
||||
{
|
||||
CurrencyType.Gold => attribute.Gold = currency,
|
||||
CurrencyType.Sapphire => attribute.Sapphire = currency,
|
||||
CurrencyType.Calium => attribute.Calium = currency,
|
||||
CurrencyType.Ruby => attribute.Ruby = currency,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class MoneyAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute, IWithCommonResultFiller
|
||||
{
|
||||
[JsonProperty]
|
||||
public double Gold
|
||||
{
|
||||
get { return m_gold; }
|
||||
set
|
||||
{
|
||||
var recorder = getEntityRecorder();
|
||||
if (null != recorder)
|
||||
{
|
||||
recorder.applyDeltaCounter(EntityDeltaType.MoneyGold, value - m_gold, value);
|
||||
}
|
||||
m_gold = value;
|
||||
}
|
||||
}
|
||||
private double m_gold = 0;
|
||||
|
||||
|
||||
[JsonProperty]
|
||||
public double Sapphire
|
||||
{
|
||||
get { return m_sapphire; }
|
||||
set
|
||||
{
|
||||
var recorder = getEntityRecorder();
|
||||
if (null != recorder)
|
||||
{
|
||||
recorder.applyDeltaCounter(EntityDeltaType.MoneySaphire, value - m_sapphire, value);
|
||||
}
|
||||
m_sapphire = value;
|
||||
}
|
||||
}
|
||||
private double m_sapphire = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public double Calium
|
||||
{
|
||||
get { return m_calium; }
|
||||
set
|
||||
{
|
||||
var recorder = getEntityRecorder();
|
||||
if (null != recorder)
|
||||
{
|
||||
recorder.applyDeltaCounter(EntityDeltaType.MoneyCalium, value - m_calium, value);
|
||||
}
|
||||
m_calium = value;
|
||||
}
|
||||
}
|
||||
private double m_calium = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public double Ruby
|
||||
{
|
||||
get { return m_ruby; }
|
||||
set
|
||||
{
|
||||
var recorder = getEntityRecorder();
|
||||
if (null != recorder)
|
||||
{
|
||||
recorder.applyDeltaCounter(EntityDeltaType.MoneyRuby, value - m_ruby, value);
|
||||
}
|
||||
m_ruby = value;
|
||||
}
|
||||
}
|
||||
private double m_ruby = 0;
|
||||
|
||||
|
||||
//=========================================================================================
|
||||
// 기본 생성자
|
||||
//=========================================================================================
|
||||
public MoneyAttribute(UserBase owner)
|
||||
: base(owner, true)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
Gold = 0;
|
||||
Sapphire = 0;
|
||||
Calium = 0;
|
||||
Ruby = 0;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var cloned = new MoneyAttribute(owner);
|
||||
cloned.Gold = Gold;
|
||||
cloned.Sapphire = Sapphire;
|
||||
cloned.Calium = Calium;
|
||||
cloned.Ruby = Ruby;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new MoneyAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var user_attribute = owner.getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as MoneyDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new MoneyDoc(OwnerEntityType.User, user_guid);
|
||||
|
||||
var origin_doc = getOriginDocBase<MoneyAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_money_attrib = try_pending_doc.getAttrib<MoneyAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_money_attrib, () => $"to_copy_money_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
to_copy_money_attrib.Gold = Gold;
|
||||
to_copy_money_attrib.Sapphire = Sapphire;
|
||||
to_copy_money_attrib.Calium = Calium;
|
||||
to_copy_money_attrib.Ruby = Ruby;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public void onFillCommonResult(EntityCommonResult commonResult, EntityAttributeBase origin, QueryBatchBase? queryBatch = null)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var before = origin as MoneyAttribute;
|
||||
NullReferenceCheckHelper.throwIfNull(before, () => $"before is null !!! - {owner.toBasicString()}");
|
||||
var after = this as MoneyAttribute;
|
||||
NullReferenceCheckHelper.throwIfNull(after, () => $"after is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var recorder = after.getEntityRecorder();
|
||||
NullReferenceCheckHelper.throwIfNull(recorder, () => $"recorder is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var money_result = commonResult.Money;
|
||||
NullReferenceCheckHelper.throwIfNull(money_result, () => $"money_result is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var target_types = EnumHelper.getValuesBeginEndBetweenWord<EntityDeltaType>("Money_");
|
||||
foreach (var type in target_types)
|
||||
{
|
||||
var currency_type = type.toCurrencyType();
|
||||
if (CurrencyType.None == currency_type)
|
||||
{
|
||||
var err_msg = $"Failed to toCurrencyType() !!! : EntityDeltaType:{type} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
continue;
|
||||
}
|
||||
|
||||
var found_delta_counter = recorder.findDeltaCounter(type);
|
||||
if (null != found_delta_counter)
|
||||
{
|
||||
var currency_type_key = (Int32)currency_type;
|
||||
var delta_count = found_delta_counter.getDeltaCount();
|
||||
|
||||
if (false == money_result.Moneys.TryGetValue(currency_type_key, out var found_money))
|
||||
{
|
||||
found_money = new Money();
|
||||
money_result.Moneys[currency_type_key] = found_money;
|
||||
}
|
||||
found_money.Amount = found_delta_counter.getTotalCount();
|
||||
|
||||
if (false == money_result.Deltas.TryGetValue(currency_type_key, out var found_money_delta_amount))
|
||||
{
|
||||
found_money_delta_amount = new MoneyDeltaAmount();
|
||||
money_result.Deltas[currency_type_key] = found_money_delta_amount;
|
||||
}
|
||||
found_money_delta_amount.DeltaType = AmountDeltaType.Merge;
|
||||
found_money_delta_amount.Amount = delta_count;
|
||||
|
||||
appendOrWriteBusinessLog4Money(currency_type, delta_count, found_money.Amount, queryBatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void appendOrWriteBusinessLog4Money( CurrencyType currencyType, double deltaCount, double amount
|
||||
, QueryBatchBase? queryBatch = null )
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var delta_type = AmountDeltaType.None;
|
||||
if (deltaCount > 0)
|
||||
{
|
||||
delta_type = AmountDeltaType.Acquire;
|
||||
}
|
||||
else if (deltaCount < 0)
|
||||
{
|
||||
delta_type = AmountDeltaType.Consume;
|
||||
}
|
||||
|
||||
var currency_delta_log = new CurrencyDeltaUpdateBusinessLog( currencyType
|
||||
, delta_type, deltaCount, amount );
|
||||
if (null != queryBatch)
|
||||
{
|
||||
queryBatch.appendBusinessLog(currency_delta_log);
|
||||
}
|
||||
else
|
||||
{
|
||||
var log_actor = owner as IWithLogActor;
|
||||
NullReferenceCheckHelper.throwIfNull(log_actor, () => $"log_actor is null !!! - {owner.toBasicString()}");
|
||||
|
||||
BusinessLogger.collectLog(log_actor, currency_delta_log);
|
||||
}
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var money_attribute = otherEntityAttribute as MoneyAttribute;
|
||||
if (null == money_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast MoneyAttribute !!!, money_attribute is null - {toBasicString()}, {owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Gold = money_attribute.Gold;
|
||||
Sapphire = money_attribute.Sapphire;
|
||||
Calium = money_attribute.Calium;
|
||||
Ruby = money_attribute.Ruby;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = money_attribute.getTryPendingDocBase() as MoneyDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
money_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<MoneyAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<MoneyAttribute>() as MoneyDoc;
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var money_attrib = origin_doc_base.getAttrib<MoneyAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(money_attrib, () => $"money_attrib is null !!! - {toBasicString()}, {owner.toBasicString()}");
|
||||
|
||||
money_attrib.Gold = Gold;
|
||||
money_attrib.Sapphire = Sapphire;
|
||||
money_attrib.Calium = Calium;
|
||||
money_attrib.Ruby = Ruby;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase newDocBase)
|
||||
{
|
||||
var owner = getOwner();
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(ItemDoc).Name;
|
||||
|
||||
var money_doc = newDocBase as MoneyDoc;
|
||||
if (null == money_doc)
|
||||
{
|
||||
err_msg = $"money_doc is null !!!, in copyEntityAttributeFromDoc() : docName:{nameof(MoneyDoc)} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<MoneyAttribute>(money_doc);
|
||||
|
||||
//=====================================================================================
|
||||
// Origin Doc => Attribute
|
||||
//=====================================================================================
|
||||
var money_attrib = money_doc.getAttrib<MoneyAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(money_attrib, () => $"money_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
Gold = money_attrib.Gold;
|
||||
Sapphire = money_attrib.Sapphire;
|
||||
Calium = money_attrib.Calium;
|
||||
Ruby = money_attrib.Ruby;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class MoneyAttributeTransactor : EntityAttributeTransactorBase<MoneyAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public MoneyAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(MoneyAttribute).Name;
|
||||
|
||||
var copy_from_money_attribute = entityAttributeBase as MoneyAttribute;
|
||||
if (null == copy_from_money_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_money_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_money_attribute = getClonedEntityAttribute() as MoneyAttribute;
|
||||
if (null == copy_to_money_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_money_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_money_attribute.Gold = copy_to_money_attribute.Gold;
|
||||
copy_to_money_attribute.Sapphire = copy_to_money_attribute.Sapphire;
|
||||
copy_to_money_attribute.Calium = copy_to_money_attribute.Calium;
|
||||
copy_to_money_attribute.Ruby = copy_to_money_attribute.Ruby;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
284
ServerCommon/Entity/Attribute/MyHomeAttribute.cs
Normal file
284
ServerCommon/Entity/Attribute/MyHomeAttribute.cs
Normal file
@@ -0,0 +1,284 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerControlCenter;
|
||||
|
||||
|
||||
using META_ID = System.UInt32;
|
||||
using USER_GUID = System.String;
|
||||
using Amazon.S3.Model;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class MyhomeAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public string MyhomeGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public META_ID MyhomeMetaId { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public string MyhomeName { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public UInt16 SelectedFlag { get; set; } = 0;
|
||||
|
||||
|
||||
public string MyhomeUgcInfoS3FileName { get; set; } = string.Empty;
|
||||
|
||||
public MyhomeUgcInfo UgcInfo { get; set; } = new();
|
||||
|
||||
public MyhomeAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void newEntityAttribute()
|
||||
{
|
||||
MyhomeGuid = System.Guid.NewGuid().ToString("N");
|
||||
base.newEntityAttribute();
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new MyhomeAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
|
||||
MyhomeGuid = string.Empty;
|
||||
MyhomeMetaId = 0;
|
||||
MyhomeName = string.Empty;
|
||||
SelectedFlag = 0;
|
||||
MyhomeUgcInfoS3FileName = string.Empty;
|
||||
UgcInfo = new();
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new MyhomeAttribute(getOwner());
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.MyhomeGuid = MyhomeGuid;
|
||||
cloned.MyhomeMetaId = MyhomeMetaId;
|
||||
cloned.MyhomeName = MyhomeName;
|
||||
cloned.SelectedFlag = SelectedFlag;
|
||||
cloned.MyhomeUgcInfoS3FileName = MyhomeUgcInfoS3FileName;
|
||||
cloned.UgcInfo = UgcInfo.Clone();
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(owner);
|
||||
|
||||
var user_attribute = owner.onGetMasterEntity()!.getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
USER_GUID user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as MyhomeDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new MyhomeDoc(user_guid, MyhomeGuid);
|
||||
|
||||
var origin_doc = getOriginDocBase<MyhomeAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<MyHomeAttrib>();
|
||||
ArgumentNullException.ThrowIfNull(to_copy_doc_attrib);
|
||||
|
||||
to_copy_doc_attrib.MyhomeGuid = MyhomeGuid;
|
||||
to_copy_doc_attrib.MyHomeMetaId = MyhomeMetaId;
|
||||
to_copy_doc_attrib.MyhomeName = MyhomeName;
|
||||
to_copy_doc_attrib.SelectedFlag = SelectedFlag;
|
||||
to_copy_doc_attrib.MyhomeUgcInfoS3FileName = MyhomeUgcInfoS3FileName;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(MyhomeDoc).Name;
|
||||
|
||||
var myhome_doc_base = docBase as MyhomeDoc;
|
||||
if (null == myhome_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, myhome_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<MyhomeAttribute>(myhome_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = myhome_doc_base.getAttrib<MyHomeAttrib>();
|
||||
ArgumentNullException.ThrowIfNull(doc_attrib);
|
||||
|
||||
MyhomeGuid = doc_attrib.MyhomeGuid;
|
||||
MyhomeMetaId = doc_attrib.MyHomeMetaId;
|
||||
MyhomeName = doc_attrib.MyhomeName;
|
||||
SelectedFlag = doc_attrib.SelectedFlag;
|
||||
MyhomeUgcInfoS3FileName = doc_attrib.MyhomeUgcInfoS3FileName;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var myhome_attribute = otherEntityAttribute as MyhomeAttribute;
|
||||
if (null == myhome_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast MyHomeAttribute !!!, myhome_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
MyhomeGuid = myhome_attribute.MyhomeGuid;
|
||||
MyhomeMetaId = myhome_attribute.MyhomeMetaId;
|
||||
MyhomeName = myhome_attribute.MyhomeName;
|
||||
SelectedFlag = myhome_attribute.SelectedFlag;
|
||||
MyhomeUgcInfoS3FileName = myhome_attribute.MyhomeUgcInfoS3FileName;
|
||||
UgcInfo = myhome_attribute.UgcInfo.Clone();
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = myhome_attribute.getTryPendingDocBase() as MyhomeDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
myhome_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<MyhomeAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<MyhomeAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var my_home_attrib = origin_doc_base.getAttrib<MyHomeAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(my_home_attrib, () => $"my_home_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
my_home_attrib.MyhomeGuid = MyhomeGuid;
|
||||
my_home_attrib.MyHomeMetaId = MyhomeMetaId;
|
||||
my_home_attrib.MyhomeName = MyhomeName;
|
||||
my_home_attrib.SelectedFlag = SelectedFlag;
|
||||
my_home_attrib.MyhomeUgcInfoS3FileName = MyhomeUgcInfoS3FileName;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class MyhomeAttributeTransactor : EntityAttributeTransactorBase<MyhomeAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public MyhomeAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(MyhomeAttribute).Name;
|
||||
|
||||
var copy_from_myhome_attribute = entityAttributeBase as MyhomeAttribute;
|
||||
if (null == copy_from_myhome_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_from_myhome_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_myhome_attribute = getClonedEntityAttribute() as MyhomeAttribute;
|
||||
if (null == copy_to_myhome_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_to_myhome_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_myhome_attribute.MyhomeGuid = copy_from_myhome_attribute.MyhomeGuid;
|
||||
copy_to_myhome_attribute.MyhomeMetaId = copy_from_myhome_attribute.MyhomeMetaId;
|
||||
copy_to_myhome_attribute.MyhomeName = copy_from_myhome_attribute.MyhomeName;
|
||||
copy_to_myhome_attribute.SelectedFlag = copy_from_myhome_attribute.SelectedFlag;
|
||||
copy_to_myhome_attribute.MyhomeUgcInfoS3FileName = copy_from_myhome_attribute.MyhomeUgcInfoS3FileName;
|
||||
copy_to_myhome_attribute.UgcInfo = copy_from_myhome_attribute.UgcInfo.Clone();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
78
ServerCommon/Entity/Attribute/MyhomeItemAttribute.cs
Normal file
78
ServerCommon/Entity/Attribute/MyhomeItemAttribute.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class MyhomeItemAttribute : ItemAttributeBase
|
||||
{
|
||||
public MyhomeItemAttribute(ItemBase owner, EntityBase ownerEntity)
|
||||
: base(owner, ownerEntity)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
var owner = getOwner() as ItemBase;
|
||||
ArgumentNullException.ThrowIfNull(owner, $"owner is null !!!");
|
||||
|
||||
return new MyhomeItemAttributeTransactor(owner);
|
||||
}
|
||||
|
||||
public override ItemDoc onCreateDocBase()
|
||||
{
|
||||
var owner = getOwner();
|
||||
ArgumentNullException.ThrowIfNull(owner, $"owner is null !!!");
|
||||
var direct_parent = owner.getDirectParent();
|
||||
ArgumentNullException.ThrowIfNull(direct_parent, $"direct_parent is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var root_parent = owner.getRootParent();
|
||||
ArgumentNullException.ThrowIfNull(root_parent, $"root_parent is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var myhome_attribute = direct_parent.getEntityAttribute<MyhomeAttribute>();
|
||||
ArgumentNullException.ThrowIfNull(myhome_attribute, $"myhome_attribute is null !!! - {direct_parent.toBasicString()}, {root_parent?.toBasicString()}");
|
||||
|
||||
var myhome_guid = myhome_attribute.MyhomeGuid;
|
||||
|
||||
return new ItemDoc(OwnerEntityType.Myhome, myhome_guid, ItemGuid);
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner() as ItemBase;
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var direct_parent = owner.getDirectParent();
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(direct_parent, () => $"direct_parent is null !!!");
|
||||
var owner_entity = getEntityOfOwnerEntityType();
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(owner_entity, () => $"owner_entity is null !!!");
|
||||
|
||||
var cloned = new MyhomeItemAttribute(owner, owner_entity);
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.ItemGuid = ItemGuid;
|
||||
cloned.ItemMetaId = ItemMetaId;
|
||||
cloned.ItemStackCount = ItemStackCount;
|
||||
cloned.Level = Level;
|
||||
cloned.Attributes = Attributes.Select(x => x).ToList();
|
||||
cloned.EquipedIvenType = EquipedIvenType;
|
||||
cloned.EquipedPos = EquipedPos;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
}
|
||||
|
||||
public class MyhomeItemAttributeTransactor : ItemAttributeBaseTransactor<MyhomeItemAttribute>
|
||||
{
|
||||
public MyhomeItemAttributeTransactor(ItemBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
238
ServerCommon/Entity/Attribute/NicknameAttribute.cs
Normal file
238
ServerCommon/Entity/Attribute/NicknameAttribute.cs
Normal file
@@ -0,0 +1,238 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class NicknameAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public string Nickname { get; set; } = string.Empty;
|
||||
|
||||
|
||||
public NicknameAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
Nickname = string.Empty;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner();
|
||||
ArgumentNullException.ThrowIfNull(owner);
|
||||
|
||||
var cloned = new NicknameAttribute(owner);
|
||||
cloned.Nickname = Nickname;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
var owner = getOwner();
|
||||
ArgumentNullException.ThrowIfNull(owner);
|
||||
|
||||
return new NicknameAttributeTransactor(owner);
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null");
|
||||
var user_attribute = owner.getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => "user_attribute is null");
|
||||
|
||||
USER_GUID user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as NicknameDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new NicknameDoc(OwnerEntityType.User, user_guid, string.Empty);
|
||||
var origin_doc = getOriginDocBase<NicknameAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<NicknameAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!!");
|
||||
|
||||
to_copy_doc_attrib.Nickname = Nickname;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var nickname_attribute = otherEntityAttribute as NicknameAttribute;
|
||||
if (null == nickname_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast NicknameAttribute !!!, nickname_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Nickname = nickname_attribute.Nickname;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = nickname_attribute.getTryPendingDocBase() as NicknameDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
nickname_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<NicknameAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<NicknameAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var nickname_attrib = origin_doc_base.getAttrib<NicknameAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(nickname_attrib, () => $"nickname_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
nickname_attrib.Nickname = Nickname;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(NicknameDoc).Name;
|
||||
|
||||
var nickame_doc_base = docBase as NicknameDoc;
|
||||
if (null == nickame_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, nickame_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<NicknameAttribute>(nickame_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var nickname_attrib = nickame_doc_base.getAttrib<NicknameAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(nickname_attrib, () => $"nickname_attrib is null !!!");
|
||||
|
||||
Nickname = nickname_attrib.Nickname;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class NicknameAttributeTransactor : EntityAttributeTransactorBase<NicknameAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public NicknameAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(NicknameAttribute).Name;
|
||||
|
||||
var copy_from_nickname_attribute = entityAttributeBase as NicknameAttribute;
|
||||
if (null == copy_from_nickname_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_nickname_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_nickname_attribute = getClonedEntityAttribute() as NicknameAttribute;
|
||||
if (null == copy_to_nickname_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_nickname_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_nickname_attribute.Nickname = copy_from_nickname_attribute.Nickname;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
277
ServerCommon/Entity/Attribute/NoticeChatAttribute.cs
Normal file
277
ServerCommon/Entity/Attribute/NoticeChatAttribute.cs
Normal file
@@ -0,0 +1,277 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class NoticeChatAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public Int32 ChatId { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public DateTime NextNoticeTime { get; set; } = new();
|
||||
|
||||
[JsonProperty]
|
||||
public Int32 RepeatMinuteTime { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public Int32 RepeatCount { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public string Sender { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public Int32 MessageType { get; set; } = 0;
|
||||
|
||||
|
||||
public List<NoticeChatDetail> DetailList { get; set; } = new();
|
||||
|
||||
public NoticeChatAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
ChatId = 0;
|
||||
NextNoticeTime = new();
|
||||
RepeatMinuteTime = 0;
|
||||
RepeatCount = 0;
|
||||
Sender = string.Empty;
|
||||
MessageType = 0;
|
||||
DetailList = new List<NoticeChatDetail>();
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new NoticeChatAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new NoticeChatAttribute(getOwner());
|
||||
cloned.ChatId = ChatId;
|
||||
cloned.NextNoticeTime = NextNoticeTime;
|
||||
cloned.RepeatMinuteTime = RepeatMinuteTime;
|
||||
cloned.RepeatCount = RepeatCount;
|
||||
cloned.Sender = Sender;
|
||||
cloned.MessageType = MessageType;
|
||||
cloned.DetailList = DetailList.Select(x => new NoticeChatDetail() { ChatMessage = x.ChatMessage, Languagetype = x.Languagetype }).ToList();
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as NoticeChatDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new NoticeChatDoc(ChatId.ToString());
|
||||
var origin_doc = getOriginDocBase<NoticeChatAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<NoticeChatAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib NoticeChatAttrib is null !!!");
|
||||
|
||||
to_copy_doc_attrib.ChatId = ChatId;
|
||||
to_copy_doc_attrib.NextNoticeTime = NextNoticeTime;
|
||||
to_copy_doc_attrib.RepeatMinuteTime = RepeatMinuteTime;
|
||||
to_copy_doc_attrib.RepeatCount = RepeatCount;
|
||||
to_copy_doc_attrib.Sender = Sender;
|
||||
to_copy_doc_attrib.MessageType = MessageType;
|
||||
to_copy_doc_attrib.DetailList = DetailList.Select(x => new NoticeChatDetail() { ChatMessage = x.ChatMessage, Languagetype = x.Languagetype }).ToList();
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(NoticeChatDoc).Name;
|
||||
|
||||
var notice_chat_doc_base = docBase as NoticeChatDoc;
|
||||
if (null == notice_chat_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, notice_chat_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<NoticeChatAttribute>(notice_chat_doc_base);
|
||||
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
|
||||
var noticechat_attrib = notice_chat_doc_base.getAttrib<NoticeChatAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(noticechat_attrib, () => $"noticechat_attrib is null !!!");
|
||||
|
||||
|
||||
ChatId = noticechat_attrib.ChatId;
|
||||
NextNoticeTime = noticechat_attrib.NextNoticeTime;
|
||||
RepeatMinuteTime = noticechat_attrib.RepeatMinuteTime;
|
||||
RepeatCount = noticechat_attrib.RepeatCount;
|
||||
Sender = noticechat_attrib.Sender;
|
||||
MessageType = noticechat_attrib.MessageType;
|
||||
DetailList = noticechat_attrib.DetailList.Select(x => new NoticeChatDetail() { ChatMessage = x.ChatMessage, Languagetype = x.Languagetype }).ToList();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var notice_chat_attribute = otherEntityAttribute as NoticeChatAttribute;
|
||||
if (null == notice_chat_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast NoticeChatAttribute !!!, notice_chat_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ChatId = notice_chat_attribute.ChatId;
|
||||
NextNoticeTime = notice_chat_attribute.NextNoticeTime;
|
||||
RepeatMinuteTime = notice_chat_attribute.RepeatMinuteTime;
|
||||
RepeatCount = notice_chat_attribute.RepeatCount;
|
||||
Sender = notice_chat_attribute.Sender;
|
||||
MessageType = notice_chat_attribute.MessageType;
|
||||
DetailList = notice_chat_attribute.DetailList.Select(x => new NoticeChatDetail() { ChatMessage = x.ChatMessage, Languagetype = x.Languagetype }).ToList();
|
||||
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = notice_chat_attribute.getTryPendingDocBase() as NoticeChatDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
notice_chat_attribute.resetTryPendingDocBase();
|
||||
syncOriginDocBaseWithNewDoc<NoticeChatAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var origin_doc_base = getOriginDocBase<NoticeChatAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var notice_chat_attrib = origin_doc_base.getAttrib<NoticeChatAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(notice_chat_attrib, () => $"notice_chat_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
notice_chat_attrib.ChatId = ChatId;
|
||||
notice_chat_attrib.NextNoticeTime = NextNoticeTime;
|
||||
notice_chat_attrib.RepeatMinuteTime = RepeatMinuteTime;
|
||||
notice_chat_attrib.RepeatCount = RepeatCount;
|
||||
notice_chat_attrib.Sender = Sender;
|
||||
notice_chat_attrib.MessageType = MessageType;
|
||||
notice_chat_attrib.DetailList = DetailList.Select(x => new NoticeChatDetail() { ChatMessage = x.ChatMessage, Languagetype = x.Languagetype }).ToList();
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class NoticeChatAttributeTransactor : EntityAttributeTransactorBase<NoticeChatAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public NoticeChatAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(NoticeChatAttribute).Name;
|
||||
|
||||
var copy_from_notice_chat_attribute = entityAttributeBase as NoticeChatAttribute;
|
||||
if (null == copy_from_notice_chat_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_notice_chat_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_notice_chat_attribute = getClonedEntityAttribute() as NoticeChatAttribute;
|
||||
if (null == copy_to_notice_chat_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_notice_chat_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_notice_chat_attribute.ChatId = copy_from_notice_chat_attribute.ChatId;
|
||||
copy_to_notice_chat_attribute.NextNoticeTime = copy_from_notice_chat_attribute.NextNoticeTime;
|
||||
copy_to_notice_chat_attribute.RepeatMinuteTime = copy_from_notice_chat_attribute.RepeatMinuteTime;
|
||||
copy_to_notice_chat_attribute.RepeatCount = copy_from_notice_chat_attribute.RepeatCount;
|
||||
copy_to_notice_chat_attribute.Sender = copy_from_notice_chat_attribute.Sender;
|
||||
copy_to_notice_chat_attribute.MessageType = copy_from_notice_chat_attribute.MessageType;
|
||||
copy_to_notice_chat_attribute.DetailList = copy_from_notice_chat_attribute.DetailList.Select(x => new NoticeChatDetail() { ChatMessage = x.ChatMessage, Languagetype = x.Languagetype }).ToList();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
240
ServerCommon/Entity/Attribute/OwnedBuildingAttribute.cs
Normal file
240
ServerCommon/Entity/Attribute/OwnedBuildingAttribute.cs
Normal file
@@ -0,0 +1,240 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using META_ID = System.UInt32;
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class OwnedBuildingAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public META_ID BuildingMetaId { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public OwnedType OwnedType { get; set; } = OwnedType.None;
|
||||
|
||||
|
||||
public OwnedBuildingAttribute(EntityBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new OwnedBuildingAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
BuildingMetaId = 0;
|
||||
OwnedType = OwnedType.None;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var owner_entity = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(owner_entity, () => $"owner_entity is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var cloned = new OwnedBuildingAttribute(owner, owner_entity);
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.BuildingMetaId = BuildingMetaId;
|
||||
cloned.OwnedType = OwnedType;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null");
|
||||
|
||||
var user_attribute = owner.getRootParent().getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => "user_attribute is null");
|
||||
|
||||
USER_GUID user_guid = user_attribute.UserGuid;
|
||||
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as OwnedBuildingDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new OwnedBuildingDoc(user_guid, BuildingMetaId);
|
||||
var origin_doc = getOriginDocBase<OwnedBuildingAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<OwnedBuildingAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!!");
|
||||
to_copy_doc_attrib.BuildingMetaId = BuildingMetaId;
|
||||
to_copy_doc_attrib.OwnedType = OwnedType;
|
||||
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(OwnedBuildingDoc).Name;
|
||||
|
||||
var owned_building_doc_base = docBase as OwnedBuildingDoc;
|
||||
if (null == owned_building_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, owned_building_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<OwnedBuildingAttribute>(owned_building_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = owned_building_doc_base.getAttrib<OwnedBuildingAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_attrib, () => $"OwnedBuildingAttrib doc_attrib is null !!!");
|
||||
|
||||
BuildingMetaId = doc_attrib.BuildingMetaId;
|
||||
OwnedType = doc_attrib.OwnedType;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var owned_building_attribute = otherEntityAttribute as OwnedBuildingAttribute;
|
||||
if (null == owned_building_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast OwnedBuildingAttribute !!!, owned_building_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
BuildingMetaId = owned_building_attribute.BuildingMetaId;
|
||||
OwnedType = owned_building_attribute.OwnedType;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = owned_building_attribute.getTryPendingDocBase() as OwnedBuildingDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
owned_building_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<OwnedBuildingAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<OwnedBuildingAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var owned_building_attrib = origin_doc_base.getAttrib<OwnedBuildingAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(owned_building_attrib, () => $"owned_building_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
|
||||
owned_building_attrib.BuildingMetaId = BuildingMetaId;
|
||||
owned_building_attrib.OwnedType = OwnedType;
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class OwnedBuildingAttributeTransactor : EntityAttributeTransactorBase<OwnedBuildingAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public OwnedBuildingAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(OwnedBuildingAttribute).Name;
|
||||
|
||||
var copy_from_owned_building_attribute = entityAttributeBase as OwnedBuildingAttribute;
|
||||
if (null == copy_from_owned_building_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_from_owned_building_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_owned_building_attribute = getClonedEntityAttribute() as OwnedBuildingAttribute;
|
||||
if (null == copy_to_owned_building_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_to_owned_building_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_owned_building_attribute.BuildingMetaId = copy_from_owned_building_attribute.BuildingMetaId;
|
||||
copy_to_owned_building_attribute.OwnedType = copy_from_owned_building_attribute.OwnedType;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
232
ServerCommon/Entity/Attribute/OwnedLandAttribute.cs
Normal file
232
ServerCommon/Entity/Attribute/OwnedLandAttribute.cs
Normal file
@@ -0,0 +1,232 @@
|
||||
using Newtonsoft.Json;
|
||||
using ServerCore; using ServerBase;
|
||||
using META_ID = System.UInt32;
|
||||
using USER_GUID = System.String;
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class OwnedLandAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public META_ID LandMetaId { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public OwnedType OwnedType { get; set; } = OwnedType.None;
|
||||
|
||||
|
||||
public OwnedLandAttribute(EntityBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new OwnedLandAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
LandMetaId = 0;
|
||||
OwnedType = OwnedType.None;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var owner_entity = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(owner_entity, () => $"owner_entity is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var cloned = new OwnedLandAttribute(owner, owner_entity);
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.LandMetaId = LandMetaId;
|
||||
cloned.OwnedType = OwnedType;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null");
|
||||
|
||||
var user_attribute = owner.getRootParent().getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => "owner is null");
|
||||
USER_GUID user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as OwnedLandDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new OwnedLandDoc(user_guid, LandMetaId);
|
||||
var origin_doc = getOriginDocBase<OwnedLandAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<OwnedLandAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!!");
|
||||
|
||||
|
||||
to_copy_doc_attrib.LandMetaId = LandMetaId;
|
||||
to_copy_doc_attrib.OwnedType = OwnedType;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(OwnedLandDoc).Name;
|
||||
|
||||
var owned_land_doc_base = docBase as OwnedLandDoc;
|
||||
if (null == owned_land_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, owned_land_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<OwnedLandAttribute>(owned_land_doc_base);
|
||||
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
|
||||
var owned_land_attrib = owned_land_doc_base.getAttrib<OwnedLandAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(owned_land_attrib, () => $"owned_land_attrib is null !!!");
|
||||
|
||||
LandMetaId = owned_land_attrib.LandMetaId;
|
||||
OwnedType = owned_land_attrib.OwnedType;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var owned_land_attribute = otherEntityAttribute as OwnedLandAttribute;
|
||||
if (null == owned_land_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast OwnedLandAttribute !!!, owned_land_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
LandMetaId = owned_land_attribute.LandMetaId;
|
||||
OwnedType = owned_land_attribute.OwnedType;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = owned_land_attribute.getTryPendingDocBase() as OwnedLandDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
owned_land_attribute.resetTryPendingDocBase();
|
||||
syncOriginDocBaseWithNewDoc<OwnedLandAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var origin_doc_base = getOriginDocBase<OwnedLandAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var owned_land_attrib = origin_doc_base.getAttrib<OwnedLandAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(owned_land_attrib, () => $"owned_land_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
owned_land_attrib.LandMetaId = LandMetaId;
|
||||
owned_land_attrib.OwnedType = OwnedType;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class OwnedLandAttributeTransactor : EntityAttributeTransactorBase<OwnedLandAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public OwnedLandAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(OwnedLandAttribute).Name;
|
||||
|
||||
var copy_from_owned_land_attribute = entityAttributeBase as OwnedLandAttribute;
|
||||
if (null == copy_from_owned_land_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_from_owned_land_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_owned_land_attribute = getClonedEntityAttribute() as OwnedLandAttribute;
|
||||
if (null == copy_to_owned_land_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_to_owned_land_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_owned_land_attribute.LandMetaId = copy_from_owned_land_attribute.LandMetaId;
|
||||
copy_to_owned_land_attribute.OwnedType = copy_from_owned_land_attribute.OwnedType;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
234
ServerCommon/Entity/Attribute/PackageLastOrderRecodeAttribute.cs
Normal file
234
ServerCommon/Entity/Attribute/PackageLastOrderRecodeAttribute.cs
Normal file
@@ -0,0 +1,234 @@
|
||||
using Newtonsoft.Json;
|
||||
using ServerCore; using ServerBase;
|
||||
using USER_GUID = System.String;
|
||||
using META_ID = System.UInt32;
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class PackageLastOrderRecodeAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public string LastOrderGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public DateTime LastBuyTime { get; set; } = new();
|
||||
|
||||
public PackageLastOrderRecodeAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
LastOrderGuid = string.Empty;
|
||||
LastBuyTime = new();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new PackageLastOrderRecodeAttribute(getOwner());
|
||||
cloned.LastOrderGuid = LastOrderGuid;
|
||||
cloned.LastBuyTime = LastBuyTime;
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new PackageLastOrderRecodeAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null");
|
||||
|
||||
var root_parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(root_parent, () => "root_parent is null");
|
||||
|
||||
var acoount_attribute = owner.getRootParent().getEntityAttribute<AccountAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(acoount_attribute, () => "acoount_attribute is null");
|
||||
|
||||
USER_GUID user_guid = acoount_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as PackageLastOrderRecodeDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new PackageLastOrderRecodeDoc(user_guid);
|
||||
var origin_doc = getOriginDocBase<PackageLastOrderRecodeAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var package_lastorder_recode_attrib = try_pending_doc.getAttrib<PackageLastOrderRecodeAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(package_lastorder_recode_attrib, () => $"package_lastorder_recode_attrib is null !!!");
|
||||
|
||||
|
||||
package_lastorder_recode_attrib.LastOrderGuid = LastOrderGuid;
|
||||
package_lastorder_recode_attrib.LastBuyTime = LastBuyTime;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(PackageLastOrderRecodeDoc).Name;
|
||||
|
||||
var package_doc_base = docBase as PackageLastOrderRecodeDoc;
|
||||
if (null == package_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, package_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<PackageLastOrderRecodeAttribute>(package_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Doc, Attribute
|
||||
//=====================================================================================
|
||||
var package_attrib = package_doc_base.getAttrib<PackageLastOrderRecodeAttrib>();
|
||||
//NullReferenceCheckHelper.throwIfNull(package_attrib, () => $"building_attrib is null !!!");
|
||||
//var doc_attrib = package_doc_base.getAttrib<PackageLastOrderRecodeAttrib>();
|
||||
|
||||
if (package_attrib == null)
|
||||
{
|
||||
err_msg = $"Failed to get package attrib : {nameof(PackageLastOrderRecodeAttrib)}";
|
||||
result.setFail(ServerErrorCode.EntityAttributeIsNull, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
LastOrderGuid = package_attrib.LastOrderGuid;
|
||||
LastBuyTime = package_attrib.LastBuyTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var package_lastorder_recode_attribute = otherEntityAttribute as PackageLastOrderRecodeAttribute;
|
||||
if (null == package_lastorder_recode_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast Attribute !!!, package_last_order_recode_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
LastOrderGuid = package_lastorder_recode_attribute.LastOrderGuid;
|
||||
LastBuyTime = package_lastorder_recode_attribute.LastBuyTime;
|
||||
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = package_lastorder_recode_attribute.getTryPendingDocBase() as PackageLastOrderRecodeDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
package_lastorder_recode_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<PackageLastOrderRecodeAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<PackageLastOrderRecodeAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var package_lastorder_recode_attrib = origin_doc_base.getAttrib<PackageLastOrderRecodeAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(package_lastorder_recode_attrib, () => $"package_lastorder_recode_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
package_lastorder_recode_attrib.LastOrderGuid = LastOrderGuid;
|
||||
package_lastorder_recode_attrib.LastBuyTime = LastBuyTime;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public class PackageLastOrderRecodeAttributeTransactor : EntityAttributeTransactorBase<PackageLastOrderRecodeAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public PackageLastOrderRecodeAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(PackageLastOrderRecodeAttribute).Name;
|
||||
|
||||
var copy_from_attribute = entityAttributeBase as PackageLastOrderRecodeAttribute;
|
||||
if (null == copy_from_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_package_last_order_recode_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_attribute = getClonedEntityAttribute() as PackageLastOrderRecodeAttribute;
|
||||
if (null == copy_to_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_package_last_order_recode_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_attribute.LastOrderGuid = copy_from_attribute.LastOrderGuid;
|
||||
copy_to_attribute.LastBuyTime = copy_from_attribute.LastBuyTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
245
ServerCommon/Entity/Attribute/PackageRepeatAttribute.cs
Normal file
245
ServerCommon/Entity/Attribute/PackageRepeatAttribute.cs
Normal file
@@ -0,0 +1,245 @@
|
||||
using Newtonsoft.Json;
|
||||
using ServerCore; using ServerBase;
|
||||
using USER_GUID = System.String;
|
||||
using META_ID = System.UInt32;
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class PackageRepeatAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public string OrderGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public META_ID ProductMetaId { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public int LeftCount { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public DateTime NextGiveTime { get; set; } = new();
|
||||
|
||||
public PackageRepeatAttribute(EntityBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
OrderGuid = string.Empty;
|
||||
ProductMetaId = 0;
|
||||
LeftCount = 0;
|
||||
NextGiveTime = new();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner_entity = getEntityOfOwnerEntityType();
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(owner_entity, () => $"owner_entity is null !!!");
|
||||
var cloned = new PackageRepeatAttribute(getOwner(), owner_entity);
|
||||
cloned.OrderGuid = OrderGuid;
|
||||
cloned.ProductMetaId = ProductMetaId;
|
||||
cloned.LeftCount = LeftCount;
|
||||
cloned.NextGiveTime = NextGiveTime;
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new PackageRepeatAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var acoount_attribute = getOwner().getRootParent().getEntityAttribute<AccountAttribute>();
|
||||
ArgumentNullException.ThrowIfNull(acoount_attribute);
|
||||
|
||||
USER_GUID user_guid = acoount_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as PackageRepeatDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new PackageRepeatDoc(user_guid, OrderGuid);
|
||||
var origin_doc = getOriginDocBase<PackageRepeatAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var package_repeat_attrib = try_pending_doc.getAttrib<PackageRepeatAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(package_repeat_attrib, () => $"package_repeat_attrib is null !!!");
|
||||
|
||||
package_repeat_attrib.OrderGuid = OrderGuid;
|
||||
package_repeat_attrib.ProductMetaId = ProductMetaId;
|
||||
package_repeat_attrib.LeftCount = LeftCount;
|
||||
package_repeat_attrib.NextGiveTime = NextGiveTime;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(PackageRepeatDoc).Name;
|
||||
|
||||
var package_doc_base = docBase as PackageRepeatDoc;
|
||||
if (null == package_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, package_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<PackageRepeatAttribute>(package_doc_base);
|
||||
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var packate_repeat_attrib = package_doc_base.getAttrib<PackageRepeatAttrib>();
|
||||
if (packate_repeat_attrib == null)
|
||||
{
|
||||
err_msg = $"Failed to get package attrib : {nameof(PackageRepeatAttrib)}";
|
||||
result.setFail(ServerErrorCode.EntityAttributeIsNull, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
OrderGuid = packate_repeat_attrib.OrderGuid;
|
||||
ProductMetaId = packate_repeat_attrib.ProductMetaId;
|
||||
LeftCount = packate_repeat_attrib.LeftCount;
|
||||
NextGiveTime = packate_repeat_attrib.NextGiveTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var package_repeat_attribute = otherEntityAttribute as PackageRepeatAttribute;
|
||||
if (null == package_repeat_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast Attribute !!!, package_repeat_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
OrderGuid = package_repeat_attribute.OrderGuid;
|
||||
ProductMetaId = package_repeat_attribute.ProductMetaId;
|
||||
LeftCount = package_repeat_attribute.LeftCount;
|
||||
NextGiveTime = package_repeat_attribute.NextGiveTime;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = package_repeat_attribute.getTryPendingDocBase() as PackageRepeatDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
package_repeat_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<PackageRepeatAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<PackageRepeatAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var package_repeat_attrib = origin_doc_base.getAttrib<PackageRepeatAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(package_repeat_attrib, () => $"package_repeat_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
package_repeat_attrib.OrderGuid = OrderGuid;
|
||||
package_repeat_attrib.ProductMetaId = ProductMetaId;
|
||||
package_repeat_attrib.LeftCount = LeftCount;
|
||||
package_repeat_attrib.NextGiveTime = NextGiveTime;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public class PackageRepeatAttributeTransactor : EntityAttributeTransactorBase<PackageRepeatAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public PackageRepeatAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(PackageRepeatAttribute).Name;
|
||||
|
||||
var copy_from_attribute = entityAttributeBase as PackageRepeatAttribute;
|
||||
if (null == copy_from_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_package_repeat_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_attribute = getClonedEntityAttribute() as PackageRepeatAttribute;
|
||||
if (null == copy_to_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_package_repeat_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_attribute.OrderGuid = copy_from_attribute.OrderGuid;
|
||||
copy_to_attribute.ProductMetaId = copy_from_attribute.ProductMetaId;
|
||||
copy_to_attribute.LeftCount = copy_from_attribute.LeftCount;
|
||||
copy_to_attribute.NextGiveTime = copy_from_attribute.NextGiveTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
185
ServerCommon/Entity/Attribute/PartyAttribute.cs
Normal file
185
ServerCommon/Entity/Attribute/PartyAttribute.cs
Normal file
@@ -0,0 +1,185 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Nettention.Proud;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
using PARTY_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class PartyVoteInfo
|
||||
{
|
||||
public string VoteTitle { get; set; } = string.Empty;
|
||||
public Dictionary<USER_GUID, VoteType> Votes { get; set; } = new();
|
||||
|
||||
public Timestamp StartVoteTime { get; set; } = new();
|
||||
|
||||
public PartyVoteInfo cloned()
|
||||
{
|
||||
var cloned = new PartyVoteInfo
|
||||
{
|
||||
VoteTitle = VoteTitle,
|
||||
StartVoteTime = StartVoteTime
|
||||
};
|
||||
|
||||
foreach (var vote in Votes)
|
||||
{
|
||||
cloned.Votes.Add(vote.Key, vote.Value);
|
||||
}
|
||||
|
||||
return cloned;
|
||||
}
|
||||
}
|
||||
|
||||
public class PartyAttribute : EntityAttributeBase, ICopyEntityAttributeFromCache
|
||||
{
|
||||
// 파티 정보
|
||||
public string PartyName { get; set; } = string.Empty;
|
||||
public string PartyLeaderCharGuid { get; set; } = string.Empty;
|
||||
|
||||
public string PartyLeaderNickname { get; set; } = string.Empty;
|
||||
|
||||
public DateTime CreatePartyTime { get; set; } = DateTimeHelper.Current;
|
||||
|
||||
public PartyVoteInfo? PartyVote { get; set; }
|
||||
public Timestamp? LastVoteTime { get; set; }
|
||||
|
||||
public HostID P2PGroup = HostID.HostID_None;
|
||||
|
||||
public PartyAttribute(EntityBase owner, NetServer? net_server) : base(owner)
|
||||
{
|
||||
onInit(net_server);
|
||||
}
|
||||
|
||||
private void onInit(NetServer? net_server)
|
||||
{
|
||||
if (null == net_server) return;
|
||||
|
||||
var byArray = new ByteArray();
|
||||
var p2PGroupType = new P2PGroupType();
|
||||
p2PGroupType.Type = 1;
|
||||
|
||||
ServerBase.ProudNetHelper.convertP2PGroupToByteArray(byArray, p2PGroupType);
|
||||
var arrHostId = Array.Empty<HostID>();
|
||||
P2PGroup = net_server.CreateP2PGroup(arrHostId, byArray);
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
PartyName = string.Empty;
|
||||
PartyLeaderCharGuid = string.Empty;
|
||||
PartyLeaderNickname = string.Empty;
|
||||
|
||||
PartyVote = null;
|
||||
P2PGroup = HostID.HostID_None;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new PartyAttribute(getOwner(), null)
|
||||
{
|
||||
PartyName = PartyName,
|
||||
PartyLeaderCharGuid = PartyLeaderCharGuid,
|
||||
PartyLeaderNickname = PartyLeaderNickname,
|
||||
CreatePartyTime = CreatePartyTime,
|
||||
|
||||
P2PGroup = P2PGroup,
|
||||
PartyVote = PartyVote?.cloned()
|
||||
};
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public int getVoteCount(VoteType vote_type)
|
||||
{
|
||||
var count = 0;
|
||||
return null == PartyVote
|
||||
? count
|
||||
: PartyVote.Votes.Count(vote => vote.Value == vote_type);
|
||||
}
|
||||
public bool copyEntityAttributeFromCache(CacheBase? cacheBase)
|
||||
{
|
||||
var party_cache = cacheBase as PartyCache;
|
||||
if(null == party_cache)
|
||||
{
|
||||
var err_msg = $"Failed to copyEntityAttributeFromCache() !!!, party_cache is null :{nameof(PartyCache)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Cache => Attribute
|
||||
//=====================================================================================
|
||||
|
||||
PartyName = party_cache.PartyName;
|
||||
PartyLeaderCharGuid = party_cache.PartyLeaderCharGuid;
|
||||
PartyLeaderNickname = party_cache.PartyLeaderNickname;
|
||||
LastVoteTime = party_cache.LastVoteTime;
|
||||
CreatePartyTime = party_cache.CreatePartyTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new PartyAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
return (new Result(), null);
|
||||
}
|
||||
}
|
||||
|
||||
public class PartyAttributeTransactor : EntityAttributeTransactorBase<PartyAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public PartyAttributeTransactor(EntityBase owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase entityAttributeBase)
|
||||
{
|
||||
string err_msg;
|
||||
|
||||
var copy_from_party_attribute = entityAttributeBase as PartyAttribute;
|
||||
if (null == copy_from_party_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_party_attribute is null :{nameof(PartyAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_party_attribute = getClonedEntityAttribute() as PartyAttribute;
|
||||
if (null == copy_to_party_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_party_attribute is null :{nameof(PartyAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_party_attribute.PartyName = copy_from_party_attribute.PartyName;
|
||||
copy_to_party_attribute.PartyLeaderCharGuid = copy_from_party_attribute.PartyLeaderCharGuid;
|
||||
copy_to_party_attribute.PartyLeaderNickname = copy_from_party_attribute.PartyLeaderNickname;
|
||||
copy_to_party_attribute.CreatePartyTime = copy_from_party_attribute.CreatePartyTime;
|
||||
copy_to_party_attribute.P2PGroup = copy_from_party_attribute.P2PGroup;
|
||||
copy_to_party_attribute.PartyVote = copy_from_party_attribute.PartyVote?.cloned();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
122
ServerCommon/Entity/Attribute/PartyInstanceAttribute.cs
Normal file
122
ServerCommon/Entity/Attribute/PartyInstanceAttribute.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerCommon.Cache;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
|
||||
public class PartyInstanceAttribute : EntityAttributeBase, ICopyEntityAttributeFromCache
|
||||
{
|
||||
public int InstanceId { get; set; } = 0;
|
||||
public string RoomId { get; set; } = string.Empty;
|
||||
public Timestamp StartTime { get; set; } = new();
|
||||
public Timestamp EndTime { get; set; } = new();
|
||||
public int JoinMemberCount { get; set; } = 0;
|
||||
|
||||
public PartyInstanceAttribute(EntityBase owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
InstanceId = 0;
|
||||
RoomId = string.Empty;
|
||||
StartTime = DateTimeHelper.MinTime.ToTimestamp();
|
||||
EndTime = DateTimeHelper.MinTime.ToTimestamp();
|
||||
JoinMemberCount = 0;
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new PartyInstanceAttribute(getOwner())
|
||||
{
|
||||
InstanceId = InstanceId,
|
||||
RoomId = RoomId,
|
||||
StartTime = StartTime,
|
||||
EndTime = EndTime,
|
||||
JoinMemberCount = JoinMemberCount
|
||||
};
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromCache(CacheBase? cacheBase)
|
||||
{
|
||||
var party_instance_cache = cacheBase as PartyInstanceCache;
|
||||
if(null == party_instance_cache)
|
||||
{
|
||||
var err_msg = $"Failed to copyEntityAttributeFromCache() !!!, party_cache is null :{nameof(PartyInstanceCache)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Cache => Attribute
|
||||
//=====================================================================================
|
||||
InstanceId = party_instance_cache.InstanceId;
|
||||
RoomId = party_instance_cache.RoomId;
|
||||
StartTime = party_instance_cache.StartTime;
|
||||
EndTime = party_instance_cache.EndTime;
|
||||
JoinMemberCount = party_instance_cache.JoinMemberCount;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new PartyInstanceAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
return (new Result(), null);
|
||||
}
|
||||
}
|
||||
|
||||
public class PartyInstanceAttributeTransactor : EntityAttributeTransactorBase<PartyInstanceAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public PartyInstanceAttributeTransactor(EntityBase owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase entityAttributeBase)
|
||||
{
|
||||
string err_msg;
|
||||
|
||||
var copy_from_party_instance_attribute = entityAttributeBase as PartyInstanceAttribute;
|
||||
if (null == copy_from_party_instance_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_party_instance_attribute is null :{nameof(PartyInstanceAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_party_instance_attribute = getClonedEntityAttribute() as PartyInstanceAttribute;
|
||||
if (null == copy_to_party_instance_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_party_instance_attribute is null :{nameof(PartyInstanceAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_party_instance_attribute.InstanceId = copy_from_party_instance_attribute.InstanceId;
|
||||
copy_to_party_instance_attribute.RoomId = copy_from_party_instance_attribute.RoomId;
|
||||
copy_to_party_instance_attribute.StartTime = copy_from_party_instance_attribute.StartTime;
|
||||
copy_to_party_instance_attribute.EndTime = copy_from_party_instance_attribute.EndTime;
|
||||
copy_to_party_instance_attribute.JoinMemberCount = copy_from_party_instance_attribute.JoinMemberCount;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
149
ServerCommon/Entity/Attribute/PartyInvitePartyRecvsAttribute.cs
Normal file
149
ServerCommon/Entity/Attribute/PartyInvitePartyRecvsAttribute.cs
Normal file
@@ -0,0 +1,149 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
|
||||
using ServerCommon.Cache;
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using PARTY_GUID = System.String;
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class PartyInvitePartyRecvsAttribute : EntityAttributeBase, ICopyEntityAttributeFromCache
|
||||
{
|
||||
private ConcurrentDictionary<PARTY_GUID, DateTime> m_party_invite_party_recvs { get; set; } = new();
|
||||
|
||||
public PartyInvitePartyRecvsAttribute(EntityBase owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override async Task<Result> onInit() => await Task.FromResult(new Result());
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
m_party_invite_party_recvs.Clear();
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new PartyInvitePartyRecvsAttribute(getOwner());
|
||||
|
||||
foreach (var send in m_party_invite_party_recvs)
|
||||
{
|
||||
cloned.m_party_invite_party_recvs.TryAdd(send.Key, send.Value);
|
||||
}
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public ConcurrentDictionary<PARTY_GUID, DateTime> getPartyInvitePartyRecvs() => m_party_invite_party_recvs;
|
||||
|
||||
public DateTime? getPartyInvitePartyRecvTime(PARTY_GUID party_guid)
|
||||
{
|
||||
if (m_party_invite_party_recvs.TryGetValue(party_guid, out var invite_recv_time))
|
||||
{
|
||||
return invite_recv_time;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addInvitePartyRecv(PARTY_GUID party_guid, DateTime recv_time)
|
||||
{
|
||||
m_party_invite_party_recvs[party_guid] = recv_time;
|
||||
}
|
||||
|
||||
public void deleteInvitePartyRecvs(IReadOnlyList<PARTY_GUID> delete_guids)
|
||||
{
|
||||
foreach (var del in delete_guids)
|
||||
{
|
||||
m_party_invite_party_recvs.Remove(del, out _);
|
||||
}
|
||||
}
|
||||
public bool copyEntityAttributeFromCache(CacheBase? cacheBase)
|
||||
{
|
||||
var party_invite_party_recv_cache = cacheBase as PartyInvitePartyRecvCache;
|
||||
if(null == party_invite_party_recv_cache)
|
||||
{
|
||||
var err_msg = $"Failed to copyEntityAttributeFromCache() !!!, party_invite_party_recv_cache is null :{nameof(PartyInvitePartyRecvCache)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Cache => Attribute
|
||||
//=====================================================================================
|
||||
m_party_invite_party_recvs.Clear();
|
||||
foreach (var send in party_invite_party_recv_cache.PartyInvitePartyRecvs)
|
||||
{
|
||||
m_party_invite_party_recvs.TryAdd(send.Key, send.Value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromAttribute(PartyInvitePartyRecvsAttribute from_attribute)
|
||||
{
|
||||
//=====================================================================================
|
||||
// Attribute => Attribute
|
||||
//=====================================================================================
|
||||
m_party_invite_party_recvs.Clear();
|
||||
foreach (var send in from_attribute.getPartyInvitePartyRecvs())
|
||||
{
|
||||
m_party_invite_party_recvs.TryAdd(send.Key, send.Value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new PartyInvitePartyRecvsAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
return (new Result(), null);
|
||||
}
|
||||
}
|
||||
|
||||
public class PartyInvitePartyRecvsAttributeTransactor : EntityAttributeTransactorBase<PartyInvitePartyRecvsAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public PartyInvitePartyRecvsAttributeTransactor(EntityBase owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase entityAttributeBase)
|
||||
{
|
||||
string err_msg;
|
||||
|
||||
var copy_from_party_invite_party_recv_attribute = entityAttributeBase as PartyInvitePartyRecvsAttribute;
|
||||
if (null == copy_from_party_invite_party_recv_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_party_invite_party_recv_attribute is null :{nameof(PartyInvitePartyRecvsAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_party_invite_party_recv_attribute = getClonedEntityAttribute() as PartyInvitePartyRecvsAttribute;
|
||||
if (null == copy_to_party_invite_party_recv_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_party_invite_party_recv_attribute is null :{nameof(PartyInvitePartyRecvsAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_party_invite_party_recv_attribute.copyEntityAttributeFromAttribute(copy_from_party_invite_party_recv_attribute);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
146
ServerCommon/Entity/Attribute/PartyInvitePartySendsAttribute.cs
Normal file
146
ServerCommon/Entity/Attribute/PartyInvitePartySendsAttribute.cs
Normal file
@@ -0,0 +1,146 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class PartyInvitePartySendsAttribute : EntityAttributeBase, ICopyEntityAttributeFromCache
|
||||
{
|
||||
private ConcurrentDictionary<string, DateTime> m_party_invite_party_sends { get; set; } = new();
|
||||
|
||||
public PartyInvitePartySendsAttribute(EntityBase owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override async Task<Result> onInit() => await Task.FromResult(new Result());
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
m_party_invite_party_sends.Clear();
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new PartyInvitePartySendsAttribute(getOwner());
|
||||
|
||||
foreach (var send in m_party_invite_party_sends)
|
||||
{
|
||||
cloned.m_party_invite_party_sends.TryAdd(send.Key, send.Value);
|
||||
}
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public ConcurrentDictionary<string, DateTime> getPartyInvitePartySends() => m_party_invite_party_sends;
|
||||
|
||||
public void addInvitePartySends(IReadOnlyList<string> add_sends)
|
||||
{
|
||||
foreach (var send in add_sends)
|
||||
{
|
||||
m_party_invite_party_sends[send] = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteInvitePartySends(IReadOnlyList<string> delete_sends)
|
||||
{
|
||||
foreach (var send in delete_sends)
|
||||
{
|
||||
m_party_invite_party_sends.Remove(send, out _);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteInvitePartySend(string invitee_guid)
|
||||
{
|
||||
m_party_invite_party_sends.Remove(invitee_guid, out _);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromCache(CacheBase? cacheBase)
|
||||
{
|
||||
var party_invite_party_send_cache = cacheBase as PartyInvitePartySendCache;
|
||||
if(null == party_invite_party_send_cache)
|
||||
{
|
||||
var err_msg = $"Failed to copyEntityAttributeFromCache() !!!, party_invite_party_send_cache is null :{nameof(PartyInvitePartySendCache)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Cache => Attribute
|
||||
//=====================================================================================
|
||||
m_party_invite_party_sends.Clear();
|
||||
foreach (var send in party_invite_party_send_cache.PartyInvitePartySends)
|
||||
{
|
||||
m_party_invite_party_sends.TryAdd(send.Key, send.Value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromAttribute(PartyInvitePartySendsAttribute from_attribute)
|
||||
{
|
||||
//=====================================================================================
|
||||
// Attribute => Attribute
|
||||
//=====================================================================================
|
||||
m_party_invite_party_sends.Clear();
|
||||
foreach (var send in from_attribute.getPartyInvitePartySends())
|
||||
{
|
||||
m_party_invite_party_sends.TryAdd(send.Key, send.Value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new PartyInvitePartySendsAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
return (new Result(), null);
|
||||
}
|
||||
}
|
||||
|
||||
public class PartyInvitePartySendsAttributeTransactor : EntityAttributeTransactorBase<PartyInvitePartySendsAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public PartyInvitePartySendsAttributeTransactor(EntityBase owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase entityAttributeBase)
|
||||
{
|
||||
string err_msg;
|
||||
|
||||
var copy_from_party_invite_party_send_attribute = entityAttributeBase as PartyInvitePartySendsAttribute;
|
||||
if (null == copy_from_party_invite_party_send_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_party_invite_party_send_attribute is null :{nameof(PartyInvitePartySendsAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_party_invite_party_send_attribute = getClonedEntityAttribute() as PartyInvitePartySendsAttribute;
|
||||
if (null == copy_to_party_invite_party_send_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_party_invite_party_send_attribute is null :{nameof(PartyInvitePartySendsAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_party_invite_party_send_attribute.copyEntityAttributeFromAttribute(copy_from_party_invite_party_send_attribute);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
143
ServerCommon/Entity/Attribute/PartyMemberAttribute.cs
Normal file
143
ServerCommon/Entity/Attribute/PartyMemberAttribute.cs
Normal file
@@ -0,0 +1,143 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerCommon.Cache;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class PartyMemberAttribute : EntityAttributeBase, ICopyEntityAttributeFromCache
|
||||
{
|
||||
private ConcurrentDictionary<USER_GUID, PartyMemberInfo> m_party_members = new();
|
||||
|
||||
public PartyMemberAttribute(EntityBase owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override async Task<Result> onInit() => await Task.FromResult(new Result());
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
m_party_members.Clear();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new PartyMemberAttribute(getOwner());
|
||||
|
||||
foreach (var member in m_party_members)
|
||||
{
|
||||
var insert = member.Value.clone();
|
||||
|
||||
cloned.m_party_members.TryAdd(member.Key, insert);
|
||||
}
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public ConcurrentDictionary<USER_GUID, PartyMemberInfo> getPartyMembers() => m_party_members;
|
||||
public PartyMemberInfo? getPartyMember(USER_GUID user_guid) => m_party_members.GetValueOrDefault(user_guid);
|
||||
public int getPartyMemberCount() => m_party_members.Count;
|
||||
|
||||
public void setPartyMember(PartyMemberInfo user) => m_party_members[user.UserGuid] = user;
|
||||
public bool deletePartyMember(USER_GUID delete_user_guid) => m_party_members.Remove(delete_user_guid, out _);
|
||||
|
||||
public bool copyEntityAttributeFromCache(CacheBase? cacheBase)
|
||||
{
|
||||
var party_member_cache = cacheBase as PartyMemberCache;
|
||||
if(null == party_member_cache)
|
||||
{
|
||||
var err_msg = $"Failed to copyEntityAttributeFromCache() !!!, party_member_cache is null :{nameof(PartyMemberCache)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Cache => Attribute
|
||||
//=====================================================================================
|
||||
foreach (var member in party_member_cache.PartyMembers)
|
||||
{
|
||||
if (m_party_members.ContainsKey(member.Key))
|
||||
{
|
||||
m_party_members[member.Key] = member.Value;
|
||||
continue;
|
||||
}
|
||||
|
||||
m_party_members.TryAdd(member.Key, member.Value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromAttribute(PartyMemberAttribute from_attribute)
|
||||
{
|
||||
//=====================================================================================
|
||||
// Attribute => Attribute
|
||||
//=====================================================================================
|
||||
foreach (var member in from_attribute.getPartyMembers())
|
||||
{
|
||||
if (m_party_members.ContainsKey(member.Key))
|
||||
{
|
||||
m_party_members[member.Key] = member.Value;
|
||||
continue;
|
||||
}
|
||||
|
||||
m_party_members.TryAdd(member.Key, member.Value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new PartyMemberAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
return (new Result(), null);
|
||||
}
|
||||
}
|
||||
|
||||
public class PartyMemberAttributeTransactor : EntityAttributeTransactorBase<PartyMemberAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public PartyMemberAttributeTransactor(EntityBase owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase entityAttributeBase)
|
||||
{
|
||||
string err_msg;
|
||||
|
||||
var copy_from_party_member_attribute = entityAttributeBase as PartyMemberAttribute;
|
||||
if (null == copy_from_party_member_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_party_member_attribute is null :{nameof(PartyMemberAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_party_member_attribute = getClonedEntityAttribute() as PartyMemberAttribute;
|
||||
if (null == copy_to_party_member_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_party_member_attribute is null :{nameof(PartyMemberAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_party_member_attribute.copyEntityAttributeFromAttribute(copy_from_party_member_attribute);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
140
ServerCommon/Entity/Attribute/PartyServerAttribute.cs
Normal file
140
ServerCommon/Entity/Attribute/PartyServerAttribute.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerCommon.Cache;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
|
||||
public class PartyServerAttribute : EntityAttributeBase, ICopyEntityAttributeFromCache
|
||||
{
|
||||
private ConcurrentBag<string> m_party_servers { get; set; }= new();
|
||||
|
||||
public PartyServerAttribute(EntityBase owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override async Task<Result> onInit() => await Task.FromResult(new Result());
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
m_party_servers.Clear();
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new PartyServerAttribute(getOwner());
|
||||
|
||||
foreach (var server in m_party_servers)
|
||||
{
|
||||
cloned.m_party_servers.Add(server);
|
||||
}
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public ConcurrentBag<string> getPartyServers() => m_party_servers;
|
||||
|
||||
public void addPartyServer(string server_name) => m_party_servers.Add(server_name);
|
||||
|
||||
public void deleteServer(string delete_server)
|
||||
{
|
||||
var new_bag = new ConcurrentBag<string>();
|
||||
foreach (var server in m_party_servers)
|
||||
{
|
||||
if (server == delete_server) continue;
|
||||
new_bag.Add(server);
|
||||
}
|
||||
|
||||
m_party_servers = new_bag;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromCache(CacheBase? cacheBase)
|
||||
{
|
||||
var party_server_cache = cacheBase as PartyServerCache;
|
||||
if(null == party_server_cache)
|
||||
{
|
||||
var err_msg = $"Failed to copyEntityAttributeFromCache() !!!, party_cache is null :{nameof(PartyServerCache)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Cache => Attribute
|
||||
//=====================================================================================
|
||||
m_party_servers.Clear();
|
||||
foreach (var server in party_server_cache.PartyServers)
|
||||
{
|
||||
m_party_servers.Add(server);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromAttribute(PartyServerAttribute from_attribute)
|
||||
{
|
||||
//=====================================================================================
|
||||
// Attribute => Attribute
|
||||
//=====================================================================================
|
||||
m_party_servers.Clear();
|
||||
foreach (var server in from_attribute.getPartyServers())
|
||||
{
|
||||
m_party_servers.Add(server);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new PartyServerAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
return (new Result(), null);
|
||||
}
|
||||
}
|
||||
|
||||
public class PartyServerAttributeTransactor : EntityAttributeTransactorBase<PartyMemberAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public PartyServerAttributeTransactor(EntityBase owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase entityAttributeBase)
|
||||
{
|
||||
string err_msg;
|
||||
|
||||
var copy_from_party_server_attribute = entityAttributeBase as PartyServerAttribute;
|
||||
if (null == copy_from_party_server_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_party_server_attribute is null :{nameof(PartyServerAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_party_server_attribute = getClonedEntityAttribute() as PartyServerAttribute;
|
||||
if (null == copy_to_party_server_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_party_server_attribute is null :{nameof(PartyServerAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_party_server_attribute.copyEntityAttributeFromAttribute(copy_from_party_server_attribute);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
360
ServerCommon/Entity/Attribute/QuestAttribute.cs
Normal file
360
ServerCommon/Entity/Attribute/QuestAttribute.cs
Normal file
@@ -0,0 +1,360 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class UgqQuestInfo
|
||||
{
|
||||
[JsonProperty()]
|
||||
public UInt32 QuestRevision { get; set; } = 0;
|
||||
|
||||
[JsonProperty()]
|
||||
public Int32 QuestCost { get; set; } = 0;
|
||||
|
||||
[JsonProperty()]
|
||||
public UgqStateType UqgState { get; set; } = UgqStateType.None;
|
||||
}
|
||||
|
||||
public class QuestAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty()]
|
||||
public UInt32 QuestId { get; set; } = 0;
|
||||
|
||||
[JsonProperty()]
|
||||
public EQuestType QuestType { get; set; } = EQuestType.NONE;
|
||||
|
||||
[JsonProperty()]
|
||||
public UgqQuestInfo UgqInfo { get; set; } = new();
|
||||
|
||||
[JsonProperty()]
|
||||
public DateTime QuestAssignTime { get; set; } = DateTimeHelper.Current;
|
||||
|
||||
[JsonProperty()]
|
||||
public Int32 CurrentTaskNum { get; set; } = 0;
|
||||
|
||||
[JsonProperty()]
|
||||
public DateTime TaskStartTime { get; set; } = DateTimeHelper.Current;
|
||||
|
||||
[JsonProperty()]
|
||||
public DateTime QuestCompleteTime { get; set; } = DateTimeHelper.Current;
|
||||
|
||||
|
||||
public List<string> ActiveEvents { get; set; } = new();
|
||||
|
||||
public Int32 HasCounter { get; set; } = 0;
|
||||
|
||||
|
||||
public Int32 MinCounter { get; set; } = 0;
|
||||
|
||||
public Int32 MaxCounter { get; set; } = 0;
|
||||
|
||||
|
||||
public Int32 CurrentCounter { get; set; } = 0;
|
||||
|
||||
public Int32 IsComplete { get; set; } = 0;
|
||||
|
||||
|
||||
public Int32 ReplacedRewardGroupId { get; set; } = 0;
|
||||
|
||||
|
||||
public Int32 HasTimer { get; set; } = 0;
|
||||
|
||||
|
||||
public DateTime TimerCompleteTime { get; set; } = DateTimeHelper.Current;
|
||||
|
||||
[JsonProperty()]
|
||||
public Int32 CurrentTaskComplete { get; set; } = 0;
|
||||
|
||||
[JsonProperty()]
|
||||
public List<string> CompletedIdxStrings { get; set; } = new();
|
||||
|
||||
public QuestDoc? m_quest_doc_nullable { get; set; } = null;
|
||||
|
||||
public QuestAttribute(EntityBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
QuestId = 0;
|
||||
QuestType = EQuestType.NONE;
|
||||
UgqInfo = new();
|
||||
QuestAssignTime = new();
|
||||
CurrentTaskNum = 0;
|
||||
TaskStartTime = new();
|
||||
QuestCompleteTime = new();
|
||||
ActiveEvents.Clear();
|
||||
HasCounter = 0;
|
||||
MinCounter = 0;
|
||||
MaxCounter = 0;
|
||||
CurrentCounter = 0;
|
||||
IsComplete = 0;
|
||||
ReplacedRewardGroupId = 0;
|
||||
HasTimer = 0;
|
||||
TimerCompleteTime = new();
|
||||
CurrentTaskComplete = 0;
|
||||
CompletedIdxStrings.Clear();
|
||||
|
||||
m_quest_doc_nullable = null;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"player is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
|
||||
var quest_attribute = owner.getEntityAttribute<QuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attribute, () => $"quest_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var acoount_attribute = owner.getRootParent().getEntityAttribute<AccountAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(acoount_attribute, () => $"acoount_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
USER_GUID user_guid = acoount_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as QuestDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new QuestDoc(user_guid, QuestId, UgqInfo.QuestRevision);
|
||||
|
||||
var origin_doc = getOriginDocBase<QuestAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_quest_attrib = try_pending_doc.getAttrib<QuestAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_quest_attrib, () => $"to_copy_quest_attrib is null !!!");
|
||||
|
||||
to_copy_quest_attrib.m_quest_id = QuestId;
|
||||
to_copy_quest_attrib.m_ugq_quest_info = new UgqQuestInfo();
|
||||
to_copy_quest_attrib.m_ugq_quest_info.QuestRevision = UgqInfo.QuestRevision;
|
||||
to_copy_quest_attrib.m_ugq_quest_info.QuestCost = UgqInfo.QuestCost;
|
||||
to_copy_quest_attrib.m_ugq_quest_info.UqgState = UgqInfo.UqgState;
|
||||
to_copy_quest_attrib.m_quest_type = QuestType;
|
||||
to_copy_quest_attrib.m_ugq_quest_info = UgqInfo;
|
||||
to_copy_quest_attrib.m_quest_assign_time = QuestAssignTime;
|
||||
to_copy_quest_attrib.m_current_task_num = CurrentTaskNum;
|
||||
to_copy_quest_attrib.m_task_start_time = TaskStartTime;
|
||||
to_copy_quest_attrib.m_quest_complete_time = QuestCompleteTime;
|
||||
to_copy_quest_attrib.m_active_events = ActiveEvents;
|
||||
to_copy_quest_attrib.m_has_counter = HasCounter;
|
||||
to_copy_quest_attrib.m_min_counter = MinCounter;
|
||||
to_copy_quest_attrib.m_max_counter = MaxCounter;
|
||||
to_copy_quest_attrib.m_current_counter = CurrentCounter;
|
||||
to_copy_quest_attrib.m_is_complete = IsComplete;
|
||||
to_copy_quest_attrib.m_replaced_reward_group_id = ReplacedRewardGroupId;
|
||||
to_copy_quest_attrib.m_has_timer = HasTimer;
|
||||
to_copy_quest_attrib.m_timer_complete_time = TimerCompleteTime;
|
||||
to_copy_quest_attrib.m_is_current_task_complete = CurrentTaskComplete;
|
||||
to_copy_quest_attrib.m_completed_idx_strings = CompletedIdxStrings;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner_entity_type = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(owner_entity_type, () => $"owner_entity_type is null !!!");
|
||||
|
||||
var cloned = new QuestAttribute(getOwner(), owner_entity_type);
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.QuestId = QuestId;
|
||||
cloned.QuestType = QuestType;
|
||||
cloned.UgqInfo = new();
|
||||
cloned.UgqInfo.QuestRevision = UgqInfo.QuestRevision;
|
||||
cloned.UgqInfo.QuestCost = UgqInfo.QuestCost;
|
||||
cloned.UgqInfo.UqgState = UgqInfo.UqgState;
|
||||
cloned.QuestAssignTime = QuestAssignTime;
|
||||
cloned.CurrentTaskNum = CurrentTaskNum;
|
||||
cloned.TaskStartTime = TaskStartTime;
|
||||
cloned.QuestCompleteTime = QuestCompleteTime;
|
||||
cloned.ActiveEvents.AddRange(ActiveEvents);
|
||||
cloned.HasCounter = HasCounter;
|
||||
cloned.MinCounter = MinCounter;
|
||||
cloned.MaxCounter = MaxCounter;
|
||||
cloned.CurrentCounter = CurrentCounter;
|
||||
cloned.IsComplete = IsComplete;
|
||||
cloned.ReplacedRewardGroupId = ReplacedRewardGroupId;
|
||||
cloned.HasTimer = HasTimer;
|
||||
cloned.TimerCompleteTime = TimerCompleteTime;
|
||||
cloned.CurrentTaskComplete = CurrentTaskComplete;
|
||||
cloned.CompletedIdxStrings.AddRange(CompletedIdxStrings);
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var result = new Result();
|
||||
if(getAttributeState().hasFlag(StateType.Removed))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
var other_attribute = otherEntityAttribute as QuestAttribute;
|
||||
if (null == other_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast QuestAttribute !!!, other_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
QuestId = other_attribute.QuestId;
|
||||
QuestType = other_attribute.QuestType;
|
||||
UgqInfo = new UgqQuestInfo();
|
||||
UgqInfo.QuestCost = other_attribute.UgqInfo.QuestCost;
|
||||
UgqInfo.QuestRevision = other_attribute.UgqInfo.QuestRevision;
|
||||
UgqInfo.UqgState = other_attribute.UgqInfo.UqgState;
|
||||
QuestAssignTime = other_attribute.QuestAssignTime;
|
||||
CurrentTaskNum = other_attribute.CurrentTaskNum;
|
||||
TaskStartTime = other_attribute.TaskStartTime;
|
||||
QuestCompleteTime = other_attribute.QuestCompleteTime;
|
||||
ActiveEvents = other_attribute.ActiveEvents;
|
||||
HasCounter = other_attribute.HasCounter;
|
||||
MinCounter = other_attribute.MinCounter;
|
||||
MaxCounter = other_attribute.MaxCounter;
|
||||
CurrentCounter = other_attribute.CurrentCounter;
|
||||
IsComplete = other_attribute.IsComplete;
|
||||
ReplacedRewardGroupId = other_attribute.ReplacedRewardGroupId;
|
||||
HasTimer = other_attribute.HasTimer;
|
||||
TimerCompleteTime = other_attribute.TimerCompleteTime;
|
||||
CurrentTaskComplete = other_attribute.CurrentTaskComplete;
|
||||
CompletedIdxStrings = other_attribute.CompletedIdxStrings.ToList();
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_attribute.getTryPendingDocBase() as QuestDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<QuestAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<QuestAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var quest_attrib = origin_doc_base.getAttrib<QuestAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_attrib, () => $"quest_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
quest_attrib.m_quest_id = QuestId;
|
||||
quest_attrib.m_quest_type = QuestType;
|
||||
quest_attrib.m_ugq_quest_info = new UgqQuestInfo();
|
||||
quest_attrib.m_ugq_quest_info.QuestCost = UgqInfo.QuestCost;
|
||||
quest_attrib.m_ugq_quest_info.QuestRevision = UgqInfo.QuestRevision;
|
||||
quest_attrib.m_ugq_quest_info.UqgState = UgqInfo.UqgState;
|
||||
quest_attrib.m_quest_assign_time = QuestAssignTime;
|
||||
quest_attrib.m_current_task_num = CurrentTaskNum;
|
||||
quest_attrib.m_task_start_time = TaskStartTime;
|
||||
quest_attrib.m_quest_complete_time = QuestCompleteTime;
|
||||
quest_attrib.m_active_events = other_attribute.ActiveEvents;
|
||||
quest_attrib.m_has_counter = HasCounter;
|
||||
quest_attrib.m_min_counter = other_attribute.MinCounter;
|
||||
quest_attrib.m_max_counter = MaxCounter;
|
||||
quest_attrib.m_current_counter = CurrentCounter;
|
||||
quest_attrib.m_is_complete = IsComplete;
|
||||
quest_attrib.m_replaced_reward_group_id = ReplacedRewardGroupId;
|
||||
quest_attrib.m_has_timer = HasTimer;
|
||||
quest_attrib.m_timer_complete_time = TimerCompleteTime;
|
||||
quest_attrib.m_is_current_task_complete = CurrentTaskComplete;
|
||||
quest_attrib.m_completed_idx_strings = CompletedIdxStrings.ToList();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase customDoc)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
|
||||
return new QuestsAttributeTransactor(getOwner());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class QuestsAttributeTransactor : EntityAttributeTransactorBase<QuestAttribute>
|
||||
{
|
||||
public QuestsAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorBaseFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
//아직 미사용
|
||||
Log.getLogger().info("copyEntityDbTransactBaseFromEntityAttribute call");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
249
ServerCommon/Entity/Attribute/QuestMailAttribute.cs
Normal file
249
ServerCommon/Entity/Attribute/QuestMailAttribute.cs
Normal file
@@ -0,0 +1,249 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using MetaAssets;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class QuestMailAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty()]
|
||||
public UInt32 QuestId { get; set; } = 0;
|
||||
[JsonProperty()]
|
||||
public UInt32 QuestRevision { get; set; } = 0;
|
||||
//[JsonProperty()]
|
||||
//public EQuestType QuestType { get; set; } = EQuestType.NONE;
|
||||
//[JsonProperty()]
|
||||
//UgqStateType UgqState { get; set; } = UgqStateType.None;
|
||||
|
||||
[JsonProperty()] public DateTime CreateTime { get; set; } = DateTimeHelper.Current;
|
||||
[JsonProperty()] public DateTime? ExpireTime { get; set; }
|
||||
|
||||
[JsonProperty()]
|
||||
public Int32 IsRead { get; set; } = 0;
|
||||
|
||||
public QuestMailAttribute(EntityBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
QuestId = 0;
|
||||
QuestRevision = 0;
|
||||
//UgqState = UgqStateType.None;
|
||||
CreateTime = DateTimeHelper.MinTime;
|
||||
ExpireTime = null;
|
||||
IsRead = 0;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var owner = getOwner();
|
||||
var result = new Result();
|
||||
|
||||
var acoount_attribute = owner.getRootParent().getEntityAttribute<AccountAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(acoount_attribute, () => $"acoount_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
USER_GUID user_guid = acoount_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as QuestMailDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = (MetaHelper.GameConfigMeta.QuestMailStoragePeriod <= 0)
|
||||
? new QuestMailDoc(user_guid, QuestId, QuestRevision)
|
||||
: new QuestMailDoc(user_guid, QuestId, QuestRevision, MetaHelper.GameConfigMeta.QuestMailStoragePeriod);
|
||||
|
||||
var origin_doc = getOriginDocBase<QuestMailAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_quest_mail_attrib = try_pending_doc.getAttrib<QuestMailAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_quest_mail_attrib, () => $"to_copy_quest_mail_attrib is null !!!");
|
||||
|
||||
to_copy_quest_mail_attrib.QuestId = QuestId;
|
||||
to_copy_quest_mail_attrib.QuestRevision = QuestRevision;
|
||||
to_copy_quest_mail_attrib.CreateTime = CreateTime;
|
||||
to_copy_quest_mail_attrib.ExpireTime = ExpireTime;
|
||||
to_copy_quest_mail_attrib.IsRead = IsRead;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner_entity_type = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(owner_entity_type, () => $"owner_entity_type is null !!!");
|
||||
|
||||
var cloned = new QuestMailAttribute(getOwner(), owner_entity_type);
|
||||
cloned.deepCopyFromBase(this);
|
||||
cloned.QuestId = QuestId;
|
||||
cloned.QuestRevision = QuestRevision;
|
||||
cloned.CreateTime = CreateTime;
|
||||
cloned.ExpireTime = ExpireTime;
|
||||
cloned.IsRead = IsRead;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
var err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
|
||||
var other_attribute = otherEntityAttribute as QuestMailAttribute;
|
||||
if (null == other_attribute)
|
||||
{
|
||||
var err_msg = $"Failed to cast QuestMailAttribute !!!, other_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
IsRead = other_attribute.IsRead;
|
||||
QuestRevision = other_attribute.QuestRevision;
|
||||
CreateTime = other_attribute.CreateTime;
|
||||
ExpireTime = other_attribute.ExpireTime;
|
||||
QuestId = other_attribute.QuestId;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_attribute.getTryPendingDocBase() as QuestMailDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<QuestMailAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<QuestMailAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var quest_mail_attrib = origin_doc_base.getAttrib<QuestMailAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_mail_attrib, () => $"quest_mail_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
quest_mail_attrib.IsRead = IsRead;
|
||||
quest_mail_attrib.QuestRevision = QuestRevision;
|
||||
quest_mail_attrib.CreateTime = CreateTime;
|
||||
quest_mail_attrib.ExpireTime = ExpireTime;
|
||||
quest_mail_attrib.QuestId = QuestId;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase customDoc)
|
||||
{
|
||||
var quest_mail_doc_base = customDoc as QuestMailDoc;
|
||||
|
||||
if (null == quest_mail_doc_base)
|
||||
{
|
||||
var to_cast_string = typeof(QuestMailDoc).Name;
|
||||
var err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, item_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<QuestMailAttribute>(quest_mail_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = quest_mail_doc_base.getAttrib<QuestMailAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_attrib, () => $"doc_attrib is null !!!");
|
||||
|
||||
QuestId = doc_attrib.QuestId;
|
||||
QuestRevision = doc_attrib.QuestRevision;
|
||||
CreateTime = doc_attrib.CreateTime;
|
||||
ExpireTime = doc_attrib.ExpireTime;
|
||||
IsRead = doc_attrib.IsRead;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new QuestMailAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
|
||||
public class QuestMailAttributeTransactor : EntityAttributeTransactorBase<QuestMailAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public QuestMailAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase entityAttributeBase)
|
||||
{
|
||||
//아직 미사용
|
||||
Log.getLogger().info("copyEntityDbTransactBaseFromEntityAttribute call");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
254
ServerCommon/Entity/Attribute/QuestPeriodRepeatCheckAttribute.cs
Normal file
254
ServerCommon/Entity/Attribute/QuestPeriodRepeatCheckAttribute.cs
Normal file
@@ -0,0 +1,254 @@
|
||||
|
||||
using JsonConvert = Newtonsoft.Json.JsonConvert;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class QuestPeriodRepeatCheckAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
public Dictionary<OncePeriodRangeType, QuestPeriodRepeatInfo> m_period_repeat_quests = new();
|
||||
|
||||
|
||||
public QuestPeriodRepeatCheckAttribute(EntityBase owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var quest_period_repeat_attribute = owner.getEntityAttribute<QuestPeriodRepeatCheckAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(quest_period_repeat_attribute, () => $"quest_period_repeat_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var user_attribute = owner.getRootParent().getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
USER_GUID user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as QuestPeriodRepeatCheckDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new QuestPeriodRepeatCheckDoc(user_guid);
|
||||
|
||||
var origin_doc = getOriginDocBase<QuestPeriodRepeatCheckAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_attrib = try_pending_doc.getAttrib<QuestPeriodRepeatAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_attrib, () => $"QuestPeriodRepeatAttrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
foreach (var info in m_period_repeat_quests)
|
||||
{
|
||||
//repeat_info = info.Value;
|
||||
QuestPeriodRepeatInfo repeat_info = new();
|
||||
foreach (var sended_quest in info.Value.m_sended_quest)
|
||||
{
|
||||
repeat_info.m_sended_quest.TryAdd(sended_quest.Key, sended_quest.Value);
|
||||
}
|
||||
|
||||
if (false == to_copy_attrib.m_period_repeat_quests.TryAdd(info.Key, repeat_info))
|
||||
{
|
||||
Log.getLogger().warn($"QuestPeriodRepeatAttrib add Fail info.key : {info.Key}, value : {JsonConvert.SerializeObject(info.Value)}");
|
||||
}
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(var result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new QuestPeriodRepeatCheckAttribute(getOwner());
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
foreach (var info in m_period_repeat_quests)
|
||||
{
|
||||
QuestPeriodRepeatInfo repeat_info = new();
|
||||
foreach (var sended_quest in info.Value.m_sended_quest)
|
||||
{
|
||||
repeat_info.m_sended_quest.TryAdd(sended_quest.Key, sended_quest.Value);
|
||||
}
|
||||
|
||||
if (false == cloned.m_period_repeat_quests.TryAdd(info.Key, repeat_info))
|
||||
{
|
||||
Log.getLogger().warn($"m_period_repeat_quests add Fail info.key : {info.Key}, value : {JsonConvert.SerializeObject(info.Value)}");
|
||||
}
|
||||
}
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (getAttributeState().hasFlag(StateType.Removed))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
var owner = getOwner();
|
||||
|
||||
var other_attribute = otherEntityAttribute as QuestPeriodRepeatCheckAttribute;
|
||||
if (null == other_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast QuestPeriodRepeatCheckAttribute !!!, other_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
foreach (var info in other_attribute.m_period_repeat_quests)
|
||||
{
|
||||
QuestPeriodRepeatInfo repeat_info = new();
|
||||
foreach (var sended_quest in info.Value.m_sended_quest)
|
||||
{
|
||||
repeat_info.m_sended_quest.TryAdd(sended_quest.Key, sended_quest.Value);
|
||||
}
|
||||
|
||||
if (false == m_period_repeat_quests.TryAdd(info.Key, repeat_info))
|
||||
{
|
||||
Log.getLogger().warn($"m_period_repeat_quests add Fail info.key : {info.Key}, value : {JsonConvert.SerializeObject(info.Value)}");
|
||||
}
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_attribute.getTryPendingDocBase() as QuestPeriodRepeatCheckDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<QuestPeriodRepeatCheckAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<QuestPeriodRepeatCheckAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var attrib = origin_doc_base.getAttrib<QuestPeriodRepeatAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(attrib, () => $"QuestPeriodRepeatAttrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
foreach (var info in m_period_repeat_quests)
|
||||
{
|
||||
QuestPeriodRepeatInfo repeat_info = new();
|
||||
foreach (var sended_quest in info.Value.m_sended_quest)
|
||||
{
|
||||
repeat_info.m_sended_quest.TryAdd(sended_quest.Key, sended_quest.Value);
|
||||
}
|
||||
|
||||
if (false == attrib.m_period_repeat_quests.TryAdd(info.Key, repeat_info))
|
||||
{
|
||||
Log.getLogger().warn($"m_period_repeat_quests add Fail info.key : {info.Key}, value : {JsonConvert.SerializeObject(info.Value)}");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase customDoc)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(QuestPeriodRepeatCheckDoc).Name;
|
||||
|
||||
var period_repeat_quest_doc = customDoc as QuestPeriodRepeatCheckDoc;
|
||||
if (null == period_repeat_quest_doc)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, period_repeat_quest_doc is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<QuestPeriodRepeatCheckAttribute>(period_repeat_quest_doc);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var period_repeat_quest_attrib = period_repeat_quest_doc.getAttrib<QuestPeriodRepeatAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(period_repeat_quest_attrib, () => $"period_repeat_quest_attrib is null !!!");
|
||||
|
||||
foreach (var info in period_repeat_quest_attrib.m_period_repeat_quests)
|
||||
{
|
||||
QuestPeriodRepeatInfo repeat_info = new();
|
||||
foreach (var sended_quest in info.Value.m_sended_quest)
|
||||
{
|
||||
repeat_info.m_sended_quest.TryAdd(sended_quest.Key, sended_quest.Value);
|
||||
}
|
||||
|
||||
if (false == m_period_repeat_quests.TryAdd(info.Key, repeat_info))
|
||||
{
|
||||
Log.getLogger().warn($"m_period_repeat_quests add Fail info.key : {info.Key}, value : {JsonConvert.SerializeObject(info.Value)}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new QuestPeriodRepeatTransactor(getOwner());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class QuestPeriodRepeatTransactor : EntityAttributeTransactorBase<QuestPeriodRepeatCheckAttribute>
|
||||
{
|
||||
public QuestPeriodRepeatTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorBaseFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
292
ServerCommon/Entity/Attribute/RentalAttribute.cs
Normal file
292
ServerCommon/Entity/Attribute/RentalAttribute.cs
Normal file
@@ -0,0 +1,292 @@
|
||||
using Amazon.S3.Model;
|
||||
using Newtonsoft.Json;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class RentalAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public int LandMetaId { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public int BuildingMetaId { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public int Floor { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public string MyhomeGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public DateTime RentalFinishTime { get; set; } = new();
|
||||
|
||||
|
||||
public RentalAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void newEntityAttribute()
|
||||
{
|
||||
base.newEntityAttribute();
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new RentalAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
LandMetaId = 0;
|
||||
BuildingMetaId = 0;
|
||||
Floor = 0;
|
||||
MyhomeGuid = string.Empty;
|
||||
RentalFinishTime = new();
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new RentalAttribute(getOwner());
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.LandMetaId = LandMetaId;
|
||||
cloned.BuildingMetaId = BuildingMetaId;
|
||||
cloned.Floor = Floor;
|
||||
cloned.MyhomeGuid = MyhomeGuid;
|
||||
cloned.RentalFinishTime = RentalFinishTime;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
|
||||
var user_attribute = owner.getRootParent().getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!!");
|
||||
|
||||
string user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as RentalDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var address = makeAddress(LandMetaId, BuildingMetaId, Floor);
|
||||
var ttl_seconds = DynamoDbClientHelper.makeTTLTimeForDynamoDB(RentalFinishTime);
|
||||
|
||||
var to_copy_doc = new RentalDoc(user_guid, address, ttl_seconds);
|
||||
|
||||
var origin_doc = getOriginDocBase<RentalAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<RentalAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!!");
|
||||
|
||||
to_copy_doc_attrib.LandMetaId = LandMetaId;
|
||||
to_copy_doc_attrib.BuildingMetaId = BuildingMetaId;
|
||||
to_copy_doc_attrib.Floor = Floor;
|
||||
to_copy_doc_attrib.MyhomeGuid = MyhomeGuid;
|
||||
to_copy_doc_attrib.RentalFinishTime = RentalFinishTime;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(RentalDoc).Name;
|
||||
|
||||
var rental_doc_base = docBase as RentalDoc;
|
||||
if (null == rental_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, rental_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<RentalAttribute>(rental_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = rental_doc_base.getAttrib<RentalAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_attrib, () => $"doc_attrib is null !!!");
|
||||
|
||||
LandMetaId = doc_attrib.LandMetaId;
|
||||
BuildingMetaId = doc_attrib.BuildingMetaId;
|
||||
Floor = doc_attrib.Floor;
|
||||
MyhomeGuid = doc_attrib.MyhomeGuid;
|
||||
RentalFinishTime = doc_attrib.RentalFinishTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var rental_attribute = otherEntityAttribute as RentalAttribute;
|
||||
if (null == rental_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast RentalAttribute !!!, rental_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
LandMetaId = rental_attribute.LandMetaId;
|
||||
BuildingMetaId = rental_attribute.BuildingMetaId;
|
||||
Floor = rental_attribute.Floor;
|
||||
MyhomeGuid = rental_attribute.MyhomeGuid;
|
||||
RentalFinishTime = rental_attribute.RentalFinishTime;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = rental_attribute.getTryPendingDocBase() as RentalDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
rental_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<RentalAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<RentalAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var rental_attrib = origin_doc_base.getAttrib<RentalAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(rental_attrib, () => $"rental_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
rental_attrib.LandMetaId = LandMetaId;
|
||||
rental_attrib.BuildingMetaId = BuildingMetaId;
|
||||
rental_attrib.Floor = Floor;
|
||||
rental_attrib.MyhomeGuid = MyhomeGuid;
|
||||
rental_attrib.RentalFinishTime = RentalFinishTime;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
string makeAddress(int landMetaId, int buildingMetaId, int floor)
|
||||
{
|
||||
var address = string.Empty;
|
||||
|
||||
if (landMetaId <= 0)
|
||||
return address;
|
||||
|
||||
address = $"{landMetaId}";
|
||||
|
||||
if (buildingMetaId <= 0)
|
||||
return address;
|
||||
|
||||
address = $"{landMetaId}#{buildingMetaId}";
|
||||
|
||||
if (floor <= 0)
|
||||
return address;
|
||||
|
||||
address = $"{landMetaId}#{buildingMetaId}#{floor}";
|
||||
|
||||
return address;
|
||||
}
|
||||
}
|
||||
|
||||
public class RentalAttributeTransactor : EntityAttributeTransactorBase<RentalAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public RentalAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(RentalAttribute).Name;
|
||||
|
||||
var copy_from_rental_attribute = entityAttributeBase as RentalAttribute;
|
||||
if (null == copy_from_rental_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_from_rental_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_rental_attribute = getClonedEntityAttribute() as RentalAttribute;
|
||||
if (null == copy_to_rental_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_to_rental_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_rental_attribute.LandMetaId = copy_from_rental_attribute.LandMetaId;
|
||||
copy_to_rental_attribute.BuildingMetaId = copy_from_rental_attribute.BuildingMetaId;
|
||||
copy_to_rental_attribute.Floor = copy_from_rental_attribute.Floor;
|
||||
copy_to_rental_attribute.MyhomeGuid = copy_from_rental_attribute.MyhomeGuid;
|
||||
copy_to_rental_attribute.RentalFinishTime = copy_from_rental_attribute.RentalFinishTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
211
ServerCommon/Entity/Attribute/RentalInstanceVisitAttribute.cs
Normal file
211
ServerCommon/Entity/Attribute/RentalInstanceVisitAttribute.cs
Normal file
@@ -0,0 +1,211 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Numerics;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class RentalInstanceVisitAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty()]
|
||||
public ConcurrentDictionary<string, DateTime> m_rental_instance_visit { get; set; } = new();
|
||||
|
||||
[JsonProperty()]
|
||||
public DateTime m_next_refresh_time { get; set; } = DateTimeHelper.Current.Date.AddDays(-1);
|
||||
|
||||
|
||||
public RentalInstanceVisitAttribute(EntityBase owner) : base(owner)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var rental_instance_visit_attribute = owner.getEntityAttribute<RentalInstanceVisitAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(rental_instance_visit_attribute, () => $"rental_instance_visit_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var user_attribute = owner.getRootParent().getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
USER_GUID user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as RentalInstanceVisitDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new RentalInstanceVisitDoc(user_guid);
|
||||
|
||||
var origin_doc = getOriginDocBase<RentalInstanceVisitAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_rental_instance_visit_attrib = try_pending_doc.getAttrib<RentalInstanceVisitAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_rental_instance_visit_attrib, () => $"to_copy_rental_instance_visit_attrib is null !!!");
|
||||
foreach (var each in m_rental_instance_visit)
|
||||
{
|
||||
if(false == to_copy_rental_instance_visit_attrib.m_rental_instance_visit_guid.TryAdd(each.Key, each.Value))
|
||||
{
|
||||
var err_msg = $"Failed to TryAdd() !!!, duplicated Key in Rental Instance Visit Guid !!! : Key:{each.Key} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
}
|
||||
}
|
||||
to_copy_rental_instance_visit_attrib.m_next_refresh_time = m_next_refresh_time;
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(var result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new RentalInstanceVisitAttribute(getOwner());
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.m_next_refresh_time = m_next_refresh_time;
|
||||
|
||||
cloned.m_rental_instance_visit = new();
|
||||
foreach (var dict in m_rental_instance_visit)
|
||||
{
|
||||
cloned.m_rental_instance_visit.TryAdd(dict.Key, dict.Value);
|
||||
}
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
Result result = new();
|
||||
if(getAttributeState().hasFlag(StateType.Removed))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
var other_attribute = otherEntityAttribute as RentalInstanceVisitAttribute;
|
||||
if (null == other_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast RentalInstanceVisitAttribute !!!, other_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
m_rental_instance_visit.Clear();
|
||||
foreach (var each in other_attribute.m_rental_instance_visit)
|
||||
{
|
||||
if (false == m_rental_instance_visit.TryAdd(each.Key, each.Value))
|
||||
{
|
||||
err_msg = $"Failed to TryAdd() !!!, duplicated Key in Rental Instance Visit Guid !!! : Key:{each.Key} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
}
|
||||
}
|
||||
m_next_refresh_time = other_attribute.m_next_refresh_time;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_attribute.getTryPendingDocBase() as RentalInstanceVisitDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<RentalInstanceVisitAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<RentalInstanceVisitAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var rental_instance_visit_attrib = origin_doc_base.getAttrib<RentalInstanceVisitAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(rental_instance_visit_attrib, () => $"rental_instance_visit_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
rental_instance_visit_attrib.m_rental_instance_visit_guid.Clear();
|
||||
foreach (var each in m_rental_instance_visit)
|
||||
{
|
||||
if(false == rental_instance_visit_attrib.m_rental_instance_visit_guid.TryAdd(each.Key, each.Value))
|
||||
{
|
||||
err_msg = $"Failed to TryAdd() !!!, duplicated Key in Rental Instance Visit Guid !!! : Key:{each.Key} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
}
|
||||
}
|
||||
rental_instance_visit_attrib.m_next_refresh_time = m_next_refresh_time;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase customDoc)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
|
||||
return new RentalInstanceVisitTransactor(getOwner());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class RentalInstanceVisitTransactor : EntityAttributeTransactorBase<RentalInstanceVisitAttribute>
|
||||
{
|
||||
public RentalInstanceVisitTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorBaseFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
193
ServerCommon/Entity/Attribute/RepeatQuestAttribute.cs
Normal file
193
ServerCommon/Entity/Attribute/RepeatQuestAttribute.cs
Normal file
@@ -0,0 +1,193 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
|
||||
|
||||
public class RepeatQuestAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty()]
|
||||
public DateTime m_next_allocate_time { get; set; } = new();
|
||||
[JsonProperty()]
|
||||
public Int32 m_is_checking { get; set; } = 0; //0 : not check, 1: checking
|
||||
|
||||
|
||||
public RepeatQuestAttribute(EntityBase owner) : base(owner)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
m_next_allocate_time = new();
|
||||
m_is_checking = 0;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
|
||||
var repeat_quest_attribute = owner.getEntityAttribute<RepeatQuestAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(repeat_quest_attribute, () => $"repeat_quest_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var user_attribute = owner.getRootParent().getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
USER_GUID user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as RepeatQuestDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new RepeatQuestDoc(user_guid);
|
||||
|
||||
var origin_doc = getOriginDocBase<RepeatQuestAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_repeat_quest_attrib = try_pending_doc.getAttrib<RepeatQuestAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_repeat_quest_attrib, () => $"to_copy_repeat_quest_attrib is null !!!");
|
||||
|
||||
to_copy_repeat_quest_attrib.m_next_allocate_time = m_next_allocate_time;
|
||||
to_copy_repeat_quest_attrib.m_is_checking = m_is_checking;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new RepeatQuestAttribute(getOwner());
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.m_next_allocate_time = m_next_allocate_time;
|
||||
cloned.m_is_checking = m_is_checking;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
ArgumentNullException.ThrowIfNull(owner);
|
||||
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
var other_attribute = otherEntityAttribute as RepeatQuestAttribute;
|
||||
if (null == other_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast QuestAttribute !!!, other_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
m_next_allocate_time = other_attribute.m_next_allocate_time;
|
||||
m_is_checking = other_attribute.m_is_checking;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_attribute.getTryPendingDocBase() as RepeatQuestDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<RepeatQuestAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<RepeatQuestAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var repeat_quest_attrib = origin_doc_base.getAttrib<RepeatQuestAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(repeat_quest_attrib, () => $"repeat_quest_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
repeat_quest_attrib.m_next_allocate_time = m_next_allocate_time;
|
||||
repeat_quest_attrib.m_is_checking = m_is_checking;
|
||||
|
||||
return result;
|
||||
}
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase customDoc)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new RepeatQuestAttributeTransactor(getOwner());
|
||||
}
|
||||
}
|
||||
|
||||
public class RepeatQuestAttributeTransactor : EntityAttributeTransactorBase<RepeatQuestAttribute>
|
||||
{
|
||||
public RepeatQuestAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorBaseFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
//아직 미사용
|
||||
Log.getLogger().info("copyEntityDbTransactBaseFromEntityAttribute call");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
324
ServerCommon/Entity/Attribute/RoomAttribute.cs
Normal file
324
ServerCommon/Entity/Attribute/RoomAttribute.cs
Normal file
@@ -0,0 +1,324 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class RoomAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty] public int RoomId { get; set; }
|
||||
[JsonProperty] public string Owner { get; set; } = string.Empty;
|
||||
[JsonProperty] public string Name { get; set; } = string.Empty;
|
||||
[JsonProperty] public string Description { get; set; } = string.Empty;
|
||||
[JsonProperty] public Dictionary<string, AnchorProp> PropInfo = new();
|
||||
|
||||
|
||||
public RoomAttribute(EntityBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
RoomId = 0;
|
||||
Owner = string.Empty;
|
||||
Name = string.Empty;
|
||||
Description = string.Empty;
|
||||
PropInfo.Clear();
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var entity_base = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(entity_base, () => $"entity_base is null !!!");
|
||||
|
||||
var cloned = new RoomAttribute(getOwner(), entity_base)
|
||||
{
|
||||
RoomId = RoomId,
|
||||
Owner = Owner,
|
||||
Name = Name,
|
||||
Description = Description
|
||||
};
|
||||
|
||||
foreach (var prop in PropInfo)
|
||||
{
|
||||
var data = new AnchorProp
|
||||
{
|
||||
TableId = prop.Value.TableId,
|
||||
GuidByType = prop.Value.GuidByType,
|
||||
IsMannequinsChanged = prop.Value.IsMannequinsChanged
|
||||
};
|
||||
|
||||
if (null != prop.Value.Mannequins)
|
||||
{
|
||||
data.Mannequins = new();
|
||||
data.Mannequins.AddRange(prop.Value.Mannequins);
|
||||
}
|
||||
|
||||
cloned.PropInfo.Add(prop.Key, prop.Value);
|
||||
}
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new IndividualRoomAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var user_attribute = owner.getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!!");
|
||||
|
||||
USER_GUID user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => Origin Doc
|
||||
//=====================================================================================
|
||||
var origin_doc = getOriginDocBase<RoomAttribute>();
|
||||
if (null == origin_doc)
|
||||
{
|
||||
var err_msg = $"Failed to toDocBase() !!!, origin_doc is null : {owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.OwnedRoomDocIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = origin_doc.getAttrib<RoomAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!!");
|
||||
|
||||
to_copy_doc_attrib.RoomId = RoomId;
|
||||
to_copy_doc_attrib.Owner = Owner;
|
||||
to_copy_doc_attrib.Name = Name;
|
||||
to_copy_doc_attrib.Description = Description;
|
||||
foreach (var prop in PropInfo)
|
||||
{
|
||||
var data = new AnchorProp
|
||||
{
|
||||
TableId = prop.Value.TableId,
|
||||
GuidByType = prop.Value.GuidByType,
|
||||
IsMannequinsChanged = prop.Value.IsMannequinsChanged
|
||||
};
|
||||
|
||||
if (null != prop.Value.Mannequins)
|
||||
{
|
||||
data.Mannequins = new();
|
||||
data.Mannequins.AddRange(prop.Value.Mannequins);
|
||||
}
|
||||
|
||||
to_copy_doc_attrib.PropInfo.Add(prop.Key, prop.Value);
|
||||
}
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, origin_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(origin_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
string err_msg;
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var other_room_attribute = otherEntityAttribute as RoomAttribute;
|
||||
if (null == other_room_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast RoomAttribute !!!, other_room_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
RoomId = other_room_attribute.RoomId;
|
||||
Owner = other_room_attribute.Owner;
|
||||
Name = other_room_attribute.Name;
|
||||
Description = other_room_attribute.Description;
|
||||
foreach (var prop in other_room_attribute.PropInfo)
|
||||
{
|
||||
var data = new AnchorProp
|
||||
{
|
||||
TableId = prop.Value.TableId,
|
||||
GuidByType = prop.Value.GuidByType,
|
||||
IsMannequinsChanged = prop.Value.IsMannequinsChanged
|
||||
};
|
||||
|
||||
if (null != prop.Value.Mannequins)
|
||||
{
|
||||
data.Mannequins = new();
|
||||
data.Mannequins.AddRange(prop.Value.Mannequins);
|
||||
}
|
||||
|
||||
PropInfo.Add(prop.Key, prop.Value);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => Origin Doc
|
||||
//=====================================================================================
|
||||
var origin_doc_base = getOriginDocBase<RoomAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var room_attrib = origin_doc_base.getAttrib<RoomAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(room_attrib, () => $"room_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
room_attrib.RoomId = RoomId;
|
||||
room_attrib.Owner = Owner;
|
||||
room_attrib.Name = Name;
|
||||
room_attrib.Description = Description;
|
||||
foreach (var prop in PropInfo)
|
||||
{
|
||||
var data = new AnchorProp
|
||||
{
|
||||
TableId = prop.Value.TableId,
|
||||
GuidByType = prop.Value.GuidByType,
|
||||
IsMannequinsChanged = prop.Value.IsMannequinsChanged
|
||||
};
|
||||
|
||||
if (null != prop.Value.Mannequins)
|
||||
{
|
||||
data.Mannequins = new();
|
||||
data.Mannequins.AddRange(prop.Value.Mannequins);
|
||||
}
|
||||
|
||||
room_attrib.PropInfo.Add(prop.Key, prop.Value);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
if (docBase is not RoomDoc room_doc)
|
||||
{
|
||||
var err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, room_doc_base is null :{nameof(RoomDoc)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<RoomAttribute>(room_doc);
|
||||
|
||||
var room_attrib = room_doc.getAttrib<RoomAttrib>();
|
||||
if (null == room_attrib)
|
||||
{
|
||||
var err_msg = $"Failed to copyEntityAttributeFromDocs() !!!, not found doc attrib !!! :{toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
RoomId = room_attrib.RoomId;
|
||||
Owner = room_attrib.Owner;
|
||||
Name = room_attrib.Name;
|
||||
Description = room_attrib.Description;
|
||||
foreach (var prop in room_attrib.PropInfo)
|
||||
{
|
||||
var data = new AnchorProp
|
||||
{
|
||||
TableId = prop.Value.TableId,
|
||||
GuidByType = prop.Value.GuidByType,
|
||||
IsMannequinsChanged = prop.Value.IsMannequinsChanged
|
||||
};
|
||||
|
||||
if (null != prop.Value.Mannequins)
|
||||
{
|
||||
data.Mannequins = new();
|
||||
data.Mannequins.AddRange(prop.Value.Mannequins);
|
||||
}
|
||||
|
||||
PropInfo.Add(prop.Key, prop.Value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class IndividualRoomAttributeTransactor: EntityAttributeTransactorBase<RoomAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public IndividualRoomAttributeTransactor(EntityBase owner) : base (owner) { }
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase entityAttributeBase)
|
||||
{
|
||||
string err_msg;
|
||||
|
||||
var copy_from_room_attribute = entityAttributeBase as RoomAttribute;
|
||||
if (null == copy_from_room_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_room_attribute is null - {nameof(RoomAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_room_attribute = getClonedEntityAttribute() as RoomAttribute;
|
||||
if (null == copy_to_room_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_room_attribute is null - {nameof(RoomAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_room_attribute.RoomId = copy_from_room_attribute.RoomId;
|
||||
copy_to_room_attribute.Owner = copy_from_room_attribute.Owner;
|
||||
copy_to_room_attribute.Name = copy_from_room_attribute.Name;
|
||||
copy_to_room_attribute.Description = copy_from_room_attribute.Description;
|
||||
foreach (var prop in copy_from_room_attribute.PropInfo)
|
||||
{
|
||||
var data = new AnchorProp
|
||||
{
|
||||
TableId = prop.Value.TableId,
|
||||
GuidByType = prop.Value.GuidByType,
|
||||
IsMannequinsChanged = prop.Value.IsMannequinsChanged
|
||||
};
|
||||
|
||||
if (null != prop.Value.Mannequins)
|
||||
{
|
||||
data.Mannequins = new();
|
||||
data.Mannequins.AddRange(prop.Value.Mannequins);
|
||||
}
|
||||
|
||||
copy_to_room_attribute.PropInfo.Add(prop.Key, prop.Value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
405
ServerCommon/Entity/Attribute/SeasonPassAttribute.cs
Normal file
405
ServerCommon/Entity/Attribute/SeasonPassAttribute.cs
Normal file
@@ -0,0 +1,405 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
using META_ID = System.UInt32;
|
||||
using Amazon.S3.Model;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class SeasonPassAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute, IWithCommonResultFiller
|
||||
{
|
||||
[JsonProperty]
|
||||
public META_ID SeasonPassMetaId { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public UInt32 Exp
|
||||
{
|
||||
get { return m_exp; }
|
||||
set
|
||||
{
|
||||
var recorder = getEntityRecorder();
|
||||
if (null != recorder)
|
||||
{
|
||||
recorder.applyDeltaCounter(EntityDeltaType.SeasonPassExp, (value - m_exp), value);
|
||||
}
|
||||
m_exp = value;
|
||||
}
|
||||
}
|
||||
private UInt32 m_exp = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public Int32 Grade
|
||||
{
|
||||
get { return m_grade; }
|
||||
set
|
||||
{
|
||||
var recorder = getEntityRecorder();
|
||||
if (null != recorder)
|
||||
{
|
||||
recorder.applyDeltaCounter(EntityDeltaType.SeasonPassGrade, (value - m_grade), value);
|
||||
}
|
||||
m_grade = value;
|
||||
}
|
||||
}
|
||||
private Int32 m_grade = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public List<Int32> takenRewards { get; set; } = new();
|
||||
|
||||
[JsonProperty]
|
||||
public bool IsChargedPass { get; set; } = false;
|
||||
|
||||
|
||||
public SeasonPassAttribute(EntityBase owner)
|
||||
: base(owner, true)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
SeasonPassMetaId = 0;
|
||||
Exp = 0;
|
||||
Grade = 0;
|
||||
takenRewards.Clear();
|
||||
IsChargedPass = false;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var cloned = new SeasonPassAttribute(owner);
|
||||
|
||||
cloned.SeasonPassMetaId = SeasonPassMetaId;
|
||||
cloned.Exp = Exp;
|
||||
cloned.Grade = Grade;
|
||||
cloned.IsChargedPass = IsChargedPass;
|
||||
cloned.takenRewards = takenRewards.Select(x => x).ToList();
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
var owner = getOwner() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
return new SeasonPassAttributeTransactor(owner);
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var acoount_attribute = owner.getEntityAttribute<AccountAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(acoount_attribute, () => $"acoount_attribute is null !!!");
|
||||
|
||||
USER_GUID user_guid = acoount_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as SeasonPassDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new SeasonPassDoc(user_guid);
|
||||
|
||||
var origin_doc = getOriginDocBase<SeasonPassAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<SeasonPassAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
to_copy_doc_attrib.SeasonPassMetaId = SeasonPassMetaId;
|
||||
to_copy_doc_attrib.Exp = Exp;
|
||||
to_copy_doc_attrib.Grade = Grade;
|
||||
to_copy_doc_attrib.IsChargedPass = IsChargedPass;
|
||||
to_copy_doc_attrib.takenRewards = takenRewards.Select(x => x).ToList();
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(SeasonPassDoc).Name;
|
||||
|
||||
var season_pass_doc_base = docBase as SeasonPassDoc;
|
||||
if (null == season_pass_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, season_pass_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<SeasonPassAttribute>(season_pass_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = season_pass_doc_base.getAttrib<SeasonPassAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_attrib, () => $"doc_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
SeasonPassMetaId = doc_attrib.SeasonPassMetaId;
|
||||
Exp = doc_attrib.Exp;
|
||||
Grade = doc_attrib.Grade;
|
||||
IsChargedPass = doc_attrib.IsChargedPass;
|
||||
takenRewards = doc_attrib.takenRewards.Select(x => x).ToList();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onFillCommonResult(EntityCommonResult commonResult, EntityAttributeBase origin, QueryBatchBase? queryBatch = null)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var before = origin as SeasonPassAttribute;
|
||||
NullReferenceCheckHelper.throwIfNull(before, () => $"before is null !!! - {owner.toBasicString()}");
|
||||
var after = this as SeasonPassAttribute;
|
||||
NullReferenceCheckHelper.throwIfNull(after, () => $"after is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var recorder = after.getEntityRecorder();
|
||||
NullReferenceCheckHelper.throwIfNull(recorder, () => $"recorder is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var exp_result = commonResult.Exp;
|
||||
NullReferenceCheckHelper.throwIfNull(exp_result, () => $"exp_result is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var season_pass_meta_id = after.SeasonPassMetaId;
|
||||
|
||||
var target_types = EnumHelper.getValuesBeginEndBetweenWord<EntityDeltaType>("SeasonPass_");
|
||||
foreach (var type in target_types)
|
||||
{
|
||||
var found_delta_counter = recorder.findDeltaCounter(type);
|
||||
if (null != found_delta_counter)
|
||||
{
|
||||
var delta_value = (Int32)found_delta_counter.getDeltaCount();
|
||||
|
||||
var level_exp_type = (Int32)LevelExpType.SeasonPass;
|
||||
if (false == exp_result.LevelExps.TryGetValue(level_exp_type, out var found_level_by_id))
|
||||
{
|
||||
found_level_by_id = new LevelExpById();
|
||||
exp_result.LevelExps.Add(level_exp_type, found_level_by_id);
|
||||
}
|
||||
if (false == found_level_by_id.LevelExpsByMetaId.TryGetValue(season_pass_meta_id, out var found_level))
|
||||
{
|
||||
found_level = new LevelExp();
|
||||
found_level_by_id.LevelExpsByMetaId.Add(season_pass_meta_id, found_level);
|
||||
}
|
||||
|
||||
if (false == exp_result.LevelExpDeltas.TryGetValue(level_exp_type, out var found_exp_delta_amount_by_meta_id))
|
||||
{
|
||||
found_exp_delta_amount_by_meta_id = new LevelExpDeltaAmountById();
|
||||
exp_result.LevelExpDeltas.Add(level_exp_type, found_exp_delta_amount_by_meta_id);
|
||||
}
|
||||
if (false == found_exp_delta_amount_by_meta_id.DeltasByMetaId.TryGetValue(season_pass_meta_id, out var found_exp_delta_amount))
|
||||
{
|
||||
found_exp_delta_amount = new LevelExpDeltaAmount();
|
||||
found_exp_delta_amount_by_meta_id.DeltasByMetaId.Add(season_pass_meta_id, found_exp_delta_amount);
|
||||
}
|
||||
|
||||
if (EntityDeltaType.SeasonPassGrade == type)
|
||||
{
|
||||
found_level.Level = after.Grade;
|
||||
found_exp_delta_amount.LevelAmount = delta_value;
|
||||
appendOrWriteBusinessLog4SeasonPass(type, delta_value, (UInt32)after.Grade, queryBatch);
|
||||
}
|
||||
else if (EntityDeltaType.SeasonPassExp == type)
|
||||
{
|
||||
found_level.ExpInTotal = after.Exp;
|
||||
found_exp_delta_amount.ExpDeltaType = AmountDeltaType.Merge;
|
||||
found_exp_delta_amount.ExpAmount = delta_value;
|
||||
appendOrWriteBusinessLog4SeasonPass(type, delta_value, after.Exp, queryBatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void appendOrWriteBusinessLog4SeasonPass( EntityDeltaType entityDeltaType, int deltaCount, UInt32 amount
|
||||
, QueryBatchBase? queryBatch = null )
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var season_pass_log_data = new SeasonPassLogData();
|
||||
switch (entityDeltaType)
|
||||
{
|
||||
case EntityDeltaType.SeasonPassGrade:
|
||||
season_pass_log_data.Grade = (int)amount;
|
||||
season_pass_log_data.DeltaGrade = deltaCount;
|
||||
break;
|
||||
case EntityDeltaType.SeasonPassExp:
|
||||
season_pass_log_data.Exp = amount;
|
||||
season_pass_log_data.DeltaExp = deltaCount;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
var season_pass_business_log = new SeasonPassBusinessLog(season_pass_log_data);
|
||||
|
||||
if (null != queryBatch)
|
||||
{
|
||||
queryBatch.appendBusinessLog(season_pass_business_log);
|
||||
}
|
||||
else
|
||||
{
|
||||
var log_actor = owner as IWithLogActor;
|
||||
NullReferenceCheckHelper.throwIfNull(log_actor, () => $"log_actor is null !!! - {owner.toBasicString()}");
|
||||
|
||||
BusinessLogger.collectLog(log_actor, season_pass_business_log);
|
||||
}
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var season_pass_attribute = otherEntityAttribute as SeasonPassAttribute;
|
||||
if (null == season_pass_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast SeasonPassAttribute !!!, season_pass_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SeasonPassMetaId = season_pass_attribute.SeasonPassMetaId;
|
||||
Exp = season_pass_attribute.Exp;
|
||||
Grade = season_pass_attribute.Grade;
|
||||
IsChargedPass = season_pass_attribute.IsChargedPass;
|
||||
takenRewards = season_pass_attribute.takenRewards.Select(x => x).ToList();
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = season_pass_attribute.getTryPendingDocBase() as SeasonPassDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
season_pass_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<SeasonPassAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<SeasonPassAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var season_pass_attrib = origin_doc_base.getAttrib<SeasonPassAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(season_pass_attrib, () => $"season_pass_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
season_pass_attrib.SeasonPassMetaId = SeasonPassMetaId;
|
||||
season_pass_attrib.Exp = Exp;
|
||||
season_pass_attrib.Grade = Grade;
|
||||
season_pass_attrib.IsChargedPass = IsChargedPass;
|
||||
season_pass_attrib.takenRewards = takenRewards.Select(x => x).ToList();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class SeasonPassAttributeTransactor : EntityAttributeTransactorBase<SeasonPassAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public SeasonPassAttributeTransactor(UserBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(SeasonPassAttribute).Name;
|
||||
|
||||
var copy_from_season_pass_attribute = entityAttributeBase as SeasonPassAttribute;
|
||||
if (null == copy_from_season_pass_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_season_pass_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_season_pass_attribute = getClonedEntityAttribute() as SeasonPassAttribute;
|
||||
if (null == copy_to_season_pass_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_season_pass_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_season_pass_attribute.SeasonPassMetaId = copy_from_season_pass_attribute.SeasonPassMetaId;
|
||||
copy_to_season_pass_attribute.Exp = copy_from_season_pass_attribute.Exp;
|
||||
copy_to_season_pass_attribute.Grade = copy_from_season_pass_attribute.Grade;
|
||||
copy_to_season_pass_attribute.IsChargedPass = copy_from_season_pass_attribute.IsChargedPass;
|
||||
copy_to_season_pass_attribute.takenRewards = copy_from_season_pass_attribute.takenRewards.Select(x => x).ToList();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,358 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
using Amazon.S3.Model;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class ShopProductTradingMeterSubAttribute
|
||||
{
|
||||
[JsonProperty("product_id")]
|
||||
public int ProductId { get; set; }
|
||||
|
||||
[JsonProperty("left_count")]
|
||||
public double LeftCount { get; set; }
|
||||
}
|
||||
|
||||
public class ShopProductTradingMeterAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
private readonly USER_GUID m_user_guid;
|
||||
|
||||
[JsonProperty]
|
||||
public int ShopId { get; set; }
|
||||
|
||||
[JsonProperty] public Timestamp EndTime { get; set; } = DateTimeHelper.MinTime.ToTimestamp();
|
||||
|
||||
[JsonProperty]
|
||||
public List<ShopProductTradingMeterSubAttribute> ShopProductTradingMeterSubs { get; private set; } = new();
|
||||
|
||||
[JsonProperty] public Int32 CurrentRenewalCount { get; private set; } = 0;
|
||||
|
||||
public ShopProductTradingMeterAttribute( EntityBase owner, USER_GUID user_guid
|
||||
, EntityBase entityOfOwnerEntityType )
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
m_user_guid = user_guid;
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
ShopId = 0;
|
||||
EndTime = DateTimeHelper.MinTime.ToTimestamp();
|
||||
ShopProductTradingMeterSubs.Clear();
|
||||
CurrentRenewalCount = 0;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner_entity_type = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(owner_entity_type, () => $"owner_entity_type is null !!!");
|
||||
|
||||
var cloned = new ShopProductTradingMeterAttribute( getOwner()
|
||||
, m_user_guid, owner_entity_type)
|
||||
{
|
||||
ShopId = ShopId,
|
||||
EndTime = EndTime,
|
||||
CurrentRenewalCount = CurrentRenewalCount
|
||||
};
|
||||
|
||||
foreach (var sub in ShopProductTradingMeterSubs)
|
||||
{
|
||||
var data = new ShopProductTradingMeterSubAttribute
|
||||
{
|
||||
ProductId = sub.ProductId,
|
||||
LeftCount = sub.LeftCount
|
||||
};
|
||||
|
||||
cloned.ShopProductTradingMeterSubs.Add(data);
|
||||
}
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new ShopProductTradingMeterAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as ShopProductTradingMeterDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new ShopProductTradingMeterDoc(m_user_guid, ShopId);
|
||||
|
||||
var origin_doc = getOriginDocBase<ShopProductTradingMeterAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
to_copy_doc.onApplyPKSK();
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<ShopProductTradingMeterAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!!");
|
||||
|
||||
to_copy_doc_attrib.onClear();
|
||||
to_copy_doc_attrib.ShopId = ShopId;
|
||||
to_copy_doc_attrib.EndTime = EndTime;
|
||||
to_copy_doc_attrib.CurrentRenewalCount = CurrentRenewalCount;
|
||||
foreach (var sub in ShopProductTradingMeterSubs)
|
||||
{
|
||||
to_copy_doc_attrib.ShopProductTradingMeterSubs.Add(new ShopProductTradingMeterSubAttrib
|
||||
{
|
||||
ProductId = sub.ProductId,
|
||||
LeftCount = sub.LeftCount
|
||||
});
|
||||
}
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
string err_msg;
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var other_shop_product_trading_meter_attribute = otherEntityAttribute as ShopProductTradingMeterAttribute;
|
||||
if (null == other_shop_product_trading_meter_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast ShopProductTradingMeterAttribute !!!, other_shop_product_trading_meter_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
onClear();
|
||||
|
||||
ShopId = other_shop_product_trading_meter_attribute.ShopId;
|
||||
EndTime = other_shop_product_trading_meter_attribute.EndTime;
|
||||
CurrentRenewalCount = other_shop_product_trading_meter_attribute.CurrentRenewalCount;
|
||||
foreach (var subAttribute in other_shop_product_trading_meter_attribute.ShopProductTradingMeterSubs)
|
||||
{
|
||||
var data = new ShopProductTradingMeterSubAttribute();
|
||||
data.ProductId = subAttribute.ProductId;
|
||||
data.LeftCount = subAttribute.LeftCount;
|
||||
ShopProductTradingMeterSubs.Add(data);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_shop_product_trading_meter_attribute.getTryPendingDocBase() as ShopProductTradingMeterDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_shop_product_trading_meter_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<ShopProductTradingMeterAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<ShopProductTradingMeterAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var shop_product_trading_meter_attrib = origin_doc_base.getAttrib<ShopProductTradingMeterAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(shop_product_trading_meter_attrib, () => $"shop_product_trading_meter_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
shop_product_trading_meter_attrib.ShopId = ShopId;
|
||||
shop_product_trading_meter_attrib.EndTime = EndTime;
|
||||
shop_product_trading_meter_attrib.CurrentRenewalCount = CurrentRenewalCount;
|
||||
|
||||
foreach(var sub in ShopProductTradingMeterSubs)
|
||||
{
|
||||
var data = new ShopProductTradingMeterSubAttrib();
|
||||
data.ProductId = sub.ProductId;
|
||||
data.LeftCount = sub.LeftCount;
|
||||
|
||||
shop_product_trading_meter_attrib.ShopProductTradingMeterSubs.Add(data);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
if (docBase is not ShopProductTradingMeterDoc meterDoc)
|
||||
{
|
||||
var err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, shop_product_trading_meter_doc is null :{nameof(ShopProductTradingMeterDoc)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<ShopProductTradingMeterAttribute>(meterDoc);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var attr = meterDoc.getAttrib<ShopProductTradingMeterAttrib>();
|
||||
if (null == attr)
|
||||
{
|
||||
var err_msg = $"Failed to copyEntityAttributeFromDocs() !!!, not found doc attrib !!! :{toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
onClear();
|
||||
ShopId = attr.ShopId;
|
||||
EndTime = attr.EndTime;
|
||||
CurrentRenewalCount = attr.CurrentRenewalCount;
|
||||
foreach (var meter in attr.ShopProductTradingMeterSubs)
|
||||
{
|
||||
var info = new ShopProductTradingMeterSubAttribute
|
||||
{
|
||||
ProductId = meter.ProductId,
|
||||
LeftCount = meter.LeftCount
|
||||
};
|
||||
|
||||
ShopProductTradingMeterSubs.Add(info);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result changeProductTradingMeter(int product_id, int delta)
|
||||
{
|
||||
var result = new Result();
|
||||
string err_msg;
|
||||
|
||||
var meter = findMeter(product_id);
|
||||
if (null == meter)
|
||||
{
|
||||
err_msg = $"Failed to found product id: {product_id}";
|
||||
result.setFail(ServerErrorCode.NotFoundProductId, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
var change = meter.LeftCount + delta;
|
||||
if (change < 0)
|
||||
{
|
||||
err_msg = $"Failed to change shop meter !!! : Invalid count - {meter.LeftCount} / {delta}";
|
||||
result.setFail(ServerErrorCode.InvalidArgument, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
meter.LeftCount += delta;
|
||||
return result;
|
||||
}
|
||||
|
||||
public ShopProductTradingMeterSubAttribute? getMeterSubAttribute(int product_id)
|
||||
=> ShopProductTradingMeterSubs.FirstOrDefault(sub => sub.ProductId == product_id);
|
||||
|
||||
public void initEndTime() => EndTime = Timestamp.FromDateTime(DateTime.UtcNow);
|
||||
|
||||
public void initRenewalCount() => CurrentRenewalCount = 0;
|
||||
|
||||
public void increaseRenewalCount(Int32 increaseCount = 1)
|
||||
{
|
||||
CurrentRenewalCount += increaseCount;
|
||||
}
|
||||
|
||||
public void setCurrentRenewalCount(Int32 currenctRenewalCount)
|
||||
{
|
||||
CurrentRenewalCount = currenctRenewalCount;
|
||||
}
|
||||
|
||||
private ShopProductTradingMeterSubAttribute? findMeter(int product_id) =>
|
||||
ShopProductTradingMeterSubs.FirstOrDefault(meter => meter.ProductId == product_id);
|
||||
}
|
||||
|
||||
public class ShopProductTradingMeterAttributeTransactor : EntityAttributeTransactorBase<ShopProductTradingMeterAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public ShopProductTradingMeterAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase entityAttributeBase)
|
||||
{
|
||||
string err_msg;
|
||||
|
||||
var copy_from_shop_product_trading_meter_attribute = entityAttributeBase as ShopProductTradingMeterAttribute;
|
||||
if (null == copy_from_shop_product_trading_meter_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_shop_product_trading_meter_attribute is null :{nameof(ShopProductTradingMeterAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_shop_product_trading_meter_attribute = getClonedEntityAttribute() as ShopProductTradingMeterAttribute;
|
||||
if (null == copy_to_shop_product_trading_meter_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_shop_product_trading_meter_attribute is null :{nameof(ShopProductTradingMeterAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_shop_product_trading_meter_attribute.onClear();
|
||||
copy_to_shop_product_trading_meter_attribute.ShopId = copy_from_shop_product_trading_meter_attribute.ShopId;
|
||||
copy_to_shop_product_trading_meter_attribute.EndTime = copy_from_shop_product_trading_meter_attribute.EndTime;
|
||||
copy_to_shop_product_trading_meter_attribute.setCurrentRenewalCount(copy_from_shop_product_trading_meter_attribute.CurrentRenewalCount);
|
||||
foreach (var subAttribute in copy_from_shop_product_trading_meter_attribute.ShopProductTradingMeterSubs)
|
||||
{
|
||||
var data = new ShopProductTradingMeterSubAttribute();
|
||||
data.ProductId = subAttribute.ProductId;
|
||||
data.LeftCount = subAttribute.LeftCount;
|
||||
copy_to_shop_product_trading_meter_attribute.ShopProductTradingMeterSubs.Add(data);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
196
ServerCommon/Entity/Attribute/SocialActionAttributeBase.cs
Normal file
196
ServerCommon/Entity/Attribute/SocialActionAttributeBase.cs
Normal file
@@ -0,0 +1,196 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
using META_ID = System.UInt32;
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public abstract class SocialActionAttributeBase : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public META_ID SocialActionMetaId { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public UInt16 EquipedPos { get; set; } = 0;
|
||||
|
||||
|
||||
public SocialActionAttributeBase(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
SocialActionMetaId = 0;
|
||||
EquipedPos = 0;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
|
||||
var user_attribute = owner.getRootParent().getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
USER_GUID user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as SocialActionDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = onCreateDocBase() as SocialActionDoc;
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc, () => $"to_copy_doc is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var origin_doc = getOriginDocBase<SocialActionAttributeBase>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var social_action_attrib = try_pending_doc.getAttrib<SocialActionAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(social_action_attrib, () => $"social_action_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
social_action_attrib.SocialActionMetaId = SocialActionMetaId;
|
||||
social_action_attrib.EquipedPos = EquipedPos;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(SocialActionDoc).Name;
|
||||
|
||||
var social_action_doc = docBase as SocialActionDoc;
|
||||
if (null == social_action_doc)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, social_action_doc is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<SocialActionAttributeBase>(social_action_doc);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = social_action_doc.getAttrib<SocialActionAttrib>();
|
||||
ArgumentNullException.ThrowIfNull(doc_attrib);
|
||||
|
||||
SocialActionMetaId = doc_attrib.SocialActionMetaId;
|
||||
EquipedPos = doc_attrib.EquipedPos;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var social_action_attribute = otherEntityAttribute as SocialActionAttributeBase;
|
||||
if (null == social_action_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast SocialActionAttribute !!!, social_action_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SocialActionMetaId = social_action_attribute.SocialActionMetaId;
|
||||
EquipedPos = social_action_attribute.EquipedPos;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = social_action_attribute.getTryPendingDocBase() as SocialActionDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
social_action_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<SocialActionAttributeBase>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<SocialActionAttributeBase>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var social_action_attrib = origin_doc_base.getAttrib<SocialActionAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(social_action_attrib, () => $"social_action_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
social_action_attrib.SocialActionMetaId = SocialActionMetaId;
|
||||
social_action_attrib.EquipedPos = EquipedPos;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class SocialActionAttributeBaseTransactor<TSocialActionAttributeBase> : EntityAttributeTransactorBase<TSocialActionAttributeBase>
|
||||
where TSocialActionAttributeBase : SocialActionAttributeBase
|
||||
{
|
||||
public SocialActionAttributeBaseTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
}
|
||||
220
ServerCommon/Entity/Attribute/SwitchingPropAttribute.cs
Normal file
220
ServerCommon/Entity/Attribute/SwitchingPropAttribute.cs
Normal file
@@ -0,0 +1,220 @@
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class SwitchingPropAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty()] public ConcurrentDictionary<Int32, Int32> m_switching_props { get; set; } = new();
|
||||
|
||||
public SwitchingPropAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
m_switching_props.Clear();
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var player = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(player, () => $"player is null !!!");
|
||||
|
||||
|
||||
var switching_prop_attribute = player.getEntityAttribute<SwitchingPropAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(switching_prop_attribute, () => $"switching_prop_attribute is null !!! - {player.toBasicString()}");
|
||||
|
||||
var user_attribute = player.getRootParent().getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {player.toBasicString()}");
|
||||
|
||||
USER_GUID user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as SwitchingPropDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new SwitchingPropDoc(user_guid);
|
||||
|
||||
var origin_doc = getOriginDocBase<SwitchingPropAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_attrib = try_pending_doc.getAttrib<SwitchingPropAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_attrib, () => $"SwitchingPropAttrib is null !!! - {player.toBasicString()}");
|
||||
|
||||
to_copy_attrib.m_switching_props.Clear();
|
||||
foreach (var prop in switching_prop_attribute.m_switching_props)
|
||||
{
|
||||
to_copy_attrib.m_switching_props.AddOrUpdate(prop.Key, prop.Value, (key, old) => prop.Value);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(var result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new SwitchingPropAttribute(getOwner());
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
foreach (var prop in m_switching_props)
|
||||
{
|
||||
Int32 prop_id = prop.Key;
|
||||
Int32 prop_state = prop.Value;
|
||||
|
||||
if (false == cloned.m_switching_props.TryAdd(prop_id, prop_state))
|
||||
{
|
||||
Log.getLogger().error($"SwitchingPropAttribute try add Fail!!! propid : {prop_id}, state : {prop_state}, player : {getOwner().toBasicString()}");
|
||||
}
|
||||
}
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (getAttributeState().hasFlag(StateType.Removed))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
var player = getOwner();
|
||||
|
||||
|
||||
var other_attribute = otherEntityAttribute as SwitchingPropAttribute;
|
||||
if (null == other_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast SwitchingPropAttribute !!!, other_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
foreach (var prop in other_attribute.m_switching_props)
|
||||
{
|
||||
m_switching_props.TryAdd(prop.Key, prop.Value);
|
||||
}
|
||||
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_attribute.getTryPendingDocBase() as SwitchingPropDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<SwitchingPropAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<SwitchingPropAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var switching_prop_attrib = origin_doc_base.getAttrib<SwitchingPropAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(switching_prop_attrib, () => $"switching_prop_attrib is null !!! - {player.toBasicString()}");
|
||||
|
||||
switching_prop_attrib.m_switching_props.Clear();
|
||||
foreach (var prop in m_switching_props)
|
||||
{
|
||||
switching_prop_attrib.m_switching_props.AddOrUpdate(prop.Key, prop.Value, (key, old) => prop.Value);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase customDoc)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(SwitchingPropDoc).Name;
|
||||
|
||||
var switching_prop_doc = customDoc as SwitchingPropDoc;
|
||||
if (null == switching_prop_doc)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, switching_prop_doc is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<SwitchingPropAttribute>(switching_prop_doc);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var switching_prop_attrib = switching_prop_doc.getAttrib<SwitchingPropAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(switching_prop_attrib, () => $"switching_prop_attrib is null !!!");
|
||||
|
||||
foreach (var prop in switching_prop_attrib.m_switching_props)
|
||||
{
|
||||
m_switching_props.AddOrUpdate(prop.Key, prop.Value, (key, old) => prop.Value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new SwitchingPropTransactor(getOwner());
|
||||
}
|
||||
}
|
||||
|
||||
public class SwitchingPropTransactor : EntityAttributeTransactorBase<SwitchingPropAttribute>
|
||||
{
|
||||
public SwitchingPropTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorBaseFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
289
ServerCommon/Entity/Attribute/SystemMetaMailAttribute.cs
Normal file
289
ServerCommon/Entity/Attribute/SystemMetaMailAttribute.cs
Normal file
@@ -0,0 +1,289 @@
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
using MAIL_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
|
||||
public class SystemMetaMailAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty("mail_id")]
|
||||
public Int32 MailId { get; set; } = 0;
|
||||
|
||||
[JsonProperty("sender_nickname")]
|
||||
public List<OperationSystemMessage> SenderNickName { get; set; } = new();
|
||||
|
||||
[JsonProperty("title")]
|
||||
public List<OperationSystemMessage> Title { get; set; } = new();
|
||||
|
||||
[JsonProperty("text")]
|
||||
public List<OperationSystemMessage> Text { get; set; } = new();
|
||||
|
||||
[JsonProperty("start_time")]
|
||||
public DateTime StartTime { get; set; } = new();
|
||||
|
||||
[JsonProperty("end_time")]
|
||||
public DateTime EndTime { get; set; } = new();
|
||||
|
||||
[JsonProperty("item_list")]
|
||||
public List<MailItem> ItemList { get; set; } = new();
|
||||
|
||||
|
||||
public SystemMetaMailAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
MailId = 0;
|
||||
SenderNickName = new();
|
||||
Title = new();
|
||||
Text = new();
|
||||
StartTime = new();
|
||||
EndTime = new();
|
||||
ItemList = new List<MailItem>();
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new SystemMailAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new SystemMetaMailAttribute(getOwner());
|
||||
cloned.MailId = MailId;
|
||||
cloned.SenderNickName = SenderNickName;
|
||||
cloned.Title = Title;
|
||||
cloned.Text = Text;
|
||||
cloned.StartTime = StartTime;
|
||||
cloned.EndTime = EndTime;
|
||||
cloned.ItemList = ItemList.Select(x => new MailItem() { ItemId = x.ItemId, Count = x.Count }).ToList();
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var result = new Result();
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as SystemMetaMailDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new SystemMetaMailDoc(MailId.ToString());
|
||||
|
||||
var origin_doc = getOriginDocBase<SystemMetaMailAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var system_meta_mail_attrib = try_pending_doc.getAttrib<SystemMetaMailAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(system_meta_mail_attrib, () => $"system_meta_mail_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
system_meta_mail_attrib.MailId = MailId;
|
||||
system_meta_mail_attrib.SenderNickName = SenderNickName;
|
||||
system_meta_mail_attrib.Title = Title;
|
||||
system_meta_mail_attrib.Text = Text;
|
||||
system_meta_mail_attrib.StartTime = StartTime;
|
||||
system_meta_mail_attrib.EndTime = EndTime;
|
||||
system_meta_mail_attrib.ItemList = ItemList.Select(x => new MailItem() { ItemId = x.ItemId, Count = x.Count }).ToList();
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var owner = getOwner();
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(SystemMetaMailDoc).Name;
|
||||
|
||||
var system_meta_mail_doc = docBase as SystemMetaMailDoc;
|
||||
if (null == system_meta_mail_doc)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, system_meta_mail_doc is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<SystemMetaMailAttribute>(system_meta_mail_doc);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var system_meta_mail_attrib = system_meta_mail_doc.getAttrib<SystemMetaMailAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(system_meta_mail_attrib, () => $"system_meta_mail_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
if (system_meta_mail_attrib == null)
|
||||
{
|
||||
err_msg = $"Failed to get system mail attrib : {nameof(SystemMetaMailAttrib)}";
|
||||
result.setFail(ServerErrorCode.EntityAttributeIsNull, err_msg);
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
MailId = system_meta_mail_attrib.MailId;
|
||||
SenderNickName = system_meta_mail_attrib.SenderNickName;
|
||||
Title = system_meta_mail_attrib.Title;
|
||||
Text = system_meta_mail_attrib.Text;
|
||||
StartTime = system_meta_mail_attrib.StartTime;
|
||||
EndTime = system_meta_mail_attrib.EndTime;
|
||||
ItemList = system_meta_mail_attrib.ItemList.Select(x => new MailItem() { ItemId = x.ItemId, Count = x.Count }).ToList();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var system_mail_attribute = otherEntityAttribute as SystemMetaMailAttribute;
|
||||
if (null == system_mail_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast SystemMailAttribute !!!, system_mail_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
MailId = MailId;
|
||||
SenderNickName = system_mail_attribute.SenderNickName;
|
||||
Title = system_mail_attribute.Title;
|
||||
Text = system_mail_attribute.Text;
|
||||
StartTime = system_mail_attribute.StartTime;
|
||||
EndTime = system_mail_attribute.EndTime;
|
||||
ItemList = system_mail_attribute.ItemList.Select(x => new MailItem() { ItemId = x.ItemId, Count = x.Count }).ToList();
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = system_mail_attribute.getTryPendingDocBase() as SystemMetaMailDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
system_mail_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<SystemMetaMailAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<SystemMetaMailAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var system_meta_mail_attrib = origin_doc_base.getAttrib<SystemMetaMailAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(system_meta_mail_attrib, () => $"system_meta_mail_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
system_meta_mail_attrib.MailId = MailId;
|
||||
system_meta_mail_attrib.SenderNickName = SenderNickName;
|
||||
system_meta_mail_attrib.Title = Title;
|
||||
system_meta_mail_attrib.Text = Text;
|
||||
system_meta_mail_attrib.StartTime = StartTime;
|
||||
system_meta_mail_attrib.EndTime = EndTime;
|
||||
system_meta_mail_attrib.ItemList = ItemList.Select(x => new MailItem() { ItemId = x.ItemId, Count = x.Count }).ToList();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class SystemMailAttributeTransactor : EntityAttributeTransactorBase<SystemMetaMailAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public SystemMailAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(SystemMetaMailAttribute).Name;
|
||||
|
||||
var copy_from_system_mail_attribute = entityAttributeBase as SystemMetaMailAttribute;
|
||||
if (null == copy_from_system_mail_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_system_mail_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_system_mail_attribute = getClonedEntityAttribute() as SystemMetaMailAttribute;
|
||||
if (null == copy_to_system_mail_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_system_mail_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_system_mail_attribute.MailId = copy_from_system_mail_attribute.MailId;
|
||||
copy_to_system_mail_attribute.SenderNickName = copy_from_system_mail_attribute.SenderNickName;
|
||||
copy_to_system_mail_attribute.Title = copy_from_system_mail_attribute.Title;
|
||||
copy_to_system_mail_attribute.Text = copy_from_system_mail_attribute.Text;
|
||||
copy_to_system_mail_attribute.StartTime = copy_from_system_mail_attribute.StartTime;
|
||||
copy_to_system_mail_attribute.EndTime = copy_from_system_mail_attribute.EndTime;
|
||||
copy_to_system_mail_attribute.ItemList = copy_from_system_mail_attribute.ItemList.Select(x => new MailItem() { ItemId = x.ItemId, Count = x.Count}).ToList();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
258
ServerCommon/Entity/Attribute/TaskReservationAttribute.cs
Normal file
258
ServerCommon/Entity/Attribute/TaskReservationAttribute.cs
Normal file
@@ -0,0 +1,258 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
using RESERVATION_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class TaskReservationAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public RESERVATION_GUID ReservationGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public TaskReservationActionType ReservationType { get; set; } = TaskReservationActionType.None;
|
||||
|
||||
[JsonProperty]
|
||||
public string JsonValue { get; set; } = string.Empty;
|
||||
|
||||
public TaskReservationAttribute(EntityBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
ReservationGuid = string.Empty;
|
||||
ReservationType = TaskReservationActionType.None;
|
||||
JsonValue = string.Empty;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
var user_base = getOwner().getRootParent() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(user_base, () => $"user_base is null !!!");
|
||||
|
||||
return new TaskReservationAttributeTransactor(user_base);
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var user_base = getOwner().getRootParent() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(user_base, () => $"user_base is null !!!");
|
||||
|
||||
var entity_type = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(entity_type, () => "Entity Type is null");
|
||||
|
||||
var cloned = new TaskReservationAttribute(user_base, entity_type);
|
||||
cloned.ReservationGuid = ReservationGuid;
|
||||
cloned.ReservationType = ReservationType;
|
||||
cloned.JsonValue = JsonValue;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner().getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var acoount_attribute = owner.getEntityAttribute<AccountAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(acoount_attribute, () => $"acoount_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
USER_GUID user_guid = acoount_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as TaskReservationDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new TaskReservationDoc(user_guid, ReservationGuid);
|
||||
|
||||
var origin_doc = getOriginDocBase<TaskReservationAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var take_reservation_attrib = try_pending_doc.getAttrib<TaskReservationAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(take_reservation_attrib, () => $"take_reservation_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
take_reservation_attrib.ReservationGuid = ReservationGuid;
|
||||
take_reservation_attrib.ReservationType = ReservationType;
|
||||
take_reservation_attrib.JsonValue = JsonValue;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var root_parent = getOwner().getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(root_parent, () => $"root_parent is null !!!");
|
||||
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(TaskReservationDoc).Name;
|
||||
|
||||
var task_reservation_doc_base = docBase as TaskReservationDoc;
|
||||
if (null == task_reservation_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, task_reservation_doc_base is null : {to_cast_string} - {root_parent.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<TaskReservationAttribute>(task_reservation_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var task_reservation_attrib = task_reservation_doc_base.getAttrib<TaskReservationAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(task_reservation_attrib, () => $"task_reservation_attrib is null !!! - {root_parent.toBasicString()}");
|
||||
|
||||
ReservationGuid = task_reservation_attrib.ReservationGuid;
|
||||
ReservationType = task_reservation_attrib.ReservationType;
|
||||
JsonValue = task_reservation_attrib.JsonValue;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var task_reservation_attribute = otherEntityAttribute as TaskReservationAttribute;
|
||||
if (null == task_reservation_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast TaskReservationAttribute !!!, task_reservation_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ReservationGuid = task_reservation_attribute.ReservationGuid;
|
||||
ReservationType = task_reservation_attribute.ReservationType;
|
||||
JsonValue = task_reservation_attribute.JsonValue;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = task_reservation_attribute.getTryPendingDocBase() as TaskReservationDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
task_reservation_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<TaskReservationAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<TaskReservationAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var task_reservation_attrib = origin_doc_base.getAttrib<TaskReservationAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(task_reservation_attrib, () => $"task_reservation_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
task_reservation_attrib.ReservationGuid = ReservationGuid;
|
||||
task_reservation_attrib.ReservationType = ReservationType;
|
||||
task_reservation_attrib.JsonValue = JsonValue;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class TaskReservationAttributeTransactor : EntityAttributeTransactorBase<TaskReservationAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public TaskReservationAttributeTransactor(UserBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(TaskReservationAttribute).Name;
|
||||
|
||||
var copy_from_attribute = entityAttributeBase as TaskReservationAttribute;
|
||||
if (null == copy_from_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_attribute = getClonedEntityAttribute() as TaskReservationAttribute;
|
||||
if (null == copy_to_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_attribute.ReservationGuid = copy_from_attribute.ReservationGuid;
|
||||
copy_to_attribute.ReservationType = copy_from_attribute.ReservationType;
|
||||
copy_to_attribute.JsonValue = copy_from_attribute.JsonValue;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
290
ServerCommon/Entity/Attribute/ToolActionAttribute.cs
Normal file
290
ServerCommon/Entity/Attribute/ToolActionAttribute.cs
Normal file
@@ -0,0 +1,290 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
using Amazon.S3.Model;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class ToolActionAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public ITEM_GUID ItemGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public META_ID ItemMetaId { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public Int32 Step { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public Int32 RandomState { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public Int64 ActionStartDateTime { get; set; } = 0;
|
||||
|
||||
public ToolActionAttribute(EntityBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
ItemGuid = string.Empty;
|
||||
ItemMetaId = 0;
|
||||
Step = 0;
|
||||
RandomState = 0;
|
||||
ActionStartDateTime = 0;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var parent = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!!");
|
||||
|
||||
var cloned = new ToolActionAttribute(owner, parent);
|
||||
cloned.ItemGuid = ItemGuid;
|
||||
cloned.ItemMetaId = ItemMetaId;
|
||||
cloned.Step = Step;
|
||||
cloned.RandomState = RandomState;
|
||||
cloned.ActionStartDateTime = ActionStartDateTime;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
return new ToolActionAttributeTransactor(owner);
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var root_parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(root_parent, () => $"root_parent is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var user_attribute = root_parent.getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {root_parent.toBasicString()}");
|
||||
|
||||
USER_GUID user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as ToolActionDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new ToolActionDoc(OwnerEntityType.User, user_guid, ItemMetaId);
|
||||
|
||||
var origin_doc = getOriginDocBase<ToolActionAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_tool_action_attrib = try_pending_doc.getAttrib<ToolActionAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_tool_action_attrib, () => $"to_copy_doc_tool_action_attrib is null !!! - {root_parent.toBasicString()}");
|
||||
|
||||
to_copy_doc_tool_action_attrib.ItemGuid = ItemGuid;
|
||||
to_copy_doc_tool_action_attrib.ItemMetaId = ItemMetaId;
|
||||
to_copy_doc_tool_action_attrib.Step = Step;
|
||||
to_copy_doc_tool_action_attrib.RandomState = RandomState;
|
||||
to_copy_doc_tool_action_attrib.ActionStartDateTime = ActionStartDateTime;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var tool_action_attribute = otherEntityAttribute as ToolActionAttribute;
|
||||
if (null == tool_action_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast ToolActionAttribute !!!, tool_action_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ItemGuid = tool_action_attribute.ItemGuid;
|
||||
ItemMetaId = tool_action_attribute.ItemMetaId;
|
||||
Step = tool_action_attribute.Step;
|
||||
RandomState = tool_action_attribute.RandomState;
|
||||
ActionStartDateTime = tool_action_attribute.ActionStartDateTime;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = tool_action_attribute.getTryPendingDocBase() as ToolActionDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
tool_action_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<ToolActionAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<ToolActionAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var tool_action_attrib = origin_doc_base.getAttrib<ToolActionAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(tool_action_attrib, () => $"tool_action_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
tool_action_attrib.ItemGuid = ItemGuid;
|
||||
tool_action_attrib.ItemMetaId = ItemMetaId;
|
||||
tool_action_attrib.Step = Step;
|
||||
tool_action_attrib.RandomState = RandomState;
|
||||
tool_action_attrib.ActionStartDateTime = ActionStartDateTime;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var root_parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(root_parent, () => $"root_parent is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var to_cast_string = typeof(ToolActionDoc).Name;
|
||||
|
||||
var tool_action_doc_base = docBase as ToolActionDoc;
|
||||
if (null == tool_action_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, tool_action_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<ToolActionAttribute>(tool_action_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var tool_action_attrib = tool_action_doc_base.getAttrib<ToolActionAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(tool_action_attrib, () => $"tool_action_attrib is null !!! - {root_parent.toBasicString()}");
|
||||
|
||||
ItemGuid = tool_action_attrib.ItemGuid;
|
||||
ItemMetaId = tool_action_attrib.ItemMetaId;
|
||||
Step = tool_action_attrib.Step;
|
||||
RandomState = tool_action_attrib.RandomState;
|
||||
ActionStartDateTime = tool_action_attrib.ActionStartDateTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class ToolActionAttributeTransactor : EntityAttributeTransactorBase<ToolActionAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public ToolActionAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(ToolActionAttribute).Name;
|
||||
|
||||
var copy_from_tool_action_attribute = entityAttributeBase as ToolActionAttribute;
|
||||
if (null == copy_from_tool_action_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_tool_action_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_tool_action_attribute = getClonedEntityAttribute() as ToolActionAttribute;
|
||||
if (null == copy_to_tool_action_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_tool_action_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_tool_action_attribute.ItemGuid = copy_from_tool_action_attribute.ItemGuid;
|
||||
copy_to_tool_action_attribute.ItemMetaId = copy_from_tool_action_attribute.ItemMetaId;
|
||||
copy_to_tool_action_attribute.Step = copy_from_tool_action_attribute.Step;
|
||||
copy_to_tool_action_attribute.RandomState = copy_from_tool_action_attribute.RandomState;
|
||||
copy_to_tool_action_attribute.ActionStartDateTime = copy_from_tool_action_attribute.ActionStartDateTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
422
ServerCommon/Entity/Attribute/UgcNpcAttribute.cs
Normal file
422
ServerCommon/Entity/Attribute/UgcNpcAttribute.cs
Normal file
@@ -0,0 +1,422 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using UGC_NPC_META_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
using ANCHOR_META_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class UgcNpcAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public UGC_NPC_META_GUID UgcNpcMetaGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public string Nickname { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public string Greeting { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public string Introduction { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public string WorldScenario { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public META_ID DefaultSocialActionMetaId { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public List<META_ID> HabitSocialActionMetaIds { get; set; } = new List<META_ID>();
|
||||
|
||||
[JsonProperty]
|
||||
public List<META_ID> DialogueSocialActionMetaIds { get; set; } = new List<META_ID>() { 110054 };
|
||||
|
||||
[JsonProperty]
|
||||
public META_ID BodyItemMetaId { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public List<META_ID> HashTagMetaIds { get; set; } = new();
|
||||
|
||||
[JsonProperty]
|
||||
public OwnerEntityType OwnerEntityType { get; set; } = OwnerEntityType.None;
|
||||
|
||||
[JsonProperty]
|
||||
public OWNER_GUID OwnerGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public LanguageType LanguageType { get; set; } = LanguageType.None;
|
||||
|
||||
[JsonProperty]
|
||||
public EntityStateType State { get; set; } = EntityStateType.None;
|
||||
|
||||
[JsonProperty]
|
||||
public ANCHOR_META_GUID AnchorMetaGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public META_ID MetaIdOfEntityStateType { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public string LocatedInstanceGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public META_ID LocatedInstanceMetaId { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public bool IsRegisteredAiChatServer { get; set; } = false;
|
||||
|
||||
private EntityPos m_current_pos = new();
|
||||
|
||||
public UgcNpcAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void newEntityAttribute()
|
||||
{
|
||||
UgcNpcMetaGuid = System.Guid.NewGuid().ToString("N");
|
||||
base.newEntityAttribute();
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
UgcNpcMetaGuid = string.Empty;
|
||||
Nickname = string.Empty;
|
||||
Title = string.Empty;
|
||||
Greeting = string.Empty;
|
||||
Introduction = string.Empty;
|
||||
Description = string.Empty;
|
||||
WorldScenario = string.Empty;
|
||||
DefaultSocialActionMetaId = 0;
|
||||
HabitSocialActionMetaIds.Clear();
|
||||
DialogueSocialActionMetaIds.Clear();
|
||||
BodyItemMetaId = 0;
|
||||
HashTagMetaIds.Clear();
|
||||
|
||||
OwnerEntityType = OwnerEntityType.None;
|
||||
OwnerGuid = string.Empty;
|
||||
LanguageType = LanguageType.None;
|
||||
AnchorMetaGuid = string.Empty;
|
||||
State = EntityStateType.None;
|
||||
LocatedInstanceGuid = string.Empty;
|
||||
LocatedInstanceMetaId = 0;
|
||||
|
||||
IsRegisteredAiChatServer = false;
|
||||
|
||||
m_current_pos = new();
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var cloned = new UgcNpcAttribute(owner);
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.UgcNpcMetaGuid = UgcNpcMetaGuid;
|
||||
cloned.Nickname = Nickname;
|
||||
cloned.Title = Title;
|
||||
cloned.Greeting = Greeting;
|
||||
cloned.Introduction = Introduction;
|
||||
cloned.Description = Description;
|
||||
cloned.WorldScenario = WorldScenario;
|
||||
cloned.DefaultSocialActionMetaId = DefaultSocialActionMetaId;
|
||||
cloned.HabitSocialActionMetaIds = HabitSocialActionMetaIds.Select(x => x).ToList();
|
||||
cloned.DialogueSocialActionMetaIds = DialogueSocialActionMetaIds.Select(x => x).ToList();
|
||||
cloned.BodyItemMetaId = BodyItemMetaId;
|
||||
cloned.HashTagMetaIds = HashTagMetaIds.Select(x => x).ToList();
|
||||
|
||||
cloned.OwnerEntityType = OwnerEntityType;
|
||||
cloned.OwnerGuid = OwnerGuid;
|
||||
cloned.LanguageType = LanguageType;
|
||||
cloned.State = State;
|
||||
cloned.AnchorMetaGuid = AnchorMetaGuid;
|
||||
cloned.MetaIdOfEntityStateType = MetaIdOfEntityStateType;
|
||||
cloned.LocatedInstanceGuid = LocatedInstanceGuid;
|
||||
cloned.LocatedInstanceMetaId = LocatedInstanceMetaId;
|
||||
|
||||
cloned.IsRegisteredAiChatServer = IsRegisteredAiChatServer;
|
||||
|
||||
cloned.m_current_pos = m_current_pos.clone();
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new UgcNpcAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as UgcNpcDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new UgcNpcDoc(OwnerEntityType, OwnerGuid, UgcNpcMetaGuid);
|
||||
|
||||
var origin_doc = getOriginDocBase<UgcNpcAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_ugc_npc_attrib = try_pending_doc.getAttrib<UgcNpcAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_ugc_npc_attrib, () => $"to_copy_doc_ugc_npc_attrib is null !!! - {owner.toBasicStringWithMaster()}");
|
||||
|
||||
to_copy_doc_ugc_npc_attrib.Nickname = Nickname;
|
||||
to_copy_doc_ugc_npc_attrib.Title = Title;
|
||||
to_copy_doc_ugc_npc_attrib.Greeting = Greeting;
|
||||
to_copy_doc_ugc_npc_attrib.Introduction = Introduction;
|
||||
to_copy_doc_ugc_npc_attrib.Description = Description;
|
||||
to_copy_doc_ugc_npc_attrib.WorldScenario = WorldScenario;
|
||||
to_copy_doc_ugc_npc_attrib.DefaultSocialActionMetaId = DefaultSocialActionMetaId;
|
||||
to_copy_doc_ugc_npc_attrib.HabitSocialActionMetaIds = HabitSocialActionMetaIds.Select(x => x).ToList();
|
||||
to_copy_doc_ugc_npc_attrib.DialogueSocialActionMetaIds = DialogueSocialActionMetaIds.Select(x => x).ToList();
|
||||
to_copy_doc_ugc_npc_attrib.BodyItemMetaId = BodyItemMetaId;
|
||||
to_copy_doc_ugc_npc_attrib.HashTagMetaIds = HashTagMetaIds.Select(x => x).ToList();
|
||||
|
||||
to_copy_doc_ugc_npc_attrib.OwnerEntityType = OwnerEntityType;
|
||||
to_copy_doc_ugc_npc_attrib.OwnerGuid = OwnerGuid;
|
||||
to_copy_doc_ugc_npc_attrib.LanguageType = LanguageType;
|
||||
to_copy_doc_ugc_npc_attrib.AnchorMetaGuid = AnchorMetaGuid;
|
||||
to_copy_doc_ugc_npc_attrib.MetaIdOfEntityStateType = MetaIdOfEntityStateType;
|
||||
to_copy_doc_ugc_npc_attrib.State = State;
|
||||
to_copy_doc_ugc_npc_attrib.LocatedInstanceGuid = LocatedInstanceGuid;
|
||||
to_copy_doc_ugc_npc_attrib.LocatedInstanceMetaId = LocatedInstanceMetaId;
|
||||
|
||||
to_copy_doc_ugc_npc_attrib.IsRegisteredAiChatServer = IsRegisteredAiChatServer;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Origin Attribute
|
||||
//=====================================================================================
|
||||
var other_ugc_npc_attribute = otherEntityAttribute as UgcNpcAttribute;
|
||||
if (null == other_ugc_npc_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast ItemAttribute !!!, other_item_attribute is null - {owner.toBasicStringWithMaster()}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
UgcNpcMetaGuid = other_ugc_npc_attribute.UgcNpcMetaGuid;
|
||||
Nickname = other_ugc_npc_attribute.Nickname;
|
||||
Title = other_ugc_npc_attribute.Title;
|
||||
Greeting = other_ugc_npc_attribute.Greeting;
|
||||
Introduction = other_ugc_npc_attribute.Introduction;
|
||||
Description = other_ugc_npc_attribute.Description;
|
||||
WorldScenario = other_ugc_npc_attribute.WorldScenario;
|
||||
DefaultSocialActionMetaId = other_ugc_npc_attribute.DefaultSocialActionMetaId;
|
||||
HabitSocialActionMetaIds = other_ugc_npc_attribute.HabitSocialActionMetaIds.Select(x => x).ToList();
|
||||
DialogueSocialActionMetaIds = other_ugc_npc_attribute.DialogueSocialActionMetaIds.Select(x => x).ToList();
|
||||
BodyItemMetaId = other_ugc_npc_attribute.BodyItemMetaId;
|
||||
HashTagMetaIds = other_ugc_npc_attribute.HashTagMetaIds.Select(x => x).ToList();
|
||||
|
||||
OwnerEntityType = other_ugc_npc_attribute.OwnerEntityType;
|
||||
OwnerGuid = other_ugc_npc_attribute.OwnerGuid;
|
||||
LanguageType = other_ugc_npc_attribute.LanguageType;
|
||||
State = other_ugc_npc_attribute.State;
|
||||
AnchorMetaGuid = other_ugc_npc_attribute.AnchorMetaGuid;
|
||||
MetaIdOfEntityStateType = other_ugc_npc_attribute.MetaIdOfEntityStateType;
|
||||
LocatedInstanceGuid = other_ugc_npc_attribute.LocatedInstanceGuid;
|
||||
LocatedInstanceMetaId = other_ugc_npc_attribute.LocatedInstanceMetaId;
|
||||
|
||||
IsRegisteredAiChatServer = other_ugc_npc_attribute.IsRegisteredAiChatServer;
|
||||
|
||||
m_current_pos = other_ugc_npc_attribute.m_current_pos.clone();
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_ugc_npc_attribute.getTryPendingDocBase() as UgcNpcDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_ugc_npc_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<UgcNpcAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<UgcNpcAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var ugc_npc_attrib = origin_doc_base.getAttrib<UgcNpcAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(ugc_npc_attrib, () => $"ugc_npc_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
ugc_npc_attrib.UgcNpcMetaGuid = UgcNpcMetaGuid;
|
||||
ugc_npc_attrib.Nickname = Nickname;
|
||||
ugc_npc_attrib.Title = Title;
|
||||
ugc_npc_attrib.Greeting = Greeting;
|
||||
ugc_npc_attrib.Introduction = Introduction;
|
||||
ugc_npc_attrib.Description = Description;
|
||||
ugc_npc_attrib.WorldScenario = WorldScenario;
|
||||
ugc_npc_attrib.DefaultSocialActionMetaId = DefaultSocialActionMetaId;
|
||||
ugc_npc_attrib.HabitSocialActionMetaIds = HabitSocialActionMetaIds.Select(x => x).ToList();
|
||||
ugc_npc_attrib.DialogueSocialActionMetaIds = DialogueSocialActionMetaIds.Select(x => x).ToList();
|
||||
ugc_npc_attrib.BodyItemMetaId = BodyItemMetaId;
|
||||
ugc_npc_attrib.HashTagMetaIds = HashTagMetaIds.Select(x => x).ToList();
|
||||
|
||||
ugc_npc_attrib.OwnerEntityType = OwnerEntityType;
|
||||
ugc_npc_attrib.OwnerGuid = OwnerGuid;
|
||||
ugc_npc_attrib.LanguageType = LanguageType;
|
||||
ugc_npc_attrib.State = State;
|
||||
ugc_npc_attrib.AnchorMetaGuid = AnchorMetaGuid;
|
||||
ugc_npc_attrib.MetaIdOfEntityStateType = MetaIdOfEntityStateType;
|
||||
ugc_npc_attrib.LocatedInstanceGuid = LocatedInstanceGuid;
|
||||
ugc_npc_attrib.LocatedInstanceMetaId = LocatedInstanceMetaId;
|
||||
|
||||
ugc_npc_attrib.IsRegisteredAiChatServer = IsRegisteredAiChatServer;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var to_cast_string = typeof(UgcNpcDoc).Name;
|
||||
|
||||
var ugc_npc_doc = docBase as UgcNpcDoc;
|
||||
if (null == ugc_npc_doc)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, ugc_npc_doc is null :{to_cast_string} - {owner.toBasicStringWithMaster()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<UgcNpcAttribute>(ugc_npc_doc);
|
||||
|
||||
var doc_ugc_npc_attrib = ugc_npc_doc.getAttrib<UgcNpcAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(doc_ugc_npc_attrib, () => $"doc_ugc_npc_attrib is null !!! - {owner.toBasicStringWithMaster()}");
|
||||
|
||||
UgcNpcMetaGuid = doc_ugc_npc_attrib.UgcNpcMetaGuid;
|
||||
Nickname = doc_ugc_npc_attrib.Nickname;
|
||||
Title = doc_ugc_npc_attrib.Title;
|
||||
Greeting = doc_ugc_npc_attrib.Greeting;
|
||||
Introduction = doc_ugc_npc_attrib.Introduction;
|
||||
Description = doc_ugc_npc_attrib.Description;
|
||||
WorldScenario = doc_ugc_npc_attrib.WorldScenario;
|
||||
DefaultSocialActionMetaId = doc_ugc_npc_attrib.DefaultSocialActionMetaId;
|
||||
HabitSocialActionMetaIds = doc_ugc_npc_attrib.HabitSocialActionMetaIds.Select(x => x).ToList();
|
||||
DialogueSocialActionMetaIds = doc_ugc_npc_attrib.DialogueSocialActionMetaIds.Select(x => x).ToList();
|
||||
BodyItemMetaId = doc_ugc_npc_attrib.BodyItemMetaId;
|
||||
HashTagMetaIds = doc_ugc_npc_attrib.HashTagMetaIds.Select(x => x).ToList();
|
||||
|
||||
OwnerEntityType = doc_ugc_npc_attrib.OwnerEntityType;
|
||||
OwnerGuid = doc_ugc_npc_attrib.OwnerGuid;
|
||||
LanguageType = doc_ugc_npc_attrib.LanguageType;
|
||||
State = doc_ugc_npc_attrib.State;
|
||||
AnchorMetaGuid = doc_ugc_npc_attrib.AnchorMetaGuid;
|
||||
MetaIdOfEntityStateType = doc_ugc_npc_attrib.MetaIdOfEntityStateType;
|
||||
LocatedInstanceGuid = doc_ugc_npc_attrib.LocatedInstanceGuid;
|
||||
LocatedInstanceMetaId = doc_ugc_npc_attrib.LocatedInstanceMetaId;
|
||||
|
||||
IsRegisteredAiChatServer = doc_ugc_npc_attrib.IsRegisteredAiChatServer;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setCurrentPos(EntityPos pos) => m_current_pos = pos;
|
||||
|
||||
public EntityPos getCurrentPos() => m_current_pos;
|
||||
|
||||
public override string toBasicString()
|
||||
{
|
||||
return $"UgcNpcNickname:{Nickname}, UgcNpcMetaGuid:{UgcNpcMetaGuid}";
|
||||
}
|
||||
}
|
||||
|
||||
public class UgcNpcAttributeTransactor : EntityAttributeTransactorBase<UgcNpcAttribute>
|
||||
{
|
||||
public UgcNpcAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class UgcNpcCommunicationRankAttribute : EntityAttributeBase, ICopyEntityAttributeFromCache
|
||||
{
|
||||
public UgcNpcCommunicationRankAttribute(EntityBase owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new UgcNpcCommunicationRankAttribute(getOwner());
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromCache(CacheBase? cacheBase)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new UgcNpcCommunicationRankAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
return (new Result(), null);
|
||||
}
|
||||
}
|
||||
|
||||
public class UgcNpcCommunicationRankAttributeTransactor : EntityAttributeTransactorBase<UgcNpcLikeRankAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public UgcNpcCommunicationRankAttributeTransactor(EntityBase owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase entityAttributeBase)
|
||||
{
|
||||
string err_msg;
|
||||
|
||||
var copy_from_ugc_npc_communication_attribute = entityAttributeBase as UgcNpcCommunicationRankAttribute;
|
||||
if (null == copy_from_ugc_npc_communication_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_ugc_npc_communication_attribute is null :{nameof(UgcNpcCommunicationRankAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_ugc_npc_communication_attribute = getClonedEntityAttribute() as UgcNpcCommunicationRankAttribute;
|
||||
if (null == copy_to_ugc_npc_communication_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_ugc_npc_communication_attribute is null :{nameof(UgcNpcCommunicationRankAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
// copy attribute members
|
||||
// ...
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
89
ServerCommon/Entity/Attribute/UgcNpcItemAttribute.cs
Normal file
89
ServerCommon/Entity/Attribute/UgcNpcItemAttribute.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
using UGC_NPC_META_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class UgcNpcItemAttribute : ItemAttributeBase
|
||||
{
|
||||
|
||||
public UgcNpcItemAttribute(ItemBase owner, EntityBase ownerEntity)
|
||||
: base(owner, ownerEntity)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
var owner = getOwner() as ItemBase;
|
||||
ArgumentNullException.ThrowIfNull(owner, $"owner is null !!!");
|
||||
|
||||
return new UgcNpcItemAttributeTransactor(owner);
|
||||
}
|
||||
|
||||
public override ItemDoc onCreateDocBase()
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var root_parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(root_parent, () => $"root_parent is null !!! - { owner.toBasicStringWithMaster()}");
|
||||
|
||||
var ugc_npc_attribute = root_parent.getEntityAttribute<UgcNpcAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(ugc_npc_attribute, () => $"ugc_npc_attribute is null !!! - {owner.toBasicString()}, {owner.toBasicStringWithMaster()}");
|
||||
|
||||
var ugc_npc_meta_guid = ugc_npc_attribute.UgcNpcMetaGuid;
|
||||
|
||||
return new ItemDoc(OwnerEntityType.UgcNpc, ugc_npc_meta_guid, ItemGuid);
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var item_base = getOwner() as ItemBase;
|
||||
NullReferenceCheckHelper.throwIfNull(item_base, () => $"item_base is null !!!");
|
||||
var root_parent = item_base.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(root_parent, () => $"root_parent is null !!! - {item_base.toBasicStringWithMaster()}");
|
||||
|
||||
var parent = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!! - {item_base.toBasicStringWithMaster()}");
|
||||
|
||||
var cloned = new UgcNpcItemAttribute(item_base, parent);
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.ItemGuid = ItemGuid;
|
||||
cloned.ItemMetaId = ItemMetaId;
|
||||
cloned.ItemStackCount = ItemStackCount;
|
||||
cloned.Level = Level;
|
||||
cloned.Attributes = Attributes.Select(x => x).ToList();
|
||||
cloned.EquipedIvenType = EquipedIvenType;
|
||||
cloned.EquipedPos = EquipedPos;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
}
|
||||
|
||||
public class UgcNpcItemAttributeTransactor : ItemAttributeBaseTransactor<UgcNpcItemAttribute>
|
||||
{
|
||||
public UgcNpcItemAttributeTransactor(ItemBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
71
ServerCommon/Entity/Attribute/UgcNpcLikeRankAttribute.cs
Normal file
71
ServerCommon/Entity/Attribute/UgcNpcLikeRankAttribute.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class UgcNpcLikeRankAttribute : EntityAttributeBase, ICopyEntityAttributeFromCache
|
||||
{
|
||||
public UgcNpcLikeRankAttribute(EntityBase owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new UgcNpcLikeRankAttribute(getOwner());
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromCache(CacheBase? cacheBase)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new UgcNpcLikeRankAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
return (new Result(), null);
|
||||
}
|
||||
}
|
||||
|
||||
public class UgcNpcLikeRankAttributeTransactor : EntityAttributeTransactorBase<UgcNpcLikeRankAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public UgcNpcLikeRankAttributeTransactor(EntityBase owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase entityAttributeBase)
|
||||
{
|
||||
string err_msg;
|
||||
|
||||
var copy_from_ugc_npc_like_rank_attribute = entityAttributeBase as UgcNpcLikeRankAttribute;
|
||||
if (null == copy_from_ugc_npc_like_rank_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_ugc_npc_like_rank_attribute is null :{nameof(UgcNpcLikeRankAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_ugc_npc_like_rank_attribute = getClonedEntityAttribute() as UgcNpcLikeRankAttribute;
|
||||
if (null == copy_to_ugc_npc_like_rank_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_ugc_npc_like_rank_attribute is null :{nameof(UgcNpcLikeRankAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
// copy attribute members
|
||||
// ...
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
71
ServerCommon/Entity/Attribute/UgcNpcQuestRankAttribute.cs
Normal file
71
ServerCommon/Entity/Attribute/UgcNpcQuestRankAttribute.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class UgcNpcQuestRankAttribute : EntityAttributeBase, ICopyEntityAttributeFromCache
|
||||
{
|
||||
public UgcNpcQuestRankAttribute(EntityBase owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new UgcNpcQuestRankAttribute(getOwner());
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromCache(CacheBase? cacheBase)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new UgcNpcQuestRankAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
return (new Result(), null);
|
||||
}
|
||||
}
|
||||
|
||||
public class UgcNpcQuestRankAttributeTransactor : EntityAttributeTransactorBase<UgcNpcLikeRankAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public UgcNpcQuestRankAttributeTransactor(EntityBase owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase entityAttributeBase)
|
||||
{
|
||||
string err_msg;
|
||||
|
||||
var copy_from_ugc_npc_quest_rank_attribute = entityAttributeBase as UgcNpcQuestRankAttribute;
|
||||
if (null == copy_from_ugc_npc_quest_rank_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_ugc_npc_quest_rank_attribute is null :{nameof(UgcNpcQuestRankAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_ugc_npc_quest_rank_attribute = getClonedEntityAttribute() as UgcNpcQuestRankAttribute;
|
||||
if (null == copy_to_ugc_npc_quest_rank_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_ugc_npc_quest_rank_attribute is null :{nameof(UgcNpcQuestRankAttribute)}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
// copy attribute members
|
||||
// ...
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
289
ServerCommon/Entity/Attribute/UgqDailyRewardCountAttribute.cs
Normal file
289
ServerCommon/Entity/Attribute/UgqDailyRewardCountAttribute.cs
Normal file
@@ -0,0 +1,289 @@
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using NeoSmart.AsyncLock;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class UgqDailyRewardCountAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
//private AsyncLock m_lock = new();
|
||||
|
||||
[JsonProperty()]
|
||||
public ConcurrentDictionary<UgqGradeType, Int32> m_ugq_daily_reward_count { get; set; } = new();
|
||||
|
||||
[JsonProperty()]
|
||||
public DateTime m_next_refresh_time { get; set; } = DateTimeHelper.Current.Date.AddDays(-1);
|
||||
|
||||
public UgqDailyRewardCountDoc? m_ugq_daily_reward_count_doc_nullable { get; set; } = null;
|
||||
|
||||
|
||||
public UgqDailyRewardCountAttribute(EntityBase owner) : base(owner)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var ugq_daily_reward_count_attribute = owner.getEntityAttribute<UgqDailyRewardCountAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(ugq_daily_reward_count_attribute, () => $"ugq_daily_reward_count_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var user_attribute = owner.getRootParent().getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
USER_GUID user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as UgqDailyRewardCountDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new UgqDailyRewardCountDoc(user_guid);
|
||||
|
||||
var origin_doc = getOriginDocBase<UgqDailyRewardCountAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_ugq_daily_reward_count_attrib = try_pending_doc.getAttrib<UgqDailyRewardCountAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_ugq_daily_reward_count_attrib, () => $"to_copy_ugq_daily_reward_count_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
foreach (var dict in m_ugq_daily_reward_count)
|
||||
{
|
||||
to_copy_ugq_daily_reward_count_attrib.m_ugq_daily_reward_count.Add(dict.Key, dict.Value);
|
||||
}
|
||||
|
||||
to_copy_ugq_daily_reward_count_attrib.m_next_refresh_time = m_next_refresh_time;
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(var result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new UgqDailyRewardCountAttribute(getOwner());
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.m_next_refresh_time = m_next_refresh_time;
|
||||
|
||||
cloned.m_ugq_daily_reward_count = new();
|
||||
foreach (var dict in m_ugq_daily_reward_count)
|
||||
{
|
||||
cloned.m_ugq_daily_reward_count.TryAdd(dict.Key, dict.Value);
|
||||
}
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var result = new Result();
|
||||
if(getAttributeState().hasFlag(StateType.Removed))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
var other_attribute = otherEntityAttribute as UgqDailyRewardCountAttribute;
|
||||
if (null == other_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast UgqDailyRewardCountAttribute !!!, other_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
foreach (var dict in other_attribute.m_ugq_daily_reward_count)
|
||||
{
|
||||
m_ugq_daily_reward_count.AddOrUpdate(dict.Key, dict.Value, (key, old) => dict.Value);
|
||||
}
|
||||
m_next_refresh_time = other_attribute.m_next_refresh_time;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = other_attribute.getTryPendingDocBase() as UgqDailyRewardCountDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
other_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<UgqDailyRewardCountAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<UgqDailyRewardCountAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var ugq_daily_reward_count_attrib = origin_doc_base.getAttrib<UgqDailyRewardCountAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(ugq_daily_reward_count_attrib, () => $"ugq_daily_reward_count_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
foreach (var each in m_ugq_daily_reward_count)
|
||||
{
|
||||
ugq_daily_reward_count_attrib.m_ugq_daily_reward_count.TryAdd(each.Key, each.Value);
|
||||
}
|
||||
ugq_daily_reward_count_attrib.m_next_refresh_time = m_next_refresh_time;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(UgqDailyRewardCountDoc).Name;
|
||||
|
||||
var ugq_daily_reward_count_doc = docBase as UgqDailyRewardCountDoc;
|
||||
if (null == ugq_daily_reward_count_doc)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, ugq_daily_reward_count_doc is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<UgqDailyRewardCountAttribute>(ugq_daily_reward_count_doc);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var ugq_daily_reward_count_attrib = ugq_daily_reward_count_doc.getAttrib<UgqDailyRewardCountAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(ugq_daily_reward_count_attrib, () => $"ugq_daily_reward_count_attrib is null !!!");
|
||||
|
||||
foreach (var each in ugq_daily_reward_count_attrib.m_ugq_daily_reward_count)
|
||||
{
|
||||
m_ugq_daily_reward_count.TryAdd(each.Key, each.Value);
|
||||
}
|
||||
m_next_refresh_time = ugq_daily_reward_count_attrib.m_next_refresh_time;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
|
||||
return new UgqDailyRewardCountTransactor(getOwner());
|
||||
}
|
||||
|
||||
|
||||
public int getDailyRewardByGrade(UgqGradeType grade)
|
||||
{
|
||||
var reward_cnt = 0;
|
||||
if (false == m_ugq_daily_reward_count.TryGetValue(grade, out var cnt))
|
||||
{
|
||||
//없으면 추가
|
||||
cnt = 0;
|
||||
m_ugq_daily_reward_count.TryAdd(grade, reward_cnt);
|
||||
}
|
||||
reward_cnt = cnt;
|
||||
|
||||
return reward_cnt;
|
||||
}
|
||||
|
||||
public ConcurrentDictionary<UgqGradeType, Int32> getDailyRewardCount()
|
||||
{
|
||||
return m_ugq_daily_reward_count;
|
||||
}
|
||||
|
||||
public void setDailyReward(UgqGradeType grade, int cnt)
|
||||
{
|
||||
m_ugq_daily_reward_count.AddOrUpdate(grade, cnt, (key, oldValue) => cnt);
|
||||
//_anchors.AddOrUpdate(anchor.AnchorGuid, anchor, (key, oldValue) => anchor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class UgqDailyRewardCountTransactor : EntityAttributeTransactorBase<UgqDailyRewardCountAttribute>
|
||||
{
|
||||
public UgqDailyRewardCountTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorBaseFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(UgqDailyRewardCountAttribute).Name;
|
||||
|
||||
var copy_from_attribute = entityAttributeBase as UgqDailyRewardCountAttribute;
|
||||
if (null == copy_from_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, UgqDailyRewardCountAttribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_attribute = getClonedEntityAttribute() as UgqDailyRewardCountAttribute;
|
||||
if (null == copy_to_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, UgqDailyRewardCountAttribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_attribute.m_next_refresh_time = copy_from_attribute.m_next_refresh_time;
|
||||
|
||||
|
||||
foreach (var dict in copy_from_attribute.m_ugq_daily_reward_count)
|
||||
{
|
||||
copy_to_attribute.m_ugq_daily_reward_count.AddOrUpdate(dict.Key, dict.Value, (key, old) => dict.Value);
|
||||
}
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
419
ServerCommon/Entity/Attribute/UserAttribute.cs
Normal file
419
ServerCommon/Entity/Attribute/UserAttribute.cs
Normal file
@@ -0,0 +1,419 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
using PARTY_GUID = System.String;
|
||||
using System.Runtime.InteropServices;
|
||||
using Amazon.S3.Model;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class UserAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, ICopyEntityAttributeFromCache, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public USER_GUID UserGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public ACCOUNT_ID AccountId { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public string EOA { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public CHARACTER_GUID SelectedCharacterGuid { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty]
|
||||
public bool IsIntroCompleted { get; set; } = false;
|
||||
|
||||
public PlayerStateType PlayerState { get; set; }
|
||||
|
||||
public string OccupiedAnchorGuid { get; set; } = string.Empty;
|
||||
|
||||
public DateTime GameLoginDateTime = DateTime.MinValue;
|
||||
public DateTime GameLogoutDateTime = DateTime.MinValue;
|
||||
|
||||
public UserAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool applyUserGuidToRefAttributes( AccountBaseDoc accountBaseDoc, AccountAttribute accountAttribute
|
||||
, UserBaseDoc userBaseDoc )
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(accountBaseDoc, () => $"accountBaseDoc is null !!! - {owner.toBasicString()}");
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(accountAttribute, () => $"accountAttribute is null !!! - {owner.toBasicString()}");
|
||||
ArgumentNullReferenceCheckHelper.throwIfNull(userBaseDoc, () => $"userBaseDoc is null !!! - - {owner.toBasicString()}");
|
||||
|
||||
accountAttribute.UserGuid = UserGuid;
|
||||
|
||||
var account_doc_attrib = accountBaseDoc.getAttrib<AccountBaseAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(account_doc_attrib, () => $"account_doc_attrib is null !!! - - {owner.toBasicString()}");
|
||||
|
||||
account_doc_attrib.UserGuid = UserGuid;
|
||||
|
||||
var user_doc_attrib = userBaseDoc.getAttrib<UserBaseAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_doc_attrib, () => $"user_doc_attrib is null !!! - - {owner.toBasicString()}");
|
||||
|
||||
user_doc_attrib.UserGuid = UserGuid;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
UserGuid = string.Empty;
|
||||
AccountId = string.Empty;
|
||||
EOA = string.Empty;
|
||||
UserGuid = string.Empty;
|
||||
IsIntroCompleted = false;
|
||||
PlayerState = PlayerStateType.None;
|
||||
OccupiedAnchorGuid = string.Empty;
|
||||
|
||||
GameLoginDateTime = DateTime.MinValue;
|
||||
GameLogoutDateTime = DateTime.MinValue;
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var cloned = new UserAttribute(owner);
|
||||
cloned.UserGuid = UserGuid;
|
||||
cloned.AccountId = AccountId;
|
||||
cloned.EOA = EOA;
|
||||
cloned.SelectedCharacterGuid = SelectedCharacterGuid;
|
||||
cloned.IsIntroCompleted = IsIntroCompleted;
|
||||
cloned.PlayerState = PlayerState;
|
||||
cloned.OccupiedAnchorGuid = OccupiedAnchorGuid;
|
||||
|
||||
cloned.GameLoginDateTime = DateTime.MinValue;
|
||||
cloned.GameLogoutDateTime = DateTime.MinValue;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new UserAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null - {owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var user_attribute = otherEntityAttribute as UserAttribute;
|
||||
if (null == user_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast UserAttribute !!!, user_attribute is null - {owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
UserGuid = user_attribute.UserGuid;
|
||||
AccountId = user_attribute.AccountId;
|
||||
EOA = user_attribute.EOA;
|
||||
SelectedCharacterGuid = user_attribute.SelectedCharacterGuid;
|
||||
IsIntroCompleted = user_attribute.IsIntroCompleted;
|
||||
PlayerState = user_attribute.PlayerState;
|
||||
OccupiedAnchorGuid = user_attribute.OccupiedAnchorGuid;
|
||||
|
||||
GameLoginDateTime = user_attribute.GameLoginDateTime;
|
||||
GameLogoutDateTime = user_attribute.GameLogoutDateTime;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = user_attribute.getTryPendingDocBase() as UserBaseDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
user_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<UserAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<UserAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var user_base_attrib = origin_doc_base.getAttrib<UserBaseAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_base_attrib, () => $"user_base_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
user_base_attrib.UserGuid = UserGuid;
|
||||
user_base_attrib.AccountId = AccountId;
|
||||
user_base_attrib.EOA = EOA;
|
||||
user_base_attrib.SelectedCharacterGuid = SelectedCharacterGuid;
|
||||
user_base_attrib.IsIntroCompleted = IsIntroCompleted;
|
||||
|
||||
user_base_attrib.GameLoginDateTime = GameLoginDateTime;
|
||||
user_base_attrib.GameLogoutDateTime = GameLogoutDateTime;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override UserBaseDoc onCreateDocBase()
|
||||
{
|
||||
return new UserBaseDoc(UserGuid);
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as UserBaseDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = onCreateDocBase();
|
||||
|
||||
var origin_doc = getOriginDocBase<UserAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<UserBaseAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_attrib, () => $"to_copy_doc_attrib is null !!! - {toBasicString()}");
|
||||
|
||||
to_copy_doc_attrib.UserGuid = UserGuid;
|
||||
to_copy_doc_attrib.AccountId = AccountId;
|
||||
to_copy_doc_attrib.EOA = EOA;
|
||||
to_copy_doc_attrib.SelectedCharacterGuid = SelectedCharacterGuid;
|
||||
to_copy_doc_attrib.IsIntroCompleted = IsIntroCompleted;
|
||||
|
||||
to_copy_doc_attrib.GameLoginDateTime = GameLoginDateTime;
|
||||
to_copy_doc_attrib.GameLogoutDateTime = GameLogoutDateTime;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromCache(CacheBase? cacheBase)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var err_msg = string.Empty;
|
||||
var login_cache = cacheBase as LoginCache;
|
||||
if(null == login_cache)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromCache() !!!, login_cache is null :{nameof(LoginCache)} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Cache => Attribute
|
||||
//=====================================================================================
|
||||
PlayerState = login_cache.State;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase customDoc)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var err_msg = string.Empty;
|
||||
|
||||
bool is_success = false;
|
||||
|
||||
var account_base_doc = customDoc as AccountBaseDoc;
|
||||
if (null != account_base_doc)
|
||||
{
|
||||
is_success = copyEntityAttributeFromAccountBaseDoc(account_base_doc);
|
||||
}
|
||||
|
||||
var user_base_doc = customDoc as UserBaseDoc;
|
||||
if(null != user_base_doc)
|
||||
{
|
||||
is_success = copyEntityAttributeFromUserBaseDoc(user_base_doc);
|
||||
}
|
||||
|
||||
if (false == is_success)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, no successful data copies !!! :{toBasicString()} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromAccountBaseDoc(AccountBaseDoc? accountBaseDoc)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(AccountBaseDoc).Name;
|
||||
if (null == accountBaseDoc)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromAccountBaseDoc() !!!, accountBaseDoc is null :{to_cast_string} - {owner.toBasicString()}";
|
||||
Log.getLogger().warn(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var account_base_attrib = accountBaseDoc.getAttrib<AccountBaseAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(account_base_attrib, () => $"account_base_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
UserGuid = account_base_attrib.UserGuid;
|
||||
AccountId = account_base_attrib.AccountId;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromUserBaseDoc(UserBaseDoc? userBaseDoc)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(UserBaseDoc).Name;
|
||||
if (null == userBaseDoc)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromUserBaseDoc() !!!, userBaseDoc is null :{to_cast_string} - {owner.toBasicString()}";
|
||||
Log.getLogger().warn(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<UserAttribute>(userBaseDoc);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var user_base_attrib = userBaseDoc.getAttrib<UserBaseAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_base_attrib, () => $"account_base_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
UserGuid = user_base_attrib.UserGuid;
|
||||
AccountId = user_base_attrib.AccountId;
|
||||
EOA = user_base_attrib.EOA;
|
||||
SelectedCharacterGuid = user_base_attrib.SelectedCharacterGuid;
|
||||
IsIntroCompleted = user_base_attrib.IsIntroCompleted;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override string toBasicString()
|
||||
{
|
||||
return $"{GetType()}, UserGuid:{UserGuid}, SelectedCharacterGuid:{SelectedCharacterGuid}, AccountId:{AccountId}";
|
||||
}
|
||||
}
|
||||
|
||||
public class UserAttributeTransactor : EntityAttributeTransactorBase<UserAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public UserAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(UserAttribute).Name;
|
||||
|
||||
var copy_from_user_attribute = entityAttributeBase as UserAttribute;
|
||||
if (null == copy_from_user_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_from_user_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_user_attribute = getClonedEntityAttribute() as UserAttribute;
|
||||
if (null == copy_to_user_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorFromEntityAttribute() !!!, copy_to_user_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_user_attribute.SelectedCharacterGuid = copy_from_user_attribute.SelectedCharacterGuid;
|
||||
copy_to_user_attribute.IsIntroCompleted = copy_from_user_attribute.IsIntroCompleted;
|
||||
copy_to_user_attribute.EOA = copy_from_user_attribute.EOA;
|
||||
copy_to_user_attribute.PlayerState = copy_from_user_attribute.PlayerState;
|
||||
copy_to_user_attribute.OccupiedAnchorGuid = copy_from_user_attribute.OccupiedAnchorGuid;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
235
ServerCommon/Entity/Attribute/UserContentsSettingAttribute.cs
Normal file
235
ServerCommon/Entity/Attribute/UserContentsSettingAttribute.cs
Normal file
@@ -0,0 +1,235 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using USER_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class UserContentsSettingAttribute : EntityAttributeBase, ICopyEntityAttributeFromDoc, IMergeWithEntityAttribute
|
||||
{
|
||||
[JsonProperty]
|
||||
public int MyhomeSlotOpenCount { get; set; } = 0;
|
||||
|
||||
[JsonProperty]
|
||||
public DateTime BeaconAppProfileUploadTime { get; set; } = new();
|
||||
|
||||
public UserContentsSettingAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
return new UserContentsSettingAttributeTransactor(getOwner());
|
||||
}
|
||||
|
||||
public override void onClear()
|
||||
{
|
||||
MyhomeSlotOpenCount = 0;
|
||||
BeaconAppProfileUploadTime = new();
|
||||
|
||||
getAttributeState().reset();
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var cloned = new UserContentsSettingAttribute(getOwner());
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.MyhomeSlotOpenCount = MyhomeSlotOpenCount;
|
||||
cloned.BeaconAppProfileUploadTime = BeaconAppProfileUploadTime;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override async Task<(Result, DynamoDbDocBase?)> toDocBase(bool isForQuery = true)
|
||||
{
|
||||
var result = new Result();
|
||||
|
||||
var user_base = getOwner() as UserBase;
|
||||
NullReferenceCheckHelper.throwIfNull(user_base, () => $"user_base is null !!!");
|
||||
|
||||
var user_attribute = user_base.getRootParent().getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {user_base.toBasicString()}");
|
||||
|
||||
USER_GUID user_guid = user_attribute.UserGuid;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute => try pending Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = getTryPendingDocBase() as UserContentsSettingDoc;
|
||||
if (null == try_pending_doc)
|
||||
{
|
||||
var to_copy_doc = new UserContentsSettingDoc(user_guid);
|
||||
|
||||
var origin_doc = getOriginDocBase<UserContentsSettingAttribute>();
|
||||
if (null != origin_doc)
|
||||
{
|
||||
to_copy_doc.copyTimestampsFromOriginDocBase(origin_doc);
|
||||
}
|
||||
|
||||
try_pending_doc = to_copy_doc;
|
||||
|
||||
setTryPendingDocBase(try_pending_doc);
|
||||
}
|
||||
|
||||
var to_copy_doc_attrib = try_pending_doc.getAttrib<UserContentsSettingAttrib>();
|
||||
ArgumentNullException.ThrowIfNull(to_copy_doc_attrib);
|
||||
to_copy_doc_attrib.MyhomeSlotOpenCount = MyhomeSlotOpenCount;
|
||||
to_copy_doc_attrib.BeaconAppProfileUploadTime = BeaconAppProfileUploadTime;
|
||||
|
||||
if (false == isForQuery)
|
||||
{
|
||||
return (result, try_pending_doc);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// Doc QueryType 반영
|
||||
//=====================================================================================
|
||||
(result, var to_query_doc) = await applyDoc4Query(try_pending_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return (result, null);
|
||||
}
|
||||
|
||||
return (result, to_query_doc);
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeFromDoc(DynamoDbDocBase? docBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(UserContentsSettingDoc).Name;
|
||||
|
||||
var user_contents_setting_doc_base = docBase as UserContentsSettingDoc;
|
||||
if (null == user_contents_setting_doc_base)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDoc() !!!, user_contents_setting_doc_base is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// New Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
syncOriginDocBaseWithNewDoc<UserContentsSettingAttribute>(user_contents_setting_doc_base);
|
||||
|
||||
//=====================================================================================
|
||||
// Doc => Attribute
|
||||
//=====================================================================================
|
||||
var doc_attrib = user_contents_setting_doc_base.getAttrib<UserContentsSettingAttrib>();
|
||||
ArgumentNullException.ThrowIfNull(doc_attrib);
|
||||
|
||||
MyhomeSlotOpenCount = doc_attrib.MyhomeSlotOpenCount;
|
||||
BeaconAppProfileUploadTime = doc_attrib.BeaconAppProfileUploadTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public Result onMerge(EntityAttributeBase otherEntityAttribute)
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (null == otherEntityAttribute)
|
||||
{
|
||||
err_msg = $"Invalid Param !!!, otherEntityAttribute is null";
|
||||
result.setFail(ServerErrorCode.FunctionParamNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// OtherAttribute => Attribute
|
||||
//=====================================================================================
|
||||
var user_contents_setting_attribute = otherEntityAttribute as UserContentsSettingAttribute;
|
||||
if (null == user_contents_setting_attribute)
|
||||
{
|
||||
err_msg = $"Failed to cast UserContentsSettingAttribute !!!, user_contents_setting_attribute is null";
|
||||
result.setFail(ServerErrorCode.ClassTypeCastIsNull, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
MyhomeSlotOpenCount = user_contents_setting_attribute.MyhomeSlotOpenCount;
|
||||
BeaconAppProfileUploadTime = user_contents_setting_attribute.BeaconAppProfileUploadTime;
|
||||
|
||||
//=====================================================================================
|
||||
// Attribute Try Pending Doc => Origin Doc
|
||||
//=====================================================================================
|
||||
var try_pending_doc = user_contents_setting_attribute.getTryPendingDocBase() as UserContentsSettingDoc;
|
||||
if (null != try_pending_doc)
|
||||
{
|
||||
user_contents_setting_attribute.resetTryPendingDocBase();
|
||||
|
||||
syncOriginDocBaseWithNewDoc<UserContentsSettingAttribute>(try_pending_doc);
|
||||
}
|
||||
|
||||
var origin_doc_base = getOriginDocBase<UserContentsSettingAttribute>();
|
||||
if (null == origin_doc_base)
|
||||
{
|
||||
// DB 에 저장되어 있지 않는 경우 OriginDoc은 null 이다 !!!
|
||||
return result;
|
||||
}
|
||||
|
||||
var account_base_attrib = origin_doc_base.getAttrib<UserContentsSettingAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(account_base_attrib, () => $"account_base_attrib is null !!! - {owner.toBasicString()}");
|
||||
|
||||
user_contents_setting_attribute.MyhomeSlotOpenCount = MyhomeSlotOpenCount;
|
||||
user_contents_setting_attribute.BeaconAppProfileUploadTime = BeaconAppProfileUploadTime;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class UserContentsSettingAttributeTransactor : EntityAttributeTransactorBase<UserContentsSettingAttribute>, ICopyEntityAttributeTransactorFromEntityAttribute
|
||||
{
|
||||
public UserContentsSettingAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool copyEntityAttributeTransactorFromEntityAttribute(EntityAttributeBase? entityAttributeBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var to_cast_string = typeof(UserContentsSettingAttribute).Name;
|
||||
|
||||
var copy_from_user_contents_setting_attribute = entityAttributeBase as UserContentsSettingAttribute;
|
||||
if (null == copy_from_user_contents_setting_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_from_user_contents_setting_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
var copy_to_user_contents_setting_attribute = getClonedEntityAttribute() as UserContentsSettingAttribute;
|
||||
if (null == copy_to_user_contents_setting_attribute)
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeTransactorBaseFromEntityAttribute() !!!, copy_to_user_contents_setting_attribute is null :{to_cast_string}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_to_user_contents_setting_attribute.MyhomeSlotOpenCount = copy_from_user_contents_setting_attribute.MyhomeSlotOpenCount;
|
||||
copy_to_user_contents_setting_attribute.BeaconAppProfileUploadTime = copy_from_user_contents_setting_attribute.BeaconAppProfileUploadTime;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
122
ServerCommon/Entity/Attribute/UserItemAttribute.cs
Normal file
122
ServerCommon/Entity/Attribute/UserItemAttribute.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerControlCenter;
|
||||
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class UserItemAttribute : ItemAttributeBase
|
||||
{
|
||||
public UserItemAttribute(ItemBase owner, EntityBase entityOfOwnerEntityType)
|
||||
: base(owner, entityOfOwnerEntityType)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
var owner = getOwner() as ItemBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
return new UserItemAttributeTransactor(owner);
|
||||
}
|
||||
|
||||
public override DynamoDbDocBase onCreateDocBase()
|
||||
{
|
||||
var owner = getOwner() as ItemBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var user_attribute = parent.getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {parent.toBasicString()}");
|
||||
|
||||
var user_guid = user_attribute.UserGuid;
|
||||
|
||||
return new ItemDoc(OwnerEntityType.User, user_guid, ItemGuid);
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner() as ItemBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var entity_of_owner_entity_type = getEntityOfOwnerEntityType();
|
||||
NullReferenceCheckHelper.throwIfNull(entity_of_owner_entity_type, () => $"entity_of_owner_entity_type is null !!! - {parent.toBasicString()}");
|
||||
|
||||
var cloned = new UserItemAttribute(owner, entity_of_owner_entity_type);
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.ItemGuid = ItemGuid;
|
||||
cloned.ItemMetaId = ItemMetaId;
|
||||
cloned.ItemStackCount = ItemStackCount;
|
||||
cloned.Level = Level;
|
||||
cloned.Attributes = Attributes.Select(x => x).ToList();
|
||||
cloned.EquipedIvenType = EquipedIvenType;
|
||||
cloned.EquipedPos = EquipedPos;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public ItemDoc makeDocBase()
|
||||
{
|
||||
var owner = getOwner() as ItemBase;
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var user_attribute = parent.getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {parent.toBasicString()}");
|
||||
|
||||
var to_copy_doc = new ItemDoc(OwnerEntityType.User, user_attribute.UserGuid, ItemGuid);
|
||||
|
||||
var to_copy_doc_item_attrib = to_copy_doc.getAttrib<ItemAttrib>();
|
||||
NullReferenceCheckHelper.throwIfNull(to_copy_doc_item_attrib, () => $"to_copy_doc_item_attrib is null !!! - {parent.toBasicString()}");
|
||||
|
||||
to_copy_doc_item_attrib.ItemGuid = ItemGuid;
|
||||
to_copy_doc_item_attrib.ItemMetaId = ItemMetaId;
|
||||
to_copy_doc_item_attrib.ItemStackCount = ItemStackCount;
|
||||
to_copy_doc_item_attrib.Level = Level;
|
||||
to_copy_doc_item_attrib.Attributes = Attributes.Select(x => x).ToList();
|
||||
to_copy_doc_item_attrib.EquipedIvenType = EquipedIvenType;
|
||||
to_copy_doc_item_attrib.EquipedPos = EquipedPos;
|
||||
|
||||
return to_copy_doc;
|
||||
}
|
||||
}
|
||||
|
||||
public class UserItemAttributeTransactor : ItemAttributeBaseTransactor<UserItemAttribute>
|
||||
{
|
||||
public UserItemAttributeTransactor(ItemBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
72
ServerCommon/Entity/Attribute/UserSocialActionAttribute.cs
Normal file
72
ServerCommon/Entity/Attribute/UserSocialActionAttribute.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class UserSocialActionAttribute : SocialActionAttributeBase
|
||||
{
|
||||
public UserSocialActionAttribute(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEntityAttributeTransactor onNewEntityAttributeTransactor()
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!! - {owner.toBasicString()}");
|
||||
|
||||
return new UserSocialActionAttributeTransactor(owner);
|
||||
}
|
||||
|
||||
public override EntityAttributeBase onCloned()
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var cloned = new UserSocialActionAttribute(owner);
|
||||
|
||||
cloned.deepCopyFromBase(this);
|
||||
|
||||
cloned.SocialActionMetaId = SocialActionMetaId;
|
||||
cloned.EquipedPos = EquipedPos;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public override DynamoDbDocBase onCreateDocBase()
|
||||
{
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
var parent = owner.getRootParent();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var user_attribute = parent.getEntityAttribute<UserAttribute>();
|
||||
NullReferenceCheckHelper.throwIfNull(user_attribute, () => $"user_attribute is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var user_guid = user_attribute.UserGuid;
|
||||
|
||||
return new SocialActionDoc(OwnerEntityType.User, user_guid, SocialActionMetaId);
|
||||
}
|
||||
}
|
||||
|
||||
public class UserSocialActionAttributeTransactor : SocialActionAttributeBaseTransactor<UserSocialActionAttribute>
|
||||
{
|
||||
public UserSocialActionAttributeTransactor(EntityBase owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
}
|
||||
53
ServerCommon/Entity/Claim/Claim.cs
Normal file
53
ServerCommon/Entity/Claim/Claim.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public enum EEventType
|
||||
{
|
||||
None = 0,
|
||||
ClaimReward = 11,
|
||||
QuestMain = 21,
|
||||
Max
|
||||
}
|
||||
public class Claim : EntityBase
|
||||
{
|
||||
public Claim(EntityBase parent, MetaAssets.ClaimType type)
|
||||
: base(EntityType.Claim, parent)
|
||||
{
|
||||
onInit().GetAwaiter().GetResult();
|
||||
addEntityAttributes(type);
|
||||
}
|
||||
|
||||
public override async Task<Result> onInit()
|
||||
{
|
||||
|
||||
return await base.onInit();
|
||||
}
|
||||
|
||||
private void addEntityAttributes(MetaAssets.ClaimType type)
|
||||
{
|
||||
var direct_parent = getDirectParent();
|
||||
NullReferenceCheckHelper.throwIfNull(direct_parent, () => $"direct_parent is null !!!");
|
||||
addEntityAttribute(new ClaimAttribute(this, type, direct_parent));
|
||||
}
|
||||
|
||||
public override string toBasicString()
|
||||
{
|
||||
return $"{this.getTypeName()} - {getRootParent().toBasicString()}";
|
||||
}
|
||||
|
||||
public override string toSummaryString()
|
||||
{
|
||||
return $"{this.getTypeName()} - {getRootParent().toBasicString()}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
114
ServerCommon/Entity/DbQuery/DBQEntityDelete.cs
Normal file
114
ServerCommon/Entity/DbQuery/DBQEntityDelete.cs
Normal file
@@ -0,0 +1,114 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
|
||||
|
||||
using DYNAMO_DB_TABLE_NAME = System.String;
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class DBQEntityDelete : QueryExecutorBase
|
||||
{
|
||||
private readonly List<DynamoDbDocBase> m_to_delete_doc_bases = new();
|
||||
|
||||
public DBQEntityDelete(DynamoDbDocBase toDeleteDocBase)
|
||||
: base(typeof(DBQEntityDelete).Name)
|
||||
{
|
||||
m_to_delete_doc_bases.Add(toDeleteDocBase);
|
||||
}
|
||||
|
||||
public DBQEntityDelete(List<DynamoDbDocBase> toDeleteDocBases)
|
||||
: base(typeof(DBQEntityDelete).Name)
|
||||
{
|
||||
m_to_delete_doc_bases = toDeleteDocBases;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리 직전에 준비해야 할 로직들을 작성한다.
|
||||
//=====================================================================================
|
||||
public override async Task<Result> onPrepareQuery()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// onPrepareQuery()를 성공할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task<Result> onQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var query_batch = getQueryBatch();
|
||||
NullReferenceCheckHelper.throwIfNull(query_batch, () => $"query_batch is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var query_runner = query_batch.getQueryRunner();
|
||||
NullReferenceCheckHelper.throwIfNull(query_runner, () => $"query_runner is null !!! - {owner.toBasicString()}");
|
||||
|
||||
foreach (var to_delete_doc in m_to_delete_doc_bases)
|
||||
{
|
||||
(result, var query_context) = await query_runner.tryCreateQueryContext(to_delete_doc, QueryType.Delete);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
NullReferenceCheckHelper.throwIfNull(query_context, () => $"query_context is null !!! - {owner.toBasicString()}");
|
||||
|
||||
result = await query_runner.tryRegisterQueryContext(query_context);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
var msg = $"{this.getTypeName()} : tryDeleteCount:{m_to_delete_doc_bases.Count}, isUseTransact:{query_batch.isUseTransact()} - TransId:{query_batch.getTransId()}";
|
||||
Log.getLogger().info(msg);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<DynamoDbDocBase> getToDeleteDocBases() => m_to_delete_doc_bases;
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리를 성공하고, doFnCommit()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task onQueryResponseCommit()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리를 실패하고, doFnRollback()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task onQueryResponseRollback(Result errorResult)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
153
ServerCommon/Entity/DbQuery/DBQEntityDeleteAfterReadAll.cs
Normal file
153
ServerCommon/Entity/DbQuery/DBQEntityDeleteAfterReadAll.cs
Normal file
@@ -0,0 +1,153 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Amazon.DynamoDBv2;
|
||||
using Amazon.DynamoDBv2.Model;
|
||||
using Amazon.DynamoDBv2.DocumentModel;
|
||||
using Amazon.Runtime;
|
||||
using StackExchange.Redis;
|
||||
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
|
||||
|
||||
using DYNAMO_DB_TABLE_NAME = System.String;
|
||||
using DYNAMO_DB_TABLE_FULL_NAME = System.String;
|
||||
using SESSION_ID = System.Int32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class DBQEntityDeleteAfterReadAll<TDoc> : QueryExecutorBase
|
||||
where TDoc : DynamoDbDocBase, new()
|
||||
{
|
||||
private string m_combination_key_for_pk = string.Empty;
|
||||
private string m_combination_key_for_sk = string.Empty;
|
||||
|
||||
private string m_pk = string.Empty;
|
||||
private string m_sk = string.Empty;
|
||||
|
||||
private List<Amazon.DynamoDBv2.DocumentModel.Document>? m_read_documents_nullable;
|
||||
|
||||
public DBQEntityDeleteAfterReadAll(string combinationKeyForPK, string combinationKeyForSK = "")
|
||||
: base(typeof(DBQEntityDeleteAfterReadAll<TDoc>).Name)
|
||||
{
|
||||
m_combination_key_for_pk = combinationKeyForPK;
|
||||
m_combination_key_for_sk = combinationKeyForSK;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리 직전에 준비해야 할 로직들을 작성한다.
|
||||
//=====================================================================================
|
||||
public override async Task<Result> onPrepareQuery()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var doc = new TDoc();
|
||||
|
||||
doc.setCombinationKeyForPKSK(m_combination_key_for_pk, m_combination_key_for_sk);
|
||||
|
||||
var error_code = doc.onApplyPKSK();
|
||||
if (error_code.isFail())
|
||||
{
|
||||
err_msg = $"Failed to onApplyPKSK() !!! : {error_code.toBasicString()} - {toBasicString()}, {owner.toBasicString()}";
|
||||
result.setFail(error_code, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
|
||||
m_pk = doc.getPK();
|
||||
m_sk = doc.getSK();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// onPrepareQuery()를 성공할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task<Result> onQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => "owner is null !!!");
|
||||
|
||||
var query_batch = getQueryBatch();
|
||||
NullReferenceCheckHelper.throwIfNull(query_batch, () => $"query_batch is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var server_logic = ServerLogicApp.getServerLogicApp();
|
||||
var dynamo_db_connector = query_batch.getDynamoDbConnector();
|
||||
|
||||
var table = dynamo_db_connector.getTableByDoc<TDoc>();
|
||||
var query_config = dynamo_db_connector.makeQueryConfigForReadByPKOnly(m_pk);
|
||||
|
||||
(result, var read_documents) = await table.simpleQueryWithQueryOperationConfig(query_config, query_batch.getTransId());
|
||||
if(result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
m_read_documents_nullable = read_documents;
|
||||
|
||||
var query_runner = query_batch.getQueryRunner();
|
||||
NullReferenceCheckHelper.throwIfNull(query_runner, () => $"query_runner is null !!! - {owner.toBasicString()}");
|
||||
|
||||
foreach (var document in m_read_documents_nullable)
|
||||
{
|
||||
var to_delete_doc = document.createDocumentQueryContext(table.TableName, QueryType.Delete);
|
||||
|
||||
result = await query_runner.tryRegisterQueryContext(to_delete_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
var msg = $"{this.getTypeName()} : tryDeleteCount:{m_read_documents_nullable.Count}, isUseTransact:{query_batch.isUseTransact()} - TransId:{query_batch.getTransId()}";
|
||||
Log.getLogger().info(msg);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<Amazon.DynamoDBv2.DocumentModel.Document>? getReadDocuments() => m_read_documents_nullable;
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리를 성공하고, doFnCommit()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task onQueryResponseCommit()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리를 실패하고, doFnRollback()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task onQueryResponseRollback(Result errorResult)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
184
ServerCommon/Entity/DbQuery/DBQEntityReadToAttribute.cs
Normal file
184
ServerCommon/Entity/DbQuery/DBQEntityReadToAttribute.cs
Normal file
@@ -0,0 +1,184 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Amazon.DynamoDBv2;
|
||||
using Amazon.DynamoDBv2.Model;
|
||||
using Amazon.DynamoDBv2.DocumentModel;
|
||||
using Amazon.Runtime;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class DBQEntityReadToAttribute<TDoc> : QueryExecutorBase
|
||||
where TDoc : DynamoDbDocBase, new()
|
||||
{
|
||||
private EntityBase m_owner_of_entity_attribute;
|
||||
|
||||
private string m_combination_key_for_pk = string.Empty;
|
||||
private string m_combination_key_for_sk = string.Empty;
|
||||
|
||||
private string m_pk = string.Empty;
|
||||
private string m_sk = string.Empty;
|
||||
|
||||
private readonly List<DynamoDbDocBase> m_to_read_doc_bases = new();
|
||||
private readonly List<Type> m_copy_to_target_entity_attribute_types;
|
||||
|
||||
public DBQEntityReadToAttribute( EntityBase ownerOfEntityAttribute
|
||||
, string combinationKeyForPK, Type[] copyToTargetEnityAttributeTypes)
|
||||
: base(typeof(DBQEntityReadToAttribute<TDoc>).Name)
|
||||
{
|
||||
m_owner_of_entity_attribute = ownerOfEntityAttribute;
|
||||
|
||||
m_combination_key_for_pk = combinationKeyForPK;
|
||||
m_copy_to_target_entity_attribute_types = copyToTargetEnityAttributeTypes.ToList<Type>();
|
||||
}
|
||||
|
||||
public DBQEntityReadToAttribute( EntityBase ownerOfEntityAttribute
|
||||
, string combinationKeyForPK, string combinationKeyForSK, Type[] copyToTargetEnityAttributeTypes)
|
||||
: base(typeof(DBQEntityReadToAttribute<TDoc>).Name)
|
||||
{
|
||||
m_owner_of_entity_attribute = ownerOfEntityAttribute;
|
||||
|
||||
m_combination_key_for_pk = combinationKeyForPK;
|
||||
m_combination_key_for_sk = combinationKeyForSK;
|
||||
m_copy_to_target_entity_attribute_types = copyToTargetEnityAttributeTypes.ToList<Type>();
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리 직전에 준비해야 할 로직들을 작성한다.
|
||||
//=====================================================================================
|
||||
public override async Task<Result> onPrepareQuery()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
(result, var primary_key) = await DynamoDBDocBaseHelper.makePrimaryKey<TDoc>(m_combination_key_for_pk, m_combination_key_for_sk);
|
||||
if(result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to makePrimaryKey<TDoc>() !!! : {result.toBasicString()}, {typeof(TDoc).Name} - {toBasicString()}, {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return result;
|
||||
}
|
||||
NullReferenceCheckHelper.throwIfNull(primary_key, () => $"primary_key is null !!! - {owner.toBasicString()}");
|
||||
|
||||
m_pk = primary_key.PK;
|
||||
m_sk = primary_key.SK;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// onPrepareQuery()를 성공할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task<Result> onQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var query_batch = getQueryBatch();
|
||||
NullReferenceCheckHelper.throwIfNull(query_batch, () => $"query_batch is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var server_logic = ServerLogicApp.getServerLogicApp();
|
||||
var dynamo_db_connector = query_batch.getDynamoDbConnector();
|
||||
|
||||
QueryOperationConfig? query_config = null;
|
||||
if (true == m_sk.isNullOrWhiteSpace())
|
||||
{
|
||||
query_config = dynamo_db_connector.makeQueryConfigForReadByPKSK(m_pk);
|
||||
}
|
||||
else
|
||||
{
|
||||
query_config = dynamo_db_connector.makeQueryConfigForReadByPKSK(m_pk, m_sk);
|
||||
}
|
||||
|
||||
(result, var read_docs) = await dynamo_db_connector.simpleQueryDocTypesWithQueryOperationConfig<TDoc>(query_config, eventTid: query_batch.getTransId());
|
||||
if(result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
var msg = $"{this.getTypeName()} : readCount:{read_docs.Count}, isUseTransact:{query_batch.isUseTransact} - TransId:{query_batch.getTransId()}";
|
||||
Log.getLogger().info(msg);
|
||||
|
||||
foreach ( var read_doc in read_docs )
|
||||
{
|
||||
foreach (var target_entity_attribute_type in m_copy_to_target_entity_attribute_types)
|
||||
{
|
||||
var target_entity_attribute_base = getOwnerOfEntityAttribute().getOriginEntityAttribute(target_entity_attribute_type);
|
||||
if (null == target_entity_attribute_base)
|
||||
{
|
||||
err_msg = $"Not found Target getOriginEntityAttribute() !!!"
|
||||
+ $" : to:{target_entity_attribute_type.Name}, from:{typeof(TDoc).Name}, ownerOfAttribute:{getOwnerOfEntityAttribute().toBasicString()}"
|
||||
+ $" - {toBasicString()}, {owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.EntityAttributeNotFound, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
|
||||
result = await ServerBase.DataCopyHelper.copyEntityAttributeFromDocs(target_entity_attribute_base, new List<DynamoDbDocBase>() { read_doc });
|
||||
if (result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to copyEntityAttributeFromDocs() !!! : {result.toBasicString()}, ownerOfAttribute:{getOwnerOfEntityAttribute().toBasicString()}"
|
||||
+ $" - {toBasicString()}, {owner.toBasicString()}";
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
m_to_read_doc_bases.Add(read_doc);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<DynamoDbDocBase> getToReadDocBases() => m_to_read_doc_bases;
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리를 성공하고, doFnCommit()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task onQueryResponseCommit()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리를 실패하고, doFnRollback()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task onQueryResponseRollback(Result errorResult)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return;
|
||||
}
|
||||
|
||||
public EntityBase getOwnerOfEntityAttribute() => m_owner_of_entity_attribute;
|
||||
}
|
||||
115
ServerCommon/Entity/DbQuery/DBQEntityWrite.cs
Normal file
115
ServerCommon/Entity/DbQuery/DBQEntityWrite.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class DBQEntityWrite : QueryExecutorBase
|
||||
{
|
||||
private readonly List<DynamoDbDocBase> m_to_write_doc_bases = new();
|
||||
|
||||
public DBQEntityWrite(DynamoDbDocBase toWriteDocBase)
|
||||
: base(typeof(DBQEntityWrite).Name)
|
||||
{
|
||||
m_to_write_doc_bases.Add(toWriteDocBase);
|
||||
}
|
||||
|
||||
public DBQEntityWrite(List<DynamoDbDocBase> toWriteDocBases)
|
||||
: base(typeof(DBQEntityWrite).Name)
|
||||
{
|
||||
m_to_write_doc_bases = toWriteDocBases;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리 직전에 준비해야 할 로직들을 작성한다.
|
||||
//=====================================================================================
|
||||
public override async Task<Result> onPrepareQuery()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// onPrepareQuery()를 성공할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task<Result> onQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var query_batch = getQueryBatch();
|
||||
NullReferenceCheckHelper.throwIfNull(query_batch, () => $"query_batch is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var query_runner = query_batch.getQueryRunner();
|
||||
NullReferenceCheckHelper.throwIfNull(query_runner, () => $"query_runner is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var dynamo_db_connector = query_batch.getDynamoDbConnector();
|
||||
|
||||
foreach (var to_write_doc in m_to_write_doc_bases)
|
||||
{
|
||||
(result, var query_context) = await query_runner.tryCreateQueryContext(to_write_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
NullReferenceCheckHelper.throwIfNull(query_context, () => $"query_context is null !!! - {owner.toBasicString()}");
|
||||
|
||||
result = await query_runner.tryRegisterQueryContext(query_context);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
var msg = $"{this.getTypeName()} : tryWriteCount:{m_to_write_doc_bases.Count}, isUseTransact:{query_batch.isUseTransact()} - TransId:{query_batch.getTransId()}";
|
||||
Log.getLogger().info(msg);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<DynamoDbDocBase> getToWriteDocBases() => m_to_write_doc_bases;
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리를 성공하고, doFnCommit()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task onQueryResponseCommit()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리를 실패하고, doFnRollback()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task onQueryResponseRollback(Result errorResult)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
182
ServerCommon/Entity/DbQuery/DBQEntityWriteAfterRead.cs
Normal file
182
ServerCommon/Entity/DbQuery/DBQEntityWriteAfterRead.cs
Normal file
@@ -0,0 +1,182 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Amazon.DynamoDBv2;
|
||||
using Amazon.DynamoDBv2.Model;
|
||||
using Amazon.DynamoDBv2.DocumentModel;
|
||||
using Amazon.Runtime;
|
||||
using StackExchange.Redis;
|
||||
|
||||
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
|
||||
|
||||
|
||||
using DYNAMO_DB_TABLE_NAME = System.String;
|
||||
using SESSION_ID = System.Int32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class DBQEntityWriteAfterRead<TDoc> : QueryExecutorBase
|
||||
where TDoc : DynamoDbDocBase, new()
|
||||
{
|
||||
private string m_combination_key_for_pk = string.Empty;
|
||||
private string m_combination_key_for_sk = string.Empty;
|
||||
|
||||
private string m_pk = string.Empty;
|
||||
private string m_sk = string.Empty;
|
||||
|
||||
private List<TDoc>? m_read_docs_nullable;
|
||||
|
||||
public delegate Task<Result> FnEntityWrite(List<TDoc> readDocs);
|
||||
|
||||
private FnEntityWrite m_fn_entity_write;
|
||||
|
||||
public DBQEntityWriteAfterRead( string combinationKeyForPK, string combinationKeyForSK
|
||||
, FnEntityWrite fnEntityWrite )
|
||||
: base(typeof(DBQEntityWriteAfterRead<TDoc>).Name)
|
||||
{
|
||||
m_combination_key_for_pk = combinationKeyForPK;
|
||||
m_combination_key_for_sk = combinationKeyForSK;
|
||||
|
||||
m_fn_entity_write = fnEntityWrite;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리 직전에 준비해야 할 로직들을 작성한다.
|
||||
//=====================================================================================
|
||||
public override async Task<Result> onPrepareQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var doc = new TDoc();
|
||||
|
||||
doc.setCombinationKeyForPKSK(m_combination_key_for_pk, m_combination_key_for_sk);
|
||||
|
||||
var error_code = doc.onApplyPKSK();
|
||||
if(error_code.isFail())
|
||||
{
|
||||
err_msg = $"Failed to onApplyPKSK() !!! : {error_code.toBasicString()} - {toBasicString()}, {owner.toBasicString()}";
|
||||
result.setFail(error_code, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
|
||||
m_pk = doc.getPK();
|
||||
m_sk = doc.getSK();
|
||||
|
||||
return await Task.FromResult(result);
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// onPrepareQuery()를 성공할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task<Result> onQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var query_batch = getQueryBatch();
|
||||
NullReferenceCheckHelper.throwIfNull(query_batch, () => $"query_batch is null !!! - {owner.toBasicString()}");
|
||||
var query_runner = query_batch.getQueryRunner();
|
||||
NullReferenceCheckHelper.throwIfNull(query_runner, () => $"query_runner is null !!! - {owner.toBasicString()}");
|
||||
var dynamo_db_connector = query_batch.getDynamoDbConnector();
|
||||
|
||||
QueryOperationConfig? query_config = null;
|
||||
if (true == m_sk.isNullOrWhiteSpace())
|
||||
{
|
||||
query_config = dynamo_db_connector.makeQueryConfigForReadByPKSK(m_pk);
|
||||
}
|
||||
else
|
||||
{
|
||||
query_config = dynamo_db_connector.makeQueryConfigForReadByPKSK(m_pk, m_sk);
|
||||
}
|
||||
|
||||
(result, var read_docs) = await dynamo_db_connector.simpleQueryDocTypesWithQueryOperationConfig<TDoc>(query_config, eventTid: query_batch.getTransId());
|
||||
if(result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
m_read_docs_nullable = read_docs;
|
||||
|
||||
var read_msg = $"{this.getTypeName()} : readCount:{read_docs.Count}, isUseTransact:{query_batch.isUseTransact()} - TransId:{query_batch.getTransId()}";
|
||||
Log.getLogger().info(read_msg);
|
||||
|
||||
result = await m_fn_entity_write.Invoke(m_read_docs_nullable);
|
||||
if(result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
var query_batch_with_document = query_batch as QueryBatch<QueryRunnerWithDocument>;
|
||||
NullReferenceCheckHelper.throwIfNull(query_batch_with_document, () => $"query_batch_with_document is null !!! - {owner.toBasicString()}");
|
||||
|
||||
foreach (var to_write_doc in m_read_docs_nullable)
|
||||
{
|
||||
(result, var query_context) = await query_runner.tryCreateQueryContext(to_write_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
NullReferenceCheckHelper.throwIfNull(query_context, () => $"query_context is null !!! - {owner.toBasicString()}");
|
||||
|
||||
result = await query_runner.tryRegisterQueryContext(query_context);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
var write_msg = $"{this.getTypeName()} : tryWriteCount:{m_read_docs_nullable.Count}, isUseTransact:{query_batch.isUseTransact()} - TransId:{query_batch.getTransId()}";
|
||||
Log.getLogger().info(write_msg);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<TDoc>? getReadDocs() => m_read_docs_nullable;
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리를 성공하고, doFnCommit()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task onQueryResponseCommit()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리를 실패하고, doFnRollback()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task onQueryResponseRollback(Result errorResult)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
107
ServerCommon/Entity/DbQuery/DBQWithItemRequestQueryContext.cs
Normal file
107
ServerCommon/Entity/DbQuery/DBQWithItemRequestQueryContext.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
using ServerCommon.BusinessLogDomain;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public class DBQWithItemRequestQueryContext : QueryExecutorBase
|
||||
{
|
||||
private readonly List<DynamoDbItemRequestQueryContext> m_to_query_item_request_query_contexts = new();
|
||||
|
||||
public DBQWithItemRequestQueryContext(DynamoDbItemRequestQueryContext queryContext)
|
||||
: base(typeof(DBQWithItemRequestQueryContext).Name)
|
||||
{
|
||||
m_to_query_item_request_query_contexts.Add(queryContext);
|
||||
}
|
||||
|
||||
public DBQWithItemRequestQueryContext(List<DynamoDbItemRequestQueryContext> queryContexts)
|
||||
: base(typeof(DBQWithItemRequestQueryContext).Name)
|
||||
{
|
||||
m_to_query_item_request_query_contexts = queryContexts;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리 직전에 준비해야 할 로직들을 작성한다.
|
||||
//=====================================================================================
|
||||
public override async Task<Result> onPrepareQuery()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// onPrepareQuery()를 성공할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task<Result> onQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var query_batch = getQueryBatch();
|
||||
NullReferenceCheckHelper.throwIfNull(query_batch, () => $"query_batch is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var query_runner = query_batch.getQueryRunner();
|
||||
NullReferenceCheckHelper.throwIfNull(query_runner, () => $"query_runner is null !!! - {owner.toBasicString()}");
|
||||
|
||||
foreach (var query_context in m_to_query_item_request_query_contexts)
|
||||
{
|
||||
result = await query_runner.tryRegisterQueryContext(query_context);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
var msg = $"{this.getTypeName()} : tryQueryCount:{m_to_query_item_request_query_contexts.Count}, isUseTransact:{query_batch.isUseTransact()} - TransId:{query_batch.getTransId()}";
|
||||
Log.getLogger().info(msg);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<DynamoDbItemRequestQueryContext> getToItemRequestQueryContexts() => m_to_query_item_request_query_contexts;
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리를 성공하고, doFnCommit()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task onQueryResponseCommit()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리를 실패하고, doFnRollback()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task onQueryResponseRollback(Result errorResult)
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Amazon.DynamoDBv2;
|
||||
using Amazon.DynamoDBv2.Model;
|
||||
using Amazon.DynamoDBv2.DocumentModel;
|
||||
using Amazon.Runtime;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public class DBQWriteToAttributeAllWithTransactionRunner : QueryExecutorBase
|
||||
{
|
||||
private readonly List<DynamoDbDocBase> m_to_write_docs = new();
|
||||
private readonly List<IEntityAttributeTransactor> m_transactors = new();
|
||||
|
||||
private readonly Dictionary<string, EntityCommonResult> m_entity_common_results = new();
|
||||
|
||||
public DBQWriteToAttributeAllWithTransactionRunner()
|
||||
: base(typeof(DBQWriteToAttributeAllWithTransactionRunner).Name)
|
||||
{
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리 직전에 준비해야 할 로직들을 작성한다.
|
||||
//=====================================================================================
|
||||
public override async Task<Result> onPrepareQuery()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var to_find_transaction_type = TransactionIdType.PrivateContents;
|
||||
var transaction_runner = owner.findTransactionRunner(to_find_transaction_type);
|
||||
if(null == transaction_runner)
|
||||
{
|
||||
err_msg = $"Not found TransactionRunner !!! : TransactionType:{to_find_transaction_type} - {owner.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.TransactionRunnerNotFound, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// 자기 자신의 Transactor들을 얻어 온다 !!!
|
||||
var transactors = transaction_runner.getEntityAttributeTransactorAll4DbQuery();
|
||||
foreach(var transactor in transactors)
|
||||
{
|
||||
if(true == transactor.isReadOnly())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
(result, var to_write_doc_nullable) = await transactor.makeDocBase();
|
||||
if(result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
NullReferenceCheckHelper.throwIfNull(to_write_doc_nullable, () => $"to_write_doc_nullable is null !!!");
|
||||
|
||||
m_to_write_docs.Add(to_write_doc_nullable);
|
||||
m_transactors.Add(transactor);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// onPrepareQuery()를 성공할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task<Result> onQuery()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var query_batch = getQueryBatch();
|
||||
NullReferenceCheckHelper.throwIfNull(query_batch, () => $"query_batch is null !!! - {owner.toBasicString()}");
|
||||
|
||||
var query_runner = query_batch.getQueryRunner();
|
||||
NullReferenceCheckHelper.throwIfNull(query_runner, () => $"query_runner is null !!! - {owner.toBasicString()}");
|
||||
|
||||
foreach (var to_write_doc in m_to_write_docs)
|
||||
{
|
||||
(result, var query_context) = await query_runner.tryCreateQueryContext(to_write_doc);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
NullReferenceCheckHelper.throwIfNull(query_context, () => $"query_context is null !!! - {owner.toBasicString()}");
|
||||
|
||||
result = await query_runner.tryRegisterQueryContext(query_context);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
var write_msg = $"{this.getTypeName()} : tryWriteCount:{m_to_write_docs.Count}, isUseTransact:{query_batch.isUseTransact()} - TransId:{query_batch.getTransId()}";
|
||||
Log.getLogger().info(write_msg);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리를 성공하고, doFnCommit()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override async Task onQueryResponseCommit()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var to_find_transaction_id_type = TransactionIdType.PrivateContents;
|
||||
var transaction_runner = owner.findTransactionRunner(to_find_transaction_id_type);
|
||||
if (null == transaction_runner)
|
||||
{
|
||||
err_msg = $"transaction_runner is null !!! : TransactionIdType:{to_find_transaction_id_type} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var query_batch = getQueryBatch();
|
||||
NullReferenceCheckHelper.throwIfNull(query_batch, () => $"query_batch is null !!! - {owner.toBasicString()}");
|
||||
|
||||
result = await transaction_runner.onCommitResults4DbQuery(m_transactors, query_batch);
|
||||
if (result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to onCommitResults4DbQuery() !!! : {result.toBasicString()} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리를 성공한 후에 EntityAttribute 변경 사항이 있는 경우 호출해 준다.
|
||||
//=====================================================================================
|
||||
public virtual async Task onMergeAfterQueryCommit()
|
||||
{
|
||||
await Task.CompletedTask;
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var owner = getOwner();
|
||||
NullReferenceCheckHelper.throwIfNull(owner, () => $"owner is null !!!");
|
||||
|
||||
var to_find_transaction_id_type = TransactionIdType.PrivateContents;
|
||||
var transaction_runner = owner.findTransactionRunner(to_find_transaction_id_type);
|
||||
if (null == transaction_runner)
|
||||
{
|
||||
err_msg = $"transaction_runner is null !!! : TransactionIdType:{to_find_transaction_id_type} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var query_batch = getQueryBatch();
|
||||
NullReferenceCheckHelper.throwIfNull(query_batch, () => $"query_batch is null !!! - {owner.toBasicString()}");
|
||||
|
||||
result = await transaction_runner.onCommitResults(query_batch);
|
||||
if (result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to onCommitResults() !!! : {result.toBasicString()} - {owner.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// DB 쿼리를 실패하고, doFnRollback()가 QueryResultType.NotCalledQueryFunc를 반환할 경우 호출된다.
|
||||
//=====================================================================================
|
||||
public override Task onQueryResponseRollback(Result errorResult)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
59
ServerCommon/Entity/EntityGetSet.cs
Normal file
59
ServerCommon/Entity/EntityGetSet.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net;
|
||||
|
||||
|
||||
using Nettention.Proud;
|
||||
using NeoSmart.AsyncLock;
|
||||
|
||||
|
||||
using ServerCore;
|
||||
using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
public abstract partial class UserBase : EntityBase, IEntityWithSession, IWithLogActor
|
||||
{
|
||||
public bool isCompletedLogout() => m_is_completed_logout;
|
||||
|
||||
public void setCompletedLogout() => m_is_completed_logout = true;
|
||||
|
||||
public DateTime getLoginStartTime() => m_login_start_time;
|
||||
|
||||
public void setLogoutEndTime(DateTime currentTime) => m_logout_end_time = currentTime;
|
||||
|
||||
public DateTime getLogoutEndTime() => m_logout_end_time;
|
||||
|
||||
public string getUserNickname() => getOriginEntityAttribute<NicknameAttribute>()?.Nickname ?? string.Empty;
|
||||
|
||||
public UInt64 getSsoAccountAuthWebAccessToken() => getOriginEntityAttribute<AccountAttribute>()?.AccessToken ?? 0;
|
||||
|
||||
public string getAccountId() => getOriginEntityAttribute<AccountAttribute>()?.AccountId ?? string.Empty;
|
||||
|
||||
public string getAccountIdString() => getOriginEntityAttribute<AccountAttribute>()?.AccountIdString ?? string.Empty;
|
||||
|
||||
public string getUserGuid() => getOriginEntityAttribute<AccountAttribute>()?.UserGuid ?? string.Empty;
|
||||
|
||||
public ListenSessionBase? getListenSessionBase() => m_listen_session_base;
|
||||
|
||||
public void setListenSessionBase(ListenSessionBase listenSessionBase) => m_listen_session_base = listenSessionBase;
|
||||
|
||||
public SESSION_ID getSessionId() => m_host_id.toSESSION_ID();
|
||||
|
||||
public HostID getHostId() => m_host_id;
|
||||
}
|
||||
352
ServerCommon/Entity/Inventory/InventoryBase.cs
Normal file
352
ServerCommon/Entity/Inventory/InventoryBase.cs
Normal file
@@ -0,0 +1,352 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using MetaAssets;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon;
|
||||
|
||||
|
||||
public abstract class InventoryBase<TSlotType> : SlotsWrapperBase<SlotsWithEntityBase<TSlotType>>, IWithInventoryAccessor
|
||||
where TSlotType : notnull
|
||||
{
|
||||
public InventoryBase(EntityType entityType, EntityBase parent)
|
||||
: base(entityType, parent)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual Result onTryTakeInEntityBase(TSlotType entityGuid, EntityBase toTakeInEntityBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var result = tryIsEquipableOrEquipWithEntityBase(entityGuid, toTakeInEntityBase);
|
||||
if (result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to onTryIsEquipableOrEquipWithEntityBase() !!! : {result.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public virtual Result onTryTakeOutEnityBase(ENTITY_GUID entityGuid, out EntityBase? takenOutEntityBase)
|
||||
{
|
||||
var err_msg = string.Empty;
|
||||
|
||||
takenOutEntityBase = null;
|
||||
|
||||
var result = tryUnequipableOrUnequipWithEntityBase(entityGuid, out var taken_out_entity_base);
|
||||
if (result.isFail())
|
||||
{
|
||||
err_msg = $"Failed to onTryUnequipableOrUnequipWithEntityBase() !!! : {result.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return result;
|
||||
}
|
||||
takenOutEntityBase = taken_out_entity_base;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public (Result, List<ItemAttributeBase>, UInt16) findItemAttributeBaseAllByMetaId(META_ID itemMetaId, UInt32 toCheckItemCount = UInt32.MaxValue)
|
||||
{
|
||||
var parent = getDirectParent();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"paren is null !!!");
|
||||
var inven_data = getData();
|
||||
NullReferenceCheckHelper.throwIfNull(inven_data, () => $"inven_data is null !!! - {parent.toBasicString()}");
|
||||
|
||||
var err_msg = string.Empty;
|
||||
var result = new Result();
|
||||
|
||||
var target_item_attributes = new List<ItemAttributeBase>();
|
||||
|
||||
if (0 >= itemMetaId)
|
||||
{
|
||||
err_msg = $"Invalid ItemMetaId !!! : itemMetaId:{itemMetaId} > 0 - {parent.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.MetaIdInvalid, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return (result, target_item_attributes, 0);
|
||||
}
|
||||
|
||||
// 1. 아이템 메타 정보를 얻는다.
|
||||
if (false == MetaData.Instance._ItemTable.TryGetValue((int)itemMetaId, out var itemMetaData))
|
||||
{
|
||||
err_msg = $"Not found ItemMeta !!! : itemMetaId:{itemMetaId} - {parent.toBasicString()}";
|
||||
result.setFail(ServerErrorCode.ItemMetaDataNotFound, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return (result, target_item_attributes, 0);
|
||||
}
|
||||
|
||||
// 2. 동일한 종류의 현재 Origin ItemAttributeBase 목록을 얻는다.
|
||||
var found_origin_item_attributes = getHasSlotsWithEntityBases().Where(x =>
|
||||
{
|
||||
var item_attribute_base = x.Value.getOriginEntityAttribute<ItemAttributeBase>();
|
||||
NullReferenceCheckHelper.throwIfNull(item_attribute_base, () => $"item_attribute_base is null !!! - {parent.toBasicString()}");
|
||||
|
||||
if ( item_attribute_base.ItemMetaId == itemMetaId
|
||||
&& item_attribute_base.ItemStackCount > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}).Select(x =>
|
||||
{
|
||||
var item_attribute_base = x.Value.getOriginEntityAttribute<ItemAttributeBase>();
|
||||
NullReferenceCheckHelper.throwIfNull(item_attribute_base, () => $"item_attribute_base is null !!! - {parent.toBasicString()}");
|
||||
|
||||
return (item_attribute_base.ItemGuid, item_attribute_base);
|
||||
}).ToDictionary();
|
||||
|
||||
// 3. 동일한 종류의 예약된 Cloned ItemAttributeBase 목록을 얻는다.
|
||||
var found_cloned_item_attributes = new Dictionary<ITEM_GUID, ItemAttributeBase>();
|
||||
var found_transaction_runner = parent.findTransactionRunner(TransactionIdType.PrivateContents);
|
||||
if (null != found_transaction_runner)
|
||||
{
|
||||
var entity_attribute_transactors = found_transaction_runner.getEntityAttributeTransactorAll(parent.onGetAvailableItemAttributeType());
|
||||
found_cloned_item_attributes = entity_attribute_transactors.Where(x =>
|
||||
{
|
||||
var item_attribute_base = x.Value.getClonedEntityAttribute() as ItemAttributeBase;
|
||||
NullReferenceCheckHelper.throwIfNull(item_attribute_base, () => $"item_attribute_base is null !!! - {parent.toBasicString()}");
|
||||
|
||||
if ( item_attribute_base.ItemMetaId == itemMetaId
|
||||
&& item_attribute_base.ItemStackCount >= 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}).Select(x =>
|
||||
{
|
||||
var item_attribute = x.Value.getClonedEntityAttribute() as ItemAttributeBase;
|
||||
NullReferenceCheckHelper.throwIfNull(item_attribute, () => $"item_attribute is null !!! - {parent.toBasicString()}");
|
||||
|
||||
return (item_attribute.ItemGuid, item_attribute);
|
||||
}).ToDictionary();
|
||||
}
|
||||
|
||||
// 4. Cloned 정보가 있거나, Origin 정보만 있는 경우 대상 아이템으로 추가한다 !!!
|
||||
var all_keys = found_origin_item_attributes.Keys.Concat(found_cloned_item_attributes.Keys).Distinct();
|
||||
foreach (var key in all_keys)
|
||||
{
|
||||
// 4.1. Cloned 정보가 있는데, 삭제 대상일 경우는 Origin & Cloned 모두 무시 한다.
|
||||
if(true == found_cloned_item_attributes.TryGetValue(key, out var found_cloned_attribute))
|
||||
{
|
||||
var stack_count = found_cloned_attribute.ItemStackCount;
|
||||
if (0 >= stack_count)
|
||||
{
|
||||
// 4.1.1. Cloned 정보가 삭제 대상일 경우 추가하지 않는다. (삭제될거니까...)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 4.1.2. Cloned 정보의 아이템 개수가 존재 한다면 추가 한다.
|
||||
target_item_attributes.Add(found_cloned_attribute);
|
||||
}
|
||||
}
|
||||
// 4.2. Origin 정보만 있는 경우 추가 한다.
|
||||
else if (found_origin_item_attributes.ContainsKey(key) && false == found_cloned_item_attributes.ContainsKey(key))
|
||||
{
|
||||
var only_origin_item_attribute = found_origin_item_attributes[key];
|
||||
|
||||
target_item_attributes.Add(only_origin_item_attribute);
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 조건에 총족된 대상 아이템들의 StackCount 합산 개수를 얻는다.
|
||||
var item_has_count = target_item_attributes.Sum(x => {
|
||||
return x.ItemStackCount;
|
||||
});
|
||||
|
||||
return (result, target_item_attributes, (UInt16)item_has_count);
|
||||
}
|
||||
|
||||
public EntityBase? findEntityBase(TSlotType toFindEntityBaseKey)
|
||||
{
|
||||
var parent = getDirectParent();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!!");
|
||||
|
||||
var inven_data = getData();
|
||||
NullReferenceCheckHelper.throwIfNull(inven_data, () => $"inven_data is null !!! - {parent.toBasicString()}");
|
||||
|
||||
var found_entity_base = inven_data.findEntityBaseInSlotType(toFindEntityBaseKey);
|
||||
if (null == found_entity_base)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return found_entity_base;
|
||||
}
|
||||
|
||||
public override void onWriteLog()
|
||||
{
|
||||
var parent = getDirectParent();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!!");
|
||||
|
||||
var has_items = getHasSlotsWithEntityBases();
|
||||
NullReferenceCheckHelper.throwIfNull(has_items, () => $"has_items is null !!! - {parent.toBasicString()}");
|
||||
|
||||
foreach (var each in has_items)
|
||||
{
|
||||
var slot_type = each.Key;
|
||||
|
||||
META_ID item_meta_id = 0;
|
||||
var item_guid = string.Empty;
|
||||
var item_stack_count = 0;
|
||||
var item_max_stack_count = 0;
|
||||
|
||||
var item_base = each.Value as ItemBase;
|
||||
if (null != item_base)
|
||||
{
|
||||
var item_attibute_base = item_base.getEntityAttribute<ItemAttributeBase>();
|
||||
NullReferenceCheckHelper.throwIfNull(item_attibute_base, () => $"item_attibute_base is null !!!");
|
||||
|
||||
item_meta_id = (META_ID)item_attibute_base.ItemMetaId;
|
||||
item_guid = item_attibute_base.ItemGuid;
|
||||
item_stack_count = item_attibute_base.ItemStackCount;
|
||||
|
||||
if (true == MetaData.Instance._ItemTable.TryGetValue((int)item_meta_id, out var found_item_meta))
|
||||
{
|
||||
item_max_stack_count = found_item_meta.StackMaxCount;
|
||||
}
|
||||
}
|
||||
|
||||
var err_msg = $"SlotType:{slot_type}, ItemMetaId:{item_meta_id}, StackCount:{item_stack_count}, MaxStackCount:{item_max_stack_count}, ItemGuid:{item_guid}";
|
||||
Log.getLogger().info(err_msg);
|
||||
}
|
||||
}
|
||||
|
||||
public ConcurrentDictionary<TSlotType, EntityBase> getHasSlotsWithEntityBases()
|
||||
{
|
||||
var parent = getDirectParent();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!!");
|
||||
|
||||
var inven_data = getData();
|
||||
NullReferenceCheckHelper.throwIfNull(inven_data, () => $"inven_data is null !!! - {parent.toBasicString()}");
|
||||
|
||||
var slots = inven_data.getSlots() as ConcurrentDictionary<TSlotType, EntityBase>;
|
||||
NullReferenceCheckHelper.throwIfNull(slots, () => $"slots is null !!! - {parent.toBasicString()}");
|
||||
|
||||
return slots;
|
||||
}
|
||||
|
||||
public List<EntityBase> getHasEntityBases()
|
||||
{
|
||||
var parent = getDirectParent();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!!");
|
||||
|
||||
var inven_data = getData();
|
||||
NullReferenceCheckHelper.throwIfNull(inven_data, () => $"inven_data is null !!! - {parent.toBasicString()}");
|
||||
|
||||
var slots_with_entity_bases = getHasSlotsWithEntityBases();
|
||||
NullReferenceCheckHelper.throwIfNull(slots_with_entity_bases, () => $"slots_with_entity_bases is null !!! - {parent.toBasicString()}");
|
||||
|
||||
return slots_with_entity_bases.Select(x => x.Value).ToList();
|
||||
}
|
||||
|
||||
// IWithInventoryAccessor.clearItemAll()
|
||||
public void clearItemAll()
|
||||
{
|
||||
var parent = getDirectParent();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"paren is null !!!");
|
||||
var inven_data = getData();
|
||||
NullReferenceCheckHelper.throwIfNull(inven_data, () => $"inven_data is null !!! - {parent.toBasicString()}");
|
||||
|
||||
var slots = inven_data.getSlots() as ConcurrentDictionary<TSlotType, EntityBase>;
|
||||
NullReferenceCheckHelper.throwIfNull(slots, () => $"slots is null !!! - {parent.toBasicString()}");
|
||||
|
||||
slots.Clear();
|
||||
}
|
||||
|
||||
// IWithInventoryAccessor.getHasItemBases()
|
||||
public List<ItemBase> getHasItemBases()
|
||||
{
|
||||
var parent = getDirectParent();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!!");
|
||||
|
||||
return getHasSlotsWithEntityBases().Select(x =>
|
||||
{
|
||||
var item_base = x.Value as ItemBase;
|
||||
NullReferenceCheckHelper.throwIfNull(item_base, () => $"item_base is null !!! - {parent.toBasicString()}");
|
||||
|
||||
return item_base;
|
||||
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
// IWithInventoryAccessor.tryEquipWithItemBase()
|
||||
public ServerErrorCode tryEquipWithItemBase(string slotType, ItemBase itemBase)
|
||||
{
|
||||
var parent = getDirectParent();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!!");
|
||||
|
||||
var inven_data = getData();
|
||||
NullReferenceCheckHelper.throwIfNull(inven_data, () => $"inven_data is null !!! - {parent.toBasicString()}");
|
||||
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if(false == slotType.fillupEnumTypeAndValueStringToEnum<TSlotType>("None", out var target_slot_type) || null == target_slot_type)
|
||||
{
|
||||
err_msg = $"Failed to fillupEnumTypeAndValueStringToEnum<TSlotType>() !!!, SlotType of Target Inventory : targetSlotType:{slotType} - {parent.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
|
||||
return ServerErrorCode.StringConvertToEnumFailed;
|
||||
}
|
||||
|
||||
return inven_data.onTryEquipWithEntityBase(target_slot_type, itemBase);
|
||||
}
|
||||
|
||||
// IWithInventoryAccessor.tryUnequipWithItemBase()
|
||||
public ServerErrorCode tryUnequipWithItemBase(string slotType, out ItemBase? itemBase)
|
||||
{
|
||||
itemBase = null;
|
||||
|
||||
var parent = getDirectParent();
|
||||
NullReferenceCheckHelper.throwIfNull(parent, () => $"parent is null !!!");
|
||||
|
||||
var inven_data = getData();
|
||||
NullReferenceCheckHelper.throwIfNull(inven_data, () => $"inven_data is null !!! - {parent.toBasicString()}");
|
||||
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (false == slotType.fillupEnumTypeAndValueStringToEnum<TSlotType>("None", out var target_slot_type) || null == target_slot_type)
|
||||
{
|
||||
err_msg = $"Failed to fillupEnumTypeAndValueStringToEnum<TSlotType>() !!!, SlotType of Target Inventory : targetSlotType:{slotType} - {parent.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
|
||||
return ServerErrorCode.StringConvertToEnumFailed;
|
||||
}
|
||||
|
||||
var result_code = inven_data.onTryUnequipWithEntityBase(target_slot_type, out EntityBase? entity_base);
|
||||
if (ServerErrorCode.Success == result_code)
|
||||
{
|
||||
itemBase = entity_base as ItemBase;
|
||||
}
|
||||
|
||||
return result_code;
|
||||
}
|
||||
}
|
||||
339
ServerCommon/Entity/Inventory/InventoryRule.cs
Normal file
339
ServerCommon/Entity/Inventory/InventoryRule.cs
Normal file
@@ -0,0 +1,339 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
|
||||
using Amazon.Runtime.Internal.Transform;
|
||||
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public abstract class RuleBase
|
||||
{
|
||||
public HashSet<MetaAssets.EItemLargeType> EquipableItemLargeTypes { get; set; } = new();
|
||||
|
||||
public HashSet<MetaAssets.EItemSmallType> EquipableItemSmallTypes { get; set; } = new();
|
||||
|
||||
public EntityDynamoDbSortKeyType EntitySKType { get; set; } = EntityDynamoDbSortKeyType.None;
|
||||
|
||||
public RuleBase() { }
|
||||
}
|
||||
|
||||
public class BagRule : RuleBase
|
||||
{
|
||||
public InvenBagType InvenBagType { get; set; } = InvenBagType.None;
|
||||
|
||||
public BagTabType UsableBagTabType { get; set; } = BagTabType.None;
|
||||
|
||||
|
||||
public BagRule()
|
||||
{ }
|
||||
}
|
||||
|
||||
public abstract class EquipRuleBase : RuleBase
|
||||
{
|
||||
public InvenEquipType InvenEquipType { get; set; } = InvenEquipType.None;
|
||||
|
||||
public abstract Result onConfigure(InvenEquipType equipType);
|
||||
}
|
||||
|
||||
public class ToolEquipRule : EquipRuleBase
|
||||
{
|
||||
public List<ToolSlotType> UsableToolSlotTypes { get; set; } = new();
|
||||
|
||||
public ToolEquipRule()
|
||||
{ }
|
||||
|
||||
public override Result onConfigure(InvenEquipType equipType)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
foreach (var item_large_type in equipType.toEquipableItemLargeTypes())
|
||||
{
|
||||
if (false == EquipableItemLargeTypes.Add(item_large_type))
|
||||
{
|
||||
err_msg = $"Failed to Add() EquipableItemLargeTypes !!!, duplicated EItemLargeType : EItemLargeType:{item_large_type} - InvenEquipType:{equipType}";
|
||||
result.setFail(ServerErrorCode.ToolEquipRuleItemLargeTypeDuplicated, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
UsableToolSlotTypes = equipType.toEquipableToolSlotTypes();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class ClothEquipRule : EquipRuleBase
|
||||
{
|
||||
public Dictionary<ClothSlotType, List<MetaAssets.EItemSmallType>> m_slots_by_cloth_slot_type = new();
|
||||
public Dictionary<MetaAssets.EItemSmallType, List<ClothSlotType>> m_slots_by_item_type = new();
|
||||
|
||||
public ClothEquipRule()
|
||||
{ }
|
||||
|
||||
public override Result onConfigure(InvenEquipType equipType)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
foreach (var item_large_type in equipType.toEquipableItemLargeTypes())
|
||||
{
|
||||
if (false == EquipableItemLargeTypes.Add(item_large_type))
|
||||
{
|
||||
err_msg = $"Failed to Add() EquipableItemLargeTypes !!!, duplicated EItemLargeType : EItemLargeType:{item_large_type} - InvenEquipType:{equipType}";
|
||||
result.setFail(ServerErrorCode.ClothEquipRuleItemLargeTypeDuplicated, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
var cloth_slot_types = EnumHelper.getValuesWithoutScopeAll<ClothSlotType>();
|
||||
foreach(var slot_type in cloth_slot_types)
|
||||
{
|
||||
if (false == m_slots_by_cloth_slot_type.TryGetValue(slot_type, out var found_item_small_types))
|
||||
{
|
||||
found_item_small_types = new List<MetaAssets.EItemSmallType>();
|
||||
m_slots_by_cloth_slot_type.Add(slot_type, found_item_small_types);
|
||||
}
|
||||
found_item_small_types = equipType.toEquipableItemSmallTypesWithClothSlotType(slot_type);
|
||||
|
||||
foreach(var item_small_type in found_item_small_types)
|
||||
{
|
||||
if (false == m_slots_by_item_type.TryGetValue(item_small_type, out var found_slot_types))
|
||||
{
|
||||
found_slot_types = new List<ClothSlotType>();
|
||||
m_slots_by_item_type.Add(item_small_type, found_slot_types);
|
||||
}
|
||||
if(false == found_slot_types.Exists(x => x == slot_type))
|
||||
{
|
||||
found_slot_types.Add(slot_type);
|
||||
}
|
||||
|
||||
EquipableItemSmallTypes.Add(item_small_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class TattooEquipRule : EquipRuleBase
|
||||
{
|
||||
public List<TattooSlotType> UsableTattooSlotPosOfDefault { get; set; } = new();
|
||||
|
||||
public List<TattooSlotType> UsableTattooSlotPosOfUgcNpc { get; set; } = new();
|
||||
|
||||
public TattooEquipRule()
|
||||
{ }
|
||||
|
||||
public override Result onConfigure(InvenEquipType equipType)
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
foreach (var item_large_type in equipType.toEquipableItemLargeTypes())
|
||||
{
|
||||
if (false == EquipableItemLargeTypes.Add(item_large_type))
|
||||
{
|
||||
err_msg = $"Failed to Add() EquipableItemLargeTypes !!!, duplicated EItemLargeType : EItemLargeType:{item_large_type} - InvenEquipType:{equipType}";
|
||||
result.setFail(ServerErrorCode.TattooEquipRuleItemLargeTypeDuplicated, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
UsableTattooSlotPosOfDefault = equipType.toEquipableTattooSlotTypes();
|
||||
UsableTattooSlotPosOfUgcNpc = equipType.toEquipableTattooSlotTypes(EntityType.UgcNpc);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<TattooSlotType> getUsableTattooSlotPos(EntityType entityType)
|
||||
{
|
||||
if( EntityType.UgcNpc == entityType
|
||||
|| EntityType.Beacon == entityType )
|
||||
{
|
||||
return UsableTattooSlotPosOfUgcNpc;
|
||||
}
|
||||
|
||||
return UsableTattooSlotPosOfDefault;
|
||||
}
|
||||
}
|
||||
|
||||
public class InventoryRule : IRule
|
||||
{
|
||||
private readonly Dictionary<InvenBagType, BagRule> m_bag_rules = new();
|
||||
private readonly Dictionary<MetaAssets.EItemLargeType, List<BagRule>> m_bag_rules_by_item_type = new();
|
||||
private readonly Dictionary<InvenEquipType, EquipRuleBase> m_equip_rule_bases = new();
|
||||
private readonly Dictionary<MetaAssets.EItemLargeType, List<EquipRuleBase>> m_equip_rule_bases_by_item_type = new();
|
||||
|
||||
public InventoryRule()
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<Result> onInit()
|
||||
{
|
||||
var result = await configure();
|
||||
if(result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<Result> configure()
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var inven_bag_type_enums = EnumHelper.getValuesWithoutScopeAll<InvenBagType>();
|
||||
foreach(var value in inven_bag_type_enums)
|
||||
{
|
||||
var bag_rule = new BagRule();
|
||||
bag_rule.InvenBagType = value;
|
||||
foreach(var item_type in value.toEquipableItemLargeTypes())
|
||||
{
|
||||
if(false == bag_rule.EquipableItemLargeTypes.Add(item_type))
|
||||
{
|
||||
err_msg = $"Failed to Add() EquipableItemLargeTypes !!!, duplicated EItemLargeType : EItemLargeType:{item_type} - InvenBagType:{value}";
|
||||
result.setFail(ServerErrorCode.BagRuleItemLargeTypeDuplicated, err_msg);
|
||||
Log.getLogger().error(result.toBasicString());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
bag_rule.UsableBagTabType = value.toUsableBagTabType();
|
||||
m_bag_rules.Add(value, bag_rule);
|
||||
}
|
||||
|
||||
var item_type_to_bag_types = EnumHelper.getValuesWithoutScopeAll<MetaAssets.EItemLargeType>();
|
||||
foreach (var item_type in item_type_to_bag_types)
|
||||
{
|
||||
foreach(var eache in m_bag_rules)
|
||||
{
|
||||
if(false == eache.Value.EquipableItemLargeTypes.Contains(item_type))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if(false == m_bag_rules_by_item_type.TryGetValue(item_type, out var found_bag_rules))
|
||||
{
|
||||
found_bag_rules = new List<BagRule>();
|
||||
m_bag_rules_by_item_type.Add(item_type, found_bag_rules);
|
||||
}
|
||||
found_bag_rules.Add(eache.Value);
|
||||
}
|
||||
}
|
||||
|
||||
var inven_equip_type_enums = EnumHelper.getValuesWithoutScopeAll<InvenEquipType>();
|
||||
foreach (var value in inven_equip_type_enums)
|
||||
{
|
||||
var equip_rule_base = newEquipRuleBaseByInvenEquipType(value);
|
||||
if (equip_rule_base == null)
|
||||
continue;
|
||||
|
||||
equip_rule_base.InvenEquipType = value;
|
||||
result = equip_rule_base.onConfigure(value);
|
||||
if(result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
equip_rule_base.EntitySKType = value.toEntitySKType();
|
||||
m_equip_rule_bases.Add(value, equip_rule_base);
|
||||
}
|
||||
|
||||
var item_type_to_equip_types = EnumHelper.getValuesWithoutScopeAll<MetaAssets.EItemLargeType>();
|
||||
foreach (var item_type in item_type_to_equip_types)
|
||||
{
|
||||
foreach (var eache in m_equip_rule_bases)
|
||||
{
|
||||
if (false == eache.Value.EquipableItemLargeTypes.Contains(item_type))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (false == m_equip_rule_bases_by_item_type.TryGetValue(item_type, out var found_equip_rule_bases))
|
||||
{
|
||||
found_equip_rule_bases = new List<EquipRuleBase>();
|
||||
m_equip_rule_bases_by_item_type.Add(item_type, found_equip_rule_bases);
|
||||
}
|
||||
found_equip_rule_bases.Add(eache.Value);
|
||||
}
|
||||
}
|
||||
|
||||
return await Task.FromResult(result);
|
||||
}
|
||||
|
||||
public EquipRuleBase? newEquipRuleBaseByInvenEquipType(InvenEquipType equipType)
|
||||
{
|
||||
switch(equipType)
|
||||
{
|
||||
case InvenEquipType.Tool:
|
||||
return new ToolEquipRule();
|
||||
|
||||
case InvenEquipType.Cloth:
|
||||
return new ClothEquipRule();
|
||||
|
||||
case InvenEquipType.Tattoo:
|
||||
return new TattooEquipRule();
|
||||
|
||||
default:
|
||||
var err_msg = $"Failed to newEquipRuleBaseByInvenEquipType() !!!, Invalid InvenEquipType : InvenEquipType:{equipType}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public BagRule? getBagRuleByInvenBagType(InvenBagType bagType)
|
||||
{
|
||||
m_bag_rules.TryGetValue(bagType, out var found_bag_rules);
|
||||
return found_bag_rules;
|
||||
}
|
||||
|
||||
public EquipRuleBase? getEquipRuleBaseByInvenEquipType(InvenEquipType equipType)
|
||||
{
|
||||
m_equip_rule_bases.TryGetValue(equipType, out var found_equip_rule_bases);
|
||||
return found_equip_rule_bases;
|
||||
}
|
||||
|
||||
public List<BagRule>? getBagRulesByItemLargeType(MetaAssets.EItemLargeType itemType)
|
||||
{
|
||||
m_bag_rules_by_item_type.TryGetValue(itemType, out var found_bag_rules);
|
||||
return found_bag_rules;
|
||||
}
|
||||
|
||||
public List<EquipRuleBase>? getEquipRuleBasesByItemLargeType(MetaAssets.EItemLargeType itemType)
|
||||
{
|
||||
m_equip_rule_bases_by_item_type.TryGetValue(itemType, out var found_equip_rule_bases);
|
||||
return found_equip_rule_bases;
|
||||
}
|
||||
|
||||
public Dictionary<InvenBagType, BagRule> getBagRules() => m_bag_rules;
|
||||
|
||||
public Dictionary<InvenEquipType, EquipRuleBase> getEquipRuleBases() => m_equip_rule_bases;
|
||||
}
|
||||
}
|
||||
207
ServerCommon/Entity/Inventory/SlotBase.cs
Normal file
207
ServerCommon/Entity/Inventory/SlotBase.cs
Normal file
@@ -0,0 +1,207 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Axion.Collections.Concurrent;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public abstract class SlotsBase
|
||||
{
|
||||
private AtomicInt32 m_slot_max_count = new(0);
|
||||
|
||||
public virtual bool onInitSlots(int slotMaxCount)
|
||||
{
|
||||
m_slot_max_count.set(slotMaxCount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract UInt32 onGetCurrSlotCount();
|
||||
|
||||
public UInt32 getSlotMaxCount()
|
||||
{
|
||||
return (UInt32)m_slot_max_count.Value;
|
||||
}
|
||||
|
||||
public virtual string toBasicString()
|
||||
{
|
||||
return $"{this.getTypeName()}, UsingSlotCount:{onGetCurrSlotCount()}, SlotMaxCount:{m_slot_max_count.Value}";
|
||||
}
|
||||
}
|
||||
|
||||
public class Slots<TSlotType> : SlotsBase, ISlotsWithType<TSlotType>
|
||||
where TSlotType : Enum
|
||||
{
|
||||
private ConcurrentHashSet<TSlotType> m_slots = new();
|
||||
|
||||
public Slots()
|
||||
{ }
|
||||
|
||||
public override bool onInitSlots(int slotMaxCount)
|
||||
{
|
||||
m_slots = new ConcurrentHashSet<TSlotType>(MultiThreadHelper.getThreadOptimalCount(), (int)slotMaxCount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual ServerErrorCode onIsEquipable(TSlotType targetSlot)
|
||||
{
|
||||
return (false == m_slots.Contains(targetSlot)) ? ServerErrorCode.Success : ServerErrorCode.SlotsAlreadyEquiped;
|
||||
}
|
||||
|
||||
public virtual ServerErrorCode onTryEquip(TSlotType targetSlot)
|
||||
{
|
||||
return (true == m_slots.TryAdd(targetSlot, out _)) ? ServerErrorCode.Success : ServerErrorCode.SlotsAlreadyEquiped;
|
||||
}
|
||||
|
||||
public virtual ServerErrorCode onIsUnequipable(TSlotType targetSlot)
|
||||
{
|
||||
return (true == m_slots.Contains(targetSlot)) ? ServerErrorCode.Success : ServerErrorCode.SlotsAlreadyUnequiped;
|
||||
}
|
||||
|
||||
public virtual ServerErrorCode onTryUnequip(TSlotType targetSlot)
|
||||
{
|
||||
return (true == m_slots.TryRemove(targetSlot, out _)) ? ServerErrorCode.Success : ServerErrorCode.SlotsAlreadyUnequiped;
|
||||
}
|
||||
|
||||
public virtual ServerErrorCode onTryEquipWithEntityBase(TSlotType targetSlot, EntityBase entityBase) => ServerErrorCode.FunctionNotImplemented;
|
||||
|
||||
public virtual ServerErrorCode onTryUnequipWithEntityBase(TSlotType targetSlot, out EntityBase? entityBase)
|
||||
{
|
||||
entityBase = null;
|
||||
return ServerErrorCode.FunctionNotImplemented;
|
||||
}
|
||||
|
||||
public virtual EntityBase? onFindEntityBase(TSlotType targetSlot)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool isExistSlotType(TSlotType slotType)
|
||||
{
|
||||
return true == m_slots.Contains(slotType);
|
||||
}
|
||||
|
||||
public override UInt32 onGetCurrSlotCount()
|
||||
{
|
||||
return (UInt32)m_slots.Count;
|
||||
}
|
||||
|
||||
public List<EntityBase> getEntityBases()
|
||||
{
|
||||
return new List<EntityBase>();
|
||||
}
|
||||
|
||||
public ICollection getSlots() => m_slots;
|
||||
}
|
||||
|
||||
public class SlotsWithEntityBase<TSlotType> : SlotsBase, ISlotsWithType<TSlotType>
|
||||
where TSlotType : notnull
|
||||
{
|
||||
private ConcurrentDictionary<TSlotType, EntityBase> m_slots = new();
|
||||
|
||||
public SlotsWithEntityBase()
|
||||
{
|
||||
}
|
||||
|
||||
public override bool onInitSlots(int slotMaxCount)
|
||||
{
|
||||
m_slots = new ConcurrentDictionary<TSlotType, EntityBase>(MultiThreadHelper.getThreadOptimalCount(), (int)slotMaxCount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual ServerErrorCode onIsEquipable(TSlotType targetSlot)
|
||||
{
|
||||
return (false == m_slots.ContainsKey(targetSlot)) ? ServerErrorCode.Success : ServerErrorCode.SlotsAlreadyEquiped;
|
||||
}
|
||||
|
||||
public virtual ServerErrorCode onTryEquipWithEntityBase(TSlotType targetSlot, EntityBase entityBase)
|
||||
{
|
||||
return (true == m_slots.TryAdd(targetSlot, entityBase)) ? ServerErrorCode.Success : ServerErrorCode.SlotsAlreadyEquiped;
|
||||
}
|
||||
|
||||
public virtual ServerErrorCode onIsUnequipable(TSlotType targetSlot)
|
||||
{
|
||||
return (true == m_slots.ContainsKey(targetSlot)) ? ServerErrorCode.Success : ServerErrorCode.SlotsAlreadyUnequiped;
|
||||
}
|
||||
|
||||
public virtual ServerErrorCode onTryUnequipWithEntityBase(TSlotType targetSlot, out EntityBase? removedEntityBase)
|
||||
{
|
||||
removedEntityBase = null;
|
||||
if (false == m_slots.TryRemove(targetSlot, out var removed_entity_base))
|
||||
{
|
||||
return ServerErrorCode.SlotsAlreadyUnequiped;
|
||||
}
|
||||
removedEntityBase = removed_entity_base;
|
||||
|
||||
return ServerErrorCode.Success;
|
||||
}
|
||||
|
||||
public virtual EntityBase? onFindEntityBase(TSlotType targetSlot)
|
||||
{
|
||||
return findEntityBaseInSlotType(targetSlot);
|
||||
}
|
||||
|
||||
public EntityBase? findEntityBaseInSlotType(TSlotType targetSlot)
|
||||
{
|
||||
if(false == m_slots.TryGetValue(targetSlot, out var found_entity_base))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return found_entity_base;
|
||||
}
|
||||
|
||||
public EntityBase? findEntityBaseBy(Func<EntityBase, bool> isFound)
|
||||
{
|
||||
foreach(var each in m_slots)
|
||||
{
|
||||
var is_success = isFound(each.Value);
|
||||
if(true == is_success)
|
||||
{
|
||||
return each.Value;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool isExistSlotType(TSlotType slotType)
|
||||
{
|
||||
return true == m_slots.ContainsKey(slotType);
|
||||
}
|
||||
|
||||
public override UInt32 onGetCurrSlotCount()
|
||||
{
|
||||
return (UInt32)m_slots.Count;
|
||||
}
|
||||
|
||||
public List<EntityBase> getEntityBases()
|
||||
{
|
||||
return m_slots.Values.ToList();
|
||||
}
|
||||
|
||||
public ICollection getSlots() => m_slots;
|
||||
|
||||
public virtual ServerErrorCode onTryEquip(TSlotType targetSlot) => ServerErrorCode.FunctionNotImplemented;
|
||||
|
||||
public virtual ServerErrorCode onTryUnequip(TSlotType targetSlot) => ServerErrorCode.FunctionNotImplemented;
|
||||
}
|
||||
}
|
||||
266
ServerCommon/Entity/Inventory/SlotsWrapper.cs
Normal file
266
ServerCommon/Entity/Inventory/SlotsWrapper.cs
Normal file
@@ -0,0 +1,266 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
using Pipelines.Sockets.Unofficial.Buffers;
|
||||
|
||||
|
||||
using ServerCore; using ServerBase;
|
||||
|
||||
|
||||
using SESSION_ID = System.Int32;
|
||||
using WORLD_ID = System.UInt32;
|
||||
using META_ID = System.UInt32;
|
||||
using ENTITY_GUID = System.String;
|
||||
using ACCOUNT_ID = System.String;
|
||||
using OWNER_GUID = System.String;
|
||||
using USER_GUID = System.String;
|
||||
using CHARACTER_GUID = System.String;
|
||||
using ITEM_GUID = System.String;
|
||||
|
||||
|
||||
|
||||
namespace ServerCommon
|
||||
{
|
||||
public abstract partial class SlotsWrapperBase<TSlots> : EntityBase
|
||||
where TSlots : ISlots, new()
|
||||
{
|
||||
private readonly TSlots m_slots;
|
||||
|
||||
public SlotsWrapperBase(EntityType entityType, EntityBase parent)
|
||||
: base(entityType, parent)
|
||||
{
|
||||
m_slots = new TSlots();
|
||||
}
|
||||
|
||||
public virtual bool onInitSlots(int slotMaxCount)
|
||||
{
|
||||
return m_slots.onInitSlots(slotMaxCount);
|
||||
}
|
||||
|
||||
public Result tryIsEquipableOrEquip<TSlotType>(TSlotType targetSlotType)
|
||||
where TSlotType : Enum
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var direct_parent = getDirectParent();
|
||||
ArgumentNullException.ThrowIfNull(direct_parent, $"direct_parent is null !!!");
|
||||
|
||||
var slots = getData() as ISlotsWithType<TSlotType>;
|
||||
ArgumentNullException.ThrowIfNull(slots, $"slots is null !!! - {direct_parent.toBasicString()}");
|
||||
|
||||
var parent = getRootParent();
|
||||
if (null != parent)
|
||||
{
|
||||
// Transaction 활성화 상태일 경우
|
||||
var transaction_runner = parent.findTransactionRunner(TransactionIdType.PrivateContents);
|
||||
if (null != transaction_runner)
|
||||
{
|
||||
var slot_type = targetSlotType.ToString();
|
||||
var to_check_slot_type = slot_type;
|
||||
if (true == EnumHelper.isEnumType(to_check_slot_type))
|
||||
{
|
||||
slot_type = to_check_slot_type.convertEnumToEnumTypeAndValueString();
|
||||
}
|
||||
|
||||
// 장착 슬롯에 슬롯과 EntityBase를 장착 해제 예약 한다.
|
||||
result = transaction_runner.tryEquipToReserveSlot(direct_parent, getEntityType(), slot_type);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
err_msg = $"Succss tryEquipToReserveSlot() : targetSlotType:{slot_type} - {toBasicString()}, {parent.toBasicString()}";
|
||||
Log.getLogger().info(err_msg);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
var error_code = slots.onTryEquip(targetSlotType);
|
||||
if (error_code.isFail())
|
||||
{
|
||||
err_msg = $"Failed to onTryEquip() !!! : targetSlotType:{targetSlotType} - {toBasicString()}, {parent?.toBasicString()}";
|
||||
result.setFail(error_code, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Result tryIsEquipableOrEquipWithEntityBase<TSlotType>(TSlotType targetSlotType, EntityBase entityBase)
|
||||
where TSlotType : notnull
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var direct_parent = getDirectParent();
|
||||
ArgumentNullException.ThrowIfNull(direct_parent, $"direct_parent is null !!!");
|
||||
|
||||
var slots = getData() as ISlotsWithType<TSlotType>;
|
||||
ArgumentNullException.ThrowIfNull(slots, $"slots is null !!! - {direct_parent.toBasicString()}");
|
||||
|
||||
var parent = getRootParent();
|
||||
if (null != parent)
|
||||
{
|
||||
// Transaction 활성화 상태일 경우
|
||||
var transaction_runner = parent.findTransactionRunner(TransactionIdType.PrivateContents);
|
||||
if (null != transaction_runner)
|
||||
{
|
||||
var slot_type = targetSlotType.ToString();
|
||||
NullReferenceCheckHelper.throwIfNull(slot_type, () => $"slot_type is null !!!");
|
||||
var to_check_slot_type = slot_type;
|
||||
NullReferenceCheckHelper.throwIfNull(to_check_slot_type, () => $"to_check_slot_type is null !!!");
|
||||
|
||||
if (true == EnumHelper.isEnumType(to_check_slot_type))
|
||||
{
|
||||
slot_type = to_check_slot_type.convertEnumToEnumTypeAndValueString();
|
||||
}
|
||||
|
||||
// 장착 슬롯에 슬롯과 EntityBase를 장착 예약 한다.
|
||||
result = transaction_runner.tryEquipToReserveSlotWithEntityBase(direct_parent, getEntityType(), slot_type, entityBase);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
err_msg = $"Succss tryEquipToReserveSlotWithEntityBase() : targetSlotType:{slot_type} - {toBasicString()}, {parent.toBasicString()}";
|
||||
Log.getLogger().info(err_msg);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
var error_code = slots.onTryEquipWithEntityBase(targetSlotType, entityBase);
|
||||
if (error_code.isFail())
|
||||
{
|
||||
err_msg = $"Failed to onTryEquipWithEntityBase() !!! : {error_code.toBasicString()}, targetSlotType:{targetSlotType}, {entityBase.toBasicString()} - {toBasicString()}, {parent?.toBasicString()}";
|
||||
result.setFail(error_code, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Result tryUnequipableOrUnequip<TSlotType>(TSlotType targetSlotType)
|
||||
where TSlotType : Enum
|
||||
{
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var direct_parent = getDirectParent();
|
||||
ArgumentNullException.ThrowIfNull(direct_parent, $"direct_parent is null !!!");
|
||||
|
||||
var slots = getData() as ISlotsWithType<TSlotType>;
|
||||
ArgumentNullException.ThrowIfNull(slots, $"slots is null !!! - {direct_parent.toBasicString()}");
|
||||
|
||||
var parent = getRootParent();
|
||||
if (null != parent)
|
||||
{
|
||||
// Transaction 활성화 상태일 경우
|
||||
var transaction_runner = parent.findTransactionRunner(TransactionIdType.PrivateContents);
|
||||
if (null != transaction_runner)
|
||||
{
|
||||
var slot_type = targetSlotType.ToString();
|
||||
var to_check_slot_type = slot_type;
|
||||
if (true == EnumHelper.isEnumType(to_check_slot_type))
|
||||
{
|
||||
slot_type = to_check_slot_type.convertEnumToEnumTypeAndValueString();
|
||||
}
|
||||
|
||||
// 장착 슬롯에 슬롯과 EntityBase를 장착 해제 예약 한다.
|
||||
result = transaction_runner.tryUnequipToReserveSlot(direct_parent, getEntityType(), slot_type);
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
err_msg = $"Success tryUnequipToReserveSlot() : targetSlotType:{slot_type} - {toBasicString()}, {parent.toBasicString()}";
|
||||
Log.getLogger().info(err_msg);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
var error_code = slots.onTryUnequip(targetSlotType);
|
||||
if (error_code.isFail())
|
||||
{
|
||||
err_msg = $"Failed to onTryUnequip() !!! : targetSlotType:{targetSlotType} - {toBasicString()}, {parent?.toBasicString()}";
|
||||
result.setFail(error_code, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Result tryUnequipableOrUnequipWithEntityBase<TSlotType>(TSlotType targetSlotType, out EntityBase? unequipedEntityBase)
|
||||
where TSlotType : notnull
|
||||
{
|
||||
unequipedEntityBase = null;
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
var direct_parent = getDirectParent();
|
||||
ArgumentNullException.ThrowIfNull(direct_parent, $"direct_parent is null !!!");
|
||||
|
||||
var slots = getData() as ISlotsWithType<TSlotType>;
|
||||
ArgumentNullException.ThrowIfNull(slots, $"slots is null !!! - {direct_parent.toBasicString()}");
|
||||
|
||||
var parent = getRootParent();
|
||||
if (null != parent)
|
||||
{
|
||||
// Transaction 활성화 상태일 경우
|
||||
var transaction_runner = parent.findTransactionRunner(TransactionIdType.PrivateContents);
|
||||
if (null != transaction_runner)
|
||||
{
|
||||
var slot_type = targetSlotType.ToString();
|
||||
NullReferenceCheckHelper.throwIfNull(slot_type, () => $"slot_type is null !!!");
|
||||
var to_check_slot_type = slot_type;
|
||||
NullReferenceCheckHelper.throwIfNull(to_check_slot_type, () => $"to_check_slot_type is null !!!");
|
||||
|
||||
if (true == EnumHelper.isEnumType(to_check_slot_type))
|
||||
{
|
||||
slot_type = to_check_slot_type.convertEnumToEnumTypeAndValueString();
|
||||
}
|
||||
|
||||
// 장착 슬롯에 슬롯과 EntityBase를 장착 해제 예약 한다.
|
||||
result = transaction_runner.tryUnequipToReserveSlotWithEntityBase(direct_parent, getEntityType(), slot_type, slots.onFindEntityBase(targetSlotType));
|
||||
if (result.isFail())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
err_msg = $"Success tryUnequipToReserveSlotWithEntityBase() : targetSlotType:{slot_type} - {toBasicString()}, {parent.toBasicString()}";
|
||||
Log.getLogger().info(err_msg);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
var error_code = slots.onTryUnequipWithEntityBase(targetSlotType, out var unequiped_entity_base);
|
||||
if (error_code.isFail())
|
||||
{
|
||||
err_msg = $"Failed to onTryUnequipWithEntityBase() !!! : {error_code.toBasicString()}, targetSlotType:{targetSlotType} - {toBasicString()}, {parent?.toBasicString()}";
|
||||
result.setFail(error_code, err_msg);
|
||||
return result;
|
||||
}
|
||||
|
||||
unequipedEntityBase = unequiped_entity_base;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public virtual void onWriteLog()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public TSlots getData() => m_slots;
|
||||
|
||||
public override string toBasicString()
|
||||
{
|
||||
return $"{this.getTypeName()}, {m_slots.toBasicString()}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user