Exemplo n.º 1
0
        private bool DoAdd()
        {
            bool result = false;

            Model.weixin_request_rule model = new Model.weixin_request_rule();
            BLL.weixin_request_rule   bll   = new BLL.weixin_request_rule();

            model.name          = "文本回复";
            model.request_type  = 1;
            model.response_type = 1;
            model.account_id    = Utils.StrToInt(ddlAccountId.SelectedValue, 0);
            model.keywords      = txtKeywords.Text.Trim();
            model.is_like_query = Utils.StrToInt(rblIsLikeQuery.SelectedValue, 0);
            model.sort_id       = Utils.StrToInt(txtSortId.Text.Trim(), 99);
            List <Model.weixin_request_content> ls = new List <Model.weixin_request_content>();

            ls.Add(new Model.weixin_request_content()
            {
                account_id = model.account_id, content = txtContent.Text.Trim()
            });
            model.contents = ls;

            if (bll.Add(model) > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加微信文本回复,关健字:" + model.keywords); //记录日志
                result = true;
            }
            return(result);
        }
Exemplo n.º 2
0
        private bool DoAdd(out string errmsg)
        {
            Model.weixin_request_rule model = new Model.weixin_request_rule();
            BLL.weixin_request_rule   bll   = new BLL.weixin_request_rule();

            model.name          = "语音回复";
            model.request_type  = 1;
            model.response_type = 3;
            model.keywords      = txtKeywords.Text.Trim();
            model.is_like_query = Utils.StrToInt(rblIsLikeQuery.SelectedValue, 0);
            model.sort_id       = Utils.StrToInt(txtSortId.Text.Trim(), 99);
            List <Model.weixin_request_content> ls = new List <Model.weixin_request_content>();
            //上传素材到微信服务器
            string mediaId = new API.Weixin.Common.CRMComm().UploadForeverMedia(Utils.GetMapPath(txtImgUrl.Text.Trim()), out errmsg);

            if (!string.IsNullOrEmpty(errmsg))
            {
                return(false);
            }
            ls.Add(new Model.weixin_request_content()
            {
                account_id = model.account_id, title = txtTitle.Text.Trim(), img_url = txtImgUrl.Text.Trim(),
                media_id   = mediaId, media_url = txtMediaUrl.Text.Trim(), meida_hd_url = txtMediaUrl.Text.Trim(), content = txtContent.Text.Trim()
            });
            model.contents = ls;

            if (bll.Add(model) > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加微信语音回复,关健字:" + model.keywords); //记录日志
                errmsg = string.Empty;
                return(true);
            }
            errmsg = "保存过程中出错!";
            return(false);
        }
Exemplo n.º 3
0
        private bool DoAdd()
        {
            bool result = false;

            Model.weixin_request_rule model = new Model.weixin_request_rule();
            BLL.weixin_request_rule   bll   = new BLL.weixin_request_rule();

            model.name          = "图文回复";
            model.request_type  = 1; //关键词回复
            model.response_type = 2; //回复的类型:文本1,图文2,语音3,视频4,第三方接口5
            model.account_id    = Utils.StrToInt(ddlAccountId.SelectedValue, 0);
            model.keywords      = txtKeywords.Text.Trim();
            model.is_like_query = Utils.StrToInt(rblIsLikeQuery.SelectedValue, 0);
            model.sort_id       = Utils.StrToInt(txtSortId.Text.Trim(), 99);

            #region 赋值规则图片
            string[] itemIdArr      = Request.Form.GetValues("item_id");
            string[] itemTitleArr   = Request.Form.GetValues("item_title");
            string[] itemContentArr = Request.Form.GetValues("item_content");
            string[] itemImgUrlArr  = Request.Form.GetValues("item_imgurl");
            string[] itemLinkUrlArr = Request.Form.GetValues("item_linkurl");
            string[] itemSortIdArr  = Request.Form.GetValues("item_sortid");
            if (itemIdArr != null && itemTitleArr != null && itemImgUrlArr != null && itemLinkUrlArr != null && itemSortIdArr != null && itemContentArr != null)
            {
                if ((itemIdArr.Length == itemTitleArr.Length) && (itemTitleArr.Length == itemImgUrlArr.Length) && (itemImgUrlArr.Length == itemLinkUrlArr.Length) &&
                    (itemLinkUrlArr.Length == itemSortIdArr.Length) && (itemSortIdArr.Length == itemContentArr.Length))
                {
                    List <Model.weixin_request_content> ls = new List <Model.weixin_request_content>();
                    for (int i = 0; i < itemIdArr.Length; i++)
                    {
                        Model.weixin_request_content modelt = new Model.weixin_request_content();
                        modelt.id         = Utils.StrToInt(itemIdArr[i].Trim(), 0);
                        modelt.account_id = model.account_id;
                        modelt.title      = itemTitleArr[i].Trim();
                        modelt.content    = itemContentArr[i].Trim();
                        modelt.img_url    = itemImgUrlArr[i].Trim();
                        modelt.link_url   = itemLinkUrlArr[i].Trim();
                        modelt.sort_id    = Utils.StrToInt(itemSortIdArr[i].Trim(), 99);
                        ls.Add(modelt);
                    }
                    model.contents = ls;
                }
            }
            else
            {
                model.contents = null;
            }
            #endregion

            if (bll.Add(model) > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加微信图文回复,关健字:" + model.keywords); //记录日志
                result = true;
            }
            return(result);
        }
