From dab4a092d9f0b0daaacedd0e6f4033d55efcf469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Tue, 18 Oct 2022 09:01:16 +0800 Subject: [PATCH] =?UTF-8?q?sql=E6=97=A5=E5=BF=97=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yi.Framework.ApiMicroservice/Program.cs | 5 ++ .../Properties/launchSettings.json | 4 +- .../appsettings.Production.json | 2 + .../appsettings.Staging.json | 2 + .../appsettings.json | 2 + .../yi-sqlsugar-dev.db | Bin 364544 -> 364544 bytes .../Yi.Framework.Common/Models/GobalModel.cs | 13 +++ .../QueueModel/OrderCreateQueueModel.cs | 2 +- .../Yi.Framework.WebCore/Appsettings.cs | 4 +- .../BuilderExtend/ApolloExtension.cs | 8 +- .../Internal/JsonOptionsWritable.cs | 4 +- .../DbExtend/DbFiterExtend.cs | 77 +++++++++--------- .../DbExtend/DbSeedExtend.cs | 2 +- .../CustomExceptionFilterAttribute.cs | 4 +- .../CustomResourceFilterAttribute.cs | 2 +- .../FilterExtend/LogActionFilterAttribute.cs | 8 +- .../MiddlewareExtend/SqlsugarExtension.cs | 9 +- .../MiddlewareExtend/SwaggerExtension.cs | 4 + .../Yi.Framework.WebCore/ServiceLocator.cs | 6 +- .../SignalRHub/MainHub.cs | 8 +- 20 files changed, 100 insertions(+), 66 deletions(-) create mode 100644 Yi.Framework.Net6/Yi.Framework.Common/Models/GobalModel.cs diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs index 392211b4..6227a613 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Program.cs @@ -142,6 +142,11 @@ builder.Services.AddHttpContextAccessor(); //添加缩略图 #endregion builder.Services.AddSingleton(); + +#region +//全局配置初始化值 +#endregion +GobalModel.SqlLogEnable = Appsettings.appBool("SqlLog_Enable"); //----------------------------------------------------------------------------------------------------------- var app = builder.Build(); #region diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Properties/launchSettings.json b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Properties/launchSettings.json index d49e5e26..29745205 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Properties/launchSettings.json +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Properties/launchSettings.json @@ -2,8 +2,8 @@ "profiles": { "Yi.Framework.ApiMicroservice": { "commandName": "Project", - //开发环境根据情况是否自动启动浏览器,个人感觉开开关关比较麻烦 - "launchBrowser": false, + //开发环境根据情况是否自动启动浏览器 + "launchBrowser": true, "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.Production.json b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.Production.json index 37d54a8b..ec8aa7bb 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.Production.json +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.Production.json @@ -9,6 +9,8 @@ }, "AllowedHosts": "*", + "SqlLog_Enable": false, + "Consul_Enabled": false, "Apollo_Enabled": false, "HealthCheck_Enabled": false, diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.Staging.json b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.Staging.json index c7ae2d34..fd710b84 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.Staging.json +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.Staging.json @@ -9,6 +9,8 @@ }, "AllowedHosts": "*", + "SqlLog_Enable": false, + "Consul_Enabled": false, "DbSeed_Enabled": false, "Apollo_Enabled": false, diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.json b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.json index 94d17102..0ed84298 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.json +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/appsettings.json @@ -9,6 +9,8 @@ }, "AllowedHosts": "*", + "SqlLog_Enable": false, + "Consul_Enabled": false, "DbSeed_Enabled": false, "Apollo_Enabled": false, diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db index dca11648a054d4219323437dcea63641f83e88d6..7b63d53450bb907b9f7f419cd83b0c020ffef2f6 100644 GIT binary patch delta 164 zcmZozAl9%zY=Si7tcfztjI$aOS`!$zCNM2|&$5>755shx0A|PO-VThF(+_=Mn#aWU zXS1ThELJ{VW;Q0#ugocihXfcH*0pneX98m8?OfkkeswU*GP_J?Z(y}#WS-8b$LzS- zK;aORL|UVs0Gptqyttw^gEIpNaDWY%ele3-V)_I*W;J0$3k3rUD^p7=6AL{9Lo;I& M6XWe`n^}W-0NV#IRsaA1 delta 84 zcmZozAl9%zY=Si7%!xA2j58Y(S`!$zCNM2|&$5P{i(xuX0JGzCZwJQ8>4!cr&D*S~ nu!^;v>pK$=GjHem&ho2+S%!J-boK^TOQ2jX^Y*pPtie102ZJ5@ diff --git a/Yi.Framework.Net6/Yi.Framework.Common/Models/GobalModel.cs b/Yi.Framework.Net6/Yi.Framework.Common/Models/GobalModel.cs new file mode 100644 index 00000000..1a86dd15 --- /dev/null +++ b/Yi.Framework.Net6/Yi.Framework.Common/Models/GobalModel.cs @@ -0,0 +1,13 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.Framework.Common.Models +{ + public static class GobalModel + { + public static bool SqlLogEnable { get; set; } = true; + } +} diff --git a/Yi.Framework.Net6/Yi.Framework.Common/QueueModel/OrderCreateQueueModel.cs b/Yi.Framework.Net6/Yi.Framework.Common/QueueModel/OrderCreateQueueModel.cs index fd20b344..0f715418 100644 --- a/Yi.Framework.Net6/Yi.Framework.Common/QueueModel/OrderCreateQueueModel.cs +++ b/Yi.Framework.Net6/Yi.Framework.Common/QueueModel/OrderCreateQueueModel.cs @@ -28,7 +28,7 @@ namespace Yi.Framework.Common.QueueModel /// 灏濊瘯娆℃暟 /// public int TryTime { get; set; } - + public OrderTypeEnum OrderType { get; set; } public enum OrderTypeEnum diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/Appsettings.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/Appsettings.cs index 9161b748..53fedd00 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/Appsettings.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/Appsettings.cs @@ -84,9 +84,9 @@ namespace Yi.Framework.WebCore } - public static IConfiguration appConfiguration(params string[] sections) + public static IConfiguration? appConfiguration(params string[] sections) { - return Configuration.GetSection(string.Join(":", sections)); + return Configuration?.GetSection(string.Join(":", sections)); } } } diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/ApolloExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/ApolloExtension.cs index 6005cdc6..36c73af5 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/ApolloExtension.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/ApolloExtension.cs @@ -52,10 +52,14 @@ namespace Yi.Framework.WebCore.BuilderExtend { var property = apolloProvider.GetType().BaseType?.GetProperty("Data", BindingFlags.Instance | BindingFlags.NonPublic); var data = property?.GetValue(apolloProvider) as IDictionary; - foreach (var item in data) + if (data is not null) { - Console.WriteLine($"key {item.Key} value {item.Value}"); + foreach (var item in data) + { + Console.WriteLine($"key {item.Key} value {item.Value}"); + } } + } }); } diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/Internal/JsonOptionsWritable.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/Internal/JsonOptionsWritable.cs index 662976d5..47ee93ff 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/Internal/JsonOptionsWritable.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/BuilderExtend/OptionsWritable/Internal/JsonOptionsWritable.cs @@ -15,12 +15,12 @@ internal class JsonOptionsWritable : FileOptionsWritableBase public override void Update(Action configuration) { - JObject jObject = JsonConvert.DeserializeObject(File.ReadAllText(this.FileName)); + JObject? jObject = JsonConvert.DeserializeObject(File.ReadAllText(this.FileName)); if (jObject != null) { TOptions option = this.Monitor.CurrentValue ?? new TOptions(); - if (jObject.TryGetValue(this.Section, out JToken jtoken)) + if (jObject.TryGetValue(this.Section, out JToken? jtoken)) { option = JsonConvert.DeserializeObject(jtoken.ToString()) ?? new TOptions(); configuration?.Invoke(option); diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbFiterExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbFiterExtend.cs index c749a4d9..b5b33dab 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbFiterExtend.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbFiterExtend.cs @@ -21,7 +21,7 @@ namespace Yi.Framework.Core } //鏃犻渶鎺堟潈鎯呭喌 - var userName = httpContext.GetUserNameInfo(); + var userName = httpContext?.GetUserNameInfo(); if (userName is null) { return; @@ -35,54 +35,57 @@ namespace Yi.Framework.Core //杩欓噷鍙互浼樺寲涓涓 //鏍规嵁缂撳瓨鑾峰彇鍏ㄩ儴鐢ㄦ埛淇℃伅 - var userRoleMenu = ServiceLocator.Instance.GetService().Get("鐢ㄦ埛id"); + var userRoleMenu = ServiceLocator.Instance?.GetService()?.Get("鐢ㄦ埛id"); - var roles = userRoleMenu.Roles; + var roles = userRoleMenu?.Roles; if (roles.IsNull()) { roles = new(); } //鍏堟祴璇曢儴闂ㄥ氨鏄疞EBG - long deptId = userRoleMenu.User.DeptId??-1; - long userId = httpContext.GetUserIdInfo(); + long deptId = userRoleMenu?.User.DeptId ?? -1; + long userId = httpContext?.GetUserIdInfo()??-1; //鏍规嵁瑙掕壊鐨勬暟鎹寖鍥达紝鏉ユ坊鍔犵浉瀵逛簬鐨勬暟鎹潈闄 - foreach (var role in roles) + if (roles is not null) { - //榛樿涓哄叏閮 - DataScopeEnum dataScope = (DataScopeEnum)(role.DataScope?? DataScopeEnum.ALL.GetHashCode()); - switch (dataScope) + foreach (var role in roles) { - case DataScopeEnum.ALL: - //鐩存帴鏀捐 - break; - case DataScopeEnum.DEPT: - //鍙兘鏌ヨ鍒拌嚜宸辩殑閮ㄩ棬鐨勬暟鎹 - db.QueryFilter.Add(new TableFilterItem(it => it.DeptId == deptId, true)); - break; - case DataScopeEnum.USER: - //鍙兘鏌ヨ鍒拌嚜宸 - db.QueryFilter.Add(new TableFilterItem(it => it.Id == userId, true)); - break; - case DataScopeEnum.CUSTOM: - //鑷畾涔夋煡璇 - var filter = new TableFilterItem(it => SqlFunc.Subqueryable().Where(f => f.DeptId == it.DeptId && f.RoleId == (long)role.Id).Any(), true); - db.QueryFilter.Add(filter); - break; - case DataScopeEnum.DEPT_FOLLOW: - //鏀捐鑷繁閮ㄩ棬鍙婁互涓 - var allChildDepts = db.Queryable().ToChildList(it => it.ParentId, deptId); - - var filter1 = new TableFilterItem(it => allChildDepts.Select(f => f.Id).ToList().Contains(it.DeptId??-1), true); + //榛樿涓哄叏閮 + DataScopeEnum dataScope = (DataScopeEnum)(role.DataScope ?? DataScopeEnum.ALL.GetHashCode()); + switch (dataScope) + { + case DataScopeEnum.ALL: + //鐩存帴鏀捐 + break; + case DataScopeEnum.DEPT: + //鍙兘鏌ヨ鍒拌嚜宸辩殑閮ㄩ棬鐨勬暟鎹 + db.QueryFilter.Add(new TableFilterItem(it => it.DeptId == deptId, true)); + break; + case DataScopeEnum.USER: + //鍙兘鏌ヨ鍒拌嚜宸 + db.QueryFilter.Add(new TableFilterItem(it => it.Id == userId, true)); + break; + case DataScopeEnum.CUSTOM: + //鑷畾涔夋煡璇 + var filter = new TableFilterItem(it => SqlFunc.Subqueryable().Where(f => f.DeptId == it.DeptId && f.RoleId == (long)role.Id).Any(), true); + db.QueryFilter.Add(filter); + break; + case DataScopeEnum.DEPT_FOLLOW: + //鏀捐鑷繁閮ㄩ棬鍙婁互涓 + var allChildDepts = db.Queryable().ToChildList(it => it.ParentId, deptId); - db.QueryFilter.Add(filter1); + var filter1 = new TableFilterItem(it => allChildDepts.Select(f => f.Id).ToList().Contains(it.DeptId ?? -1), true); - //閮ㄩ棬鏃犻渶杩囨护 - //var filter2 = new TableFilterItem(it => allChildDepts.Select(f => f.Id).ToList().Contains(it.Id),true); - //db.QueryFilter.Add(filter2); - break; - default: - break; + db.QueryFilter.Add(filter1); + + //閮ㄩ棬鏃犻渶杩囨护 + //var filter2 = new TableFilterItem(it => allChildDepts.Select(f => f.Id).ToList().Contains(it.Id),true); + //db.QueryFilter.Add(filter2); + break; + default: + break; + } } } } diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbSeedExtend.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbSeedExtend.cs index 54a688f0..b1e23a78 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbSeedExtend.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/DbExtend/DbSeedExtend.cs @@ -93,7 +93,7 @@ namespace Yi.Framework.WebCore.DbExtend if (Appsettings.appBool("DbSeed_Enabled")) { - var _Db = app.ApplicationServices.GetService(); + var _Db = app.ApplicationServices.GetRequiredService(); Invoer(_Db); } diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomExceptionFilterAttribute.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomExceptionFilterAttribute.cs index 23af7be8..7e6754b6 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomExceptionFilterAttribute.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomExceptionFilterAttribute.cs @@ -27,8 +27,8 @@ namespace Yi.Framework.WebCore.FilterExtend { context.Result = new JsonResult( Result.Error("鎿嶄綔澶辫触").SetData(context.Exception.Message)); - string url = context.HttpContext.Request.Path.Value; - string actionName = context.ActionDescriptor.DisplayName; + string? url = context.HttpContext.Request.Path.Value; + string? actionName = context.ActionDescriptor.DisplayName; var logModel = new LogModel() { diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomResourceFilterAttribute.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomResourceFilterAttribute.cs index c8640ef7..031948f0 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomResourceFilterAttribute.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/CustomResourceFilterAttribute.cs @@ -12,7 +12,7 @@ namespace Yi.Framework.WebCore.FilterExtend /// public class CustomResourceFilterAttribute : Attribute, IResourceFilter, IFilterMetadata { - private static Dictionary CustomCache = new Dictionary(); + private static Dictionary CustomCache = new Dictionary(); /// /// 鍙戠敓鍦ㄥ叾浠栧姩浣滀箣鍓 /// diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/LogActionFilterAttribute.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/LogActionFilterAttribute.cs index 50cbca85..0e91e039 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/LogActionFilterAttribute.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/FilterExtend/LogActionFilterAttribute.cs @@ -14,7 +14,7 @@ namespace Yi.Framework.WebCore.FilterExtend /// public class LogActionFilterAttribute : ActionFilterAttribute { - private ILogger _logger = null; + private ILogger _logger ; public LogActionFilterAttribute(ILogger logger) { this._logger = logger; @@ -22,11 +22,11 @@ namespace Yi.Framework.WebCore.FilterExtend public override void OnActionExecuting(ActionExecutingContext context) { - string url = context.HttpContext.Request.Path.Value; + string? url = context.HttpContext.Request.Path.Value; string argument = JsonConvert.SerializeObject(context.ActionArguments); - string controllerName = context.Controller.GetType().FullName; - string actionName = context.ActionDescriptor.DisplayName; + string? controllerName = context.Controller.GetType().FullName; + string? actionName = context.ActionDescriptor.DisplayName; LogModel logModel = new LogModel() { diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/SqlsugarExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/SqlsugarExtension.cs index 29f36b3b..b3dd8d1e 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/SqlsugarExtension.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/SqlsugarExtension.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Yi.Framework.Common.Models; namespace Yi.Framework.WebCore.MiddlewareExtend { @@ -95,10 +96,9 @@ namespace Yi.Framework.WebCore.MiddlewareExtend }; db.Aop.OnLogExecuting = (s, p) => { - //鏆傛椂鍏堝叧闂璼ql鎵撳嵃 - if (false) + if (GobalModel.SqlLogEnable) { - var _logger = ServiceLocator.Instance.GetService>(); + var _logger = ServiceLocator.Instance?.GetRequiredService>(); StringBuilder sb = new StringBuilder(); sb.Append("鎵цSQL:" + s.ToString()); @@ -106,8 +106,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend { sb.Append($"\r\n鍙傛暟:{i.ParameterName},鍙傛暟鍊:{i.Value}"); } - - _logger.LogInformation(sb.ToString()); + _logger?.LogInformation(sb.ToString()); } diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/SwaggerExtension.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/SwaggerExtension.cs index 1c4bca99..d49d925c 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/SwaggerExtension.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/MiddlewareExtend/SwaggerExtension.cs @@ -31,6 +31,10 @@ namespace Yi.Framework.WebCore.MiddlewareExtend //涓 Swagger JSON and UI璁剧疆xml鏂囨。娉ㄩ噴璺緞 //鑾峰彇搴旂敤绋嬪簭鎵鍦ㄧ洰褰(缁濆璺緞锛屼笉鍙楀伐浣滅洰褰曞奖鍝嶏紝寤鸿閲囩敤姝ゆ柟娉曡幏鍙栬矾寰勪娇鐢╳indwos&Linux锛 var basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location); + if (basePath is null) + { + throw new Exception("鏈壘鍒皊wagger鏂囦欢"); + } var apiXmlPath = Path.Combine(basePath, @"Config/SwaggerDoc.xml");//鎺у埗鍣ㄥ眰娉ㄩ噴 //var entityXmlPath = Path.Combine(basePath, @"SwaggerDoc.xml");//瀹炰綋娉ㄩ噴 //c.IncludeXmlComments(apiXmlPath, true);//true琛ㄧず鏄剧ず鎺у埗鍣ㄦ敞閲 diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/ServiceLocator.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/ServiceLocator.cs index d6e235d2..8d72a516 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/ServiceLocator.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/ServiceLocator.cs @@ -7,14 +7,14 @@ namespace Yi.Framework.WebCore { public static class ServiceLocator { - public static IServiceProvider Instance { get; set; } + public static IServiceProvider? Instance { get; set; } public static string Admin { get; set; } = "cc"; - public static bool GetHttp(out HttpContext httpContext) + public static bool GetHttp(out HttpContext? httpContext) { httpContext = null; - var httpContextAccessor = Instance.GetService(); + var httpContextAccessor = Instance?.GetService(); if (httpContextAccessor is null) { return false; diff --git a/Yi.Framework.Net6/Yi.Framework.WebCore/SignalRHub/MainHub.cs b/Yi.Framework.Net6/Yi.Framework.WebCore/SignalRHub/MainHub.cs index 1617fa1e..f8f24f98 100644 --- a/Yi.Framework.Net6/Yi.Framework.WebCore/SignalRHub/MainHub.cs +++ b/Yi.Framework.Net6/Yi.Framework.WebCore/SignalRHub/MainHub.cs @@ -40,11 +40,11 @@ namespace Yi.Framework.WebCore.SignalRHub { OnlineUser users = new(Context.ConnectionId) { - Browser= loginUser.Browser, - LoginLocation = loginUser.LoginLocation, - Ipaddr= loginUser.LoginIp, + Browser= loginUser?.Browser, + LoginLocation = loginUser?.LoginLocation, + Ipaddr= loginUser?.LoginIp, LoginTime=DateTime.Now, - Os=loginUser.Os, + Os=loginUser?.Os, UserName= name??"" }; clientUsers.Add(users);