Exemple #1
0
        private void SetDefault()
        {
            EnumPushType enumPushType = (EnumPushType)this.rblPushType.SelectedValue.ToInt(0);

            this.lblPushType.Text                  = $"<em>*</em>{((Enum)(object)enumPushType).ToDescription()}:";
            this.txtURL.Style["display"]           = "none";
            this.rblActivity.Style["display"]      = "none";
            this.lblShow.Style["display"]          = "none";
            this.btnSelectTopic.Style["display"]   = "none";
            this.btnSelectProduct.Style["display"] = "none";
            switch (enumPushType)
            {
            case EnumPushType.Activity:
                this.rblActivity.Style["display"] = "block";
                break;

            case EnumPushType.Link:
                this.txtURL.Style["display"] = "block";
                break;

            case EnumPushType.ProductTopic:
                this.lblShow.Style["display"]        = "block";
                this.btnSelectTopic.Style["display"] = "block";
                break;

            case EnumPushType.Product:
                this.lblShow.Style["display"]          = "block";
                this.btnSelectProduct.Style["display"] = "block";
                break;
            }
        }
Exemple #2
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            lock (ManualPush.objLock)
            {
                string text  = this.txtURL.Text.Trim();
                string str   = string.Empty;
                string text2 = this.txtPushContent.Text.Trim();
                string text3 = this.txtPushTitle.Text.Trim();
                string value = this.hidUserIds.Value;
                if (string.IsNullOrEmpty(value))
                {
                    this.ShowMsg("请选择要推送消息的会员", false);
                }
                else if (string.IsNullOrEmpty(text3))
                {
                    this.ShowMsg("请填写推送标题", false);
                }
                else if (string.IsNullOrEmpty(text2))
                {
                    this.ShowMsg("请填写推送内容", false);
                }
                else
                {
                    EnumPushType enumPushType = (EnumPushType)this.rblPushType.SelectedValue.ToInt(0);
                    switch (enumPushType)
                    {
                    case EnumPushType.Link:
                        if (string.IsNullOrEmpty(text))
                        {
                            this.ShowMsg("请填写链接", false);
                            return;
                        }
                        if (!Regex.IsMatch(text, "(http|ftp|https):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%&amp;:/~\\+#]*[\\w\\-\\@?^=%&amp;/~\\+#])?"))
                        {
                            this.ShowMsg("请输入正确的链接,比如 https://www.huz.com.cn", false);
                            return;
                        }
                        str = string.Format("url{1}{0}{2}", this.txtURL.Text.Trim(), VShopHelper.SEPARATORCONTEXT, VShopHelper.SEPARATOREVERY);
                        break;

                    case EnumPushType.ProductTopic:
                        if (string.IsNullOrEmpty(this.topicId))
                        {
                            this.ShowMsg("请选择专题", false);
                            return;
                        }
                        str = string.Format("url{1}{0}{2}", Globals.HostPath(HttpContext.Current.Request.Url) + "/appshop/Topics?TopicId=" + this.topicId, VShopHelper.SEPARATORCONTEXT, VShopHelper.SEPARATOREVERY);
                        break;

                    case EnumPushType.Activity:
                        switch (this.rblActivity.SelectedValue.ToInt(0))
                        {
                        case 2:
                            str = string.Format("url{1}{0}{2}", Globals.HostPath(HttpContext.Current.Request.Url) + "/appshop/CountDownProducts.aspx", VShopHelper.SEPARATORCONTEXT, VShopHelper.SEPARATOREVERY);
                            break;

                        case 1:
                            str = string.Format("url{1}{0}{2}", Globals.HostPath(HttpContext.Current.Request.Url) + "/appshop/GroupBuyList.aspx", VShopHelper.SEPARATORCONTEXT, VShopHelper.SEPARATOREVERY);
                            break;
                        }
                        break;

                    case EnumPushType.Product:
                        if (string.IsNullOrEmpty(this.productId))
                        {
                            this.ShowMsg("请选择商品", false);
                            return;
                        }
                        str = string.Format("productid{1}{0}{2}", this.productId, VShopHelper.SEPARATORCONTEXT, VShopHelper.SEPARATOREVERY);
                        break;
                    }
                    DateTime now  = DateTime.Now;
                    int      num  = 14;
                    int      num2 = 20;
                    if (text3.Length > num)
                    {
                        this.ShowMsg($"推送标题不能超过{num}", false);
                    }
                    else if (text2.Length > num2)
                    {
                        this.ShowMsg($"推送内容不能超过{num2}个字", false);
                    }
                    else
                    {
                        str += string.Format("type{1}{0}{2}", (int)enumPushType, VShopHelper.SEPARATORCONTEXT, VShopHelper.SEPARATOREVERY);
                        AppPushRecordInfo appPushRecordInfo = new AppPushRecordInfo
                        {
                            PushType     = (int)enumPushType,
                            PushContent  = text2,
                            PushTitle    = text3,
                            SendUserIds  = value,
                            PushStatus   = 1,
                            PushSendType = 1,
                            PushSendDate = now,
                            ToAll        = false,
                            Extras       = str
                        };
                        if (VShopHelper.CheckAppPushRecordDuplicate(appPushRecordInfo))
                        {
                            this.ShowMsg("不能在一小时内推送重复的信息", false);
                        }
                        else
                        {
                            VShopHelper.AppPushRecordSendAboutAtOnce(appPushRecordInfo);
                            if (appPushRecordInfo.PushStatus.Equals(EnumPushStatus.PushFailure))
                            {
                                this.ShowMsg("推送失败", false);
                            }
                            else
                            {
                                this.ShowMsg("推送成功", true);
                            }
                        }
                    }
                }
            }
        }