public string Process(RequestMsgModel msg)
        {
            SubscribeEventRequestMsgModel msgMode = msg as SubscribeEventRequestMsgModel;

            if (msgMode != null)
            {
                SiteActivityDAL dal      = new SiteActivityDAL();
                SiteActivity    activity = dal.GetSiteAct(Params["SiteCode"].ToString(), "Coupon");
                if (activity != null)
                {
                    CouponDAL cdal = new CouponDAL();
                    if (!cdal.ExistCoupon(Params["SiteCode"].ToString(), activity.ID, msgMode.FromUserName))
                    {
                        Coupon coupon = new Coupon()
                        {
                            SiteCode       = Params["SiteCode"].ToString(),
                            SiteActivityID = activity.ID,
                            OpenID         = msgMode.FromUserName,
                            CouponCode     = GetCouponCode(msgMode.FromUserName),
                            CouponStatus   = 0
                        };
                        cdal.InsertInfo(coupon);
                    }
                }
            }
            return(string.Empty);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (null != Common.Common.NoHtml(Request.QueryString["action"]))
            {
                strAction = Common.Common.NoHtml(Request.QueryString["action"]);
            }
            if (null != Common.Common.NoHtml(Request.QueryString["id"]))
            {
                strID = Common.Common.NoHtml(Request.QueryString["id"]);
            }

            SiteActivityDAL dal = new SiteActivityDAL();

            switch (strAction)
            {
            case "del":
                if (dal.UpdateActivityActStatus(strID, "0"))
                {
                    strMessage = "活动已失效!";
                }
                else
                {
                    strMessage = "操作失败!";
                }
                break;

            default:
                break;
            }
            Response.Write(strMessage);
            Response.End();
        }
        const string vsKey = "searchCriteria"; //ViewState key
        /// <summary>
        /// 页面加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ddlactlist.Items.Clear();
                SiteActivityDAL actDal = new SiteActivityDAL();
                DataSet         ds     = new DataSet();
                if (Session["strRoleCode"].ToString() == "ADMIN")
                {
                    ds = actDal.GetActivityListByState("");
                }
                else
                {
                    ds = actDal.GetActivityListByState("  AND SiteCode ='" + Session["strSiteCode"].ToString() + "' ");
                }
                DataTable dt = ds.Tables[0];

                DataRow dr = ds.Tables[0].NewRow();
                dr["ID"]       = "";
                dr["ActTitle"] = "--全部--";
                dt.Rows.InsertAt(dr, 0);
                ddlactlist.DataSource     = ds.Tables[0].DefaultView;
                ddlactlist.DataTextField  = "ActTitle";
                ddlactlist.DataValueField = "ID";
                ddlactlist.DataBind();
                AspNetPager1.CurrentPageIndex = 1;
                string s = "";
                if (Session["strRoleCode"].ToString() != "ADMIN")
                {
                    s = " AND b.SiteCode = '" + Session["strSiteCode"].ToString() + "' ";
                }
                ViewState[vsKey] = s;
                LoadData(s);
            }
        }
        /// <summary>
        /// 页面加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Session["strSiteCode"].ToString()) && Session["strRoleCode"].ToString() != "ADMIN")
            {
                Response.Write("<script language=JavaScript>parent.location.href='../Index.aspx';</script>");
                Response.End();
            }
            if (!IsPostBack)
            {
                #region 初始化界面

                ddlactlist.Items.Clear();
                SiteActivityDAL actDal = new SiteActivityDAL();
                DataSet         ds     = new DataSet();
                if (Session["strRoleCode"].ToString() == "ADMIN")
                {
                    ds = actDal.GetActivityListByState("");
                }
                else
                {
                    ds = actDal.GetActivityListByState("  AND SiteCode ='" + Session["strSiteCode"].ToString() + "' ");
                }
                DataTable dt = ds.Tables[0];

                DataRow dr = ds.Tables[0].NewRow();
                dr["ID"]       = "";
                dr["ActTitle"] = "--全部--";
                dt.Rows.InsertAt(dr, 0);
                ddlactlist.DataSource     = ds.Tables[0].DefaultView;
                ddlactlist.DataTextField  = "ActTitle";
                ddlactlist.DataValueField = "ID";
                ddlactlist.DataBind();

                awardsort.Items.Add(new ListItem("大转盘", "0"));
                awardsort.Items.Add(new ListItem("刮刮奖", "1"));

                if (null != Common.Common.NoHtml(Request.QueryString["action"]))
                {
                    strAction = Common.Common.NoHtml(Request.QueryString["action"]);
                }
                if (null != Common.Common.NoHtml(Request.QueryString["id"]))
                {
                    strID = Common.Common.NoHtml(Request.QueryString["id"]);
                }
                #endregion
            }
        }
