本文整理匯總了C#中XenAPI.VM.GetRecommendedExportSpace方法的典型用法代碼示例。如果您正苦於以下問題:C# VM.GetRecommendedExportSpace方法的具體用法?C# VM.GetRecommendedExportSpace怎麽用?C# VM.GetRecommendedExportSpace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類XenAPI.VM
的用法示例。
在下文中一共展示了VM.GetRecommendedExportSpace方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Execute
/// <summary>
///
/// </summary>
/// <param name="connection"></param>
/// <param name="vm">The VM to export.</param>
/// <param name="host">Used for filtering purposes. May be null.</param>
private void Execute(IXenConnection connection, VM vm, Host host)
{
/*
* These properties have not been copied over to the new save file dialog.
*
dlg.AddExtension = true;
dlg.CheckPathExists = true;
dlg.CreatePrompt = false;
dlg.CheckFileExists = false;
dlg.OverwritePrompt = true;
dlg.ValidateNames = true;*/
string filename;
bool verify;
// Showing this dialog has the (undocumented) side effect of changing the working directory
// to that of the file selected. This means a handle to the directory persists, making
// it undeletable until the program exits, or the working dir moves on. So, save and
// restore the working dir...
String oldDir = "";
try
{
oldDir = Directory.GetCurrentDirectory();
while (true)
{
ExportVMDialog dlg = new ExportVMDialog();
dlg.DefaultExt = "xva";
dlg.Filter = Messages.MAINWINDOW_XVA_BLURB;
dlg.Title = Messages.MAINWINDOW_XVA_TITLE;
if (dlg.ShowDialog(Parent) != DialogResult.OK)
return;
filename = dlg.FileName;
verify = dlg.Verify;
// CA-12975: Warn the user if the export operation does not have enough disk space to
// complete. This is an approximation only.
Win32.DiskSpaceInfo diskSpaceInfo = Win32.GetDiskSpaceInfo(dlg.FileName);
if (diskSpaceInfo == null)
{
// Could not determine free disk space. Carry on regardless.
break;
}
else
{
ulong freeSpace = diskSpaceInfo.FreeBytesAvailable;
decimal neededSpace = vm.GetRecommendedExportSpace(Properties.Settings.Default.ShowHiddenVMs);
ulong spaceLeft = 100 * Util.BINARY_MEGA; // We want the user to be left with some disk space afterwards
if (neededSpace >= freeSpace - spaceLeft)
{
string msg = string.Format(Messages.CONFIRM_EXPORT_NOT_ENOUGH_MEMORY, Util.DiskSizeString((long)neededSpace),
Util.DiskSizeString((long)freeSpace), vm.Name);
DialogResult dr = new ThreeButtonDialog(
new ThreeButtonDialog.Details(SystemIcons.Warning, msg),
"ExportVmDialogInsufficientDiskSpace",
new ThreeButtonDialog.TBDButton(Messages.CONTINUE_WITH_EXPORT, DialogResult.OK),
new ThreeButtonDialog.TBDButton(Messages.CHOOSE_ANOTHER_DESTINATION, DialogResult.Retry),
ThreeButtonDialog.ButtonCancel).ShowDialog(Parent);
if (dr == DialogResult.Retry)
{
continue;
}
else if (dr == DialogResult.Cancel)
{
return;
}
}
if (diskSpaceInfo.IsFAT && neededSpace > (4 * Util.BINARY_GIGA) - 1)
{
string msg = string.Format(Messages.CONFIRM_EXPORT_FAT, Util.DiskSizeString((long)neededSpace),
Util.DiskSizeString(4 * Util.BINARY_GIGA), vm.Name);
DialogResult dr = new ThreeButtonDialog(
new ThreeButtonDialog.Details(SystemIcons.Warning, msg),
"ExportVmDialogFSLimitExceeded",
new ThreeButtonDialog.TBDButton(Messages.CONTINUE_WITH_EXPORT, DialogResult.OK),
new ThreeButtonDialog.TBDButton(Messages.CHOOSE_ANOTHER_DESTINATION, DialogResult.Retry),
ThreeButtonDialog.ButtonCancel).ShowDialog(Parent);
if (dr == DialogResult.Retry)
{
continue;
}
else if (dr == DialogResult.Cancel)
{
return;
}
}
break;
}
//.........這裏部分代碼省略.........