/// <summary>
        /// 修改
        /// </summary>
        public static string Edit(HttpContext context)
        {
            var uid = context.Request["UID"];
            //var userId = websiteOwner;//Comm.DataLoadTool.GetCurrUserID();
            //if (string.IsNullOrEmpty(userid))
            //{
            //    return "请重新登录";
            //}
            var keyword   = context.Request["MsgKeyword"];
            var matchType = context.Request["MatchType"];
            var oldInfo   = bll.Get <WeixinReplyRuleInfo>(string.Format("UID={0}", uid));

            if (oldInfo.MsgKeyword != keyword)//对比关键字已经改变
            {
                //关键字改变,检查关键字是否重复
                if (!bll.CheckUserKeyword(websiteOwner, keyword))
                {
                    return("关键字重复");
                }
            }

            var model = new WeixinReplyRuleInfo();

            model.UID          = uid;
            model.MsgKeyword   = keyword;
            model.MatchType    = matchType;
            model.ReplyContent = context.Request["ReplyContent"];
            model.ReceiveType  = "text";
            model.ReplyType    = "text";
            model.CreateDate   = DateTime.Now;
            model.RuleType     = 1;
            model.UserID       = websiteOwner;
            return(bll.Update(model).ToString().ToLower());
        }
Example #2
0
        /// <summary>
        /// 添加
        /// </summary>
        private static string Add(HttpContext context)
        {
            //if (!_isedit)
            //{
            //    return null;
            //}

            try
            {
                //var userid = websiteOwner; //Comm.DataLoadTool.GetCurrUserID();
                //if (string.IsNullOrEmpty(userid))
                //{
                //    return "请重新登录";
                //}
                var keyword   = context.Request["MsgKeyword"];
                var matchtype = context.Request["MatchType"];
                if (!bll.CheckUserKeyword(websiteOwner, keyword))
                {
                    return("关键字重复");
                }
                var model = new WeixinReplyRuleInfo();
                model.MsgKeyword  = keyword;
                model.MatchType   = matchtype;
                model.ReceiveType = "news";
                model.ReplyType   = "news";
                model.CreateDate  = DateTime.Now;
                model.RuleType    = 1;
                var sourceIds = context.Request["SourceIds"];
                model.UID    = bll.GetGUID(BLLJIMP.TransacType.WeixinReplyRuleAdd);
                model.UserID = websiteOwner;
                WeixinReplyRuleImgsInfo ruleImgsInfo;
                if (bll.Add(model))//规则表添加成功,往图文表插入
                {
                    if (!string.IsNullOrEmpty(sourceIds))
                    {
                        foreach (var item in sourceIds.Split(','))
                        {
                            var sourceinfo = bll.Get <WeixinMsgSourceInfo>(string.Format("SourceID='{0}'", item));
                            ruleImgsInfo             = new WeixinReplyRuleImgsInfo();
                            ruleImgsInfo.UID         = bll.GetGUID(BLLJIMP.TransacType.WeixinReplyRuleImgAdd);
                            ruleImgsInfo.RuleID      = model.UID;
                            ruleImgsInfo.Title       = sourceinfo.Title;
                            ruleImgsInfo.Description = sourceinfo.Description;
                            ruleImgsInfo.PicUrl      = sourceinfo.PicUrl;
                            ruleImgsInfo.Url         = sourceinfo.Url;
                            bll.Add(ruleImgsInfo);
                        }
                        return("true");
                    }
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }

            return("false");
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.user          = userBll.GetCurrWebSiteUserInfo();
            menuModel          = weixinBll.Get <ZentCloud.BLLJIMP.Model.WeixinReplyRuleInfo>(string.Format(" UserID = '{0}' and RuleType = 4 ", user.UserID));
            currentWebsiteInfo = userBll.GetWebsiteInfoModelFromDataBase();
            OauthDomain        = ZentCloud.Common.ConfigHelper.GetConfigString("WeixinOpenOAuthDoMain");
            WebsiteInfo model = bllWeisite.GetWebsiteInfo();

            if (model != null && !string.IsNullOrEmpty(model.WeiXinBindDomain))
            {
                strDomain = model.WeiXinBindDomain;
            }
        }
        /// <summary>
        /// 添加
        /// </summary>
        private static string Add(HttpContext context)
        {
            //if (!_isedit)
            //{
            //    return null;
            //}

            try
            {
                //var userid = websiteOwner;
                //if (string.IsNullOrEmpty(userid))
                //{
                //    return "请重新登录";
                //}
                var keyword   = context.Request["MsgKeyword"];
                var matchType = context.Request["MatchType"];
                if (!bll.CheckUserKeyword(websiteOwner, keyword))
                {
                    return("关键字重复");
                }
                var model = new WeixinReplyRuleInfo();
                model.MsgKeyword   = keyword;
                model.MatchType    = matchType;
                model.ReplyContent = context.Request["ReplyContent"];
                model.ReceiveType  = "text";
                model.ReplyType    = "text";
                model.CreateDate   = DateTime.Now;
                model.RuleType     = 1;
                model.UID          = bll.GetGUID(BLLJIMP.TransacType.WeixinReplyRuleAdd);
                model.UserID       = websiteOwner;
                return(bll.Add(model).ToString().ToLower());
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }

            //return "false";
        }
Example #5
0
        private static string Edit(HttpContext context)
        {
            //if (!_isedit)
            //{
            //    return null;
            //}

            try
            {
                var uid = context.Request["UID"];
                //if (string.IsNullOrEmpty(userid))
                //{
                //    return "请重新登录";
                //}
                var keyword   = context.Request["MsgKeyword"];
                var matchType = context.Request["MatchType"];
                var oldInfo   = bll.Get <WeixinReplyRuleInfo>(string.Format("UID={0}", uid));
                if (oldInfo.MsgKeyword != keyword)//对比关键字已经改变
                {
                    //关键字改变,检查关键字是否重复
                    if (!bll.CheckUserKeyword(websiteOwner, keyword))
                    {
                        return("关键字重复");
                    }
                }
                var sourceType = context.Request["SourceType"];
                var sourceIds  = context.Request["SourceIds"];
                var model      = new WeixinReplyRuleInfo();
                model.UID         = uid;
                model.MsgKeyword  = keyword;
                model.MatchType   = matchType;
                model.ReceiveType = "news";
                model.ReplyType   = "news";
                model.RuleType    = 1;
                model.UID         = context.Request["UID"];
                model.UserID      = websiteOwner;
                WeixinReplyRuleImgsInfo ruleImgsInfo;
                if (bll.Update(model))//规则表更新成功,更新图文表信息
                {
                    if (!string.IsNullOrEmpty(sourceIds))
                    {
                        if (sourceType.Equals("imagelist"))//原有的图文表
                        {
                            //更新图文列表
                            bll.Delete(new WeixinReplyRuleImgsInfo(), string.Format("RuleID='{0}' And UID Not IN ({1})", uid, sourceIds));
                            return("true");
                        }
                        else if (sourceType.Equals("source"))//从素材表中选择
                        {
                            //删除旧图片
                            bll.Delete(new WeixinReplyRuleImgsInfo(), string.Format("RuleID='{0}'", uid));
                            //添加新图片
                            foreach (var item in sourceIds.Split(','))
                            {
                                var sourceInfo = bll.Get <WeixinMsgSourceInfo>(string.Format("SourceID='{0}'", item));
                                ruleImgsInfo             = new WeixinReplyRuleImgsInfo();
                                ruleImgsInfo.UID         = bll.GetGUID(BLLJIMP.TransacType.WeixinReplyRuleImgAdd);
                                ruleImgsInfo.RuleID      = model.UID;
                                ruleImgsInfo.Title       = sourceInfo.Title;
                                ruleImgsInfo.Description = sourceInfo.Description;
                                ruleImgsInfo.PicUrl      = sourceInfo.PicUrl;
                                ruleImgsInfo.Url         = sourceInfo.Url;
                                bll.Add(ruleImgsInfo);
                            }
                            return("true");
                        }
                    }
                    else
                    {
                        return("请选择素材");
                    }
                }
                else
                {
                    return("更新规则表失败");
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }

            return("false");
        }
Example #6
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);
            }
        }
