|
@@ -23,6 +23,40 @@ namespace DataSharing.FwDataExchange
|
|
|
// _sharingConfigurationManager = sharingConfigurationManager;
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="TResponse"></typeparam>
|
|
|
+ /// <param name="url"></param>
|
|
|
+ /// <param name="httpMethod"></param>
|
|
|
+ /// <param name="stringContent"></param>
|
|
|
+ /// <param name="cancellationToken"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<TResponse?> RequestAsync<TResponse>(string url, string httpMethod,string? cacheToken, string? stringContent = null, CancellationToken cancellationToken = default)
|
|
|
+ {
|
|
|
+ using var scope = _scopeFactory.CreateScope();
|
|
|
+ var provider = scope.ServiceProvider;
|
|
|
+ var sharingConfigurationManager = provider.GetRequiredService<ISharingConfigurationManager>();
|
|
|
+ var httpInvoker = provider.GetRequiredService<IHttpInvoker>();
|
|
|
+ //var cacheToken = provider.GetRequiredService<ITypedCache<FwTokenInfo>>();
|
|
|
+
|
|
|
+ //var token = cacheToken.GetOrSet(KeyToken,
|
|
|
+ // d => GetToken(cancellationToken).GetAwaiter().GetResult(),
|
|
|
+ // TimeSpan.FromMinutes(10));
|
|
|
+ // var configSendDataOld = sharingConfigurationManager.GetYiBinConfig().SendDataOld.AddressUrl;
|
|
|
+ string configSendDataOld = "http://171.94.154.2:50105/hlds/";
|
|
|
+ if (sharingConfigurationManager.IsCity(ConfigurationConsts.YiBin))
|
|
|
+ configSendDataOld = sharingConfigurationManager.GetYiBinConfig().SendDataOld.AddressUrl;
|
|
|
+ else if (sharingConfigurationManager.IsCity(ConfigurationConsts.ZiGong))
|
|
|
+ configSendDataOld = sharingConfigurationManager.GetZiGongConfig().SendDataOld.AddressUrl;
|
|
|
+ else if (sharingConfigurationManager.IsCity(ConfigurationConsts.LuZhou))
|
|
|
+ configSendDataOld = sharingConfigurationManager.GetLuZhouConfig().SendDataOld.AddressUrl;
|
|
|
+ configSendDataOld = "http://171.94.154.2:50105/hlds/";
|
|
|
+ return await httpInvoker.RequestStringContentAsync<TResponse>(url, httpMethod, stringContent,
|
|
|
+ d => d.SetHttpClient(configSendDataOld, cacheToken), cancellationToken);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|