Пример #1
0
 protected void btnReceive_OnClick(object sender, EventArgs e)
 {
     try
     {
         var s        = txtRecordId.Text.Trim();
         var recordId = ConvertHelper.ConvertToInt(s);
         if (recordId <= 0)
         {
             Master.ShowMessage("序号必须大于0.");
             return;
         }
         var mail = MailInfoMgr.GetById(recordId, Master.ZoneId);
         if (!mail.HasAttach)
         {
             Master.ShowMessage("该邮件没有附件.");
             return;
         }
         var code = WebServerHandler.AttachmentReceive(Master.ZoneId, mail.ManagerId, mail.Idx);
         if (code == 0)
         {
             Master.ShowMessage("收取成功");
         }
         else
         {
             Master.ShowMessage("收取失败:" + code);
         }
     }
     catch (Exception ex)
     {
         LogHelper.Insert(ex);
         Master.ShowMessage("出错了:" + ex.Message);
     }
 }
Пример #2
0
 public MailAttachmentReceiveResponse AttachmentReceive(Guid managerId, int recordId)
 {
     if (recordId == -1)
     {
         var mailList = MailInfoMgr.GetForAttachmentBatch(managerId);
         return(AttachmentReceive(mailList));
     }
     else
     {
         var mail = MailInfoMgr.GetById(recordId);
         if (mail == null || mail.ManagerId != managerId)
         {
             return(ResponseHelper.InvalidParameter <MailAttachmentReceiveResponse>());
         }
         if (!ShareUtil.CheckBytes(mail.Attachment))
         {
             return(ResponseHelper.Create <MailAttachmentReceiveResponse>(MessageCode.MailNoAttachment));
         }
         if (mail.HasAttach == false)
         {
             return(ResponseHelper.Create <MailAttachmentReceiveResponse>(MessageCode.MailAttachmentReceiveRepeat));
         }
         var mailList = new List <MailInfoEntity>(1);
         mailList.Add(mail);
         return(AttachmentReceive(mailList));
     }
 }
Пример #3
0
 /// <summary>
 /// 发奖
 /// </summary>
 private void GiveReward(string zoneId)
 {
     try
     {
         List <GambleRankEntity> list = GambleRankMgr.GetRank(10, zoneId);
         for (int i = 0, count = list.Count; i < count; i++)
         {
             if (list[i].Status == 1)
             {
                 continue;//已经发过奖了
             }
             //TODO=======邮件发送奖励
             int cardLib = 0;
             int rank    = list[i].RankIndex;
             if (rank == 1)
             {
                 cardLib = 9;
             }
             else if (rank == 2)
             {
                 cardLib = 8;
             }
             else if (rank >= 3 && rank <= 10)
             {
                 cardLib = 10;
             }
             if (cardLib > 0)
             {
                 var itemCode = CacheFactory.LotteryCache.LotteryByLib(cardLib);
                 if (itemCode > 0)
                 {
                     MailInfoEntity mailInfo = new MailInfoEntity();
                     mailInfo.MailType       = (int)EnumMailType.AdminSend;
                     mailInfo.ManagerId      = list[i].ManagerId;
                     mailInfo.IsRead         = false;
                     mailInfo.Status         = 0;
                     mailInfo.RowTime        = DateTime.Now;
                     mailInfo.ExpiredTime    = MailCore.Instance.GetExpiredTime(true, DateTime.Now);
                     mailInfo.ContentString  = "竞猜排名奖励|恭喜你竞猜盈利排名第" + rank + ",获得奖励,请查收附件.";
                     mailInfo.MailAttachment = new MailAttachmentEntity();
                     mailInfo.MailAttachment.AddAttachment(1, itemCode, false, 0);
                     mailInfo.Attachment = SerializationHelper.ToByte(mailInfo.MailAttachment);
                     mailInfo.HasAttach  = true;
                     MailInfoMgr.Insert(mailInfo, null, zoneId);
                 }
             }
             //======已经发奖,改变status标记==============
             list[i].Status = 1;
             GambleRankMgr.Update(list[i], null, zoneId);
         }
     }
     catch (Exception ex)
     {
         SystemlogMgr.Error("GambleCore.GiveReward", ex);
     }
 }
