Exemplo n.º 1
0
        protected void btnLadderPrize_Click(object sender, EventArgs e)
        {
            try
            {
                var zone      = AdminMgr.GetSelectZoneId(HttpContext.Current, ddlZone);
                var curSeason = ConvertHelper.ConvertToInt(txtLadderSeason.Text);
                if (curSeason <= 0)
                {
                    ShowMessage("天梯赛季不能小于1");
                    return;
                }
                ShowMessage("天梯发奖开始...");
                var managers = LadderManagerhistoryMgr.GetPrizeManager(curSeason, zone);
                if (managers != null)
                {
                    List <MailBuilder> mails = new List <MailBuilder>(managers.Count);
                    foreach (var manager in managers)
                    {
                        LadderThread.Instance.SendPrize(manager, 0, ref mails);
                    }

                    var mailDataTable = MailCore.BuildMailBulkTable(mails);
                    LadderSqlHelper.SaveManagerPrize(managers, mailDataTable, zone);
                }
                ShowMessage("天梯发奖成功。");
            }
            catch (Exception ex)
            {
                LogHelper.Insert(ex);
                ShowMessage("local exception:" + ex.Message);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 合区所需的提前发放天梯赛奖励
        /// </summary>
        /// <returns></returns>
        public MessageCode ScoreToHonorJobMergeZone()
        {
            var season = CacheFactory.SeasonCache.GetCurrentSeason();

            if (season == null)
            {
                return(MessageCode.LadderNoSeason);
            }

            var curDate = DateTime.Today;

            if (season.Idx == 1 && curDate == season.Startdate)
            {
                return(MessageCode.LadderSeasonDonotNeedSend);
            }
            int isNewSeason = 1;
            int curSeason   = season.Idx;

            if (season.Startdate == curDate && season.Idx > 1)
            {
                isNewSeason = 1;
                curSeason   = curSeason - 1;
            }
            LadderInfoMgr.ScoreToHonorMergeZone(DateTime.Today, curSeason);
            if (isNewSeason == 1)
            {
                try
                {
                    var curSeasonEntity = CacheFactory.SeasonCache.GetEntity(curSeason);
                    var managers        = LadderManagerhistoryMgr.GetPrizeManager(curSeason);
                    if (managers != null)
                    {
                        List <MailBuilder> mails = new List <MailBuilder>(managers.Count);
                        foreach (var manager in managers)
                        {
                            SendPrize(manager, curSeasonEntity.Status, ref mails);
                            if (manager.Rank < 3)
                            {
                                NbManagerhonorMgr.Add(manager.ManagerId, (int)EnumMatchType.Ladder, 0, manager.Season,
                                                      manager.Rank);
                            }
                        }

                        var mailDataTable = MailCore.BuildMailBulkTable(mails);
                        LadderSqlHelper.SaveManagerPrize(managers, mailDataTable);
                    }
                }
                catch (Exception ex)
                {
                    SystemlogMgr.Error("ScoreToHonorJob SendPrize", ex);
                    return(MessageCode.Exception);
                }
            }
            return(MessageCode.Success);
        }
Exemplo n.º 3
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            try
            {
                var zoneId = ZoneId;
                if (string.IsNullOrEmpty(zoneId))
                {
                    ShowMessage("请选择区");
                    return;
                }
                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 <NbManagerEntity> managers = new List <NbManagerEntity>();
                var ss = users.Split(',');
                foreach (var s in ss)
                {
                    var manager = NbManagerMgr.GetByAccount(s, zoneId);
                    if (manager == null || manager.Count < 1)
                    {
                        ShowMessage("未找到对应经理,账号:" + s);
                        return;
                    }
                    managers.Add(manager[0]);
                }
                var mailType    = ConvertHelper.ConvertToInt(dr_type.SelectedValue);
                var attachments = GetAttachments();
                if (mailType == 1)
                {
                    MailBuilder mail = new MailBuilder(title, content);

                    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;
                            }
                        }
                    }
                    List <MailInfoEntity> mailList = new List <MailInfoEntity>(managers.Count);
                    var mailInfo = mail.MailInfo;
                    foreach (var entity in managers)
                    {
                        var mailEntity = mailInfo.Clone();
                        mailEntity.ManagerId = entity.Idx;
                        mailList.Add(mailEntity);
                    }
                    var mailTable = MailCore.BuildMailBulkTable(mailList);
                    if (MailSqlHelper.SaveMailBulk(mailTable,
                                                   ConnectionFactory.Instance.GetConnectionString(zoneId, "Main")))
                    {
                        ShowMessage("发送成功");
                        datagrid1.DataSource = null;
                        datagrid1.DataBind();
                        LocalAttachment = null;
                    }
                    else
                    {
                        ShowMessage("发送失败");
                    }
                }
                else if (mailType == 2)
                {
                    //{
                    //    MailShareBuilder mail = new MailShareBuilder(title, content);

                    //    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;
                    //            }
                    //        }
                    //    }
                    //    MailshareInfoEntity mailList = new MailshareInfoEntity();
                    //    var mailInfo = mail.MailInfo;
                    //    if (managers.Count > 1)
                    //    {
                    //        ShowMessage("只支持单个发送");
                    //        return;
                    //    }
                    //    foreach (var entity in managers)
                    //    {
                    //        var mailEntity = mailInfo.Clone();
                    //        mailEntity.Account = entity.Account;
                    //    }

                    //    if (mail.Save(zoneId))
                    //    {
                    //        ShowMessage("发送成功");
                    //        datagrid1.DataSource = null;
                    //        datagrid1.DataBind();
                    //        LocalAttachment = null;
                    //    }
                    //    else
                    //    {
                    //        ShowMessage("发送失败");
                    //    }
                    //}

                    ShowMessage("请选择邮件类型");
                }
            }
            catch (Exception ex)
            {
                LogHelper.Insert(ex);
                ShowMessage("发送失败:" + ex.Message);
            }
        }