Beispiel #1
0
        protected void Save_B_Click(object sender, EventArgs e)
        {
            M_WX_ReplyMsg rpMod = new M_WX_ReplyMsg();

            if (Mid > 0)
            {
                rpMod = rpBll.SelReturnModel(Mid);
            }
            M_WXImgItem item = new M_WXImgItem()
            {
                Title = Title_T.Text, Description = Content_T.Text, PicUrl = PicUrl_T.Text, Url = Url_T.Text
            };

            rpMod.fiter     = filter_T.Text.Trim();
            rpMod.Content   = JsonConvert.SerializeObject(item);
            rpMod.MsgType   = item.IsText ? "0" : "1";
            rpMod.AppId     = AppId;
            rpMod.MsgType   = Request.Form["msgtype_rad"];
            rpMod.IsDefault = IsDefault_Chk.Checked ? 1 : 0;
            if (Mid > 0)
            {
                rpBll.UpdateByID(rpMod);
            }
            else
            {
                rpBll.Insert(rpMod);
            }
            Response.Redirect("ReplyList.aspx?appid=" + AppId);
        }
Beispiel #2
0
        public IActionResult ReplyAdd_Submit()
        {
            M_WX_ReplyMsg rpMod = new M_WX_ReplyMsg();

            if (Mid > 0)
            {
                rpMod = rpBll.SelReturnModel(Mid);
            }
            M_WXImgItem item = new M_WXImgItem()
            {
                Title = GetParam("Title_T"), Description = GetParam("Content_T"), PicUrl = GetParam("PicUrl_T"), Url = GetParam("Url_T")
            };

            rpMod.fiter     = GetParam("filter_T");
            rpMod.Content   = JsonConvert.SerializeObject(item);
            rpMod.MsgType   = item.IsText ? "0" : "1";
            rpMod.AppId     = AppId;
            rpMod.MsgType   = Request.Form["msgtype_rad"];
            rpMod.IsDefault = DataConvert.CLng(GetParam("IsDefault_Chk"));
            if (Mid > 0)
            {
                rpBll.UpdateByID(rpMod);
            }
            else
            {
                rpBll.Insert(rpMod);
            }
            return(WriteOK("ReplyList?appid=" + AppId));
        }
Beispiel #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (AppId <= 0)
     {
         function.WriteErrMsg("请先配置公众号信息,再进入该页面,[<a href='WxAppManage.aspx'>前往配置</a>]");
     }
     if (!IsPostBack)
     {
         M_WX_APPID appmod = appBll.SelReturnModel(AppId);
         string     alias  = " [公众号:" + appmod.Alias + "]";
         if (Mid > 0)
         {
             M_WX_ReplyMsg rpMod = rpBll.SelReturnModel(Mid);
             filter_T.Text = rpMod.fiter;
             M_WXImgItem item = JsonConvert.DeserializeObject <M_WXImgItem>(rpMod.Content);
             Title_T.Text   = item.Title;
             Content_T.Text = item.Description;
             PicUrl_T.Text  = item.PicUrl;
             Url_T.Text     = item.Url;
             function.Script(this, "SetRadVal('msgtype_rad','" + rpMod.MsgType + "');");
             IsDefault_Chk.Checked = rpMod.IsDefault == 1;
         }
         Call.SetBreadCrumb(Master, "<li><a href='Home.aspx'>移动微信</a></li><li class='active'><a href='ReplyList.aspx'>回复管理</a></li></li><li class='active'>添加回复" + alias + "</li>");
     }
 }
        protected void Save_B_Click(object sender, EventArgs e)
        {
            M_WX_ReplyMsg replymsg = new M_WX_ReplyMsg();

            replymsg.fiter   = GuestMsg_T.Text;
            replymsg.Content = Content_T.Text;
            wxBll.Insert(replymsg);
        }