Пример #4
0
 public MessageCodeResponse Read(Guid managerId, int recordId)
 {
     if (MailInfoMgr.Read(managerId, recordId))
     {
         return(ResponseHelper.CreateSuccess <MessageCodeResponse>());
     }
     else
     {
         return(ResponseHelper.InvalidParameter <MessageCodeResponse>());
     }
 }
Пример #5
0
        public bool HasUnReadMail(Guid managerId)
        {
            int totalCount = 0;
            var list       = MailInfoMgr.GetByManager(managerId, ref totalCount);

            if (list == null)
            {
                return(false);
            }
            return(list.Any(mailInfoEntity => !mailInfoEntity.IsRead));
        }
Пример #6
0
 public MessageCode ClearExpired()
 {
     try
     {
         MailInfoMgr.ClearExpired(DateTime.Now);
         return(MessageCode.Success);
     }
     catch (Exception ex)
     {
         SystemlogMgr.Error("Mail-ClearExpired", ex);
         return(MessageCode.Exception);
     }
 }
Пример #7
0
        public MailDataResponse DeleteMail(Guid managerId, string recordIds)
        {
            int returnCode = -2;

            MailInfoMgr.Delete(managerId, recordIds, ref returnCode);
            if (returnCode == ShareUtil.SuccessCode)
            {
                return(GetMailData(managerId));
            }
            else
            {
                return(ResponseHelper.Create <MailDataResponse>(returnCode));
            }
        }
Пример #8
0
        public bool Save(string zoneId, DbTransaction transaction = null)
        {
            if (_mail == null)
            {
                return(true);
            }
            if (_mail.MailAttachment == null)
            {
                _mail.Attachment = new byte[0];
                _mail.HasAttach  = false;
            }
            else
            {
                _mail.Attachment = SerializationHelper.ToByte(_mail.MailAttachment);
                _mail.HasAttach  = true;
            }
            _mail.ExpiredTime = MailCore.Instance.GetExpiredTime(_mail.HasAttach, _mail.RowTime);
            var result = MailInfoMgr.Insert(_mail, transaction, zoneId);

            return(result);
        }
Пример #9
0
        public MailDataResponse GetMailData(Guid managerId)
        {
            int totalCount = 0;
            var response   = ResponseHelper.CreateSuccess <MailDataResponse>();

            response.Data = new MailDataEntity();
            var list = MailInfoMgr.GetByManager(managerId, ref totalCount);

            if (list != null && list.Count > 0)
            {
                foreach (var entity in list)
                {
                    entity.MailTick        = ShareUtil.GetTimeTick(entity.RowTime);
                    entity.MailExpiredTick = ShareUtil.GetTimeTick(entity.ExpiredTime);
                    entity.MailAttachment  = SerializationHelper.FromByte <MailAttachmentEntity>(entity.Attachment);
                }
            }
            response.Data.Mails      = list;
            response.Data.TotalCount = totalCount;
            return(response);
        }
