CrazyIter_Bin 9 月之前
父節點
當前提交
a1ae652028

+ 8 - 45
TEAMModelOS.Extension/HTEX.Complex/Program.cs

@@ -24,7 +24,8 @@ namespace HTEX.Complex
     {
     {
         public static void Main(string[] args)
         public static void Main(string[] args)
         {
         {
-            var builder = WebApplication.CreateBuilder(args);            //builder.WebHost.ConfigureKestrel(options =>
+            var builder = WebApplication.CreateBuilder(args);
+            //builder.WebHost.ConfigureKestrel(options =>
             //{
             //{
             //    //options.ListenAnyIP(4001, options => {
             //    //options.ListenAnyIP(4001, options => {
             //    //   // options.UseHttps("Crt/iteden.pfx", "iteden"); 
             //    //   // options.UseHttps("Crt/iteden.pfx", "iteden"); 
@@ -75,9 +76,7 @@ namespace HTEX.Complex
                     };
                     };
                 });
                 });
             builder.Services.AddControllers();
             builder.Services.AddControllers();
-#if DEBUG
-            builder.WebHost.UseUrls(new[] { "https://*:7298" });
-#endif
+          
             // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
             // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
             builder.Services.AddEndpointsApiExplorer();
             builder.Services.AddEndpointsApiExplorer();
             //builder.Services.AddSwaggerGen();
             //builder.Services.AddSwaggerGen();
@@ -109,36 +108,14 @@ namespace HTEX.Complex
                             .AllowAnyMethod();
                             .AllowAnyMethod();
                 });
                 });
             });
             });
-#if !DEBUG
-            builder.Services.AddHangfire(config => {
-                config.UseRedisStorage(builder.Configuration.GetValue<string>("Azure:Redis:ConnectionString"));
-            });
-            builder.Services.AddHangfireServer();
-#endif
-
             builder.Services.AddControllersWithViews();
             builder.Services.AddControllersWithViews();
             //MQTT  服务端API 发送消息到MQTT客户端 https://www.cnblogs.com/weskynet/p/16441219.html
             //MQTT  服务端API 发送消息到MQTT客户端 https://www.cnblogs.com/weskynet/p/16441219.html
-            // builder.Services.AddHostedService<MqttHostService>();
-
-
             #region MQTT配置
             #region MQTT配置
-            //string hostIp = Configuration["MqttOption:HostIp"];//IP地址
-            //int hostPort = int.Parse(Configuration["MqttOption:HostPort"]);//端口号
-            //int timeout = int.Parse(Configuration["MqttOption:Timeout"]);//超时时间
-            //string username = Configuration["MqttOption:UserName"];//用户名
-            //string password = Configuration["MqttOption:Password"];//密码
-
-
-
-
             builder.Services.AddSingleton<MQTTEvents>();
             builder.Services.AddSingleton<MQTTEvents>();
             builder.Services.AddSingleton(new JsonSerializerOptions(JsonSerializerDefaults.Web));
             builder.Services.AddSingleton(new JsonSerializerOptions(JsonSerializerDefaults.Web));
