private void btnOK_Click(object sender, EventArgs e) { var message = string.Format(@"Are you sure that you want to do a {0}{1} on {2} in {3} seconds?", _shutdownParameters.Forced ? " forced " : string.Empty, _shutdownParameters.ShutdownType.ToString( ), _shutdownParameters.ComputerName, _shutdownParameters.Timeout); if (DialogResult.Yes == MessageBox.Show(message, @"Confirm", MessageBoxButtons.YesNo)) { DprComputerInfo.ShutdownComputer(_shutdownParameters); } }
private void LoadValues( DprComputerInfo.ShutdownComputerParameters parameters ) { txtComputer.Text = parameters.ComputerName; foreach( var shutdownType in (DprComputerInfo.ShutdownComputerParameters.ShutdownTypes[])Enum.GetValues( typeof( DprComputerInfo.ShutdownComputerParameters.ShutdownTypes ) ) ) { cmbTypeOfShutdown.Items.Add( shutdownType.ToString( ) ); } cmbTypeOfShutdown.SelectedItem = parameters.ShutdownType.ToString( ); chkForced.Checked = parameters.Forced; numTimeout.Minimum = UInt32.MinValue; numTimeout.Maximum = UInt32.MaxValue; numTimeout.Value = parameters.Timeout; txtMessage.Text = parameters.Comment; }
private void SetupComputerInfoTab( ) { AddDataPageToTabControl("Computer Info", tcMain, new DataPageControl <DprComputerInfo>(this) { QueryDataCb = DprComputerInfo.Generate, SetupColumnsCb = delegate(DataGridView dgv) { DgvHelpers.GenerateAllColumns(dgv, typeof(DprComputerInfo), new List <string> { @"ConnectionStatus" }); DgvHelpers.SetColumnHeader(DgvHelpers.GetColumn(dgv, @"ConnectionStatusString"), @"Connection Status"); MoveStatusColumnsFirst(dgv); foreach (var actionName in DprComputerInfo.SetupActions( ).Keys) { DgvHelpers.AddButtonColumn(dgv, actionName); } } }); }
public static void Generate(string computerName, SyncList.SyncList <DprComputerInfo> result) { Helpers.AssertNotNull(result, @"result SyncList cannot be null"); Helpers.AssertString(computerName, @"Computer name cannot be empty"); var ci = new DprComputerInfo(computerName) { LocalSystemDateTime = DateTime.Now }; try { WmiHelpers.ForEach(computerName, @"SELECT * FROM Win32_OperatingSystem WHERE Primary=TRUE", obj => { ci.LastBootTime = WmiHelpers.GetNullableDate(obj, @"LastBootUpTime"); ci.SystemTime = WmiHelpers.GetNullableDate(obj, @"LocalDateTime"); ci.Version = WmiHelpers.GetString(obj, @"Caption"); ci.Architecture = WmiHelpers.GetString(obj, @"OSArchitecture"); ci.InstallDate = WmiHelpers.GetNullableDate(obj, @"InstallDate"); return(true); }); WmiHelpers.ForEach(computerName, @"SELECT * FROM Win32_BIOS", obj => { ci.Manufacturer = WmiHelpers.GetString(obj, @"Manufacturer"); ci.HwReleaseDate = WmiHelpers.GetNullableDate(obj, @"ReleaseDate"); ci.SerialNumber = WmiHelpers.GetString(obj, @"SerialNumber"); ci.BiosVersion = WmiHelpers.GetString(obj, @"SMBIOSBIOSVersion"); return(true); }); WmiHelpers.ForEach(computerName, @"SELECT * FROM Win32_ComputerSystem", obj => { ci.Model = WmiHelpers.GetString(obj, @"Model"); ci.TotalPhysicalMemory = WmiHelpers.GetUInt(obj, @"TotalPhysicalMemory"); return(true); }); } catch (UnauthorizedAccessException uae) { GlobalLogging.WriteLine(Logging.LogSeverity.Error, @"Exception - {0} - {1}", uae.TargetSite, uae.Message); ci.ConnectionStatus = ConnectionStatuses.AuthorizationError; } catch (Exception ex) { GlobalLogging.WriteLine(Logging.LogSeverity.Error, @"Exception - {0} - {1}", ex.TargetSite, ex.Message); ci.ConnectionStatus = ConnectionStatuses.Error; } result.Add(ci); ValidateUniqueness(result); }
public ConfirmShutdownDialog( DprComputerInfo.ShutdownComputerParameters shutdownParameters ) { _shutdownParameters = shutdownParameters; InitializeComponent( ); }
public static void Generate( string computerName, SyncList.SyncList<DprComputerInfo> result ) { Helpers.AssertNotNull( result, @"result SyncList cannot be null" ); Helpers.AssertString( computerName, @"Computer name cannot be empty" ); var ci = new DprComputerInfo( computerName ) { LocalSystemDateTime = DateTime.Now }; try { WmiHelpers.ForEach( computerName, @"SELECT * FROM Win32_OperatingSystem WHERE Primary=TRUE", obj => { ci.LastBootTime = WmiHelpers.GetNullableDate( obj, @"LastBootUpTime" ); ci.SystemTime = WmiHelpers.GetNullableDate( obj, @"LocalDateTime" ); ci.Version = WmiHelpers.GetString( obj, @"Caption" ); ci.Architecture = WmiHelpers.GetString( obj, @"OSArchitecture" ); ci.InstallDate = WmiHelpers.GetNullableDate( obj, @"InstallDate" ); return true; } ); WmiHelpers.ForEach( computerName, @"SELECT * FROM Win32_BIOS", obj => { ci.Manufacturer = WmiHelpers.GetString( obj, @"Manufacturer" ); ci.HwReleaseDate = WmiHelpers.GetNullableDate( obj, @"ReleaseDate" ); ci.SerialNumber = WmiHelpers.GetString( obj, @"SerialNumber" ); ci.BiosVersion = WmiHelpers.GetString( obj, @"SMBIOSBIOSVersion" ); return true; } ); WmiHelpers.ForEach( computerName, @"SELECT * FROM Win32_ComputerSystem", obj => { ci.Model = WmiHelpers.GetString( obj, @"Model" ); ci.TotalPhysicalMemory = WmiHelpers.GetUInt( obj, @"TotalPhysicalMemory" ); return true; } ); } catch( UnauthorizedAccessException uae ) { GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"Exception - {0} - {1}", uae.TargetSite, uae.Message ); ci.ConnectionStatus = ConnectionStatuses.AuthorizationError; } catch( Exception ex ) { GlobalLogging.WriteLine( Logging.LogSeverity.Error, @"Exception - {0} - {1}", ex.TargetSite, ex.Message ); ci.ConnectionStatus = ConnectionStatuses.Error; } result.Add( ci ); ValidateUniqueness( result ); }