CP-24818: [Update Wizard Improvements] Show the progress of the download in Automated mode

Signed-off-by: Gabor Apati-Nagy <gabor.apati-nagy@citrix.com>
This commit is contained in:
Gabor Apati-Nagy 2017-10-02 16:34:23 +01:00
parent f983dd9e90
commit c00439bef4
6 changed files with 70 additions and 20 deletions

View File

@ -291,7 +291,7 @@ namespace XenAdmin.Wizards.PatchingWizard
{
if (pa.Visible)
{
sb.Append(pa);
sb.Append(pa.ProgressDescription ?? pa.ToString());
sb.AppendLine();
}
}
@ -435,19 +435,30 @@ namespace XenAdmin.Wizards.PatchingWizard
}
private static void RunPlanAction(UpdateProgressBackgroundWorker bgw, PlanAction action)
private void RunPlanAction(UpdateProgressBackgroundWorker bgw, PlanAction action)
{
InitializePlanAction(bgw, action);
action.OnProgressChange += action_OnProgressChange;
bgw.ReportProgress(0, action);
action.Run();
Thread.Sleep(1000);
action.OnProgressChange -= action_OnProgressChange;
bgw.doneActions.Add(action);
bgw.ReportProgress((int)((1.0 / (double)bgw.ActionsCount) * 100), action);
}
private void action_OnProgressChange(object sender, EventArgs e)
{
Program.Invoke(Program.MainWindow, () =>
{
UpdateStatusTextBox();
});
}
private static void InitializePlanAction(UpdateProgressBackgroundWorker bgw, PlanAction action)
{
if (action is IAvoidRestartHostsAware)

View File

@ -102,23 +102,25 @@ namespace XenAdmin.Wizards.PatchingWizard.PlanActions
private void downloadAndUnzipXenServerPatchAction_Changed(object sender)
{
var action = sender as AsyncAction;
if (action == null)
var downloadAction = sender as DownloadAndUnzipXenServerPatchAction;
if (downloadAction == null)
return;
if (Cancelling)
action.Cancel();
downloadAction.Cancel();
Program.Invoke(Program.MainWindow, () =>
{
//UpdateActionProgress(action);
//flickerFreeListBox1.Refresh();
//OnPageUpdated();
if (!string.IsNullOrEmpty(downloadAction.DownloadProgressDescription))
ProgressDescription = string.Format(Messages.PATCHINGWIZARD_AUTOUPDATINGPAGE_IN_PROGRESS_DOTDOTDOT, downloadAction.DownloadProgressDescription);
});
}
private void downloadAndUnzipXenServerPatchAction_Completed(ActionBase sender)
{
ProgressDescription = null;
var action = sender as AsyncAction;
if (action == null)
return;

View File

@ -45,7 +45,7 @@ namespace XenAdmin.Wizards.PatchingWizard.PlanActions
protected static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private int _percentComplete;
public event EventHandler OnPercentCompleteChange;
public event EventHandler OnProgressChange;
public event EventHandler OnActionError;
public event Action<PlanAction, Host> StatusChanged;
public Exception Error;
@ -91,8 +91,8 @@ namespace XenAdmin.Wizards.PatchingWizard.PlanActions
protected set
{
_percentComplete = value;
if (OnPercentCompleteChange != null)
OnPercentCompleteChange(this, new EventArgs());
if (OnProgressChange != null)
OnProgressChange(this, new EventArgs());
}
}
@ -250,6 +250,26 @@ namespace XenAdmin.Wizards.PatchingWizard.PlanActions
{
Cancelling = true;
}
string _progressDescription;
public string ProgressDescription
{
get
{
return _progressDescription;
}
protected set
{
_progressDescription = value;
if (OnProgressChange != null)
OnProgressChange(this, new EventArgs());
}
}
}
}

View File

@ -253,7 +253,10 @@ namespace XenAdmin.Actions
if (pc != PercentComplete)
{
PercentComplete = pc;
Description = string.Format(Messages.DOWNLOAD_AND_EXTRACT_ACTION_DOWNLOADING_DETAILS_DESC, updateName,
DownloadProgressDescription
= Description
= string.Format(Messages.DOWNLOAD_AND_EXTRACT_ACTION_DOWNLOADING_DETAILS_DESC, updateName,
Util.DiskSizeString(e.BytesReceived),
Util.DiskSizeString(e.TotalBytesToReceive));
}
@ -289,5 +292,7 @@ namespace XenAdmin.Actions
protected override void CancelRelatedTask()
{
}
public string DownloadProgressDescription { get; set; }
}
}

