// populate a list of PartitionInfoEx with information about the actual partitions on a DiskDrive // pass in an Action that will populate a storage location with the information public async Task PopulatePartitionInfoExs(CrudType cRUD, DiskDriveInfoEx diskInfoEx, Action <DiskDriveInfoEx> storePartitionInfoExs) { Log.Debug($"starting PopulatePartitionInfoExs: cRUD = {cRUD.ToString()}, diskInfoEx = {diskInfoEx.Dump()}"); // ToDo: Get the list of partitions from the Disk hardware await new Task(() => Thread.Sleep(500)); // Until real partitions are available, mock up the current laptop configuration as of 4/15/19 // No partitions on drives 0 and 1, and one partition on drive 2, one drive letter E var partitionInfoExs = new List <PartitionInfoEx>(); switch (diskInfoEx.DriveNumber) { case 2: { var partitionInfoEx = new PartitionInfoEx() { PartitionDbId = new Id <PartitionInfoEx>(), DriveLetters = new List <string>() { "E" } }; partitionInfoExs.Add(partitionInfoEx); break; } default: break; } storePartitionInfoExs.Invoke(diskInfoEx); // ToDo: see if the disk already has partitions in the DB var dBPartitions = new List <PartitionInfoEx>(); Log.Debug($"leaving PopulatePartitionInfoExs"); }
public static IEnumerable <object[]> TestData() { StringBuilder str = new StringBuilder(); foreach (PartitionFileSystemTestData[] partitionFileSystem in PartitionFileSystemTestDataGenerator.TestData()) { foreach (UnitsNetInformationTestData[] information in UnitsNetInformationTestDataGenerator.TestData()) { IEnumerable <char> driveLetters = new List <char>() { 'E' }; foreach (PhiloteTestData <IPartitionInfoEx>[] philote in PhiloteTestDataGenerator <IPartitionInfoEx> .TestData()) { var X = new PartitionInfoEx(partitionFileSystem[0].ObjTestData, information[0].ObjTestData, driveLetters, philote[0].ObjTestData); str.Clear(); str.Append($"{{\"PartitionFileSystem\":{partitionFileSystem[0].SerializedTestData},\"Size\":{information[0].SerializedTestData},\"DriveLetters\":[\"E\"],\"Philote\":{philote[0].SerializedTestData}}}"); yield return(new PartitionInfoExTestData[] { new PartitionInfoExTestData(new PartitionInfoEx(partitionFileSystem[0].ObjTestData, information[0].ObjTestData, driveLetters, philote[0].ObjTestData), str.ToString()) }); //yield return new PartitionInfoExTestData[] { new PartitionInfoExTestData(new PartitionInfoEx(idpair.ID, idpair.ID2, new string[1] {"X"}, partitionFileSystem[0].ObjTestData, information[0].ObjTestData), str.ToString()) }; } } //} } }
// Extension methods to populate a ComputerHardware object public static ATAP.Utilities.ComputerInventory.ComputerHardware FromComputerName(this ATAP.Utilities.ComputerInventory.ComputerHardware me, string computerName) { ATAP.Utilities.ComputerInventory.ComputerHardware lCH; switch (computerName.Trim().ToLowerInvariant()) { //ToDo: read actual HW, currently specific for laptop case "localhost": // create the partitions COD for drive 2 //Log.Debug("in ComputerHardware.FromComputerName initializer"); var partitionInfoExs = new PartitionInfoExs(); PartitionInfoEx PIE1 = new PartitionInfoEx() { DriveLetters = new List <string>() { "E" }, Exceptions = new List <Exception>(), PartitionDbId = new Id <PartitionInfoEx>(Guid.Empty), PartitionId = new Id <PartitionInfoEx>(Guid.NewGuid()), Size = 1000000000000 }; partitionInfoExs.PartitionInfoExCOD.Add(PIE1.PartitionId, PIE1); DiskDriveInfoEx DDIE0 = new DiskDriveInfoEx() { DiskDriveId = new Id <DiskDriveInfoEx>(Guid.NewGuid()), DiskDriveDbId = new Id <DiskDriveInfoEx>(Guid.Empty), DiskDriveMaker = DiskDriveMaker.Generic, DiskDriveType = DiskDriveType.SSD, SerialNumber = "123", PartitionInfoExs = partitionInfoExs, Exceptions = new List <Exception>() }; var diskDriveInfoExs = new DiskDriveInfoExs(); diskDriveInfoExs.DiskDriveInfoExCOD.Add(DDIE0.DiskDriveId, DDIE0); lCH = new ComputerHardware(new MainBoard(MainBoardMaker.Generic, CPUSocket.Generic), new List <CPUMaker> { CPUMaker.Intel }, diskDriveInfoExs.DiskDriveInfoExCOD, new TimeBlock(DateTime.UtcNow, true)); break; default: throw new NotImplementedException($"cannot populate ComputerHardware object from computerName = {computerName}"); } return(lCH); }