Ejemplo n.º 1
0
 public static string GetRedirectUrl(int publishmentSystemId, ELotteryType lotteryType)
 {
     return(PageUtils.GetWeiXinUrl(nameof(PageLottery), new NameValueCollection
     {
         { "publishmentSystemId", publishmentSystemId.ToString() },
         { "lotteryType", ELotteryTypeUtils.GetValue(lotteryType) }
     }));
 }
Ejemplo n.º 2
0
        public static string GetEndImageUrl(PublishmentSystemInfo publishmentSystemInfo, ELotteryType lotteryType, string endImageUrl)
        {
            if (!string.IsNullOrEmpty(endImageUrl))
            {
                return(PageUtils.AddProtocolToUrl(PageUtility.ParseNavigationUrl(publishmentSystemInfo, endImageUrl)));
            }
            var directoryName = "img" + ELotteryTypeUtils.GetValue(lotteryType);

            return(PageUtils.AddProtocolToUrl(SiteFilesAssets.GetUrl(publishmentSystemInfo.Additional.ApiUrl, $"weixin/lottery/{directoryName}/end.jpg")));
        }
Ejemplo n.º 3
0
        public static string GetOpenWindowStringByLottery(int publishmentSystemID, ELotteryType lotteryType, int lotteryID)
        {
            var arguments = new NameValueCollection();

            arguments.Add("publishmentSystemID", publishmentSystemID.ToString());
            arguments.Add("lotteryType", ELotteryTypeUtils.GetValue(lotteryType));
            arguments.Add("lotteryID", lotteryID.ToString());

            return(JsUtils.OpenWindow.GetOpenWindowString("导出CSV", "modal_export.aspx", arguments, 400, 240, true));
        }
Ejemplo n.º 4
0
 public static string GetOpenWindowStringByLottery(int publishmentSystemId, ELotteryType lotteryType, int lotteryId)
 {
     return(PageUtils.GetOpenWindowString("导出CSV",
                                          PageUtils.GetWeiXinUrl(nameof(ModalExport), new NameValueCollection
     {
         { "publishmentSystemId", publishmentSystemId.ToString() },
         { "lotteryType", ELotteryTypeUtils.GetValue(lotteryType) },
         { "lotteryId", lotteryId.ToString() }
     }), 400, 240, true));
 }
Ejemplo n.º 5
0
 public static string GetRedirectUrl(int publishmentSystemId, ELotteryType lotteryType, int lotteryId, int awardId, string returnUrl)
 {
     return(PageUtils.GetWeiXinUrl(nameof(PageLotteryWinner), new NameValueCollection
     {
         { "publishmentSystemId", publishmentSystemId.ToString() },
         { "lotteryType", ELotteryTypeUtils.GetValue(lotteryType) },
         { "lotteryId", lotteryId.ToString() },
         { "awardId", awardId.ToString() },
         { "returnUrl", StringUtils.ValueToUrl(returnUrl) }
     }));
 }
Ejemplo n.º 6
0
        public static string GetContentAwardImageUrl(PublishmentSystemInfo publishmentSystemInfo, ELotteryType lotteryType, string contentImageUrl, int awardCount)
        {
            if (!string.IsNullOrEmpty(contentImageUrl))
            {
                return(PageUtils.AddProtocolToUrl(PageUtility.ParseNavigationUrl(publishmentSystemInfo, contentImageUrl)));
            }
            var fileName = awardCount + ".png";

            if (awardCount < 2 || awardCount > 9)
            {
                fileName = "contentAward.png";
            }
            var directoryName = "img" + ELotteryTypeUtils.GetValue(lotteryType);

            return(PageUtils.AddProtocolToUrl(SiteFilesAssets.GetUrl(publishmentSystemInfo.Additional.ApiUrl, $"weixin/lottery/{directoryName}/{fileName}")));
        }