View File

@ -11709,7 +11709,7 @@ namespace XenAdmin {
}
/// <summary>
/// Looks up a localized string similar to Downloading {0}.
/// Looks up a localized string similar to Downloading update {0}.
/// </summary>
public static string DOWNLOAD_AND_EXTRACT_ACTION_DOWNLOADING_DESC {
get {
@ -11718,7 +11718,7 @@ namespace XenAdmin {
}
/// <summary>
/// Looks up a localized string similar to Downloading {0} ({1} of {2}).
/// Looks up a localized string similar to Downloading update {0} ({1} of {2}).
/// </summary>
public static string DOWNLOAD_AND_EXTRACT_ACTION_DOWNLOADING_DETAILS_DESC {
get {
@ -11727,7 +11727,7 @@ namespace XenAdmin {
}
/// <summary>
/// Looks up a localized string similar to Extracting {0}.
/// Looks up a localized string similar to Extracting update {0}.
/// </summary>
public static string DOWNLOAD_AND_EXTRACT_ACTION_EXTRACTING_DESC {
get {
@ -11754,7 +11754,7 @@ namespace XenAdmin {
}
/// <summary>
/// Looks up a localized string similar to Download and extract {0}.
/// Looks up a localized string similar to Download and extract update {0}.
/// </summary>
public static string DOWNLOAD_AND_EXTRACT_ACTION_TITLE {
get {
@ -26445,6 +26445,15 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to {0}....
/// </summary>
public static string PATCHINGWIZARD_AUTOUPDATINGPAGE_IN_PROGRESS_DOTDOTDOT {
get {
return ResourceManager.GetString("PATCHINGWIZARD_AUTOUPDATINGPAGE_IN_PROGRESS_DOTDOTDOT", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Upload and Install.
/// </summary>

View File

@ -4163,16 +4163,16 @@ This will also delete its subfolders.</value>
<value>Downloading update from '{0}'...</value>
</data>
<data name="DOWNLOAD_AND_EXTRACT_ACTION_DOWNLOADING_DESC" xml:space="preserve">
<value>Downloading {0}</value>
<value>Downloading update {0}</value>
</data>
<data name="DOWNLOAD_AND_EXTRACT_ACTION_DOWNLOADING_DETAILS_DESC" xml:space="preserve">
<value>Downloading {0} ({1} of {2})</value>
<value>Downloading update {0} ({1} of {2})</value>
</data>
<data name="DOWNLOAD_AND_EXTRACT_ACTION_DOWNLOAD_CANCELLED_DESC" xml:space="preserve">
<value>Download canceled</value>
</data>
<data name="DOWNLOAD_AND_EXTRACT_ACTION_EXTRACTING_DESC" xml:space="preserve">
<value>Extracting {0}</value>
<value>Extracting update {0}</value>
</data>
<data name="DOWNLOAD_AND_EXTRACT_ACTION_EXTRACTING_ERROR" xml:space="preserve">
<value>Cannot extract the update file from downloaded archive. Please see application logs for more details.</value>
@ -4181,7 +4181,7 @@ This will also delete its subfolders.</value>
<value>Update file could not be located. Please see application logs for more details.</value>
</data>
<data name="DOWNLOAD_AND_EXTRACT_ACTION_TITLE" xml:space="preserve">
<value>Download and extract {0}</value>
<value>Download and extract update {0}</value>
</data>
<data name="DOWNLOAD_ELLIPSES" xml:space="preserve">
<value>Download...</value>
@ -9128,6 +9128,9 @@ However, there is not enough space to perform the repartitioning, so the current
<data name="PATCHINGWIZARD_AUTOUPDATINGPAGE_FAILED" xml:space="preserve">
<value>The update was not completed successfully</value>
</data>
<data name="PATCHINGWIZARD_AUTOUPDATINGPAGE_IN_PROGRESS_DOTDOTDOT" xml:space="preserve">
<value>{0}...</value>
</data>
<data name="PATCHINGWIZARD_AUTOUPDATINGPAGE_TEXT" xml:space="preserve">
<value>Upload and Install</value>
</data>