protected void SendMail_btn_Click(object sender, EventArgs e)
        {
   
            var business = new Bussiness.PlayerBussiness();
            try
            {

                var userid = business.GetUserSingleByNickName(UserName_tbx.Text).ID;

                //business.SendMailAndItemByUserName(Title_tbx.Text, Content_tbx.Text, UserName_tbx.Text,0,0,string.Empty);
                var mail=new MailInfo();
                mail.Title=Title_tbx.Text;
                mail.Content=Content_tbx.Text;
                mail.ReceiverID=userid;
                mail.Sender = "Administrators";
                mail.SenderID = 0;
                mail.Type = 1;
                business.SendMail(mail);
                Error_lbl.Text = "OK";
            }
            catch
            {
                Error_lbl.Text = "User  :";
            }
      
        }
 public bool HandleCommand(TankHotSpringLogicProcessor process, GamePlayer player, GSPacketIn packet)
 {
     if (player.CurrentHotSpringRoom != null)
     {
         int num = packet.ReadInt();
         if (num <= 0)
         {
             return false;
         }
         if (player.PlayerCharacter.Money >= num)
         {
             player.RemoveMoney(num);
             LogMgr.LogMoneyAdd(LogMoneyType.Marry, LogMoneyType.Marry_Gift, player.PlayerCharacter.ID, num, player.PlayerCharacter.Money, 0, 0, 0, "", "", "");
             using (PlayerBussiness bussiness = new PlayerBussiness())
             {
                 string translation = LanguageMgr.GetTranslation("LargessCommand.Content", new object[] { player.PlayerCharacter.NickName, num / 2 });
                 string str2 = LanguageMgr.GetTranslation("LargessCommand.Title", new object[] { player.PlayerCharacter.NickName });
                 MailInfo mail = new MailInfo {
                     Annex1 = "",
                     Content = translation,
                     Gold = 0,
                     IsExist = true,
                     Money = num / 2,
                     Receiver = player.CurrentHotSpringRoom.Info.playerName,
                     ReceiverID = player.CurrentHotSpringRoom.Info.playerID,
                     Sender = LanguageMgr.GetTranslation("LargessCommand.Sender", new object[0]),
                     SenderID = 0,
                     Title = str2,
                     Type = 14
                 };
                 bussiness.SendMail(mail);
                 player.Out.SendMailResponse(mail.ReceiverID, eMailRespose.Receiver);
                 MailInfo info2 = new MailInfo {
                     Annex1 = "",
                     Content = translation,
                     Gold = 0,
                     IsExist = true,
                     Money = num / 2,
                     Receiver = player.CurrentHotSpringRoom.Info.GroomName,
                     ReceiverID = player.CurrentHotSpringRoom.Info.GroomID,
                     Sender = LanguageMgr.GetTranslation("LargessCommand.Sender", new object[0]),
                     SenderID = 0,
                     Title = str2,
                     Type = 14
                 };
                 bussiness.SendMail(info2);
                 player.Out.SendMailResponse(info2.ReceiverID, eMailRespose.Receiver);
             }
             player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("LargessCommand.Succeed", new object[0]));
             GSPacketIn @in = player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("LargessCommand.Notice", new object[] { player.PlayerCharacter.NickName, num }));
             player.CurrentHotSpringRoom.SendToPlayerExceptSelf(@in, player);
             return true;
         }
         player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserFirecrackersCommand.MoneyNotEnough", new object[0]));
     }
     return false;
 }
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            //已经开始游戏则不处理
            if (client.Player.CurrentRoom != null && client.Player.CurrentRoom.IsPlaying)
                return 0;
            int bagType = packet.ReadByte();
            int index = packet.ReadInt();
            PlayerInventory bag = client.Player.GetInventory((eBageType)bagType);
            ItemInfo item = bag.GetItemAt(index);

            if (item != null && !item.IsValidItem())
            {
                if (bagType == 0 && index < 11)
                {
                    int place = bag.FindFirstEmptySlot(31);
                    if (place != -1)
                    {
                        bag.RemoveItem(item);
                        //bag.MoveItem(item.Place, place);
                    }
                    else
                    {
                        using (PlayerBussiness pb = new PlayerBussiness())
                        {
                            MailInfo mail = new MailInfo();
                            mail.Annex1 = item.ItemID.ToString();
                            mail.Content = LanguageMgr.GetTranslation("ItemOverdueHandler.Content");
                            mail.Gold = 0;
                            mail.IsExist = true;
                            mail.Money = 0;
                            mail.Receiver = client.Player.PlayerCharacter.NickName;
                            mail.ReceiverID = item.UserID;
                            mail.Sender = client.Player.PlayerCharacter.NickName;
                            mail.SenderID = item.UserID;
                            mail.Title = LanguageMgr.GetTranslation("ItemOverdueHandler.Title");
                            mail.Type = (int)eMailType.ItemOverdue;
                            if (pb.SendMail(mail))
                            {
                                //item.UserID = 0;
                                bag.RemoveItem(item);
                            }
                        }
                    }
                }
                else
                {
                    bag.UpdateItem(item);
                }
            }


            return 0;
        }
        /// <summary>
        /// 从数据库中加载
        /// </summary>
        /// <param name="playerId"></param>
        public void LoadFromDatabase(int playerId)
        {
            using (PlayerBussiness pb = new PlayerBussiness())
            {
                //ItemInfo[] list = pb.GetUserItem(playerId);
                ItemInfo[] list = pb.GetUserBagByType(playerId, _bagType);
                foreach (ItemInfo item in list)
                {
                    _items[item.Place] = item;
                }


                for (int i = 0; i < 11; i++)
                {
                    ItemInfo item = _items[i];
                    if (item == null)
                        continue;

                    if (!_items[i].IsValidItem())
                    {
                        UpdatePlayerProperties(item, false);
                        int place = base.FindFirstEmptySlot(11);
                        if (place != -1)
                        {
                            MoveItem(item.Place, place);
                        }
                        else
                        {
                            MailInfo mail = new MailInfo();
                            mail.Annex1 = item.ItemID.ToString();
                            mail.Content = "物品已过期!";
                            mail.Gold = 0;
                            mail.IsExist = true;
                            mail.Money = 0;
                            mail.Receiver = _player.PlayerCharacter.NickName;
                            mail.ReceiverID = item.UserID;
                            mail.Sender = _player.PlayerCharacter.NickName;
                            mail.SenderID = item.UserID;
                            mail.Title = "物品已过期!";
                            if (pb.SendMail(mail))
                            {
                                item.UserID = 0;
                                RemoveItem(item);
                            }
                        }
                    }
                }
                UpdatePlayerProperties();
            }

        }
        public void SendGoodManCard(string receiverName, int receiverID, string senderName, int senderID, PlayerBussiness db)
        {
            ItemTemplateInfo goodMan = ItemMgr.FindItemTemplate(11105);
            ItemInfo goodManCard = ItemInfo.CreateFromTemplate(goodMan, 1, (int)ItemAddType.webing);
            goodManCard.IsBinds = true;

            goodManCard.UserID = 0;
            db.AddGoods(goodManCard);

            MailInfo mail = new MailInfo();
            mail.Annex1 = goodManCard.ItemID.ToString();
            mail.Content = LanguageMgr.GetTranslation("MarryApplyReplyHandler.Content");
            mail.Gold = 0;
            mail.IsExist = true;
            mail.Money = 0;
            mail.Receiver = receiverName;
            mail.ReceiverID = receiverID;
            mail.Sender = senderName;
            mail.SenderID = senderID;
            mail.Title = LanguageMgr.GetTranslation("MarryApplyReplyHandler.Title");
            mail.Type = (int)eMailType.Marry;
            db.SendMail(mail);
            //Spouse.Out.SendMailResponse(mail.ReceiverID, eMailRespose.Receiver);
        }
        public bool HandleCommand(TankMarryLogicProcessor process, GamePlayer player, GSPacketIn packet)
        {
            if (player.CurrentMarryRoom == null || player.CurrentMarryRoom.RoomState != eRoomState.FREE)
            {
                return false;
            }

            if(player.PlayerCharacter.ID != player.CurrentMarryRoom.Info.GroomID && player.PlayerCharacter.ID != player.CurrentMarryRoom.Info.BrideID )
            {
                return false;
            }

            int needMoney = GameProperties.PRICE_PROPOSE;
            if(player.CurrentMarryRoom.Info.IsHymeneal)
            {
                if (player.PlayerCharacter.Money < needMoney)
                {
                    player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("UserFirecrackersCommand.MoneyNotEnough"));
                    return false;
                }
            }

            GamePlayer Groom = player.CurrentMarryRoom.GetPlayerByUserID(player.CurrentMarryRoom.Info.GroomID);
            if(Groom == null)
            {
                player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("HymenealCommand.NoGroom"));
                return false;
            }

            GamePlayer Bride = player.CurrentMarryRoom.GetPlayerByUserID(player.CurrentMarryRoom.Info.BrideID);
            if (Bride == null)
            {
                player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("HymenealCommand.NoBride"));
                return false;
            }

            bool result = false;
            bool isFirst = false;
            GSPacketIn pkg = packet.Clone();

            int hymenealState = packet.ReadInt();

            if (1 == hymenealState)
            {
                player.CurrentMarryRoom.RoomState = eRoomState.FREE;
            }
            else
            {
                player.CurrentMarryRoom.RoomState = eRoomState.Hymeneal;
                player.CurrentMarryRoom.BeginTimerForHymeneal(170 * 1000);

                if (!player.PlayerCharacter.IsGotRing)
                {
                    isFirst = true;
                    ItemTemplateInfo ringTemplate = ItemMgr.FindItemTemplate(9022);
                    ItemInfo ring1 = ItemInfo.CreateFromTemplate(ringTemplate, 1, (int)ItemAddType.webing);
                    ring1.IsBinds = true;
                    //Groom.CurrentInventory.AddItem(ring1, 11);
                    using (PlayerBussiness pb = new PlayerBussiness())
                    {
                        ring1.UserID = 0;
                        pb.AddGoods(ring1);

                        string content = LanguageMgr.GetTranslation("HymenealCommand.Content", Bride.PlayerCharacter.NickName);

                        MailInfo mail = new MailInfo();
                        mail.Annex1 = ring1.ItemID.ToString();
                        mail.Content = content;
                        mail.Gold = 0;
                        mail.IsExist = true;
                        mail.Money = 0;
                        mail.Receiver = Groom.PlayerCharacter.NickName;
                        mail.ReceiverID = Groom.PlayerCharacter.ID;
                        mail.Sender = LanguageMgr.GetTranslation("HymenealCommand.Sender");
                        mail.SenderID = 0;
                        mail.Title = LanguageMgr.GetTranslation("HymenealCommand.Title");
                        mail.Type = (int)eMailType.Marry;
                        if (pb.SendMail(mail))
                        {
                            result = true;
                        }
                        player.Out.SendMailResponse(mail.ReceiverID, eMailRespose.Receiver);
                    }

                    ItemInfo ring2 = ItemInfo.CreateFromTemplate(ringTemplate, 1, (int)ItemAddType.webing);
                    ring2.IsBinds = true;
                    //Bride.CurrentInventory.AddItem(ring2, 11);
                    using (PlayerBussiness pb = new PlayerBussiness())
                    {
                        ring2.UserID = 0;
                        pb.AddGoods(ring2);

                        string content = LanguageMgr.GetTranslation("HymenealCommand.Content", Groom.PlayerCharacter.NickName);

                        MailInfo mail = new MailInfo();
                        mail.Annex1 = ring2.ItemID.ToString();
                        mail.Content = content;
                        mail.Gold = 0;
                        mail.IsExist = true;
                        mail.Money = 0;
                        mail.Receiver = Bride.PlayerCharacter.NickName;
                        mail.ReceiverID = Bride.PlayerCharacter.ID;
                        mail.Sender = LanguageMgr.GetTranslation("HymenealCommand.Sender");
                        mail.SenderID = 0;
                        mail.Title = LanguageMgr.GetTranslation("HymenealCommand.Title");
                        mail.Type = (int)eMailType.Marry;
                        if (pb.SendMail(mail))
                        {
                            result = true;
                        }
                        player.Out.SendMailResponse(mail.ReceiverID, eMailRespose.Receiver);
                    }

                    player.CurrentMarryRoom.Info.IsHymeneal = true;

                    using (PlayerBussiness db = new PlayerBussiness())
                    {
                        db.UpdateMarryRoomInfo(player.CurrentMarryRoom.Info);

                        //更新IsGotRing的数据库
                        db.UpdatePlayerGotRingProp(Groom.PlayerCharacter.ID,Bride.PlayerCharacter.ID);

                        //通过数据库读入PlayerCharacter内存
                        Groom.LoadMarryProp();
                        Bride.LoadMarryProp();
                    }

                    //Groom.PlayerCharacter.IsGotRing = true;
                    //Bride.PlayerCharacter.IsGotRing = true;

                }
                else
                {
                    isFirst = false;
                    result = true;
                }

                if (!isFirst)
                {
                    //player.SetMoney(-needMoney, MoneyRemoveType.Marry);
                    player.RemoveMoney(needMoney);
                    LogMgr.LogMoneyAdd(LogMoneyType.Marry, LogMoneyType.Marry_Hymeneal, player.PlayerCharacter.ID, needMoney, player.PlayerCharacter.Money, 0, 0, 0,0, "", "", "");
                    CountBussiness.InsertSystemPayCount(player.PlayerCharacter.ID, needMoney, 0, (int)eConsumerType.Marry, (int)eSubConsumerType.Marry_Hymeneal);
                }

                pkg.WriteInt(player.CurrentMarryRoom.Info.ID);
                pkg.WriteBoolean(result);
                //0 player.CurrentMarryRoom.SendToAll(pkg);
                //0 player.CurrentMarryRoom.SendToAllForScene(pkg,1);
                player.CurrentMarryRoom.SendToAll(pkg);

                if(result)
                {
                    string msg = LanguageMgr.GetTranslation("HymenealCommand.Succeed", Groom.PlayerCharacter.NickName, Bride.PlayerCharacter.NickName);
                    GSPacketIn message = player.Out.SendMessage(eMessageType.ChatNormal, msg);
                    player.CurrentMarryRoom.SendToPlayerExceptSelfForScene(message, player);
                }
            }

            return true;
        }
        // <summary>
        // 修改:  Xiaov 
        // 时间:  2009-11-7
        // 描述:  发送邮件<未测试>   
       
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {

           
            if (client.Player.PlayerCharacter.Gold < 100)
                return 1;

           

            string msg = "UserSendMailHandler.Success";
            eMessageType eMsg = eMessageType.Normal;
            GSPacketIn pkg = packet.Clone();
            pkg.ClearContext();

            string nickName = packet.ReadString().Trim();
            string title = packet.ReadString();
            string content = packet.ReadString();
            bool isPay = packet.ReadBoolean();
            int validDate = packet.ReadInt();
            int money = packet.ReadInt();

            eBageType bag1 = (eBageType)packet.ReadByte();
            int place1 = packet.ReadInt();
            eBageType bag2 = (eBageType)packet.ReadByte();
            int place2 = packet.ReadInt();
            eBageType bag3 = (eBageType)packet.ReadByte();
            int place3 = packet.ReadInt();
            eBageType bag4 = (eBageType)packet.ReadByte();
            int place4 = packet.ReadInt();

            if ((money!=0||place1!=-1||place2!=-1||place3!=-1||place4!=-1)&&(client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked))
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked"));
                pkg.WriteBoolean(false);
                client.Out.SendTCP(pkg);
                return 1;
            }

            using (PlayerBussiness db = new PlayerBussiness())
            {
                PlayerInfo user;
                GamePlayer player = Managers.WorldMgr.GetClientByPlayerNickName(nickName);
                if (player == null)
                {
                    user = db.GetUserSingleByNickName(nickName);
                }
                else
                {
                    user = player.PlayerCharacter;
                }

                if (user != null && !string.IsNullOrEmpty(nickName))
                {
                    if (user.NickName != client.Player.PlayerCharacter.NickName)
                    {
                        client.Player.SaveIntoDatabase();

                        //附件内容描述(例:邮件最后一行标注附件为:1、大喇叭x5;2、强化石4级x1;3、极•烈火x1;4、点券999999;5、强化公式-朱雀x5
                        MailInfo message = new MailInfo();
                        message.SenderID = client.Player.PlayerCharacter.ID;
                        message.Sender = client.Player.PlayerCharacter.NickName;
                        message.ReceiverID = user.ID;
                        message.Receiver = user.NickName;
                        message.IsExist = true;
                        message.Gold = 0;
                        message.Money = 0;

                        message.Title = title;
                        message.Content = content;
                        List<ItemInfo> items = new List<ItemInfo>();
                        List<eBageType> bagType = new List<eBageType>();
                        StringBuilder annexRemark = new StringBuilder();
                        annexRemark.Append(LanguageMgr.GetTranslation("UserSendMailHandler.AnnexRemark"));
                        int index = 0;

                        if (place1 != -1)
                        {
                            ItemInfo goods = client.Player.GetItemAt(bag1, place1);
                            if (goods != null && !goods.IsBinds)
                            {
                                message.Annex1Name = goods.Template.Name;
                                message.Annex1 = goods.ItemID.ToString();
                                items.Add(goods);
                                bagType.Add(bag1);
                                //annexRemark = message.Annex1Name + "x" + goods.Count;
                                index++;
                                annexRemark.Append(index);
                                annexRemark.Append("、");
                                //annexRemark.Append(annexRemark.Length);
                                annexRemark.Append(message.Annex1Name);
                                annexRemark.Append("x");
                                annexRemark.Append(goods.Count);
                                annexRemark.Append(";");
                                //goods.UserID = 0;
                                //client.Player.RemoveAllItem(goods, true, ItemRemoveType.Mail);
                            }
                        }

                        if (place2 != -1)
                        {
                            ItemInfo goods = client.Player.GetItemAt(bag2, place2);
                            if (goods != null && !goods.IsBinds)
                            {
                                message.Annex2Name = goods.Template.Name;
                                message.Annex2 = goods.ItemID.ToString();
                                items.Add(goods);
                                bagType.Add(bag2);
                                index++;
                                annexRemark.Append(index);
                                annexRemark.Append("、");
                                annexRemark.Append(message.Annex2Name);
                                annexRemark.Append("x");
                                annexRemark.Append(goods.Count);
                                annexRemark.Append(";");
                                //goods.UserID = 0;
                                //client.Player.RemoveAllItem(goods, true, ItemRemoveType.Mail);
                            }
                        }

                        if (place3 != -1)
                        {
                            ItemInfo goods = client.Player.GetItemAt(bag3, place3);
                            if (goods != null && !goods.IsBinds)
                            {
                                message.Annex3Name = goods.Template.Name;
                                message.Annex3 = goods.ItemID.ToString();
                                items.Add(goods);
                                bagType.Add(bag3);
                                index++;
                                annexRemark.Append(index);
                                annexRemark.Append("、");
                                annexRemark.Append(message.Annex3Name);
                                annexRemark.Append("x");
                                annexRemark.Append(goods.Count);
                                annexRemark.Append(";");
                            }
                        }

                        if (place4 != -1)
                        {
                            ItemInfo goods = client.Player.GetItemAt(bag4, place4);
                            if (goods != null && !goods.IsBinds)
                            {
                                message.Annex4Name = goods.Template.Name;
                                message.Annex4 = goods.ItemID.ToString();
                                items.Add(goods);
                                bagType.Add(bag4);
                                index++;
                                annexRemark.Append(index);
                                annexRemark.Append("、");
                                annexRemark.Append(message.Annex4Name);
                                annexRemark.Append("x");
                                annexRemark.Append(goods.Count);
                                annexRemark.Append(";");
                            }
                        }

                        if (isPay)
                        {
                            if (money <= 0 || (string.IsNullOrEmpty(message.Annex1) && string.IsNullOrEmpty(message.Annex2) && string.IsNullOrEmpty(message.Annex3) && string.IsNullOrEmpty(message.Annex4)))
                                return 1;

                            message.ValidDate = validDate == 1 ? 1 : 6;
                            message.Type = (int)eMailType.Payment;
                            if (money > 0)
                            {
                                message.Money = money;
                                index++;
                                annexRemark.Append(index);
                                annexRemark.Append("、");
                                annexRemark.Append(LanguageMgr.GetTranslation("UserSendMailHandler.PayMoney"));
                                annexRemark.Append(money);
                                annexRemark.Append(";");
                            }
                        }
                        else
                        {
                            message.Type = (int)eMailType.Common;
                            if (client.Player.PlayerCharacter.Money >= money && money > 0)
                            {
                                message.Money = money;
                                client.Player.RemoveMoney(money);
                                LogMgr.LogMoneyAdd(LogMoneyType.Mail, LogMoneyType.Mail_Send, client.Player.PlayerCharacter.ID, money, client.Player.PlayerCharacter.Money, 0, 0, 0, "", "", "");
                                index++;
                                annexRemark.Append(index);
                                annexRemark.Append("、");
                                annexRemark.Append(LanguageMgr.GetTranslation("UserSendMailHandler.Money"));
                                annexRemark.Append(money);
                                annexRemark.Append(";");
                            }
                        }

                        if (annexRemark.Length > 1)
                        {
                            message.AnnexRemark = annexRemark.ToString();
                        }

                        if (db.SendMail(message))
                        {
                            client.Player.RemoveGold(100);
                            for(int i=0;i<items.Count;i++)
                            {
                                items[i].UserID = 0;
                                client.Player.RemoveItem(items[i]);
                                items[i].IsExist = true;
                            }
                        }

                        client.Player.SaveIntoDatabase();
                        pkg.WriteBoolean(true);

                        //发送通知
                        if (user.State != 0)
                        {
                            client.Player.Out.SendMailResponse(user.ID, eMailRespose.Receiver);
                        }
                        client.Player.Out.SendMailResponse(client.Player.PlayerCharacter.ID, eMailRespose.Send);
                    }
                    else
                    {
                        msg = "UserSendMailHandler.Failed1";
                        pkg.WriteBoolean(false);
                    }
                }
                else
                {   
                     
                    eMsg = eMessageType.ERROR;
                    msg = "UserSendMailHandler.Failed2";
                    pkg.WriteBoolean(false);
                }
            }
            client.Out.SendMessage(eMsg, LanguageMgr.GetTranslation(msg));
            client.Out.SendTCP(pkg);
            
            return 0;
        }
