using System; using System.Collections.Generic; using System.Net.Http; using APT.Infrastructure.Api; using APT.Infrastructure.EF; using Microsoft.Extensions.Configuration; namespace APT.API { public class CombindedConnectionGenerator : IConnectionGenerator { static Lazy random = new Lazy(); private readonly IConfiguration configuration; public string TenantKey => ""; public CombindedConnectionGenerator(IConfiguration configuration) { this.configuration = configuration; } public string GetConnection(TenantOption option, TenantInfo tenantInfo) { return tenantInfo.Conn; //var webapiUrl = "http://localhost:5001/api/DbConfigs"; //var httpResponseMsg = new HttpResponseMessage(); //using (var httpClient = new HttpClient()) //{ // httpResponseMsg = httpClient.GetAsync(webapiUrl).Result; // var retrnUrl = httpResponseMsg.Content.ReadAsStringAsync().Result; // dynamic urls = Newtonsoft.Json.JsonConvert.DeserializeObject(retrnUrl); // if (urls != null) // { // List connList = new List(); // foreach (dynamic url in urls) // { // if (url.name == span) // { // connList.Add(url.conn); // } // } // if (connList.Count > 0) // { // var mod = (random.Value.Next(100) % connList.Count); // return connList[mod]; // } // } //} //if (span.Length > 4 && int.TryParse(span[5].ToString(), out var number)) //{ //var mod = (random.Value.Next(1000) % 3)+1; // return configuration.GetConnectionString($"{option.ConnectionPrefix}{mod}"); //} throw new NotSupportedException("ÅäÖÃÐÅÏ¢²»´æÔÚ"); }// public bool MatchTenantKey(string tenantKey) { return true; } } }