초기커밋

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