Exemple #8
0
        //0表示男女,1男2女
        //type 1表示物品,2表示金币,3表示点券,4表示经验,5表示功勋,6表示BUFF
        public static bool AddDailyAward(GamePlayer player)
        {
            if (DateTime.Now.Date == player.PlayerCharacter.LastAward.Date)
            {
                return false;
            }

            //if (player.PlayerCharacter.DayLoginCount > 0)
            //    return false;

            player.PlayerCharacter.DayLoginCount++;
            player.PlayerCharacter.LastAward = DateTime.Now;
            DailyAwardInfo[] infos = GetAllAwardInfo();
            StringBuilder msg = new StringBuilder();
            string full = string.Empty;
            bool has = false;
            foreach (DailyAwardInfo info in infos)
            {
                if (info.Sex != 0 && (player.PlayerCharacter.Sex ? 1 : 2) != info.Sex)
                    continue;

                has = true;
                switch (info.Type)
                {
                    case 1:
                        ItemTemplateInfo itemTemplateInfo = Bussiness.Managers.ItemMgr.FindItemTemplate(info.TemplateID);
                        if (itemTemplateInfo != null)
                        {
                            int itemCount = info.Count;
                            for (int len = 0; len < itemCount; len += itemTemplateInfo.MaxCount)
                            {
                                int count = len + itemTemplateInfo.MaxCount > itemCount ? itemCount - len : itemTemplateInfo.MaxCount;
                                ItemInfo item = ItemInfo.CreateFromTemplate(itemTemplateInfo, count, (int)ItemAddType.DailyAward);
                                item.ValidDate = info.ValidDate;
                                item.IsBinds = info.IsBinds;

                                //if (player.AddItem(item, Game.Server.Statics.ItemAddType.DailyAward, item.GetBagType()) == -1)
                                if (!player.AddTemplate(item,item.Template.BagType,item.Count))
                                {
                                    using (PlayerBussiness db = new PlayerBussiness())
                                    {
                                        item.UserID = 0;
                                        db.AddGoods(item);

                                        MailInfo message = new MailInfo();
                                        message.Annex1 = item.ItemID.ToString();
                                        message.Content = LanguageMgr.GetTranslation("AwardMgr.AddDailyAward.Content", item.Template.Name);
                                        message.Gold = 0;
                                        message.Money = 0;
                                        message.Receiver = player.PlayerCharacter.NickName;
                                        message.ReceiverID = player.PlayerCharacter.ID;
                                        message.Sender = message.Receiver;
                                        message.SenderID = message.ReceiverID;
                                        message.Title = LanguageMgr.GetTranslation("AwardMgr.AddDailyAward.Title", item.Template.Name);
                                        message.Type = (int)eMailType.DailyAward;
                                        db.SendMail(message);

                                        full = LanguageMgr.GetTranslation("AwardMgr.AddDailyAward.Mail");
                                    }
                                }
                            }
                        }
                        break;
                    case 2:
                        player.AddGold(info.Count);
                        break;
                    case 3:
                        player.AddMoney(info.Count);
                        LogMgr.LogMoneyAdd(LogMoneyType.Award, LogMoneyType.Award_Daily, player.PlayerCharacter.ID, info.Count, player.PlayerCharacter.Money, 0, 0, 0, 0, "", "", "");
                        break;
                    case 4:
                        player.AddGP(info.Count);
                        break;
                    case 5:
                        player.AddOffer(info.Count, false);
                        break;
                    case 6:
                        ItemTemplateInfo template = Bussiness.Managers.ItemMgr.FindItemTemplate(info.TemplateID);
                        if (template != null)
                        {
                            AbstractBuffer buffer = BufferList.CreateBufferHour(template, info.ValidDate);
                            buffer.Start(player);
                        }
                        break;
                }
            }

            if (has)
            {
                //player.Out.SendMessage(eMessageType.DailyAward, full + msg.ToString());

                if (!string.IsNullOrEmpty(full))
                {
                    player.Out.SendMailResponse(player.PlayerCharacter.ID, eMailRespose.Receiver);
                }
            }

            return true;
        }
