¤NameÙ,åæâSqlSugar.SqlSugarExceptionâå¼å¸¸¤User¤Name¯zhangxianzhi123¤Icon¤GuidÙ$061ac4c0-1f94-4312-b34d-211f1e407e0b¢IḑServiceÀ«TimeCreated×ÿ
© i¢IdÙ$eaf98ab3-b4d9-4cc5-928a-e862cbe2a6c9¢IdÙ@Microsoft.VisualStudio.Conversations.Debugging.ExceptionAnalysis¨Metadata¨IsThreadðConversationMode°ExperimentalChatªResponders¤Name¥Debug¤Icon¤GuidÙ$ae27a6b0-e345-4288-96df-5eaf394ee369¢IdÍM§Service¤Name¾DebugAssistantResponderService§Version£0.3 CorrelationIdÙ$0d50867c-b65b-40b5-8aa4-2182e81e9c7f©MessageIdÙ$656bb92b-d3b4-45b7-b1d6-35db7258a6d4§Context®ValueContainerÙ¤Microsoft.VisualStudio.Copilot.Debugging.DebuggerContext, Microsoft.VisualStudio.Copilot.Shared, Version=17.14.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3aÅ©CallStack«StackFrames«FrameNumber¤NameÙ[[å¼å¸¸] WIDESEA_Core.dll!WIDESEA_Core.HostedService.PermissionDataHostService.GetUserRoles®IsExternalCode®IsCurrentFrameèLanguageÀ«CodeContext«CodeSnippetÜ ,ÙE public static List<UserRole> GetUserRoles(ISqlSugarClient db)© {Ùg List<ExpandoObject> roles = db.Queryable("Sys_Role", "x").Select(RoleSelectModes).ToList();Ù= List<dynamic> roleDynamics = new List<dynamic>();Ù' foreach (var item in roles) {Ù' roleDynamics.Add(item); } ÙA List<dynamic> roleDataDynamics = new List<dynamic>();Ù} List<ExpandoObject> roleDatas = db.Queryable("Sys_RoleDataPermission", "x").Select(RoleDataSelectModes).ToList();Ù+ foreach (var item in roleDatas) {Ù+ roleDataDynamics.Add(item); } Ùg List<ExpandoObject> users = db.Queryable("Sys_User", "x").Select(UserSelectModes).ToList(); Ù< List<UserRole> userRoles = new List<UserRole>();Ù' foreach (var item in users) {Ù$ dynamic user = item;ÙZ dynamic? role = roleDynamics.FirstOrDefault(x => x.RoleId == user.RoleId);Ù
List<object> warehouseIds = roleDataDynamics.Where(x => x.RoleId == user.RoleId).Select(x => x.WarehouseId).ToList();Ù0 List<int> ids = new List<int>();Ù< for (int i = 0; i < warehouseIds.Count; i++)± {Ù> ids.Add(Convert.ToInt32(warehouseIds[i]));± }Ù! if (role != null)± {Ù. userRoles.Add(new UserRoleµ {Ù- RoleId = role.RoleId,Ù1 RoleName = role.RoleName,Ù1 ParentId = role.ParentId,Ù- UserId = user.UserId,Ù1 UserName = user.UserName,Ù* WarehouseIds = ids· });± } }½ return userRoles;© }³ActiveStatementLine¨FilePathÙC:\Users\Administrator\Desktop\代ç åº\FengLvLiTiKu\代ç 管ç\WMS\WMSServices\WIDESEA_Core\HostedService\PermissionDataHostService.cs»OriginalActiveStatementLine.¶CodeContextWasExcluded«FrameNumber¤NameÙY[å¼å¸¸] WIDESEA_Core.dll!WIDESEA_Core.HostedService.PermissionDataHostService.StartAsync®IsExternalCode®IsCurrentFrame¨LanguageÀ«CodeContext«CodeSnippetÙC public Task StartAsync(CancellationToken cancellationToken)© {ÙC List<UserRole> userRoles = GetUserRoles(_dbContext.Db);Ù" UserRoles = userRoles;ÙJ _cacheService.AddOrUpdate("UserRoles", userRoles.Serialize()); Ù& return Task.CompletedTask;© }³ActiveStatementLine¨FilePathÙC:\Users\Administrator\Desktop\代ç åº\FengLvLiTiKu\代ç 管ç\WMS\WMSServices\WIDESEA_Core\HostedService\PermissionDataHostService.cs»OriginalActiveStatementLine ¶CodeContextWasExcluded«FrameNumber¤Name®[å¤é¨ä»£ç ]®IsExternalCodeîIsCurrentFrame¨LanguageÀ«CodeContextÀ¶CodeContextWasExcluded«FrameNumber¤NameÙK[æ£å¨çå¾
弿¥æä½ï¼å廿æ Enter 坿¥ç弿¥è°ç¨å æ ]®IsExternalCodeîIsCurrentFrame¨LanguageÀ«CodeContextÀ¶CodeContextWasExcluded«FrameNumber¤Name®[å¤é¨ä»£ç ]®IsExternalCodeîIsCurrentFrame¨LanguageÀ«CodeContextÀ¶CodeContextWasExcluded«FrameNumber¤NameÙ%WIDESEA_WMSServer.dll!Program.<Main>$®IsExternalCode®IsCurrentFrame¨LanguageÀ«CodeContext«CodeSnippetÜ Ù-defaultFilesOptions.DefaultFileNames.Clear();Ù7defaultFilesOptions.DefaultFileNames.Add("index.html");Ù)app.UseDefaultFiles(defaultFilesOptions);Ù+app.UseMiddleware<HttpRequestMiddleware>();µapp.UseStaticFiles();¶app.UseCookiePolicy();¹app.UseStatusCodePages(); ±app.UseRouting(); ¸app.UseAuthentication();·app.UseAuthorization(); µapp.MapControllers(); ªapp.Run();³ActiveStatementLine¨FilePathÙoC:\Users\Administrator\Desktop\代ç åº\FengLvLiTiKu\代ç 管ç\WMS\WMSServices\WIDESEA_WMSServer\Program.cs»OriginalActiveStatementLine̶CodeContextWasExcluded·AdditionalSymbolContextÀ°HasOmittedFramesæLocals©Variables¤Nameª$exception¥ValueÚ{"䏿æç¤º : è¿æ¥æ°æ®åºè¿ç¨ä¸åçéè¯¯ï¼æ£æ¥æå¡å¨æ¯å¦æ£å¸¸è¿æ¥å符串æ¯å¦æ£ç¡®ï¼é误信æ¯ï¼A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - 管éçå¦ä¸ç«¯ä¸æ ä»»ä½è¿ç¨ã)DbType=\"SqlServer\";ConfigId=\"WIDESEA\".\r\nEnglish Message : Connection open error . A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - 管éçå¦ä¸ç«¯ä¸æ ä»»ä½è¿ç¨ã)DbType=\"SqlServer\";ConfigId=\"WIDESEA\" "}¤TypeºSqlSugar.SqlSugarException¬IsExpandableéExceptionExceptionTypeºSqlSugar.SqlSugarException°ExceptionMessageÚ䏿æç¤º : è¿æ¥æ°æ®åºè¿ç¨ä¸åçéè¯¯ï¼æ£æ¥æå¡å¨æ¯å¦æ£å¸¸è¿æ¥å符串æ¯å¦æ£ç¡®ï¼é误信æ¯ï¼A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - 管éçå¦ä¸ç«¯ä¸æ ä»»ä½è¿ç¨ã)DbType="SqlServer";ConfigId="WIDESEA".
|
English Message : Connection open error . A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - 管éçå¦ä¸ç«¯ä¸æ ä»»ä½è¿ç¨ã)DbType="SqlServer";ConfigId="WIDESEA" «CodeContext«CodeSnippetÜ ,ÙE public static List<UserRole> GetUserRoles(ISqlSugarClient db)© {Ùg List<ExpandoObject> roles = db.Queryable("Sys_Role", "x").Select(RoleSelectModes).ToList();Ù= List<dynamic> roleDynamics = new List<dynamic>();Ù' foreach (var item in roles) {Ù' roleDynamics.Add(item); } ÙA List<dynamic> roleDataDynamics = new List<dynamic>();Ù} List<ExpandoObject> roleDatas = db.Queryable("Sys_RoleDataPermission", "x").Select(RoleDataSelectModes).ToList();Ù+ foreach (var item in roleDatas) {Ù+ roleDataDynamics.Add(item); } Ùg List<ExpandoObject> users = db.Queryable("Sys_User", "x").Select(UserSelectModes).ToList(); Ù< List<UserRole> userRoles = new List<UserRole>();Ù' foreach (var item in users) {Ù$ dynamic user = item;ÙZ dynamic? role = roleDynamics.FirstOrDefault(x => x.RoleId == user.RoleId);Ù
List<object> warehouseIds = roleDataDynamics.Where(x => x.RoleId == user.RoleId).Select(x => x.WarehouseId).ToList();Ù0 List<int> ids = new List<int>();Ù< for (int i = 0; i < warehouseIds.Count; i++)± {Ù> ids.Add(Convert.ToInt32(warehouseIds[i]));± }Ù! if (role != null)± {Ù. userRoles.Add(new UserRoleµ {Ù- RoleId = role.RoleId,Ù1 RoleName = role.RoleName,Ù1 ParentId = role.ParentId,Ù- UserId = user.UserId,Ù1 UserName = user.UserName,Ù* WarehouseIds = ids· });± } }½ return userRoles;© }³ActiveStatementLine¨FilePathÙC:\Users\Administrator\Desktop\代ç åº\FengLvLiTiKu\代ç 管ç\WMS\WMSServices\WIDESEA_Core\HostedService\PermissionDataHostService.cs»OriginalActiveStatementLine.¯InnerExceptions²OriginalStackTraceÀ¹HasOmittedInnerExceptions¶CodeContextWasExcluded¨DeadlockÀ¯CopilotTypeName¯DebuggerContext¨TypeName¤Name¯DebuggerContext§IsArray¢IdÙ$022aea4e-af28-41ec-90d0-d21d7c2bac01¯ProviderMoniker¤NameÙ6Microsoft.VisualStudio.Copilot.DebuggerContextProvider§Version£0.3¦SourceÙ6Microsoft.VisualStudio.Copilot.DebuggerContextProvider©Relevance ¦Member¨debugger©CanReduceéRequestIdÙ$0d50867c-b65b-40b5-8aa4-2182e81e9c7f©Reference©#debugger¦Traits«IsEphemeral§Content ¢IdÄÀ6*J¦K(KÓÝëªVisibility«Annotations§ContentÙ=ä½¿ç¨ #debugger åæâSqlSugar.SqlSugarExceptionâå¼å¸¸ ¢IdÄÄC²XE«þ]j,*ªVisibility«Annotations§ContentÚHelp me analyze the current exception and find the root cause for it, not just the immediate cause. First, think about the strategy for solving the problem. Do NOT make assumptions about the situation- use the functions available to you to request data and context that would be helpful in finding the solution. As you obtain additional data, you will likely need to request more, take your time, call the functions as much as you need to gather all the information. Exhaust every tool and context available before concluding that you cannot proceed. Do not evaluate expressions of methods that have already been called and their return value is stored in a variable. Use the stored variable values instead. Once you think you have figured out what's going on, first, concisely describe the error and then explain in less than 200 words why I am getting the error. There is more code in my application that might be contributing to the error. You can suggest a fix or tell me what additional information is needed to solve it.¨Metadata©exceptionSystem.StringįCustomException¬EventMessageÀ¦Intent°ExplainException¨GuidanceÀ¥Model¦Family§gpt-4.1§ModelIdÀ¬Capabilities §Purpose²DirectedResponders©FunctionsCorrelationIdÙ$0d50867c-b65b-40b5-8aa4-2182e81e9c7f©MessageIdÙ$8ee7a531-4fd1-42fe-9457-8234fa45849b§Context®ValueContainerÙ¤Microsoft.VisualStudio.Copilot.Debugging.DebuggerContext, Microsoft.VisualStudio.Copilot.Shared, Version=17.14.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3aÅ©CallStack«StackFrames«FrameNumber¤NameÙ[[å¼å¸¸] WIDESEA_Core.dll!WIDESEA_Core.HostedService.PermissionDataHostService.GetUserRoles®IsExternalCode®IsCurrentFrameèLanguageÀ«CodeContext«CodeSnippetÜ ,ÙE public static List<UserRole> GetUserRoles(ISqlSugarClient db)© {Ùg List<ExpandoObject> roles = db.Queryable("Sys_Role", "x").Select(RoleSelectModes).ToList();Ù= List<dynamic> roleDynamics = new List<dynamic>();Ù' foreach (var item in roles) {Ù' roleDynamics.Add(item); } ÙA List<dynamic> roleDataDynamics = new List<dynamic>();Ù} List<ExpandoObject> roleDatas = db.Queryable("Sys_RoleDataPermission", "x").Select(RoleDataSelectModes).ToList();Ù+ foreach (var item in roleDatas) {Ù+ roleDataDynamics.Add(item); } Ùg List<ExpandoObject> users = db.Queryable("Sys_User", "x").Select(UserSelectModes).ToList(); Ù< List<UserRole> userRoles = new List<UserRole>();Ù' foreach (var item in users) {Ù$ dynamic user = item;ÙZ dynamic? role = roleDynamics.FirstOrDefault(x => x.RoleId == user.RoleId);Ù
List<object> warehouseIds = roleDataDynamics.Where(x => x.RoleId == user.RoleId).Select(x => x.WarehouseId).ToList();Ù0 List<int> ids = new List<int>();Ù< for (int i = 0; i < warehouseIds.Count; i++)± {Ù> ids.Add(Convert.ToInt32(warehouseIds[i]));± }Ù! if (role != null)± {Ù. userRoles.Add(new UserRoleµ {Ù- RoleId = role.RoleId,Ù1 RoleName = role.RoleName,Ù1 ParentId = role.ParentId,Ù- UserId = user.UserId,Ù1 UserName = user.UserName,Ù* WarehouseIds = ids· });± } }½ return userRoles;© }³ActiveStatementLine¨FilePathÙC:\Users\Administrator\Desktop\代ç åº\FengLvLiTiKu\代ç 管ç\WMS\WMSServices\WIDESEA_Core\HostedService\PermissionDataHostService.cs»OriginalActiveStatementLine.¶CodeContextWasExcluded«FrameNumber¤NameÙY[å¼å¸¸] WIDESEA_Core.dll!WIDESEA_Core.HostedService.PermissionDataHostService.StartAsync®IsExternalCode®IsCurrentFrame¨LanguageÀ«CodeContext«CodeSnippetÙC public Task StartAsync(CancellationToken cancellationToken)© {ÙC List<UserRole> userRoles = GetUserRoles(_dbContext.Db);Ù" UserRoles = userRoles;ÙJ _cacheService.AddOrUpdate("UserRoles", userRoles.Serialize()); Ù& return Task.CompletedTask;© }³ActiveStatementLine¨FilePathÙC:\Users\Administrator\Desktop\代ç åº\FengLvLiTiKu\代ç 管ç\WMS\WMSServices\WIDESEA_Core\HostedService\PermissionDataHostService.cs»OriginalActiveStatementLine ¶CodeContextWasExcluded«FrameNumber¤Name®[å¤é¨ä»£ç ]®IsExternalCodeîIsCurrentFrame¨LanguageÀ«CodeContextÀ¶CodeContextWasExcluded«FrameNumber¤NameÙK[æ£å¨çå¾
弿¥æä½ï¼å廿æ Enter 坿¥ç弿¥è°ç¨å æ ]®IsExternalCodeîIsCurrentFrame¨LanguageÀ«CodeContextÀ¶CodeContextWasExcluded«FrameNumber¤Name®[å¤é¨ä»£ç ]®IsExternalCodeîIsCurrentFrame¨LanguageÀ«CodeContextÀ¶CodeContextWasExcluded«FrameNumber¤NameÙ%WIDESEA_WMSServer.dll!Program.<Main>$®IsExternalCode®IsCurrentFrame¨LanguageÀ«CodeContext«CodeSnippetÜ Ù-defaultFilesOptions.DefaultFileNames.Clear();Ù7defaultFilesOptions.DefaultFileNames.Add("index.html");Ù)app.UseDefaultFiles(defaultFilesOptions);Ù+app.UseMiddleware<HttpRequestMiddleware>();µapp.UseStaticFiles();¶app.UseCookiePolicy();¹app.UseStatusCodePages(); ±app.UseRouting(); ¸app.UseAuthentication();·app.UseAuthorization(); µapp.MapControllers(); ªapp.Run();³ActiveStatementLine¨FilePathÙoC:\Users\Administrator\Desktop\代ç åº\FengLvLiTiKu\代ç 管ç\WMS\WMSServices\WIDESEA_WMSServer\Program.cs»OriginalActiveStatementLine̶CodeContextWasExcluded·AdditionalSymbolContextÀ°HasOmittedFramesæLocals©Variables¤Nameª$exception¥ValueÚ{"䏿æç¤º : è¿æ¥æ°æ®åºè¿ç¨ä¸åçéè¯¯ï¼æ£æ¥æå¡å¨æ¯å¦æ£å¸¸è¿æ¥å符串æ¯å¦æ£ç¡®ï¼é误信æ¯ï¼A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - 管éçå¦ä¸ç«¯ä¸æ ä»»ä½è¿ç¨ã)DbType=\"SqlServer\";ConfigId=\"WIDESEA\".\r\nEnglish Message : Connection open error . A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - 管éçå¦ä¸ç«¯ä¸æ ä»»ä½è¿ç¨ã)DbType=\"SqlServer\";ConfigId=\"WIDESEA\" "}¤TypeºSqlSugar.SqlSugarException¬IsExpandableéExceptionExceptionTypeºSqlSugar.SqlSugarException°ExceptionMessageÚ䏿æç¤º : è¿æ¥æ°æ®åºè¿ç¨ä¸åçéè¯¯ï¼æ£æ¥æå¡å¨æ¯å¦æ£å¸¸è¿æ¥å符串æ¯å¦æ£ç¡®ï¼é误信æ¯ï¼A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - 管éçå¦ä¸ç«¯ä¸æ ä»»ä½è¿ç¨ã)DbType="SqlServer";ConfigId="WIDESEA".
|
English Message : Connection open error . A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - 管éçå¦ä¸ç«¯ä¸æ ä»»ä½è¿ç¨ã)DbType="SqlServer";ConfigId="WIDESEA" «CodeContext«CodeSnippetÜ ,ÙE public static List<UserRole> GetUserRoles(ISqlSugarClient db)© {Ùg List<ExpandoObject> roles = db.Queryable("Sys_Role", "x").Select(RoleSelectModes).ToList();Ù= List<dynamic> roleDynamics = new List<dynamic>();Ù' foreach (var item in roles) {Ù' roleDynamics.Add(item); } ÙA List<dynamic> roleDataDynamics = new List<dynamic>();Ù} List<ExpandoObject> roleDatas = db.Queryable("Sys_RoleDataPermission", "x").Select(RoleDataSelectModes).ToList();Ù+ foreach (var item in roleDatas) {Ù+ roleDataDynamics.Add(item); } Ùg List<ExpandoObject> users = db.Queryable("Sys_User", "x").Select(UserSelectModes).ToList(); Ù< List<UserRole> userRoles = new List<UserRole>();Ù' foreach (var item in users) {Ù$ dynamic user = item;ÙZ dynamic? role = roleDynamics.FirstOrDefault(x => x.RoleId == user.RoleId);Ù
List<object> warehouseIds = roleDataDynamics.Where(x => x.RoleId == user.RoleId).Select(x => x.WarehouseId).ToList();Ù0 List<int> ids = new List<int>();Ù< for (int i = 0; i < warehouseIds.Count; i++)± {Ù> ids.Add(Convert.ToInt32(warehouseIds[i]));± }Ù! if (role != null)± {Ù. userRoles.Add(new UserRoleµ {Ù- RoleId = role.RoleId,Ù1 RoleName = role.RoleName,Ù1 ParentId = role.ParentId,Ù- UserId = user.UserId,Ù1 UserName = user.UserName,Ù* WarehouseIds = ids· });± } }½ return userRoles;© }³ActiveStatementLine¨FilePathÙC:\Users\Administrator\Desktop\代ç åº\FengLvLiTiKu\代ç 管ç\WMS\WMSServices\WIDESEA_Core\HostedService\PermissionDataHostService.cs»OriginalActiveStatementLine.¯InnerExceptions²OriginalStackTraceÀ¹HasOmittedInnerExceptions¶CodeContextWasExcluded¨DeadlockÀ¯CopilotTypeName¯DebuggerContext¨TypeName¤Name¯DebuggerContext§IsArray¢IdÙ$022aea4e-af28-41ec-90d0-d21d7c2bac01¯ProviderMoniker¤NameÙ6Microsoft.VisualStudio.Copilot.DebuggerContextProvider§Version£0.3¦SourceÙ6Microsoft.VisualStudio.Copilot.DebuggerContextProvider©Relevance ¦Member¨debugger©CanReduceéRequestIdÙ$0d50867c-b65b-40b5-8aa4-2182e81e9c7f©Reference©#debugger¦Traits«IsEphemeral§Content¢IdÄcóVZÈ?ÏA}Ǹ¬´fPªVisibility«Annotations¥StateÀ«DescriptionÀ¦Status¨Function¢Id½call_VYp68UuOzysSVpaVLGNkpopt¤Name¹GetAdditionalContextAsync©Arguments ¤jsonÙá{"expressions":["db"],"reason":"Understanding the state and configuration of the ISqlSugarClient instance (db) is critical to diagnosing connection issues, as misconfiguration or disposal could cause the observed exception."}¬ConfirmationÀ·ConfirmationRequirement¦Result ¥Value®ValueContainerSystem.StringÄ"Ù GetAdditionalContextAsync failed¯CopilotTypeName¦string¨TypeName¤Name¦string§IsArray¢IdÄláxðb6A¬þ¢E=8ªVisibility«Annotations¥StateÀ«DescriptionÀ¦Status¨Function¢Id½call_E87PZBHSbkK7pHuO2vQZH8cp¤Name¹GetAdditionalContextAsync©Arguments ¤jsonÚH{"expressions":["_dbContext.Db"],"reason":"The exception occurs when calling GetUserRoles(_dbContext.Db). Understanding the state and configuration of _dbContext.Db is essential to determine if the database connection is properly set up or if there are issues such as disposal, misconfiguration, or invalid connection strings."}¬ConfirmationÀ·ConfirmationRequirement¦Result ¥Value®ValueContainerSystem.StringÄ"Ù GetAdditionalContextAsync failed¯CopilotTypeName¦string¨TypeName¤Name¦string§IsArray¢IdÄ4~ÞÌxF/E«í¿ B*ªVisibility«Annotations¥StateÙ#读å PermissionDataHostService.cs«DescriptionÀ¦Status¨Function¢Id½call_wf0yrwLWrVhtBLNdEKBYg40X¤Name¨get_file©Arguments ¤jsonÙF{"filename":"WIDESEA_Core/HostedService/PermissionDataHostService.cs"}¬ConfirmationÀ·ConfirmationRequirement ¦Result ¥Value®ValueContainerÙMicrosoft.VisualStudio.Copilot.CopilotContext, Microsoft.VisualStudio.Copilot, Version=17.14.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3aÅ®ValueContainerÙMicrosoft.VisualStudio.Copilot.DocumentContext, Microsoft.VisualStudio.Copilot, Version=17.14.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3aÅÒ
§ContentÚ±using HslCommunication.WebSocket;
|
using Microsoft.Extensions.Hosting;
|
using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
using System.Dynamic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using WIDESEA_Core.Helper;
|
using WIDESEA_Core.Seed;
|
using ICacheService = WIDESEA_Core.Caches.ICacheService;
|
|
namespace WIDESEA_Core.HostedService
|
{
|
public class PermissionDataHostService : IHostedService
|
{
|
private readonly DBContext _dbContext;
|
private readonly ICacheService _cacheService;
|
private readonly WebSocketServer _server;
|
|
public static List<UserRole> UserRoles;
|
|
public PermissionDataHostService(DBContext dbContext, ICacheService cacheService, WebSocketServer server)
|
{
|
_dbContext = dbContext;
|
_cacheService = cacheService;
|
_server = server;
|
}
|
|
public Task StartAsync(CancellationToken cancellationToken)
|
{
|
List<UserRole> userRoles = GetUserRoles(_dbContext.Db);
|
UserRoles = userRoles;
|
_cacheService.AddOrUpdate("UserRoles", userRoles.Serialize());
|
|
return Task.CompletedTask;
|
}
|
|
public Task StopAsync(CancellationToken cancellationToken)
|
{
|
throw new NotImplementedException();
|
}
|
|
public static List<UserRole> GetUserRoles(ISqlSugarClient db)
|
{
|
List<ExpandoObject> roles = db.Queryable("Sys_Role", "x").Select(RoleSelectModes).ToList();
|
List<dynamic> roleDynamics = new List<dynamic>();
|
foreach (var item in roles)
|
{
|
roleDynamics.Add(item);
|
}
|
|
List<dynamic> roleDataDynamics = new List<dynamic>();
|
List<ExpandoObject> roleDatas = db.Queryable("Sys_RoleDataPermission", "x").Select(RoleDataSelectModes).ToList();
|
foreach (var item in roleDatas)
|
{
|
roleDataDynamics.Add(item);
|
}
|
|
List<ExpandoObject> users = db.Queryable("Sys_User", "x").Select(UserSelectModes).ToList();
|
|
List<UserRole> userRoles = new List<UserRole>();
|
foreach (var item in users)
|
{
|
dynamic user = item;
|
dynamic? role = roleDynamics.FirstOrDefault(x => x.RoleId == user.RoleId);
|
List<object> warehouseIds = roleDataDynamics.Where(x => x.RoleId == user.RoleId).Select(x => x.WarehouseId).ToList();
|
List<int> ids = new List<int>();
|
for (int i = 0; i < warehouseIds.Count; i++)
|
{
|
ids.Add(Convert.ToInt32(warehouseIds[i]));
|
}
|
if (role != null)
|
{
|
userRoles.Add(new UserRole
|
{
|
RoleId = role.RoleId,
|
RoleName = role.RoleName,
|
ParentId = role.ParentId,
|
UserId = user.UserId,
|
UserName = user.UserName,
|
WarehouseIds = ids
|
});
|
}
|
}
|
return userRoles;
|
}
|
|
public static List<UserRole> GetUserRoles(ISqlSugarClient db, int userId)
|
{
|
List<ExpandoObject> roles = db.Queryable("Sys_Role", "x").Select(RoleSelectModes).ToList();
|
List<dynamic> roleDynamics = new List<dynamic>();
|
foreach (var item in roles)
|
{
|
roleDynamics.Add(item);
|
}
|
|
List<dynamic> roleDataDynamics = new List<dynamic>();
|
List<ExpandoObject> roleDatas = db.Queryable("Sys_RoleDataPermission", "x").Select(RoleDataSelectModes).ToList();
|
foreach (var item in roleDatas)
|
{
|
roleDataDynamics.Add(item);
|
}
|
|
List<ExpandoObject> users = db.Queryable("Sys_User", "x").Where($"UserId={userId}").Select(UserSelectModes).ToList();
|
|
List<UserRole> userRoles = new List<UserRole>();
|
foreach (var item in users)
|
{
|
dynamic user = item;
|
dynamic? role = roleDynamics.FirstOrDefault(x => x.RoleId == user.RoleId);
|
List<object> warehouseIds = roleDataDynamics.Where(x => x.RoleId == user.RoleId).Select(x => x.WarehouseId).ToList();
|
List<int> ids = new List<int>();
|
for (int i = 0; i < warehouseIds.Count; i++)
|
{
|
ids.Add(Convert.ToInt32(warehouseIds[i]));
|
}
|
if (role != null)
|
{
|
userRoles.Add(new UserRole
|
{
|
RoleId = role.RoleId,
|
RoleName = role.RoleName,
|
ParentId = role.ParentId,
|
UserId = user.UserId,
|
UserName = user.UserName,
|
WarehouseIds = ids
|
});
|
}
|
}
|
return userRoles;
|
}
|
|
static List<SelectModel> RoleSelectModes = new List<SelectModel>()
|
{
|
new SelectModel()
|
{
|
FieldName = "RoleId",
|
},
|
new SelectModel()
|
{
|
FieldName = "ParentId",
|
},
|
new SelectModel()
|
{
|
FieldName = "RoleName",
|
},
|
};
|
|
static List<SelectModel> UserSelectModes = new List<SelectModel>()
|
{
|
new SelectModel()
|
{
|
FieldName = "UserId",
|
},
|
new SelectModel()
|
{
|
FieldName = "UserName",
|
},
|
new SelectModel()
|
{
|
FieldName = "RoleId",
|
},
|
new SelectModel()
|
{
|
FieldName = "RoleName",
|
}
|
};
|
|
static List<SelectModel> RoleDataSelectModes = new List<SelectModel>()
|
{
|
new SelectModel()
|
{
|
FieldName = "RoleId",
|
},
|
new SelectModel()
|
{
|
FieldName = "WarehouseId",
|
}
|
};
|
}
|
|
public class UserRole
|
{
|
public int UserId { get; set; }
|
|
public int RoleId { get; set; }
|
|
public string RoleName { get; set; }
|
|
public string UserName { get; set; }
|
|
public int ParentId { get; set; }
|
|
public int AuthorityScope { get; set; }
|
|
public List<int> WarehouseIds { get; set; }
|
}
|
}
|
¯OriginalContentÀªSelections¨FilePathÙC:\Users\Administrator\Desktop\代ç åº\FengLvLiTiKu\代ç 管ç\WMS\WMSServices\WIDESEA_Core\HostedService\PermissionDataHostService.cs¨Language¢C#¯CopilotTypeName¯DocumentContext¨TypeName¤Name¯DocumentContext§IsArray¢IdÄÔû]g4LºW¡[=Ná¯ProviderMoniker¤NameÙ6Microsoft.VisualStudio.Copilot.DocumentContextProvider§Version£0.3¦SourceÙ6Microsoft.VisualStudio.Copilot.DocumentContextProvider©Relevance ¦Member¤file©CanReduceéRequestIdÄ|P [¶µ@¤!è©ReferenceÀ¦Traits«IsEphemeral¯CopilotTypeName®CopilotContext¨TypeName¤Name®CopilotContext§IsArray¢IdÄ©zg¼xÓC¶ÈS®9ªVisibility«Annotations¥StateÙ8æ¾ä¸å°æä»¶âWIDESEA_Core/Helper/DBContext.csâã«DescriptionÀ¦Status¨Function¢Id½call_NxULpgZDeT4aQSaqikF9Ceav¤Name¨get_file©Arguments ¤jsonÙ/{"filename":"WIDESEA_Core/Helper/DBContext.cs"}¬ConfirmationÀ·ConfirmationRequirement ¦Result ¥Value®ValueContainerÙMicrosoft.VisualStudio.Copilot.CopilotContext, Microsoft.VisualStudio.Copilot, Version=17.14.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3aÄÀ¯CopilotTypeName®CopilotContext¨TypeName¤Name®CopilotContext§IsArray¢IdÄ4òЦ&AADQ ˪Visibility«Annotations¥StateÙ8æ¾ä¸å°æä»¶âWIDESEA_Core/Seed/SelectModel.csâã«DescriptionÀ¦Status¨Function¢Id½call_2SXKFobEeuFzH5yOLDXRtbC7¤Name¨get_file©Arguments ¤jsonÙ/{"filename":"WIDESEA_Core/Seed/SelectModel.cs"}¬ConfirmationÀ·ConfirmationRequirement ¦Result ¥Value®ValueContainerÙMicrosoft.VisualStudio.Copilot.CopilotContext, Microsoft.VisualStudio.Copilot, Version=17.14.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3aÄÀ¯CopilotTypeName®CopilotContext¨TypeName¤Name®CopilotContext§IsArrayÂ
¢IdÄÚ7½¿J®CáÁöªVisibility«Annotations§ContentÚ³**Concise Error Description:**
|
The exception is a `SqlSugar.SqlSugarException` indicating a database connection issue:
|
> "A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - 管éçå¦ä¸ç«¯ä¸æ ä»»ä½è¿ç¨ã)"
|
|
**Why You Are Getting This Error:**
|
This error means your application can reach the SQL Server, but the login process fails. The message "管éçå¦ä¸ç«¯ä¸æ ä»»ä½è¿ç¨" ("No process is on the other end of the pipe") suggests a problem with the SQL Server's ability to complete the login handshake. This is often caused by:
|
- SQL Server service not running or restarting during connection.
|
- Incorrect authentication mode or credentials.
|
- Network/protocol issues (e.g., Shared Memory not supported remotely).
|
- SQL Server misconfiguration or resource exhaustion.
|
|
**Next Steps / Suggestions:**
|
- Check if the SQL Server service is running and accessible.
|
- Verify the connection string in your `DBContext` for correctness.
|
- Ensure the SQL Server allows the authentication method you are using.
|
- Check for recent changes to SQL Server configuration or network environment.
|
- Review the construction and lifecycle of your `ISqlSugarClient` instance for premature disposal or misconfiguration.
|
|
If you provide the contents of your `DBContext` class and your connection string, I can help further pinpoint the root cause.
|
|
¨Mentions¨Metadata¬EventMessageÀ©SessionIdÙ$eaf98ab3-b4d9-4cc5-928a-e862cbe2a6c9¢IdÙ@Microsoft.VisualStudio.Conversations.Debugging.ExceptionAnalysis¦Author¤Name¥Debug¤Icon¤GuidÙ$ae27a6b0-e345-4288-96df-5eaf394ee369¢IdÍM§Service¤Name¾DebugAssistantResponderService§Version£0.3¦Status¦Quotas¤Type©Timestamp×ÿ
|
»ài ©ResetTimeÖÿi¢0 ¥UsageË@Q ¥LimitË@@ ®OverageAllowed¤Type©Timestamp×ÿ
|
»ài ©ResetTimeÖÿi¢0 ¥UsageË@uÀ ¥LimitË@¯@ ®OverageAllowed¤Type©Timestamp×ÿ
|
»ài ©ResetTimeÖÿi¢0 ¥UsageË ¥LimitË ®OverageAllowed©FollowUps§MessageÙ Show me the DBContext class code¯SendImmediately§MessageÙ3How can I check if my connection string is correct?¯SendImmediately¨CanRetryÂ
|