Exemple #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);
        }
Exemple #2
0
 public async Task SendWindowsSessions()
 {
     if (EnvironmentHelper.IsWindows)
     {
         await SendToViewer(() => RtcSession.SendWindowsSessions(Win32Interop.GetActiveSessions()),
                            () => CasterSocket.SendWindowsSessions(Win32Interop.GetActiveSessions(), ViewerConnectionID));
     }
 }
Exemple #3
0
 public async Task SendWindowsSessions()
 {
     if (EnvironmentHelper.IsWindows)
     {
         var dto = new WindowsSessionsDto(Win32Interop.GetActiveSessions());
         await SendToViewer(() => RtcSession.SendDto(dto),
                            () => CasterSocket.SendDtoToViewer(dto, ViewerConnectionID));
     }
 }
Exemple #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");
     }
 }
Exemple #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");
     }
 }