From e2a7f5ed8f66d8d269b701d8ad65ce5fb288d1c2 Mon Sep 17 00:00:00 2001 From: liujiaqiang <1448951783@qq.com> Date: Wed, 14 Jun 2023 20:51:46 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Common/ReservationController.cs | 2 +- .../Controllers/Common/WebSocketController.cs | 59 ++++++++------- .../system/SystemControllerController.cs | 33 ++++++++- .../logs/Logs/ExceptionLog/20230614/16.log | 12 ++++ .../logs/Logs/ExceptionLog/20230614/17.log | 72 +++++++++++++++++++ Elight.Entity/AppMode/App_ReceptionModel.cs | 2 +- Elight.Entity/AppMode/StagingModel.cs | 2 +- Elight.Entity/AppMode/StagingNumModel.cs | 2 +- .../SystemModel/App_Sys_DepartModel.cs | 2 +- .../SystemModel/App_Sys_MenuModel.cs | 10 +-- .../SystemModel/App_Sys_RoleMenuModel.cs | 2 +- .../SystemModel/App_Sys_RoleModel.cs | 2 +- .../SystemModel/App_Sys_RoleUserModel.cs | 2 +- .../SystemModel/App_Sys_UnitModel.cs | 2 +- .../SystemModel/App_Sys_UserModel.cs | 10 +-- .../Func_Dossier_LogRecordModel.cs | 2 +- 16 files changed, 166 insertions(+), 50 deletions(-) create mode 100644 24Hour/wwwroot/CaseFile/logs/Logs/ExceptionLog/20230614/16.log create mode 100644 24Hour/wwwroot/CaseFile/logs/Logs/ExceptionLog/20230614/17.log diff --git a/24Hour/Controllers/Common/ReservationController.cs b/24Hour/Controllers/Common/ReservationController.cs index 76823ca..4c25f7e 100644 --- a/24Hour/Controllers/Common/ReservationController.cs +++ b/24Hour/Controllers/Common/ReservationController.cs @@ -56,7 +56,7 @@ namespace _24Hour.Controllers.Common .Where(q => q.IsDelete == 0).ToPageListAsync(Reception.PageIndex, Reception.PageSize); list.ForEach(q => { - var data = app_staging.Where(a => a.Id == q.receptionId).First(); + var data = app_staging.Where(a => a.Id == q.receptionId).FirstOrDefault(); if (data != null) { q.receptionId = data.title; diff --git a/24Hour/Controllers/Common/WebSocketController.cs b/24Hour/Controllers/Common/WebSocketController.cs index e7662b9..3ed2834 100644 --- a/24Hour/Controllers/Common/WebSocketController.cs +++ b/24Hour/Controllers/Common/WebSocketController.cs @@ -1,6 +1,8 @@ using Elight.Entity; using Elight.Logic; using Elight.Utility; +using Elight.Utility.Code; +using javax.xml.crypto; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; @@ -16,6 +18,7 @@ namespace _24Hour.Controllers.Common private readonly SqlSugarClient _db;//数据库 App_Sys_UserModel _userdata = new App_Sys_UserModel();//当前用户 private readonly ILogger _logger;//日志 + Result result = new Result(); private static Dictionary CONNECT_POOL = new Dictionary();//用户连接池 //private static Dictionary> MESSAGE_POOL = new Dictionary>();//离线消息池 public WebSocketController(ILogger logger, SqlSugarClient db, User user) @@ -158,53 +161,55 @@ namespace _24Hour.Controllers.Common /// [HttpPost] [Route("text")] - public async Task text(WebSocketSending Sendingdata) + public async Task text() { try { //获取发送人连接 var socket = CONNECT_POOL.Where(q => q.Key == _userdata.Id).Select(q => q.Value).First(); - while (true) + if (socket.State == WebSocketState.Open) { - if (socket.State == WebSocketState.Open) - { - ArraySegment buffer = new ArraySegment(new byte[2048]); - WebSocketReceiveResult result = await socket.ReceiveAsync(buffer, CancellationToken.None); + ArraySegment buffer = new ArraySegment(new byte[2048]); + //WebSocketReceiveResult result = await socket.ReceiveAsync(buffer, CancellationToken.None); - #region 消息处理(消息转发) - try + #region 消息处理(消息转发) + try + { + #region 关闭Socket处理,删除连接池 + if (socket.State != WebSocketState.Open)//连接关闭 { - #region 关闭Socket处理,删除连接池 - if (socket.State != WebSocketState.Open)//连接关闭 - { - if (CONNECT_POOL.ContainsKey(_userdata.Id)) CONNECT_POOL.Remove(_userdata.Id);//删除连接池 - break; - } - #endregion + if (CONNECT_POOL.ContainsKey(_userdata.Id)) CONNECT_POOL.Remove(_userdata.Id);//删除连接池 + result.IsSucceed = true; + result.result = ""; + return result; + } + #endregion - #region 消息发送 - var content = JsonConvert.SerializeObject(Sendingdata); - buffer = new ArraySegment(Encoding.UTF8.GetBytes(content)); - await socket.SendAsync(buffer, WebSocketMessageType.Text, true, CancellationToken.None); - #endregion - } - catch (Exception exs) - { - //消息转发异常处理,本次消息忽略 继续监听接下来的消息 - } + #region 消息发送 + var content = "测试test"; + buffer = new ArraySegment(Encoding.UTF8.GetBytes(content)); + await socket.SendAsync(buffer, WebSocketMessageType.Text, true, CancellationToken.None); #endregion } - else + catch (Exception exs) { + //消息转发异常处理,本次消息忽略 继续监听接下来的消息 } - }//while end + #endregion + } + else + { + } } catch (Exception) { //整体异常处理 if (CONNECT_POOL.ContainsKey(_userdata.Id)) CONNECT_POOL.Remove(_userdata.Id); } + result.IsSucceed = true; + result.result = ""; + return result; } } diff --git a/24Hour/Controllers/system/SystemControllerController.cs b/24Hour/Controllers/system/SystemControllerController.cs index b2a6f83..4957b54 100644 --- a/24Hour/Controllers/system/SystemControllerController.cs +++ b/24Hour/Controllers/system/SystemControllerController.cs @@ -42,6 +42,10 @@ namespace _24Hour.Controllers.system [Route("QueryUser0")] public async Task QueryUser0(App_Sys_UserInput UserModel) { + var userlist = new List(); + + var Unitlist = await _db.Queryable().Where(q => q.IsDelete == 0).ToListAsync(); + var Departlist = await _db.Queryable().Where(q => q.IsDelete == 0).ToListAsync(); var list = await _db.Queryable() .WhereIF(!UserModel.name.IsNull(), q => q.name.Contains(UserModel.name)) .WhereIF(!UserModel.phone.IsNull(), q => q.phone.Contains(UserModel.phone)) @@ -49,7 +53,30 @@ namespace _24Hour.Controllers.system .WhereIF(!UserModel.cardId.IsNull(), q => q.cardId.Contains(UserModel.cardId)) .Where(q => q.IsDeleted == 0 && q.usertype == 0) .ToPageListAsync(UserModel.PageIndex, UserModel.PageSize); - var data = new QueryResult(UserModel, list); + list.ForEach(q => { + var Unitdata = Unitlist.Where(x => x.Id == q.unitCode)?.FirstOrDefault(); + var Departdata = Departlist.Where(x => x.Id == q.department)?.FirstOrDefault(); + userlist.Add(new + { + q.Id, + q.unitCode, + q.department, + q.name, + q.sex, + q.duties, + q.phone, + q.cardId, + q.wechatId, + q.isdeactivate, + q.becurrent, + q.photo, + q.identity, + q.createtime, + unitname = Unitdata?.unitname, + departname= Departdata?.departname + }); + }); + var data = new { Paging = UserModel,Data = userlist}; result.IsSucceed = true; result.result = data; return result; @@ -237,9 +264,9 @@ namespace _24Hour.Controllers.system [Route("QueryRole")] public async Task QueryRole(App_Sys_RoleInput roledata) { - var totalCount = 0; var list = await _db.Queryable() .WhereIF(roledata.name.NotNull(), q => q.name.Contains(roledata.name)) + .WhereIF(roledata.unitCode.NotNull(), q => q.unitCode.Contains(roledata.unitCode)) .Where(q => q.IsDeleted == 0).ToPageListAsync(roledata.PageIndex, roledata.PageSize); var data = new QueryResult(roledata, list); result.IsSucceed = true; @@ -1016,7 +1043,7 @@ namespace _24Hour.Controllers.system datalist.ForEach(item => { - var data = pidlist.Where(q => q.Id == item.pid).First(); + var data = pidlist.Where(q => q.Id == item.pid).FirstOrDefault(); if (data != null) { var childrenlist = new List(); diff --git a/24Hour/wwwroot/CaseFile/logs/Logs/ExceptionLog/20230614/16.log b/24Hour/wwwroot/CaseFile/logs/Logs/ExceptionLog/20230614/16.log new file mode 100644 index 0000000..cf0cfac --- /dev/null +++ b/24Hour/wwwroot/CaseFile/logs/Logs/ExceptionLog/20230614/16.log @@ -0,0 +1,12 @@ +日志时间:2023-06-14 16:50:49 +************************Exception Start******************************** +Exception Remark:添加数据库日志信息_WriteSysLog_1 发生异常 +Exception Date:2023/6/14 16:50:49 +Exception Type:MySqlConnector.MySqlException +Exception Message:Unknown column 'SerialNumber' in 'field list' +Exception Source:SqlSugar +Exception StackTrace: at SqlSugar.AdoProvider.ExecuteCommand(String sql, SugarParameter[] parameters) + at SqlSugar.InsertableProvider`1.ExecuteCommand() + at Elight.Logic.WriteSysLog.WriteSysLogadd(String operationType, String content, Result result, SqlSugarClient _db, String opeCasDepAccCas) in E:\Code\24Hour.Service\Elight.Logic\WriteSysLog.cs:line 51 +************************Exception End************************************ + diff --git a/24Hour/wwwroot/CaseFile/logs/Logs/ExceptionLog/20230614/17.log b/24Hour/wwwroot/CaseFile/logs/Logs/ExceptionLog/20230614/17.log new file mode 100644 index 0000000..78a1e40 --- /dev/null +++ b/24Hour/wwwroot/CaseFile/logs/Logs/ExceptionLog/20230614/17.log @@ -0,0 +1,72 @@ +日志时间:2023-06-14 17:05:00 +************************Exception Start******************************** +Exception Remark:添加数据库日志信息_WriteSysLog_1 发生异常 +Exception Date:2023/6/14 17:05:00 +Exception Type:MySqlConnector.MySqlException +Exception Message:Unknown column 'SerialNumber' in 'field list' +Exception Source:SqlSugar +Exception StackTrace: at SqlSugar.AdoProvider.ExecuteCommand(String sql, SugarParameter[] parameters) + at SqlSugar.InsertableProvider`1.ExecuteCommand() + at Elight.Logic.WriteSysLog.WriteSysLogadd(String operationType, String content, Result result, SqlSugarClient _db, String opeCasDepAccCas) in E:\Code\24Hour.Service\Elight.Logic\WriteSysLog.cs:line 51 +************************Exception End************************************ + +日志时间:2023-06-14 17:10:15 +************************Exception Start******************************** +Exception Remark:添加数据库日志信息_WriteSysLog_1 发生异常 +Exception Date:2023/6/14 17:10:15 +Exception Type:MySqlConnector.MySqlException +Exception Message:Unknown column 'SerialNumber' in 'field list' +Exception Source:SqlSugar +Exception StackTrace: at SqlSugar.AdoProvider.ExecuteCommand(String sql, SugarParameter[] parameters) + at SqlSugar.InsertableProvider`1.ExecuteCommand() + at Elight.Logic.WriteSysLog.WriteSysLogadd(String operationType, String content, Result result, SqlSugarClient _db, String opeCasDepAccCas) in E:\Code\24Hour.Service\Elight.Logic\WriteSysLog.cs:line 51 +************************Exception End************************************ + +日志时间:2023-06-14 17:11:43 +************************Exception Start******************************** +Exception Remark:添加数据库日志信息_WriteSysLog_1 发生异常 +Exception Date:2023/6/14 17:11:43 +Exception Type:MySqlConnector.MySqlException +Exception Message:Unknown column 'SerialNumber' in 'field list' +Exception Source:SqlSugar +Exception StackTrace: at SqlSugar.AdoProvider.ExecuteCommand(String sql, SugarParameter[] parameters) + at SqlSugar.InsertableProvider`1.ExecuteCommand() + at Elight.Logic.WriteSysLog.WriteSysLogadd(String operationType, String content, Result result, SqlSugarClient _db, String opeCasDepAccCas) in E:\Code\24Hour.Service\Elight.Logic\WriteSysLog.cs:line 51 +************************Exception End************************************ + +日志时间:2023-06-14 17:31:14 +************************Exception Start******************************** +Exception Remark:添加数据库日志信息_WriteSysLog_1 发生异常 +Exception Date:2023/6/14 17:31:14 +Exception Type:MySqlConnector.MySqlException +Exception Message:Unknown column 'SerialNumber' in 'field list' +Exception Source:SqlSugar +Exception StackTrace: at SqlSugar.AdoProvider.ExecuteCommand(String sql, SugarParameter[] parameters) + at SqlSugar.InsertableProvider`1.ExecuteCommand() + at Elight.Logic.WriteSysLog.WriteSysLogadd(String operationType, String content, Result result, SqlSugarClient _db, String opeCasDepAccCas) in E:\Code\24Hour.Service\Elight.Logic\WriteSysLog.cs:line 51 +************************Exception End************************************ + +日志时间:2023-06-14 17:36:33 +************************Exception Start******************************** +Exception Remark:添加数据库日志信息_WriteSysLog_1 发生异常 +Exception Date:2023/6/14 17:36:33 +Exception Type:MySqlConnector.MySqlException +Exception Message:Unknown column 'SerialNumber' in 'field list' +Exception Source:SqlSugar +Exception StackTrace: at SqlSugar.AdoProvider.ExecuteCommand(String sql, SugarParameter[] parameters) + at SqlSugar.InsertableProvider`1.ExecuteCommand() + at Elight.Logic.WriteSysLog.WriteSysLogadd(String operationType, String content, Result result, SqlSugarClient _db, String opeCasDepAccCas) in E:\Code\24Hour.Service\Elight.Logic\WriteSysLog.cs:line 51 +************************Exception End************************************ + +日志时间:2023-06-14 17:52:35 +************************Exception Start******************************** +Exception Remark:添加数据库日志信息_WriteSysLog_1 发生异常 +Exception Date:2023/6/14 17:52:35 +Exception Type:MySqlConnector.MySqlException +Exception Message:Unknown column 'SerialNumber' in 'field list' +Exception Source:SqlSugar +Exception StackTrace: at SqlSugar.AdoProvider.ExecuteCommand(String sql, SugarParameter[] parameters) + at SqlSugar.InsertableProvider`1.ExecuteCommand() + at Elight.Logic.WriteSysLog.WriteSysLogadd(String operationType, String content, Result result, SqlSugarClient _db, String opeCasDepAccCas) in E:\Code\24Hour.Service\Elight.Logic\WriteSysLog.cs:line 51 +************************Exception End************************************ + diff --git a/Elight.Entity/AppMode/App_ReceptionModel.cs b/Elight.Entity/AppMode/App_ReceptionModel.cs index 181c252..a337835 100644 --- a/Elight.Entity/AppMode/App_ReceptionModel.cs +++ b/Elight.Entity/AppMode/App_ReceptionModel.cs @@ -73,6 +73,6 @@ namespace Elight.Entity /// 是否删除:0:未删除、1:删除 /// [DataMember] - public int IsDelete { get; set; } = 0; + public int? IsDelete { get; set; } = 0; } } diff --git a/Elight.Entity/AppMode/StagingModel.cs b/Elight.Entity/AppMode/StagingModel.cs index 5a30e4c..aaec620 100644 --- a/Elight.Entity/AppMode/StagingModel.cs +++ b/Elight.Entity/AppMode/StagingModel.cs @@ -67,6 +67,6 @@ namespace Elight.Entity /// 是否删除:0:未删除、1:删除 /// [DataMember] - public int IsDelete { get; set; } = 0; + public int? IsDelete { get; set; } = 0; } } diff --git a/Elight.Entity/AppMode/StagingNumModel.cs b/Elight.Entity/AppMode/StagingNumModel.cs index b68d5f5..9a71eef 100644 --- a/Elight.Entity/AppMode/StagingNumModel.cs +++ b/Elight.Entity/AppMode/StagingNumModel.cs @@ -49,6 +49,6 @@ namespace Elight.Entity /// 是否删除:0:未删除、1:删除 /// [DataMember] - public int IsDelete { get; set; } = 0; + public int? IsDelete { get; set; } = 0; } } diff --git a/Elight.Entity/SystemModel/App_Sys_DepartModel.cs b/Elight.Entity/SystemModel/App_Sys_DepartModel.cs index 892bda0..ebd3e9f 100644 --- a/Elight.Entity/SystemModel/App_Sys_DepartModel.cs +++ b/Elight.Entity/SystemModel/App_Sys_DepartModel.cs @@ -45,7 +45,7 @@ namespace Elight.Entity /// 是否删除 0否,1是 /// [DataMember] - public int IsDelete { get; set; } + public int? IsDelete { get; set; } = 0; /// /// 创建人Id diff --git a/Elight.Entity/SystemModel/App_Sys_MenuModel.cs b/Elight.Entity/SystemModel/App_Sys_MenuModel.cs index 80fb7bc..ce680e0 100644 --- a/Elight.Entity/SystemModel/App_Sys_MenuModel.cs +++ b/Elight.Entity/SystemModel/App_Sys_MenuModel.cs @@ -69,28 +69,28 @@ namespace Elight.Entity /// 当前菜单在列表中显示时 激活的菜单 /// [DataMember] - public bool currentActiveMenu { get; set; } + public bool? currentActiveMenu { get; set; } /// /// 是否隐藏面包眉 /// [DataMember] - public bool hideBreadcrumb { get; set; } + public bool? hideBreadcrumb { get; set; } /// /// 是否隐藏当前菜单 /// [DataMember] - public bool hideMenu { get; set; } + public bool? hideMenu { get; set; } /// /// 排序 /// [DataMember] - public int sortnum { get; set; } + public int? sortnum { get; set; } /// /// 是否删除 0否,1是 /// [DataMember] - public int IsDelete { get; set; } + public int? IsDelete { get; set; } = 0; /// /// 创建人Id diff --git a/Elight.Entity/SystemModel/App_Sys_RoleMenuModel.cs b/Elight.Entity/SystemModel/App_Sys_RoleMenuModel.cs index e5e0337..3112768 100644 --- a/Elight.Entity/SystemModel/App_Sys_RoleMenuModel.cs +++ b/Elight.Entity/SystemModel/App_Sys_RoleMenuModel.cs @@ -54,7 +54,7 @@ namespace Elight.Entity /// 是否删除 /// [DataMember] - public int IsDeleted { get; set; } = 0; + public int? IsDeleted { get; set; } = 0; } } diff --git a/Elight.Entity/SystemModel/App_Sys_RoleModel.cs b/Elight.Entity/SystemModel/App_Sys_RoleModel.cs index 34efbfa..1decfd2 100644 --- a/Elight.Entity/SystemModel/App_Sys_RoleModel.cs +++ b/Elight.Entity/SystemModel/App_Sys_RoleModel.cs @@ -54,7 +54,7 @@ namespace Elight.Entity /// 是否删除 /// [DataMember] - public int IsDeleted { get; set; } = 0; + public int? IsDeleted { get; set; } = 0; } } diff --git a/Elight.Entity/SystemModel/App_Sys_RoleUserModel.cs b/Elight.Entity/SystemModel/App_Sys_RoleUserModel.cs index b62d3b6..704c872 100644 --- a/Elight.Entity/SystemModel/App_Sys_RoleUserModel.cs +++ b/Elight.Entity/SystemModel/App_Sys_RoleUserModel.cs @@ -54,7 +54,7 @@ namespace Elight.Entity /// 是否删除 /// [DataMember] - public int IsDeleted { get; set; } = 0; + public int? IsDeleted { get; set; } = 0; } } diff --git a/Elight.Entity/SystemModel/App_Sys_UnitModel.cs b/Elight.Entity/SystemModel/App_Sys_UnitModel.cs index e30aca2..273248e 100644 --- a/Elight.Entity/SystemModel/App_Sys_UnitModel.cs +++ b/Elight.Entity/SystemModel/App_Sys_UnitModel.cs @@ -46,7 +46,7 @@ namespace Elight.Entity /// 是否删除 0否,1是 /// [DataMember] - public int IsDelete { get; set; } + public int? IsDelete { get; set; }=0; /// /// 创建人Id diff --git a/Elight.Entity/SystemModel/App_Sys_UserModel.cs b/Elight.Entity/SystemModel/App_Sys_UserModel.cs index 9200ea5..97d70d3 100644 --- a/Elight.Entity/SystemModel/App_Sys_UserModel.cs +++ b/Elight.Entity/SystemModel/App_Sys_UserModel.cs @@ -77,19 +77,19 @@ namespace Elight.Entity /// 账号类型0:系统,1:APP /// [DataMember] - public int usertype { get; set; } + public int? usertype { get; set; } /// /// 是否停用 0:启用,1禁用 /// [DataMember] - public int isdeactivate { get; set; } + public int? isdeactivate { get; set; } /// /// 是否App通用:0:通用,1:不通用 /// [DataMember] - public int becurrent { get; set; } + public int? becurrent { get; set; } /// /// 头像地址 @@ -101,13 +101,13 @@ namespace Elight.Entity /// 性别 0:女 1:男 /// [DataMember] - public int sex { get; set; } + public int? sex { get; set; } /// /// 是否删除 /// [DataMember] - public int IsDeleted { get; set; } = 0; + public int? IsDeleted { get; set; } = 0; /// /// 审核状态 /// diff --git a/Elight.Entity/SystemModel/Func_Dossier_LogRecordModel.cs b/Elight.Entity/SystemModel/Func_Dossier_LogRecordModel.cs index 2019ccc..9db08e1 100644 --- a/Elight.Entity/SystemModel/Func_Dossier_LogRecordModel.cs +++ b/Elight.Entity/SystemModel/Func_Dossier_LogRecordModel.cs @@ -99,7 +99,7 @@ namespace Elight.Entity.SystemModel /// 是否删除 /// [DataMember] - public int IsDeleted { get; set; } + public int? IsDeleted { get; set; } /*CodeAutoBuilderArea*/