Exemple #9
0
        public void SendStoreToMail()
        {
            if (_player.PlayerCharacter.ConsortiaID != 0)
                return;

            bool response = false;
            int annexIndex = 0;
            MailInfo message = new MailInfo();
            StringBuilder annexRemark = new StringBuilder();
            annexRemark.Append(LanguageMgr.GetTranslation("Game.Server.GameUtils.CommonBag.AnnexRemark"));
            _player.SaveIntoDatabase();

            using (PlayerBussiness db = new PlayerBussiness())
            {
                for (int i = 0; i < _count; i++)
                {
                    ItemInfo item = m_items[i];
                    if (item == null)
                        continue;

                    RemoveItem(item);
                    response = true;
                    annexIndex++;
                    annexRemark.Append(annexIndex);
                    annexRemark.Append("、");
                    annexRemark.Append(item.Template.Name);
                    annexRemark.Append("x");
                    annexRemark.Append(item.Count);
                    annexRemark.Append(";");

                    switch (annexIndex)
                    {
                        case 1:
                            message.Annex1 = item.ItemID.ToString();
                            message.Annex1Name = item.Template.Name;
                            break;
                        case 2:
                            message.Annex2 = item.ItemID.ToString();
                            message.Annex2Name = item.Template.Name;
                            break;
                        case 3:
                            message.Annex3 = item.ItemID.ToString();
                            message.Annex3Name = item.Template.Name;
                            break;
                        case 4:
                            message.Annex4 = item.ItemID.ToString();
                            message.Annex4Name = item.Template.Name;
                            break;
                        case 5:
                            message.Annex5 = item.ItemID.ToString();
                            message.Annex5Name = item.Template.Name;
                            break;
                    }

                    if (annexIndex == 5)
                    {
                        annexIndex = 0;
                        message.AnnexRemark = annexRemark.ToString();
                        annexRemark.Remove(0, annexRemark.Length);
                        annexRemark.Append(LanguageMgr.GetTranslation("GoodsPresentHandler.AnnexRemark"));
                        message.Content = "";
                        message.Gold = 0;
                        message.Money = 0;
                        message.Receiver = _player.PlayerCharacter.NickName;
                        message.ReceiverID = _player.PlayerCharacter.ID;
                        message.Sender = LanguageMgr.GetTranslation("Game.Server.GameUtils.CommonBag.Sender");
                        message.SenderID = _player.PlayerCharacter.ID;
                        message.Title = message.Annex1Name; //message.AnnexRemark;// LanguageMgr.GetTranslation("Game.Server.GameUtils.CommonBag.Title");
                        message.Type = (int)eMailType.StoreCanel;
                        db.SendMail(message);

                        message.Revert();
                    }
                }

                if (annexIndex > 0)
                {
                    message.AnnexRemark = annexRemark.ToString();
                    message.Content = "";
                    message.Gold = 0;
                    message.Money = 0;
                    message.Receiver = _player.PlayerCharacter.NickName;
                    message.ReceiverID = _player.PlayerCharacter.ID;
                    message.Sender = LanguageMgr.GetTranslation("Game.Server.GameUtils.CommonBag.Sender");
                    message.SenderID = _player.PlayerCharacter.ID;
                    message.Title = message.Annex1Name; //message.AnnexRemark;// LanguageMgr.GetTranslation("Game.Server.GameUtils.CommonBag.Title");
                    message.Type = (int)eMailType.StoreCanel;
                    db.SendMail(message);
                }
            }

            _player.SaveIntoDatabase();

            if (response)
            {
                _player.Out.SendMailResponse(_player.PlayerCharacter.ID, eMailRespose.Receiver);
            }
        }
Exemple #10
0
 public bool UpdateMail(MailInfo mail, int oldMoney)
 {
     bool flag = false;
     try
     {
         SqlParameter[] SqlParameters = new SqlParameter[30]
     {
       new SqlParameter("@ID", (object) mail.ID),
       new SqlParameter("@Annex1", mail.Annex1 == null ? (object) "" : (object) mail.Annex1),
       new SqlParameter("@Annex2", mail.Annex2 == null ? (object) "" : (object) mail.Annex2),
       new SqlParameter("@Content", mail.Content == null ? (object) "" : (object) mail.Content),
       new SqlParameter("@Gold", (object) mail.Gold),
       new SqlParameter("@IsExist", (object) (int) (mail.IsExist ? 1 : 0)),
       new SqlParameter("@Money", (object) mail.Money),
       new SqlParameter("@Receiver", mail.Receiver == null ? (object) "" : (object) mail.Receiver),
       new SqlParameter("@ReceiverID", (object) mail.ReceiverID),
       new SqlParameter("@Sender", mail.Sender == null ? (object) "" : (object) mail.Sender),
       new SqlParameter("@SenderID", (object) mail.SenderID),
       new SqlParameter("@Title", mail.Title == null ? (object) "" : (object) mail.Title),
       new SqlParameter("@IfDelS", (object) false),
       new SqlParameter("@IsDelete", (object) false),
       new SqlParameter("@IsDelR", (object) false),
       new SqlParameter("@IsRead", (object) (int) (mail.IsRead ? 1 : 0)),
       new SqlParameter("@SendTime", (object) mail.SendTime),
       new SqlParameter("@Type", (object) mail.Type),
       new SqlParameter("@OldMoney", (object) oldMoney),
       new SqlParameter("@ValidDate", (object) mail.ValidDate),
       new SqlParameter("@Annex1Name", (object) mail.Annex1Name),
       new SqlParameter("@Annex2Name", (object) mail.Annex2Name),
       new SqlParameter("@Result", SqlDbType.Int),
       null,
       null,
       null,
       null,
       null,
       null,
       null
     };
         SqlParameters[22].Direction = ParameterDirection.ReturnValue;
         SqlParameters[23] = new SqlParameter("@Annex3", mail.Annex3 == null ? (object)"" : (object)mail.Annex3);
         SqlParameters[24] = new SqlParameter("@Annex4", mail.Annex4 == null ? (object)"" : (object)mail.Annex4);
         SqlParameters[25] = new SqlParameter("@Annex5", mail.Annex5 == null ? (object)"" : (object)mail.Annex5);
         SqlParameters[26] = new SqlParameter("@Annex3Name", mail.Annex3Name == null ? (object)"" : (object)mail.Annex3Name);
         SqlParameters[27] = new SqlParameter("@Annex4Name", mail.Annex4Name == null ? (object)"" : (object)mail.Annex4Name);
         SqlParameters[28] = new SqlParameter("@Annex5Name", mail.Annex5Name == null ? (object)"" : (object)mail.Annex5Name);
         SqlParameters[29] = new SqlParameter("GiftToken", (object)mail.GiftToken);
         this.db.RunProcedure("SP_Mail_Update", SqlParameters);
         flag = (int)SqlParameters[22].Value == 0;
     }
     catch (Exception ex)
     {
         if (BaseBussiness.log.IsErrorEnabled)
             BaseBussiness.log.Error((object)"Init", ex);
     }
     return flag;
 }
