Explorar o código

新增TEAMModel Azure Function,調整OS部分帶碼中,尚未完成

JAELYS %!s(int64=4) %!d(string=hai) anos
pai
achega
23be1975eb

+ 264 - 0
TEAMModelFunction/.gitignore

@@ -0,0 +1,264 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# Azure Functions localsettings file
+local.settings.json
+
+# User-specific files
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUNIT
+*.VisualState.xml
+TestResult.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# DNX
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+*_i.c
+*_p.c
+*_i.h
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# TODO: Comment the next line if you want to checkin your web deploy settings
+# but database connection strings (with potential passwords) will be unencrypted
+#*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/packages/*
+# except build/, which is used as an MSBuild target.
+!**/packages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/packages/repositories.config
+# NuGet v3's project.json files produces more ignoreable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+node_modules/
+orleans.codegen.cs
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# CodeRush
+.cr/
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc

+ 36 - 0
TEAMModelFunction/MonitorCosmosDB.cs

@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Net.Http;
+using System.Threading.Tasks;
+using CoreSDK.DingDing;
+using Microsoft.Azure.Documents;
+using Microsoft.Azure.WebJobs;
+using Microsoft.Azure.WebJobs.Host;
+using Microsoft.Extensions.Logging;
+
+namespace TEAMModelFunction
+{
+    public class MonitorCosmosDB
+    {
+        private readonly IHttpClientFactory _clientFactory;        
+
+        public MonitorCosmosDB(IHttpClientFactory clientFactory)
+        {
+            _clientFactory = clientFactory;            
+        }
+
+        [FunctionName("School")]
+        public async Task School([CosmosDBTrigger(
+            databaseName: "TEAMModelOS",
+            collectionName: "School",
+            ConnectionStringSetting = "CosmosConnection",
+            LeaseCollectionName = "leases")]IReadOnlyList<Document> input, ILogger log)
+        {           
+                if (input != null && input.Count > 0)
+                {
+                    log.LogInformation("Documents modified " + input.Count);
+                    log.LogInformation("First document Id " + input[0].Id);
+                }           
+        }
+    }
+}

+ 16 - 0
TEAMModelFunction/MonitorServicesBus.cs

@@ -0,0 +1,16 @@
+using System;
+using Microsoft.Azure.WebJobs;
+using Microsoft.Azure.WebJobs.Host;
+using Microsoft.Extensions.Logging;
+
+namespace TEAMModelFunction
+{
+    public static class MonitorServicesBus
+    {
+        [FunctionName("test_queue_activetask")]
+        public static void Run([ServiceBusTrigger("test_queue_activetask", Connection = "ServiceBusConnection")]string myQueueItem, ILogger log)
+        {
+            log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
+        }
+    }
+}

+ 8 - 0
TEAMModelFunction/Properties/serviceDependencies.json

@@ -0,0 +1,8 @@
+{
+  "dependencies": {
+    "storage1": {
+      "type": "storage",
+      "connectionId": "AzureWebJobsStorage"
+    }
+  }
+}

+ 9 - 0
TEAMModelFunction/Properties/serviceDependencies.local.json

@@ -0,0 +1,9 @@
+{
+  "dependencies": {
+    "storage1": {
+      "resourceId": "/subscriptions/[parameters('subscriptionId')]/resourceGroups/[parameters('resourceGroup')]/providers/Microsoft.Storage/storageAccounts/teammodelstorage",
+      "type": "storage.azure",
+      "connectionId": "AzureWebJobsStorage"
+    }
+  }
+}

+ 20 - 0
TEAMModelFunction/Startup.cs

@@ -0,0 +1,20 @@
+using CoreSDK.DingDing;
+using Microsoft.Azure.Functions.Extensions.DependencyInjection;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using System.Text;
+
+[assembly: FunctionsStartup(typeof(TEAMModelFunction.Startup))]
+namespace TEAMModelFunction
+{
+    public class Startup : FunctionsStartup
+    {
+        public override void Configure(IFunctionsHostBuilder builder)
+        {
+            builder.Services.AddHttpClient();            
+        }
+    }
+}

+ 21 - 0
TEAMModelFunction/TEAMModelFunction.csproj