-      
-            builder.Services.AddHostedMqttServerWithServices(x => {
+            builder.Services.AddHostedMqttServerWithServices(x =>
+            {
                 x.WithDefaultEndpoint()
                 x.WithDefaultEndpoint()
-                //.WithDefaultEndpointBoundIPAddress(System.Net.IPAddress.Parse("127.0.0.1"))
-                //.WithDefaultEndpointPort(1883)
-                //.WithEncryptedEndpointPort(1884)
                 .WithConnectionBacklog(1000)
                 .WithConnectionBacklog(1000)
                 .WithPersistentSessions(true).WithKeepAlive()
                 .WithPersistentSessions(true).WithKeepAlive()
                 .WithDefaultCommunicationTimeout(TimeSpan.FromMilliseconds(30));
                 .WithDefaultCommunicationTimeout(TimeSpan.FromMilliseconds(30));
@@ -146,7 +123,7 @@ namespace HTEX.Complex
             #endregion
             #endregion
 
 
             var app = builder.Build();
             var app = builder.Build();
-            var events = app.Services.GetRequiredService<MQTTEvents>();
+           
             // Configure the HTTP request pipeline.
             // Configure the HTTP request pipeline.
             if (!app.Environment.IsDevelopment())
             if (!app.Environment.IsDevelopment())
             {
             {
@@ -154,28 +131,14 @@ namespace HTEX.Complex
                 // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                 // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                 app.UseHsts();
                 app.UseHsts();
             }
             }
-
-            app.UseHttpsRedirection();
-            app.UseStaticFiles();
-
             app.UseRouting();
             app.UseRouting();
             app.UseCors(); //使用跨域設定
             app.UseCors(); //使用跨域設定
-            app.UseHttpsRedirection(); //開發中暫時關掉
             app.UseAuthentication();
             app.UseAuthentication();
             app.UseAuthorization();
             app.UseAuthorization();
-            //app.MapControllerRoute(
-            //    name: "default",
-            //    pattern: "{controller=Home}/{action=Index}/{id?}");
-            //app.UseEndpoints(endpoints => {
-            //    endpoints.MapControllers();
-            //    endpoints.MapConnectionHandler<MqttConnectionHandler>("/mqtt", opts => opts.WebSockets.SubProtocolSelector = protocolList => protocolList.FirstOrDefault() ?? string.Empty);
-            //    endpoints.MapFallbackToFile("index.html");
-            //    endpoints.MapHub<SignalRScreenServerHub>("/signalr/screen").RequireCors("any");
-            //});
             app.MapControllers();
             app.MapControllers();
-            app.MapConnectionHandler<MqttConnectionHandler>("/mqtt", opts => opts.WebSockets.SubProtocolSelector = protocolList => protocolList.FirstOrDefault() ?? string.Empty);
-            app.MapFallbackToFile("index.html");
             app.MapHub<SignalRScreenServerHub>("/signalr/screen").RequireCors("any");
             app.MapHub<SignalRScreenServerHub>("/signalr/screen").RequireCors("any");
+            app.MapConnectionHandler<MqttConnectionHandler>("/mqtt", opts => opts.WebSockets.SubProtocolSelector = protocolList => protocolList.FirstOrDefault() ?? string.Empty);
+            var events = app.Services.GetRequiredService<MQTTEvents>();
             app.UseMqttServer(server =>
             app.UseMqttServer(server =>
             {
             {
                 server.WithAttributeRouting(app.Services, allowUnmatchedRoutes: false);
                 server.WithAttributeRouting(app.Services, allowUnmatchedRoutes: false);

+ 1 - 1
TEAMModelOS.Extension/HTEX.Complex/Properties/launchSettings.json

@@ -12,7 +12,7 @@
     },
     },
     "https": {
     "https": {
       "commandName": "Project",
       "commandName": "Project",
-      "launchBrowser": true,
+      "launchBrowser": false,
       "launchUrl": "weatherforecast",
       "launchUrl": "weatherforecast",
       "environmentVariables": {
       "environmentVariables": {
         "ASPNETCORE_ENVIRONMENT": "Development"
         "ASPNETCORE_ENVIRONMENT": "Development"

+ 2 - 0
TEAMModelOS.Extension/HTEX.Complex/Services/SignalRScreenServerHub.cs

@@ -90,6 +90,8 @@ namespace HTEX.Complex.Services
                             screenClient.screenUrl = device.screenUrl;
                             screenClient.screenUrl = device.screenUrl;
                             screenClient.delay = device.delay;
                             screenClient.delay = device.delay;
                             screenClient.timeout = device.timeout;
                             screenClient.timeout = device.timeout;
+                            screenClient.cpu = device.cpu;
+                            screenClient.ram = device.ram;
                             screenClient.last_time= DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                             screenClient.last_time= DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                             //连接成功,发送消息给客户端。
                             //连接成功,发送消息给客户端。
                             await SendConnection(connid, new ConnectionMessage
                             await SendConnection(connid, new ConnectionMessage

+ 10 - 0
TEAMModelOS.Extension/HTEX.Complex/appsettings.Development.json

@@ -6,6 +6,16 @@
     }
     }
   },
   },
   "AllowedHosts": "*",
   "AllowedHosts": "*",
+  "Kestrel": {
+    "Endpoints": {
+      "Http": {
+        "Url": "http://*:8807"
+      },
+      "Https": {
+        "Url": "https://*:8808"
+      }
+    }
+  },
   "Azure": {
   "Azure": {
     "Storage": {
     "Storage": {
       "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodeltest;AccountKey=O2W2vadCqexDxWO+px+QK7y1sHwsYj8f/WwKLdOdG5RwHgW/Dupz9dDUb4c1gi6ojzQaRpFUeAAmOu4N9E+37A==;EndpointSuffix=core.chinacloudapi.cn",
       "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodeltest;AccountKey=O2W2vadCqexDxWO+px+QK7y1sHwsYj8f/WwKLdOdG5RwHgW/Dupz9dDUb4c1gi6ojzQaRpFUeAAmOu4N9E+37A==;EndpointSuffix=core.chinacloudapi.cn",

+ 10 - 0
TEAMModelOS.Extension/HTEX.Complex/appsettings.json

@@ -6,6 +6,16 @@
     }
     }
   },
   },
   "AllowedHosts": "*",
   "AllowedHosts": "*",
+  "Kestrel": {
+    "Endpoints": {
+      "Http": {
+        "Url": "http://*:8807"
+      },
+      "Https": {
+        "Url": "https://*:8808"
+      }
+    }
+  },
   "Azure": {
   "Azure": {
     "Storage": {
     "Storage": {
       "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelos;AccountKey=Dl04mfZ9hE9cdPVO1UtqTUQYN/kz/dD/p1nGvSq4tUu/4WhiKcNRVdY9tbe8620nPXo/RaXxs+1F9sVrWRo0bg==;EndpointSuffix=core.chinacloudapi.cn",
       "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelos;AccountKey=Dl04mfZ9hE9cdPVO1UtqTUQYN/kz/dD/p1nGvSq4tUu/4WhiKcNRVdY9tbe8620nPXo/RaXxs+1F9sVrWRo0bg==;EndpointSuffix=core.chinacloudapi.cn",

+ 1 - 1
TEAMModelOS.Extension/HTEX.ScreenClient/appsettings.Development.json

@@ -10,6 +10,6 @@
     "ScreenUrl": "http://52.130.252.100:13000",
     "ScreenUrl": "http://52.130.252.100:13000",
     "Timeout": 30000,
     "Timeout": 30000,
     "Delay": 500,
     "Delay": 500,
-    "CenterUrl": "https://localhost:7298"
+    "CenterUrl": "http://52.130.252.100:8807"
   }
   }
 }
 }

+ 1 - 1
TEAMModelOS.Extension/HTEX.ScreenClient/appsettings.json

@@ -10,6 +10,6 @@
     "ScreenUrl": "http://52.130.252.100:13000",
     "ScreenUrl": "http://52.130.252.100:13000",
     "Timeout": 30000,
     "Timeout": 30000,
     "Delay": 500,
     "Delay": 500,
-    "CenterUrl": "https://localhost:7298"
+    "CenterUrl": "http://52.130.252.100:8807"
   }
   }
 }
 }

+ 1 - 1
TEAMModelOS/Controllers/Both/CourseBaseController.cs

@@ -1848,7 +1848,7 @@ namespace TEAMModelOS.Controllers.Both
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
-                await _dingDing.SendBotMsg($"{_option.Location},课程处理异常,{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
+                await _dingDing.SendBotMsg($"{_option.Location},课程处理异常,{ex.Message}\n{ex.StackTrace}{request.ToJsonString()}", GroupNames.成都开发測試群組);
                 return Ok(new { code = 500, msg = ex.Message });
                 return Ok(new { code = 500, msg = ex.Message });
             }
             }
             return Ok();
             return Ok();