Exemple #1
0
        /// <summary>
        /// 根据设备应用唯一秘钥,从服务器查询应用密钥对应客户端信息
        /// </summary>
        /// <param name="deviceAppSecret">设备应用唯一秘钥</param>
        /// <returns>返回服务器客户端信息</returns>
        private async Task <ClientListOutput> GetRemoteClientOutputAsync(string deviceAppSecret)
        {
            MiniProfiler.Current.Step("GetRemoteClientOutputAsync");
            var baseAuthInput = await BeforeRequestNpsApiAsync();

            var searchApiResult = await _npsApi.ClientListAsync(new ClientListInput
            {
                AuthKey   = baseAuthInput.AuthKey,
                Timestamp = baseAuthInput.Timestamp,
                KeyWords  = deviceAppSecret,
                OrderType = "asc",
                Offset    = "0",
                Limit     = "1"
            });

            return(searchApiResult ?? null);
        }
Exemple #2
0
        public async Task NpsClientTest()
        {
            var authCpryKey = await _npsApi.AuthKeyAsync();

            var serverTime = await _npsApi.ServerTimeAsync();

            var authKey = Infrastructure.Helpers.EncryptHelper.Md5By32($"jyioself2020{serverTime.Timestamp}").ToLower();

            var clients = await _npsApi.ClientListAsync(new Application.NpsApi.Dtos.ClientListInput
            {
                AuthKey   = authKey,
                Timestamp = serverTime.Timestamp,
                KeyWords  = "",//ux5zk6i9jbguetvc可根据唯一验证密钥查询
                OrderType = "asc",
                Offset    = "0",
                Limit     = "10"
            });

            serverTime = await _npsApi.ServerTimeAsync();

            authKey = Infrastructure.Helpers.EncryptHelper.Md5By32($"jyioself2020{serverTime.Timestamp}").ToLower();
            var client = await _npsApi.ClientAsync(new Application.NpsApi.Dtos.ClientIdInput
            {
                Id        = 2,
                AuthKey   = authKey,
                Timestamp = serverTime.Timestamp
            });

            serverTime = await _npsApi.ServerTimeAsync();

            authKey = Infrastructure.Helpers.EncryptHelper.Md5By32($"jyioself2020{serverTime.Timestamp}").ToLower();
            var appSecret = _guidGenerator.Create().ToString("N");

            var addClient = await _npsApi.AddClientAsync(new Application.NpsApi.Dtos.ClientAddInput
            {
                AuthKey   = authKey,
                Timestamp = serverTime.Timestamp,
                Remark    = $"测试添加客户端_{appSecret.Substring(0, 8)}",
                AppSecret = appSecret
            });

            serverTime = await _npsApi.ServerTimeAsync();

            authKey   = Infrastructure.Helpers.EncryptHelper.Md5By32($"jyioself2020{serverTime.Timestamp}").ToLower();
            appSecret = _guidGenerator.Create().ToString("N");

            var editClient = await _npsApi.EditClientAsync(new Application.NpsApi.Dtos.ClientEditInput
            {
                AuthKey   = authKey,
                Timestamp = serverTime.Timestamp,
                Id        = 7,
                Remark    = $"测试编辑客户端_{appSecret.Substring(0, 8)}",
                AppSecret = appSecret
            });

            serverTime = await _npsApi.ServerTimeAsync();

            authKey = Infrastructure.Helpers.EncryptHelper.Md5By32($"jyioself2020{serverTime.Timestamp}").ToLower();
            var deleteClient = await _npsApi.DeleteClientAsync(new Application.NpsApi.Dtos.ClientIdInput
            {
                AuthKey   = authKey,
                Timestamp = serverTime.Timestamp,
                Id        = 7
            });

            Assert.True(addClient.Status == 1);
            Assert.True(editClient.Status == 1);
            Assert.True(deleteClient.Status == 1);
        }