From c8c2ea448ad3f69858f87ef2ed92e129b2ed3143 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Thu, 9 Aug 2018 10:54:32 +0100 Subject: [PATCH] CA-156828: Do not uncompress imported appliance on a modal dialog, but rather asynchronously on the SelectImportSourcePage, so that the rest of XenCenter is usable while the unzip is taking place; for this purpose a progress bar was added on the page and the DecompressApplianceDialog was removed. Signed-off-by: Konstantina Chremmou --- .../DecompressApplianceDialog.Designer.cs | 189 ------ XenAdmin/Dialogs/DecompressApplianceDialog.cs | 188 ------ .../Dialogs/DecompressApplianceDialog.ja.resx | 630 ------------------ .../Dialogs/DecompressApplianceDialog.resx | 630 ------------------ .../DecompressApplianceDialog.zh-CN.resx | 630 ------------------ .../ImportWizard/ImportSourcePage.Designer.cs | 62 +- .../Wizards/ImportWizard/ImportSourcePage.cs | 237 +++++-- .../ImportWizard/ImportSourcePage.resx | 193 +++++- XenAdmin/XenAdmin.csproj | 15 - .../DecompressApplianceDialogTests.cs | 52 -- XenAdminTests/XenAdminTests.csproj | 1 - 11 files changed, 428 insertions(+), 2399 deletions(-) delete mode 100644 XenAdmin/Dialogs/DecompressApplianceDialog.Designer.cs delete mode 100644 XenAdmin/Dialogs/DecompressApplianceDialog.cs delete mode 100644 XenAdmin/Dialogs/DecompressApplianceDialog.ja.resx delete mode 100644 XenAdmin/Dialogs/DecompressApplianceDialog.resx delete mode 100644 XenAdmin/Dialogs/DecompressApplianceDialog.zh-CN.resx delete mode 100644 XenAdminTests/DialogTests/DecompressApplianceDialogTests.cs diff --git a/XenAdmin/Dialogs/DecompressApplianceDialog.Designer.cs b/XenAdmin/Dialogs/DecompressApplianceDialog.Designer.cs deleted file mode 100644 index e71cc180e..000000000 --- a/XenAdmin/Dialogs/DecompressApplianceDialog.Designer.cs +++ /dev/null @@ -1,189 +0,0 @@ -namespace XenAdmin.Dialogs -{ - partial class DecompressApplianceDialog - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DecompressApplianceDialog)); - this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.m_tlpButtons = new System.Windows.Forms.TableLayoutPanel(); - this.m_buttonDecompress = new System.Windows.Forms.Button(); - this.m_buttonCancel = new System.Windows.Forms.Button(); - this.m_tlpNotice = new System.Windows.Forms.TableLayoutPanel(); - this.m_labelNotice = new XenAdmin.Controls.Common.AutoHeightLabel(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.m_tlpProgress = new System.Windows.Forms.TableLayoutPanel(); - this.m_progressBar = new System.Windows.Forms.ProgressBar(); - this.autoHeightLabel1 = new XenAdmin.Controls.Common.AutoHeightLabel(); - this.m_tlpError = new System.Windows.Forms.TableLayoutPanel(); - this.m_pictureBoxError = new System.Windows.Forms.PictureBox(); - this.autoHeightLabel3 = new XenAdmin.Controls.Common.AutoHeightLabel(); - this.m_labelError = new XenAdmin.Controls.Common.AutoHeightLabel(); - this.tableLayoutPanel1.SuspendLayout(); - this.m_tlpButtons.SuspendLayout(); - this.m_tlpNotice.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); - this.m_tlpProgress.SuspendLayout(); - this.m_tlpError.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.m_pictureBoxError)).BeginInit(); - this.SuspendLayout(); - // - // tableLayoutPanel1 - // - resources.ApplyResources(this.tableLayoutPanel1, "tableLayoutPanel1"); - this.tableLayoutPanel1.Controls.Add(this.m_tlpButtons, 0, 4); - this.tableLayoutPanel1.Controls.Add(this.m_tlpNotice, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.m_tlpProgress, 0, 1); - this.tableLayoutPanel1.Controls.Add(this.m_tlpError, 0, 2); - this.tableLayoutPanel1.Name = "tableLayoutPanel1"; - // - // m_tlpButtons - // - resources.ApplyResources(this.m_tlpButtons, "m_tlpButtons"); - this.m_tlpButtons.Controls.Add(this.m_buttonDecompress, 1, 0); - this.m_tlpButtons.Controls.Add(this.m_buttonCancel, 2, 0); - this.m_tlpButtons.Name = "m_tlpButtons"; - // - // m_buttonDecompress - // - resources.ApplyResources(this.m_buttonDecompress, "m_buttonDecompress"); - this.m_buttonDecompress.Name = "m_buttonDecompress"; - this.m_buttonDecompress.UseVisualStyleBackColor = true; - this.m_buttonDecompress.Click += new System.EventHandler(this.m_buttonDecompress_Click); - // - // m_buttonCancel - // - resources.ApplyResources(this.m_buttonCancel, "m_buttonCancel"); - this.m_buttonCancel.Name = "m_buttonCancel"; - this.m_buttonCancel.UseVisualStyleBackColor = true; - this.m_buttonCancel.Click += new System.EventHandler(this.m_buttonCancel_Click); - // - // m_tlpNotice - // - resources.ApplyResources(this.m_tlpNotice, "m_tlpNotice"); - this.m_tlpNotice.Controls.Add(this.m_labelNotice, 1, 0); - this.m_tlpNotice.Controls.Add(this.pictureBox1, 0, 0); - this.m_tlpNotice.Name = "m_tlpNotice"; - // - // m_labelNotice - // - resources.ApplyResources(this.m_labelNotice, "m_labelNotice"); - this.m_labelNotice.Name = "m_labelNotice"; - // - // pictureBox1 - // - resources.ApplyResources(this.pictureBox1, "pictureBox1"); - this.pictureBox1.Image = global::XenAdmin.Properties.Resources._000_WarningAlert_h32bit_32; - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.TabStop = false; - // - // m_tlpProgress - // - resources.ApplyResources(this.m_tlpProgress, "m_tlpProgress"); - this.m_tlpProgress.Controls.Add(this.m_progressBar, 0, 2); - this.m_tlpProgress.Controls.Add(this.autoHeightLabel1, 0, 0); - this.m_tlpProgress.Name = "m_tlpProgress"; - // - // m_progressBar - // - resources.ApplyResources(this.m_progressBar, "m_progressBar"); - this.m_progressBar.MarqueeAnimationSpeed = 20; - this.m_progressBar.Name = "m_progressBar"; - this.m_progressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous; - // - // autoHeightLabel1 - // - resources.ApplyResources(this.autoHeightLabel1, "autoHeightLabel1"); - this.autoHeightLabel1.Name = "autoHeightLabel1"; - // - // m_tlpError - // - resources.ApplyResources(this.m_tlpError, "m_tlpError"); - this.m_tlpError.Controls.Add(this.m_pictureBoxError, 0, 0); - this.m_tlpError.Controls.Add(this.autoHeightLabel3, 1, 0); - this.m_tlpError.Controls.Add(this.m_labelError, 1, 2); - this.m_tlpError.Name = "m_tlpError"; - // - // m_pictureBoxError - // - resources.ApplyResources(this.m_pictureBoxError, "m_pictureBoxError"); - this.m_pictureBoxError.Name = "m_pictureBoxError"; - this.m_tlpError.SetRowSpan(this.m_pictureBoxError, 3); - this.m_pictureBoxError.TabStop = false; - // - // autoHeightLabel3 - // - resources.ApplyResources(this.autoHeightLabel3, "autoHeightLabel3"); - this.autoHeightLabel3.Name = "autoHeightLabel3"; - // - // m_labelError - // - resources.ApplyResources(this.m_labelError, "m_labelError"); - this.m_labelError.Name = "m_labelError"; - // - // DecompressApplianceDialog - // - resources.ApplyResources(this, "$this"); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; - this.ControlBox = false; - this.Controls.Add(this.tableLayoutPanel1); - this.HelpButton = false; - this.Name = "DecompressApplianceDialog"; - this.tableLayoutPanel1.ResumeLayout(false); - this.tableLayoutPanel1.PerformLayout(); - this.m_tlpButtons.ResumeLayout(false); - this.m_tlpNotice.ResumeLayout(false); - this.m_tlpNotice.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); - this.m_tlpProgress.ResumeLayout(false); - this.m_tlpProgress.PerformLayout(); - this.m_tlpError.ResumeLayout(false); - this.m_tlpError.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.m_pictureBoxError)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; - private XenAdmin.Controls.Common.AutoHeightLabel m_labelNotice; - private System.Windows.Forms.ProgressBar m_progressBar; - private System.Windows.Forms.TableLayoutPanel m_tlpNotice; - private System.Windows.Forms.PictureBox pictureBox1; - private System.Windows.Forms.TableLayoutPanel m_tlpProgress; - private XenAdmin.Controls.Common.AutoHeightLabel autoHeightLabel1; - private System.Windows.Forms.TableLayoutPanel m_tlpError; - private System.Windows.Forms.PictureBox m_pictureBoxError; - private XenAdmin.Controls.Common.AutoHeightLabel autoHeightLabel3; - private System.Windows.Forms.TableLayoutPanel m_tlpButtons; - private System.Windows.Forms.Button m_buttonDecompress; - private System.Windows.Forms.Button m_buttonCancel; - private XenAdmin.Controls.Common.AutoHeightLabel m_labelError; - } -} - diff --git a/XenAdmin/Dialogs/DecompressApplianceDialog.cs b/XenAdmin/Dialogs/DecompressApplianceDialog.cs deleted file mode 100644 index 567109a2d..000000000 --- a/XenAdmin/Dialogs/DecompressApplianceDialog.cs +++ /dev/null @@ -1,188 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, - * with or without modification, are permitted provided - * that the following conditions are met: - * - * * Redistributions of source code must retain the above - * copyright notice, this list of conditions and the - * following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the - * following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -using System; -using System.ComponentModel; -using System.Drawing; -using System.IO; -using System.Windows.Forms; -using XenCenterLib.Archive; - -using XenCenterLib.Compression; - -namespace XenAdmin.Dialogs -{ - public partial class DecompressApplianceDialog : XenDialogBase - { - private readonly BackgroundWorker m_worker; - private readonly string m_compressedFile; - private readonly string m_decompressedFile; - - public DecompressApplianceDialog(string compresssedFile, string decompressedFile) - { - InitializeComponent(); - m_pictureBoxError.Image = SystemIcons.Error.ToBitmap(); - m_labelNotice.Text = string.Format(Messages.UNCOMPRESS_APPLIANCE_DESCRIPTION, Path.GetFileName(decompressedFile), Path.GetFileName(compresssedFile)); - m_tlpNotice.Visible = true; - m_tlpProgress.Visible = false; - HideError(); - - m_compressedFile = compresssedFile; - m_decompressedFile = decompressedFile; - - m_worker = new BackgroundWorker {WorkerReportsProgress = true, WorkerSupportsCancellation = true}; - m_worker.DoWork += m_worker_DoWork; - m_worker.ProgressChanged += m_worker_ProgressChanged; - m_worker.RunWorkerCompleted += m_worker_RunWorkerCompleted; - } - - #region Private methods - - private void ShowError(string error) - { - m_tlpError.Visible = true; - m_labelError.Text = error; - m_buttonDecompress.Text = Messages.RETRY; - m_buttonDecompress.Enabled = true; - } - - private void HideError() - { - m_tlpError.Visible = false; - } - - #endregion - - #region Event handlers - - private void m_worker_DoWork(object sender, DoWorkEventArgs e) - { - FileInfo info = new FileInfo(m_compressedFile); - long length = info.Length; - - using (Stream inStream = File.Open(m_compressedFile, FileMode.Open, FileAccess.ReadWrite, FileShare.None)) - using (Stream outStream = File.Open(m_decompressedFile, FileMode.Create, FileAccess.ReadWrite, FileShare.None)) - { - try - { - using (CompressionStream bzis = CompressionFactory.Reader( CompressionFactory.Type.Gz, inStream)) - { - byte[] buffer = new byte[4*1024]; - - int bytesRead; - while ((bytesRead = bzis.Read(buffer, 0, buffer.Length)) > 0) - { - outStream.Write(buffer, 0, bytesRead); - - int percentage = (int)Math.Floor((double)bzis.Position*100/length); - - if (percentage < 0) - m_worker.ReportProgress(0); - else if (percentage > 100) - m_worker.ReportProgress(100); - else - m_worker.ReportProgress(percentage); - - if (m_worker.CancellationPending) - { - e.Cancel = true; - return; - } - } - } - } - finally - { - outStream.Flush(); - } - } - } - - private void m_worker_ProgressChanged(object sender, ProgressChangedEventArgs e) - { - Program.Invoke(this, () => m_progressBar.Value = e.ProgressPercentage); - } - - private void m_worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) - { - if (e.Error != null)//failure - { - Program.Invoke(this, () => - { - m_tlpProgress.Visible = false; - ShowError(e.Error.Message); - m_tlpProgress.Visible = false; - //delete what has been unzipped so far - //if file does not exist, no exception is thrown, so no need to check - File.Delete(m_decompressedFile); - }); - } - else if (e.Cancelled)//user cancelled - { - Program.Invoke(this, () => - { - File.Delete(m_decompressedFile); - DialogResult = DialogResult.Cancel; - }); - } - else//success - { - Program.Invoke(this, () => - { - m_progressBar.Value = 100; - File.Delete(m_compressedFile); - DialogResult = DialogResult.Yes; - }); - } - - } - - private void m_buttonDecompress_Click(object sender, EventArgs e) - { - HideError(); - m_tlpNotice.Visible = false; - m_tlpProgress.Visible = true; - m_progressBar.Value = 0; - m_buttonDecompress.Enabled = false; - m_worker.RunWorkerAsync(); - } - - private void m_buttonCancel_Click(object sender, EventArgs e) - { - if (m_worker.IsBusy) - m_worker.CancelAsync(); - else - DialogResult = DialogResult.Cancel; - } - - #endregion - } -} diff --git a/XenAdmin/Dialogs/DecompressApplianceDialog.ja.resx b/XenAdmin/Dialogs/DecompressApplianceDialog.ja.resx deleted file mode 100644 index 790c5f2f3..000000000 --- a/XenAdmin/Dialogs/DecompressApplianceDialog.ja.resx +++ /dev/null @@ -1,630 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - Top, Bottom, Left, Right - - - - 1 - - - True - - - GrowAndShrink - - - 3 - - - - Segoe UI, 9pt - - - NoControl - - - 235, 3 - - - 95, 23 - - - 0 - - - 圧縮解除(&U) - - - m_buttonDecompress - - - System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - m_tlpButtons - - - 0 - - - Segoe UI, 9pt - - - NoControl - - - 336, 3 - - - 95, 23 - - - 1 - - - キャンセル - - - m_buttonCancel - - - System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - m_tlpButtons - - - 1 - - - Fill - - - Segoe UI, 9pt - - - 3, 163 - - - 1 - - - 434, 29 - - - 3 - - - m_tlpButtons - - - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 0 - - - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="m_buttonDecompress" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="m_buttonCancel" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /></Controls><Columns Styles="Percent,100,AutoSize,0,AutoSize,0" /><Rows Styles="AutoSize,0" /></TableLayoutSettings> - - - True - - - GrowAndShrink - - - 2 - - - True - - - Fill - - - Segoe UI, 9pt - - - 41, 0 - - - 390, 38 - - - 0 - - - m_label - - - m_labelNotice - - - XenAdmin.Controls.Common.AutoHeightLabel, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - - - m_tlpNotice - - - 0 - - - Segoe UI, 9pt - - - 3, 3 - - - 32, 32 - - - 1 - - - pictureBox1 - - - System.Windows.Forms.PictureBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - m_tlpNotice - - - 1 - - - Fill - - - Segoe UI, 9pt - - - 3, 3 - - - 1 - - - 434, 38 - - - 4 - - - m_tlpNotice - - - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 1 - - - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="m_labelNotice" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="pictureBox1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,AutoSize,0" /><Rows Styles="AutoSize,0" /></TableLayoutSettings> - - - True - - - GrowAndShrink - - - 1 - - - Fill - - - Segoe UI, 9pt - - - 3, 28 - - - 428, 23 - - - 1 - - - m_progressBar - - - System.Windows.Forms.ProgressBar, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - m_tlpProgress - - - 0 - - - True - - - Fill - - - Segoe UI, 9pt - - - 3, 0 - - - 428, 15 - - - 2 - - - ファイルの圧縮を解除しています... - - - autoHeightLabel1 - - - XenAdmin.Controls.Common.AutoHeightLabel, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - - - m_tlpProgress - - - 1 - - - Fill - - - Segoe UI, 9pt - - - 3, 47 - - - 3 - - - 434, 54 - - - 5 - - - m_tlpProgress - - - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 2 - - - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="m_progressBar" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="autoHeightLabel1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100" /><Rows Styles="AutoSize,0,Absolute,10,AutoSize,0" /></TableLayoutSettings> - - - True - - - GrowAndShrink - - - 2 - - - Segoe UI, 9pt - - - 3, 3 - - - 32, 32 - - - 0 - - - m_pictureBoxError - - - System.Windows.Forms.PictureBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - m_tlpError - - - 0 - - - True - - - Fill - - - Segoe UI, 9pt - - - NoControl - - - 41, 0 - - - 390, 15 - - - 1 - - - 圧縮解除に失敗しました。 - - - MiddleLeft - - - autoHeightLabel3 - - - XenAdmin.Controls.Common.AutoHeightLabel, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - - - m_tlpError - - - 1 - - - True - - - Fill - - - Segoe UI, 9pt - - - 41, 25 - - - 390, 15 - - - 2 - - - autoHeightLabel2 - - - MiddleLeft - - - m_labelError - - - XenAdmin.Controls.Common.AutoHeightLabel, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - - - m_tlpError - - - 2 - - - Fill - - - Segoe UI, 9pt - - - 3, 107 - - - 3 - - - 434, 40 - - - 6 - - - m_tlpError - - - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 3 - - - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="m_pictureBoxError" Row="0" RowSpan="3" Column="0" ColumnSpan="1" /><Control Name="autoHeightLabel3" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="m_labelError" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,AutoSize,0" /><Rows Styles="AutoSize,0,Absolute,10,AutoSize,0" /></TableLayoutSettings> - - - Segoe UI, 9pt - - - 13, 13 - - - 5 - - - 440, 195 - - - 0 - - - tableLayoutPanel1 - - - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 0 - - - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="m_tlpButtons" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="m_tlpNotice" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="m_tlpProgress" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="m_tlpError" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,Percent,100,AutoSize,0" /></TableLayoutSettings> - - - True - - - 96, 96 - - - True - - - GrowAndShrink - - - 465, 220 - - - Segoe UI, 9pt - - - ファイルの圧縮解除 - - - DecompressApplianceDialog - - - XenAdmin.Dialogs.XenDialogBase, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - - \ No newline at end of file diff --git a/XenAdmin/Dialogs/DecompressApplianceDialog.resx b/XenAdmin/Dialogs/DecompressApplianceDialog.resx deleted file mode 100644 index 96414904d..000000000 --- a/XenAdmin/Dialogs/DecompressApplianceDialog.resx +++ /dev/null @@ -1,630 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - Top, Bottom, Left, Right - - - - 1 - - - True - - - GrowAndShrink - - - 3 - - - - Segoe UI, 9pt - - - NoControl - - - 235, 3 - - - 95, 23 - - - 0 - - - &Uncompress - - - m_buttonDecompress - - - System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - m_tlpButtons - - - 0 - - - Segoe UI, 9pt - - - NoControl - - - 336, 3 - - - 95, 23 - - - 1 - - - Cancel - - - m_buttonCancel - - - System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - m_tlpButtons - - - 1 - - - Fill - - - Segoe UI, 9pt - - - 3, 163 - - - 1 - - - 434, 29 - - - 3 - - - m_tlpButtons - - - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 0 - - - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="m_buttonDecompress" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="m_buttonCancel" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /></Controls><Columns Styles="Percent,100,AutoSize,0,AutoSize,0" /><Rows Styles="AutoSize,0" /></TableLayoutSettings> - - - True - - - GrowAndShrink - - - 2 - - - True - - - Fill - - - Segoe UI, 9pt - - - 41, 0 - - - 390, 38 - - - 0 - - - m_label - - - m_labelNotice - - - XenAdmin.Controls.Common.AutoHeightLabel, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - - - m_tlpNotice - - - 0 - - - Segoe UI, 9pt - - - 3, 3 - - - 32, 32 - - - 1 - - - pictureBox1 - - - System.Windows.Forms.PictureBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - m_tlpNotice - - - 1 - - - Fill - - - Segoe UI, 9pt - - - 3, 3 - - - 1 - - - 434, 38 - - - 4 - - - m_tlpNotice - - - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 1 - - - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="m_labelNotice" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="pictureBox1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,AutoSize,0" /><Rows Styles="AutoSize,0" /></TableLayoutSettings> - - - True - - - GrowAndShrink - - - 1 - - - Fill - - - Segoe UI, 9pt - - - 3, 28 - - - 428, 23 - - - 1 - - - m_progressBar - - - System.Windows.Forms.ProgressBar, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - m_tlpProgress - - - 0 - - - True - - - Fill - - - Segoe UI, 9pt - - - 3, 0 - - - 428, 15 - - - 2 - - - Uncompressing file, please wait... - - - autoHeightLabel1 - - - XenAdmin.Controls.Common.AutoHeightLabel, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - - - m_tlpProgress - - - 1 - - - Fill - - - Segoe UI, 9pt - - - 3, 47 - - - 3 - - - 434, 54 - - - 5 - - - m_tlpProgress - - - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 2 - - - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="m_progressBar" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="autoHeightLabel1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100" /><Rows Styles="AutoSize,0,Absolute,10,AutoSize,0" /></TableLayoutSettings> - - - True - - - GrowAndShrink - - - 2 - - - Segoe UI, 9pt - - - 3, 3 - - - 32, 32 - - - 0 - - - m_pictureBoxError - - - System.Windows.Forms.PictureBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - m_tlpError - - - 0 - - - True - - - Fill - - - Segoe UI, 9pt - - - NoControl - - - 41, 0 - - - 390, 15 - - - 1 - - - Uncompression failed. - - - MiddleLeft - - - autoHeightLabel3 - - - XenAdmin.Controls.Common.AutoHeightLabel, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - - - m_tlpError - - - 1 - - - True - - - Fill - - - Segoe UI, 9pt - - - 41, 25 - - - 390, 15 - - - 2 - - - autoHeightLabel2 - - - MiddleLeft - - - m_labelError - - - XenAdmin.Controls.Common.AutoHeightLabel, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - - - m_tlpError - - - 2 - - - Fill - - - Segoe UI, 9pt - - - 3, 107 - - - 3 - - - 434, 40 - - - 6 - - - m_tlpError - - - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 3 - - - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="m_pictureBoxError" Row="0" RowSpan="3" Column="0" ColumnSpan="1" /><Control Name="autoHeightLabel3" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="m_labelError" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,AutoSize,0" /><Rows Styles="AutoSize,0,Absolute,10,AutoSize,0" /></TableLayoutSettings> - - - Segoe UI, 9pt - - - 13, 13 - - - 5 - - - 440, 195 - - - 0 - - - tableLayoutPanel1 - - - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 0 - - - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="m_tlpButtons" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="m_tlpNotice" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="m_tlpProgress" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="m_tlpError" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,Percent,100,AutoSize,0" /></TableLayoutSettings> - - - True - - - 96, 96 - - - True - - - GrowAndShrink - - - 465, 220 - - - Segoe UI, 9pt - - - Uncompress File - - - DecompressApplianceDialog - - - XenAdmin.Dialogs.XenDialogBase, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - - \ No newline at end of file diff --git a/XenAdmin/Dialogs/DecompressApplianceDialog.zh-CN.resx b/XenAdmin/Dialogs/DecompressApplianceDialog.zh-CN.resx deleted file mode 100644 index 8f8766996..000000000 --- a/XenAdmin/Dialogs/DecompressApplianceDialog.zh-CN.resx +++ /dev/null @@ -1,630 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - Top, Bottom, Left, Right - - - - 1 - - - True - - - GrowAndShrink - - - 3 - - - - Segoe UI, 9pt - - - NoControl - - - 235, 3 - - - 95, 23 - - - 0 - - - 解压 (&U) - - - m_buttonDecompress - - - System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - m_tlpButtons - - - 0 - - - Segoe UI, 9pt - - - NoControl - - - 336, 3 - - - 95, 23 - - - 1 - - - 取消 - - - m_buttonCancel - - - System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - m_tlpButtons - - - 1 - - - Fill - - - Segoe UI, 9pt - - - 3, 163 - - - 1 - - - 434, 29 - - - 3 - - - m_tlpButtons - - - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 0 - - - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="m_buttonDecompress" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="m_buttonCancel" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /></Controls><Columns Styles="Percent,100,AutoSize,0,AutoSize,0" /><Rows Styles="AutoSize,0" /></TableLayoutSettings> - - - True - - - GrowAndShrink - - - 2 - - - True - - - Fill - - - Segoe UI, 9pt - - - 41, 0 - - - 390, 38 - - - 0 - - - m_label - - - m_labelNotice - - - XenAdmin.Controls.Common.AutoHeightLabel, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - - - m_tlpNotice - - - 0 - - - Segoe UI, 9pt - - - 3, 3 - - - 32, 32 - - - 1 - - - pictureBox1 - - - System.Windows.Forms.PictureBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - m_tlpNotice - - - 1 - - - Fill - - - Segoe UI, 9pt - - - 3, 3 - - - 1 - - - 434, 38 - - - 4 - - - m_tlpNotice - - - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 1 - - - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="m_labelNotice" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="pictureBox1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,AutoSize,0" /><Rows Styles="AutoSize,0" /></TableLayoutSettings> - - - True - - - GrowAndShrink - - - 1 - - - Fill - - - Segoe UI, 9pt - - - 3, 28 - - - 428, 23 - - - 1 - - - m_progressBar - - - System.Windows.Forms.ProgressBar, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - m_tlpProgress - - - 0 - - - True - - - Fill - - - Segoe UI, 9pt - - - 3, 0 - - - 428, 15 - - - 2 - - - 正在解压文件,请稍候... - - - autoHeightLabel1 - - - XenAdmin.Controls.Common.AutoHeightLabel, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - - - m_tlpProgress - - - 1 - - - Fill - - - Segoe UI, 9pt - - - 3, 47 - - - 3 - - - 434, 54 - - - 5 - - - m_tlpProgress - - - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 2 - - - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="m_progressBar" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="autoHeightLabel1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100" /><Rows Styles="AutoSize,0,Absolute,10,AutoSize,0" /></TableLayoutSettings> - - - True - - - GrowAndShrink - - - 2 - - - Segoe UI, 9pt - - - 3, 3 - - - 32, 32 - - - 0 - - - m_pictureBoxError - - - System.Windows.Forms.PictureBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - m_tlpError - - - 0 - - - True - - - Fill - - - Segoe UI, 9pt - - - NoControl - - - 41, 0 - - - 390, 15 - - - 1 - - - 解压失败。 - - - MiddleLeft - - - autoHeightLabel3 - - - XenAdmin.Controls.Common.AutoHeightLabel, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - - - m_tlpError - - - 1 - - - True - - - Fill - - - Segoe UI, 9pt - - - 41, 25 - - - 390, 15 - - - 2 - - - autoHeightLabel2 - - - MiddleLeft - - - m_labelError - - - XenAdmin.Controls.Common.AutoHeightLabel, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - - - m_tlpError - - - 2 - - - Fill - - - Segoe UI, 9pt - - - 3, 107 - - - 3 - - - 434, 40 - - - 6 - - - m_tlpError - - - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 3 - - - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="m_pictureBoxError" Row="0" RowSpan="3" Column="0" ColumnSpan="1" /><Control Name="autoHeightLabel3" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="m_labelError" Row="2" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,AutoSize,0" /><Rows Styles="AutoSize,0,Absolute,10,AutoSize,0" /></TableLayoutSettings> - - - Segoe UI, 9pt - - - 13, 13 - - - 5 - - - 440, 195 - - - 0 - - - tableLayoutPanel1 - - - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 0 - - - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="m_tlpButtons" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="m_tlpNotice" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="m_tlpProgress" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="m_tlpError" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,Percent,100,AutoSize,0" /></TableLayoutSettings> - - - True - - - 96, 96 - - - True - - - GrowAndShrink - - - 465, 220 - - - Segoe UI, 9pt - - - 解压文件 - - - DecompressApplianceDialog - - - XenAdmin.Dialogs.XenDialogBase, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - - \ No newline at end of file diff --git a/XenAdmin/Wizards/ImportWizard/ImportSourcePage.Designer.cs b/XenAdmin/Wizards/ImportWizard/ImportSourcePage.Designer.cs index 7197bb887..906823687 100644 --- a/XenAdmin/Wizards/ImportWizard/ImportSourcePage.Designer.cs +++ b/XenAdmin/Wizards/ImportWizard/ImportSourcePage.Designer.cs @@ -39,18 +39,29 @@ this.m_tlpEncryption = new System.Windows.Forms.TableLayoutPanel(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.autoHeightLabel1 = new XenAdmin.Controls.Common.AutoHeightLabel(); + this.progressBar1 = new System.Windows.Forms.ProgressBar(); + this.m_tlpError = new System.Windows.Forms.TableLayoutPanel(); + this.pictureBox2 = new System.Windows.Forms.PictureBox(); + this._labelError = new System.Windows.Forms.Label(); + this.labelProgress = new System.Windows.Forms.Label(); + this._unzipWorker = new System.ComponentModel.BackgroundWorker(); this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel2.SuspendLayout(); this.m_tlpEncryption.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.m_tlpError.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); this.SuspendLayout(); // // tableLayoutPanel1 // resources.ApplyResources(this.tableLayoutPanel1, "tableLayoutPanel1"); this.tableLayoutPanel1.Controls.Add(this.lblIntro, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 0, 2); - this.tableLayoutPanel1.Controls.Add(this.m_tlpEncryption, 0, 4); + this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.m_tlpEncryption, 0, 2); + this.tableLayoutPanel1.Controls.Add(this.progressBar1, 0, 5); + this.tableLayoutPanel1.Controls.Add(this.m_tlpError, 0, 3); + this.tableLayoutPanel1.Controls.Add(this.labelProgress, 0, 4); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; // // lblIntro @@ -109,6 +120,44 @@ resources.ApplyResources(this.autoHeightLabel1, "autoHeightLabel1"); this.autoHeightLabel1.Name = "autoHeightLabel1"; // + // progressBar1 + // + resources.ApplyResources(this.progressBar1, "progressBar1"); + this.progressBar1.Name = "progressBar1"; + this.progressBar1.Style = System.Windows.Forms.ProgressBarStyle.Continuous; + // + // m_tlpError + // + resources.ApplyResources(this.m_tlpError, "m_tlpError"); + this.m_tlpError.Controls.Add(this.pictureBox2, 0, 0); + this.m_tlpError.Controls.Add(this._labelError, 1, 0); + this.m_tlpError.Name = "m_tlpError"; + // + // pictureBox2 + // + resources.ApplyResources(this.pictureBox2, "pictureBox2"); + this.pictureBox2.Image = global::XenAdmin.Properties.Resources._000_error_h32bit_16; + this.pictureBox2.Name = "pictureBox2"; + this.pictureBox2.TabStop = false; + // + // _labelError + // + resources.ApplyResources(this._labelError, "_labelError"); + this._labelError.Name = "_labelError"; + // + // labelProgress + // + resources.ApplyResources(this.labelProgress, "labelProgress"); + this.labelProgress.Name = "labelProgress"; + // + // _unzipWorker + // + this._unzipWorker.WorkerReportsProgress = true; + this._unzipWorker.WorkerSupportsCancellation = true; + this._unzipWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this._unzipWorker_DoWork); + this._unzipWorker.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this._unzipWorker_ProgressChanged); + this._unzipWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this._unzipWorker_RunWorkerCompleted); + // // ImportSourcePage // resources.ApplyResources(this, "$this"); @@ -122,6 +171,9 @@ this.m_tlpEncryption.ResumeLayout(false); this.m_tlpEncryption.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.m_tlpError.ResumeLayout(false); + this.m_tlpError.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); this.ResumeLayout(false); } @@ -138,6 +190,12 @@ private System.Windows.Forms.TableLayoutPanel m_tlpEncryption; private System.Windows.Forms.PictureBox pictureBox1; private XenAdmin.Controls.Common.AutoHeightLabel autoHeightLabel1; + private System.Windows.Forms.ProgressBar progressBar1; + private System.Windows.Forms.TableLayoutPanel m_tlpError; + private System.Windows.Forms.PictureBox pictureBox2; + private System.ComponentModel.BackgroundWorker _unzipWorker; + private System.Windows.Forms.Label labelProgress; + private System.Windows.Forms.Label _labelError; } } diff --git a/XenAdmin/Wizards/ImportWizard/ImportSourcePage.cs b/XenAdmin/Wizards/ImportWizard/ImportSourcePage.cs index 3ec9a8c59..fe7a55ba1 100644 --- a/XenAdmin/Wizards/ImportWizard/ImportSourcePage.cs +++ b/XenAdmin/Wizards/ImportWizard/ImportSourcePage.cs @@ -31,6 +31,8 @@ using System; using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; using System.IO; using System.Text.RegularExpressions; using System.Windows.Forms; @@ -40,6 +42,7 @@ using DiscUtils; using DiscUtils.Wim; using XenAdmin.Controls; using XenCenterLib; +using XenCenterLib.Compression; using XenAdmin.Dialogs; using XenAdmin.Controls.Common; using XenCenterLib.Archive; @@ -55,9 +58,9 @@ namespace XenAdmin.Wizards.ImportWizard { #region Private fields private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - private readonly string[] m_supportedImageTypes = new[] { ".vhd", ".vmdk" };//CA-61385: remove ".vdi", ".wim" support for Boston - private readonly string[] m_supportedApplianceTypes = new[] { ".ovf", ".ova", ".ova.gz" }; - private readonly string[] m_supportedXvaTypes = new[] {".xva", "ova.xml"}; + private readonly string[] m_supportedImageTypes = { ".vhd", ".vmdk" };//CA-61385: remove ".vdi", ".wim" support for Boston + private readonly string[] m_supportedApplianceTypes = { ".ovf", ".ova", ".ova.gz" }; + private readonly string[] m_supportedXvaTypes = {".xva", "ova.xml"}; /// /// Stores the last valid selected appliance @@ -66,6 +69,9 @@ namespace XenAdmin.Wizards.ImportWizard private EnvelopeType m_selectedOvfEnvelope; private bool m_buttonNextEnabled; + + private string _unzipFileIn; + private string _unzipFileOut; #endregion public ImportSourcePage() @@ -73,6 +79,9 @@ namespace XenAdmin.Wizards.ImportWizard InitializeComponent(); m_ctrlError.HideError(); m_tlpEncryption.Visible = false; + m_tlpError.Visible = false; + progressBar1.Visible = false; + labelProgress.Visible = false; } #region Base class (XenTabPage) overrides @@ -113,27 +122,38 @@ namespace XenAdmin.Wizards.ImportWizard return; } - if (!PerformCheck(CheckIsCompressed)) - { - cancel = true; - return; - } + string extension = Path.GetExtension(FilePath).ToLower(); - var checks = new List(); + if (extension == ".gz") + { + if (!PerformCheck(CheckSourceIsWritable)) + { + cancel = true; + return; + } + + if (!Uncompress()) + { + cancel = true; + return; + } + } + + CheckDelegate check = null; switch (TypeOfImport) { case ImportWizard.ImportType.Xva: - checks.Add(GetDiskCapacityXva); + check = GetDiskCapacityXva; break; case ImportWizard.ImportType.Ovf: - checks.Add(LoadAppliance); + check = LoadAppliance; break; case ImportWizard.ImportType.Vhd: - checks.Add(GetDiskCapacityImage); + check = GetDiskCapacityImage; break; } - if (!PerformCheck(checks.ToArray())) + if (!PerformCheck(check)) { cancel = true; return; @@ -149,6 +169,12 @@ namespace XenAdmin.Wizards.ImportWizard } } + public override void PageCancelled() + { + if (_unzipWorker.IsBusy) + _unzipWorker.CancelAsync(); + } + public override void PopulatePage() { lblIntro.Text = OvfModeOnly ? Messages.IMPORT_SOURCE_PAGE_INTRO_OVF_ONLY : Messages.IMPORT_SOURCE_PAGE_INTRO; @@ -548,35 +574,6 @@ namespace XenAdmin.Wizards.ImportWizard } } - /// - /// Check when we leave the page - /// - private bool CheckIsCompressed(out string error) - { - error = string.Empty; - string fileName = FilePath; - string extension = Path.GetExtension(fileName).ToLower(); - - if (extension == ".gz") - { - if (!CheckSourceIsWritable(out error)) - return false; - - string outfile = Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName)); - - using (var dlog = new DecompressApplianceDialog(fileName, outfile)) - { - if (dlog.ShowDialog(ParentForm) == DialogResult.Yes) - { - m_textBoxFile.Text = outfile; - return true; - } - return false; //user cancelled or error - } - } - return true;//it's not compressed, ok to continue - } - private bool CheckDownloadFromUri(out string error) { error = string.Empty; @@ -606,10 +603,58 @@ namespace XenAdmin.Wizards.ImportWizard return false; //an error happened during download or the user cancelled } } - - #endregion - #region Control event handlers + #endregion + + #region Uncompression + + private bool Uncompress() + { + _unzipFileIn = FilePath; + if (string.IsNullOrEmpty(_unzipFileIn)) + return false; + + _unzipFileOut = Path.Combine(Path.GetDirectoryName(_unzipFileIn), Path.GetFileNameWithoutExtension(_unzipFileIn)); + + var msg = string.Format(Messages.UNCOMPRESS_APPLIANCE_DESCRIPTION, + Path.GetFileName(_unzipFileOut), Path.GetFileName(_unzipFileIn)); + + using (var dlog = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Exclamation, msg, Messages.XENCENTER), + new ThreeButtonDialog.TBDButton(Messages.YES, DialogResult.Yes), + new ThreeButtonDialog.TBDButton(Messages.NO, DialogResult.No))) + { + if (dlog.ShowDialog(this) == DialogResult.Yes) + return StartUncompression(); + + return false; //user cancelled or error + } + } + + private bool StartUncompression() + { + m_textBoxFile.Enabled = false; + m_buttonBrowse.Enabled = false; + + m_buttonNextEnabled = false; + OnPageUpdated(); + + m_tlpError.Visible = false; + labelProgress.Visible = true; + progressBar1.Visible = true; + progressBar1.Value = 0; + _unzipWorker.RunWorkerAsync(); + + while (_unzipWorker.IsBusy) + Application.DoEvents(); + + m_textBoxFile.Enabled = true; + m_buttonBrowse.Enabled = true; + return m_textBoxFile.Text == _unzipFileOut; + } + + #endregion + + #region Event handlers private void m_buttonBrowse_Click(object sender, EventArgs e) { @@ -635,6 +680,108 @@ namespace XenAdmin.Wizards.ImportWizard IsDirty = true; } + + private void _unzipWorker_DoWork(object sender, DoWorkEventArgs e) + { + FileInfo info = new FileInfo(_unzipFileIn); + long length = info.Length; + + using (Stream inStream = File.Open(_unzipFileIn, FileMode.Open, FileAccess.ReadWrite, FileShare.None)) + using (Stream outStream = File.Open(_unzipFileOut, FileMode.Create, FileAccess.ReadWrite, FileShare.None)) + { + try + { + using (CompressionStream bzis = CompressionFactory.Reader(CompressionFactory.Type.Gz, inStream)) + { + byte[] buffer = new byte[4 * 1024]; + + int bytesRead; + while ((bytesRead = bzis.Read(buffer, 0, buffer.Length)) > 0) + { + outStream.Write(buffer, 0, bytesRead); + + int percentage = (int)Math.Floor((double)bzis.Position * 100 / length); + + if (percentage < 0) + _unzipWorker.ReportProgress(0); + else if (percentage > 100) + _unzipWorker.ReportProgress(100); + else + _unzipWorker.ReportProgress(percentage); + + if (_unzipWorker.CancellationPending) + { + e.Cancel = true; + return; + } + } + } + + e.Result = _unzipFileOut; + } + catch (Exception ex) + { + log.Error(string.Format("Error while uncompressing {0} to {1}", _unzipFileIn, _unzipFileOut), ex); + throw; + } + finally + { + outStream.Flush(); + } + } + } + + private void _unzipWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) + { + progressBar1.Value = e.ProgressPercentage; + } + + private void _unzipWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) + { + progressBar1.Visible = false; + labelProgress.Visible = false; + + if (e.Cancelled) + { + try + { + File.Delete(_unzipFileOut); + } + catch (Exception ex) + { + log.Error(string.Format("Failed to delete uncompressed file {0}.", _unzipFileOut), ex); + } + return; + } + + if (e.Error != null) + { + m_tlpError.Visible = true; + try + { + File.Delete(_unzipFileOut); + } + catch (Exception ex) + { + log.Error(string.Format("Failed to delete uncompressed file {0}.", _unzipFileOut), ex); + } + return; + } + + var uncompressedFile = e.Result as string; + progressBar1.Value = 100; + m_textBoxFile.Text = uncompressedFile; + + try + { + File.Delete(_unzipFileIn); + } + catch (Exception ex) + { + log.Error(string.Format("Failed to delete compressed file {0}.", _unzipFileIn), ex); + } + } + #endregion } } diff --git a/XenAdmin/Wizards/ImportWizard/ImportSourcePage.resx b/XenAdmin/Wizards/ImportWizard/ImportSourcePage.resx index a40ae14d7..be4e08f20 100644 --- a/XenAdmin/Wizards/ImportWizard/ImportSourcePage.resx +++ b/XenAdmin/Wizards/ImportWizard/ImportSourcePage.resx @@ -112,29 +112,32 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 1 True - + Fill NoControl - + 3, 0 + + 3, 0, 3, 20 + 555, 13 @@ -190,7 +193,7 @@ label1 - System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel2 @@ -217,7 +220,7 @@ m_textBoxFile - System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel2 @@ -244,7 +247,7 @@ m_buttonBrowse - System.Windows.Forms.Button, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel2 @@ -294,6 +297,9 @@ 3, 36 + + 3, 3, 3, 20 + 2 @@ -307,7 +313,7 @@ tableLayoutPanel2 - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 @@ -340,7 +346,7 @@ pictureBox1 - System.Windows.Forms.PictureBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 m_tlpEncryption @@ -385,7 +391,7 @@ Fill - 3, 113 + 3, 110 1 @@ -400,7 +406,7 @@ m_tlpEncryption - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 tableLayoutPanel1 @@ -411,6 +417,150 @@ <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="pictureBox1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="autoHeightLabel1" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100" /><Rows Styles="AutoSize,0" /></TableLayoutSettings> + + Left, Right + + + 3, 267 + + + 555, 23 + + + 3 + + + progressBar1 + + + System.Windows.Forms.ProgressBar, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + + 3 + + + Bottom, Left, Right + + + True + + + GrowAndShrink + + + 2 + + + Left + + + 3, 3 + + + 16, 16 + + + 0 + + + pictureBox2 + + + System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + m_tlpError + + + 0 + + + Left + + + True + + + 25, 4 + + + 319, 13 + + + 3 + + + Failed to uncompress file. Please see the logs for more information. + + + _labelError + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + m_tlpError + + + 1 + + + 3, 226 + + + 1 + + + 555, 22 + + + 4 + + + m_tlpError + + + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + + 4 + + + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="pictureBox2" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="_labelError" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,Percent,100,Absolute,20" /><Rows Styles="Percent,100" /></TableLayoutSettings> + + + True + + + 3, 251 + + + 164, 13 + + + 5 + + + Uncompressing file, please wait... + + + labelProgress + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + + 5 + Fill @@ -430,7 +580,7 @@ tableLayoutPanel1 - System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 $this @@ -439,9 +589,12 @@ 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="lblIntro" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="tableLayoutPanel2" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="m_tlpEncryption" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100" /><Rows Styles="AutoSize,0,Absolute,20,AutoSize,0,Absolute,20,AutoSize,0,Percent,100" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="lblIntro" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="tableLayoutPanel2" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="m_tlpEncryption" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="progressBar1" Row="5" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="m_tlpError" Row="3" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="labelProgress" Row="4" RowSpan="1" Column="0" ColumnSpan="1" /></Controls><Columns Styles="Percent,100" /><Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,Percent,100,AutoSize,0,AutoSize,0" /></TableLayoutSettings> - + + 17, 17 + + True @@ -450,10 +603,16 @@ 561, 293 + + _unzipWorker + + + System.ComponentModel.BackgroundWorker, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + ImportSourcePage - XenAdmin.Wizards.GenericPages.ImExPortPage, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + XenAdmin.Controls.XenTabPage, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - + \ No newline at end of file diff --git a/XenAdmin/XenAdmin.csproj b/XenAdmin/XenAdmin.csproj index 5ccba309d..0804570bc 100755 --- a/XenAdmin/XenAdmin.csproj +++ b/XenAdmin/XenAdmin.csproj @@ -3064,12 +3064,6 @@ - - Form - - - DecompressApplianceDialog.cs - Form @@ -5250,15 +5244,6 @@ DateFilterDialog.cs - - DecompressApplianceDialog.cs - - - DecompressApplianceDialog.cs - - - DecompressApplianceDialog.cs - DialogWithProgress.cs diff --git a/XenAdminTests/DialogTests/DecompressApplianceDialogTests.cs b/XenAdminTests/DialogTests/DecompressApplianceDialogTests.cs deleted file mode 100644 index 9db00d63c..000000000 --- a/XenAdminTests/DialogTests/DecompressApplianceDialogTests.cs +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, - * with or without modification, are permitted provided - * that the following conditions are met: - * - * * Redistributions of source code must retain the above - * copyright notice, this list of conditions and the - * following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the - * following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -using System.Windows.Forms; -using NUnit.Framework; -using XenAdmin.Dialogs; - -namespace XenAdminTests.DialogTests.boston.DecompressApplianceDialogTests -{ - [TestFixture, Category(TestCategories.UICategoryA)] - public class DecompressApplianceDialogTests : DialogTest - { - protected override DecompressApplianceDialog NewDialog() - { - return new DecompressApplianceDialog("file1", "file2"); - } - - protected override void RunAfter() - { - Button decompress = TestUtils.GetButton(dialog, "m_buttonDecompress"); - Assert.IsTrue(decompress.Enabled, "decompress button enabled"); - } - } -} \ No newline at end of file diff --git a/XenAdminTests/XenAdminTests.csproj b/XenAdminTests/XenAdminTests.csproj index a74b701d7..17df3c4dd 100644 --- a/XenAdminTests/XenAdminTests.csproj +++ b/XenAdminTests/XenAdminTests.csproj @@ -272,7 +272,6 @@ -