Beispiel #5
0
    //用户文件信息处理
    public string UserTextDeal(M_WxTextMsg reqMod)
    {
        M_WX_ReplyMsg rpMod  = rpBll.SelByFileAndDef(appBll.GetAppByWxNo(reqMod.ToUserName).ID, reqMod.Content);
        M_WxImgMsg    msgMod = new M_WxImgMsg();

        msgMod.ToUserName   = reqMod.FromUserName;
        msgMod.FromUserName = reqMod.ToUserName;
        //如果未匹配到则直接返回
        string result = "";

        if (rpMod == null)
        {
            M_WxImgMsg msgmod1 = new M_WxImgMsg();
            msgmod1.ToUserName   = reqMod.FromUserName;
            msgmod1.FromUserName = reqMod.ToUserName;
            M_WX_ReplyMsg rpMod1 = new M_WX_ReplyMsg();
            rpMod1 = rpBll.SelByFileAndDef(appBll.GetAppByWxNo(reqMod.ToUserName).ID, "头图");
            if (rpMod1 != null)
            {
                M_WXImgItem item = JsonConvert.DeserializeObject <M_WXImgItem>(rpMod1.Content);
                msgmod1.Articles.Add(new M_WXImgItem()
                {
                    Title = item.Title, Url = item.Url, Description = item.Description, PicUrl = item.PicUrl
                });
            }
            RepToClient(msgmod1.ToXML());
        }
        else//如果匹配到
        {
            M_WXImgItem item = JsonConvert.DeserializeObject <M_WXImgItem>(rpMod.Content);
            if (item.Description.Contains("{$UserName}"))
            {
                M_WX_User wuserMod = api.GetWxUserModel(reqMod.FromUserName);
                item.PicUrl      = wuserMod.HeadImgUrl;
                item.Description = item.Description.Replace("{$UserName}", wuserMod.Name);
            }
            msgMod.Articles.Add(item);
            switch (rpMod.MsgType)
            {
            case "0":
                M_WxTextMsg textMod = ImageToText(msgMod);
                result = textMod.ToXML();
                break;

            case "1":
                result = msgMod.ToXML();
                break;
            }
        }
        return(result);
    }
Beispiel #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     ExHelper.CheckUserAuth("wechat");
     if (!IsPostBack)
     {
         M_WX_APPID appmod = ExHelper.WX_SelMyModel();
         if (Mid > 0)
         {
             M_WX_ReplyMsg rpMod = rpBll.SelReturnModel(Mid);
             filter_T.Text = rpMod.fiter;
             M_WXImgItem item = JsonConvert.DeserializeObject <M_WXImgItem>(rpMod.Content);
             Title_T.Text   = item.Title;
             Content_T.Text = item.Description;
             PicUrl_T.Text  = item.PicUrl;
             Url_T.Text     = item.Url;
             function.Script(this, "SetRadVal('msgtype_rad','" + rpMod.MsgType + "');");
             IsDefault_Chk.Checked = rpMod.IsDefault == 1;
         }
     }
 }
Beispiel #7
0
        public IActionResult ReplyAdd()
        {
            if (AppId <= 0)
            {
                return(WriteErr("请先配置公众号信息,再进入该页面,[<a href='WxAppManage.aspx'>前往配置</a>]"));
            }
            B_ARoleAuth.AuthCheckEx(ZLEnum.Auth.portable, "wechat");
            //M_WX_APPID appmod = appBll.SelReturnModel(AppId);
            //string alias = " [公众号:" + appmod.Alias + "]";
            M_WX_ReplyMsg rpMod  = new M_WX_ReplyMsg();
            M_WXImgItem   rpItem = new M_WXImgItem();

            if (Mid > 0)
            {
                rpMod  = rpBll.SelReturnModel(Mid);
                rpItem = JsonConvert.DeserializeObject <M_WXImgItem>(rpMod.Content);
                //IsDefault_Chk.Checked = rpMod.IsDefault == 1;
            }

            ViewBag.rpItem = rpItem;
            return(View(viewDir + "ReplyAdd.cshtml", rpMod));
        }