@@ -0,0 +1,21 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
+    <AzureFunctionsVersion>v3</AzureFunctionsVersion>
+  </PropertyGroup>
+  <ItemGroup>
+    <PackageReference Include="CoreSDK" Version="1.0.0" />
+    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="3.0.7" />
+    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="4.1.0" />
+    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.7" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Update="host.json">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+    </None>
+    <None Update="local.settings.json">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
+    </None>
+  </ItemGroup>
+</Project>

+ 11 - 0
TEAMModelFunction/host.json

@@ -0,0 +1,11 @@
+{
+    "version": "2.0",
+    "logging": {
+        "applicationInsights": {
+            "samplingExcludedTypes": "Request",
+            "samplingSettings": {
+                "isEnabled": true
+            }
+        }
+    }
+}

+ 6 - 0
TEAMModelOS.sln

@@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TEAMModelOS.Service", "TEAM
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TEAMModelGrpc", "TEAMModelGrpc\TEAMModelGrpc.csproj", "{B10346B6-FE98-47AF-A77C-148605EFF0E5}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TEAMModelFunction", "TEAMModelFunction\TEAMModelFunction.csproj", "{78470113-6261-4F9A-9EF3-E315F060813D}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -33,6 +35,10 @@ Global
 		{B10346B6-FE98-47AF-A77C-148605EFF0E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{B10346B6-FE98-47AF-A77C-148605EFF0E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{B10346B6-FE98-47AF-A77C-148605EFF0E5}.Release|Any CPU.Build.0 = Release|Any CPU
+		{78470113-6261-4F9A-9EF3-E315F060813D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{78470113-6261-4F9A-9EF3-E315F060813D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{78470113-6261-4F9A-9EF3-E315F060813D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{78470113-6261-4F9A-9EF3-E315F060813D}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 18 - 0
TEAMModelOS/Controllers/Client/AClassONEController.cs

@@ -0,0 +1,18 @@
+using Microsoft.AspNetCore.Mvc;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace TEAMModelOS.Controllers.Client
+{
+    [Route("api/[controller]")]
+    [ApiController]
+    public class AClassONEController : ControllerBase
+    {
+        public AClassONEController()
+        {
+          
+        }
+    }
+}

+ 18 - 0
TEAMModelOS/Controllers/Client/HiTAControlller.cs

@@ -0,0 +1,18 @@
+using Microsoft.AspNetCore.Mvc;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace TEAMModelOS.Controllers.Client
+{
+    [Route("api/[controller]")]
+    [ApiController]
+    public class HiTAControlller : ControllerBase
+    {
+        public HiTAControlller()
+        {
+           
+        }
+    }
+}

+ 53 - 0
TEAMModelOS/Controllers/Client/HiTeachController.cs

@@ -0,0 +1,53 @@
+using CoreSDK.DingDing;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Options;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using TEAMModelOS.Models;
+using TEAMModelOS.SDK.Extension.DataResult.JsonRpcRequest;
+using TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse;
+using TEAMModelOS.SDK.Helper.Common.JsonHelper;
+using TEAMModelOS.SDK.Helper.Common.LogHelper;
+using TEAMModelOS.SDK.Module.AzureBlob.Configuration;
+using TEAMModelOS.SDK.Module.AzureBlob.Interfaces;
+
+namespace TEAMModelOS.Controllers.Client
+{
+   
+    [Route("hiteach")]
+    [ApiController]
+    public class HiTeachController : ControllerBase
+    {
+
+        private readonly DingDing _dingDing;
+        private readonly Option _option;
+
+        public HiTeachController(DingDing dingDing, IOptionsSnapshot<Option> option)
+        {
+            _dingDing = dingDing;
+            _option = option?.Value;
+        }
+       
+        [Authorize(Roles = "HiTeach")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+        [ProducesResponseType(StatusCodes.Status400BadRequest)]
+        [ProducesDefaultResponseType]
+        [HttpPost("init")]
+        public async Task<IActionResult> Init()
+        {
+            try
+            {
+
+            }
+            catch (Exception ex)
+            {
+                await _dingDing.SendBotMsg($"CoreAPI2,{_option.Location},Channel/Create()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
+                return BadRequest();
+            }
+        }
+    }
+}

+ 61 - 0
TEAMModelOS/Models/Option.cs

@@ -0,0 +1,61 @@
+using Microsoft.AspNetCore.Authentication.OAuth;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Primitives;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace TEAMModelOS.Models
+{
+    public class Option
+    {
+        public Option()
+        {
+        }
+
+        public string Location { get; set; }
+        public string LocationNum { get; set; }  
+        public string BlobDomain { get; set; }
+        public string HostName { get; set; }
+        public IList<string> AllowedHosts { get; }
+        public IList<StringSegment> AllowedRedirects
+        {
+            get
+            {
+                var allowedRedirects = new List<StringSegment>();
+                if (AllowedHosts?.Count > 0 && !TryProcessHosts(AllowedHosts, allowedRedirects))
+                {
+                    return allowedRedirects;
+                }
+                return allowedRedirects;
+            }
+        }
+        public string JwtSecretKey { get; set; }
+        public string Authority { get; set; }
+        public string Audience { get; set; }
+        public string OSFunction { get; set; }
+
+
+
+        private bool TryProcessHosts(IEnumerable<string> incoming, IList<StringSegment> results)
+        {
+            foreach (var entry in incoming)
+            {
+                // Punycode. Http.Sys requires you to register Unicode hosts, but the headers contain punycode.
+                var host = new HostString(entry).ToUriComponent();
+                if (IsTopLevelWildcard(host)) continue;
+                if (!results.Contains(host, StringSegmentComparer.OrdinalIgnoreCase)) results.Add(host);
+            }
+            return true;
+        }
+
+        private bool IsTopLevelWildcard(string host)
+        {
+            return (string.Equals("*", host, StringComparison.Ordinal) // HttpSys wildcard
+                           || string.Equals("[::]", host, StringComparison.Ordinal) // Kestrel wildcard, IPv6 Any
+                           || string.Equals("0.0.0.0", host, StringComparison.Ordinal)); // IPv4 Any
+        }
+
+    }  
+}

+ 43 - 49
TEAMModelOS/Startup.cs

@@ -18,6 +18,7 @@ using Microsoft.Azure.ServiceBus;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Hosting;
+using Microsoft.IdentityModel.Tokens;
 using Scrutor;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.Context.Attributes.Azure;
@@ -39,7 +40,7 @@ namespace TEAMModelOS
 {
     public class Startup
     {
-        private IServiceCollection _services;
+        //private IServiceCollection _services;
         public Startup(IConfiguration configuration, IWebHostEnvironment env)
         {
             Configuration = configuration;
@@ -47,50 +48,44 @@ namespace TEAMModelOS
         }
 
         public IConfiguration Configuration { get; }
-      
+
         // This method gets called by the runtime. Use this method to add services to the container.
         public void ConfigureServices(IServiceCollection services)
         {
-
-
             // true,默認情況下,聲明映射將以舊格式映射聲明名稱,以適應較早的SAML應用程序,RoleClaimType = 'http://schemas.microsoft.com/ws/2008/06/identity/claims/role'
-            // false,RoleClaimType = 'roles' 
-            /*
+            // false,RoleClaimType = 'roles'             
             JwtSecurityTokenHandler.DefaultMapInboundClaims = false;
-            //這個設定ValidAudiences等專案準備要布署時,會在Azure CN 設置AD金鑰,晚一點處理沒關係,會搭配訪問其他雲服務時的Client金鑰獲取及刷新代碼,之後再提供
-            var tokenvalidationparameters = new TokenValidationParameters
-            {
-                RoleClaimType = "roles",
-                ValidAudiences = new string[] { "8768b06f-c5c5-4b0c-abfb-d7ded354626d", "api://8768b06f-c5c5-4b0c-abfb-d7ded354626d" },
-            }; 
-            services.AddAuthentication(options =>
-            {
-                options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
-            }).AddJwtBearer(options => //AzureADJwtBearer
-            {
-                //options.SaveToken = true; //驗證令牌由服務器生成才有效,不適用於服務重啟或分布式架構
-                options.Authority = "https://login.microsoftonline.com/73a2bcc5-fe99-4566-aa8a-07e7bb287df1/v2.0";
-                options.RequireHttpsMetadata = true;
-                options.Audience = "8768b06f-c5c5-4b0c-abfb-d7ded354626d";
-                options.TokenValidationParameters = tokenvalidationparameters;
-                options.Events = new JwtBearerEvents();
-                //下列事件有需要紀錄則打開
-                //options.Events.OnMessageReceived = async context => { await Task.FromResult(0); };
-                //options.Events.OnForbidden = async context => { await Task.FromResult(0); };
-                //options.Events.OnChallenge = async context => { await Task.FromResult(0); };
-                //options.Events.OnAuthenticationFailed = async context => { await Task.FromResult(0); };
-                options.Events.OnTokenValidated = async context =>
+
+            services.AddAuthentication(options => options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme)
+                .AddJwtBearer(options => //AzureADJwtBearer
                 {
-                    if (!context.Principal.Claims.Any(x => x.Type == "http://schemas.microsoft.com/identity/claims/scope") //ClaimConstants.Scope
-                       && !context.Principal.Claims.Any(y => y.Type == "roles")) //ClaimConstants.Roles //http://schemas.microsoft.com/ws/2008/06/identity/claims/role
+                    //options.SaveToken = true; //驗證令牌由服務器生成才有效,不適用於服務重啟或分布式架構
+                    options.Authority = Configuration["Option:Authority"];
+                    options.Audience = Configuration["Option:Audience"];
+                    options.RequireHttpsMetadata = true;
+                    options.TokenValidationParameters = new TokenValidationParameters
                     {
-                        //TODO 需處理額外授權非角色及範圍的訪問異常紀錄
-                        throw new UnauthorizedAccessException("Neither scope or roles claim was found in the bearer token.");
-                    }
-                    await Task.FromResult(0);
-                };
-            });
-            */
+                        RoleClaimType = "roles",
+                        ValidAudiences = new string[] { Configuration["Option:Audience"], $"api://{Configuration["Option:Audience"]}" }
+                    };
+                    options.Events = new JwtBearerEvents();
+                    //下列事件有需要紀錄則打開
+                    //options.Events.OnMessageReceived = async context => { await Task.FromResult(0); };
+                    //options.Events.OnForbidden = async context => { await Task.FromResult(0); };
+                    //options.Events.OnChallenge = async context => { await Task.FromResult(0); };
+                    //options.Events.OnAuthenticationFailed = async context => { await Task.FromResult(0); };
+                    options.Events.OnTokenValidated = async context =>
+                    {
+                        if (!context.Principal.Claims.Any(x => x.Type == "http://schemas.microsoft.com/identity/claims/scope") //ClaimConstants.Scope
+                        && !context.Principal.Claims.Any(y => y.Type == "roles")) //ClaimConstants.Roles //http://schemas.microsoft.com/ws/2008/06/identity/claims/role
+                        {
+                            //TODO 需處理額外授權非角色及範圍的訪問異常紀錄
+                            throw new UnauthorizedAccessException("Neither scope or roles claim was found in the bearer token.");
+                        }
+                        await Task.FromResult(0);
+                    };
+                });
+
             //設定跨域請求
             //services.AddCors(options =>
             //{
@@ -115,7 +110,7 @@ namespace TEAMModelOS
                 x.MultipartBodyLengthLimit = long.MaxValue; // In case of multipart
                 x.MultipartHeadersLengthLimit = int.MaxValue;
             });
-           
+
             // Table配置
             services.AddScoped<IAzureTableDBRepository, AzureTableDBRepository>();
             //使用Blob配置
@@ -132,10 +127,10 @@ namespace TEAMModelOS
             //services.JwtAuth(Configuration.GetSection("JwtSetting"));
             //注入CSRedis
             var csredis = new CSRedis.CSRedisClient(Configuration.GetSection("Azure:Redis:ConnectionString").Get<string>());
-           // CSRedis.CSRedisClient.Serialize = obj =>System.Text.Json.JsonSerializer.Serialize(obj);
-         //   CSRedis.CSRedisClient.Deserialize = (json, type) => System.Text.Json.JsonSerializer.Deserialize(json, type);
+            // CSRedis.CSRedisClient.Serialize = obj =>System.Text.Json.JsonSerializer.Serialize(obj);
+            //   CSRedis.CSRedisClient.Deserialize = (json, type) => System.Text.Json.JsonSerializer.Deserialize(json, type);
             RedisHelper.Initialization(csredis);
-           // RedisHelper.Instance.CurrentSerialize = obj => System.Text.Json.JsonSerializer.Serialize(obj);
+            // RedisHelper.Instance.CurrentSerialize = obj => System.Text.Json.JsonSerializer.Serialize(obj);
             //services.AddSingleton<PowerPointService, PowerPointService>();
 
 
@@ -148,21 +143,20 @@ namespace TEAMModelOS
                .AddClasses(classes => classes.AssignableTo<IChangeService>()).UsingRegistrationStrategy(RegistrationStrategy.Skip)
                    .AsImplementedInterfaces()
                   .WithSingletonLifetime());
-            _services = services;
+           // _services = services;
         }
 
         // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
-        public   void Configure(IApplicationBuilder app, IWebHostEnvironment env, IAzureCosmosDBV3Repository cosmosDBV3Repository, 
-            IChangeFeedInvoke changeFeedInvoke,IAzureServiceBusService azureServiceBusService , IServiceBusReviceService serviceBusReviceService)
+        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IAzureCosmosDBV3Repository cosmosDBV3Repository )
         {
             if (env.IsDevelopment())
             {
                 app.UseDeveloperExceptionPage();
             }
-            CosmosDict dict=  cosmosDBV3Repository.InitializeDatabase().Result;
-            changeFeedInvoke.MonitorChangeFeed(dict, _services);
-            azureServiceBusService.init();
-            serviceBusReviceService.ReciveMessageAsync(); 
+            CosmosDict dict = cosmosDBV3Repository.InitializeDatabase().Result;
+            //changeFeedInvoke.MonitorChangeFeed(dict, _services);
+            //azureServiceBusService.init();
+            //serviceBusReviceService.ReciveMessageAsync();
             app.UseMiddleware<HttpGlobalExceptionInvoke>();
             //以下需要按照順序載入中間件  如果应用调用 UseStaticFiles,请将 UseStaticFiles 置于 UseRouting之前。
             app.UseStaticFiles();

+ 1 - 1
TEAMModelOS/TEAMModelOS.csproj

@@ -13,8 +13,8 @@
   <ItemGroup>
     <PackageReference Include="Bogus" Version="29.0.1" />
     <PackageReference Include="Caching.CSRedis" Version="3.5.5" />
+    <PackageReference Include="CoreSDK" Version="1.0.0" />
     <PackageReference Include="CSRedisCore" Version="3.5.5" />
-    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.3" />
     <PackageReference Include="Microsoft.Azure.ServiceBus" Version="4.1.3" />
     <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.3" />
     <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" />

+ 4 - 1
TEAMModelOS/appsettings.json

@@ -11,7 +11,10 @@
     "Location": "China",
     "LocationNum": "1",
     "HostName": "localhost:5001",
-    "AllowedHosts": [ "localhost", "*.teammodel.cn", "*.teammodel.net", "*.habookaclass.biz", "test" ]
+    "AllowedHosts": [ "localhost", "*.teammodel.cn", "*.teammodel.net", "*.habookaclass.biz", "test" ],
+    "JwtSecretKey": null,
+    "Authority": "https://login.chinacloudapi.cn/4807e9cf-87b8-4174-aa5b-e76497d7392b/v2.0", //China:"https://login.chinacloudapi.cn/4807e9cf-87b8-4174-aa5b-e76497d7392b/v2.0", //Global:"https://login.microsoftonline.com/73a2bcc5-fe99-4566-aa8a-07e7bb287df1/v2.0"
+    "Audience": "72643704-b2e7-4b26-b881-bd5865e7a7a5" //China:"72643704-b2e7-4b26-b881-bd5865e7a7a5",Global:"8768b06f-c5c5-4b0c-abfb-d7ded354626d"
   },
   "Azure": {
     "Table": {