Esempio n. 5
0
        protected override bool BeforeLoad()
        {
            if (null == Request.QueryString["id"])
            {
                return(false);
            }
            CouponID = Common.Common.NoHtml(Request.QueryString["id"].ToString());
            string strGuid = string.Empty;

            if (null != Request.QueryString["sitecode"] && null != Request.QueryString["openid"])
            {
                SiteCode = Common.Common.NoHtml(Request.QueryString["sitecode"].ToString());
                OpenID   = Common.Common.NoHtml(Request.QueryString["openid"].ToString());
                //插入优惠券
                SiteActivityDAL dalActive = new SiteActivityDAL();
                DataSet         dsActive  = dalActive.GetActivityDetail(CouponID);
                if (null != dsActive && dsActive.Tables.Count > 0 && dsActive.Tables[0].Rows.Count > 0)
                {
                    strGuid = Guid.NewGuid().ToString("N");
                    CouponDAL cdal = new CouponDAL();
                    if (!cdal.ExistCoupon(SiteCode, CouponID, OpenID))
                    {
                        Coupon coupon = new Coupon()
                        {
                            ID             = strGuid,
                            SiteCode       = SiteCode,
                            SiteActivityID = CouponID,
                            OpenID         = OpenID,
                            CouponStatus   = 0
                        };
                        cdal.InsertInfo(coupon);
                    }
                }
                CouponID = strGuid;
            }
            else
            {
                SiteActivityDAL dalActive = new SiteActivityDAL();
                DataSet         dsActive  = dalActive.GetActivityDetail(CouponID);
                if (null != dsActive && dsActive.Tables.Count > 0 && dsActive.Tables[0].Rows.Count > 0)
                {
                    SiteCode = dsActive.Tables[0].Rows[0]["SIteCode"].ToString();
                }
            }
            return(base.BeforeLoad());
        }
Esempio n. 6
0
        protected override void AddTempData(JinianNet.JNTemplate.TemplateContext context)
        {
            base.AddTempData(context);
            //取最新抢购的优惠活动
            List <Model.ACT.SiteActivity> liActive = new List <Model.ACT.SiteActivity>();

            DAL.ACT.SiteActivityDAL dalActive = new SiteActivityDAL();

            List <MyCouponInfo> liCoupon = new List <MyCouponInfo>();
            CouponDAL           dalCoup  = new CouponDAL();

            DataSet dsActive = dalActive.GetActivityList(" SiteCode = '" + SiteCode + "' AND ActStatus = 1 AND ActType = 'RushCoupon' AND StartTime < GETDATE() AND EndTime > GETDATE() ");

            if (null != dsActive && dsActive.Tables.Count > 0 && dsActive.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow row in dsActive.Tables[0].Rows)
                {
                    if (!dalCoup.ExistCoupon(SiteCode, row["ID"].ToString(), OpenID))
                    {
                        Model.ACT.SiteActivity modelActive = DataConvert.DataRowToModel <Model.ACT.SiteActivity>(row);
                        liActive.Add(modelActive);
                    }
                }
            }

            DataSet ds      = dalCoup.GetCouponInfoList(SiteCode, OpenID);
            string  strInfo = string.Empty;

            if (null != ds && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    MyCouponInfo model = DataConvert.DataRowToModel <MyCouponInfo>(row);
                    liCoupon.Add(model);
                }
            }
            else
            {
                strInfo = "亲,你还没有参加过活动哦,多多关注我们的新活动!";
            }
            context.TempData["openid"]          = OpenID;
            context.TempData["rushcoupon_list"] = liActive;
            context.TempData["coupon_list"]     = liCoupon;
            context.TempData["couponinfo"]      = strInfo;
        }
