提交 30ed59a6 编写于 作者: 麦壳饼's avatar 麦壳饼

调整客户端c#api

上级 aad4bd8e
......@@ -31,7 +31,7 @@ namespace IoTSharp.Sdk.Http
_display = storage.Value_Boolean.ToString();
break;
case DataType.DateTime:
if (storage.Value_DateTime!=DateTime.MinValue) _display = storage.Value_DateTime.ToString("yyyy-MM-dd HH:mm:ss");
if (storage.Value_DateTime!=DateTime.MinValue) _display = storage.Value_DateTime?.ToString("yyyy-MM-dd HH:mm:ss");
break;
case DataType.Double:
_display = storage.Value_Double.ToString();
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -48,7 +48,8 @@ namespace IoTSharp.Sdk.Http
try
{
_act_client = Create<AccountClient>();
_result = await _act_client.RegisterAsync( new RegisterDto() { Customer= customer, Email= username, Password=password, PhoneNumber= phoneNumber });
var apiresult = await _act_client.RegisterAsync( new RegisterDto() { Customer= customer, Email= username, Password=password, PhoneNumber= phoneNumber });
_result = apiresult.Data;
HttpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {Token.Access_token}");
ApiResultOfUserInfoDto userInfoDto = await _act_client.MyInfoAsync();
MyInfo = userInfoDto.Data;
......@@ -64,10 +65,15 @@ namespace IoTSharp.Sdk.Http
try
{
_act_client = Create<AccountClient>();
_result = await _act_client.LoginAsync(new LoginDto() { UserName = username, Password = password });
HttpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {Token.Access_token}");
ApiResultOfUserInfoDto userInfoDto = await _act_client.MyInfoAsync();
MyInfo = userInfoDto.Data;
var apiResultOfLoginResult = await _act_client.LoginAsync(new LoginDto() { UserName = username, Password = password });
if (apiResultOfLoginResult.Code == (int)ApiCode.Success)
{
_result = apiResultOfLoginResult.Data;
HttpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {Token.Access_token}");
ApiResultOfUserInfoDto userInfoDto = await _act_client.MyInfoAsync();
MyInfo = userInfoDto.Data;
}
}
catch (Exception ex)
{
......
......@@ -2,6 +2,7 @@
namespace IoTSharp.Sdk.Http
{
public class InstallRresult
{
public string result { get; set; }
......
......@@ -26,6 +26,10 @@ namespace IoTSharp.Sdk.Http
{
return new Session(result);
}
public static implicit operator Session(ApiResultOfLoginResult result)
{
return new Session(result.Data);
}
public static explicit operator LoginResult(Session result)
{
return (LoginResult) result;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册