Exemplo n.º 4
0
        private bool DoAdd()
        {
            bool result = false;
            Model.weixin_request_rule model = new Model.weixin_request_rule();
            BLL.weixin_request_rule bll = new BLL.weixin_request_rule();

            model.name = "语音回复";
            model.request_type = 1;
            model.response_type = 3;
            model.account_id = Utils.StrToInt(ddlAccountId.SelectedValue, 0);
            model.keywords = txtKeywords.Text.Trim();
            model.is_like_query = Utils.StrToInt(rblIsLikeQuery.SelectedValue, 0);
            model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99);
            List<Model.weixin_request_content> ls = new List<Model.weixin_request_content>();
            ls.Add(new Model.weixin_request_content() { account_id = model.account_id, title = txtTitle.Text.Trim(), media_url = txtMediaUrl.Text.Trim(), content = txtContent.Text.Trim() });
            model.contents = ls;

            if (bll.Add(model) > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加微信语音回复,关健字:" + model.keywords); //记录日志
                result = true;
            }
            return result;
        }
Exemplo n.º 5
0
        private bool DoAdd()
        {
            bool result = false;
            Model.weixin_request_rule model = new Model.weixin_request_rule();
            BLL.weixin_request_rule bll = new BLL.weixin_request_rule();

            model.name = "图文回复";
            model.request_type = 1; //关键词回复
            model.response_type = 2; //回复的类型:文本1,图文2,语音3,视频4,第三方接口5
            model.account_id = Utils.StrToInt(ddlAccountId.SelectedValue, 0);
            model.keywords = txtKeywords.Text.Trim();
            model.is_like_query = Utils.StrToInt(rblIsLikeQuery.SelectedValue, 0);
            model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99);

            #region 赋值规则图片
            string[] itemIdArr = Request.Form.GetValues("item_id");
            string[] itemTitleArr = Request.Form.GetValues("item_title");
            string[] itemContentArr = Request.Form.GetValues("item_content");
            string[] itemImgUrlArr = Request.Form.GetValues("item_imgurl");
            string[] itemLinkUrlArr = Request.Form.GetValues("item_linkurl");
            string[] itemSortIdArr = Request.Form.GetValues("item_sortid");
            if (itemIdArr != null && itemTitleArr != null && itemImgUrlArr != null && itemLinkUrlArr != null && itemSortIdArr != null && itemContentArr != null)
            {
                if ((itemIdArr.Length == itemTitleArr.Length) && (itemTitleArr.Length == itemImgUrlArr.Length) && (itemImgUrlArr.Length == itemLinkUrlArr.Length)
                    && (itemLinkUrlArr.Length == itemSortIdArr.Length) && (itemSortIdArr.Length == itemContentArr.Length))
                {
                    List<Model.weixin_request_content> ls = new List<Model.weixin_request_content>();
                    for (int i = 0; i < itemIdArr.Length; i++)
                    {
                        Model.weixin_request_content modelt = new Model.weixin_request_content();
                        modelt.id = Utils.StrToInt(itemIdArr[i].Trim(), 0);
                        modelt.account_id = model.account_id;
                        modelt.title = itemTitleArr[i].Trim();
                        modelt.content = itemContentArr[i].Trim();
                        modelt.img_url = itemImgUrlArr[i].Trim();
                        modelt.link_url = itemLinkUrlArr[i].Trim();
                        modelt.sort_id = Utils.StrToInt(itemSortIdArr[i].Trim(), 99);
                        ls.Add(modelt);
                    }
                    model.contents = ls;
                }
            }
            else
            {
                model.contents = null;
            }
            #endregion

            if (bll.Add(model) > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加微信图文回复,关健字:" + model.keywords); //记录日志
                result = true;
            }
            return result;
        }