Exemple #11
0
 public int SendMailAndItem(string title, string content, int UserID, int templateID, int count, int validDate, int gold, int money, int StrengthenLevel, int AttackCompose, int DefendCompose, int AgilityCompose, int LuckCompose, bool isBinds)
 {
     MailInfo mail = new MailInfo();
     mail.Annex1 = "";
     mail.Content = title;
     mail.Gold = gold;
     mail.Money = money;
     mail.Receiver = "";
     mail.ReceiverID = UserID;
     mail.Sender = "Administrators";
     mail.SenderID = 0;
     mail.Title = content;
     SqlDataProvider.Data.ItemInfo itemInfo = new SqlDataProvider.Data.ItemInfo((ItemTemplateInfo)null);
     itemInfo.AgilityCompose = AgilityCompose;
     itemInfo.AttackCompose = AttackCompose;
     itemInfo.BeginDate = DateTime.Now;
     itemInfo.Color = "";
     itemInfo.DefendCompose = DefendCompose;
     itemInfo.IsDirty = false;
     itemInfo.IsExist = true;
     itemInfo.IsJudge = true;
     itemInfo.LuckCompose = LuckCompose;
     itemInfo.StrengthenLevel = StrengthenLevel;
     itemInfo.TemplateID = templateID;
     itemInfo.ValidDate = validDate;
     itemInfo.Count = count;
     itemInfo.IsBinds = isBinds;
     int returnValue = 1;
     this.SendMailAndItem(mail, itemInfo, ref returnValue);
     return returnValue;
 }
        public int SendMailAndItem(string title, string content, int UserID, int templateID, int count, int validDate, int gold, int money, int StrengthenLevel, int AttackCompose, int DefendCompose, int AgilityCompose, int LuckCompose, bool isBinds)
        {
            MailInfo message = new MailInfo();
            message.Annex1 = "";
            message.Content = title;
            message.Gold = gold;
            message.Money = money;
            message.Receiver = "";
            message.ReceiverID = UserID;
            message.Sender = "Administrators";//LanguageMgr.GetTranslation("PlayerBussiness.SendMailAndItem.Sender");
            message.SenderID = 0;
            message.Title = content;

            ItemInfo userGoods = new ItemInfo(null);
            userGoods.AgilityCompose = AgilityCompose;
            userGoods.AttackCompose = AttackCompose;
            userGoods.BeginDate = DateTime.Now;
            userGoods.Color = "";
            userGoods.DefendCompose = DefendCompose;
            userGoods.IsDirty = false;
            userGoods.IsExist = true;
            userGoods.IsJudge = true;
            userGoods.LuckCompose = LuckCompose;
            userGoods.StrengthenLevel = StrengthenLevel;
            userGoods.TemplateID = templateID;
            userGoods.ValidDate = validDate;
            userGoods.Count = count;
            userGoods.IsBinds = isBinds;

            int returnValue = 1;
            SendMailAndItem(message, userGoods, ref returnValue);
            return returnValue;
        }
        public bool SendMailAndMoney(MailInfo mail, ref int returnValue)
        {
            bool result = false;
            try
            {
                SqlParameter[] para = new SqlParameter[18];
                para[0] = new SqlParameter("@ID", mail.ID);
                para[0].Direction = ParameterDirection.Output;
                para[1] = new SqlParameter("@Annex1", mail.Annex1 == null ? "" : mail.Annex1);
                para[2] = new SqlParameter("@Annex2", mail.Annex2 == null ? "" : mail.Annex2);
                para[3] = new SqlParameter("@Content", mail.Content == null ? "" : mail.Content);
                para[4] = new SqlParameter("@Gold", mail.Gold);
                para[5] = new SqlParameter("@IsExist", true);
                para[6] = new SqlParameter("@Money", mail.Money);
                para[7] = new SqlParameter("@Receiver", mail.Receiver == null ? "" : mail.Receiver);
                para[8] = new SqlParameter("@ReceiverID", mail.ReceiverID);
                para[9] = new SqlParameter("@Sender", mail.Sender == null ? "" : mail.Sender);
                para[10] = new SqlParameter("@SenderID", mail.SenderID);
                para[11] = new SqlParameter("@Title", mail.Title == null ? "" : mail.Title);
                para[12] = new SqlParameter("@IfDelS", false);
                para[13] = new SqlParameter("@IsDelete", false);
                para[14] = new SqlParameter("@IsDelR", false);
                para[15] = new SqlParameter("@IsRead", false);
                para[16] = new SqlParameter("@SendTime", DateTime.Now);
                para[17] = new SqlParameter("@Result", System.Data.SqlDbType.Int);
                para[17].Direction = ParameterDirection.ReturnValue;

                result = db.RunProcedure("SP_Admin_SendUserMoney", para);
                returnValue = (int)para[17].Value;
                result = returnValue == 0;

            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                    log.Error("Init", e);
            }
            finally
            {
            }
            return result;
        }
        public bool SendMailAndItem(MailInfo mail, ItemInfo item, ref int returnValue)
        {
            bool result = false;
            try
            {

                SqlParameter[] para = new SqlParameter[34];
                //物品
                para[0] = new SqlParameter("@ItemID", item.ItemID);
                para[1] = new SqlParameter("@UserID", item.UserID);
                para[2] = new SqlParameter("@TemplateID", item.TemplateID);
                para[3] = new SqlParameter("@Place", item.Place);
                para[4] = new SqlParameter("@AgilityCompose", item.AgilityCompose);
                para[5] = new SqlParameter("@AttackCompose", item.AttackCompose);
                para[6] = new SqlParameter("@BeginDate", item.BeginDate);
                para[7] = new SqlParameter("@Color", item.Color == null ? "" : item.Color);
                para[8] = new SqlParameter("@Count", item.Count);
                para[9] = new SqlParameter("@DefendCompose", item.DefendCompose);
                para[10] = new SqlParameter("@IsBinds", item.IsBinds);
                para[11] = new SqlParameter("@IsExist", item.IsExist);
                para[12] = new SqlParameter("@IsJudge", item.IsJudge);
                para[13] = new SqlParameter("@LuckCompose", item.LuckCompose);
                para[14] = new SqlParameter("@StrengthenLevel", item.StrengthenLevel);
                para[15] = new SqlParameter("@ValidDate", item.ValidDate);
                para[16] = new SqlParameter("@BagType", item.BagType);
                //信箱
                para[17] = new SqlParameter("@ID", mail.ID);
                para[17].Direction = ParameterDirection.Output;
                para[18] = new SqlParameter("@Annex1", mail.Annex1 == null ? "" : mail.Annex1);
                para[19] = new SqlParameter("@Annex2", mail.Annex2 == null ? "" : mail.Annex2);
                para[20] = new SqlParameter("@Content", mail.Content == null ? "" : mail.Content);
                para[21] = new SqlParameter("@Gold", mail.Gold);
                para[22] = new SqlParameter("@Money", mail.Money);
                para[23] = new SqlParameter("@Receiver", mail.Receiver == null ? "" : mail.Receiver);
                para[24] = new SqlParameter("@ReceiverID", mail.ReceiverID);
                para[25] = new SqlParameter("@Sender", mail.Sender == null ? "" : mail.Sender);
                para[26] = new SqlParameter("@SenderID", mail.SenderID);
                para[27] = new SqlParameter("@Title", mail.Title == null ? "" : mail.Title);
                para[28] = new SqlParameter("@IfDelS", false);
                para[29] = new SqlParameter("@IsDelete", false);
                para[30] = new SqlParameter("@IsDelR", false);
                para[31] = new SqlParameter("@IsRead", false);
                para[32] = new SqlParameter("@SendTime", DateTime.Now);
                para[33] = new SqlParameter("@Result", System.Data.SqlDbType.Int);
                para[33].Direction = ParameterDirection.ReturnValue;

                result = db.RunProcedure("SP_Admin_SendUserItem", para);
                returnValue = (int)para[33].Value;
                result = returnValue == 0;

                if (result)
                {
                    using (CenterServiceClient client = new CenterServiceClient())
                    {
                        client.MailNotice(mail.ReceiverID);
                    }
                }

            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                    log.Error("Init", e);
            }
            finally
            {
            }
            return result;
        }
        public bool UpdateMail(MailInfo mail, int oldMoney)
        {
            bool result = false;
            try
            {
                SqlParameter[] para = new SqlParameter[30];
                para[0] = new SqlParameter("@ID", mail.ID);
                para[1] = new SqlParameter("@Annex1", mail.Annex1 == null ? "" : mail.Annex1);
                para[2] = new SqlParameter("@Annex2", mail.Annex2 == null ? "" : mail.Annex2);
                para[3] = new SqlParameter("@Content", mail.Content == null ? "" : mail.Content);
                para[4] = new SqlParameter("@Gold", mail.Gold);
                para[5] = new SqlParameter("@IsExist", mail.IsExist);
                para[6] = new SqlParameter("@Money", mail.Money);
                para[7] = new SqlParameter("@Receiver", mail.Receiver == null ? "" : mail.Receiver);
                para[8] = new SqlParameter("@ReceiverID", mail.ReceiverID);
                para[9] = new SqlParameter("@Sender", mail.Sender == null ? "" : mail.Sender);
                para[10] = new SqlParameter("@SenderID", mail.SenderID);
                para[11] = new SqlParameter("@Title", mail.Title == null ? "" : mail.Title);
                para[12] = new SqlParameter("@IfDelS", false);
                para[13] = new SqlParameter("@IsDelete", false);
                para[14] = new SqlParameter("@IsDelR", false);
                para[15] = new SqlParameter("@IsRead", mail.IsRead);
                para[16] = new SqlParameter("@SendTime", mail.SendTime);
                para[17] = new SqlParameter("@Type", mail.Type);
                para[18] = new SqlParameter("@OldMoney", oldMoney);
                para[19] = new SqlParameter("@ValidDate", mail.ValidDate);
                para[20] = new SqlParameter("@Annex1Name", mail.Annex1Name);
                para[21] = new SqlParameter("@Annex2Name", mail.Annex2Name);
                para[22] = new SqlParameter("@Result", System.Data.SqlDbType.Int);
                para[22].Direction = ParameterDirection.ReturnValue;
                para[23] = new SqlParameter("@Annex3", mail.Annex3 == null ? "" : mail.Annex3);
                para[24] = new SqlParameter("@Annex4", mail.Annex4 == null ? "" : mail.Annex4);
                para[25] = new SqlParameter("@Annex5", mail.Annex5 == null ? "" : mail.Annex5);
                para[26] = new SqlParameter("@Annex3Name", mail.Annex3Name == null ? "" : mail.Annex3Name);
                para[27] = new SqlParameter("@Annex4Name", mail.Annex4Name == null ? "" : mail.Annex4Name);
                para[28] = new SqlParameter("@Annex5Name", mail.Annex5Name == null ? "" : mail.Annex5Name);
                para[29] = new SqlParameter("GiftToken", mail.GiftToken);
                db.RunProcedure("SP_Mail_Update", para);

                int returnValue = (int)para[22].Value;
                result = returnValue == 0;
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                    log.Error("Init", e);
            }
            finally
            {
            }
            return result;
        }
        public bool SendMail(MailInfo mail)
        {
            bool result = false;
            try
            {
                SqlParameter[] para = new SqlParameter[29];
                para[0] = new SqlParameter("@ID", mail.ID);
                para[0].Direction = ParameterDirection.Output;
                para[1] = new SqlParameter("@Annex1", mail.Annex1 == null ? "" : mail.Annex1);
                para[2] = new SqlParameter("@Annex2", mail.Annex2 == null ? "" : mail.Annex2);
                para[3] = new SqlParameter("@Content", mail.Content == null ? "" : mail.Content);
                para[4] = new SqlParameter("@Gold", mail.Gold);
                para[5] = new SqlParameter("@IsExist", true);
                para[6] = new SqlParameter("@Money", mail.Money);
                para[7] = new SqlParameter("@Receiver", mail.Receiver == null ? "" : mail.Receiver);
                para[8] = new SqlParameter("@ReceiverID", mail.ReceiverID);
                para[9] = new SqlParameter("@Sender", mail.Sender == null ? "" : mail.Sender);
                para[10] = new SqlParameter("@SenderID", mail.SenderID);
                para[11] = new SqlParameter("@Title", mail.Title == null ? "" : mail.Title);
                para[12] = new SqlParameter("@IfDelS", false);
                para[13] = new SqlParameter("@IsDelete", false);
                para[14] = new SqlParameter("@IsDelR", false);
                para[15] = new SqlParameter("@IsRead", false);
                para[16] = new SqlParameter("@SendTime", DateTime.Now);
                para[17] = new SqlParameter("@Type", mail.Type);
                para[18] = new SqlParameter("@Annex1Name", mail.Annex1Name == null ? "" : mail.Annex1Name);
                para[19] = new SqlParameter("@Annex2Name", mail.Annex2Name == null ? "" : mail.Annex2Name);
                para[20] = new SqlParameter("@Annex3", mail.Annex3 == null ? "" : mail.Annex3);
                para[21] = new SqlParameter("@Annex4", mail.Annex4 == null ? "" : mail.Annex4);
                para[22] = new SqlParameter("@Annex5", mail.Annex5 == null ? "" : mail.Annex5);
                para[23] = new SqlParameter("@Annex3Name", mail.Annex3Name == null ? "" : mail.Annex3Name);
                para[24] = new SqlParameter("@Annex4Name", mail.Annex4Name == null ? "" : mail.Annex4Name);
                para[25] = new SqlParameter("@Annex5Name", mail.Annex5Name == null ? "" : mail.Annex5Name);
                para[26] = new SqlParameter("@ValidDate", mail.ValidDate);
                para[27] = new SqlParameter("@AnnexRemark", mail.AnnexRemark == null ? "" : mail.AnnexRemark);
                para[28] = new SqlParameter("GiftToken", mail.GiftToken);
        //        @ID = @ID OUTPUT,
                result = db.RunProcedure("SP_Mail_Send", para);
                mail.ID = (int)para[0].Value;
                using (CenterServiceClient client = new CenterServiceClient())
                {
                    client.MailNotice(mail.ReceiverID);
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                    log.Error("Init", e);
            }
            finally
            {
            }
            return result;

        }
 public MailInfo InitMail(SqlDataReader reader)
 {
     MailInfo info = new MailInfo();
     info.Annex1 = reader["Annex1"].ToString();
     info.Annex2 = reader["Annex2"].ToString();
     info.Content = reader["Content"].ToString();
     info.Gold = (int)reader["Gold"];
     info.ID = (int)reader["ID"];
     info.IsExist = (bool)reader["IsExist"];
     info.Money = (int)reader["Money"];
     info.Receiver = reader["Receiver"].ToString();
     info.ReceiverID = (int)reader["ReceiverID"];
     info.Sender = reader["Sender"].ToString();
     info.SenderID = (int)reader["SenderID"];
     info.Title = reader["Title"].ToString();
     info.Type = (int)reader["Type"];
     info.ValidDate = (int)reader["ValidDate"];
     info.IsRead = (bool)reader["IsRead"];
     info.SendTime = (DateTime)reader["SendTime"];
     info.Annex1Name = reader["Annex1Name"] == null ? "" : reader["Annex1Name"].ToString();
     info.Annex2Name = reader["Annex2Name"] == null ? "" : reader["Annex2Name"].ToString();
     info.Annex3 = reader["Annex3"].ToString();
     info.Annex4 = reader["Annex4"].ToString();
     info.Annex5 = reader["Annex5"].ToString();
     info.Annex3Name = reader["Annex3Name"] == null ? "" : reader["Annex3Name"].ToString();
     info.Annex4Name = reader["Annex4Name"] == null ? "" : reader["Annex4Name"].ToString();
     info.Annex5Name = reader["Annex5Name"] == null ? "" : reader["Annex5Name"].ToString();
     info.AnnexRemark = reader["AnnexRemark"] == null ? "" : reader["AnnexRemark"].ToString();
     return info;
 }
Exemple #18
0
 public bool SendMail(MailInfo mail)
 {
     bool flag = false;
     try
     {
         SqlParameter[] SqlParameters = new SqlParameter[29];
         SqlParameters[0] = new SqlParameter("@ID", (object)mail.ID);
         SqlParameters[0].Direction = ParameterDirection.Output;
         SqlParameters[1] = new SqlParameter("@Annex1", mail.Annex1 == null ? (object)"" : (object)mail.Annex1);
         SqlParameters[2] = new SqlParameter("@Annex2", mail.Annex2 == null ? (object)"" : (object)mail.Annex2);
         SqlParameters[3] = new SqlParameter("@Content", mail.Content == null ? (object)"" : (object)mail.Content);
         SqlParameters[4] = new SqlParameter("@Gold", (object)mail.Gold);
         SqlParameters[5] = new SqlParameter("@IsExist", (object)true);
         SqlParameters[6] = new SqlParameter("@Money", (object)mail.Money);
         SqlParameters[7] = new SqlParameter("@Receiver", mail.Receiver == null ? (object)"" : (object)mail.Receiver);
         SqlParameters[8] = new SqlParameter("@ReceiverID", (object)mail.ReceiverID);
         SqlParameters[9] = new SqlParameter("@Sender", mail.Sender == null ? (object)"" : (object)mail.Sender);
         SqlParameters[10] = new SqlParameter("@SenderID", (object)mail.SenderID);
         SqlParameters[11] = new SqlParameter("@Title", mail.Title == null ? (object)"" : (object)mail.Title);
         SqlParameters[12] = new SqlParameter("@IfDelS", (object)false);
         SqlParameters[13] = new SqlParameter("@IsDelete", (object)false);
         SqlParameters[14] = new SqlParameter("@IsDelR", (object)false);
         SqlParameters[15] = new SqlParameter("@IsRead", (object)false);
         SqlParameters[16] = new SqlParameter("@SendTime", (object)DateTime.Now);
         SqlParameters[17] = new SqlParameter("@Type", (object)mail.Type);
         SqlParameters[18] = new SqlParameter("@Annex1Name", mail.Annex1Name == null ? (object)"" : (object)mail.Annex1Name);
         SqlParameters[19] = new SqlParameter("@Annex2Name", mail.Annex2Name == null ? (object)"" : (object)mail.Annex2Name);
         SqlParameters[20] = new SqlParameter("@Annex3", mail.Annex3 == null ? (object)"" : (object)mail.Annex3);
         SqlParameters[21] = new SqlParameter("@Annex4", mail.Annex4 == null ? (object)"" : (object)mail.Annex4);
         SqlParameters[22] = new SqlParameter("@Annex5", mail.Annex5 == null ? (object)"" : (object)mail.Annex5);
         SqlParameters[23] = new SqlParameter("@Annex3Name", mail.Annex3Name == null ? (object)"" : (object)mail.Annex3Name);
         SqlParameters[24] = new SqlParameter("@Annex4Name", mail.Annex4Name == null ? (object)"" : (object)mail.Annex4Name);
         SqlParameters[25] = new SqlParameter("@Annex5Name", mail.Annex5Name == null ? (object)"" : (object)mail.Annex5Name);
         SqlParameters[26] = new SqlParameter("@ValidDate", (object)mail.ValidDate);
         SqlParameters[27] = new SqlParameter("@AnnexRemark", mail.AnnexRemark == null ? (object)"" : (object)mail.AnnexRemark);
         SqlParameters[28] = new SqlParameter("GiftToken", (object)mail.GiftToken);
         flag = this.db.RunProcedure("SP_Mail_Send", SqlParameters);
         mail.ID = (int)SqlParameters[0].Value;
         using (CenterServiceClient centerServiceClient = new CenterServiceClient())
             centerServiceClient.MailNotice(mail.ReceiverID);
     }
     catch (Exception ex)
     {
         if (BaseBussiness.log.IsErrorEnabled)
             BaseBussiness.log.Error((object)"Init", ex);
     }
     return flag;
 }
Exemple #19
0
 public bool SendMailAndItem(MailInfo mail, SqlDataProvider.Data.ItemInfo item, ref int returnValue)
 {
     bool flag = false;
     try
     {
         SqlParameter[] SqlParameters = new SqlParameter[34]
     {
       new SqlParameter("@ItemID", (object) item.ItemID),
       new SqlParameter("@UserID", (object) item.UserID),
       new SqlParameter("@TemplateID", (object) item.TemplateID),
       new SqlParameter("@Place", (object) item.Place),
       new SqlParameter("@AgilityCompose", (object) item.AgilityCompose),
       new SqlParameter("@AttackCompose", (object) item.AttackCompose),
       new SqlParameter("@BeginDate", (object) item.BeginDate),
       new SqlParameter("@Color", item.Color == null ? (object) "" : (object) item.Color),
       new SqlParameter("@Count", (object) item.Count),
       new SqlParameter("@DefendCompose", (object) item.DefendCompose),
       new SqlParameter("@IsBinds", (object) (int) (item.IsBinds ? 1 : 0)),
       new SqlParameter("@IsExist", (object) (int) (item.IsExist ? 1 : 0)),
       new SqlParameter("@IsJudge", (object) (int) (item.IsJudge ? 1 : 0)),
       new SqlParameter("@LuckCompose", (object) item.LuckCompose),
       new SqlParameter("@StrengthenLevel", (object) item.StrengthenLevel),
       new SqlParameter("@ValidDate", (object) item.ValidDate),
       new SqlParameter("@BagType", (object) item.BagType),
       new SqlParameter("@ID", (object) mail.ID),
       null,
       null,
       null,
       null,
       null,
       null,
       null,
       null,
       null,
       null,
       null,
       null,
       null,
       null,
       null,
       null
     };
         SqlParameters[17].Direction = ParameterDirection.Output;
         SqlParameters[18] = new SqlParameter("@Annex1", mail.Annex1 == null ? (object)"" : (object)mail.Annex1);
         SqlParameters[19] = new SqlParameter("@Annex2", mail.Annex2 == null ? (object)"" : (object)mail.Annex2);
         SqlParameters[20] = new SqlParameter("@Content", mail.Content == null ? (object)"" : (object)mail.Content);
         SqlParameters[21] = new SqlParameter("@Gold", (object)mail.Gold);
         SqlParameters[22] = new SqlParameter("@Money", (object)mail.Money);
         SqlParameters[23] = new SqlParameter("@Receiver", mail.Receiver == null ? (object)"" : (object)mail.Receiver);
         SqlParameters[24] = new SqlParameter("@ReceiverID", (object)mail.ReceiverID);
         SqlParameters[25] = new SqlParameter("@Sender", mail.Sender == null ? (object)"" : (object)mail.Sender);
         SqlParameters[26] = new SqlParameter("@SenderID", (object)mail.SenderID);
         SqlParameters[27] = new SqlParameter("@Title", mail.Title == null ? (object)"" : (object)mail.Title);
         SqlParameters[28] = new SqlParameter("@IfDelS", (object)false);
         SqlParameters[29] = new SqlParameter("@IsDelete", (object)false);
         SqlParameters[30] = new SqlParameter("@IsDelR", (object)false);
         SqlParameters[31] = new SqlParameter("@IsRead", (object)false);
         SqlParameters[32] = new SqlParameter("@SendTime", (object)DateTime.Now);
         SqlParameters[33] = new SqlParameter("@Result", SqlDbType.Int);
         SqlParameters[33].Direction = ParameterDirection.ReturnValue;
         flag = this.db.RunProcedure("SP_Admin_SendUserItem", SqlParameters);
         returnValue = (int)SqlParameters[33].Value;
         flag = returnValue == 0;
         if (flag)
         {
             using (CenterServiceClient centerServiceClient = new CenterServiceClient())
                 centerServiceClient.MailNotice(mail.ReceiverID);
         }
     }
     catch (Exception ex)
     {
         if (BaseBussiness.log.IsErrorEnabled)
             BaseBussiness.log.Error((object)"Init", ex);
     }
     return flag;
 }
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            if (countConnect >= 3000) { client.Disconnect(); return 0; }

            int gold = 0;            //表示金币
            int money = 0;           //表示点券
            int offer = 0;           //表示功勋
            int gifttoken = 0;       //表示礼劵
            int medal = 0;
            StringBuilder payGoods = new StringBuilder();                    //表示支付物品ID
            eMessageType eMsg = eMessageType.Normal;
            string msg = "UserBuyItemHandler.Success";

            List<ItemInfo> buyitems = new List<ItemInfo>();                  //购买物品列表
            //List<int> needitemsinfo = new List<int>();                       //购买所需物品列表
            List<bool> dresses = new List<bool>();
            List<int> places = new List<int>();
            StringBuilder types = new StringBuilder();

            bool isBind = false;
            ConsortiaInfo consotia = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);

            int count = packet.ReadInt();
            for (int i = 0; i < count; i++)
            {
                int buyFrom = packet.ReadInt();
                int GoodsID = packet.ReadInt();
                int type = packet.ReadInt();
                string color = packet.ReadString();
                bool dress = packet.ReadBoolean();
                string skin = packet.ReadString();
                int place = packet.ReadInt();

                //这里开始处理公会商店
                ShopItemInfo shopItem = Bussiness.Managers.ShopMgr.GetShopItemInfoById(GoodsID);                   //获取商品信息
                //if (shopItem.ShopID == 2 || !Bussiness.Managers.ShopMgr.CanBuy(shopItem.ShopID, consotia == null ? 1 : consotia.ShopLevel, ref isBind, client.Player.PlayerCharacter.ConsortiaID, client.Player.PlayerCharacter.Riches))
                if (!Bussiness.Managers.ShopMgr.CanBuy(shopItem.ShopID, consotia == null ? 1 : consotia.ShopLevel, ref isBind, client.Player.PlayerCharacter.ConsortiaID, client.Player.PlayerCharacter.Riches))
                {
                    client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserBuyItemHandler.FailByPermission"));
                    return 1;
                }

                //if (shopItem == null)
                //{
                //    continue;
                //}

                ItemTemplateInfo goods = Bussiness.Managers.ItemMgr.FindItemTemplate(shopItem.TemplateID);              //获取物品属性

                ItemInfo item = ItemInfo.CreateFromTemplate(goods, 1, (int)ItemAddType.Buy);                            //创建物品模板

                ////////////////////////////////////////////////////////////////////////////////////////////////////
                //判断有限期
                if (0 == shopItem.BuyType)                              //时间购买类型
                {
                    if (1 == type)
                    {
                        item.ValidDate = shopItem.AUnit;
                    }
                    if (2 == type)
                    {
                        item.ValidDate = shopItem.BUnit;
                    }
                    if (3 == type)
                    {
                        item.ValidDate = shopItem.CUnit;
                    }
                }
                else                                                  //数量购买类型
                {
                    if (1 == type)
                    {
                        item.Count = shopItem.AUnit;
                    }
                    if (2 == type)
                    {
                        item.Count = shopItem.BUnit;
                    }
                    if (3 == type)
                    {
                        item.Count = shopItem.CUnit;
                    }
                }
                ////////////////////////////////////////////////////////////////////////////////////////////////////////

                if (item == null && shopItem == null)
                    continue;
                item.Color = color == null ? "" : color;
                item.Skin = skin == null ? "" : skin;
                if (isBind == true)
                {
                    item.IsBinds = true;
                }
                else
                {
                    item.IsBinds = Convert.ToBoolean(shopItem.IsBind);
                }

                types.Append(type);
                types.Append(",");
                buyitems.Add(item);
                dresses.Add(dress);
                places.Add(place);

                ItemInfo.SetItemType(shopItem, type, ref gold, ref money, ref offer, ref gifttoken, ref medal);

            }

            if (buyitems.Count == 0)
                return 1;
            if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked"));
                return 1;
            }

            //判断金币或礼券等是否足够
            if (gold <= client.Player.PlayerCharacter.Gold &&
                money <= client.Player.PlayerCharacter.Money &&
                offer <= client.Player.PlayerCharacter.Offer &&
                gifttoken <= client.Player.PlayerCharacter.GiftToken)// &&
                //medal <= client.Player.PlayerCharacter.medal)
            {
                client.Player.RemoveMoney(money);
                client.Player.RemoveGold(gold);
                client.Player.RemoveOffer(offer);
                client.Player.RemoveGiftToken(gifttoken);
                //client.Player.RemoveMedal(medal);

                string itemIDs = "";
                int annexIndex = 0;
                MailInfo message = new MailInfo();
                StringBuilder annexRemark = new StringBuilder();
                annexRemark.Append(LanguageMgr.GetTranslation("GoodsPresentHandler.AnnexRemark"));

                for (int i = 0; i < buyitems.Count; i++)
                {
                    itemIDs += (itemIDs == "" ? buyitems[i].TemplateID.ToString() : "," + buyitems[i].TemplateID.ToString());
                    if (client.Player.AddTemplate(buyitems[i], buyitems[i].Template.BagType, buyitems[i].Count))
                    {
                        if (dresses[i] && buyitems[i].CanEquip())
                        {
                            int slot = client.Player.MainBag.FindItemEpuipSlot(buyitems[i].Template);
                            if ((slot == 9 || slot == 10) && (places[i] == 9 || places[i] == 10))
                            {
                                slot = places[i];
                            }
                            else if ((slot == 7 || slot == 8) && (places[i] == 7 || places[i] == 8))
                            {
                                slot = places[i];
                            }

                            client.Player.MainBag.MoveItem(buyitems[i].Place, slot, 0);
                            msg = "UserBuyItemHandler.Save";
                        }
                    }
                    else
                    {
                        using (PlayerBussiness db = new PlayerBussiness())
                        {
                            buyitems[i].UserID = 0;
                            db.AddGoods(buyitems[i]);

                            annexIndex++;
                            annexRemark.Append(annexIndex);
                            annexRemark.Append("、");
                            annexRemark.Append(buyitems[i].Template.Name);
                            annexRemark.Append("x");
                            annexRemark.Append(buyitems[i].Count);
                            annexRemark.Append(";");
                            switch (annexIndex)
                            {
                                case 1:
                                    message.Annex1 = buyitems[i].ItemID.ToString();
                                    message.Annex1Name = buyitems[i].Template.Name;
                                    break;
                                case 2:
                                    message.Annex2 = buyitems[i].ItemID.ToString();
                                    message.Annex2Name = buyitems[i].Template.Name;
                                    break;
                                case 3:
                                    message.Annex3 = buyitems[i].ItemID.ToString();
                                    message.Annex3Name = buyitems[i].Template.Name;
                                    break;
                                case 4:
                                    message.Annex4 = buyitems[i].ItemID.ToString();
                                    message.Annex4Name = buyitems[i].Template.Name;
                                    break;
                                case 5:
                                    message.Annex5 = buyitems[i].ItemID.ToString();
                                    message.Annex5Name = buyitems[i].Template.Name;
                                    break;
                            }

                            if (annexIndex == 5)
                            {
                                annexIndex = 0;
                                message.AnnexRemark = annexRemark.ToString();
                                annexRemark.Remove(0, annexRemark.Length);
                                annexRemark.Append(LanguageMgr.GetTranslation("GoodsPresentHandler.AnnexRemark"));

                                message.Content = LanguageMgr.GetTranslation("UserBuyItemHandler.Title") + message.Annex1Name + "]";
                                message.Gold = 0;
                                message.Money = 0;
                                message.Receiver = client.Player.PlayerCharacter.NickName;
                                message.ReceiverID = client.Player.PlayerCharacter.ID;
                                message.Sender = message.Receiver;
                                message.SenderID = message.ReceiverID;
                                message.Title = message.Content;
                                message.Type = (int)eMailType.BuyItem;
                                db.SendMail(message);

                                eMsg = eMessageType.ERROR;
                                msg = "UserBuyItemHandler.Mail";

                                message.Revert();
                            }
                        }
                    }
                }

                if (annexIndex > 0)
                {
                    using (PlayerBussiness db = new PlayerBussiness())
                    {
                        message.AnnexRemark = annexRemark.ToString();
                        message.Content = LanguageMgr.GetTranslation("UserBuyItemHandler.Title") + message.Annex1Name + "]";
                        message.Gold = 0;
                        message.Money = 0;
                        message.Receiver = client.Player.PlayerCharacter.NickName;
                        message.ReceiverID = client.Player.PlayerCharacter.ID;
                        message.Sender = message.Receiver;
                        message.SenderID = message.ReceiverID;
                        message.Title = message.Content;
                        message.Type = (int)eMailType.BuyItem;
                        db.SendMail(message);

                        eMsg = eMessageType.ERROR;
                        msg = "UserBuyItemHandler.Mail";
                    }
                }

                if (eMsg == eMessageType.ERROR)
                {
                    client.Out.SendMailResponse(client.Player.PlayerCharacter.ID, eMailRespose.Receiver);
                }

                client.Player.OnPaid(money, gold, offer, gifttoken, medal, payGoods.ToString());//触发任务事件

                LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_Buy, client.Player.PlayerCharacter.ID, money, client.Player.PlayerCharacter.Money, gold, gifttoken, offer, medal, "牌子编号", itemIDs, types.ToString());
            }
            else
            {
                if (gold > client.Player.PlayerCharacter.Gold)
                {
                    msg = "UserBuyItemHandler.NoGold";
                }
                if (offer > client.Player.PlayerCharacter.Offer)
                {
                    msg = "UserBuyItemHandler.NoOffer";
                }
                if (gifttoken > client.Player.PlayerCharacter.GiftToken)
                {
                    msg = "UserBuyItemHandler.GiftToken";
                }
                if (medal > client.Player.PlayerCharacter.medal)
                {
                    msg = "UserBuyItemHandler.Medal";
                }
                eMsg = eMessageType.ERROR;
            }

            client.Out.SendMessage(eMsg, LanguageMgr.GetTranslation(msg));
            return 0;
        }
