149 lines
5.0 KiB
C#
149 lines
5.0 KiB
C#
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;
|
|
}
|
|
} |