Files
caliverse_server/GameServer/z.Backup/OwnedMail.cs
2025-05-01 07:20:41 +09:00

347 lines
12 KiB
C#

//using Nettention.Proud;
//using ServerCore; using ServerBase;
//using Google.Protobuf.WellKnownTypes;
//using ServerCommon;
//using Amazon.CloudWatchLogs.Model.Internal.MarshallTransformations;
//using ServerCommon.Redis;
//namespace GameServer
//{
// public class OwnedMail
// {
// public bool isNewReceivedMail = false;
// public bool isNewSystemMail = false;
// string accountGuid = string.Empty;
// List<MailEntity> receivedMails = new();
// List<MailEntity> sendedMails = new();
// MovePlayerInfo movePlayerInfo = new MovePlayerInfo();
// public async Task<bool> LoadDB(string accountGuid)
// {
// this.accountGuid = accountGuid;
// var receiveMail = await GameServerApp.Instance.MainDB.GetMailList(accountGuid, EMailType.RECEIVED_MAIL);
// if (receiveMail is null)
// {
// Log.getLogger().error("receivedMails == null");
// return false;
// }
// receivedMails = receiveMail;
// foreach (var receivedEntity in receivedMails)
// {
// if (receivedEntity.Attr.isRead == false)
// {
// isNewReceivedMail = true;
// break;
// }
// }
// var sendMail = await GameServerApp.Instance.MainDB.GetMailList(accountGuid, EMailType.SENDED_MAIL);
// if (sendMail is null)
// {
// Log.getLogger().error("sendedMails == null");
// return false;
// }
// sendedMails = sendMail;
// return true;
// }
// private async Task<List<MailEntity>> GetReceivedMailList(string ownerNickName)
// {
// if(isNewReceivedMail == false)
// {
// return receivedMails;
// }
// var receiveMail = await GameServerApp.Instance.MainDB.GetMailList(accountGuid, EMailType.RECEIVED_MAIL);
// if (receiveMail is null)
// {
// Log.getLogger().error("receivedMails == null");
// return receivedMails;
// }
// receivedMails = receiveMail;
// List<MailEntity> newMailEntity = new();
// newMailEntity.AddRange(receivedMails);
// return newMailEntity;
// }
// private List<MailEntity> GetSendedMailList()
// {
// List<MailEntity> newMailEntity = new();
// newMailEntity.AddRange(sendedMails);
// return newMailEntity;
// }
// public void UpdateReceivedMailToMemory(string mailKey, MailEntity receivedEntity)
// {
// foreach(MailEntity updateMailEntity in receivedMails)
// {
// if(updateMailEntity.Attr.mailKey == mailKey)
// {
// updateMailEntity.ReadFrom(receivedEntity.DocumentForUpdate());
// break;
// }
// }
// }
// public void AddSendedMailToMemory(string mailKey, MailEntity sendedEntity)
// {
// sendedMails.Add(sendedEntity);
// }
// public void DeleteMailToMemory(string mailKey, EMailType mailType)
// {
// var EntityList = GetCopyMailList(mailType);
// var mailEntity = GetMailEntity(mailKey, EntityList);
// if(mailEntity != null)
// {
// if (mailType == EMailType.RECEIVED_MAIL)
// {
// receivedMails.Remove(mailEntity);
// }
// else
// {
// sendedMails.Remove(mailEntity);
// }
// }
// }
// private List<MailEntity> GetCopyMailList(EMailType mailType)
// {
// List<MailEntity> EntityList = new();
// switch (mailType)
// {
// case EMailType.RECEIVED_MAIL:
// EntityList.AddRange(receivedMails); break;
// case EMailType.SENDED_MAIL:
// EntityList.AddRange(sendedMails); break;
// default:
// return EntityList;
// }
// return EntityList;
// }
// public async Task<List<MailInfo>?> GetMailListInfo(EMailType mailType, string ownerNickName)
// {
// List<MailInfo> mailInfos = new List<MailInfo>();
// List<MailEntity> MailList;
// string frontKey = string.Empty;
// string backKey = string.Empty;
// switch (mailType)
// {
// case EMailType.RECEIVED_MAIL: MailList = await GetReceivedMailList(ownerNickName); frontKey = movePlayerInfo.frontReceivedMailKey; backKey = movePlayerInfo.backReceivedMailKey; break;
// case EMailType.SENDED_MAIL: MailList = GetSendedMailList(); frontKey = movePlayerInfo.frontSendedMailKey; backKey = movePlayerInfo.backSendedMailKey; break;
// default: return null;
// }
// bool skipMail = false;
// bool isBackMail = false;
// int mailCount = 0;
// string newFrontKey = string.Empty;
// string newBackKey = string.Empty;
// foreach (var mail in MailList)
// {
// ++mailCount;
// if(mailCount >= ServerCommon.Constant.MAX_READ_MAIL_DB_COUNT)
// {
// break;
// }
// if(mail.Attr.mailKey == frontKey)
// {
// skipMail = true;
// }
// if (mail.Attr.mailKey == backKey)
// {
// isBackMail = true;
// skipMail = false;
// }
// if (skipMail == true)
// {
// continue;
// }
// if(isBackMail == false)
// {
// newFrontKey = newFrontKey == string.Empty ? mail.Attr.mailKey : newFrontKey;
// }
// else
// {
// newBackKey = mail.Attr.mailKey;
// }
// MailInfo mailInfo = new MailInfo();
// mailInfo.setMailInfo(mail, mailType);
// mailInfos.Add(mailInfo);
// }
// switch (mailType)
// {
// case EMailType.RECEIVED_MAIL:
// {
// movePlayerInfo.frontReceivedMailKey = newFrontKey;
// movePlayerInfo.backReceivedMailKey = newBackKey;
// break;
// }
// case EMailType.SENDED_MAIL:
// {
// movePlayerInfo.frontSendedMailKey = newFrontKey;
// movePlayerInfo.backSendedMailKey = newBackKey;
// break;
// }
// default: return null;
// }
// return mailInfos;
// }
// public MovePlayerInfo MakeMovePlayerInfo()
// {
// return movePlayerInfo;
// }
// public void SaveMovePlayerInfo(MovePlayerInfo newMovePlayerInfo)
// {
// movePlayerInfo = newMovePlayerInfo;
// }
// public MailEntity? GetMailEntity(string mailKey, in List<MailEntity> mailEntityList)
// {
// foreach (var mailEntity in mailEntityList)
// {
// if(mailEntity.Attr.mailKey == mailKey)
// {
// return mailEntity;
// }
// }
// return null;
// }
// public ServerErrorCode DelMail(string mailKey, EMailType mailType, out MailEntity? newMailEntity)
// {
// newMailEntity = default;
// var EntityList = GetCopyMailList(mailType);
// var mailEntity = GetMailEntity(mailKey, EntityList);
// if(mailEntity == null)
// {
// Log.getLogger().error($"Not Found Mail. mailKey : {mailKey}");
// return ServerErrorCode.NotFoundMail;
// }
// newMailEntity = mailType == EMailType.RECEIVED_MAIL ? new ReceivedMailEntity(mailEntity.DocumentForUpdate()) : new SendedMailEntity(mailEntity.DocumentForUpdate());
// return ServerErrorCode.Success;
// }
// public ServerErrorCode ReadReceivedMail(string mailKey, out MailEntity? newMailEntity)
// {
// newMailEntity = default;
// var EntityList = GetCopyMailList(EMailType.RECEIVED_MAIL);
// var mailEntity = GetMailEntity(mailKey, EntityList);
// if (mailEntity == null)
// {
// Log.getLogger().error($"Not Found Mail. mailKey : {mailKey}");
// return ServerErrorCode.NotFoundMail;
// }
// newMailEntity = new ReceivedMailEntity(mailEntity.DocumentForUpdate());
// newMailEntity.Attr.isRead = true;
// return ServerErrorCode.Success;
// }
// public ServerErrorCode GetItemsReceivedMail(string mailKey, out MailEntity? newMailEntity)
// {
// newMailEntity = default;
// var EntityList = GetCopyMailList(EMailType.RECEIVED_MAIL);
// var mailEntity = GetMailEntity(mailKey, EntityList);
// if (mailEntity == null)
// {
// Log.getLogger().error($"Not Found Mail. mailKey : {mailKey}");
// return ServerErrorCode.NotFoundMail;
// }
// if (mailEntity.Attr.ItemList.Count == 0)
// {
// Log.getLogger().error($"Item is Empty. mailKey : {mailKey}");
// return ServerErrorCode.EmptyItemInMail;
// }
// newMailEntity = new ReceivedMailEntity(mailEntity.DocumentForUpdate());
// newMailEntity.Attr.isGetItem = true;
// return ServerErrorCode.Success;
// }
// public void newMailNoti()
// {
// isNewReceivedMail = true;
// }
// public void newSystemMailNoti()
// {
// isNewSystemMail = true;
// }
// public void SendInfoFromLogin(HostID hostId)
// {
// if(isNewReceivedMail == false)
// {
// return;
// }
// ClientToGame clientToGame = new ClientToGame();
// clientToGame.Message = new ClientToGameMessage();
// clientToGame.Message.NewMailNoti = new ClientToGameMessage.Types.NewMailNoti();
// clientToGame.Message.NewMailNoti.IsLoginNoti = 1;
// GameServer.Instance._proxy.Message(hostId, RmiContext.ReliableSend, clientToGame);
// }
// //for cheat command
// public async Task<ServerErrorCode> SetRemainedTime(bool isSendMail, int remainedTime)
// {
// var EntityList = GetCopyMailList(EMailType.RECEIVED_MAIL);
// if (isSendMail == true)
// {
// EntityList = GetCopyMailList(EMailType.SENDED_MAIL);
// }
// List<MailEntity> mailEntities = new List<MailEntity>();
// foreach(var mailEntity in EntityList)
// {
// mailEntity.Attr.expireTime = Timestamp.FromDateTime(DateTime.UtcNow.AddMinutes(remainedTime));
// mailEntities.Add(mailEntity);
// }
// if (await GameServerApp.Instance.MainDB.UpdateMail(mailEntities) == false)
// {
// Log.getLogger().error($"DB UpdateMail Failed.");
// return ServerErrorCode.DbUpdateFailed;
// }
// return ServerErrorCode.Success;
// }
// }
//}