Ejemplo n.º 7
0
        public int GetTotalNum(int publishmentSystemID, ELotteryType lotteryType, int lotteryID)
        {
            string sqlString =
                $"SELECT COUNT(*) FROM {TABLE_NAME} WHERE {LotteryWinnerAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryWinnerAttribute.LotteryType} = '{ELotteryTypeUtils.GetValue(lotteryType)}'";

            if (lotteryID > 0)
            {
                sqlString =
                    $"SELECT COUNT(*) FROM {TABLE_NAME} WHERE {LotteryWinnerAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryWinnerAttribute.LotteryID} = {lotteryID}";
            }

            return(BaiRongDataProvider.DatabaseDao.GetIntResult(sqlString));
        }
Ejemplo n.º 8
0
        public List <LotteryWinnerInfo> GetWinnerInfoList(int publishmentSystemID, ELotteryType lotteryType, int lotteryID)
        {
            var winnerInfoList = new List <LotteryWinnerInfo>();

            string SQL_WHERE =
                $"WHERE {LotteryWinnerAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryWinnerAttribute.LotteryType} = '{ELotteryTypeUtils.GetValue(lotteryType)}'";

            if (lotteryID > 0)
            {
                SQL_WHERE =
                    $"WHERE {LotteryWinnerAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryWinnerAttribute.LotteryID} = {lotteryID}";
            }

            var SQL_SELECT = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TABLE_NAME, 0, SqlUtils.Asterisk, SQL_WHERE, "ORDER BY ID DESC");

            using (var rdr = ExecuteReader(SQL_SELECT))
            {
                while (rdr.Read())
                {
                    var winnerInfo = new LotteryWinnerInfo(rdr);
                    winnerInfoList.Add(winnerInfo);
                }
                rdr.Close();
            }

            return(winnerInfoList);
        }
Ejemplo n.º 9
0
        public List <LotteryWinnerInfo> GetWinnerInfoList(int publishmentSystemId, ELotteryType lotteryType, int lotteryId)
        {
            var winnerInfoList = new List <LotteryWinnerInfo>();

            string sqlWhere =
                $"WHERE {LotteryWinnerAttribute.PublishmentSystemId} = {publishmentSystemId} AND {LotteryWinnerAttribute.LotteryType} = '{ELotteryTypeUtils.GetValue(lotteryType)}'";

            if (lotteryId > 0)
            {
                sqlWhere =
                    $"WHERE {LotteryWinnerAttribute.PublishmentSystemId} = {publishmentSystemId} AND {LotteryWinnerAttribute.LotteryId} = {lotteryId}";
            }

            var sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TableName, 0, SqlUtils.Asterisk, sqlWhere, "ORDER BY ID DESC");

            using (var rdr = ExecuteReader(sqlSelect))
            {
                while (rdr.Read())
                {
                    var winnerInfo = new LotteryWinnerInfo(rdr);
                    winnerInfoList.Add(winnerInfo);
                }
                rdr.Close();
            }

            return(winnerInfoList);
        }
Ejemplo n.º 10
0
        public List <int> GetLotteryIDList(int publishmentSystemID, ELotteryType lotteryType)
        {
            var lotteryIDList = new List <int>();

            string SQL_WHERE =
                $"WHERE {LotteryAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryAttribute.LotteryType} = '{ELotteryTypeUtils.GetValue(lotteryType)}'";
            var SQL_SELECT = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TABLE_NAME, 0, LotteryAttribute.ID, SQL_WHERE, null);

            using (var rdr = ExecuteReader(SQL_SELECT))
            {
                while (rdr.Read())
                {
                    lotteryIDList.Add(rdr.GetInt32(0));
                }
                rdr.Close();
            }

            return(lotteryIDList);
        }
Ejemplo n.º 11
0
        public string GetSelectString(int publishmentSystemID, ELotteryType lotteryType)
        {
            string whereString =
                $"WHERE {LotteryAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryAttribute.LotteryType} = '{ELotteryTypeUtils.GetValue(lotteryType)}'";

            return(BaiRongDataProvider.TableStructureDao.GetSelectSqlString(TABLE_NAME, SqlUtils.Asterisk, whereString));
        }
