Browse Source

插件

bjmzak
DESKTOP-G961P6V\Zhh 2 years ago
parent
commit
041dad1945
  1. 8
      src/Shentun.ColumnReferencePlugIns/PlugInsBase.cs
  2. 8
      src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointWebPeisPlugIns.cs
  3. 6
      src/Shentun.Peis.Application.Contracts/WebApiOutDto.cs
  4. 15
      src/Shentun.Peis.Application.Contracts/WebApiOutDtoBase.cs
  5. 13
      src/Shentun.Peis.Application.Contracts/WebApiOutDtoExter.cs
  6. 15
      src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs
  7. 8
      src/Shentun.Peis.HttpApi.Host/AppServiceHelper.cs

8
src/Shentun.ColumnReferencePlugIns/PlugInsBase.cs

@ -188,7 +188,7 @@ namespace Shentun.Peis.PlugIns
} }
result = await response.Content.ReadAsStringAsync(); result = await response.Content.ReadAsStringAsync();
var resultDto = JsonConvert.DeserializeObject< WebApiOutDtoExter<TOut>>(result);
var resultDto = JsonConvert.DeserializeObject< WebApiOutDto<TOut>>(result);
if (resultDto.Code == -1) if (resultDto.Code == -1)
{ {
@ -212,7 +212,7 @@ namespace Shentun.Peis.PlugIns
return Task.CompletedTask; return Task.CompletedTask;
} }
public async virtual Task<WebApiOutDtoExter<LoginOutDataDto>> LoginAsync()
public async virtual Task<WebApiOutDto<LoginOutDataDto>> LoginAsync()
{ {
if(string.IsNullOrWhiteSpace(SelfUser)) if(string.IsNullOrWhiteSpace(SelfUser))
{ {
@ -225,7 +225,7 @@ namespace Shentun.Peis.PlugIns
var relult = await LoginAsync(SelfUser, SelfPassword); var relult = await LoginAsync(SelfUser, SelfPassword);
return relult; return relult;
} }
public async Task<WebApiOutDtoExter<LoginOutDataDto>> LoginAsync(string userId, string password)
public async Task<WebApiOutDto<LoginOutDataDto>> LoginAsync(string userId, string password)
{ {
if (string.IsNullOrWhiteSpace(userId)) if (string.IsNullOrWhiteSpace(userId))
{ {
@ -261,7 +261,7 @@ namespace Shentun.Peis.PlugIns
throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result); throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result);
} }
result = await response.Content.ReadAsStringAsync(); result = await response.Content.ReadAsStringAsync();
var restultDto = JsonConvert.DeserializeObject<WebApiOutDtoExter<LoginOutDataDto>>(result);
var restultDto = JsonConvert.DeserializeObject<WebApiOutDto<LoginOutDataDto>>(result);
if (restultDto == null) if (restultDto == null)
{ {
throw new Exception("返回结果是空"); throw new Exception("返回结果是空");

8
src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointWebPeisPlugIns.cs

@ -78,7 +78,7 @@ namespace Shentun.Peis.PlugIns.WebAppoints
(_webPeisGetAppointRegisterAsbitemListByIdUrl, webAppointPatientRegisterIdInput); (_webPeisGetAppointRegisterAsbitemListByIdUrl, webAppointPatientRegisterIdInput);
return appointRegisterAsbitemDtos; return appointRegisterAsbitemDtos;
} }
public async virtual Task<WebApiOutDtoExter<LoginOutDataDto>> LoginWebPeisAsync()
public async virtual Task<WebApiOutDto<LoginOutDataDto>> LoginWebPeisAsync()
{ {
if (string.IsNullOrWhiteSpace(_webPeisUser)) if (string.IsNullOrWhiteSpace(_webPeisUser))
{ {
@ -92,7 +92,7 @@ namespace Shentun.Peis.PlugIns.WebAppoints
return relult; return relult;
} }
public async Task<WebApiOutDtoExter<LoginOutDataDto>> LoginWebPeisAsync(string userId, string password)
public async Task<WebApiOutDto<LoginOutDataDto>> LoginWebPeisAsync(string userId, string password)
{ {
if (string.IsNullOrWhiteSpace(userId)) if (string.IsNullOrWhiteSpace(userId))
{ {
@ -128,7 +128,7 @@ namespace Shentun.Peis.PlugIns.WebAppoints
throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result); throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result);
} }
result = await response.Content.ReadAsStringAsync(); result = await response.Content.ReadAsStringAsync();
var restultDto = JsonConvert.DeserializeObject<WebApiOutDtoExter<LoginOutDataDto>>(result);
var restultDto = JsonConvert.DeserializeObject<WebApiOutDto<LoginOutDataDto>>(result);
if (restultDto == null) if (restultDto == null)
{ {
throw new Exception("返回结果是空"); throw new Exception("返回结果是空");
@ -187,7 +187,7 @@ namespace Shentun.Peis.PlugIns.WebAppoints
} }
result = await response.Content.ReadAsStringAsync(); result = await response.Content.ReadAsStringAsync();
var resultDto = JsonConvert.DeserializeObject<WebApiOutDtoExter<TOut>>(result);
var resultDto = JsonConvert.DeserializeObject<WebApiOutDto<TOut>>(result);
if (resultDto != null) if (resultDto != null)
{ {
if (resultDto.Code == -1) if (resultDto.Code == -1)

6
src/Shentun.Peis.Application.Contracts/WebApiOutDto.cs

@ -4,8 +4,10 @@ using System.Text;
namespace Shentun.Peis namespace Shentun.Peis
{ {
public class WebApiOutDto: WebApiOutDtoBase
public class WebApiOutDto<T>
{ {
public object Data { get; set; }
public int Code { get; set; }
public string Message { get; set; }
public T? Data { get; set; }
} }
} }

15
src/Shentun.Peis.Application.Contracts/WebApiOutDtoBase.cs

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Shentun.Peis
{
public class WebApiOutDtoBase
{
public string Code { get; set; }
public string Message { get; set; }
}
}

13
src/Shentun.Peis.Application.Contracts/WebApiOutDtoExter.cs

@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis
{
public class WebApiOutDtoExter<T>
{
public int Code { get; set; }
public string Message { get; set; }
public T? Data { get; set; }
}
}

15
src/Shentun.Peis.Application/TransToWebPeis/TransToWebPeisAppService.cs

@ -200,7 +200,7 @@ namespace Shentun.Peis.TransToWebPeis
var user = interfaceConfig.GetSection("Interface").GetSection("User").Value; var user = interfaceConfig.GetSection("Interface").GetSection("User").Value;
var password = interfaceConfig.GetSection("Interface").GetSection("Password").Value; var password = interfaceConfig.GetSection("Interface").GetSection("Password").Value;
var result = await CallAppServiceAsync<UploadPeisReportIuputDto, WebApiOutDto>(url, "", input);
var result = await CallAppServiceAsync<UploadPeisReportIuputDto, object>(url, "", input);
} }
@ -329,16 +329,13 @@ namespace Shentun.Peis.TransToWebPeis
} }
result = await response.Content.ReadAsStringAsync(); result = await response.Content.ReadAsStringAsync();
var resultDto = JsonConvert.DeserializeObject<TOut>(result);
if (resultDto is WebApiOutDtoBase)
var resultDto = JsonConvert.DeserializeObject<WebApiOutDto<TOut>>(result);
if (resultDto.Code == -1)
{ {
var webApiOutDtoBase = resultDto as WebApiOutDtoBase;
if (webApiOutDtoBase.Code == "-1")
{
throw new Exception($"调用服务失败{webApiOutDtoBase.Message}");
}
throw new Exception($"调用服务失败{resultDto.Message}");
} }
return resultDto;
return resultDto.Data;
} }
} }

