protected void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.tdCustomerAccount.Value))
            {
                this.tdResponse.Text = "客服帐号不能为空";
                return;
            }
            if (string.IsNullOrEmpty(this.tdOpenID.Value))
            {
                this.tdResponse.Text = "用户OpenID不能为空";
                return;
            }
            var result = MessageHandler.CreateCustomerService(WeixinHelper.GetAccessToken(null), this.tdCustomerAccount.Value, this.tdOpenID.Value);

            this.tdResponse.Text = result.Body;
        }
Пример #2
0
        public static bool GrabWechat_Chat(int UserID, Foresight.DataAccess.Wechat_ChatRequest chat_request, out string errormsg, out Foresight.DataAccess.Wechat_ServiceUser user)
        {
            errormsg = string.Empty;
            user     = null;
            List <SqlParameter> parameters = new List <SqlParameter>();

            using (SqlHelper helper = new SqlHelper())
            {
                if (chat_request == null)
                {
                    errormsg = "其他客服已接单";
                    return(false);
                }
                user = Foresight.DataAccess.Wechat_ChatRequest.GetWechat_ServiceUserByUserID(UserID, helper);
                if (user == null)
                {
                    errormsg = "您不是客服人员";
                    return(false);
                }
                var result = MessageHandler.CreateCustomerService(WeixinHelper.GetAccessToken(null), user.AccountName, chat_request.OpenID);
                if (result.IsError)
                {
                    errormsg = result.ErrorMsg;
                    return(false);
                }
                try
                {
                    helper.BeginTransaction();
                    bool update_result = Foresight.DataAccess.Wechat_ChatRequest.SaveWechat_ChatRequestByUserID(UserID, chat_request.ID, helper);
                    helper.Commit();
                    if (update_result)
                    {
                        return(true);
                    }
                    errormsg = "其他客服已接单";
                    return(false);
                }
                catch (Exception ex)
                {
                    errormsg = ex.Message;
                    helper.Rollback();
                    return(false);
                }
            }
        }