Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            logger.Info(this.Request.Url.AbsoluteUri);

            //http%3a%2f%2f112.64.17.80%2fwechat%2fBusinessPolicyQuery.aspx%3fsearch_scope%3dvalidate%26messageType%3dnotice%26agentId%3d6
            //http%3a%2f%2f112.64.17.80%2fwechat%2fBusinessPolicyQuery.aspx%3fsearch_scope%3dvalidate%26messageType%3dnotice
            String myUrl = "http://112.64.17.80/wechat/CaseQuery.aspx?agentId=10";
             myUrl = this.Server.UrlEncode(myUrl);
            string code = Request.QueryString["code"];
            string state = Request.QueryString["state"];
           // string search_scope = Request.QueryString["search_scope"];
            string agentId = Request.QueryString["agentId"];
            logger.Info("agentId=" + Request.QueryString["agentId"]);
            logger.Info("code=" + Request.QueryString["code"]);
            logger.Info("state=" + Request.QueryString["state"]);
           // logger.Info("search_scope=" + Request.QueryString["search_scope"]);
             WechatUtil wechatUtil = new Util.WechatUtil();
             HttpResult result = wechatUtil.getUserInfoFromWechat(code, agentId, MyConstant.ScretId);
            logger.Info("result=" + result.Html);
            if (result != null && result.Html != null && result.Html.Contains("UserId"))
            {
                WechatUserId returnMessage = (WechatUserId)JsonConvert.DeserializeObject(result.Html, typeof(WechatUserId));

                AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
                AgentWechatAccount agentWechatAccount = agentWechatAccountDao.Get(returnMessage.UserId);

                if (agentWechatAccount != null && !String.IsNullOrEmpty(agentWechatAccount.status) && !agentWechatAccount.status.Equals("Y"))
                {
                    this.lblTitle.Text = "你的账号已被停用,请联系联通工作人员!";
                    //  sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                    // sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "对不起,你的账号已被停用,请联系联通工作人员!\n\n");

                }
                else if (agentWechatAccount == null)
                {
                    this.lblTitle.Text = "用户不存在,请联系联通工作人员!";
                    //sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                    // sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "用户不存在,请联系联通工作人员!\n\n");
                }
                else
                {
                    String agentNo = agentWechatAccount.branchNo;
                    if (String.IsNullOrEmpty(agentNo))
                    {
                        agentNo = agentWechatAccount.agentNo;
                    }


                    bindDataToGrid("", agentNo, agentWechatAccount.contactId);
                }
            }
            else
            {
                //bindDataToGrid("", "P001","P001");
            }
          

        }