Пример #10
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            try
            {
                var users = txtUserList.Text;
                if (string.IsNullOrEmpty(users))
                {
                    ShowMessage("请选择用户");
                    return;
                }
                var title = txtMailTitle.Text;
                if (string.IsNullOrEmpty(title))
                {
                    ShowMessage("请输入标题");
                    return;
                }
                var content = txtMailContent.Text;
                if (string.IsNullOrEmpty(content))
                {
                    ShowMessage("请输入内容");
                    return;
                }
                List <LocalMailManagerCorssEntity> managers = new List <LocalMailManagerCorssEntity>();
                var ss = users.Split('|');
                foreach (var s in ss)
                {
                    var sss     = s.Split(',');
                    var manager = NbManagerMgr.GetByAccount(sss[1], sss[0]);
                    if (manager == null || manager.Count < 1)
                    {
                        ShowMessage("未找到对应经理,账号:" + s);
                        return;
                    }
                    managers.Add(new LocalMailManagerCorssEntity()
                    {
                        ManagerId = manager[0].Idx, ZoneId = sss[0], Account = sss[1]
                    });
                }

                MailBuilder mail        = new MailBuilder(title, content);
                var         attachments = GetAttachments();
                if (attachments.Count > 0)
                {
                    foreach (var entity in attachments)
                    {
                        switch (entity.Type)
                        {
                        case 1:
                            mail.AddAttachment(EnumCurrencyType.Coin, entity.Count);
                            break;

                        case 2:
                            mail.AddAttachment(EnumCurrencyType.Point, entity.Count);
                            break;

                        case 3:
                            mail.AddAttachment(entity.Count, entity.ItemCode, entity.IsBinding, entity.Strength);
                            break;

                        case 4:    //声望
                            mail.AddAttachment(EnumCurrencyType.Prestige, entity.Count);
                            break;

                        case 8:    //绑劵
                            mail.AddAttachment(EnumCurrencyType.BindPoint, entity.Count);
                            break;
                        }
                    }
                }
                var    mailInfo = mail.MailInfo;
                string failList = "";
                foreach (var entity in managers)
                {
                    try
                    {
                        var mailEntity = mailInfo.Clone();
                        mailEntity.ManagerId = entity.ManagerId;
                        MailInfoMgr.Insert(mailEntity, null, entity.ZoneId);
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Insert(ex);
                        failList = string.Format("{0}{1},{2}|", failList, entity.ZoneId, entity.Account);
                    }
                }
                if (!string.IsNullOrEmpty(failList))
                {
                    ShowMessage("部分发送失败,列表:" + failList.TrimEnd('|'));
                }
                else
                {
                    ShowMessage("发送成功");
                }

                datagrid1.DataSource = null;
                datagrid1.DataBind();
                LocalAttachment = null;
            }
            catch (Exception ex)
            {
                LogHelper.Insert(ex);
                ShowMessage("发送失败:" + ex.Message);
            }
        }
Пример #11
0
 protected void btnSendMail_Click(object sender, EventArgs e)
 {
     try
     {
         string notSendString = "";
         string sendString    = txt_SendString.Text;
         string mailName      = txt_MailName.Text;
         string info          = txt_mailInfo.Text;
         if (sendString.Trim().Length == 0 || mailName.Trim().Length <= 0 || info.Trim().Length <= 0)
         {
             ShowMessage("请输入串");
             return;
         }
         var malls = sendString.Split('|');
         List <LocalMailManagerCorssEntity> managers = new List <LocalMailManagerCorssEntity>();
         foreach (var s in malls)
         {
             var sss     = s.Split(',');
             var manager = NbManagerMgr.GetByAccount(sss[1], sss[0]);
             if (manager == null || manager.Count < 1)
             {
                 ShowMessage("未找到对应经理,账号:" + s);
                 return;
             }
             managers.Add(new LocalMailManagerCorssEntity()
             {
                 ManagerId = manager[0].Idx, ZoneId = sss[0], Account = sss[1], Point = ConvertHelper.ConvertToInt(sss[2])
             });
         }
         MailBuilder mail = null;
         foreach (var item in managers)
         {
             try
             {
                 if (item.Point <= 0)
                 {
                     continue;
                 }
                 mail = new MailBuilder(mailName, info);
                 //mail = new MailBuilder(item.ManagerId, mailName);
                 mail.AddAttachment(EnumCurrencyType.Point, item.Point);
                 var mailInfo   = mail.MailInfo;
                 var mailEntity = mailInfo.Clone();
                 mailEntity.ManagerId = item.ManagerId;
                 if (!MailInfoMgr.Insert(mailEntity, null, item.ZoneId))
                 {
                     notSendString += item.ZoneId + "," + item.Account + "," + item.Point + "|";
                     LogHelper.Insert(item.ZoneId + "," + item.Account + "," + item.Point + "-----失败",
                                      LogType.Info);
                 }
                 else
                 {
                     LogHelper.Insert(item.ZoneId + "," + item.Account + "," + item.Point + "-----成功",
                                      LogType.Info);
                 }
             }
             catch (Exception ex)
             {
                 notSendString += item.ZoneId + "," + item.Account + "," + item.Point + "|";
                 LogHelper.Insert(item.ZoneId + "," + item.Account + "," + item.Point + "-----失败",
                                  LogType.Info);
             }
         }
         if (notSendString.Trim().Length > 0)
         {
             ShowMessage("未成功发送的串:" + notSendString);
         }
         else
         {
             ShowMessage("发送成功");
         }
     }
     catch (Exception ex)
     {
         LogHelper.Insert(ex);
         ShowMessage("发送失败:" + ex.Message);
     }
 }
