コード例 #1
0
        public async Task <Device> CreateDevice(string deviceId, string orgId)
        {
            var device = GetDeviceBase(deviceId, orgId);

            try
            {
                var(usedStorage, totalStorage) = GetSystemDriveInfo();
                var(usedMemory, totalMemory)   = GetMemoryInGB();

                device.CurrentUser    = Win32Interop.GetActiveSessions().LastOrDefault()?.Username;
                device.Drives         = GetAllDrives();
                device.UsedStorage    = usedStorage;
                device.TotalStorage   = totalStorage;
                device.UsedMemory     = usedMemory;
                device.TotalMemory    = totalMemory;
                device.CpuUtilization = await GetCpuUtilization();

                device.AgentVersion = GetAgentVersion();
            }
            catch (Exception ex)
            {
                Logger.Write(ex, "Error getting device info.");
            }

            return(device);
        }
コード例 #2
0
ファイル: Viewer.cs プロジェクト: xickwy/Remotely
 public async Task SendWindowsSessions()
 {
     if (EnvironmentHelper.IsWindows)
     {
         await SendToViewer(() => RtcSession.SendWindowsSessions(Win32Interop.GetActiveSessions()),
                            () => CasterSocket.SendWindowsSessions(Win32Interop.GetActiveSessions(), ViewerConnectionID));
     }
 }
コード例 #3
0
ファイル: Viewer.cs プロジェクト: zuimei100/Remotely
 public async Task SendWindowsSessions()
 {
     if (EnvironmentHelper.IsWindows)
     {
         var dto = new WindowsSessionsDto(Win32Interop.GetActiveSessions());
         await SendToViewer(() => RtcSession.SendDto(dto),
                            () => CasterSocket.SendDtoToViewer(dto, ViewerConnectionID));
     }
 }
コード例 #4
0
 public static string GetCurrentUser()
 {
     try
     {
         if (OSUtils.IsWindows)
         {
             return(Win32Interop.GetActiveSessions().LastOrDefault()?.Username);
         }
         else if (OSUtils.IsLinux)
         {
             var users = OSUtils.StartProcessWithResults("users", "");
             return(users?.Split()?.FirstOrDefault()?.Trim());
         }
         throw new Exception("Unsupported operating system.");
     }
     catch
     {
         return("Error Retrieving");
     }
 }
コード例 #5
0
 public static string GetCurrentUser()
 {
     try
     {
         if (EnvironmentHelper.IsWindows)
         {
             return(Win32Interop.GetActiveSessions().LastOrDefault()?.Username);
         }
         else if (EnvironmentHelper.IsLinux)
         {
             var users = EnvironmentHelper.StartProcessWithResults("users", "");
             return(users?.Split()?.FirstOrDefault()?.Trim());
         }
         throw new Exception("Unsupported operating system.");
     }
     catch (Exception ex)
     {
         Logger.Write(ex, "Error getting current user.");
         return("Error Retrieving");
     }
 }