Example #7
0
        /// <summary>
        /// 保存规则
        /// </summary>
        private void SaveRule()
        {
            WeixinReplyRuleInfo model = new WeixinReplyRuleInfo();

            model.MsgKeyword = this.txtKeyWord.Text.Trim();

            if (CheckIsEmpty(model.MsgKeyword, "关键字不能为空!"))
            {
                this.txtKeyWord.Focus();
                return;
            }

            //判断关键字不能重复
            if (this.weixinBll.Exists(model, "MsgKeyword"))
            {
                this.ShowMessge("该关键字已经存在!");
                return;
            }

            switch (this.rdoListReplyType.SelectedItem.Text)
            {
            case "文本":
                model.ReplyContent = this.txtTextContent.Text.Trim();
                if (CheckIsEmpty(model.ReplyContent, "回复内容不能为空!"))
                {
                    this.txtTextContent.Focus();
                    return;
                }
                model.ReplyType = "text";
                model.UID       = this.weixinBll.GetGUID(TransacType.WeixinReplyRuleAdd);

                break;

            case "图文":
                model.ReplyType = "news";
                // 保存图文
                List <BLLJIMP.Model.Weixin.Article> imgList = this.GetVistateImgList();

                if (imgList.Count <= 0)
                {
                    this.ShowMessge("图文消息图片数量不能为 0 !");
                    return;
                }
                model.UID = this.weixinBll.GetGUID(TransacType.WeixinReplyRuleAdd);

                List <WeixinReplyRuleImgsInfo> imgModelList = new List <WeixinReplyRuleImgsInfo>();
                int tmpOrderIndex = 0;
                foreach (var item in imgList)
                {
                    WeixinReplyRuleImgsInfo imgModel = new WeixinReplyRuleImgsInfo();
                    imgModel.UID         = this.weixinBll.GetGUID(TransacType.WeixinReplyRuleImgAdd);
                    imgModel.RuleID      = model.UID;
                    imgModel.Description = item.Description;
                    imgModel.OrderIndex  = tmpOrderIndex;
                    imgModel.PicUrl      = item.PicUrl;
                    imgModel.Title       = item.Title;
                    imgModel.Url         = item.Url;
                    tmpOrderIndex++;
                    imgModelList.Add(imgModel);
                }

                if (!this.weixinBll.AddList <WeixinReplyRuleImgsInfo>(imgModelList))
                {
                    this.ShowMessge("保存图片失败!");
                    return;
                }

                break;

            default:
                break;
            }


            model.UserID      = this.userInfo.UserID;
            model.ReceiveType = "text";//目前默认只接收文本推送信息处理
            model.MatchType   = this.ddlMatchType.SelectedItem.Text;
            model.CreateDate  = DateTime.Now;

            if (this.weixinBll.Add(model))
            {
                //this.ShowMessge("添加成功!");

                this.ViewState["imgData"] = null;

                this.LoadData();

                this.ClearAddPanel();
                //this.HideAddPanel();
            }
            else
            {
                this.ShowMessge("添加失败!");
            }
        }