private bool GetDiskCapacityXva(out string error) { error = string.Empty; ulong ImageLength = 0; try { FileInfo info = new FileInfo(textBoxFile.Text); ImageLength = info.Length > 0 ? (ulong)info.Length : 0; SROper sROper = new SROper(); sROper.DiskCapacity = GetTotalSizeFromXmlXva(GetXmlStringFromTarXVA()); //xva style sROper.VifCount = this.VifCount; sROper.VcpuCount = this.VcpuCount; sROper.Memory = this.memory; sROper.vmNameLabel = this.nameLabel; int MaxVIFsAllowed = 0; try { MaxVIFsAllowed = Convert.ToInt32(MaxVIFsAllowedValue); } catch { MaxVIFsAllowed = 0; } sROper.MaxVIFsAllowed = MaxVIFsAllowed; } catch (Exception ex) { //error = ex.Message; error = "模板文件内容不正确!"; log.ErrorFormat(error + ":{0}", ex.Message); return(false); } return(true); }
protected override bool OnSetActive() { if (!base.OnSetActive()) { return(false); } log.InfoFormat("进入【存储配置】页面"); SelectSRInfoLabel.Text = ""; //ThreadStart threadStart = new ThreadStart(setVmName); //Thread thread = new Thread(threadStart); //thread.Start(); string vdiSize = string.Format("{0:0.00}GB", ConnectManager.DiskCapacity / Constants.UINT); label1.Text = string.Format("所需磁盘容量为{0}, 请选择可用容量大于{1}的存储池", vdiSize, vdiSize); sROper = new SROper(); List <SRVo> srList = sROper.getSRByTargetHost(); ////排序:降序 //Reverser<SRVo> reverser = new Reverser<SRVo>(new SRVo().GetType(), "AvailableCapacity", ReverserInfo.Direction.DESC); //srList.Sort(reverser); ////排序 //srList.Sort(delegate(SRVo x, SRVo y) { return x.AvailableCapacity.CompareTo(y.AvailableCapacity);}); ////排序,使用Lambda表达式,升序 //srList.Sort((x, y) => x.AvailableCapacity.CompareTo(y.AvailableCapacity)); //排序,使用Lambda表达式,降序 srList.Sort((x, y) => y.AvailableCapacity.CompareTo(x.AvailableCapacity)); if (srList.Count > 0) { storageDataGridView.RowCount = srList.Count; storageDataGridView.Rows[0].Selected = true; //每次默认选中第一行 for (int i = 0; i < srList.Count; i++) { storageDataGridView.Rows[i].Cells["uuidColumn"].Value = srList[i].Uuid; //int index = storageDataGridView.CurrentRow == null ? 0 : storageDataGridView.CurrentRow.Index; int index = 0; if (i == index) { storageDataGridView.Rows[i].Cells["checkBoxColumn"].Value = SelectedStatus.Selected; } else { storageDataGridView.Rows[i].Cells["checkBoxColumn"].Value = SelectedStatus.NoSelected; } storageDataGridView.Rows[i].Cells["nameLabelColumn"].Value = srList[i].Name; storageDataGridView.Rows[i].Cells["AvailableCapacityColumn"].Value = string.Format("{0:0.00}GB", srList[i].AvailableCapacity / Constants.UINT); storageDataGridView.Rows[i].Cells["physicalSizeColumn"].Value = string.Format("{0:0.00}GB", srList[i].PhysicalSize / Constants.UINT); storageDataGridView.Rows[i].Cells["TypeColumn"].Value = srList[i].Type; storageDataGridView.Rows[i].Cells["infoColumn"].Value = srList[i].Info; } //storageDataGridView.Sort(storageDataGridView.Columns["AvailableCapacityColumn"], ListSortDirection.Descending); Wizard.SetWizardButtons(WizardButton.Back | WizardButton.Next); } else { Wizard.SetWizardButtons(WizardButton.Back); } return(true); }