Exemple #21
0
 public bool SendMailAndMoney(MailInfo mail, ref int returnValue)
 {
     bool flag = false;
     try
     {
         SqlParameter[] SqlParameters = new SqlParameter[18];
         SqlParameters[0] = new SqlParameter("@ID", (object)mail.ID);
         SqlParameters[0].Direction = ParameterDirection.Output;
         SqlParameters[1] = new SqlParameter("@Annex1", mail.Annex1 == null ? (object)"" : (object)mail.Annex1);
         SqlParameters[2] = new SqlParameter("@Annex2", mail.Annex2 == null ? (object)"" : (object)mail.Annex2);
         SqlParameters[3] = new SqlParameter("@Content", mail.Content == null ? (object)"" : (object)mail.Content);
         SqlParameters[4] = new SqlParameter("@Gold", (object)mail.Gold);
         SqlParameters[5] = new SqlParameter("@IsExist", (object)true);
         SqlParameters[6] = new SqlParameter("@Money", (object)mail.Money);
         SqlParameters[7] = new SqlParameter("@Receiver", mail.Receiver == null ? (object)"" : (object)mail.Receiver);
         SqlParameters[8] = new SqlParameter("@ReceiverID", (object)mail.ReceiverID);
         SqlParameters[9] = new SqlParameter("@Sender", mail.Sender == null ? (object)"" : (object)mail.Sender);
         SqlParameters[10] = new SqlParameter("@SenderID", (object)mail.SenderID);
         SqlParameters[11] = new SqlParameter("@Title", mail.Title == null ? (object)"" : (object)mail.Title);
         SqlParameters[12] = new SqlParameter("@IfDelS", (object)false);
         SqlParameters[13] = new SqlParameter("@IsDelete", (object)false);
         SqlParameters[14] = new SqlParameter("@IsDelR", (object)false);
         SqlParameters[15] = new SqlParameter("@IsRead", (object)false);
         SqlParameters[16] = new SqlParameter("@SendTime", (object)DateTime.Now);
         SqlParameters[17] = new SqlParameter("@Result", SqlDbType.Int);
         SqlParameters[17].Direction = ParameterDirection.ReturnValue;
         flag = this.db.RunProcedure("SP_Admin_SendUserMoney", SqlParameters);
         returnValue = (int)SqlParameters[17].Value;
         flag = returnValue == 0;
     }
     catch (Exception ex)
     {
         if (BaseBussiness.log.IsErrorEnabled)
             BaseBussiness.log.Error((object)"Init", ex);
     }
     return flag;
 }
        public bool HandleCommand(TankHotSpringLogicProcessor process, GamePlayer player, GSPacketIn packet)
        {
            if (player.CurrentHotSpringRoom == null /*|| player.CurrentHotSpringRoom.RoomState != eRoomState.FREE*/)
            {
                return false;
            }

            //if (player.PlayerCharacter.ID == player.CurrentHotSpringRoom.Info.GroomID || player.PlayerCharacter.ID == player.CurrentHotSpringRoom.Info.BrideID)
            //{
            //    return false;
            //}

            int num = packet.ReadInt();

            if (num > 0)
            {
                if (player.PlayerCharacter.Money >= num)
                {
                    //player.SetMoney(-num, MoneyAddType.Marry);
                    player.RemoveMoney(num);
                    LogMgr.LogMoneyAdd(LogMoneyType.Marry, LogMoneyType.Marry_Gift, player.PlayerCharacter.ID, num, player.PlayerCharacter.Money, 0, 0, 0, "", "", "");
                }
                else
                {
                    player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserFirecrackersCommand.MoneyNotEnough"));
                    return false;
                }


                using (PlayerBussiness pb = new PlayerBussiness())
                {
                    string content = LanguageMgr.GetTranslation("LargessCommand.Content",player.PlayerCharacter.NickName,num / 2);
                    string title = LanguageMgr.GetTranslation("LargessCommand.Title",player.PlayerCharacter.NickName);

                    MailInfo mail1 = new MailInfo();
                    mail1.Annex1 = "";
                    mail1.Content = content;
                    mail1.Gold = 0;
                    mail1.IsExist = true;
                    mail1.Money = num / 2;
                    mail1.Receiver = player.CurrentHotSpringRoom.Info.BrideName;
                    mail1.ReceiverID = player.CurrentHotSpringRoom.Info.BrideID;
                    mail1.Sender = LanguageMgr.GetTranslation("LargessCommand.Sender");
                    mail1.SenderID = 0;
                    mail1.Title = title;
                    mail1.Type = (int)eMailType.Marry;
                    pb.SendMail(mail1);

                    player.Out.SendMailResponse(mail1.ReceiverID, eMailRespose.Receiver);

                    MailInfo mail2 = new MailInfo();
                    mail2.Annex1 = "";
                    mail2.Content = content;
                    mail2.Gold = 0;
                    mail2.IsExist = true;
                    mail2.Money = num / 2;
                    mail2.Receiver = player.CurrentHotSpringRoom.Info.GroomName;
                    mail2.ReceiverID = player.CurrentHotSpringRoom.Info.GroomID;
                    mail2.Sender = LanguageMgr.GetTranslation("LargessCommand.Sender");
                    mail2.SenderID = 0;
                    mail2.Title = title;
                    mail2.Type = (int)eMailType.Marry;
                    pb.SendMail(mail2);

                    player.Out.SendMailResponse(mail2.ReceiverID, eMailRespose.Receiver);
                }

                player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("LargessCommand.Succeed"));
                GSPacketIn msg = player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("LargessCommand.Notice", player.PlayerCharacter.NickName, num));
                player.CurrentHotSpringRoom.SendToPlayerExceptSelf(msg,player);

                return true;
            }
      
            return false;
        }
        public bool SendItemsToMail(List<ItemInfo> items, MailInfo mail,PlayerBussiness pb)
        {
            if (mail == null)   return false;
            if (items.Count > 5) return false;

            if (m_saveToDb)
            {
                List<ItemInfo> sent = new List<ItemInfo>();
                StringBuilder annexRemark = new StringBuilder();
                annexRemark.Append(LanguageMgr.GetTranslation("Game.Server.GameUtils.CommonBag.AnnexRemark"));
                
                if (items.Count > 0 && TakeOutItem(items[0]))
                {
                    ItemInfo it = items[0];

                    mail.Annex1 = it.ItemID.ToString();
                    mail.Annex1Name = it.Template.Name;
                    annexRemark.Append("1、" + mail.Annex1Name + "x" + it.Count + ";");
                    sent.Add(it);
                }

                if (items.Count > 1 && TakeOutItem(items[1]))
                {
                    ItemInfo it = items[1];

                    mail.Annex2 = it.ItemID.ToString();
                    mail.Annex2Name = it.Template.Name;
                    annexRemark.Append("2、" + mail.Annex2Name + "x" + it.Count + ";");
                    sent.Add(it);
                }


                 if (items.Count > 2 && TakeOutItem(items[2]))
                {
                    ItemInfo it = items[2];

                    mail.Annex3 = it.ItemID.ToString();
                    mail.Annex3Name = it.Template.Name;
                    annexRemark.Append("3、" + mail.Annex3Name + "x" + it.Count + ";");
                     sent.Add(it);
                }

                if (items.Count > 3 && TakeOutItem(items[3]))
                {
                    ItemInfo it = items[3];

                    mail.Annex4 = it.ItemID.ToString();
                    mail.Annex4Name = it.Template.Name;
                    annexRemark.Append("4、" + mail.Annex4Name + "x" + it.Count + ";");
                    sent.Add(it);
                }

                if (items.Count > 4 && TakeOutItem(items[4]))
                {
                    ItemInfo it = items[4];

                    mail.Annex5 = it.ItemID.ToString();
                    mail.Annex5Name = it.Template.Name;
                    annexRemark.Append("5、" + mail.Annex5Name + "x" + it.Count + ";");
                    sent.Add(it);
                }

                mail.AnnexRemark = annexRemark.ToString();

                if (pb.SendMail(mail))
                {
                    return true;
                }
                else
                {
                    foreach (ItemInfo it in sent)
                    {
                        AddItem(it);
                    }
                }
            }
            return false;
 
        }
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            int bagType = packet.ReadByte();
            int place = packet.ReadInt();

            PlayerInventory arkBag = client.Player.GetInventory((eBageType)bagType);
            ItemInfo goods = arkBag.GetItemAt(place);
            string full = "";

            List<ItemInfo> infos = new List<ItemInfo>();
            if (goods != null && goods.IsValidItem() &&
                goods.Template.CategoryID == 11 &&
                goods.Template.Property1 == 6 &&
                client.Player.PlayerCharacter.Grade >= goods.Template.NeedLevel)
            {
                int money = 0;
                int gold = 0;
                int giftToken = 0;
                int medal = 0;
                int[] bags = new int[3];
                OpenUpItem(goods.Template.Data, bags, infos, ref gold, ref money,ref giftToken, ref medal);
                bags[goods.GetBagType()]--;

                if (client.Player.RemoveTemplate(goods.TemplateID, 1)) //trminhpc
                {
                    //格式如:你获得了 数量 点券,数量 金币,武器/装备/美容,数量 道具
                     StringBuilder notice = new StringBuilder();
                    int index = 0;
                    StringBuilder msg = new StringBuilder();
                    msg.Append(LanguageMgr.GetTranslation("OpenUpArkHandler.Start"));

                    if (money != 0)
                    {
                        msg.Append(money + LanguageMgr.GetTranslation("OpenUpArkHandler.Money"));
                        client.Player.AddMoney(money);
                        LogMgr.LogMoneyAdd(LogMoneyType.Box, LogMoneyType.Box_Open, client.Player.PlayerCharacter.ID, money, client.Player.PlayerCharacter.Money, gold, 0, 0,0, "", "", "");//添加日志
                    }
                    if (gold != 0)
                    {
                        msg.Append(gold + LanguageMgr.GetTranslation("OpenUpArkHandler.Gold"));
                        client.Player.AddGold(gold);
                    }
                    if (giftToken != 0)
                    {
                        msg.Append(giftToken + LanguageMgr.GetTranslation("OpenUpArkHandler.GiftToken"));
                        client.Player.AddGiftToken(giftToken);
                    }
                    if (medal != 0) //trminhpc
                    {
                        msg.Append(medal + LanguageMgr.GetTranslation("OpenUpArkHandler.Medal"));
                        client.Player.AddMedal(medal);
                    }
                    StringBuilder msga = new StringBuilder();
                    foreach (ItemInfo info in infos)
                    {
                        //IBag bag = client.Player.GetBag(info.GetBagType());
                        //bag.AddItem(info);
                        //msg.Append((info.GetBagType() == 0 ? "" : info.Count.ToString()) + " " + info.Template.Name + ",");

                        msga.Append(info.Template.Name + "x" + info.Count.ToString() + ",");

                        if ((info.Template.Quality >= goods.Template.Property2) & (goods.Template.Property2 != 0))
                        {
                            notice.Append(info.Template.Name + ",");
                            index++;

                        }
                        //msg.Append(info.Template.Name + "x" + info.Count.ToString() + ",");
                        if (!client.Player.AddTemplate(info, info.Template.BagType, info.Count))
                        {
                            using (PlayerBussiness db = new PlayerBussiness())
                            {
                                info.UserID = 0;
                                db.AddGoods(info);

                                MailInfo message = new MailInfo();
                                message.Annex1 = info.ItemID.ToString();
                                message.Content = LanguageMgr.GetTranslation("OpenUpArkHandler.Content1") + info.Template.Name + LanguageMgr.GetTranslation("OpenUpArkHandler.Content2");
                                message.Gold = 0;
                                message.Money = 0;
                                message.Receiver = client.Player.PlayerCharacter.NickName;
                                message.ReceiverID = client.Player.PlayerCharacter.ID;
                                message.Sender = message.Receiver;
                                message.SenderID = message.ReceiverID;
                                message.Title = LanguageMgr.GetTranslation("OpenUpArkHandler.Title") + info.Template.Name + "]";
                                message.Type = (int)eMailType.OpenUpArk;
                                db.SendMail(message);
                                full = LanguageMgr.GetTranslation("OpenUpArkHandler.Mail");
                            }
                        }
                    }
                    if (msga.Length > 0)
                    {
                        msga.Remove(msga.Length - 1, 1);
                        string[] msgstr = msga.ToString().Split(',');
                        for (int i = 0; i < msgstr.Length; i++)
                        {
                            int counts = 1;  //统计重复数量

                            //先统计重复数量
                            for (int j = i + 1; j < msgstr.Length; j++)
                            {
                                //重复,则更变字符串;
                                if (msgstr[i].Contains(msgstr[j]) && msgstr[j].Length == msgstr[i].Length)
                                {
                                    counts++;
                                    msgstr[j] = j.ToString();
                                }
                            }

                            //重复数字入串
                            if (counts > 1)
                            {
                                msgstr[i] = msgstr[i].Remove(msgstr[i].Length - 1, 1);
                                msgstr[i] = msgstr[i] + counts.ToString();
                            }

                            //判断是否留字符串
                            if (msgstr[i] != i.ToString())
                            {
                                msgstr[i] = msgstr[i] + ",";
                                msg.Append(msgstr[i]);
                            }

                        }
                    }
                    if (goods.Template.Property2 != 0 & index > 0)
                    {
                        string msg1 = LanguageMgr.GetTranslation("OpenUpArkHandler.Notice", client.Player.PlayerCharacter.NickName, goods.Template.Name, notice, notice.Remove(notice.Length - 1, 1));

                        //client.Out.SendSystemNotice(msg);

                        GSPacketIn pkg1 = new GSPacketIn((byte)ePackageType.SYS_NOTICE);
                        pkg1.WriteInt(2);
                        pkg1.WriteString(msg1);

                        GameServer.Instance.LoginServer.SendPacket(pkg1);

                        GamePlayer[] players = Game.Server.Managers.WorldMgr.GetAllPlayers();

                        foreach (GamePlayer p in players)
                        {
                            if (p != client.Player)
                                p.Out.SendTCP(pkg1);
                        }
                    }
                    msg.Remove(msg.Length - 1, 1);
                    msg.Append(".");
                    client.Out.SendMessage(eMessageType.Normal, full + msg.ToString());

                    if (!string.IsNullOrEmpty(full))
                    {
                        //GameServer.Instance.LoginServer.SendMailResponse(client.Player.PlayerCharacter.ID);
                        client.Out.SendMailResponse(client.Player.PlayerCharacter.ID, eMailRespose.Receiver);
                    }
                }
            }
            return 1;
        }
        /// <summary>
        /// 群发邮件
        /// </summary>
        public bool SendAllItemsToMail(string sender,string title,eMailType type)
        {
            if (m_saveToDb)
            {
                BeginChanges();
                try
                {
                    using (PlayerBussiness pb = new PlayerBussiness())
                    {
                        lock (m_lock)
                        {
                            List<ItemInfo> items = GetItems();

                            int count = items.Count;
                            for (int i = 0; i < count; i += 5)
                            {
                                MailInfo mail = new MailInfo();
                                mail.SenderID = 0;
                                mail.Sender = sender;
                                mail.ReceiverID = m_player.PlayerCharacter.ID;
                                mail.Receiver = m_player.PlayerCharacter.NickName;
                                mail.Title = title;
                                mail.Type = (int)type;
                                mail.Content = "";

                                List<ItemInfo> list = new List<ItemInfo>();
                                for(int j = 0; j < 5; j ++)
                                {
                                    int index = i * 5 + j;
                                    if(index < items.Count)
                                    {
                                        list.Add(items[index]);
                                    }
                                }
                                if (SendItemsToMail(list, mail, pb) == false)
                                {
                                    return false;
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Send Items Mail Error:" + ex);
                }
                finally
                {
                    SaveToDatabase();
                    CommitChanges();
                }
                m_player.Out.SendMailResponse(m_player.PlayerCharacter.ID, eMailRespose.Receiver);
            }
            return true;
        }
Exemple #26
0
 public static XElement CreateMailInfo(MailInfo info, string nodeName)
 {
     TimeSpan days = DateTime.Now.Subtract(info.SendTime);
     return new XElement(nodeName, new XAttribute("ID", info.ID),
         new XAttribute("Title", info.Title),
         new XAttribute("Content", info.Content),
         new XAttribute("Sender", info.Sender),
         new XAttribute("Receiver", info.Receiver),
         new XAttribute("SendTime", info.SendTime.ToString("yyyy-MM-dd HH:mm:ss")),
         //new XAttribute("Days", info.ValidDate - days.Hours),
         new XAttribute("ValidDate", info.ValidDate),
         new XAttribute("Gold", info.Gold),
         new XAttribute("Money", info.Money),
         new XAttribute("Annex1ID", info.Annex1 == null ? "" : info.Annex1),
         new XAttribute("Annex2ID", info.Annex2 == null ? "" : info.Annex2),
         new XAttribute("Annex3ID", info.Annex3 == null ? "" : info.Annex3),
         new XAttribute("Annex4ID", info.Annex4 == null ? "" : info.Annex4),
         new XAttribute("Annex5ID", info.Annex5 == null ? "" : info.Annex5),
         new XAttribute("Annex1Name", info.Annex1Name == null ? "" : info.Annex1Name),
         new XAttribute("Annex2Name", info.Annex2Name == null ? "" : info.Annex2Name),
         new XAttribute("Annex3Name", info.Annex3Name == null ? "" : info.Annex3Name),
         new XAttribute("Annex4Name", info.Annex4Name == null ? "" : info.Annex4Name),
         new XAttribute("Annex5Name", info.Annex5Name == null ? "" : info.Annex5Name),
         new XAttribute("AnnexRemark", info.AnnexRemark == null ? "" : info.AnnexRemark),
         new XAttribute("Type", info.Type),
         //new XAttribute("ValidDate", info.ValidDate),
         new XAttribute("IsRead", info.IsRead));
 }
 /// <summary>
 /// 发送物品到邮箱中
 /// </summary>
 /// <param name="item"></param>
 /// <param name="pb"></param>
 /// <returns></returns>
 public bool SendItemToMail(ItemInfo item, PlayerBussiness pb, MailInfo mail)
 {
     if (m_saveToDb && item.BagType == BagType)
     {
         if (mail == null)
         {
             mail = new MailInfo();
             mail.Annex1 = item.ItemID.ToString();
             mail.Content = LanguageMgr.GetTranslation("Game.Server.GameUtils.Title");
             mail.Gold = 0;
             mail.IsExist = true;
             mail.Money = 0;
             mail.Receiver = m_player.PlayerCharacter.NickName;
             mail.ReceiverID = item.UserID;
             mail.Sender = m_player.PlayerCharacter.NickName;
             mail.SenderID = item.UserID;
             mail.Title = LanguageMgr.GetTranslation("Game.Server.GameUtils.Title");
             mail.Type = (int)eMailType.ItemOverdue;
         }
         if (pb.SendMail(mail))
         {
             RemoveItem(item);
             item.IsExist = true;
             return true;
         }
         return false;
     }
     return false;
 }
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            int gold = 0;            //表示金币
            int money = 0;           //表示点券
            int offer = 0;           //表示功勋
            int gifttoken = 0;       //表示礼劵
            StringBuilder payGoods = new StringBuilder();                    //表示支付物品ID
            eMessageType eMsg = eMessageType.Normal;
            string msg = "GoodsPresentHandler.Success";

            string content = packet.ReadString();       //赠送人留言
            string nickName = packet.ReadString();      //购买人昵称
            List<int> needitemsinfo = new List<int>();  //存放兑换物品的templateID,Count

            if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked"));
                return 0;
            }

            using (PlayerBussiness db = new PlayerBussiness())
            {
                PlayerInfo receiver = db.GetUserSingleByNickName(nickName);
                if (receiver != null)
                {
                    List<ItemInfo> items = new List<ItemInfo>();
                    StringBuilder types = new StringBuilder();

                    int count = packet.ReadInt();
                    for (int i = 0; i < count; i++)
                    {
                        int GoodsID = packet.ReadInt();         //序号
                        int type = packet.ReadInt();       //购买方式
                        string color = packet.ReadString();//颜色
                        string skin = packet.ReadString(); //皮肤

                        ShopItemInfo shopItem = Bussiness.Managers.ShopMgr.GetShopItemInfoById(GoodsID);                   //获取商品信息

                        if (shopItem == null)                                                                              //商品不存在
                        {
                            continue;
                        }

                        ItemTemplateInfo goods = Bussiness.Managers.ItemMgr.FindItemTemplate(shopItem.TemplateID);              //查找物品属性
                        ItemInfo item = ItemInfo.CreateFromTemplate(goods, 1, (int)ItemAddType.Gift);                           //构建物品临时属性

                        if (item == null)
                            continue;

                        //未开始
                        //if (shopitem.AValue1 <= 0 || shopitem.Beat <= 0)
                        //    continue;

                        item.Color = color == null ? "" : color;
                        item.Skin = skin == null ? "" : skin;

                        if (item == null)
                            continue;

                        types.Append(type);
                        types.Append(",");
                        items.Add(item);

                        needitemsinfo = ItemInfo.SetItemType(shopItem, type, ref gold, ref money, ref offer, ref gifttoken);
                    }

                    if (items.Count == 0)
                        return 1;

                    //////////////////////////////////////////////////////////////////////////////////////
                    //玩家背包中是否有兑换物品所需要的物品
                    int icount = client.Player.MainBag.GetItems().Count;       //获取个数
                    bool result = true;
                    for (int j = 0; j < needitemsinfo.Count; j += 2)
                    {
                        if (client.Player.GetItemCount(needitemsinfo[j]) < needitemsinfo[j + 1])
                        {
                            result = false;
                        }
                    }

                    if (!result)
                    {
                        eMsg = eMessageType.ERROR;
                        msg = "UserBuyItemHandler.NoBuyItem";
                        return 1;
                    }
                    /////////////////////////////////////////////////////////////

                    if (gold <= client.Player.PlayerCharacter.Gold && money <= client.Player.PlayerCharacter.Money && offer <= client.Player.PlayerCharacter.Offer && gifttoken <= client.Player.PlayerCharacter.GiftToken)
                    {

                        types.Remove(types.Length - 1, 1);
                        client.Player.RemoveMoney(money);
                        client.Player.RemoveGold(gold);
                        client.Player.RemoveOffer(offer);
                        client.Player.RemoveGiftToken(gifttoken);
                        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        //从玩家背包中删除兑换所需要的物品
                        for (int j = 0; j < needitemsinfo.Count; j += 2)
                        {
                            client.Player.RemoveTemplate(needitemsinfo[j], needitemsinfo[j + 1]);
                            payGoods.Append(needitemsinfo[j].ToString() + ":");
                        }
                        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                        string itemIDs = "";
                        int annexIndex = 0;
                        MailInfo message = new MailInfo();
                        StringBuilder annexRemark = new StringBuilder();
                        annexRemark.Append(LanguageMgr.GetTranslation("GoodsPresentHandler.AnnexRemark"));

                        foreach (ItemInfo item in items)
                        {
                            itemIDs += (itemIDs == "" ? item.TemplateID.ToString() : "," + item.TemplateID.ToString());
                            item.UserID = 0;
                            db.AddGoods(item);

                            annexIndex++;
                            annexRemark.Append(annexIndex);
                            annexRemark.Append("、");
                            annexRemark.Append(item.Template.Name);
                            annexRemark.Append("x");
                            annexRemark.Append(item.Count);
                            annexRemark.Append(";");

                            switch (annexIndex)
                            {
                                case 1:
                                    message.Annex1 = item.ItemID.ToString();
                                    message.Annex1Name = item.Template.Name;
                                    break;
                                case 2:
                                    message.Annex2 = item.ItemID.ToString();
                                    message.Annex2Name = item.Template.Name;
                                    break;
                                case 3:
                                    message.Annex3 = item.ItemID.ToString();
                                    message.Annex3Name = item.Template.Name;
                                    break;
                                case 4:
                                    message.Annex4 = item.ItemID.ToString();
                                    message.Annex4Name = item.Template.Name;
                                    break;
                                case 5:
                                    message.Annex5 = item.ItemID.ToString();
                                    message.Annex5Name = item.Template.Name;
                                    break;
                            }

                            if (annexIndex == 5)
                            {
                                annexIndex = 0;
                                message.AnnexRemark = annexRemark.ToString();
                                annexRemark.Remove(0, annexRemark.Length);
                                annexRemark.Append(LanguageMgr.GetTranslation("GoodsPresentHandler.AnnexRemark"));
                                message.Content = content;
                                message.Gold = 0;
                                message.Money = 0;
                                message.Receiver = receiver.NickName;
                                message.ReceiverID = receiver.ID;
                                message.Sender = client.Player.PlayerCharacter.NickName;
                                message.SenderID = client.Player.PlayerCharacter.ID;
                                message.Title = message.Sender + LanguageMgr.GetTranslation("GoodsPresentHandler.Content") + message.Annex1Name + "]";
                                message.Type = (int)eMailType.PresentItem;
                                db.SendMail(message);

                                message.Revert();
                            }
                        }

                        if (annexIndex > 0)
                        {
                            message.AnnexRemark = annexRemark.ToString();
                            message.Content = content;
                            message.Gold = 0;
                            message.Money = 0;
                            message.Receiver = receiver.NickName;
                            message.ReceiverID = receiver.ID;
                            message.Sender = client.Player.PlayerCharacter.NickName;
                            message.SenderID = client.Player.PlayerCharacter.ID;
                            message.Title = message.Sender + LanguageMgr.GetTranslation("GoodsPresentHandler.Content") + message.Annex1Name + "]";
                            message.Type = (int)eMailType.PresentItem;
                            db.SendMail(message);
                        }
                        LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_Present, client.Player.PlayerCharacter.ID, money, client.Player.PlayerCharacter.Money, gold, gifttoken, offer, payGoods.ToString(), itemIDs, types.ToString());
                        client.Out.SendMailResponse(receiver.ID, eMailRespose.Receiver);
                        client.Out.SendMailResponse(client.Player.PlayerCharacter.ID, eMailRespose.Send);
                    }
                    else
                    {
                        eMsg = eMessageType.ERROR;
                        msg = "GoodsPresentHandler.NoMoney";
                    }
                }
                else
                {
                    eMsg = eMessageType.ERROR;
                    msg = "GoodsPresentHandler.NoUser";
                }
            }
            client.Out.SendMessage(eMsg, LanguageMgr.GetTranslation(msg));
            return 0;
        }