Exemplo n.º 2
0
        public HttpResult sendTextMessageToWechat(String toUser, String content, string corpId, String Wechat_Secret, int agentid)
        {
            WechatUtil wechatUtil = new WechatUtil();
            String accessToken = wechatUtil.GetAccessTokenNoCache(corpId, Wechat_Secret);

            var msgUrl = string.Format("https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={0}", accessToken);


            var msgData = new
            {

                touser = toUser,
                msgtype = "text",
                agentid = agentid,
                safe = 0,
                text = new
                {

                    content = content
                }
            };

            string msgJson = JsonConvert.SerializeObject(msgData, Formatting.Indented);



            HttpHelper httpHelper = new HttpHelper();
            HttpItem item = new HttpItem()
            {
                Encoding = Encoding.GetEncoding("UTF-8"),
                URL = msgUrl,
                Method = "post",//URL     可选项 默认为Get
                Postdata = msgJson,
                PostEncoding = Encoding.GetEncoding("UTF-8")//可以发送中文消息了,开心

            };

            HttpResult result = httpHelper.GetHtml(item);

            return result;
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            logger.Info(this.Request.Url.AbsoluteUri);

            //bindDataToGrid("", "政策", "validate", "DL204053", "P001");
            //http%3a%2f%2f112.64.17.80%2fwechat%2fBusinessPolicyQuery.aspx%3fsearch_scope%3dvalidate%26messageType%3dnotice%26agentId%3d6
            //http%3a%2f%2f112.64.17.80%2fwechat%2fBusinessPolicyQuery.aspx%3fsearch_scope%3dvalidate%26messageType%3dnotice
            //String myUrl = "http://112.64.17.80/wechat/BusinessPolicyQuery.aspx?search_scope=validate&messageType=notice&agentId=6";
            // myUrl = this.Server.UrlEncode(myUrl);
            string code = Request.QueryString["code"];
            string state = Request.QueryString["state"];
            string search_scope = Request.QueryString["search_scope"];
            string agentId = Request.QueryString["agentId"];
            logger.Info("agentId=" + Request.QueryString["agentId"]);
            logger.Info("code=" + Request.QueryString["code"]);
            logger.Info("state=" + Request.QueryString["state"]);
            logger.Info("search_scope=" + Request.QueryString["search_scope"]);
             WechatUtil wechatUtil = new Util.WechatUtil();
             HttpResult result = wechatUtil.getUserInfoFromWechat(code, agentId, MyConstant.ScretId);
            logger.Info("result=" + result.Html);
            if (result != null && result.Html != null && result.Html.Contains("UserId"))
            {
                WechatUserId returnMessage = (WechatUserId)JsonConvert.DeserializeObject(result.Html, typeof(WechatUserId));

                AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
                AgentWechatAccount agentWechatAccount = agentWechatAccountDao.Get(returnMessage.UserId);

                if (agentWechatAccount != null && !String.IsNullOrEmpty(agentWechatAccount.status) && !agentWechatAccount.status.Equals("Y"))
                {
                    this.lblType.Text = "你的账号已被停用,请联系联通工作人员!";
                    //  sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                    // sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "对不起,你的账号已被停用,请联系联通工作人员!\n\n");

                }
                else if (agentWechatAccount == null)
                {
                    this.lblType.Text = "用户不存在,请联系联通工作人员!";
                    //sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                    // sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "用户不存在,请联系联通工作人员!\n\n");
                }
                else
                {
                    String agentNo = agentWechatAccount.branchNo;
                    if (String.IsNullOrEmpty(agentNo))
                    {
                        agentNo = agentWechatAccount.agentNo;
                    }


                   // search_scope = "all";
                    String type = "通知公告/重点关注";
                    if (!String.IsNullOrEmpty(state) && state.Equals("myNotice"))
                    {
                        type = "通知公告/重点关注";
                    }

                    if (!String.IsNullOrEmpty(state) && state.Equals("policy"))
                    {
                        type = "政策";
                    }

                    if (!String.IsNullOrEmpty(state) && state.Equals("rule"))
                    {
                        type = "服务规范";
                    }


                    WechatQueryLog wechatQueryLog = new ChinaUnion_BO.WechatQueryLog();
                    wechatQueryLog.agentName = "";
                    wechatQueryLog.module = Util.MyConstant.module_Notice;
                    wechatQueryLog.subSystem = "通知公告与促销政策";
                    wechatQueryLog.queryTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    wechatQueryLog.queryString = type;
                    wechatQueryLog.wechatId = agentWechatAccount.contactId;
                    WechatQueryLogDao wechatQueryLogDao = new WechatQueryLogDao();
                    try
                    {
                        wechatQueryLogDao.Add(wechatQueryLog);
                    }
                    catch
                    {
                    }

                    bindDataToGrid("", type, search_scope, agentNo, agentWechatAccount.contactId);
                }
            }
          

        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string sequence =  Request.QueryString["seq"];
            string userId =  Request.QueryString["userId"];
            logger.Info("sequence=" + sequence);
            logger.Info("userId=" + userId);

            if (String.IsNullOrEmpty(sequence))
            {
                string code = Request.QueryString["code"];
                sequence = Request.QueryString["state"];
                string search_scope = Request.QueryString["search_scope"];
                string agentId = Request.QueryString["agentId"];
                logger.Info("agentId=" + Request.QueryString["agentId"]);
                logger.Info("code=" + Request.QueryString["code"]);
                logger.Info("state=" + Request.QueryString["state"]);
                logger.Info("search_scope=" + Request.QueryString["search_scope"]);
                WechatUtil wechatUtil = new Util.WechatUtil();
                HttpResult result = wechatUtil.getUserInfoFromWechat(code, agentId, MyConstant.ScretId);
                logger.Info("result=" + result.Html);
                if (result != null && result.Html != null && result.Html.Contains("UserId"))
                {
                    WechatUserId returnMessage = (WechatUserId)JsonConvert.DeserializeObject(result.Html, typeof(WechatUserId));
                    userId = returnMessage.UserId;
                }
                
            }
            if (!String.IsNullOrEmpty(sequence))
            {
                PolicyDao policyDao = new ChinaUnion_DataAccess.PolicyDao();
                Policy policy = policyDao.Get(Int32.Parse(sequence));
                if (policy != null)
                {
                    this.lblSubject.Text = policy.subject;
                    this.lblSendTime.Text = policy.creatTime;
                    if (!String.IsNullOrEmpty(policy.content))
                    {
                        this.lblContent.Text = policy.content.Replace("\r\n"," <br>").Replace("\n"," <br>");
                    }
                    this.lblValidateStartTime.Text = policy.validateStartTime;
                    this.lblValidateEndTime.Text = policy.validateEndTime;
                    this.lblAttachment.Text = policy.attachmentName;
                    this.lblAttachment.NavigateUrl = "BusinessPolicyAttachmentDetail.aspx?seq=" + policy.sequence + "&userId=" + userId;

                    logger.Info("sequence=" + sequence);
                    logger.Info("userId=" + userId);
                    PolicyReceiverLogDao policyReceiverLogDao = new PolicyReceiverLogDao();
                    PolicyReceiverLog policyReceiverLog = new PolicyReceiverLog();
                    policyReceiverLog.policySequence = policy.sequence;
                    policyReceiverLog.readtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    policyReceiverLog.userId = userId;
                    policyReceiverLogDao.Add(policyReceiverLog);


                    WechatQueryLog wechatQueryLog = new ChinaUnion_BO.WechatQueryLog();
                    wechatQueryLog.agentName = "";
                    wechatQueryLog.module = Util.MyConstant.module_Notice;
                    wechatQueryLog.subSystem = "通知公告与促销政策";
                    wechatQueryLog.queryTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    wechatQueryLog.queryString = policy.type;
                    wechatQueryLog.wechatId = userId;
                    WechatQueryLogDao wechatQueryLogDao = new WechatQueryLogDao();
                    try
                    {
                        wechatQueryLogDao.Add(wechatQueryLog);
                    }
                    catch
                    {
                    }
                }
            }
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {

            //https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx31204de5a3ae758e&redirect_uri=http%3a%2f%2f112.64.17.80%2fwechat%2fMyExamQuery.aspx%3fstatus%3dnew%26messageType%3dexam%26agentId%3d11&response_type=code&scope=snsapi_base&state=new#wechat_redirect
            //https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx31204de5a3ae758e&redirect_uri=http%3a%2f%2f112.64.17.80%2fwechat%2fMyExamQuery.aspx%3fstatus%3dfinish%26messageType%3dexam%26agentId%3d11&response_type=code&scope=snsapi_base&state=join#wechat_redirect
            //https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx31204de5a3ae758e&redirect_uri=http%3a%2f%2f112.64.17.80%2fwechat%2fMyExamQuery.aspx%3fstatus%3dnew%26messageType%3dsurvey%26agentId%3d11&response_type=code&scope=snsapi_base&state=new#wechat_redirect
            //https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx31204de5a3ae758e&redirect_uri=http%3a%2f%2f112.64.17.80%2fwechat%2fMyExamQuery.aspx%3fstatus%3dfinish%26messageType%3dsurvey%26agentId%3d11&response_type=code&scope=snsapi_base&state=join#wechat_redirect
            //String myUrl = "http://112.64.17.80/wechat/MyExamQuery.aspx?status=new&messageType=exam&agentId=11";
            // myUrl = this.Server.UrlEncode(myUrl);

            logger.Info(this.Request.Url.AbsoluteUri);
            string code = Request.QueryString["code"];
            string state = Request.QueryString["state"];
            string messageType = Request.QueryString["messageType"];
            string agentId = Request.QueryString["agentId"];
            string status = Request.QueryString["status"];
            logger.Info("agentId=" + Request.QueryString["agentId"]);
            logger.Info("code=" + Request.QueryString["code"]);
            logger.Info("state=" + Request.QueryString["state"]);
            logger.Info("messageType=" + Request.QueryString["messageType"]);
            logger.Info("status=" + Request.QueryString["status"]);
             WechatUtil wechatUtil = new Util.WechatUtil();
             HttpResult result = wechatUtil.getUserInfoFromWechat(code, agentId, MyConstant.ScretId);
            logger.Info("result=" + result.Html);
            if (result != null && result.Html != null && result.Html.Contains("UserId"))
            {
                WechatUserId returnMessage = (WechatUserId)JsonConvert.DeserializeObject(result.Html, typeof(WechatUserId));

                logger.Info("returnMessage userId=" + returnMessage.UserId);

                AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
                AgentWechatAccount agentWechatAccount = agentWechatAccountDao.Get(returnMessage.UserId);

                if (agentWechatAccount != null && !String.IsNullOrEmpty(agentWechatAccount.status) && !agentWechatAccount.status.Equals("Y"))
                {
                    this.lblType.Text = "你的账号已被停用,请联系联通工作人员!";
                    //  sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                    // sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "对不起,你的账号已被停用,请联系联通工作人员!\n\n");

                }
                else if (agentWechatAccount == null)
                {
                    this.lblType.Text = "用户不存在,请联系联通工作人员!";
                    //sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                    // sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "用户不存在,请联系联通工作人员!\n\n");
                }
                else
                {
                    String agentNo = agentWechatAccount.branchNo;
                    if (String.IsNullOrEmpty(agentNo))
                    {
                        agentNo = agentWechatAccount.agentNo;
                    }
                   

                    //this.lblUserId.Text = agentWechatAccount.contactId;

                    this.Session.Add("userId", agentWechatAccount.contactId);
                    this.Session.Add("messageType", messageType);
                    this.Session.Add("status", status);
                    bindDataToGrid("");
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            logger.Info(this.Request.Url.AbsoluteUri);

           
            string code = Request.QueryString["code"];
            string state = Request.QueryString["state"];
            
            logger.Info("code=" + Request.QueryString["code"]);
            logger.Info("state=" + Request.QueryString["state"]);

            if (!String.IsNullOrEmpty(code))
            {
                WechatUtil wechatUtil = new Util.WechatUtil();
                HttpResult result = wechatUtil.getUserInfoFromWechat(code, "9", "stkc3kfO0sCrIJTFCHzOhmEsRWAnVGHqrzBIy4le6mV6EcSkNbpY0Tt49Uci2Buu");
                logger.Info("result=" + result.Html);
                if (result != null && result.Html != null && result.Html.Contains("UserId"))
                {
                    WechatUserId returnMessage = (WechatUserId)JsonConvert.DeserializeObject(result.Html, typeof(WechatUserId));

                    AgentWechatAccountDao agentWechatAccountDao = new AgentWechatAccountDao();
                    AgentWechatAccount agentWechatAccount = agentWechatAccountDao.Get(returnMessage.UserId);

                    if (agentWechatAccount != null && !String.IsNullOrEmpty(agentWechatAccount.status) && !agentWechatAccount.status.Equals("Y"))
                    {
                        this.lblType.Text = "你的账号已被停用,请联系联通工作人员!";
                        //  sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                        // sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "对不起,你的账号已被停用,请联系联通工作人员!\n\n");

                    }
                    else if (agentWechatAccount == null)
                    {
                        this.lblType.Text = "用户不存在,请联系联通工作人员!";
                        //sb.AppendFormat("<MsgType><![CDATA[text]]></MsgType>");
                        // sb.AppendFormat("<Content><![CDATA[{0}]]></Content>", "用户不存在,请联系联通工作人员!\n\n");
                    }
                    else
                    {
                        String agentNo = agentWechatAccount.branchNo;
                        if (String.IsNullOrEmpty(agentNo))
                        {
                            agentNo = agentWechatAccount.agentNo;
                        }
                        String type = "吐槽";
                        if (!String.IsNullOrEmpty(state) && state.Equals("complain"))
                        {
                            type = "吐槽";
                            this.lblTitle.Text = "吐槽历史";
                        }

                        if (!String.IsNullOrEmpty(state) && state.Equals("appraise"))
                        {
                            type = "点赞";
                            this.lblTitle.Text = "点赞历史";
                        }

                        if (!String.IsNullOrEmpty(state) && state.Equals("suggestion"))
                        {
                            type = "建议";
                            this.lblTitle.Text = "建议历史";
                        }
                        WechatQueryLog wechatQueryLog = new ChinaUnion_BO.WechatQueryLog();
                        wechatQueryLog.agentName = "";
                        wechatQueryLog.module = Util.MyConstant.module_Service;
                        wechatQueryLog.subSystem = "服务监督";
                        wechatQueryLog.queryTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        wechatQueryLog.queryString = type;
                        wechatQueryLog.wechatId = agentWechatAccount.contactId;
                        WechatQueryLogDao wechatQueryLogDao = new WechatQueryLogDao();
                        try
                        {
                            wechatQueryLogDao.Add(wechatQueryLog);
                        }
                        catch
                        {
                        }

                        bindDataToGrid("", type, agentNo, returnMessage.UserId);
                    }
                }
            }
            else
            {
                string type = Request.QueryString["type"];
                string agentNo = Request.QueryString["agentNo"];
                string userId = Request.QueryString["userId"];
                if (!String.IsNullOrEmpty(type) && !String.IsNullOrEmpty(agentNo))
                {
                    bindDataToGrid("", type, agentNo, userId);
                }
            }
        }