Beispiel #8
0
    //用户文件信息处理
    public string UserTextDeal(M_WxTextMsg reqMod)
    {
        M_WX_ReplyMsg rpMod  = rpBll.SelByFileAndDef(appBll.GetAppByWxNo(reqMod.ToUserName).ID, reqMod.Content);
        M_WxImgMsg    msgMod = new M_WxImgMsg();

        msgMod.ToUserName   = reqMod.FromUserName;
        msgMod.FromUserName = reqMod.ToUserName;
        //如果未匹配到则直接返回
        string result = "";

        if (rpMod == null)
        {
            msgMod.Articles.Add(new M_WXImgItem()
            {
                Title = "未找到相关联的操作"
            });
            result = msgMod.ToXML();
        }
        else//如果匹配到
        {
            M_WXImgItem item = JsonConvert.DeserializeObject <M_WXImgItem>(rpMod.Content);
            msgMod.Articles.Add(item);
            switch (rpMod.MsgType)
            {
            case "0":
                M_WxTextMsg textMod = ImageToText(msgMod);
                result = textMod.ToXML();
                break;

            case "1":
                result = msgMod.ToXML();
                break;
            }
        }
        return(result);
    }
Beispiel #9
0
    /// <summary>
    /// 系统事件,如订阅等处理
    /// </summary>
    public void WxEventHandler(M_WxTextMsg reqMod)
    {
        M_WX_User userMod = null;

        errmsg += ",事件:" + reqMod.Event;
        switch (reqMod.Event.ToLower())
        {
        case "subscribe":
            userMod       = api.GetWxUserModel(reqMod.FromUserName);
            userMod.CDate = DateTime.Now;
            userMod.AppId = api.AppId.ID;
            wxuserBll.Insert(userMod);
            M_WxImgMsg msgmod = new M_WxImgMsg();
            msgmod.ToUserName   = reqMod.FromUserName;
            msgmod.FromUserName = reqMod.ToUserName;

            M_WX_ReplyMsg rpMod1 = new M_WX_ReplyMsg();
            rpMod1 = rpBll.SelByFileAndDef(appBll.GetAppByWxNo(reqMod.ToUserName).ID, "头图");
            if (rpMod1 != null)
            {
                M_WXImgItem item = JsonConvert.DeserializeObject <M_WXImgItem>(rpMod1.Content);
                msgmod.Articles.Add(new M_WXImgItem()
                {
                    Title = item.Title, Url = item.Url, Description = item.Description, PicUrl = item.PicUrl
                });
            }
            rpMod1 = rpBll.SelByFileAndDef(appBll.GetAppByWxNo(reqMod.ToUserName).ID, "推送1");
            {
                M_WXImgItem item = JsonConvert.DeserializeObject <M_WXImgItem>(rpMod1.Content);
                msgmod.Articles.Add(new M_WXImgItem()
                {
                    Title = item.Title, Url = item.Url, Description = item.Description, PicUrl = item.PicUrl
                });
            }
            rpMod1 = rpBll.SelByFileAndDef(appBll.GetAppByWxNo(reqMod.ToUserName).ID, "推送2");
            {
                M_WXImgItem item = JsonConvert.DeserializeObject <M_WXImgItem>(rpMod1.Content);
                msgmod.Articles.Add(new M_WXImgItem()
                {
                    Title = item.Title, Url = item.Url, Description = item.Description, PicUrl = item.PicUrl
                });
            }
            rpMod1 = rpBll.SelByFileAndDef(appBll.GetAppByWxNo(reqMod.ToUserName).ID, "推送3");
            {
                M_WXImgItem item = JsonConvert.DeserializeObject <M_WXImgItem>(rpMod1.Content);
                msgmod.Articles.Add(new M_WXImgItem()
                {
                    Title = item.Title, Url = item.Url, Description = item.Description, PicUrl = item.PicUrl
                });
            }
            rpMod1 = rpBll.SelByFileAndDef(appBll.GetAppByWxNo(reqMod.ToUserName).ID, "推送4");
            {
                M_WXImgItem item = JsonConvert.DeserializeObject <M_WXImgItem>(rpMod1.Content);
                msgmod.Articles.Add(new M_WXImgItem()
                {
                    Title = item.Title, Url = item.Url, Description = item.Description, PicUrl = item.PicUrl
                });
            }
            rpMod1 = rpBll.SelByFileAndDef(appBll.GetAppByWxNo(reqMod.ToUserName).ID, "推送5");
            {
                M_WXImgItem item = JsonConvert.DeserializeObject <M_WXImgItem>(rpMod1.Content);
                msgmod.Articles.Add(new M_WXImgItem()
                {
                    Title = item.Title, Url = item.Url, Description = item.Description, PicUrl = item.PicUrl
                });
            }
            RepToClient(msgmod.ToXML());
            System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(SendMsg), reqMod);
            break;

        case "unsubscribe":
        {
            userMod = wxuserBll.SelForOpenid(reqMod.FromUserName);
            if (userMod != null)
            {
                wxuserBll.Del(userMod.ID);
            }
        }
        break;

        case "location":    //用户进入公众号(包含定位信息)
            break;

        case "scan":    //带参数的二维码扫描进入(关注事件在上方处理)
            M_UserAPP   uappMod  = new M_UserAPP();
            B_UserAPP   uappBll  = new B_UserAPP();
            M_UserInfo  mu       = new M_UserInfo();
            M_WxTextMsg textMod2 = new M_WxTextMsg();
            textMod2.FromUserName = reqMod.ToUserName;
            textMod2.ToUserName   = reqMod.FromUserName;
            textMod2.MsgType      = "text";
            textMod2.Content      = "";
            uappMod = uappBll.SelModelByOpenID(reqMod.FromUserName, "wechat");
            if (uappMod != null)
            {
                mu = buser.GetUserByUserID(uappMod.UserID);
                M_UserInfo pmu = buser.GetUserByUserID(DataConvert.CLng(reqMod.EventKey));
                if (mu != null && mu.UserID > 0)
                {
                    if (DataConvert.CLng(mu.ParentUserID) > 0)
                    {
                        textMod2.Content = "您已绑定了推荐人不能重复绑定!";
                        RepToClient(textMod2.ToXML());
                    }
                    else
                    {
                        if (mu.UserID == DataConvert.CLng(reqMod.EventKey))
                        {
                            textMod2.Content = "您扫描的是您自己的二维码!";
                        }
                        else
                        {
                            mu.ParentUserID = DataConvert.CLng(reqMod.EventKey).ToString();
                            if (pmu != null && pmu.UserID > 0)
                            {
                                string err = "";
                                if (CheckParentUser(pmu.UserID, mu.UserID, ref err))
                                {
                                    mu.ParentUserID = pmu.UserID.ToString();
                                    if (buser.UpdateByID(mu))
                                    {
                                        textMod2.Content = "您成功绑定了推荐人:" + pmu.TrueName + "!";
                                    }

                                    else
                                    {
                                        textMod2.Content = "绑定推荐人失败!";
                                    }
                                }
                                else
                                {
                                    textMod2.Content = "绑定推荐失败,错误信息:" + err;
                                }
                            }
                            else
                            {
                                textMod2.Content = "绑定推荐失败,推荐人不存在!";
                            }
                        }
                        RepToClient(textMod2.ToXML());
                    }
                }
            }
            break;

        default:
            break;
        }
    }
