using Google.Protobuf; using Google.Protobuf.WellKnownTypes; using ServerCore; using ServerBase; using ServerCommon; using ServerCommon.BusinessLogDomain; using MetaAssets; namespace GameServer; public class NoticeChat : EntityBase { private NoticeChat(EntityBase parent) : base(EntityType.NoticeChat, parent) { } public override async Task onInit() { addEntityAttribute(new NoticeChatAttribute(this)); return await base.onInit(); } public static async Task<(Result, NoticeChat?)> createTestNoticeChat(EntityBase owner, int chat_id, int messageType, string KoMessage, string EnMessage) { var notice_chat = new NoticeChat(owner); var result = await notice_chat.onInit(); if (result.isFail()) { return (result, null); } var err_msg = string.Empty; DateTime now = DateTime.UtcNow; var notice_chat_attribute = notice_chat.getEntityAttribute(); if (notice_chat_attribute == null) { err_msg = $"Failed to get notice chat attribute : {nameof(NoticeChatAttribute)}"; result.setFail(ServerErrorCode.EntityAttributeIsNull, err_msg); Log.getLogger().error(err_msg); return (result, null); } List detailInfos = new(); detailInfos.Add(new NoticeChatDetail() { ChatMessage = $"{chat_id} {KoMessage}", Languagetype = LanguageType.Ko }); detailInfos.Add(new NoticeChatDetail() { ChatMessage = $"{chat_id} {EnMessage}", Languagetype = LanguageType.En }); detailInfos.Add(new NoticeChatDetail() { ChatMessage = $"{chat_id} あなたの名前は何ですか", Languagetype = LanguageType.Ja }); notice_chat_attribute.ChatId = chat_id; notice_chat_attribute.NextNoticeTime = now; notice_chat_attribute.RepeatCount = 10; notice_chat_attribute.RepeatMinuteTime = 1; notice_chat_attribute.Sender = "[GM]그리노스"; notice_chat_attribute.MessageType = messageType; notice_chat_attribute.DetailList = detailInfos; notice_chat_attribute.newEntityAttribute(); return (result, notice_chat); } public static async Task<(Result, NoticeChat?)> createMailFromDoc(EntityBase parent, NoticeChatDoc doc) { var system_mail = new NoticeChat(parent); var result = await system_mail.onInit(); if (result.isFail()) { return (result, null); } var err_msg = string.Empty; var notice_chat_attribute = system_mail.getEntityAttribute(); if (notice_chat_attribute == null) { err_msg = $"Failed to get notice chat attribute : {nameof(NoticeChatAttribute)}"; result.setFail(ServerErrorCode.EntityAttributeIsNull, err_msg); Log.getLogger().error(err_msg); return (result, null); } if (notice_chat_attribute.copyEntityAttributeFromDoc(doc) == false) { err_msg = $"Failed to copyEntityAttributeFromDoc !!! : doc_type {doc.GetType()} - {system_mail.getRootParent().toBasicString()}"; result.setFail(ServerErrorCode.DynamoDbDocCopyToEntityAttributeFailed, err_msg); Log.getLogger().error(err_msg); return (result, null); } return (result, system_mail); } public override string toBasicString() { return $"{this.getTypeName()} - {getRootParent().toBasicString()}"; } public override string toSummaryString() { return $"{this.getTypeName()} - {getRootParent().toBasicString()}"; } }