模拟测试修改
This commit is contained in:
parent
f4ec11a634
commit
a1dbd33400
|
|
@ -1,11 +1,8 @@
|
||||||
using Furion;
|
using Furion;
|
||||||
using Furion.DependencyInjection;
|
using Furion.DependencyInjection;
|
||||||
using Furion.RemoteRequest.Extensions;
|
|
||||||
using MessagePack;
|
using MessagePack;
|
||||||
using Nirvana.Common;
|
using Nirvana.Common;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
@ -23,11 +20,13 @@ namespace Waste.Application
|
||||||
private static string ApiSecretHash = App.Configuration["SZDevPlatSetting:ApiSecretHash"];
|
private static string ApiSecretHash = App.Configuration["SZDevPlatSetting:ApiSecretHash"];
|
||||||
private readonly IHttpClientFactory _clientFactory;
|
private readonly IHttpClientFactory _clientFactory;
|
||||||
private readonly ILoggerService _loggerService;
|
private readonly ILoggerService _loggerService;
|
||||||
|
|
||||||
public SuZhouService(IHttpClientFactory clientFactory, ILoggerService loggerService)
|
public SuZhouService(IHttpClientFactory clientFactory, ILoggerService loggerService)
|
||||||
{
|
{
|
||||||
_clientFactory = clientFactory;
|
_clientFactory = clientFactory;
|
||||||
_loggerService = loggerService;
|
_loggerService = loggerService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分页查询当前账号下存在的地产区域数据
|
/// 分页查询当前账号下存在的地产区域数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -37,7 +36,6 @@ namespace Waste.Application
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<ResultInfo> GetEstatesAsync(int page = 1, int size = 10, string search = "")
|
public async Task<ResultInfo> GetEstatesAsync(int page = 1, int size = 10, string search = "")
|
||||||
{
|
{
|
||||||
|
|
||||||
var url = $"{ApiUrl}/api/estates?page={page}&size={size}&search={search}";
|
var url = $"{ApiUrl}/api/estates?page={page}&size={size}&search={search}";
|
||||||
var response = await GetDataAsync(url, 1, "");
|
var response = await GetDataAsync(url, 1, "");
|
||||||
var resdata = await response.Content.ReadAsByteArrayAsync();
|
var resdata = await response.Content.ReadAsByteArrayAsync();
|
||||||
|
|
@ -52,6 +50,7 @@ namespace Waste.Application
|
||||||
return new ResultInfo(ResultState.FAIL, msg);
|
return new ResultInfo(ResultState.FAIL, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询地产区域信息
|
/// 查询地产区域信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -73,6 +72,7 @@ namespace Waste.Application
|
||||||
return new ResultInfo(ResultState.FAIL, msg);
|
return new ResultInfo(ResultState.FAIL, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hello接口GET测试
|
/// Hello接口GET测试
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -94,6 +94,7 @@ namespace Waste.Application
|
||||||
}
|
}
|
||||||
return new ResultInfo(ResultState.SUCCESS, "success", returndata);
|
return new ResultInfo(ResultState.SUCCESS, "success", returndata);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加地产区域信息
|
/// 添加地产区域信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -118,6 +119,7 @@ namespace Waste.Application
|
||||||
return new ResultInfo(ResultState.FAIL, msg);
|
return new ResultInfo(ResultState.FAIL, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 向服务端推送测试用垃圾采集数据
|
/// 向服务端推送测试用垃圾采集数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -159,6 +161,7 @@ namespace Waste.Application
|
||||||
return new ResultInfo(ResultState.FAIL, msg);
|
return new ResultInfo(ResultState.FAIL, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hello接口Post测试
|
/// Hello接口Post测试
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -185,6 +188,7 @@ namespace Waste.Application
|
||||||
}
|
}
|
||||||
return new ResultInfo(ResultState.SUCCESS, "success", returndata);
|
return new ResultInfo(ResultState.SUCCESS, "success", returndata);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取时间戳
|
/// 获取时间戳
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -207,6 +211,7 @@ namespace Waste.Application
|
||||||
int timestamp = Convert.ToInt32((utcTime - utcStartTime).TotalSeconds);
|
int timestamp = Convert.ToInt32((utcTime - utcStartTime).TotalSeconds);
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取随机数
|
/// 获取随机数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -217,6 +222,7 @@ namespace Waste.Application
|
||||||
int nonce = random.Next(1, Int32.MaxValue);
|
int nonce = random.Next(1, Int32.MaxValue);
|
||||||
return nonce;
|
return nonce;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取签名
|
/// 获取签名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -245,6 +251,7 @@ namespace Waste.Application
|
||||||
string sign = Md5.md5(str, 16).ToLower();
|
string sign = Md5.md5(str, 16).ToLower();
|
||||||
return sign;
|
return sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// POST封装接口
|
/// POST封装接口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -285,6 +292,7 @@ namespace Waste.Application
|
||||||
var testdata = await response.Content.ReadAsStringAsync();
|
var testdata = await response.Content.ReadAsStringAsync();
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// GET接口封装
|
/// GET接口封装
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -316,6 +324,7 @@ namespace Waste.Application
|
||||||
var testdata = await response.Content.ReadAsStringAsync();
|
var testdata = await response.Content.ReadAsStringAsync();
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete接口封装
|
/// Delete接口封装
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -347,6 +356,7 @@ namespace Waste.Application
|
||||||
var testdata = await response.Content.ReadAsStringAsync();
|
var testdata = await response.Content.ReadAsStringAsync();
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除地产区域
|
/// 删除地产区域
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -367,6 +377,7 @@ namespace Waste.Application
|
||||||
return new ResultInfo(ResultState.FAIL, msg);
|
return new ResultInfo(ResultState.FAIL, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除采集点
|
/// 删除采集点
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -386,6 +397,7 @@ namespace Waste.Application
|
||||||
return new ResultInfo(ResultState.FAIL, resdata);
|
return new ResultInfo(ResultState.FAIL, resdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加采集点
|
/// 添加采集点
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -410,6 +422,7 @@ namespace Waste.Application
|
||||||
return new ResultInfo(ResultState.FAIL, msg);
|
return new ResultInfo(ResultState.FAIL, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 上传数据
|
/// 上传数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,49 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace WasteConsoleTest
|
namespace WasteConsoleTest
|
||||||
{
|
{
|
||||||
class Program
|
/// <summary>
|
||||||
|
/// 向服务端推送测试用垃圾采集数据
|
||||||
|
/// </summary>
|
||||||
|
[MessagePackObject]
|
||||||
|
public class MessageGarbageC2SDto //客户端向服务端请求的DTO
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 垃圾称重数据,64位浮点进度,单位为千克
|
||||||
|
/// </summary>
|
||||||
|
[Key("weight")]
|
||||||
|
public double Weight { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 垃圾桶编码
|
||||||
|
/// </summary>
|
||||||
|
[Key("trash")]
|
||||||
|
public string Trash { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 垃圾类型,缺省类型 : 0,厨余垃圾 : 1,可回收物 : 2,有害垃圾 : 3,其他垃圾 : 4
|
||||||
|
/// </summary>
|
||||||
|
[Key("type")]
|
||||||
|
public int Type { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据扫描时间,UNIX时间戳
|
||||||
|
/// </summary>
|
||||||
|
[Key("scanningTime")]
|
||||||
|
public long ScanningTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备状态,使用中 : 0:使用中,异常 : 1,检修 : 2,检修结束 : 3,启用 : 4,未知 : 5
|
||||||
|
/// </summary>
|
||||||
|
[Key("d_status")]
|
||||||
|
public int DStatus { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class Program
|
||||||
{
|
{
|
||||||
private static WSocketClientHelp wSocketClient = null;
|
private static WSocketClientHelp wSocketClient = null;
|
||||||
public static string SocketURL = "wss://api.device.suzhou.ljflytjl.cn/device_rpc";
|
public static string SocketURL = "wss://api.device.suzhou.ljflytjl.cn/device_rpc";
|
||||||
static async Task Main(string[] args)
|
|
||||||
|
private static async Task Main(string[] args)
|
||||||
{
|
{
|
||||||
var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
|
var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
|
||||||
{
|
{
|
||||||
|
|
@ -86,8 +124,14 @@ namespace WasteConsoleTest
|
||||||
{
|
{
|
||||||
await myService.Garbages();
|
await myService.Garbages();
|
||||||
}
|
}
|
||||||
|
//messagepack测试上报
|
||||||
|
else if (cmd.Equals("postmessagepack", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
await myService.MessageGarbages();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void WSocketClient_OnError(object sender, Exception ex)
|
private static void WSocketClient_OnError(object sender, Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"发生异常:{ex.Message}");
|
Console.WriteLine($"发生异常:{ex.Message}");
|
||||||
|
|
@ -126,7 +170,7 @@ namespace WasteConsoleTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//如果收到的消息为type=6心跳包,需要响应Pong
|
//如果收到的消息为type=6心跳包,需要响应Pong
|
||||||
if(jsondata !=null && jsondata.type == 6)
|
if (jsondata != null && jsondata.type == 6)
|
||||||
{
|
{
|
||||||
var senddata = @"{
|
var senddata = @"{
|
||||||
""type"": 6
|
""type"": 6
|
||||||
|
|
@ -137,9 +181,7 @@ namespace WasteConsoleTest
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IMyService
|
public interface IMyService
|
||||||
|
|
@ -148,11 +190,18 @@ namespace WasteConsoleTest
|
||||||
/// 测试token有效期
|
/// 测试token有效期
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Task TestTokenAsync();
|
Task TestTokenAsync();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 传送垃圾数据
|
/// 传送垃圾数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task Garbages();
|
Task Garbages();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Messagepack传送垃圾数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task MessageGarbages();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MyService : IMyService
|
public class MyService : IMyService
|
||||||
|
|
@ -163,6 +212,7 @@ namespace WasteConsoleTest
|
||||||
{
|
{
|
||||||
_clientFactory = clientFactory;
|
_clientFactory = clientFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 传送垃圾数据
|
/// 传送垃圾数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -174,19 +224,14 @@ namespace WasteConsoleTest
|
||||||
string token = gettoken();
|
string token = gettoken();
|
||||||
if (!string.IsNullOrEmpty(token))
|
if (!string.IsNullOrEmpty(token))
|
||||||
{
|
{
|
||||||
int timestamp = GetTimestamp();
|
var scantime = GetTimestamp();
|
||||||
DateTime testtime = DateTime.Parse("2021-08-22 20:00:00");
|
|
||||||
DateTime utcTime = TimeZoneInfo.ConvertTimeToUtc(testtime);
|
|
||||||
DateTime utcStartTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
|
||||||
int scantime= timestamp = Convert.ToInt32((utcTime - utcStartTime).TotalSeconds);
|
|
||||||
|
|
||||||
var garbageC2SDto = new GarbageC2SDto
|
var garbageC2SDto = new GarbageC2SDto
|
||||||
{
|
{
|
||||||
weight = 50.25,
|
weight = 42.3,
|
||||||
trash = "251658245",
|
trash = "64424512085",
|
||||||
scanningTime = scantime,
|
scanningTime = scantime,
|
||||||
d_status = 0,
|
d_status = 0,
|
||||||
type = 1
|
type = 4
|
||||||
};
|
};
|
||||||
int nonce = GetNonce();
|
int nonce = GetNonce();
|
||||||
string[] paramlist = new string[] {
|
string[] paramlist = new string[] {
|
||||||
|
|
@ -194,14 +239,14 @@ namespace WasteConsoleTest
|
||||||
};
|
};
|
||||||
string sign = GetUserApiSign(WSocketClientHelp.Secret, paramlist);
|
string sign = GetUserApiSign(WSocketClientHelp.Secret, paramlist);
|
||||||
var request = new HttpRequestMessage(HttpMethod.Post,
|
var request = new HttpRequestMessage(HttpMethod.Post,
|
||||||
"https://api.data.suzhou.ljflytjl.cn/api/Garbages");
|
"https://api.data.suzhou.ljflytjl.cn/api/Garbages?api-version=1.0");
|
||||||
request.Headers.Add("Authorization", $"Bearer {token}");
|
request.Headers.Add("Authorization", $"Bearer {token}");
|
||||||
request.Headers.Add("secret", WSocketClientHelp.Secret);
|
request.Headers.Add("secret", WSocketClientHelp.Secret);
|
||||||
request.Headers.Add("nonce", nonce.ToString());
|
request.Headers.Add("nonce", nonce.ToString());
|
||||||
request.Headers.Add("time", timestamp.ToString());
|
request.Headers.Add("time", scantime.ToString());
|
||||||
request.Headers.Add("sign", sign);
|
request.Headers.Add("sign", sign);
|
||||||
var message = JsonConvert.SerializeObject(garbageC2SDto);
|
var message = JsonConvert.SerializeObject(garbageC2SDto);
|
||||||
request.Content = new StringContent(message, Encoding.UTF8, "application/json");
|
request.Content = new StringContent(message, Encoding.Default, "application/json");
|
||||||
var client = _clientFactory.CreateClient();
|
var client = _clientFactory.CreateClient();
|
||||||
var response = await client.SendAsync(request);
|
var response = await client.SendAsync(request);
|
||||||
var result = await response.Content.ReadAsStringAsync();
|
var result = await response.Content.ReadAsStringAsync();
|
||||||
|
|
@ -221,8 +266,65 @@ namespace WasteConsoleTest
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// MessagePack传送垃圾数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task MessageGarbages()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string token = gettoken();
|
||||||
|
if (!string.IsNullOrEmpty(token))
|
||||||
|
{
|
||||||
|
var timestamp = GetTimestamp();
|
||||||
|
var garbageC2SDto = new MessageGarbageC2SDto
|
||||||
|
{
|
||||||
|
Weight = 50.2,
|
||||||
|
Trash = "64424509988",
|
||||||
|
ScanningTime = timestamp,
|
||||||
|
DStatus = 0,
|
||||||
|
Type = 4
|
||||||
|
};
|
||||||
|
int nonce = GetNonce();
|
||||||
|
string[] paramlist = new string[] {
|
||||||
|
garbageC2SDto.Weight.ToString(),garbageC2SDto.Trash,garbageC2SDto.Type.ToString(),garbageC2SDto.ScanningTime.ToString(),garbageC2SDto.DStatus.ToString()
|
||||||
|
};
|
||||||
|
string sign = GetUserApiSign(WSocketClientHelp.Secret, paramlist);
|
||||||
|
var request = new HttpRequestMessage(HttpMethod.Post,
|
||||||
|
"https://api.data.suzhou.ljflytjl.cn/api/Garbages");
|
||||||
|
request.Headers.Add("Authorization", $"Bearer {token}");
|
||||||
|
request.Headers.Add("secret", WSocketClientHelp.Secret);
|
||||||
|
request.Headers.Add("nonce", nonce.ToString());
|
||||||
|
request.Headers.Add("time", timestamp.ToString());
|
||||||
|
request.Headers.Add("sign", sign);
|
||||||
|
|
||||||
|
var bytes = MessagePackSerializer.Serialize(garbageC2SDto);
|
||||||
|
request.Content = new ByteArrayContent(bytes);
|
||||||
|
request.Headers.Add("Accept", "application/x-msgpack");
|
||||||
|
request.Content.Headers.Add("Content-Type", "application/x-msgpack");
|
||||||
|
var client = _clientFactory.CreateClient();
|
||||||
|
var response = await client.SendAsync(request);
|
||||||
|
var result = await response.Content.ReadAsStringAsync();
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"上报成功:{result}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine($"上报失败:{response.StatusCode},{result}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.Write("token未找到");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -254,17 +356,30 @@ namespace WasteConsoleTest
|
||||||
Console.Write("token未找到");
|
Console.Write("token未找到");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取时间戳
|
/// 获取时间戳
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private int GetTimestamp()
|
private long GetTimestamp()
|
||||||
{
|
{
|
||||||
DateTime utcTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now);
|
DateTime utcTime = TimeZoneInfo.ConvertTimeToUtc(DateTime.Now);
|
||||||
DateTime utcStartTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
DateTime utcStartTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||||
int timestamp = Convert.ToInt32((utcTime-utcStartTime).TotalSeconds);
|
var timestamp = Convert.ToInt32((utcTime - utcStartTime).TotalSeconds);
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取UTC时间戳
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static int CurrentUTCTimeStamp()
|
||||||
|
{
|
||||||
|
var ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||||
|
var times = Convert.ToInt32(ts.TotalSeconds);
|
||||||
|
return times;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取随机数
|
/// 获取随机数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -275,6 +390,7 @@ namespace WasteConsoleTest
|
||||||
int nonce = random.Next(1, Int32.MaxValue);
|
int nonce = random.Next(1, Int32.MaxValue);
|
||||||
return nonce;
|
return nonce;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取签名
|
/// 获取签名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -306,6 +422,7 @@ namespace WasteConsoleTest
|
||||||
sign = sign.ToLower();
|
sign = sign.ToLower();
|
||||||
return sign;
|
return sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取token
|
/// 获取token
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -321,6 +438,7 @@ namespace WasteConsoleTest
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 向服务端推送测试用垃圾采集数据
|
/// 向服务端推送测试用垃圾采集数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -330,24 +448,29 @@ namespace WasteConsoleTest
|
||||||
/// 垃圾称重数据,64位浮点进度,单位为千克
|
/// 垃圾称重数据,64位浮点进度,单位为千克
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double weight { get; set; }
|
public double weight { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 垃圾桶编码
|
/// 垃圾桶编码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string trash { get; set; }
|
public string trash { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 垃圾类型,缺省类型 : 0,厨余垃圾 : 1,可回收物 : 2,有害垃圾 : 3,其他垃圾 : 4
|
/// 垃圾类型,缺省类型 : 0,厨余垃圾 : 1,可回收物 : 2,有害垃圾 : 3,其他垃圾 : 4
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
public int type { get; set; }
|
public int type { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 数据扫描时间,UNIX时间戳
|
/// 数据扫描时间,UNIX时间戳
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int scanningTime { get; set; }
|
public long scanningTime { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设备状态,使用中 : 0:使用中,异常 : 1,检修 : 2,检修结束 : 3,启用 : 4,未知 : 5
|
/// 设备状态,使用中 : 0:使用中,异常 : 1,检修 : 2,检修结束 : 3,启用 : 4,未知 : 5
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int d_status { get; set; }
|
public int d_status { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 响应的数据
|
/// 响应的数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -357,18 +480,22 @@ namespace WasteConsoleTest
|
||||||
/// 类型,6-心跳包,1-token,3-其他
|
/// 类型,6-心跳包,1-token,3-其他
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int type { get; set; }
|
public int type { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 请求id
|
/// 请求id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string invocationId { get; set; }
|
public string invocationId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 结果
|
/// 结果
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string result { get; set; }
|
public string result { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 目标
|
/// 目标
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string target { get; set; }
|
public string target { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 参数
|
/// 参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -379,6 +506,7 @@ namespace WasteConsoleTest
|
||||||
{
|
{
|
||||||
Console.WriteLine($"已连接");
|
Console.WriteLine($"已连接");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetTimeOut()
|
public static void SetTimeOut()
|
||||||
{
|
{
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
|
|
@ -386,7 +514,7 @@ namespace WasteConsoleTest
|
||||||
DateTime startime = DateTime.Now;
|
DateTime startime = DateTime.Now;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if(wSocketClient.State == WebSocketState.Open)
|
if (wSocketClient.State == WebSocketState.Open)
|
||||||
{
|
{
|
||||||
if ((DateTime.Now - startime).TotalSeconds >= 15)
|
if ((DateTime.Now - startime).TotalSeconds >= 15)
|
||||||
{
|
{
|
||||||
|
|
@ -401,6 +529,7 @@ namespace WasteConsoleTest
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] RemoveSeparator(byte[] data)
|
private static byte[] RemoveSeparator(byte[] data)
|
||||||
{
|
{
|
||||||
List<byte> t = new List<byte>(data);
|
List<byte> t = new List<byte>(data);
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,9 @@ namespace WasteConsoleTest
|
||||||
private ClientWebSocket ws = null;
|
private ClientWebSocket ws = null;
|
||||||
private Uri uri = null;
|
private Uri uri = null;
|
||||||
private bool isUserClose = false;//是否最后由用户手动关闭
|
private bool isUserClose = false;//是否最后由用户手动关闭
|
||||||
public static string Secret = "IICmWj5giYTWoCYd";
|
public static string Secret = "VOVGXa8Rw7hwp4p5";
|
||||||
public static string SecretHash = "6176c58a6569b3cf";
|
public static string SecretHash = "wSQnkR1Eec4U5FPRA5aGDwpmH3+P6YtEK3yHYQ79r8w=";
|
||||||
public static string deviceid = "08d96cf1-d6b4-4e73-8356-02816912b3ba";
|
public static string deviceid = "08da3552-46ee-41b5-88ee-ea3f0047b57f";
|
||||||
|
|
||||||
// <summary>
|
// <summary>
|
||||||
/// WebSocket状态
|
/// WebSocket状态
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue