示例#1
0
        private DtWechatJsapiTicket RenewJsapiTicket(string appId)
        {
            DtWechatJsapiTicket dtWechatJsapiTicket = null;

            var var_AccessToken = this.GetAccessToken(appId);

            if (var_AccessToken == null)
            {
                throw new Exception("获取AccessToken失败");
            }

            string requstUri = string.Format(urlJsapiTicket, var_AccessToken.AccessToken);

            HttpClient client = new HttpClient();
            JsapiTicketModel model_JsapiTicket = client.GetAsync(requstUri).Result.Content.ReadAsAsync<JsapiTicketModel>().Result;

            if (model_JsapiTicket != null && (model_JsapiTicket.ErrCode == null || model_JsapiTicket.ErrCode == 0))
            {
                dtWechatJsapiTicket = new DtWechatJsapiTicket();

                dtWechatJsapiTicket.JsapiTicket = model_JsapiTicket.JsapiTicket;
                dtWechatJsapiTicket.ExpiresIn = model_JsapiTicket.ExpiresIn;
                dtWechatJsapiTicket.AccessTokenId = var_AccessToken.Id;
            }

            return dtWechatJsapiTicket;
        }
示例#2
0
        public int UpdateJsapiTicket(DtWechatJsapiTicket dtWechatJsapiTicket)
        {
            string commandText = @"UPDATE [dbo].[WECHAT_JSAPI_TICKET] 
                SET
                    [SYSTEM_UPDATE_DATETIME] = GETDATE(),
                    [JSAPI_TICKET] = @JSAPI_TICKET,
                    [EXPIRES_IN] = @EXPIRES_IN
                WHERE [PK_ID] = @PK_ID";

            return this.dbHelper.ExecuteNonQuery
                (
                    commandText,
                    new
                    {
                        JSAPI_TICKET = dtWechatJsapiTicket.JsapiTicket,
                        EXPIRES_IN = dtWechatJsapiTicket.ExpiresIn,
                        PK_ID = dtWechatJsapiTicket.Id,
                    }
                );
        }
示例#3
0
        public int PutJsapiTicket(DtWechatJsapiTicket dtWechatJsapiTicket)
        {
            var var_Result = this.dalWechat.UpdateJsapiTicket(dtWechatJsapiTicket);

            return var_Result;
        }
示例#4
0
        public int InsertJsapiTicket(DtWechatJsapiTicket dtWechatJsapiTicket)
        {
            string commandText = @"INSERT INTO [dbo].[WECHAT_JSAPI_TICKET]
                (                    
                    [SYSTEM_INSERT_DATETIME],
                    [SYSTEM_STATUS],
                    [JSAPI_TICKET],
                    [EXPIRES_IN],
                    [FK_WECHAT_ACCESS_TOKEN_PK_ID]
                )
                VALUES
                (
                    GETDATE(),
                    0,
                    @JSAPI_TICKET,
                    @EXPIRES_IN,
                    @FK_WECHAT_ACCESS_TOKEN_PK_ID
                )";

            return this.dbHelper.ExecuteNonQuery
                (
                    commandText,
                    new
                    {
                        JSAPI_TICKET = dtWechatJsapiTicket.JsapiTicket,
                        EXPIRES_IN = dtWechatJsapiTicket.ExpiresIn,
                        FK_WECHAT_ACCESS_TOKEN_PK_ID = dtWechatJsapiTicket.AccessTokenId,
                    }
                );
        }
示例#5
0
        public int PostJsapiTicket(DtWechatJsapiTicket dtWechatJsapiTicket)
        {
            var var_Result = this.dalWechat.InsertJsapiTicket(dtWechatJsapiTicket);

            return var_Result;
        }