Ejemplo n.º 12
0
        public int GetFirstIDByKeywordID(int publishmentSystemID, ELotteryType lotteryType, int keywordID)
        {
            string sqlString =
                $"SELECT TOP 1 ID FROM {TABLE_NAME} WHERE {LotteryAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryAttribute.LotteryType} = '{ELotteryTypeUtils.GetValue(lotteryType)}' AND {LotteryAttribute.IsDisabled} <> '{true}' AND {LotteryAttribute.KeywordID} = {keywordID}";

            return(BaiRongDataProvider.DatabaseDao.GetIntResult(sqlString));
        }
Ejemplo n.º 13
0
        public List <int> GetLotteryIdList(int publishmentSystemId, ELotteryType lotteryType)
        {
            var lotteryIdList = new List <int>();

            string sqlWhere =
                $"WHERE {LotteryAttribute.PublishmentSystemId} = {publishmentSystemId} AND {LotteryAttribute.LotteryType} = '{ELotteryTypeUtils.GetValue(lotteryType)}'";
            var sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TableName, 0, LotteryAttribute.Id, sqlWhere, null);

            using (var rdr = ExecuteReader(sqlSelect))
            {
                while (rdr.Read())
                {
                    lotteryIdList.Add(rdr.GetInt32(0));
                }
                rdr.Close();
            }

            return(lotteryIdList);
        }
Ejemplo n.º 14
0
        public List <LotteryInfo> GetLotteryInfoListByKeywordId(int publishmentSystemId, ELotteryType lotteryType, int keywordId)
        {
            var lotteryInfoList = new List <LotteryInfo>();

            string sqlWhere =
                $"WHERE {LotteryAttribute.PublishmentSystemId} = {publishmentSystemId} AND {LotteryAttribute.LotteryType} = '{ELotteryTypeUtils.GetValue(lotteryType)}' AND {LotteryAttribute.IsDisabled} <> '{true}'";

            if (keywordId > 0)
            {
                sqlWhere += $" AND {LotteryAttribute.KeywordId} = {keywordId}";
            }
            var sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TableName, 0, SqlUtils.Asterisk, sqlWhere, null);

            using (var rdr = ExecuteReader(sqlSelect))
            {
                while (rdr.Read())
                {
                    var lotteryInfo = new LotteryInfo(rdr);
                    lotteryInfoList.Add(lotteryInfo);
                }
                rdr.Close();
            }

            return(lotteryInfoList);
        }
Ejemplo n.º 15
0
 public static string GetRedirectUrl(int publishmentSystemID, ELotteryType lotteryType, int lotteryID, int awardID, string returnUrl)
 {
     return(PageUtils.GetWXUrl(
                $"background_lotteryWinner.aspx?publishmentSystemID={publishmentSystemID}&lotteryType={ELotteryTypeUtils.GetValue(lotteryType)}&lotteryID={lotteryID}&awardID={awardID}&returnUrl={StringUtils.ValueToUrl(returnUrl)}"));
 }
Ejemplo n.º 16
0
 public static string GetRedirectUrl(int publishmentSystemID, ELotteryType lotteryType)
 {
     return(PageUtils.GetWXUrl(
                $"background_lottery.aspx?PublishmentSystemID={publishmentSystemID}&lotteryType={ELotteryTypeUtils.GetValue(lotteryType)}"));
 }
