2 Commits
b6eea44266
...
b72836017f
| Author | SHA1 | Message | Date |
|---|---|---|---|
|
|
b72836017f |
预约
|
1 year ago |
|
|
79a5ce65fd |
预约
|
1 year ago |
13 changed files with 799 additions and 7 deletions
-
65Shentun.WebPeis.Plugins/ColumnReferences/ColumnReferencePlugIns.cs
-
143Shentun.WebPeis.Plugins/ColumnReferences/ColumnReferencePlugInsBase.cs
-
43Shentun.WebPeis.Plugins/ColumnReferences/ColumnReferencePlugInsDbBase.cs
-
14Shentun.WebPeis.Plugins/LoginInputDto.cs
-
22Shentun.WebPeis.Plugins/LoginOutDto.cs
-
330Shentun.WebPeis.Plugins/PlugInsBase.cs
-
29Shentun.WebPeis.Plugins/Shentun.WebPeis.Plugins.csproj
-
92Shentun.WebPeis.Plugins/ThirdPlugInsBase.cs
-
21Shentun.WebPeis.Plugins/WebPeisPlugInsModule.cs
-
9Shentun.WebPeis.sln
-
33src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs
-
3src/Shentun.WebPeis.Application/Persons/PersonAppService.cs
-
2src/Shentun.WebPeis.Domain/AppointPatientRegisters/AppointPatientRegisterManager.cs
@ -0,0 +1,65 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Shentun.WebPeis.PlugIns.ColumnReferences |
|||
{ |
|||
interface IColumnReferencePlugIns |
|||
{ |
|||
public List<ColumnReferenceColumn> GetAppColumns(); |
|||
public string GetAppFilterColumnName(); |
|||
public List<ColumnReferenceColumn> GetInterfaceColumns(); |
|||
public Task<List<ColumnReferenceCodeValue>> GetAppCodeValuesAsync(); |
|||
public Task<List<ColumnReferenceFilterCodeValue>> GetAppFilterCodeValuesAsync(); |
|||
public Task<List<ColumnReferenceCodeValue>> GetInterfaceCodeValuesAsync(); |
|||
} |
|||
|
|||
public class ColumnReferenceCodeValue |
|||
{ |
|||
public string CodeValue { get; set; } |
|||
public string DisplayName { get; set; } |
|||
public string Exter1 { get; set; } |
|||
public string Exter2 { get; set; } |
|||
public string Exter3 { get; set; } |
|||
public string Exter4 { get; set; } |
|||
public string Exter5 { get; set; } |
|||
public string SimpleCode { get; set; } |
|||
public string FilterCodeValue { get; set; } |
|||
public int DisplayOrder { get; set; } |
|||
} |
|||
|
|||
public class ColumnReferenceFilterCodeValue |
|||
{ |
|||
public string CodeValue { get; set; } |
|||
public string DiaplayName { get; set; } |
|||
public int DisplayOrder { get; set; } |
|||
} |
|||
|
|||
public class ColumnReferenceInterfaceCodeValue |
|||
{ |
|||
public string InterfaceCodeValue { get; set; } |
|||
public string DisplayName { get; set; } |
|||
public string Exter1 { get; set; } |
|||
public string Exter2 { get; set; } |
|||
public string Exter3 { get; set; } |
|||
public string Exter4 { get; set; } |
|||
public string Exter5 { get; set; } |
|||
|
|||
} |
|||
public class ColumnReferenceColumn |
|||
{ |
|||
public string Column { get; set; } |
|||
public string Name { get; set; } |
|||
} |
|||
|
|||
public class ColumnReferenceTable |
|||
{ |
|||
public string TableName { get; set; } |
|||
public string CodeColumn { get; set; } |
|||
public string NameColumn { get; set; } |
|||
public string SimpleCodeColumn { get; set; } |
|||
public string DisplayOrderColumn { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,143 @@ |
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using System.Data.Common; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Text.Json; |
|||
using System.Threading.Tasks; |
|||
using Dapper; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Npgsql; |
|||
using Shentun.Utilities; |
|||
namespace Shentun.WebPeis.PlugIns.ColumnReferences |
|||
{ |
|||
|
|||
public class ColumnReferencePlugInsBase : PlugInsBase, IColumnReferencePlugIns |
|||
{ |
|||
|
|||
protected string AppSql; |
|||
private List<ColumnReferenceColumn> _columns; |
|||
private List<ColumnReferenceColumn> _interfaceColumns; |
|||
|
|||
public ColumnReferencePlugInsBase(string parmValue) : base(parmValue) |
|||
{ |
|||
|
|||
AppSql = InterfaceConfig.GetSection("App").GetSection("Sql").Value; |
|||
var columns = InterfaceConfig.GetSection("App").GetSection("Columns").Value; |
|||
string[]? columnArry; |
|||
if (columns != null) |
|||
{ |
|||
columns = columns.Replace(",", ","); |
|||
columnArry = columns.Split(','); |
|||
_columns = new List<ColumnReferenceColumn>(); |
|||
foreach (var column in columnArry) |
|||
{ |
|||
var singleColumns = column.Split('='); |
|||
if (singleColumns.Length == 2) |
|||
{ |
|||
_columns.Add(new ColumnReferenceColumn() |
|||
{ |
|||
Column = singleColumns[0], |
|||
Name = singleColumns[1] |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
columns = InterfaceConfig.GetSection("Interface").GetSection("Columns").Value; |
|||
if (columns != null) |
|||
{ |
|||
columns = columns.Replace(",", ","); |
|||
columnArry = columns.Split(','); |
|||
_interfaceColumns = new List<ColumnReferenceColumn>(); |
|||
foreach (var columnName in columnArry) |
|||
{ |
|||
var singleColumns = columnName.Split('='); |
|||
if (singleColumns.Length == 2) |
|||
{ |
|||
_interfaceColumns.Add(new ColumnReferenceColumn() |
|||
{ |
|||
Column = singleColumns[0], |
|||
Name = singleColumns[1] |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
|
|||
} |
|||
public virtual List<ColumnReferenceColumn> GetAppColumns() |
|||
{ |
|||
if (_columns == null || _columns.Count() == 0) |
|||
{ |
|||
return new List<ColumnReferenceColumn>() |
|||
{ |
|||
new ColumnReferenceColumn() |
|||
{ |
|||
Column = "Code", |
|||
Name = "编码" |
|||
}, |
|||
new ColumnReferenceColumn() |
|||
{ |
|||
Column = "DisplayName", |
|||
Name = "名称" |
|||
} |
|||
|
|||
}; |
|||
} |
|||
return _columns; |
|||
|
|||
} |
|||
|
|||
public virtual List<ColumnReferenceColumn> GetInterfaceColumns() |
|||
{ |
|||
if (_interfaceColumns == null || _interfaceColumns.Count() == 0) |
|||
{ |
|||
return new List<ColumnReferenceColumn>() |
|||
{ |
|||
new ColumnReferenceColumn() |
|||
{ |
|||
Column = "Code", |
|||
Name = "编码" |
|||
}, |
|||
new ColumnReferenceColumn() |
|||
{ |
|||
Column = "DisplayName", |
|||
Name = "名称" |
|||
} |
|||
|
|||
}; |
|||
} |
|||
return _interfaceColumns; |
|||
} |
|||
public virtual async Task<List<ColumnReferenceCodeValue>> GetAppCodeValuesAsync() |
|||
{ |
|||
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr)) |
|||
{ |
|||
var list = (await conn.QueryAsync<ColumnReferenceCodeValue>(AppSql)).ToList(); |
|||
return list; |
|||
} |
|||
} |
|||
|
|||
public virtual async Task<List<ColumnReferenceCodeValue>> GetInterfaceCodeValuesAsync() |
|||
{ |
|||
return new List<ColumnReferenceCodeValue>() |
|||
{ |
|||
|
|||
}; |
|||
} |
|||
|
|||
public virtual async Task<List<ColumnReferenceFilterCodeValue>> GetAppFilterCodeValuesAsync() |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public virtual string GetAppFilterColumnName() |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
using Dapper; |
|||
using Microsoft.Data.SqlClient; |
|||
using Npgsql; |
|||
using Oracle.ManagedDataAccess.Client; |
|||
using Shentun.Utilities; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Data.Common; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Shentun.WebPeis.PlugIns.ColumnReferences |
|||
{ |
|||
public class ColumnReferencePlugInsDbBase : ColumnReferencePlugInsBase |
|||
{ |
|||
|
|||
public ColumnReferencePlugInsDbBase(string parmValue) : base(parmValue) |
|||
{ |
|||
InterfaceSql = InterfaceConfig.GetSection("Interface").GetSection("Sql").Value; |
|||
InterfaceDbType = InterfaceConfig.GetSection("Interface").GetSection("DbType").Value; |
|||
InterfaceConnctionStr = InterfaceConfig.GetSection("Interface").GetSection("ConnectionStrings").Value; |
|||
} |
|||
|
|||
|
|||
public override async Task<List<ColumnReferenceCodeValue>> GetInterfaceCodeValuesAsync() |
|||
{ |
|||
using (DbConnection conn = CreateInterfaceDbConnect()) |
|||
{ |
|||
var list = (await conn.QueryAsync<ColumnReferenceCodeValue>(InterfaceSql)).ToList(); |
|||
foreach (var item in list) |
|||
{ |
|||
if(string.IsNullOrWhiteSpace(item.SimpleCode)) |
|||
{ |
|||
item.SimpleCode = LanguageConverter.GetPYSimpleCode(item.DisplayName); |
|||
} |
|||
|
|||
} |
|||
return list; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Shentun.WebPeis.PlugIns |
|||
{ |
|||
public class LoginInputDto |
|||
{ |
|||
public string UserName { get; set; } |
|||
public string Password { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Shentun.WebPeis.PlugIns |
|||
{ |
|||
//public class LoginOutDto: WebApiOutDtoBase
|
|||
//{
|
|||
// public LoginOutDataDto Data { get; set; }
|
|||
//}
|
|||
|
|||
public class LoginOutDataDto |
|||
{ |
|||
public string peis_id { get; set; } |
|||
public string access_token { get; set; } |
|||
public string token_type { get; set; } |
|||
public int expires_in { get; set; } |
|||
public string refresh_token { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,330 @@ |
|||
using Microsoft.Data.SqlClient; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.Logging; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Converters; |
|||
using Npgsql; |
|||
using Oracle.ManagedDataAccess.Client; |
|||
using Shentun.Utilities; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Data.Common; |
|||
using System.IdentityModel.Tokens.Jwt; |
|||
using System.Linq; |
|||
using System.Linq.Dynamic.Core.Tokenizer; |
|||
using System.Net.Http.Headers; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Shentun.WebPeis.PlugIns |
|||
{ |
|||
public class PlugInsBase |
|||
{ |
|||
protected IConfiguration? AppConfig; |
|||
protected IConfiguration? InterfaceConfig; |
|||
protected string? AppConnctionStr; |
|||
private string? _appBaseAddress; |
|||
private static string? _accesToken; |
|||
protected string? AppUser; |
|||
protected string? AppPassword; |
|||
|
|||
protected string? InterfaceSql; |
|||
protected string? InterfaceSqlKeyColumn; |
|||
protected string? InterfaceDbType; |
|||
protected string? InterfaceConnctionStr; |
|||
|
|||
protected string? InterfaceWebApiUrl; |
|||
|
|||
protected Guid ItemColumnReferenceId; |
|||
protected Guid AsbitemColumnReferenceId; |
|||
protected Guid DepartmentColumnReferenceId; |
|||
protected Guid UserColumnReferenceId; |
|||
protected ILogger<PlugInsBase> Logger; |
|||
static PlugInsBase() |
|||
{ |
|||
Dapper.DefaultTypeMap.MatchNamesWithUnderscores = true; |
|||
} |
|||
public PlugInsBase() |
|||
{ |
|||
Init(); |
|||
} |
|||
|
|||
public PlugInsBase(string parmValue) |
|||
{ |
|||
Init(); |
|||
|
|||
Init(parmValue); |
|||
|
|||
} |
|||
public void Init() |
|||
{ |
|||
AppConfig = new ConfigurationBuilder() |
|||
.SetBasePath(DirectoryHelper.GetAppDirectory()) // 设置基础路径为当前目录
|
|||
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) |
|||
.Build(); |
|||
AppConnctionStr = AppConfig.GetSection("ConnectionStrings") |
|||
.GetSection("Default").Value; |
|||
_appBaseAddress = AppConfig.GetSection("App") |
|||
.GetSection("SelfUrl").Value; |
|||
AppUser = AppConfig.GetSection("App") |
|||
.GetSection("SelfUser").Value; |
|||
AppPassword = AppConfig.GetSection("App") |
|||
.GetSection("SelfPassword").Value; |
|||
|
|||
using var loggerFactory = LoggerFactory.Create(builder => |
|||
{ |
|||
|
|||
}); |
|||
Logger = loggerFactory.CreateLogger<PlugInsBase>(); |
|||
} |
|||
public void Init(string parmValue) |
|||
{ |
|||
var configurationBuilder = new ConfigurationBuilder() |
|||
.AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue))); |
|||
InterfaceConfig = configurationBuilder.Build(); |
|||
//如果接口配置里面配置了用户名密码,则用接口中的覆盖本地配置
|
|||
var appUser = InterfaceConfig.GetSection("App").GetSection("User").Value; |
|||
if(!string.IsNullOrWhiteSpace(appUser)) |
|||
{ |
|||
AppUser = appUser; |
|||
} |
|||
var appPassword = InterfaceConfig.GetSection("App").GetSection("Password").Value; |
|||
if (!string.IsNullOrWhiteSpace(appPassword)) |
|||
{ |
|||
AppPassword = appPassword; |
|||
} |
|||
//设置接口有关配置
|
|||
InterfaceSql = InterfaceConfig.GetSection("Interface").GetSection("Sql").Value; |
|||
InterfaceSqlKeyColumn = InterfaceConfig.GetSection("Interface").GetSection("SqlKeyColumn").Value; |
|||
InterfaceDbType = InterfaceConfig.GetSection("Interface").GetSection("DbType").Value; |
|||
InterfaceWebApiUrl = InterfaceConfig.GetSection("Interface").GetSection("WebApiUrl").Value; |
|||
|
|||
InterfaceConnctionStr = InterfaceConfig.GetSection("Interface").GetSection("ConnectionStrings").Value; |
|||
|
|||
var itemColumnReferenceIdStr = InterfaceConfig.GetSection("Interface") |
|||
.GetSection("ItemColumnReferenceId").Value; |
|||
if (!string.IsNullOrWhiteSpace(itemColumnReferenceIdStr)) |
|||
{ |
|||
ItemColumnReferenceId = new Guid(itemColumnReferenceIdStr); |
|||
} |
|||
|
|||
var asbItemColumnReferenceIdStr = InterfaceConfig.GetSection("Interface") |
|||
.GetSection("AsbitemColumnReferenceId").Value; |
|||
if (!string.IsNullOrWhiteSpace(asbItemColumnReferenceIdStr)) |
|||
{ |
|||
AsbitemColumnReferenceId = new Guid(asbItemColumnReferenceIdStr); |
|||
} |
|||
|
|||
var departmentColumnReferenceIdStr = InterfaceConfig.GetSection("Interface") |
|||
.GetSection("DepartmentColumnReferenceId").Value; |
|||
if (!string.IsNullOrWhiteSpace(departmentColumnReferenceIdStr)) |
|||
{ |
|||
DepartmentColumnReferenceId = new Guid(departmentColumnReferenceIdStr); |
|||
} |
|||
|
|||
var userColumnReferenceIdStr = InterfaceConfig.GetSection("Interface") |
|||
.GetSection("UserColumnReferenceId").Value; |
|||
if (!string.IsNullOrWhiteSpace(userColumnReferenceIdStr)) |
|||
{ |
|||
UserColumnReferenceId = new Guid(userColumnReferenceIdStr); |
|||
} |
|||
} |
|||
protected DbConnection CreateInterfaceDbConnect() |
|||
{ |
|||
DbConnection conn; |
|||
if (string.IsNullOrWhiteSpace(InterfaceConnctionStr)) |
|||
{ |
|||
throw new ArgumentException("数据连接设置中的DbType不能为空"); |
|||
} |
|||
InterfaceDbType = InterfaceDbType.ToLower(); |
|||
//Logger.LogInformation("数据库类型:" + InterfaceDbType);
|
|||
if (InterfaceDbType == "sqlserver") |
|||
{ |
|||
//Logger.LogInformation("调用sqlserver:" + InterfaceDbType);
|
|||
conn = new SqlConnection(InterfaceConnctionStr); |
|||
} |
|||
else if (InterfaceDbType == "postgres") |
|||
{ |
|||
//Logger.LogInformation("调用postgres:" + InterfaceDbType);
|
|||
conn = new NpgsqlConnection(InterfaceConnctionStr); |
|||
} |
|||
else if (InterfaceDbType == "oracle") |
|||
{ |
|||
//Logger.LogInformation("调用oracle:" + InterfaceDbType);
|
|||
conn = new OracleConnection(InterfaceConnctionStr); |
|||
} |
|||
else |
|||
{ |
|||
throw new ArgumentException("数据连接设置中的DbType不支持"); |
|||
} |
|||
return conn; |
|||
} |
|||
|
|||
public async Task<TOut> CallAppServiceAsync<TInput, TOut>(string url, TInput data, string method = "post") |
|||
{ |
|||
if(string.IsNullOrWhiteSpace(_appBaseAddress)) |
|||
{ |
|||
throw new Exception("_appBaseAddress不能为空"); |
|||
} |
|||
string baseAddress = _appBaseAddress; |
|||
await CheckLoginAsync(); |
|||
using (var httpClientHandler = new HttpClientHandler()) |
|||
{ |
|||
using (var httpClient = new HttpClient(httpClientHandler)) |
|||
{ |
|||
httpClient.BaseAddress = new Uri(baseAddress); |
|||
|
|||
httpClient.DefaultRequestHeaders.Accept.Add( |
|||
new MediaTypeWithQualityHeaderValue("application/json"));//设置accept标头,告诉JSON是可接受的响应类型
|
|||
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _accesToken); |
|||
IsoDateTimeConverter timeFormat = new IsoDateTimeConverter(); |
|||
timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; |
|||
var sendData = JsonConvert.SerializeObject(data, Newtonsoft.Json.Formatting.Indented, timeFormat); |
|||
using (HttpContent httpContent = new StringContent(sendData)) |
|||
{ |
|||
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); |
|||
HttpResponseMessage response = null; |
|||
if (method == "post") |
|||
{ |
|||
response = await httpClient.PostAsync(url, httpContent); |
|||
} |
|||
else |
|||
{ |
|||
response = await httpClient.GetAsync(url); |
|||
} |
|||
|
|||
string result; |
|||
if (!response.IsSuccessStatusCode) |
|||
{ |
|||
result = response.Content.ReadAsStringAsync().Result; |
|||
throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result); |
|||
} |
|||
result = await response.Content.ReadAsStringAsync(); |
|||
|
|||
var resultDto = JsonConvert.DeserializeObject< WebApiOutDto<TOut>>(result); |
|||
|
|||
if (resultDto.Code == -1) |
|||
{ |
|||
throw new Exception($"调用WebApi失败,返回-1,消息:" + resultDto.Message); |
|||
} |
|||
return resultDto.Data; |
|||
|
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
|
|||
public virtual async Task DoWorkAsync() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public virtual Task DoWork() |
|||
{ |
|||
return Task.CompletedTask; |
|||
} |
|||
|
|||
public async virtual Task<WebApiOutDto<LoginOutDataDto>> LoginAsync() |
|||
{ |
|||
if(string.IsNullOrWhiteSpace(AppUser)) |
|||
{ |
|||
throw new Exception("SelfUser不能为空"); |
|||
} |
|||
if (string.IsNullOrWhiteSpace(AppPassword)) |
|||
{ |
|||
throw new Exception("SelfPassword不能为空"); |
|||
} |
|||
var relult = await LoginAsync(AppUser, AppPassword); |
|||
return relult; |
|||
} |
|||
public async Task<WebApiOutDto<LoginOutDataDto>> LoginAsync(string userId, string password) |
|||
{ |
|||
if (string.IsNullOrWhiteSpace(userId)) |
|||
{ |
|||
throw new Exception("用户ID不能为空"); |
|||
} |
|||
if (string.IsNullOrWhiteSpace(password)) |
|||
{ |
|||
throw new Exception("密码不能为空"); |
|||
} |
|||
using (var httpClientHandler = new HttpClientHandler()) |
|||
{ |
|||
using (var httpClient = new HttpClient(httpClientHandler)) |
|||
{ |
|||
httpClient.BaseAddress = new Uri(_appBaseAddress); |
|||
|
|||
httpClient.DefaultRequestHeaders.Accept.Add( |
|||
new MediaTypeWithQualityHeaderValue("application/json"));//设置accept标头,告诉JSON是可接受的响应类型
|
|||
var url = "api/identity/users/login"; |
|||
var loginUser = new LoginInputDto() |
|||
{ |
|||
UserName = userId, |
|||
Password = password |
|||
}; |
|||
var sendData = JsonConvert.SerializeObject(loginUser); |
|||
using (HttpContent httpContent = new StringContent(sendData)) |
|||
{ |
|||
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); |
|||
HttpResponseMessage response = await httpClient.PostAsync(url, httpContent); |
|||
string result; |
|||
if (!response.IsSuccessStatusCode) |
|||
{ |
|||
result = response.Content.ReadAsStringAsync().Result; |
|||
throw new Exception("http通信错误:" + response.StatusCode + ",结果:" + result); |
|||
} |
|||
result = await response.Content.ReadAsStringAsync(); |
|||
var restultDto = JsonConvert.DeserializeObject<WebApiOutDto<LoginOutDataDto>>(result); |
|||
if (restultDto == null) |
|||
{ |
|||
throw new Exception("返回结果是空"); |
|||
} |
|||
if (restultDto.Code != 1) |
|||
{ |
|||
throw new Exception($"登录失败{restultDto.Message}"); |
|||
} |
|||
_accesToken = restultDto.Data.access_token; |
|||
return restultDto; |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
|
|||
private async Task CheckLoginAsync() |
|||
{ |
|||
if (string.IsNullOrWhiteSpace(_accesToken)) |
|||
{ |
|||
await LoginAsync(); |
|||
} |
|||
else |
|||
{ |
|||
var handler = new JwtSecurityTokenHandler(); |
|||
var payload = handler.ReadJwtToken(_accesToken).Payload; |
|||
var claims = payload.Claims; |
|||
var exp = claims.First(claim => claim.Type == "exp").Value; |
|||
if (exp == null) |
|||
{ |
|||
await LoginAsync(); |
|||
} |
|||
else |
|||
{ |
|||
if (long.TryParse(exp, out var expires)) |
|||
{ |
|||
var expireTime = DateTimeOffset.FromUnixTimeSeconds(expires).LocalDateTime; |
|||
if (expireTime <= DateTime.Now) |
|||
{ |
|||
await LoginAsync(); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
await LoginAsync(); |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net8.0</TargetFramework> |
|||
<ImplicitUsings>enable</ImplicitUsings> |
|||
<Nullable>enable</Nullable> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<Folder Include="SyncAppointToPeis\" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Dapper" Version="2.1.35" /> |
|||
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.1" /> |
|||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" /> |
|||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> |
|||
<PackageReference Include="Npgsql" Version="8.0.3" /> |
|||
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="23.4.0" /> |
|||
<PackageReference Include="Volo.Abp.Core" Version="8.1.4" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\src\Shentun.Utilities\Shentun.Utilities.csproj" /> |
|||
<ProjectReference Include="..\src\Shentun.WebPeis.Application.Contracts\Shentun.WebPeis.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\src\Shentun.WebPeis.HttpApi.Client\Shentun.WebPeis.HttpApi.Client.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,92 @@ |
|||
using Dapper; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Npgsql; |
|||
using Shentun.Utilities; |
|||
using Shentun.WebPeis.PlugIns.ColumnReferences; |
|||
using Shentun.WebPeis.ThirdInterfaces; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Data.Common; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Shentun.WebPeis.PlugIns |
|||
{ |
|||
public class ThirdPlugInsBase: PlugInsBase |
|||
{ |
|||
//private Guid _thirdInterfaceId;
|
|||
protected ThirdInterfaceDto _thirdInterfaceDto; |
|||
public ThirdPlugInsBase(Guid thirdInterfaceId):base() |
|||
{ |
|||
|
|||
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr)) |
|||
{ |
|||
string sql; |
|||
sql = @"
|
|||
SELECT * |
|||
from third_interface |
|||
where id =@ThirdInterfaceId |
|||
";
|
|||
_thirdInterfaceDto = ( conn.Query<ThirdInterfaceDto>(sql, |
|||
new { ThirdInterfaceId = thirdInterfaceId })).Single(); |
|||
Init(_thirdInterfaceDto.ParmValue); |
|||
} |
|||
} |
|||
public ThirdPlugInsBase(string parmValue):base(parmValue) |
|||
{ |
|||
|
|||
} |
|||
|
|||
public async Task<List<ColumnReferenceInterfaceCodeValue>> GetColumnReferenceInterfaceCodeValuesAsync(Guid columnReferenceId, |
|||
string appCodeValue) |
|||
{ |
|||
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr)) |
|||
{ |
|||
string sql; |
|||
sql = @"
|
|||
SELECT |
|||
column_reference_interface.interface_code_value |
|||
from column_reference |
|||
join column_reference_code on column_reference.id = column_reference_code.column_reference_id |
|||
join column_reference_interface on column_reference_code.id = column_reference_interface.column_reference_code_id |
|||
where column_reference.id = @ColumnReferenceId and |
|||
column_reference_code.code_value = @CodeValue |
|||
";
|
|||
var columnReferenceInterfaceCodeValues = (await conn.QueryAsync<ColumnReferenceInterfaceCodeValue>(sql, |
|||
new { ColumnReferenceId = columnReferenceId, CodeValue =appCodeValue })).ToList(); |
|||
return columnReferenceInterfaceCodeValues; |
|||
} |
|||
} |
|||
|
|||
public async Task<List<ColumnReferenceCodeValue>> GetColumnReferenceCodeValuesAsync(Guid columnReferenceId, |
|||
string interfaceCodeValue) |
|||
{ |
|||
if(string.IsNullOrWhiteSpace(interfaceCodeValue)) |
|||
{ |
|||
throw new Exception("第三方编码不能为空"); |
|||
} |
|||
interfaceCodeValue = interfaceCodeValue.Trim(); |
|||
using (DbConnection conn = new NpgsqlConnection(AppConnctionStr)) |
|||
{ |
|||
string sql; |
|||
sql = @"
|
|||
SELECT |
|||
column_reference_code.code_value |
|||
from column_reference |
|||
join column_reference_code on column_reference.id = column_reference_code.column_reference_id |
|||
join column_reference_interface on column_reference_code.id = column_reference_interface.column_reference_code_id |
|||
where column_reference.id = @ColumnReferenceId and |
|||
column_reference_interface.interface_code_value = @InterfaceCodeValue |
|||
";
|
|||
var columnReferenceCodeValues = (await conn.QueryAsync<ColumnReferenceCodeValue>(sql, |
|||
new { ColumnReferenceId = columnReferenceId, InterfaceCodeValue = interfaceCodeValue })).ToList(); |
|||
//if(columnReferenceCodeValues.Count == 0)
|
|||
//{
|
|||
// throw new Exception($"{interfaceCodeValue}没有找到对照");
|
|||
//}
|
|||
return columnReferenceCodeValues; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Shentun.WebPeis.Plugins |
|||
{ |
|||
public class WebPeisPlugInsModule : AbpModule |
|||
{ |
|||
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
|||
{ |
|||
//var myService = context.ServiceProvider
|
|||
// .GetRequiredService<MyService>();
|
|||
|
|||
//myService.Initialize();
|
|||
} |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue