초기커밋

This commit is contained in:
2025-05-01 07:20:41 +09:00
commit 98bb2e3c5c
2747 changed files with 646947 additions and 0 deletions

View 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;
}
}
}