private void btnAddDataBase_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(txtAuditorName.Text)) { MessageBox.Show("Please enter your name into the Auditor Name textbox"); } else { am.CheckIfCompInHardDatabase(txtComputerName.Text); //Checks to see if PC already exists and deletes it if it does - this is to stop mulitple records of the same machine am.CheckIfCompInNetDatabase(txtComputerName.Text); am.CheckIfCompInPrinDatabase(txtComputerName.Text); am.CheckIfCompInPeriDatabase(txtComputerName.Text); am.CheckIfCompInSoftDatabase(txtComputerName.Text); ExportingInformation ei = new ExportingInformation(); FieldsNotEmpty(); string CommentsToString = (new TextRange(rtxtComments.Document.ContentStart, rtxtComments.Document.ContentEnd).Text); am.AuditComputerData(txtAuditDate.Text, txtAuditorName.Text, txtManufacturer.Text, txtModel.Text, txtComputerName.Text, txtOS.Text, txtOSArch.Text, txtServicePack.Text, txtSerialNumber.Text, MWRamAmt, txtProcessor.Text, MWNoProcessors, MWHardDriveSize, MWFreeHardDrive, CommentsToString); foreach (var ipAddress in cbIPAddress.Items) { //Will add every IP address in the IPAddress Combobox to the networking table am.AuditNetworkInfo(txtComputerName.Text, "IPAddress", ipAddress.ToString()); } foreach (var macAddress in cbMacAddress.Items) { //Will add every MAC address in the MACAddress Combobox to the networking table am.AuditNetworkInfo(txtComputerName.Text, "MACAddress", macAddress.ToString()); } foreach (var printer in lbPrinters.Items) { //Will add every Printer in the Printer listbox to the Printers table am.AuditPrintersInfo(txtComputerName.Text, printer.ToString()); } foreach (var peripheral in lbPeripherals.Items) { //Will add every Peripheral in the Peripheral listbox to the Peripheral table am.AuditPeripherals(txtComputerName.Text, peripheral.ToString()); } if (dgSoftware.HasItems) { ei.Softcomputername = txtComputerName.Text; ei.ExportingToDatabase = true; ei.Show(); } else { MessageBox.Show("Information Added"); } } }
public void GetSoftwareInfoAndSaveCSV(string sftFilePath) { //GET SOFTWARE INFORMATION string sof_query = "SELECT * FROM Win32_Product"; ManagementObjectSearcher sof_searcher = new ManagementObjectSearcher(sof_query); ExportingInformation ei = new ExportingInformation(); ei.Show(); foreach (ManagementObject process in sof_searcher.Get()) { string tempSoftwareName = Convert.ToString(process["Name"]); string tempSoftwareVendor = Convert.ToString(process["Vendor"]); string tempSoftwareVersion = Convert.ToString(process["Version"]); using (StreamWriter sw = File.AppendText(sftFilePath)) { sw.WriteLine("$$$###**!!Software!!**###$$$," + tempSoftwareName.Replace(',', '-') + "," + tempSoftwareVendor.Replace(',', '-') + "," + tempSoftwareVersion.Replace(',', '-')); sw.Flush(); sw.Close(); } } ei.Hide(); }
public void GetSoftwareInfoAndSaveCSV(string sftFilePath) { //GET SOFTWARE INFORMATION string sof_query = "SELECT * FROM Win32_Product"; ManagementObjectSearcher sof_searcher = new ManagementObjectSearcher(sof_query); ExportingInformation ei = new ExportingInformation(); ei.Show(); foreach (ManagementObject process in sof_searcher.Get()) { string tempSoftwareName = Convert.ToString(process["Name"]); string tempSoftwareVendor = Convert.ToString(process["Vendor"]); string tempSoftwareVersion = Convert.ToString(process["Version"]); using (StreamWriter sw = File.AppendText(sftFilePath)) { sw.WriteLine("$$$###**!!Software!!**###$$$," + tempSoftwareName.Replace(',', '-') + "," + tempSoftwareVendor.Replace(',', '-') + "," + tempSoftwareVersion.Replace(',', '-')); sw.Flush(); sw.Close(); } } ei.Hide(); }
private void btnAddDataBase_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(txtAuditorName.Text)) { MessageBox.Show("Please enter your name into the Auditor Name textbox"); } else { am.CheckIfCompInHardDatabase(txtComputerName.Text); //Checks to see if PC already exists and deletes it if it does - this is to stop mulitple records of the same machine am.CheckIfCompInNetDatabase(txtComputerName.Text); am.CheckIfCompInPrinDatabase(txtComputerName.Text); am.CheckIfCompInPeriDatabase(txtComputerName.Text); am.CheckIfCompInSoftDatabase(txtComputerName.Text); ExportingInformation ei = new ExportingInformation(); FieldsNotEmpty(); string CommentsToString = (new TextRange(rtxtComments.Document.ContentStart, rtxtComments.Document.ContentEnd).Text); am.AuditComputerData(txtAuditDate.Text, txtAuditorName.Text, txtManufacturer.Text, txtModel.Text, txtComputerName.Text, txtOS.Text, txtOSArch.Text, txtServicePack.Text, txtSerialNumber.Text, MWRamAmt, txtProcessor.Text, MWNoProcessors, MWHardDriveSize, MWFreeHardDrive, CommentsToString); foreach (var ipAddress in cbIPAddress.Items) { //Will add every IP address in the IPAddress Combobox to the networking table am.AuditNetworkInfo(txtComputerName.Text, "IPAddress", ipAddress.ToString()); } foreach (var macAddress in cbMacAddress.Items) { //Will add every MAC address in the MACAddress Combobox to the networking table am.AuditNetworkInfo(txtComputerName.Text, "MACAddress", macAddress.ToString()); } foreach (var printer in lbPrinters.Items) { //Will add every Printer in the Printer listbox to the Printers table am.AuditPrintersInfo(txtComputerName.Text, printer.ToString()); } foreach (var peripheral in lbPeripherals.Items) { //Will add every Peripheral in the Peripheral listbox to the Peripheral table am.AuditPeripherals(txtComputerName.Text, peripheral.ToString()); } if (dgSoftware.HasItems) { ei.Softcomputername = txtComputerName.Text; ei.ExportingToDatabase = true; ei.Show(); } else { MessageBox.Show("Information Added"); } } }