Ejemplo n.º 17
0
        public string GetSelectString(int publishmentSystemID, ELotteryType lotteryType, int lotteryID, int awardID)
        {
            string whereString =
                $"WHERE {LotteryWinnerAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryWinnerAttribute.LotteryType} = '{ELotteryTypeUtils.GetValue(lotteryType)}'";

            if (lotteryID > 0)
            {
                whereString =
                    $"WHERE {LotteryWinnerAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryWinnerAttribute.LotteryID} = {lotteryID}";
            }
            if (awardID > 0)
            {
                whereString = $" AND {LotteryWinnerAttribute.AwardID} = {awardID}";
            }
            return(BaiRongDataProvider.TableStructureDao.GetSelectSqlString(TABLE_NAME, SqlUtils.Asterisk, whereString));
        }
Ejemplo n.º 18
0
        public List <LotteryInfo> GetLotteryInfoListByKeywordID(int publishmentSystemID, ELotteryType lotteryType, int keywordID)
        {
            var lotteryInfoList = new List <LotteryInfo>();

            string SQL_WHERE =
                $"WHERE {LotteryAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryAttribute.LotteryType} = '{ELotteryTypeUtils.GetValue(lotteryType)}' AND {LotteryAttribute.IsDisabled} <> '{true}'";

            if (keywordID > 0)
            {
                SQL_WHERE += $" AND {LotteryAttribute.KeywordID} = {keywordID}";
            }
            var SQL_SELECT = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TABLE_NAME, 0, SqlUtils.Asterisk, SQL_WHERE, null);

            using (var rdr = ExecuteReader(SQL_SELECT))
            {
                while (rdr.Read())
                {
                    var lotteryInfo = new LotteryInfo(rdr);
                    lotteryInfoList.Add(lotteryInfo);
                }
                rdr.Close();
            }

            return(lotteryInfoList);
        }