8
src/Shentun.Peis.HttpApi.Host/AppServiceHelper.cs

@ -68,7 +68,7 @@ namespace Shentun.Peis
} }
result = await response.Content.ReadAsStringAsync(); result = await response.Content.ReadAsStringAsync();
var resultDto = JsonConvert.DeserializeObject< WebApiOutDtoExter<TOut> >(result);
var resultDto = JsonConvert.DeserializeObject< WebApiOutDto<TOut> >(result);
if (resultDto.Code == -1 ) if (resultDto.Code == -1 )
{ {
throw new Exception($"调用服务失败{resultDto.Message}"); throw new Exception($"调用服务失败{resultDto.Message}");
@ -112,7 +112,7 @@ namespace Shentun.Peis
} }
result = response.Content.ReadAsStringAsync().Result; result = response.Content.ReadAsStringAsync().Result;
var resultDto = JsonConvert.DeserializeObject<WebApiOutDtoExter<TOut>>(result);
var resultDto = JsonConvert.DeserializeObject<WebApiOutDto<TOut>>(result);
if (resultDto.Code == -1) if (resultDto.Code == -1)
{ {
throw new Exception($"调用服务失败{resultDto.Message}"); throw new Exception($"调用服务失败{resultDto.Message}");
@ -162,7 +162,7 @@ namespace Shentun.Peis
throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result); throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result);
} }
result = await response.Content.ReadAsStringAsync(); result = await response.Content.ReadAsStringAsync();
var restultDto = JsonConvert.DeserializeObject<WebApiOutDtoExter<LoginOutDataDto>>(result);
var restultDto = JsonConvert.DeserializeObject<WebApiOutDto<LoginOutDataDto>>(result);
if (restultDto == null) if (restultDto == null)
{ {
throw new Exception("返回结果是空"); throw new Exception("返回结果是空");
@ -208,7 +208,7 @@ namespace Shentun.Peis
throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result); throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result);
} }
result = response.Content.ReadAsStringAsync().Result; result = response.Content.ReadAsStringAsync().Result;
var restultDto = JsonConvert.DeserializeObject<WebApiOutDtoExter<LoginOutDataDto>>(result);
var restultDto = JsonConvert.DeserializeObject<WebApiOutDto<LoginOutDataDto>>(result);
if (restultDto == null) if (restultDto == null)
{ {
throw new Exception("返回结果是空"); throw new Exception("返回结果是空");

Loading…
Cancel
Save