public NextActiveHardDrive ( List |
||
schemaImagedDrives | List |
|
clientHdNumber | int | |
Результат | int |
public string CheckHdRequirements(int profileId, int clientHdNumber, string newHdSize, string imageSchemaDrives) { var result = new Services.Client.HardDriveSchema(); var imageProfile = BLL.ImageProfile.ReadProfile(profileId); var partitionHelper = new ClientPartitionHelper(imageProfile); var imageSchema = partitionHelper.GetImageSchema(); if (clientHdNumber > imageSchema.HardDrives.Count()) { result.IsValid = "false"; result.Message = "No Image Exists To Download To This Hard Drive. There Are More" + "Hard Drive's Than The Original Image"; return JsonConvert.SerializeObject(result); } var listSchemaDrives = new List<int>(); if(!string.IsNullOrEmpty(imageSchemaDrives)) listSchemaDrives.AddRange(imageSchemaDrives.Split(' ').Select(hd => Convert.ToInt32(hd))); result.SchemaHdNumber = partitionHelper.NextActiveHardDrive(listSchemaDrives,clientHdNumber); if (result.SchemaHdNumber == -1) { result.IsValid = "false"; result.Message = "Not Active Hard Drive Images Were Found To Deploy."; return JsonConvert.SerializeObject(result); } var newHdBytes = Convert.ToInt64(newHdSize); var minimumSize = partitionHelper.HardDrive(result.SchemaHdNumber,newHdBytes); if (minimumSize > newHdBytes) { Logger.Log("Error: " + newHdBytes / 1024 / 1024 + " MB Is Less Than The Minimum Required HD Size For This Image(" + minimumSize / 1024 / 1024 + " MB)"); result.IsValid = "false"; result.Message = newHdBytes/1024/1024 + " MB Is Less Than The Minimum Required HD Size For This Image(" + minimumSize/1024/1024 + " MB)"; return JsonConvert.SerializeObject(result); } if (minimumSize == newHdBytes) { result.IsValid = "original"; result.PhysicalPartitions = partitionHelper.GetActivePartitions(result.SchemaHdNumber, imageProfile); result.PhysicalPartitionCount = partitionHelper.GetActivePartitionCount(result.SchemaHdNumber); result.PartitionType = imageSchema.HardDrives[result.SchemaHdNumber].Table; result.BootPartition = imageSchema.HardDrives[result.SchemaHdNumber].Boot; result.UsesLvm = partitionHelper.CheckForLvm(result.SchemaHdNumber); result.Guid = imageSchema.HardDrives[result.SchemaHdNumber].Guid; return JsonConvert.SerializeObject(result); } result.IsValid = "true"; result.PhysicalPartitions = partitionHelper.GetActivePartitions(result.SchemaHdNumber, imageProfile); result.PhysicalPartitionCount = partitionHelper.GetActivePartitionCount(result.SchemaHdNumber); result.PartitionType = imageSchema.HardDrives[result.SchemaHdNumber].Table; result.BootPartition = imageSchema.HardDrives[result.SchemaHdNumber].Boot; result.UsesLvm = partitionHelper.CheckForLvm(result.SchemaHdNumber); result.Guid = imageSchema.HardDrives[result.SchemaHdNumber].Guid; return JsonConvert.SerializeObject(result); }