Ver código fonte

修改BI多个数据库字符串注入方式。测试是可以查询数据库,serverBus未测试,

Li 3 anos atrás
pai
commit
6241b430d5

+ 36 - 9
TEAMModelBI/Controllers/BIHome/OnLineController.cs

@@ -8,6 +8,7 @@ using System.Linq;
 using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelBI.Tool;
+using TEAMModelBI.Tool.Context;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
@@ -35,10 +36,17 @@ namespace TEAMModelBI.Controllers.BIHome
         /// </summary>
         /// <returns></returns>
         [HttpPost("get-count")]
-        public async Task<IActionResult> GetCount() 
+        public async Task<IActionResult> GetCount(JsonElement jsonElement) 
         {
             var cosmosClient = _azureCosmos.GetCosmosClient();
             var table = _azureStorage.GetCloudTableClient().GetTableReference("IESLogin");
+            jsonElement.TryGetProperty("site", out JsonElement site);
+            if ($"{site}".Equals(BIConst.GlobalSite)) 
+            {
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+                table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("IESLogin");
+            }
+
             DateTimeOffset dateTime = DateTimeOffset.UtcNow;
 
             var (daySt, dayEt) = TimeHelper.GetStartOrEnd(dateTime);  //今天开始时间    13位
@@ -107,6 +115,14 @@ namespace TEAMModelBI.Controllers.BIHome
         {
 
             var table = _azureStorage.GetCloudTableClient().GetTableReference("IESLogin");
+            var redisClinet = _azureRedis.GetRedisClient(8);
+            jsonElement.TryGetProperty("site", out JsonElement site);
+            if ($"{site}".Equals(BIConst.GlobalSite))
+            {
+                table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("IESLogin");
+                redisClinet = _azureRedis.GetRedisClient(dbnum: 8, name: BIConst.GlobalSite);
+            }
+
             DateTimeOffset dateTime =  DateTimeOffset.UtcNow;
 
             var (daySt, dayEt) = TimeHelper.GetStartOrEnd(dateTime);  //今天开始时间    13位
@@ -119,7 +135,7 @@ namespace TEAMModelBI.Controllers.BIHome
             Dictionary<long, int> stuDays = new();  //学生在线人数
             Dictionary<long, int> tmdDays = new();  //醍摩豆账户学生
 
-            SortedSetEntry[] tchDay = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Login:IES:teacher:{dateDay}");
+            SortedSetEntry[] tchDay = redisClinet.SortedSetRangeByScoreWithScores($"Login:IES:teacher:{dateDay}");
             if (tchDay.Length > 0)
             {
                 foreach (var item in tchDay)
@@ -144,7 +160,7 @@ namespace TEAMModelBI.Controllers.BIHome
                 {
                     foreach (var item in hourLoginsTch)
                     {
-                        await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Login:IES:teacher:{dateDay}", $"{item.Hour}", item.Teacher);//存一天24小时
+                        await redisClinet.SortedSetIncrementAsync($"Login:IES:teacher:{dateDay}", $"{item.Hour}", item.Teacher);//存一天24小时
                         var utcTo = new DateTimeOffset(new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, item.Hour, 0, 0)).Hour;
                         //var hour = int.Parse(DateTime.SpecifyKind(Convert.ToDateTime($"{dateTime.Year}/{dateTime.Month}/{ dateTime.Day} {item.Hour}:00:00"), DateTimeKind.Utc).ToLocalTime().ToString("HH"));
                         tchDays.Add(utcTo, item.Teacher);
@@ -156,7 +172,7 @@ namespace TEAMModelBI.Controllers.BIHome
                 }
             }
 
-            SortedSetEntry[] stuDay = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Login:IES:student:{dateDay}");
+            SortedSetEntry[] stuDay = redisClinet.SortedSetRangeByScoreWithScores($"Login:IES:student:{dateDay}");
             if (stuDay.Length > 0)
             {
                 foreach (var item in stuDay)
@@ -182,7 +198,7 @@ namespace TEAMModelBI.Controllers.BIHome
                 {
                     foreach (var item in hourLoginsStu)
                     {
-                        await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Login:IES:student:{dateDay}", $"{item.Hour}", item.Student);//存一天24小时
+                        await redisClinet.SortedSetIncrementAsync($"Login:IES:student:{dateDay}", $"{item.Hour}", item.Student);//存一天24小时
                         var utcTo = new DateTimeOffset(new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, item.Hour, 0, 0)).Hour;
                         //var hour = int.Parse(DateTime.SpecifyKind(Convert.ToDateTime($"{dateTime.Year}/{dateTime.Month}/{ dateTime.Day} {item.Hour}:00:00"), DateTimeKind.Utc).ToLocalTime().ToString("HH"));
                         stuDays.Add(utcTo, item.Student);
@@ -194,7 +210,7 @@ namespace TEAMModelBI.Controllers.BIHome
                 }
             }
 
-            SortedSetEntry[] tmdDay = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Login:IES:tmduser:{dateDay}");
+            SortedSetEntry[] tmdDay = redisClinet.SortedSetRangeByScoreWithScores($"Login:IES:tmduser:{dateDay}");
             if (tmdDay.Length > 0)
             {
                 foreach (var item in stuDay)
@@ -220,7 +236,7 @@ namespace TEAMModelBI.Controllers.BIHome
                 {
                     foreach (var item in hourLoginsTmd)
                     {
-                        await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Login:IES:tmduser:{dateDay}", $"{item.Hour}", item.TmdUser);//存一天24小时
+                        await redisClinet.SortedSetIncrementAsync($"Login:IES:tmduser:{dateDay}", $"{item.Hour}", item.TmdUser);//存一天24小时
                         var utcTo = new DateTimeOffset(new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, item.Hour, 00, 00)).Hour;
                         //var hour = int.Parse(DateTime.SpecifyKind(Convert.ToDateTime($"{dateTime.Year}/{dateTime.Month}/{ dateTime.Day} {item.Hour}:00:00"), DateTimeKind.Utc).ToLocalTime().ToString("HH"));
                         tmdDays.Add(utcTo, item.TmdUser);
@@ -240,10 +256,15 @@ namespace TEAMModelBI.Controllers.BIHome
         /// </summary>
         /// <returns></returns>
         [HttpPost("get-lessontrend")]
-        public async Task<IActionResult> GetLessonTrend()
+        public async Task<IActionResult> GetLessonTrend(JsonElement jsonElement)
         {
             DateTimeOffset dateTime = DateTimeOffset.UtcNow;
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            jsonElement.TryGetProperty("site", out JsonElement site);
+            if ($"{site}".Equals(BIConst.GlobalSite))
+            {
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+            }
             int year = dateTime.Year;   //当前年
             int month = dateTime.Month;  //当前月
             int day = dateTime.Day;      //当天
@@ -313,9 +334,15 @@ namespace TEAMModelBI.Controllers.BIHome
         /// </summary>
         /// <returns></returns>
         [HttpPost("get-edition")]
-        public async Task<IActionResult> GetEdition() 
+        public async Task<IActionResult> GetEdition(JsonElement jsonElement) 
         {
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            jsonElement.TryGetProperty("site", out JsonElement site);
+            if ($"{site}".Equals(BIConst.GlobalSite))
+            {
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+            }
+
             int beCnt = 0; //基础班
             int seCnt = 0; //标准版
             int peCnt = 0; //专业版

+ 86 - 16
TEAMModelBI/Controllers/BITest/TestController.cs

@@ -45,6 +45,7 @@ using System.Net.Http.Json;
 using System.Net;
 using TEAMModelBI.Tool.CosmosBank;
 using System.Diagnostics;
+using StackExchange.Redis;
 
 namespace TEAMModelBI.Controllers.BITest
 {
@@ -54,20 +55,22 @@ namespace TEAMModelBI.Controllers.BITest
     {
 
         private readonly AzureCosmosFactory _azureCosmos;
+        private readonly AzureStorageFactory _azureStorage;
+        private readonly AzureRedisFactory _azureRedis;
         private readonly DingDing _dingDing;
         private readonly Option _option;
-        private readonly AzureStorageFactory _azureStorage;
         private readonly IWebHostEnvironment _environment; //读取文件
         //读取配置文件
         private readonly IConfiguration _configuration;
         private readonly CoreAPIHttpService _coreAPIHttpService;
         private readonly HttpClient _httpClient;
 
-        public TestController(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, IOptionsSnapshot<Option> option, IWebHostEnvironment hostingEnvironment, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService, HttpClient httpClient)
+        public TestController(AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, DingDing dingDing, IOptionsSnapshot<Option> option, IWebHostEnvironment hostingEnvironment, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService, HttpClient httpClient)
         {
             _azureCosmos = azureCosmos;
-            _dingDing = dingDing;
             _azureStorage = azureStorage;
+            _azureRedis = azureRedis;
+            _dingDing = dingDing;
             _option = option?.Value;
             _environment = hostingEnvironment;
             _configuration = configuration;
@@ -1263,30 +1266,97 @@ namespace TEAMModelBI.Controllers.BITest
             return Ok(new { state = 200, linqTests, set });
         }
 
-        [HttpPost("get-cosmosdb")]
+        /// <summary>
+        /// 多个连接字符串方式
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost("get-manydb")]
         public async Task<IActionResult> GetMany()
         {
-            var cosmos = _configuration.GetValue<string>("Azure:Cosmos:ConnectionString");
 
+            #region  依赖注入的方式 
 
-            var clientUrl = _configuration.GetValue<string>("Azure:CosmosUrl:ConnectionString");
-            var clientKey = _configuration.GetValue<string>("Azure:CosmosKey:ConnectionString");
+            DateTimeOffset dateTime = DateTimeOffset.UtcNow;
+            var dateDay = dateTime.ToString("yyyyMMdd"); //获取当天的日期
+            Dictionary<long, int> allDays = new();  //所有在线人数
+            Dictionary<long, int> tchDays = new();  //教师在线人数
+            SortedSetEntry[] tchDay = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Login:IES:teacher:{dateDay}");
+            if (tchDay.Length > 0)
+            {
+                foreach (var item in tchDay)
+                {
+                    int val = ((int)item.Score);
+                    int key = ((int)item.Element);
+                    var utcTo = new DateTimeOffset(new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, key, 0, 0)).Hour;
+                    //var hour = int.Parse(DateTime.SpecifyKind(Convert.ToDateTime($"{dateTime.Year}/{dateTime.Month}/{ dateTime.Day} {key}:00:00"), DateTimeKind.Utc).ToLocalTime().ToString("HH"));
+                    tchDays.Add(utcTo, val);
+                    if (allDays.ContainsKey(utcTo))
+                        allDays[utcTo] = (allDays[utcTo] + val);
+                    else
+                        allDays.Add(utcTo, val);
+                }
+            }
+            var redisGl = _azureRedis.GetRedisClient(dbnum: 0, name: "Global");
 
+            var temps= await _azureRedis.GetRedisClient(dbnum: 0, name: "Global").SortedSetIncrementAsync($"Login:IES:Test", $"1", 1);//一天24小时  小时为单位
 
-            CosmosClient cosmosClient = new(clientUrl, clientKey);
-            //var cosmosClient = _azureCosmos.GetCosmosClient(region:client,name: cosmos);
 
-            var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync("hbcn", new PartitionKey("Base"));
-            School school = new();
-            if (response.Status == 200)
-            {
-                using var json = await JsonDocument.ParseAsync(response.ContentStream);
-                school = json.ToObject<School>();
 
+            var cosmosDefaulat = _azureCosmos.GetCosmosClient(); //默认数据库
+            List<School> schools = new();
+            await foreach (var item in cosmosDefaulat.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<School>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            {
+                schools.Add(item);
+            }
+            var cosmosGlobal = _azureCosmos.GetCosmosClient(name: "Global"); //默认数据库
+            List<School> schoolGlobals = new();
+            await foreach (var item in cosmosGlobal.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<School>(queryText: "select value(c) from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            {
+                schoolGlobals.Add(item);
             }
+            return Ok(new { state = 200, dcnt = schools.Count, schools, dgcnt = schoolGlobals.Count, schoolGlobals });
+
+
+            ////table多库连接
+            //var tableDefulat = _azureStorage.GetCloudTableClient().GetTableReference("IESLogin");  //Table默认表
+            //List<DayLogin> hourLoginsDefualt = await tableDefulat.FindListByDict<DayLogin>(new Dictionary<string, object> { { "PartitionKey", $"DayLogin" } });
+
+            //var table = _azureStorage.GetCloudTableClient("Global").GetTableReference("IESLogin");  //Table国际站
+            //List<DayLogin> hourLogins= await  table.FindListByDict<DayLogin>(new Dictionary<string, object> { { "PartitionKey", $"DayLogin" } });
+
+            //return Ok(new { state = 200, hourLogins, hourLoginsDefualt });
+            #endregion
+
+            #region  原始方式
+            //cosmosDB连接字符串
+            //var clientUrl = _configuration.GetValue<string>("Azure:CosmosUrl:ConnectionString");
+            //var clientKey = _configuration.GetValue<string>("Azure:CosmosKey:ConnectionString");
+            //CosmosClient cosmosClient = new(clientUrl, clientKey);
+            //var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync("hbcn", new PartitionKey("Base"));
+            //School school = new();
+            //if (response.Status == 200)
+            //{
+            //    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+            //    school = json.ToObject<School>();
+            //}
+
+            //Table连接字符串
+            //var tableUrl = _configuration.GetValue<string>("Azure:StorageUrl:ConnectionString");
+            //Uri url = new(tableUrl, UriKind.Absolute);
+            //var tableKey = _configuration.GetValue<string>("Azure:StorageKey:ConnectionString");
+            //StorageCredentials sta = new StorageCredentials("teammodeltest", tableKey);
+            //CloudTableClient cloudTableClient = new CloudTableClient(url, sta);
+            //var table1 = cloudTableClient.GetTableReference("IESLogin");
+            //var tableGlobal = _configuration.GetValue<string>("AzureGlobal");
+
+            //Dictionary<string, object> dic = new() { { "PartitionKey", $"HourLogin" } };
+            //List<HourLogin> hourLogin = await table1.FindListByDict<HourLogin>(dic);
 
+            //List<HourLogin> hourLogin1= await table.FindListByDict<HourLogin>(dic);
 
-            return Ok(new { state = 200, school }); 
+            //var table = _azureStorage.GetCloudTableClient().GetTableReference("IESLogin");
+            //return Ok(new { state = 200 }); 
+            #endregion
         }
 
         public class linqTest

+ 32 - 0
TEAMModelBI/DI/BIAzureCosmosFactoryExtensions.cs

@@ -0,0 +1,32 @@
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.DependencyInjection.Extensions;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using TEAMModelOS.SDK.DI;
+
+namespace TEAMModelBI.DI
+{
+    public static class BIAzureCosmosFactoryExtensions
+    {
+        /// <summary>
+        /// cosmosDB注入
+        /// </summary>
+        /// <param name="services"></param>
+        /// <param name="connectionInfo"></param>
+        /// <returns></returns>
+        /// <exception cref="ArgumentNullException"></exception>
+        public static IServiceCollection AddBIAzureCosmos(this IServiceCollection services, List<(string name, string connectionString)> connectionInfo)
+        {
+            if (services == null) throw new ArgumentNullException(nameof(services));
+            if (connectionInfo == null) throw new ArgumentNullException(nameof(connectionInfo));
+            services.TryAddSingleton<AzureCosmosFactory>();
+            connectionInfo.ForEach(connection =>
+            {
+                services.Configure<AzureCosmosFactoryOptions>(connection.name, o => { o.Name = connection.name; o.CosmosConnectionString = connection.connectionString; });
+            });  //多个数据库注入
+            //services.Configure<AzureCosmosFactoryOptions>(name, o => { o.Name = name; o.CosmosConnectionString = connectionString; });  //单个数据库注入
+            return services;
+        }
+    }
+}

+ 36 - 0
TEAMModelBI/DI/BIAzureRedisFactoryExtensions.cs

@@ -0,0 +1,36 @@
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.DependencyInjection.Extensions;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using TEAMModelOS.SDK.DI;
+
+namespace TEAMModelBI.DI
+{
+    public static class BIAzureRedisFactoryExtensions
+    {
+        /// <summary>
+        /// Redis数据库注入
+        /// </summary>
+        /// <param name="services"></param>
+        /// <param name="connectionInfos"></param>
+        /// <returns></returns>
+        /// <exception cref="ArgumentNullException"></exception>
+        public static IServiceCollection AddBIAzureRedis(this IServiceCollection services, List<(string name ,string  connectionString)> connectionInfos)
+        {
+            if (services == null) throw new ArgumentNullException(nameof(services));
+            if (connectionInfos == null) throw new ArgumentNullException(nameof(connectionInfos));
+
+            services.TryAddSingleton<AzureRedisFactory>();
+            //多个连接字符串注入
+            connectionInfos.ForEach(connection =>
+            {
+                services.Configure<AzureRedisFactoryOptions>(connection.name, o => { o.Name = connection.name; o.RedisConnectionString = connection.connectionString; });
+            });
+            ////单个连接字符注入
+            //services.Configure<AzureRedisFactoryOptions>(name, o => { o.Name = name; o.RedisConnectionString = connectionString; });
+
+            return services;
+        }
+    }
+}

+ 37 - 0
TEAMModelBI/DI/BIAzureServiceBusFactoryExtensions.cs

@@ -0,0 +1,37 @@
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.DependencyInjection.Extensions;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using TEAMModelOS.SDK.DI;
+
+namespace TEAMModelBI.DI
+{
+    public static class BIAzureServiceBusFactoryExtensions
+    {
+        /// <summary>
+        /// Function注入
+        /// </summary>
+        /// <param name="services"></param>
+        /// <param name="connectInfos"></param>
+        /// <returns></returns>
+        /// <exception cref="ArgumentNullException"></exception>
+        /// <exception cref="AccessViolationException"></exception>
+        public static IServiceCollection AddBIAzureServiceBus(this IServiceCollection services, List<(string name, string connectionString)> connectInfos) 
+        {
+            if (services == null) throw new ArgumentNullException(nameof(services));
+            if (connectInfos == null) throw new AccessViolationException(nameof(connectInfos));
+
+            services.TryAddSingleton<AzureServiceBusFactory>();
+
+            //多个注入
+            connectInfos.ForEach(connect => {
+                services.Configure<AzureServiceBusFactoryOptions>(connect.name, o => { o.Name = connect.name; o.ServiceBusConnectionString = connect.connectionString; });            
+            });
+
+            //services.Configure<AzureServiceBusFactoryOptions>(name, o => { o.Name = name; o.ServiceBusConnectionString = connectionString; });//单一注入
+
+            return services;
+        }
+    }
+}

+ 32 - 0
TEAMModelBI/DI/BIAzureStorageFactoryExtensions.cs

@@ -0,0 +1,32 @@
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.DependencyInjection.Extensions;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using TEAMModelOS.SDK.DI;
+
+namespace TEAMModelBI.DI
+{
+    public static class BIAzureStorageFactoryExtensions
+    {
+        /// <summary>
+        /// Storage依赖注入
+        /// </summary>
+        /// <param name="services"></param>
+        /// <param name="connectionInfo"></param>
+        /// <returns></returns>
+        /// <exception cref="ArgumentNullException"></exception>
+        public static IServiceCollection AddBIAzureStorage(this IServiceCollection services, List<(string name, string connectionString)> connectionInfo)
+        {
+            if (services == null) throw new ArgumentNullException(nameof(services));
+            if (connectionInfo == null) throw new ArgumentNullException(nameof(connectionInfo));
+
+            services.TryAddSingleton<AzureStorageFactory>();
+            connectionInfo.ForEach(connection =>
+            {
+                services.Configure<AzureStorageFactoryOptions>(connection.name, o => { o.Name = connection.name; o.StorageAccountConnectionString = connection.connectionString; });
+            });
+            return services;
+        }
+    }
+}

+ 32 - 4
TEAMModelBI/Startup.cs

@@ -15,6 +15,7 @@ using System.Collections.Generic;
 using System.IdentityModel.Tokens.Jwt;
 using System.Linq;
 using System.Threading.Tasks;
+using TEAMModelBI.DI;
 using TEAMModelBI.Models;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK;
@@ -87,10 +88,37 @@ namespace TEAMModelBI
                     .AllowAnyMethod();
                 });
             });
-            services.AddAzureStorage(Configuration.GetValue<string>("Azure:Storage:ConnectionString"));
-            services.AddAzureRedis(Configuration.GetValue<string>("Azure:Redis:ConnectionString"));
-            services.AddAzureCosmos(Configuration.GetValue<string>("Azure:Cosmos:ConnectionString"));
-            services.AddAzureServiceBus(Configuration.GetValue<string>("Azure:ServiceBus:ConnectionString"));
+
+            //Table和blob注入
+            List<(string name, string connectionString)> storageConnects = new();
+            storageConnects.Add(("Default", Configuration.GetValue<string>("Azure:Storage:ConnectionString")));      //大路站ClientString
+            storageConnects.Add(("Global", Configuration.GetValue<string>("GlobalAzure:Storage:ConnectionString"))); //国际站ClientString
+            services.AddBIAzureStorage(storageConnects);
+
+            //cosmosDB注入
+            List<(string name,string connectionString)> cosmosDBConnects = new();
+            cosmosDBConnects.Add(("Default", Configuration.GetValue<string>("Azure:Cosmos:ConnectionString")));      //大路站ClientString
+            cosmosDBConnects.Add(("Global", Configuration.GetValue<string>("GlobalAzure:Cosmos:ConnectionString"))); //国际站ClientString
+            services.AddBIAzureCosmos(cosmosDBConnects);
+
+            //redis注入
+            List<(string name, string connectionString)> redisConnects = new();
+            redisConnects.Add(("Default", Configuration.GetValue<string>("Azure:Redis:ConnectionString")));
+            redisConnects.Add(("Global", Configuration.GetValue<string>("GlobalAzure:Redis:ConnectionString")));
+            services.AddBIAzureRedis(redisConnects);
+
+            //serverBus 注入 
+            List<(string name, string connectionString)> funConnects = new();
+            funConnects.Add(("Default", Configuration.GetValue<string>("Azure:Redis:ConnectionString")));
+            funConnects.Add(("Global", Configuration.GetValue<string>("GlobalAzure:Redis:ConnectionString")));
+            services.AddBIAzureServiceBus(funConnects);
+            
+            //单一注入
+            //services.AddAzureStorage(Configuration.GetValue<string>("Azure:Storage:ConnectionString"));
+            //services.AddAzureCosmos(Configuration.GetValue<string>("Azure:Cosmos:ConnectionString"));
+            //services.AddAzureRedis(Configuration.GetValue<string>("Azure:Redis:ConnectionString"));
+            //services.AddAzureServiceBus(Configuration.GetValue<string>("Azure:ServiceBus:ConnectionString"));     
+
             services.AddSnowflakeId(Convert.ToInt64(Configuration.GetValue<string>("Option:LocationNum")), 1);
             services.AddHttpClient();
             services.AddHttpClient<DingDing>(); 

+ 10 - 0
TEAMModelBI/Tool/Context/BIConst.cs

@@ -0,0 +1,10 @@
+namespace TEAMModelBI.Tool.Context
+{
+    public class BIConst
+    {
+        /// <summary>
+        /// 国际站点
+        /// </summary>
+        public static readonly string GlobalSite = "Global";
+    }
+}

+ 18 - 0
TEAMModelBI/appsettings.Development.json

@@ -19,6 +19,7 @@
     "HttpTrigger": "https://teammodelosfunction-test.chinacloudsites.cn/api/"
     //"HttpTrigger": "http://localhost:7071/api/"
   },
+  //大陆站连接字符串
   "Azure": {
     "Storage": {
       "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodeltest;AccountKey=O2W2vadCqexDxWO+px+QK7y1sHwsYj8f/WwKLdOdG5RwHgW/Dupz9dDUb4c1gi6ojzQaRpFUeAAmOu4N9E+37A==;EndpointSuffix=core.chinacloudapi.cn"
@@ -41,6 +42,23 @@
       "ItemCondQueue": "dep-itemcond"
     }
   },
+  //国际站连接字符串  暂时是本地
+  "GlobalAzure": {
+    "Storage": {
+      "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelstorage;AccountKey=Yq7D4dE6cFuer2d2UZIccTA/i0c3sJ/6ITc8tNOyW+K5f+/lWw9GCos3Mxhj47PyWQgDL8YbVD63B9XcGtrMxQ==;EndpointSuffix=core.chinacloudapi.cn" // 之前未删除
+    },
+    "Cosmos": {
+      "ConnectionString": "AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==" //本地
+    },
+    "Redis": {
+      "ConnectionString": "52.130.252.100:6379,password=habook,ssl=false,abortConnect=False,writeBuffer=10240"
+    },
+    "ServiceBus": {
+      "ConnectionString": "Endpoint=sb://teammodelos.servicebus.chinacloudapi.cn/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Sy4h4EQ8zP+7w/lOLi1X3tGord/7ShFHimHs1vC50Dc=",
+      "ActiveTask": "dep-active-task",
+      "ItemCondQueue": "dep-itemcond"
+    }
+  },
   "HaBookAuth": {
     "CoreId": {
       "userinfo": "https://api2.teammodel.cn/Oauth2/GetUserInfos"

+ 18 - 0
TEAMModelBI/appsettings.json

@@ -25,6 +25,7 @@
     "HttpTrigger": "https://teammodelosfunction-test.chinacloudsites.cn/api/"
     //"HttpTrigger": "http://localhost:7071/api/"
   },
+  //大陆站连接字符串
   "Azure": {
     //
     "Storage": {
@@ -47,6 +48,23 @@
       "ItemCondQueue": "dep-itemcond" //队列消息
     }
   },
+  //国际站连接字符串
+  "GlobalAzure": {
+    "Storage": {
+      "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelstorage;AccountKey=Yq7D4dE6cFuer2d2UZIccTA/i0c3sJ/6ITc8tNOyW+K5f+/lWw9GCos3Mxhj47PyWQgDL8YbVD63B9XcGtrMxQ==;EndpointSuffix=core.chinacloudapi.cn" // 之前未删除
+    },
+    "Cosmos": {
+      "ConnectionString": "AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==" //本地
+    },
+    "Redis": {
+      "ConnectionString": "52.130.252.100:6379,password=habook,ssl=false,abortConnect=False,writeBuffer=10240"
+    },
+    "ServiceBus": {
+      "ConnectionString": "Endpoint=sb://teammodelos.servicebus.chinacloudapi.cn/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Sy4h4EQ8zP+7w/lOLi1X3tGord/7ShFHimHs1vC50Dc=",
+      "ActiveTask": "dep-active-task",
+      "ItemCondQueue": "dep-itemcond"
+    }
+  },
   "HaBookAuth": {
     "CoreId": {
       "userinfo": "https://api2.teammodel.cn/Oauth2/GetUserInfos"