Beispiel #10
0
    /// <summary>
    /// 系统事件,如订阅等处理
    /// </summary>
    public void WxEventHandler(M_WxTextMsg reqMod)
    {
        M_WX_User userMod = null;

        switch (reqMod.Event.ToLower())
        {
        case "subscribe":
            userMod       = api.GetWxUserModel(reqMod.FromUserName);
            userMod.CDate = DateTime.Now;
            userMod.AppId = api.AppId.ID;
            wxuserBll.Insert(userMod);
            M_WxImgMsg msgmod = JsonConvert.DeserializeObject <M_WxImgMsg>(api.AppId.WelStr);
            msgmod.ToUserName   = reqMod.FromUserName;
            msgmod.FromUserName = reqMod.ToUserName;

            int        pid      = DataConvert.CLng(reqMod.EventKey.Replace("qrscene_", ""));
            Appinfo    uappMod1 = new Appinfo();
            B_UserAPP  uappBll1 = new B_UserAPP();
            M_UserInfo mu1      = new M_UserInfo();
            M_WX_User  wuserMod = new M_WX_User();
            M_Uinfo    mubase   = new M_Uinfo();
            uappMod1 = uappBll1.SelModelByOpenID(reqMod.FromUserName, "wechat");
            wuserMod = api.GetWxUserModel(reqMod.FromUserName);
            if (uappMod1 != null)
            {
                mu1 = buser.GetUserByUserID(uappMod1.UserID);
                if (mu1 != null && mu1.UserID > 0)
                {
                    mu1.TrueName = wuserMod.Name;
                    mu1.GroupID  = 1;
                    buser.UpdateByID(mu1);
                }
                else
                {
                    mu1.UserName = "******" + DateTime.Now.ToString("yyyyMMddHHmmss") + function.GetRandomString(2).ToLower();
                    mu1.UserPwd  = StringHelper.MD5(function.GetRandomString(6));
                    mu1.Email    = function.GetRandomString(10) + "@wx.com";
                    mu1.Question = function.GetRandomString(5);
                    mu1.Answer   = function.GetRandomString(5);
                    mu1.TrueName = wuserMod.Name;
                    mu1.GroupID  = 1;
                    mu1.UserID   = buser.Add(mu1);

                    uappMod1.UserID     = mu1.UserID;
                    uappMod1.SourcePlat = "wechat";
                    uappMod1.OpenID     = reqMod.FromUserName;
                    uappBll1.UpdateByID(uappMod1);
                    mubase.UserId = mu1.UserID;
                    buser.AddBase(mubase);
                }
            }
            else
            {
                uappMod1     = new Appinfo();
                mu1.UserName = "******" + DateTime.Now.ToString("yyyyMMddHHmmss") + function.GetRandomString(2).ToLower();
                mu1.UserPwd  = StringHelper.MD5(function.GetRandomString(6));
                mu1.Email    = function.GetRandomString(10) + "@wx.com";
                mu1.Question = function.GetRandomString(5);
                mu1.Answer   = function.GetRandomString(5);
                mu1.TrueName = wuserMod.Name;
                mu1.GroupID  = 1;
                mu1.UserID   = buser.Add(mu1);

                uappMod1.UserID     = mu1.UserID;
                uappMod1.SourcePlat = "wechat";
                uappMod1.OpenID     = reqMod.FromUserName;
                uappBll1.Insert(uappMod1);
                mubase.UserId = mu1.UserID;
                buser.AddBase(mubase);
            }

            if (string.IsNullOrEmpty(msgmod.Articles[0].PicUrl))     //如未设置图片则以纯文本格式发送,纯文本支持内置超链接
            {
                M_WxTextMsg textMod = ImageToText(msgmod);
                RepToClient(textMod.ToXML());
            }
            else
            {
                RepToClient(msgmod.ToXML());
            }
            //关注时发送多条信息
            if (pid > 0)
            {
                System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(SendMsg), reqMod);
            }
            //关注时发送多条信息
            //System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(SendMsg), reqMod);
            break;

        case "unsubscribe":
            wxuserBll.DelByOpenid(api.AppId.ID, reqMod.FromUserName);
            break;

        case "location":    //用户进入公众号(包含定位信息)
            M_WxImgMsg msgmod1 = new M_WxImgMsg();
            msgmod1.ToUserName   = reqMod.FromUserName;
            msgmod1.FromUserName = reqMod.ToUserName;
            M_WX_ReplyMsg rpMod = new M_WX_ReplyMsg();
            rpMod = rpBll.SelByFileAndDef(appBll.GetAppByWxNo(reqMod.ToUserName).ID, "头图");
            if (rpMod != null)
            {
                M_WXImgItem item = JsonConvert.DeserializeObject <M_WXImgItem>(rpMod.Content);
                msgmod1.Articles.Add(new M_WXImgItem()
                {
                    Title = item.Title, Url = item.Url, Description = item.Description, PicUrl = item.PicUrl
                });
            }
//                rpMod = rpBll.SelByFileAndDef(appBll.GetAppByWxNo(reqMod.ToUserName).ID, "推送1");
//                {
//                    M_WXImgItem item = JsonConvert.DeserializeObject<M_WXImgItem>(rpMod.Content);
//                    msgmod1.Articles.Add(new M_WXImgItem() { Title = item.Title, Url = item.Url, Description = item.Description, PicUrl = item.PicUrl });
//                }
//                rpMod = rpBll.SelByFileAndDef(appBll.GetAppByWxNo(reqMod.ToUserName).ID, "推送2");
//                {
//                    M_WXImgItem item = JsonConvert.DeserializeObject<M_WXImgItem>(rpMod.Content);
//                    msgmod1.Articles.Add(new M_WXImgItem() { Title = item.Title, Url = item.Url, Description = item.Description, PicUrl = item.PicUrl });
//                }
//                rpMod = rpBll.SelByFileAndDef(appBll.GetAppByWxNo(reqMod.ToUserName).ID, "推送3");
//                {
//                    M_WXImgItem item = JsonConvert.DeserializeObject<M_WXImgItem>(rpMod.Content);
//                    msgmod1.Articles.Add(new M_WXImgItem() { Title = item.Title, Url = item.Url, Description = item.Description, PicUrl = item.PicUrl });
//                }
//                rpMod = rpBll.SelByFileAndDef(appBll.GetAppByWxNo(reqMod.ToUserName).ID, "推送4");
//                {
//                    M_WXImgItem item = JsonConvert.DeserializeObject<M_WXImgItem>(rpMod.Content);
//                    msgmod1.Articles.Add(new M_WXImgItem() { Title = item.Title, Url = item.Url, Description = item.Description, PicUrl = item.PicUrl });
//                }
            RepToClient(msgmod1.ToXML());
            break;

        case "scan":
            Appinfo     uappMod  = new Appinfo();
            B_UserAPP   uappBll  = new B_UserAPP();
            M_UserInfo  mu       = new M_UserInfo();
            M_WxTextMsg textMod2 = new M_WxTextMsg();
            textMod2.FromUserName = reqMod.ToUserName;
            textMod2.ToUserName   = reqMod.FromUserName;
            textMod2.MsgType      = "text";
            textMod2.Content      = "";
            uappMod = uappBll.SelModelByOpenID(reqMod.FromUserName, "wechat");
            if (uappMod != null)
            {
                mu = buser.GetUserByUserID(uappMod.UserID);
                M_UserInfo pmu = buser.GetUserByUserID(DataConvert.CLng(reqMod.EventKey));
                if (mu != null && mu.UserID > 0)
                {
                    if (DataConvert.CLng(mu.ParentUserID) > 0)
                    {
                        textMod2.Content = "您已绑定了推荐人不能重复绑定!";
                        RepToClient(textMod2.ToXML());
                    }
                    else
                    {
                        if (mu.UserID == DataConvert.CLng(reqMod.EventKey))
                        {
                            textMod2.Content = "您扫描的是您自己的二维码!";
                        }
                        else
                        {
                            mu.ParentUserID = DataConvert.CLng(reqMod.EventKey).ToString();
                            if (pmu != null && pmu.UserID > 0)
                            {
                                string err = "";
                                if (CheckParentUser(pmu.UserID, mu.UserID, ref err))
                                {
                                    mu.ParentUserID = pmu.UserID.ToString();
                                    if (buser.UpdateByID(mu))
                                    {
                                        textMod2.Content = "您成功绑定了推荐人:" + pmu.TrueName + "!";
                                    }

                                    else
                                    {
                                        textMod2.Content = "绑定推荐人失败!";
                                    }
                                }
                                else
                                {
                                    textMod2.Content = "绑定推荐失败,错误信息:" + err;
                                }
                            }
                            else
                            {
                                textMod2.Content = "绑定推荐失败,推荐人不存在!";
                            }
                        }
                        RepToClient(textMod2.ToXML());
                    }
                }
            }
            break;

        default:
            break;
        }
    }