IsAlreadyReceived() public method

public IsAlreadyReceived ( ulong mailGuid ) : bool
mailGuid ulong
return bool
 internal void DeleteMail(ulong userGuid, ulong mailGuid)
 {
     UserProcessScheduler dataProcess = UserServer.Instance.UserProcessScheduler;
     UserInfo user = dataProcess.GetUserInfo(userGuid);
     if (null != user) {
         List<MailInfo> mails;
         if (m_UserMails.TryGetValue(userGuid, out mails)) {
             if (null != mails) {
                 MailInfo info = null;
                 int ct = mails.Count;
                 int index = 0;
                 for (; index < ct; ++index) {
                     if (mails[index].m_MailGuid == mailGuid) {
                         info = mails[index];
                         break;
                     }
                 }
                 if (null != info) {
                     mails.RemoveAt(index);
                 }
             }
         }
         MailStateInfo mailStateInfo = user.MailStateInfo;
         if (!mailStateInfo.IsAlreadyReceived(mailGuid)) {
             int wholeCt = m_WholeMails.Count;
             for (int index = 0; index < wholeCt; ++index) {
                 MailInfo info = m_WholeMails[index];
                 if (info.m_MailGuid == mailGuid) {
                     mailStateInfo.DeleteMail(mailGuid);
                 }
             }
         }
     }
 }
Example #2
0
        internal void ReceiveMail(ulong userGuid, ulong mailGuid)
        {
            UserProcessScheduler dataProcess = UserServer.Instance.UserProcessScheduler;
            UserInfo             user        = dataProcess.GetUserInfo(userGuid);

            if (null != user)
            {
                List <TableMailInfoWrap> mails;
                if (m_UserMails.TryGetValue((long)userGuid, out mails))
                {
                    if (null != mails)
                    {
                        TableMailInfoWrap info = null;
                        int ct    = mails.Count;
                        int index = 0;
                        for (; index < ct; ++index)
                        {
                            if (mails[index].Guid == mailGuid)
                            {
                                info = mails[index];
                                break;
                            }
                        }
                        if (null != info && CheckBagCapacity(user, info))
                        {
                            mails.RemoveAt(index);
                            ExtractMailAttachment(info, userGuid);
                        }
                    }
                }
                MailStateInfo mailStateInfo = user.MailStateInfo;
                if (!mailStateInfo.IsAlreadyReceived(mailGuid))
                {
                    int wholeCt = m_WholeMails.Count;
                    for (int index = 0; index < wholeCt; ++index)
                    {
                        TableMailInfoWrap info = m_WholeMails[index];
                        if (info.Guid == mailGuid)
                        {
                            if (CheckBagCapacity(user, info))
                            {
                                mailStateInfo.ReceiveMail(mailGuid);
                                if (info.LevelDemand <= user.Level && info.SendDate >= user.CreateTime && info.ExpiryDate >= DateTime.Now)
                                {
                                    ExtractMailAttachment(info, userGuid);
                                }
                            }
                        }
                    }
                }
            }
        }
 internal void GetMailList(ulong userGuid)
 {
     UserProcessScheduler dataProcess = UserServer.Instance.UserProcessScheduler;
     UserInfo user = dataProcess.GetUserInfo(userGuid);
     if (null != user) {
         List<MailInfoForMessage> mailList = new List<MailInfoForMessage>();
         List<MailInfo> mails;
         if (m_UserMails.TryGetValue(userGuid, out mails)) {
             int ct = mails.Count;
             for (int ix = 0; ix < ct; ++ix) {
                 MailInfo mailInfo = mails[ix];
                 if (mailInfo.m_ExpiryDate >= DateTime.Now) {
                     MailInfoForMessage mailInfoForMsg = new MailInfoForMessage();
                     mailInfoForMsg.m_AlreadyRead = mailInfo.m_AlreadyRead;
                     mailInfoForMsg.m_MailGuid = mailInfo.m_MailGuid;
                     mailInfoForMsg.m_Title = mailInfo.m_Title;
                     mailInfoForMsg.m_Sender = mailInfo.m_Sender;
                     mailInfoForMsg.m_SendTime = mailInfo.m_SendTime.ToString("yyyyMMddHHmmss");
                     mailInfoForMsg.m_Text = mailInfo.m_Text;
                     mailInfoForMsg.m_Money = mailInfo.m_Money;
                     mailInfoForMsg.m_Gold = mailInfo.m_Gold;
                     int itemCt = mailInfo.m_Items.Count;
                     if (itemCt > 0) {
                         for (int index = 0; index < itemCt; ++index) {
                             MailItemForMessage mailItem = new MailItemForMessage();
                             mailItem.m_ItemId = mailInfo.m_Items[index].m_ItemId;
                             mailItem.m_ItemNum = mailInfo.m_Items[index].m_ItemNum;
                             mailInfoForMsg.m_Items.Add(mailItem);
                         }
                     }
                     mailList.Add(mailInfoForMsg);
                 }
             }
         }
         MailStateInfo mailStateInfo = user.MailStateInfo;
         //这里不对用户数据加锁,因为用户的邮件状态的改变都在这个线程完成(除上线时的数据加载)
         int wholeMailCt = m_WholeMails.Count;
         for (int ix = 0; ix < wholeMailCt; ++ix) {
             MailInfo mailInfo = m_WholeMails[ix];
             if (mailInfo.m_LevelDemand <= user.Level
               && mailInfo.m_SendTime >= user.CreateTime
               && mailInfo.m_ExpiryDate >= DateTime.Now
               && !mailStateInfo.IsAlreadyReceived(mailInfo.m_MailGuid)) {
                 if (!mailStateInfo.HaveMail(mailInfo.m_MailGuid)) {
                     mailStateInfo.AddMail(mailInfo.m_MailGuid, mailInfo.m_ExpiryDate);
                 }
                 MailInfoForMessage mailInfoForMsg = new MailInfoForMessage();
                 mailInfoForMsg.m_AlreadyRead = mailStateInfo.IsAlreadyRead(mailInfo.m_MailGuid);
                 mailInfoForMsg.m_MailGuid = mailInfo.m_MailGuid;
                 mailInfoForMsg.m_Title = mailInfo.m_Title;
                 mailInfoForMsg.m_Sender = mailInfo.m_Sender;
                 mailInfoForMsg.m_SendTime = mailInfo.m_SendTime.ToString("yyyyMMddHHmmss");
                 mailInfoForMsg.m_Text = mailInfo.m_Text;
                 mailInfoForMsg.m_Money = mailInfo.m_Money;
                 mailInfoForMsg.m_Gold = mailInfo.m_Gold;
                 int itemCt = mailInfo.m_Items.Count;
                 if (itemCt > 0) {
                     for (int index = 0; index < itemCt; ++index) {
                         MailItemForMessage mailItem = new MailItemForMessage();
                         mailItem.m_ItemId = mailInfo.m_Items[index].m_ItemId;
                         mailItem.m_ItemNum = mailInfo.m_Items[index].m_ItemNum;
                         mailInfoForMsg.m_Items.Add(mailItem);
                     }
                 }
                 mailList.Add(mailInfoForMsg);
             }
         }
         NodeMessage syncMailListMsg = new NodeMessage(LobbyMessageDefine.Msg_LC_SyncMailList, userGuid);
         GameFrameworkMessage.Msg_LC_SyncMailList protoMsg = new Msg_LC_SyncMailList();
         protoMsg.m_Mails.AddRange(mailList);
         syncMailListMsg.m_ProtoData = protoMsg;
         NodeMessageDispatcher.SendNodeMessage(user.NodeName, syncMailListMsg);
     }
 }