Пример #12
0
        MessageCode Tran_SaveAttachment(DbTransaction transaction, List <MailInfoEntity> mails, ItemPackageFrame package, NbManagerEntity manager, int coin, int sophicate, int point, int prestige, int bindPoint, int addGoldBar, Guid managerId, int addluckyCoin, int addGameCoin)
        {
            var orderId = mails[0].Idx.ToString();

            foreach (var mail in mails)
            {
                if (!MailInfoMgr.Update(mail, transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            if (package != null)
            {
                if (!package.Save(transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }

            if (coin > 0)
            {
                var code = ManagerCore.Instance.AddCoin(manager, coin, EnumCoinChargeSourceType.MailAttachment, orderId, transaction);
                if (code != MessageCode.Success)
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            if (sophicate > 0)
            {
                int resultSophisticate = manager.Sophisticate;
                if (!NbManagerMgr.AddSophisticate(manager.Idx, sophicate, ref resultSophisticate, transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            if (point > 0)
            {
                var code = PayCore.Instance.AddBonus(manager.Account, point, EnumChargeSourceType.MailAttachment,
                                                     orderId, transaction);
                if (code != MessageCode.Success)
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            if (bindPoint > 0)
            {
                var payUser = PayUserMgr.GetById(manager.Account);
                if (payUser == null)
                {
                    payUser           = new PayUserEntity();
                    payUser.Account   = manager.Account;
                    payUser.BindPoint = bindPoint;
                    payUser.RowTime   = DateTime.Now;
                    payUser.IsNew     = true;
                }
                else
                {
                    payUser.BindPoint += bindPoint;
                }
                if (payUser.IsNew)
                {
                    if (!PayUserMgr.Insert(payUser, transaction))
                    {
                        return(MessageCode.NbUpdateFail);
                    }
                }
                else
                {
                    if (!PayUserMgr.Update(payUser, transaction))
                    {
                        return(MessageCode.NbUpdateFail);
                    }
                }
            }
            if (addGoldBar > 0)
            {
                var goldBarManager = ScoutingGoldbarMgr.GetById(managerId);
                if (goldBarManager == null)
                {
                    goldBarManager = new ScoutingGoldbarEntity(managerId, addGoldBar, 0, 0, 0, DateTime.Now,
                                                               DateTime.Now);
                    if (!ScoutingGoldbarMgr.Insert(goldBarManager, transaction))
                    {
                        return(MessageCode.NbUpdateFail);
                    }
                }
                else
                {
                    goldBarManager.GoldBarNumber = goldBarManager.GoldBarNumber + addGoldBar;
                    if (!ScoutingGoldbarMgr.Update(goldBarManager, transaction))
                    {
                        return(MessageCode.NbUpdateFail);
                    }
                }
                GoldbarRecordEntity record = new GoldbarRecordEntity(0, managerId, true, addGoldBar, (int)EnumCoinChargeSourceType.MailAttachment, DateTime.Now);
                GoldbarRecordMgr.Insert(record);
            }
            if (addluckyCoin > 0)
            {
                if (!TurntableManagerMgr.AddLuckyCoin(managerId, addluckyCoin, transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }
            if (addGameCoin > 0)
            {
                if (!PenaltykickManagerMgr.AddGameCurrency(managerId, addGameCoin, transaction))
                {
                    return(MessageCode.NbUpdateFail);
                }
            }

            return(MessageCode.Success);
        }