コード例 #1
0
        public void PlayerReadMail(GPlayer PL, Packet packet)
        {
            var _db = new PangyaEntities();
            PangyaBinaryWriter Reply;


            if (!packet.ReadUInt32(out uint MailIndex))
            {
                return;
            }

            Reply = new PangyaBinaryWriter();

            var QueryList = _db.ProcReadMail((int)PL.GetUID, (int)MailIndex).ToList();

            try
            {
                if (QueryList.Count > 0)
                {
                    Reply.Write(new byte[] { 0x12, 0x02 });
                    Reply.Write((uint)0);
                    Reply.Write(QueryList.First().Mail_Index);             //Select Page
                    Reply.WritePStr(QueryList.First().Sender);             //Sender
                    Reply.WritePStr(QueryList.First().RegDate.ToString()); //IsRead
                    Reply.WritePStr(QueryList.First().Msg);
                    Reply.Write((byte)1);
                    Reply.Write(QueryList.Count);//FF FF FF FF
                    foreach (var data in QueryList)
                    {
                        Reply.Write(uint.MaxValue);
                        Reply.Write(data.TYPEID);                       //typeID
                        Reply.Write(Convert.ToByte(data.IsTime));
                        Reply.Write(data.QTY ?? 0);                     //quantidade
                        Reply.Write(Convert.ToUInt32(data.DAY ?? 0));   //dias
                        Reply.WriteZero(16);
                        Reply.Write(4294967295);                        //FF FF FF FF
                        Reply.Write(0);
                        Reply.WriteStr(IsUCCNull(data.UCC_UNIQUE), 14); //UCC_UNIQUE
                    }
                    PL.SendResponse(Reply.GetBytes());
                }
                else
                {
                    Reply.Write(new byte[] { 0x12, 0x02 });
                    Reply.Write((uint)2);
                    PL.SendResponse(Reply.GetBytes());
                }
            }
            catch
            {
                PL.Close();
            }
        }