Ejemplo n.º 19
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                var selectedStep = 0;
                if (phStep1.Visible)
                {
                    selectedStep = 1;
                }
                else if (phStep2.Visible)
                {
                    selectedStep = 2;
                }
                else if (phStep3.Visible)
                {
                    selectedStep = 3;
                }
                else if (phStep4.Visible)
                {
                    selectedStep = 4;
                }
                else if (phStep5.Visible)
                {
                    selectedStep = 5;
                }

                phStep1.Visible = phStep2.Visible = phStep3.Visible = phStep4.Visible = phStep5.Visible = false;

                if (selectedStep == 1)
                {
                    var isConflict       = false;
                    var conflictKeywords = string.Empty;
                    if (!string.IsNullOrEmpty(tbKeywords.Text))
                    {
                        if (lotteryID > 0)
                        {
                            var lotteryInfo = DataProviderWX.LotteryDAO.GetLotteryInfo(lotteryID);
                            isConflict = KeywordManager.IsKeywordUpdateConflict(PublishmentSystemID, lotteryInfo.KeywordID, PageUtils.FilterXSS(tbKeywords.Text), out conflictKeywords);
                        }
                        else
                        {
                            isConflict = KeywordManager.IsKeywordInsertConflict(PublishmentSystemID, PageUtils.FilterXSS(tbKeywords.Text), out conflictKeywords);
                        }
                    }

                    if (isConflict)
                    {
                        FailMessage($"触发关键词“{conflictKeywords}”已存在,请设置其他关键词");
                        phStep1.Visible = true;
                    }
                    else
                    {
                        phStep2.Visible = true;
                    }
                }
                else if (selectedStep == 2)
                {
                    phStep3.Visible = true;
                }
                else if (selectedStep == 3)
                {
                    var isItemReady = true;

                    var awardMaxCount      = TranslateUtils.ToInt(tbAwardMaxCount.Text);
                    var awardMaxDailyCount = TranslateUtils.ToInt(tbAwardMaxDailyCount.Text);
                    if (awardMaxDailyCount > awardMaxCount)
                    {
                        FailMessage("摇摇乐保存失败,每人每天最多允许抽奖次数必须小于每人最多抽奖次数");
                        isItemReady = false;
                    }

                    if (isItemReady)
                    {
                        var itemCount = TranslateUtils.ToInt(Request.Form["itemCount"]);

                        if (itemCount < 1)
                        {
                            FailMessage("摇摇乐保存失败,至少需要设置一个奖项");
                            isItemReady = false;
                        }
                        else
                        {
                            var itemIDList      = TranslateUtils.StringCollectionToIntList(Request.Form["itemID"]);
                            var awardNameList   = TranslateUtils.StringCollectionToStringList(Request.Form["itemAwardName"]);
                            var titleList       = TranslateUtils.StringCollectionToStringList(Request.Form["itemTitle"]);
                            var totalNumList    = TranslateUtils.StringCollectionToIntList(Request.Form["itemTotalNum"]);
                            var probabilityList = TranslateUtils.StringCollectionToDecimalList(Request.Form["itemProbability"]);

                            decimal probabilityAll = 0;

                            var awardInfoList = new List <LotteryAwardInfo>();
                            for (var i = 0; i < itemCount; i++)
                            {
                                var awardInfo = new LotteryAwardInfo {
                                    ID = itemIDList[i], PublishmentSystemID = PublishmentSystemID, LotteryID = lotteryID, AwardName = awardNameList[i], Title = titleList[i], TotalNum = totalNumList[i], Probability = probabilityList[i]
                                };

                                if (string.IsNullOrEmpty(awardInfo.AwardName))
                                {
                                    FailMessage("保存失败,奖项名称为必填项");
                                    isItemReady = false;
                                }
                                if (string.IsNullOrEmpty(awardInfo.Title))
                                {
                                    FailMessage("保存失败,奖品名为必填项");
                                    isItemReady = false;
                                }
                                if (awardInfo.Probability < 0 || awardInfo.Probability > 100)
                                {
                                    FailMessage("保存失败,各项中奖概率总和不能超过100%");
                                    isItemReady = false;
                                }

                                probabilityAll += awardInfo.Probability;

                                awardInfoList.Add(awardInfo);
                            }

                            if (probabilityAll <= 0 || probabilityAll > 100)
                            {
                                FailMessage("摇摇乐保存失败,获奖概率之和必须在1%到100%之间");
                                isItemReady = false;
                            }

                            if (isItemReady)
                            {
                                DataProviderWX.LotteryAwardDAO.DeleteAllNotInIDList(PublishmentSystemID, lotteryID, itemIDList);

                                foreach (var awardInfo in awardInfoList)
                                {
                                    var newAwardInfo = DataProviderWX.LotteryAwardDAO.GetAwardInfo(awardInfo.ID);
                                    if (awardInfo.ID > 0)
                                    {
                                        var wonNum = DataProviderWX.LotteryWinnerDAO.GetTotalNum(awardInfo.ID);
                                        if (awardInfo.TotalNum < wonNum)
                                        {
                                            awardInfo.TotalNum = wonNum;
                                        }
                                        awardInfo.WonNum = newAwardInfo.WonNum;
                                        DataProviderWX.LotteryAwardDAO.Update(awardInfo);
                                    }
                                    else
                                    {
                                        DataProviderWX.LotteryAwardDAO.Insert(awardInfo);
                                    }
                                }
                            }
                        }
                    }

                    if (isItemReady)
                    {
                        phStep4.Visible = true;
                    }
                    else
                    {
                        phStep3.Visible = true;
                    }
                }
                else if (selectedStep == 4)
                {
                    phStep5.Visible = true;
                    btnSubmit.Text  = "确 认";
                }
                else if (selectedStep == 5)
                {
                    var lotteryInfo = new LotteryInfo();
                    if (lotteryID > 0)
                    {
                        lotteryInfo = DataProviderWX.LotteryDAO.GetLotteryInfo(lotteryID);
                    }
                    lotteryInfo.PublishmentSystemID = PublishmentSystemID;
                    lotteryInfo.LotteryType         = ELotteryTypeUtils.GetValue(ELotteryType.YaoYao);

                    lotteryInfo.KeywordID  = DataProviderWX.KeywordDAO.GetKeywordID(PublishmentSystemID, lotteryID > 0, tbKeywords.Text, EKeywordType.YaoYao, lotteryInfo.KeywordID);
                    lotteryInfo.IsDisabled = !cbIsEnabled.Checked;

                    lotteryInfo.StartDate       = dtbStartDate.DateTime;
                    lotteryInfo.EndDate         = dtbEndDate.DateTime;
                    lotteryInfo.Title           = PageUtils.FilterXSS(tbTitle.Text);
                    lotteryInfo.ImageUrl        = imageUrl.Value;;
                    lotteryInfo.Summary         = tbSummary.Text;
                    lotteryInfo.ContentImageUrl = contentImageUrl.Value;
                    lotteryInfo.ContentUsage    = tbContentUsage.Text;

                    lotteryInfo.AwardUsage         = tbAwardUsage.Text;
                    lotteryInfo.IsAwardTotalNum    = cbIsAwardTotalNum.Checked;
                    lotteryInfo.AwardMaxCount      = TranslateUtils.ToInt(tbAwardMaxCount.Text);
                    lotteryInfo.AwardMaxDailyCount = TranslateUtils.ToInt(tbAwardMaxDailyCount.Text);
                    lotteryInfo.AwardCode          = tbAwardCode.Text;
                    lotteryInfo.AwardImageUrl      = awardImageUrl.Value;

                    lotteryInfo.IsFormRealName    = cbIsFormRealName.Checked;
                    lotteryInfo.FormRealNameTitle = tbFormRealNameTitle.Text;
                    lotteryInfo.IsFormMobile      = cbIsFormMobile.Checked;
                    lotteryInfo.FormMobileTitle   = tbFormMobileTitle.Text;
                    lotteryInfo.IsFormEmail       = cbIsFormEmail.Checked;
                    lotteryInfo.FormEmailTitle    = tbFormEmailTitle.Text;
                    lotteryInfo.IsFormAddress     = cbIsFormAddress.Checked;
                    lotteryInfo.FormAddressTitle  = tbFormAddressTitle.Text;

                    lotteryInfo.EndTitle    = tbEndTitle.Text;
                    lotteryInfo.EndImageUrl = endImageUrl.Value;
                    lotteryInfo.EndSummary  = tbEndSummary.Text;

                    try
                    {
                        if (lotteryID > 0)
                        {
                            DataProviderWX.LotteryDAO.Update(lotteryInfo);

                            LogUtils.AddLog(BaiRongDataProvider.AdministratorDao.UserName, "修改摇摇乐",
                                            $"摇摇乐:{tbTitle.Text}");
                            SuccessMessage("修改摇摇乐成功!");
                        }
                        else
                        {
                            lotteryID = DataProviderWX.LotteryDAO.Insert(lotteryInfo);

                            DataProviderWX.LotteryAwardDAO.UpdateLotteryID(PublishmentSystemID, lotteryID);

                            LogUtils.AddLog(BaiRongDataProvider.AdministratorDao.UserName, "添加摇摇乐",
                                            $"摇摇乐:{tbTitle.Text}");
                            SuccessMessage("添加摇摇乐成功!");
                        }

                        var redirectUrl = BackgroundLottery.GetRedirectUrl(PublishmentSystemID, ELotteryType.YaoYao);
                        AddWaitAndRedirectScript(redirectUrl);
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "摇摇乐设置失败!");
                    }
                }
            }
        }
Ejemplo n.º 20
0
        private static string GetLotteryUrl(PublishmentSystemInfo publishmentSystemInfo, LotteryInfo lotteryInfo)
        {
            var fileName = ELotteryTypeUtils.GetValue(ELotteryTypeUtils.GetEnumType(lotteryInfo.LotteryType)).ToLower();

            return(PageUtils.AddProtocolToUrl(SiteFilesAssets.GetUrl(publishmentSystemInfo.Additional.ApiUrl, $"weixin/lottery/{fileName}.html")));
        }