Beispiel #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            /*
             * 1.保存Token、链接、公众号名称,并且设置注册也验证状态都为开启状态;
             * 2.保存或者更改注册回复;
             * 3.保存或者更改菜单回复;
             *
             */

            try
            {
                user = Comm.DataLoadTool.GetCurrUserModel();
                user.WeixinPublicName = this.txtWeinxinPublicName.Text.Trim();
                user.WeixinAPIUrl     = this.lbURL.Text.Trim();
                user.WeixinToken      = this.txtToken.Text.Trim();

                user.WeixinIsEnableMenu = int.Parse(rblEnableMenu.SelectedValue);
                user.IsWeixinVerify     = int.Parse(rblIsWeixinVerify.SelectedValue);

                user.WeixinAppId     = txtAppId.Text;
                user.WeixinAppSecret = txtAppSecret.Text;
                if (user.WeixinIsEnableMenu == 0)
                {
                    weixinBll.DeleteWeixinClientMenu(weixinBll.GetAccessToken(user.UserID));
                }



                //关闭内定注册模块
                user.WeixinIsOpenReg      = 0;
                user.WeixinRegIsVerifySMS = 0;

                this.userBll.Update(user);

                ZentCloud.BLLJIMP.Model.WeixinReplyRuleInfo regModel = weixinBll.Get <ZentCloud.BLLJIMP.Model.WeixinReplyRuleInfo>(string.Format(" UserID = '{0}' and RuleType = 3 ", user.UserID));

                if (regModel != null)
                {
                    regModel.MsgKeyword = this.txtRegKeyWord.Text.Trim();
                    this.weixinBll.Update(regModel);
                }
                else
                {
                    regModel = new WeixinReplyRuleInfo();
                    regModel.ReplyContent = "请输入手机号码进行注册";
                    regModel.ReplyType    = "text";
                    regModel.ReceiveType  = "text";
                    regModel.MatchType    = "全文匹配";
                    regModel.UserID       = user.UserID;
                    regModel.UID          = this.weixinBll.GetGUID(BLLJIMP.TransacType.WeixinReplyRuleAdd);
                    regModel.RuleType     = 3;
                    regModel.MsgKeyword   = this.txtRegKeyWord.Text.Trim();
                    regModel.CreateDate   = DateTime.Now;
                    this.weixinBll.Add(regModel);
                }

                ZentCloud.BLLJIMP.Model.WeixinReplyRuleInfo menuModel = weixinBll.Get <ZentCloud.BLLJIMP.Model.WeixinReplyRuleInfo>(string.Format(" UserID = '{0}' and RuleType = 4 ", user.UserID));

                if (menuModel != null)
                {
                    menuModel.MsgKeyword   = this.txtMenuKeyWord.Text.Trim();
                    menuModel.ReplyContent = this.txtMenuContent.Text.Trim();
                    this.weixinBll.Update(menuModel);
                }
                else
                {
                    menuModel = new WeixinReplyRuleInfo();
                    menuModel.ReplyContent = this.txtMenuContent.Text.Trim();
                    menuModel.ReplyType    = "text";
                    menuModel.ReceiveType  = "text";
                    menuModel.MatchType    = "全文匹配";
                    menuModel.UserID       = user.UserID;
                    menuModel.UID          = this.weixinBll.GetGUID(BLLJIMP.TransacType.WeixinReplyRuleAdd);
                    menuModel.RuleType     = 4;
                    menuModel.MsgKeyword   = this.txtMenuKeyWord.Text.Trim();
                    menuModel.CreateDate   = DateTime.Now;
                    this.weixinBll.Add(menuModel);
                }

                //添加默认注册流程
                if (this.weixinBll.GetList <WXFlowInfo>(string.Format(" UserID = '{0}' and FlowSysType = 3", user.UserID)).Count.Equals(0))
                {
                    this.weixinBll.AddUserDefaultFlow(user.UserID);
                }

                this.ShowMessge("保存成功!");
            }
            catch (Exception ex)
            {
                this.ShowMessge("保存失败:" + ex.Message);
            }
        }