Esempio n. 7
0
        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="strWhere">条件</param>
        void LoadData(string strWhere)
        {
            txtTitle.Text = "";
            SiteActivityDAL dal = new SiteActivityDAL();
            DataSet         ds  = dal.GetAllActivity(strWhere);
            DataView        dv  = ds.Tables[0].DefaultView;

            AspNetPager1.RecordCount = dv.Count;

            PagedDataSource pds = new PagedDataSource();

            pds.DataSource       = dv;
            pds.AllowPaging      = true;
            pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
            pds.PageSize         = AspNetPager1.PageSize;
            Repeater1.DataSource = pds;
            Repeater1.DataBind();
        }
Esempio n. 8
0
        public void ShowActivityInfo(string strID)
        {
            SiteActivityDAL dal   = new SiteActivityDAL();
            DataSet         ds    = dal.GetActivityDetail(strID);
            SiteActivity    model = DataConvert.DataRowToModel <SiteActivity>(ds.Tables[0].Rows[0]);

            this.txtName.Text     = model.ActTitle;
            this.hd_content.Value = model.ActContent;
            this.txtSummary.Text  = model.Remark;
            starttime.Text        = model.StartTime;
            endtime.Text          = model.EndTime;
            cutTime.Text          = model.CutOffTime;
            Discount.Text         = model.DisCount;
            opentime.Text         = model.OpenTime;
            closetime.Text        = model.CloseTime;
            daylimit.Text         = model.DayLimit.ToString();
            if (model.ActStatus == 0)
            {
                ActStatusno.Checked = true;
            }
            else
            {
                ActStatusyes.Checked = true;
            }
            img0.Src = "../../" + model.Photo;
            if (strAction == "show")
            {
                this.btnReset.Visible = false;
                this.btnSave.Visible  = false;
                starttime.ReadOnly    = true;
                endtime.ReadOnly      = true;
                txtName.ReadOnly      = true;
                txtSummary.ReadOnly   = true;
            }
            else
            {
                starttime.Attributes.Add("onclick", "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})");
                endtime.Attributes.Add("onclick", "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})");
                cutTime.Attributes.Add("onclick", "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})");
                opentime.Attributes.Add("onclick", "WdatePicker({dateFmt:'HH:mm:ss'})");
                closetime.Attributes.Add("onclick", "WdatePicker({dateFmt:'HH:mm:ss'})");
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 处理回复消息
        /// "text":回复文本消息处理,MsgValue对应回复的文本
        /// "sub_auto_coupon":回复订阅自动优惠券处理,MsgValue对应回复的图文消息ID
        /// "auto_news_article":根据文章自动生成图文消息进行回复,MsgValue为类别ID
        /// "news":回复图文表中的消息,MsgValue为图文消息表ID集,用逗号分隔
        /// </summary>
        /// <param name="replyMsgType"></param>
        /// <param name="replyMsgValue"></param>
        /// <param name="customParams"></param>
        /// <returns></returns>
        private string ProcessReply(RequestMsgModel msgModel, string replyMsgType, string replyMsgValue)
        {
            string res = string.Empty;

            try
            {
                switch (replyMsgType.ToLower())
                {
                case "text":
                    //回复文本消息处理,MsgValue对应回复的文本
                    TextResponseMsgModel textMsg = new TextResponseMsgModel()
                    {
                        ToUserName   = msgModel.FromUserName,
                        FromUserName = msgModel.ToUserName,
                        CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString(),
                        Content      = replyMsgValue == null ? string.Empty : TransformText(replyMsgValue, msgModel)
                    };
                    res = textMsg.ToString();
                    break;

                case "voice":
                    //回复语音消息处理,MsgValue对应回复的文本
                    VoiceResponseMsgModel voiceMsg = new VoiceResponseMsgModel()
                    {
                        ToUserName   = msgModel.FromUserName,
                        FromUserName = msgModel.ToUserName,
                        CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString(),
                    };
                    Media media = MediaDAL.CreateInstance().GetMediaByID(replyMsgValue);
                    if (media != null && !string.IsNullOrEmpty(media.MediaID))
                    {
                        voiceMsg.MediaId = media.MediaID;
                    }
                    res = voiceMsg.ToString();
                    break;

                case "wxpay_test":
                    //用于微信支付测试
                    TextResponseMsgModel textMsgx = new TextResponseMsgModel()
                    {
                        ToUserName   = msgModel.FromUserName,
                        FromUserName = msgModel.ToUserName,
                        CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString(),
                        Content      = string.Format("<a href='{0}/Payment/wxpay/wxpayDemo.aspx?openid={1}'>微信支付测试</a>", GetSiteUrl(), msgModel.FromUserName)
                    };
                    res = textMsgx.ToString();
                    break;

                case "transfer_customer_service":
                    //将消息转发到多客服
                    TransferCustomerServiceResponseMsgModel transferMsg = new TransferCustomerServiceResponseMsgModel()
                    {
                        ToUserName   = msgModel.FromUserName,
                        FromUserName = msgModel.ToUserName,
                        CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString(),
                    };
                    res = transferMsg.ToString();
                    break;

                case "sub_auto_coupon":
                    //回复订阅自动优惠券处理,MsgValue对应回复的优惠券图文消息ID
                    //SubscribeCouponActHandle sch = new SubscribeCouponActHandle();
                    SiteActivityDAL dal      = new SiteActivityDAL();
                    SiteActivity    activity = dal.GetSiteAct(siteCode, "Coupon");
                    if (activity != null)
                    {
                        CouponDAL cdal = new CouponDAL();
                        if (!cdal.ExistCoupon(siteCode, activity.ID, msgModel.FromUserName))
                        {
                            Coupon coupon = new Coupon()
                            {
                                SiteCode       = siteCode,
                                SiteActivityID = activity.ID,
                                OpenID         = msgModel.FromUserName,
                                //CouponCode = msgModel.FromUserName,
                                CouponStatus = 0
                            };
                            cdal.InsertInfo(coupon);
                        }
                    }
                    CouponNewsDAL nmDAL = new CouponNewsDAL();
                    CouponNews    nm    = nmDAL.GetCouponNews(replyMsgValue);
                    if (nm != null)
                    {
                        NewsResponseMsgModel newsModel = new NewsResponseMsgModel()
                        {
                            ToUserName   = msgModel.FromUserName,
                            FromUserName = msgModel.ToUserName,
                            CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString()
                        };
                        List <Article> articles = new List <Article>();
                        articles.Add(new Article()
                        {
                            Title       = nm.Title,
                            Description = nm.Description,
                            PicUrl      = GetPicUrl(nm.PicUrl),
                            Url         = TransformUrl(nm.Url, msgModel)
                        });
                        newsModel.Articles = articles;
                        res = newsModel.ToString();
                    }
                    break;

                case "auto_coupon_category":
                    SiteActivityDAL dalCatList  = new SiteActivityDAL();
                    SiteActivity    activityCat = dalCatList.GetSiteAct(siteCode, "Coupon");
                    if (activityCat != null)
                    {
                        CouponDAL cdal = new CouponDAL();
                        if (!cdal.ExistCoupon(siteCode, activityCat.ID, msgModel.FromUserName))
                        {
                            Coupon coupon = new Coupon()
                            {
                                SiteCode       = siteCode,
                                SiteActivityID = activityCat.ID,
                                OpenID         = msgModel.FromUserName,
                                //CouponCode = msgModel.FromUserName,
                                CouponStatus = 0
                            };
                            cdal.InsertInfo(coupon);
                        }
                    }
                    ArticleDAL catDal = new ArticleDAL();
                    DataSet    cdsCat = catDal.GetCategoryList(siteCode, replyMsgValue);
                    if (cdsCat != null && cdsCat.Tables.Count > 0 && cdsCat.Tables[0] != null && cdsCat.Tables[0].Rows.Count > 0)
                    {
                        int i = 0;
                        NewsResponseMsgModel newsModel = new NewsResponseMsgModel()
                        {
                            ToUserName   = msgModel.FromUserName,
                            FromUserName = msgModel.ToUserName,
                            CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString()
                        };
                        List <Article> articles = new List <Article>();
                        foreach (DataRow dr in cdsCat.Tables[0].Rows)
                        {
                            if (++i > 4)
                            {
                                break;
                            }
                            articles.Add(new Article()
                            {
                                Title       = dr["Title"].ToString(),
                                Description = dr["Summary"].ToString(),
                                //Description = RemoveHtmlTag(dr["Content"].ToString(), 30),
                                PicUrl = GetPicUrl(dr["Pic"].ToString()),
                                Url    = GetArticleUrl(dr["ID"].ToString())
                            });
                        }
                        newsModel.Articles = articles;
                        res = newsModel.ToString();
                    }
                    break;

                case "auto_news_article":
                    //根据文章自动生成图文消息进行回复,MsgValue为文章ID
                    ArticleDAL aDal = new ArticleDAL();
                    DataSet    ds   = aDal.GetArticleDetail(replyMsgValue);
                    if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        int i = 0;
                        NewsResponseMsgModel newsModel = new NewsResponseMsgModel()
                        {
                            ToUserName   = msgModel.FromUserName,
                            FromUserName = msgModel.ToUserName,
                            CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString()
                        };
                        List <Article> articles = new List <Article>();
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            if (++i > 4)
                            {
                                break;
                            }
                            articles.Add(new Article()
                            {
                                Title       = dr["Title"].ToString(),
                                Description = dr["Summary"].ToString(),
                                //Description = RemoveHtmlTag(dr["Content"].ToString(), 100),
                                PicUrl = GetPicUrl(dr["Pic"].ToString()),
                                Url    = GetArticleUrl(dr["ID"].ToString())
                            });
                        }
                        newsModel.Articles = articles;
                        res = newsModel.ToString();
                    }
                    break;

                case "auto_news_category":
                    //根据类别自动生成图文消息进行回复,MsgValue为类别ID
                    ArticleDAL cDal = new ArticleDAL();
                    DataSet    cds  = cDal.GetCategoryList(siteCode, replyMsgValue);
                    if (cds != null && cds.Tables.Count > 0 && cds.Tables[0] != null && cds.Tables[0].Rows.Count > 0)
                    {
                        int i = 0;
                        NewsResponseMsgModel newsModel = new NewsResponseMsgModel()
                        {
                            ToUserName   = msgModel.FromUserName,
                            FromUserName = msgModel.ToUserName,
                            CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString()
                        };
                        List <Article> articles = new List <Article>();
                        foreach (DataRow dr in cds.Tables[0].Rows)
                        {
                            if (++i > 4)
                            {
                                break;
                            }
                            articles.Add(new Article()
                            {
                                Title       = dr["Title"].ToString(),
                                Description = dr["Summary"].ToString(),
                                //Description = RemoveHtmlTag(dr["Content"].ToString(), 30),
                                PicUrl = GetPicUrl(dr["Pic"].ToString()),
                                Url    = GetArticleUrl(dr["ID"].ToString())
                            });
                        }
                        newsModel.Articles = articles;
                        res = newsModel.ToString();
                    }
                    break;

                case "coupon":
                    //回复图文表中的消息,MsgValue为图文消息表ID集,用逗号分隔
                    NewsMsgDAL nmDAL1 = new NewsMsgDAL();
                    NewsMsg    nms    = nmDAL1.GetNewsMsg(replyMsgValue);
                    if (nms != null)
                    {
                        NewsResponseMsgModel newsModel = new NewsResponseMsgModel()
                        {
                            ToUserName   = msgModel.FromUserName,
                            FromUserName = msgModel.ToUserName,
                            CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString()
                        };
                        List <Article> articles = new List <Article>();
                        articles.Add(new Article()
                        {
                            Title       = nms.Title,
                            Description = nms.Description,
                            PicUrl      = GetPicUrl(nms.PicUrl),
                            Url         = TransformUrl(nms.Url, msgModel)
                        });
                        newsModel.Articles = articles;
                        res = newsModel.ToString();
                    }
                    break;

                case "news":
                    //回复图文表中的消息,MsgValue为图文消息表ID集,用逗号分隔
                    NewsMsgDAL      nmDALs   = new NewsMsgDAL();
                    IList <NewsMsg> newsMsgs = nmDALs.GetNewsMsgs(replyMsgValue);
                    if (newsMsgs != null)
                    {
                        NewsResponseMsgModel newsModel = new NewsResponseMsgModel()
                        {
                            ToUserName   = msgModel.FromUserName,
                            FromUserName = msgModel.ToUserName,
                            CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString()
                        };
                        List <Article> articles = new List <Article>();
                        foreach (NewsMsg msg in newsMsgs)
                        {
                            articles.Add(new Article()
                            {
                                Title       = msg.Title,
                                Description = msg.Description,
                                PicUrl      = GetPicUrl(msg.PicUrl),
                                Url         = TransformUrl(msg.Url, msgModel)
                            });
                        }
                        newsModel.Articles = articles;
                        res = newsModel.ToString();
                    }
                    break;

                case "url":
                    //根据文章自动生成图文消息进行回复,MsgValue为文章ID
                    DAL.SYS.AccountDAL dalUrl = new DAL.SYS.AccountDAL();
                    DataSet            dsUrl  = dalUrl.GetAccountExtData(replyMsgValue);
                    if (dsUrl != null && dsUrl.Tables.Count > 0 && dsUrl.Tables[0] != null && dsUrl.Tables[0].Rows.Count > 0)
                    {
                        int i = 0;
                        NewsResponseMsgModel newsModel = new NewsResponseMsgModel()
                        {
                            ToUserName   = msgModel.FromUserName,
                            FromUserName = msgModel.ToUserName,
                            CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString()
                        };
                        List <Article> articles = new List <Article>();
                        foreach (DataRow dr in dsUrl.Tables[0].Rows)
                        {
                            if (++i > 4)
                            {
                                break;
                            }
                            articles.Add(new Article()
                            {
                                Title       = dr["Name"].ToString(),
                                Description = dr["Summary"].ToString(),
                                PicUrl      = GetPicUrl(dr["Photo"].ToString()),
                                Url         = GetSiteInfo(dr["ID"].ToString())
                            });
                        }
                        newsModel.Articles = articles;
                        res = newsModel.ToString();
                    }
                    break;

                case "hp_photo_text":
                    //为当前hp_photo对应的照片附加文字信息
                    PhotoDAL photoDal = new PhotoDAL();
                    if (photoDal.ExistPhoto(siteCode, msgModel.FromUserName, 0))
                    {
                        TextRequestMsgModel temp = msgModel as TextRequestMsgModel;
                        string text = temp.Content.Replace("#ms", "");
                        //附加图片文字
                        photoDal.UpdateAttachText(siteCode, msgModel.FromUserName, text);
                        TextResponseMsgModel textMsg2 = new TextResponseMsgModel()
                        {
                            ToUserName   = msgModel.FromUserName,
                            FromUserName = msgModel.ToUserName,
                            CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString(),
                            Content      = replyMsgValue == null ? string.Empty : TransformText(replyMsgValue, msgModel)
                        };
                        res = textMsg2.ToString();
                    }
                    else
                    {
                        TextResponseMsgModel textMsg2 = new TextResponseMsgModel()
                        {
                            ToUserName   = msgModel.FromUserName,
                            FromUserName = msgModel.ToUserName,
                            CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString(),
                            Content      = "对不起,您暂未参加图片打印活动!"
                        };
                        res = textMsg2.ToString();
                    }
                    break;

                case "hp_photo_ticket":
                    //对当前hp_photo对应的照片进行打印认证
                    PrintCodeDAL        printCodeDAL = new PrintCodeDAL();
                    TextRequestMsgModel temp1        = msgModel as TextRequestMsgModel;
                    string printCode = temp1.Content.Replace("#dy", "");
                    string clientID  = printCodeDAL.GetClientIDByPrintCode(printCode, siteCode);
                    ExceptionLogDAL.InsertExceptionLog(new ExceptionLog()
                    {
                        Message = clientID
                    });
                    if (!string.IsNullOrEmpty(clientID))
                    {
                        PhotoDAL photoDal1 = new PhotoDAL();
                        photoDal1.UpdatePrintInfo(printCode, clientID, siteCode, msgModel.FromUserName);
                        TextResponseMsgModel textMsg2 = new TextResponseMsgModel()
                        {
                            ToUserName   = msgModel.FromUserName,
                            FromUserName = msgModel.ToUserName,
                            CreateTime   = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString(),
                            Content      = replyMsgValue == null ? string.Empty : TransformText(replyMsgValue, msgModel)
                        };
                        res = textMsg2.ToString();
                        //TextResponseMsgModel textMsg2 = new TextResponseMsgModel()
                        //{
                        //    ToUserName = msgModel.FromUserName,
                        //    FromUserName = msgModel.ToUserName,
                        //    CreateTime = WeiXinHelper.ConvertDateTimeInt(DateTime.Now).ToString(),
                        //    Content = "照片打印中,请稍侯..."
                        //};
                        //res = textMsg2.ToString();
                    }
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                ExceptionLogDAL.InsertExceptionLog(ex);
            }
            return(res);
        }
Esempio n. 10
0
        protected override bool BeforeLoad()
        {
            string strGuid = string.Empty;


            if (null != Request.QueryString["sitecode"] && null != Request.QueryString["openid"] && null != Request.QueryString["couponid"])
            {
                CouponID = Common.Common.NoHtml(Request.QueryString["couponid"].ToString());
                SiteCode = Common.Common.NoHtml(Request.QueryString["sitecode"].ToString());

                if (Request.QueryString["sitecode"].ToString().Length > 6)
                {
                    return(false);
                }

                if (Request.QueryString["couponid"].ToString().Length != 32)
                {
                    return(false);
                }

                if (Request.QueryString["openid"].ToString().Length > 29 || Request.QueryString["openid"].ToString().Length < 25)
                {
                    return(false);
                }
                else
                {
                    OpenID = Request.QueryString["openid"].ToString();
                }

                //插入优惠券
                SiteActivityDAL dalActive = new SiteActivityDAL();
                DataSet         dsActive  = dalActive.GetActivityDetail(CouponID);
                if (null != dsActive && dsActive.Tables.Count > 0 && dsActive.Tables[0].Rows.Count > 0)
                {
                    strGuid = Guid.NewGuid().ToString("N");
                    CouponDAL cdal = new CouponDAL();
                    if (!cdal.ExistCoupon(SiteCode, CouponID, OpenID))
                    {
                        //判断是否可以参加
                        //取当前已经参加的人数
                        int iCount = 10000000;
                        if (null != dsActive.Tables[0].Rows[0]["DayLimit"].ToString())
                        {
                            string strCount = "SiteCode = '" + SiteCode + "' AND SiteActivityID = '" + CouponID + "' AND CONVERT(VARCHAR(10),AddTime,120) = CONVERT(VARCHAR(10),GETDATE(),120)";
                            iCount = cdal.GetCouponCount(strCount);
                        }
                        string strStartTime = dsActive.Tables[0].Rows[0]["StartTime"].ToString();
                        string strEndTime   = dsActive.Tables[0].Rows[0]["EndTime"].ToString();
                        string strOpenTime  = dsActive.Tables[0].Rows[0]["OpenTime"].ToString();
                        string strCloseTime = dsActive.Tables[0].Rows[0]["CloseTime"].ToString();
                        string strDayLimit  = dsActive.Tables[0].Rows[0]["DayLimit"].ToString();

                        if (DateTime.Now >= Convert.ToDateTime(strStartTime) &&
                            DateTime.Now < Convert.ToDateTime(strEndTime) &&
                            DateTime.Now.Hour >= int.Parse(strOpenTime) &&
                            DateTime.Now.Hour < int.Parse(strCloseTime)
                            )
                        {
                            if (iCount < int.Parse(strDayLimit))
                            {
                                Coupon coupon = new Coupon()
                                {
                                    ID             = strGuid,
                                    SiteCode       = SiteCode,
                                    SiteActivityID = CouponID,
                                    OpenID         = OpenID,
                                    CouponStatus   = 0
                                };
                                cdal.InsertInfo(coupon);
                                strReHtml = "RushBuyOK.html";
                            }
                            else
                            {
                                strReHtml  = "RushBuyOver.html";
                                strMessage = "抱歉!优惠券已经被抢完,请关注下期活动!";
                            }
                        }
                        else
                        {
                            strReHtml  = "RushBuyOver.html";
                            strMessage = "抱歉!近期活动未开始或者已经结束,请关注公方微信优惠消息!";
                        }
                    }
                    else
                    {
                        strReHtml  = "RushBuyOver.html";
                        strMessage = "抱歉!您已经参与了活动,请把机会留给其余的顾客。";
                    }
                }
                CouponID = strGuid;
            }
            else
            {
                Response.Write("<script>window.opener=null;window.close();</script>");
                return(false);
            }
            return(base.BeforeLoad());
        }
Esempio n. 11
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (txtName.Text.Trim() != null && txtName.Text.Trim() != "")
            {
                //上传图标
                string strIconFileName     = string.Empty; //图标路径
                string strIconSaveFileName = string.Empty; //网址路径
                try
                {
                    if (this.file0.PostedFile.FileName == "")
                    {
                        strIconSaveFileName = "";
                    }
                    else
                    {
                        if (!System.IO.Directory.Exists(Server.MapPath("~") + @"/Images"))
                        {
                            System.IO.Directory.CreateDirectory(Server.MapPath("~") + @"/Images");
                        }
                        if (!System.IO.Directory.Exists(String.Format(@"{0}/Images/{1}", Server.MapPath("~"), Session["strSiteCode"].ToString())))
                        {
                            System.IO.Directory.CreateDirectory(String.Format(@"{0}/Images/{1}", Server.MapPath("~"), Session["strSiteCode"].ToString()));
                        }
                        string orignalName = this.file0.PostedFile.FileName;                      //获取客户机上传文件的文件名
                        string extendName  = orignalName.Substring(orignalName.LastIndexOf(".")); //获取扩展名

                        if (extendName != ".gif" && extendName != ".jpg" && extendName != ".jpeg" && extendName != ".png")
                        {
                            MessageBox.Show(this, "文件格式有误!");
                            return;
                        }//检查文件格式
                        string newName = String.Format("{0}_{1}{2}", DateTime.Now.Millisecond, file0.PostedFile.ContentLength, extendName);//对文件进行重命名
                        strIconFileName     = String.Format(@"{0}Images/{1}/{2}", Server.MapPath("~"), Session["strSiteCode"].ToString(), newName);
                        strIconSaveFileName = String.Format(@"Images/{0}/{1}", Session["strSiteCode"].ToString(), newName);
                        file0.PostedFile.SaveAs(strIconFileName);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, "上传发生错误!原因是:" + ex.ToString());
                }

                SiteActivity model = new SiteActivity();
                model.ID         = Guid.NewGuid().ToString("N").ToUpper();
                model.ActTitle   = txtName.Text.Trim();
                model.SiteCode   = GlobalSession.strSiteCode;
                model.ActContent = hd_content.Value;
                model.StartTime  = starttime.Text;
                model.EndTime    = endtime.Text;
                model.Remark     = txtSummary.Text;
                model.CutOffTime = cutTime.Text;
                model.DisCount   = Discount.Text;
                model.Photo      = strIconSaveFileName;
                model.OpenTime   = opentime.Text;
                model.CloseTime  = closetime.Text;
                if (daylimit.Text.Trim() != null && daylimit.Text.Trim() != "" && Convert.ToInt32(daylimit.Text) > -1)
                {
                    model.DayLimit = Convert.ToInt32(daylimit.Text);
                }
                model.ActStatus = ActStatusyes.Checked?1:0;//默认1 生效
                SiteActivityDAL dal = new SiteActivityDAL();
                if (dal.SaveActivity(model) > 0)
                {
                    MessageBox.Show(this, "添加成功!");
                }
                else
                {
                    MessageBox.Show(this, "添加失败!");
                }
            }
            else
            {
                MessageBox.Show(this, "请输入相关名称!");
            }
        }