예제 #1
0
        MessageCode BuilReceiveAttachmentData(MailInfoEntity mail, ref NbManagerEntity manager, ref ItemPackageFrame package, ref int addCoin, ref int addSophisticate, ref int addPoint, ref int addPrestige, ref int addBindPoint, ref int addGoldBar, ref int addluckyCoin, ref int addGameCoin)
        {
            var attachments = SerializationHelper.FromByte <MailAttachmentEntity>(mail.Attachment);

            var         managerId = mail.ManagerId;
            MessageCode code      = MessageCode.Success;

            foreach (var attachment in attachments.Attachments)
            {
                #region build Attachment
                switch (attachment.AttachmentType)
                {
                case (int)EnumAttachmentType.Coin:
                    if (manager == null)
                    {
                        manager = ManagerCore.Instance.GetManager(managerId);
                    }
                    addCoin += attachment.Count;
                    break;

                case (int)EnumAttachmentType.Sophisticate:
                    if (manager == null)
                    {
                        manager = ManagerCore.Instance.GetManager(managerId);
                    }
                    addSophisticate += attachment.Count;
                    break;

                case (int)EnumAttachmentType.Point:
                    if (manager == null)
                    {
                        manager = ManagerCore.Instance.GetManager(managerId);
                    }
                    addPoint += attachment.Count;
                    break;

                case (int)EnumAttachmentType.Prestige:
                    if (manager == null)
                    {
                        manager = ManagerCore.Instance.GetManager(managerId);
                    }
                    addPrestige += attachment.Count;
                    break;

                case (int)EnumAttachmentType.NewItem:
                    var attachmentItemEntity = attachment as AttachmentItemEntity;
                    if (attachmentItemEntity == null)
                    {
                        return(MessageCode.NbParameterError);
                    }
                    if (package == null)
                    {
                        package = ItemCore.Instance.GetPackage(managerId, _mailTransactionTypeDic[mail.MailType]);
                    }
                    code = package.AddItems(attachmentItemEntity.ItemCode, attachmentItemEntity.Count,
                                            attachmentItemEntity.Strength, attachmentItemEntity.IsBinding, attachmentItemEntity.IsDeal);
                    if (code != MessageCode.Success)
                    {
                        return(code);
                    }
                    break;

                case (int)EnumAttachmentType.UsedPlayerCard:
                    if (package == null)
                    {
                        package = ItemCore.Instance.GetPackage(managerId, _mailTransactionTypeDic[mail.MailType]);
                    }
                    var usedPlayerCard = attachment as AttachmentUsedItemEntity;
                    if (usedPlayerCard == null)
                    {
                        return(MessageCode.NbParameterError);
                    }
                    code = package.AddUsedItem(usedPlayerCard.ItemProperty as PlayerCardUsedEntity);
                    if (code != MessageCode.Success)
                    {
                        return(code);
                    }
                    break;

                case (int)EnumAttachmentType.UsedEquipment:
                    if (package == null)
                    {
                        package = ItemCore.Instance.GetPackage(managerId, _mailTransactionTypeDic[mail.MailType]);
                    }
                    var usedEquipment = attachment as AttachmentUsedItemEntity;
                    if (usedEquipment == null)
                    {
                        return(MessageCode.NbParameterError);
                    }
                    code = package.AddUsedItem(usedEquipment.ItemProperty as EquipmentUsedEntity);
                    if (code != MessageCode.Success)
                    {
                        return(code);
                    }
                    break;

                case (int)EnumAttachmentType.UsedMallItem:
                //if (package == null)
                //    package = ItemCore.Instance.GetPackage(managerId, _mailTransactionTypeDic[mail.MailType]);
                //var usedMallItem = attachment as AttachmentUsedItemEntity;
                //if (usedMallItem == null)
                //    return MessageCode.NbParameterError;
                //var itemProperty = usedMallItem.ItemProperty as MallItemUsedEntity;

                //code = package.AddUsedItem(itemProperty);
                //if (code != MessageCode.Success)
                //{
                //    return code;
                //}
                //break;

                case (int)EnumAttachmentType.Equipment:
                    if (package == null)
                    {
                        package = ItemCore.Instance.GetPackage(managerId, _mailTransactionTypeDic[mail.MailType]);
                    }
                    var equipment = attachment as AttachmentEquipmentEntity;
                    if (equipment == null)
                    {
                        return(MessageCode.NbParameterError);
                    }
                    code = package.AddEquipment(equipment.ItemCode, equipment.IsBinding, equipment.IsDeal, equipment.EquipmentProperty);
                    if (code != MessageCode.Success)
                    {
                        return(code);
                    }
                    break;

                case (int)EnumAttachmentType.BindPoint:
                    if (manager == null)
                    {
                        manager = ManagerCore.Instance.GetManager(managerId);
                    }
                    addBindPoint += attachment.Count;
                    break;

                case (int)EnumAttachmentType.GoldBar:
                    addGoldBar += attachment.Count;
                    break;

                case (int)EnumAttachmentType.LuckyCoin:
                    addluckyCoin += attachment.Count;
                    break;

                case (int)EnumAttachmentType.GameCoin:
                    addGameCoin += attachment.Count;
                    break;

                default:
                    return(MessageCode.NbParameterError);
                }
                #endregion
            }
            mail.IsRead      = true;
            mail.HasAttach   = false;
            mail.ExpiredTime = GetExpiredTime(false, DateTime.Now);
            return(MessageCode.Success);
        }