From 180080adbb4b90903e351e41c3c9c5c3f575deda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B7=83=E7=82=B9=E5=B7=A5=E5=9D=8A?= Date: Sat, 4 Apr 2020 09:19:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=9A=E8=AF=9D=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E5=86=99=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SiMay.RemoteClient.NewCore/ApplicationService/FileService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SiMay.RemoteClient.NewCore/ApplicationService/FileService.cs b/SiMay.RemoteClient.NewCore/ApplicationService/FileService.cs index 088f129..577ffac 100644 --- a/SiMay.RemoteClient.NewCore/ApplicationService/FileService.cs +++ b/SiMay.RemoteClient.NewCore/ApplicationService/FileService.cs @@ -494,7 +494,7 @@ namespace SiMay.ServiceCore .ToArray(); foreach (var sessionItem in sessions) { - if (sessionItem.SessionState == 1 && sessionItem.UserName.ToLower() != "system") + if (sessionItem.HasUserProcess && sessionItem.UserName.ToLower() != "system") { List userFolders = GetUserFolderPath(); foreach (var item in userFolders) -- Gitee From 45a42aebf7e95e4341f2ec033c5bbe41f6489546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B7=83=E7=82=B9=E5=B7=A5=E5=9D=8A?= Date: Sat, 4 Apr 2020 18:42:21 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9=E8=AE=BF=E9=97=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApplicationService/FileService.cs | 120 +++++++++++------- 1 file changed, 71 insertions(+), 49 deletions(-) diff --git a/SiMay.RemoteClient.NewCore/ApplicationService/FileService.cs b/SiMay.RemoteClient.NewCore/ApplicationService/FileService.cs index 577ffac..5afb650 100644 --- a/SiMay.RemoteClient.NewCore/ApplicationService/FileService.cs +++ b/SiMay.RemoteClient.NewCore/ApplicationService/FileService.cs @@ -482,55 +482,25 @@ namespace SiMay.ServiceCore public void RedirtionHandler(TcpSocketSaeaSession session) { var pack = GetMessageEntity(session); - var sessions = UserTrunkContext.UserTrunkContextInstance.GetSessionItems() - .Select(c => new SiMay.Core.Packets.SysManager.SessionItem() - { - UserName = c.UserName, - SessionId = c.SessionId, - SessionState = c.SessionState, - WindowStationName = c.WindowStationName, - HasUserProcess = c.HasUserProcess - }) - .ToArray(); - foreach (var sessionItem in sessions) - { - if (sessionItem.HasUserProcess && sessionItem.UserName.ToLower() != "system") - { - List userFolders = GetUserFolderPath(); - foreach (var item in userFolders) - { - if (item.UserName == sessionItem.UserName) - { - string strFolderName = "Desktop"; - if (pack.SpecialFolder == Environment.SpecialFolder.MyDocuments) - { - strFolderName = "Personal"; - } - else if (pack.SpecialFolder == Environment.SpecialFolder.MyMusic) - { - strFolderName = "My Music"; - } - else if (pack.SpecialFolder == Environment.SpecialFolder.MyPictures) - { - strFolderName = "My Pictures"; - } - else if (pack.SpecialFolder == Environment.SpecialFolder.MyVideos) - { - strFolderName = "My Video"; - } - List userShellFolders = item.UserShellFolders.ToList(); - foreach (var usfItem in userShellFolders) - { - if (usfItem.Name == strFolderName) - { - this.GetFileListHandler(usfItem.Path); - return; - } - } - } - } - } + try + { + var userShellFolderPath = GetUserFolderPath() + .Where(c => c.UserName == UserTrunkContext.UserTrunkContextInstance.GetSessionItems() + .Select(c => new Core.Packets.SysManager.SessionItem() + { + UserName = c.UserName, + HasUserProcess = c.HasUserProcess + }) + .Where(c => c.HasUserProcess == true && c.UserName.ToLower() != "system") + .ToArray()[0].UserName) + .ToArray()[0].UserShellFolders + .Where(s => s.Name == FolderName(pack.SpecialFolder)) + .ToArray()[0].Path; + + this.GetFileListHandler(userShellFolderPath); + return; } + catch (Exception ex) { LogHelper.WriteErrorByCurrentMethod(ex); } this.GetFileListHandler(Environment.GetFolderPath(pack.SpecialFolder)); } @@ -710,7 +680,59 @@ namespace SiMay.ServiceCore return fileLst; } - + public static string FolderName(Environment.SpecialFolder specialFolder) + { + return specialFolder switch + { + Environment.SpecialFolder.ApplicationData => "AppData", + Environment.SpecialFolder.CommonApplicationData => "", + Environment.SpecialFolder.LocalApplicationData => "Local AppData", + Environment.SpecialFolder.Cookies => "Cookies", + Environment.SpecialFolder.Desktop => "Desktop", + Environment.SpecialFolder.Favorites => "Favorites", + Environment.SpecialFolder.History => "History", + Environment.SpecialFolder.InternetCache => "Cache", + Environment.SpecialFolder.Programs => "", + Environment.SpecialFolder.MyComputer => "", + Environment.SpecialFolder.MyMusic => "My Music", + Environment.SpecialFolder.MyPictures => "My Pictures", + Environment.SpecialFolder.MyVideos => "My Video", + Environment.SpecialFolder.Recent => "Recent", + Environment.SpecialFolder.SendTo => "SendTo", + Environment.SpecialFolder.StartMenu => "Start Menu", + Environment.SpecialFolder.Startup => "Startup", + Environment.SpecialFolder.System => "", + Environment.SpecialFolder.Templates => "Templates", + Environment.SpecialFolder.DesktopDirectory => "Desktop", + Environment.SpecialFolder.MyDocuments => "Personal", + Environment.SpecialFolder.ProgramFiles => "", + Environment.SpecialFolder.CommonProgramFiles => "", + Environment.SpecialFolder.AdminTools => "", + Environment.SpecialFolder.CDBurning => "", + Environment.SpecialFolder.CommonAdminTools => "", + Environment.SpecialFolder.CommonDocuments => "", + Environment.SpecialFolder.CommonMusic => "", + Environment.SpecialFolder.CommonOemLinks => "", + Environment.SpecialFolder.CommonPictures => "", + Environment.SpecialFolder.CommonStartMenu => "", + Environment.SpecialFolder.CommonPrograms => "", + Environment.SpecialFolder.CommonStartup => "", + Environment.SpecialFolder.CommonDesktopDirectory => "", + Environment.SpecialFolder.CommonTemplates => "", + Environment.SpecialFolder.CommonVideos => "", + Environment.SpecialFolder.Fonts => "", + Environment.SpecialFolder.NetworkShortcuts => "", + Environment.SpecialFolder.PrinterShortcuts => "", + Environment.SpecialFolder.UserProfile => "", + Environment.SpecialFolder.CommonProgramFilesX86 => "", + Environment.SpecialFolder.ProgramFilesX86 => "", + Environment.SpecialFolder.Resources => "", + Environment.SpecialFolder.LocalizedResources => "", + Environment.SpecialFolder.SystemX86 => "", + Environment.SpecialFolder.Windows => "", + _ => "", + }; + } public static List GetUserFolderPath() { var userFolder = new List(); -- Gitee