public bool QueryServer(FrameworkServerProxy server, out string status) { status = string.Empty; if (server == null) { throw new ArgumentNullException("server"); } bool serverLoaded = false; // Try to load information about this server, if it fails then ask the user if they // would like to load information manually. try { var info = WindowsManagementInstrumentation.GetSystemInformation(server.HostName); server.Architecture = info.Architecture; server.Cores = info.Cores; server.DiskSpace = info.DiskSpace; server.HostName = info.HostName; server.Memory = info.Memory; server.OperatingSystem = info.OperatingSystem; server.Processors = info.Processors; // We may (or likely will) have multiple IP Addresses for the environment so go with the first found server.IpAddress = info.IpAddresses.FirstOrDefault(); serverLoaded = true; } catch (COMException ex) { status = ex.Message; } catch (UnauthorizedAccessException ex) { status = ex.Message; } return(serverLoaded); }
/// <summary> /// Copies from an instance of a <see cref="FrameworkServerProxy"/>. /// </summary> /// <param name="proxy">The proxy.</param> public void CopyFrom(FrameworkServerProxy proxy) { if (proxy == null) { throw new ArgumentNullException("proxy"); } Active = proxy.Active; Architecture = proxy.Architecture; Cores = proxy.Cores; DiskSpace = proxy.DiskSpace; HostName = proxy.HostName; Memory = proxy.Memory; OperatingSystem = proxy.OperatingSystem; Processors = proxy.Processors; IpAddress = proxy.IpAddress; ServiceVersion = proxy.ServiceVersion; foreach (var type in proxy.ServerTypes) { ServerTypes.Add(type); } }