Esempio n. 1
0
        public int InsertAccessToken(DtWechatAccessToken dtWechatAccessToken)
        {
            string commandText = @"INSERT INTO [dbo].[WECHAT_ACCESS_TOKEN]
                (                    
                    [SYSTEM_INSERT_DATETIME],
                    [SYSTEM_STATUS],
                    [ACCESS_TOKEN],
                    [EXPIRES_IN],
                    [FK_WECHAT_BASIC_DATA_PK_ID]
                )
                VALUES
                (
                    GETDATE(),
                    0,
                    @ACCESS_TOKEN,
                    @EXPIRES_IN,
                    @FK_WECHAT_BASIC_DATA_PK_ID
                )";

            return this.dbHelper.ExecuteNonQuery
                (
                    commandText,
                    new
                    {
                        ACCESS_TOKEN = dtWechatAccessToken.AccessToken,
                        EXPIRES_IN = dtWechatAccessToken.ExpiresIn,
                        FK_WECHAT_BASIC_DATA_PK_ID = dtWechatAccessToken.BasicDataId,
                    }
                );
        }
Esempio n. 2
0
        private DtWechatAccessToken RenewAccessToken(string appId)
        {
            DtWechatAccessToken dtWechatAccessToken = null;

            var var_BasicData = this.bllWechat.GetBasicData(appId);

            if (var_BasicData == null)
            {
                throw new Exception("未配置微信开发的基础数据");
            }

            string requstUri = string.Format(urlAccessToken, var_BasicData.AppId, var_BasicData.AppSecret);

            HttpClient client = new HttpClient();
            AccessTokenModel model_AccessToken = client.GetAsync(requstUri).Result.Content.ReadAsAsync<AccessTokenModel>().Result;

            if (model_AccessToken != null && (model_AccessToken.ErrCode == null || model_AccessToken.ErrCode == 0))
            {
                dtWechatAccessToken = new DtWechatAccessToken();

                dtWechatAccessToken.AccessToken = model_AccessToken.AccessToken;
                dtWechatAccessToken.ExpiresIn = model_AccessToken.ExpiresIn;
                dtWechatAccessToken.BasicDataId = var_BasicData.Id;
            }

            return dtWechatAccessToken;
        }
Esempio n. 3
0
        public int UpdateAccessToken(DtWechatAccessToken dtWechatAccessToken)
        {
            string commandText = @"UPDATE [dbo].[WECHAT_ACCESS_TOKEN] 
                SET
                    [SYSTEM_UPDATE_DATETIME] = GETDATE(),
                    [ACCESS_TOKEN] = @ACCESS_TOKEN,
                    [EXPIRES_IN] = @EXPIRES_IN
                WHERE [PK_ID] = @PK_ID";

            return this.dbHelper.ExecuteNonQuery
                (
                    commandText,
                    new
                    {
                        ACCESS_TOKEN = dtWechatAccessToken.AccessToken,
                        EXPIRES_IN = dtWechatAccessToken.ExpiresIn,
                        PK_ID = dtWechatAccessToken.Id,
                    }
                );
        }
Esempio n. 4
0
        public int PutAccessToken(DtWechatAccessToken dtWechatAccessToken)
        {
            var var_Result = this.dalWechat.UpdateAccessToken(dtWechatAccessToken);

            return var_Result;
        }
Esempio n. 5
0
        public int PostAccessToken(DtWechatAccessToken dtWechatAccessToken)
        {
            var var_Result = this.dalWechat.InsertAccessToken(dtWechatAccessToken);

            return var_Result;
        }