Do not use the task description as the AsyncAction description because in most cases it is not localised.

Also, do not poll if the RelatedTask is null.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2021-03-09 00:31:57 +00:00
parent 47d9146ce3
commit f05b16eff7
7 changed files with 9 additions and 45 deletions

View File

@ -141,7 +141,7 @@ namespace XenAdmin.Actions
/// <summary> /// <summary>
/// Prepare the action's task for exit by removing the XenCenterUUID. /// Prepare the action's task for exit by removing the XenCenterUUID.
/// A call here just before exit will mean that the task will get picked /// A call here just before exit will mean that the task will get picked
/// up as a meddling action on restart of xencenter, and thus reappear in the log. /// up as a meddling action on restart of xencenter, and thus reappear in the EventsTab.
/// </summary> /// </summary>
public void PrepareForLogReloadAfterRestart() public void PrepareForLogReloadAfterRestart()
{ {
@ -269,6 +269,9 @@ namespace XenAdmin.Actions
public void PollToCompletion(double start = 0, double finish = 100, bool suppressFailures = false) public void PollToCompletion(double start = 0, double finish = 100, bool suppressFailures = false)
{ {
if (RelatedTask == null)
return;
try try
{ {
DateTime startTime = DateTime.Now; DateTime startTime = DateTime.Now;
@ -342,8 +345,7 @@ namespace XenAdmin.Actions
Session = session; Session = session;
} }
Tick((int)(start + task.progress * (finish - start)), PercentComplete = (int)(start + task.progress * (finish - start));
task.Description() == "" ? Description : task.Description());
switch (task.status) switch (task.status)
{ {

View File

@ -81,6 +81,7 @@ namespace XenAdmin.Actions
switch (type) switch (type)
{ {
case HostBackupRestoreType.backup: case HostBackupRestoreType.backup:
Description = string.Format(Messages.BACKINGUP_HOST, Host.Name());
RelatedTask = Task.create(Session, "get_host_backup_task", Host.address); RelatedTask = Task.create(Session, "get_host_backup_task", Host.address);
log.DebugFormat("HTTP GETTING file from {0} to {1}", Host.address, filename); log.DebugFormat("HTTP GETTING file from {0} to {1}", Host.address, filename);

View File

@ -60,6 +60,7 @@ namespace XenAdmin.Actions
protected override void Run() protected override void Run()
{ {
Description = string.Format(Messages.ACTION_SYSTEM_STATUS_COMPILING, Helpers.GetName(host));
Status = ReportStatus.compiling; Status = ReportStatus.compiling;
string hostname = Helpers.GetName(host); string hostname = Helpers.GetName(host);

View File

@ -98,9 +98,7 @@ namespace XenAdmin.Actions
SafeToExit = false; SafeToExit = false;
Description = Messages.ACTION_EXPORT_DESCRIPTION_IN_PROGRESS; Description = Messages.ACTION_EXPORT_DESCRIPTION_IN_PROGRESS;
RelatedTask = XenAPI.Task.create(Session, RelatedTask = Task.create(Session, "export", $"Exporting {VM.Name()} to backup file");
string.Format(Messages.ACTION_EXPORT_TASK_NAME, VM.Name()),
string.Format(Messages.ACTION_EXPORT_TASK_DESCRIPTION, VM.Name()));
UriBuilder uriBuilder = new UriBuilder(this.Session.Url); UriBuilder uriBuilder = new UriBuilder(this.Session.Url);
uriBuilder.Path = "export"; uriBuilder.Path = "export";

View File

@ -1203,15 +1203,6 @@ namespace XenAdmin {
} }
} }
/// <summary>
/// Looks up a localized string similar to Exporting {0} to backup file.
/// </summary>
public static string ACTION_EXPORT_TASK_DESCRIPTION {
get {
return ResourceManager.GetString("ACTION_EXPORT_TASK_DESCRIPTION", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Exporting {0}. /// Looks up a localized string similar to Exporting {0}.
/// </summary> /// </summary>
@ -3678,24 +3669,6 @@ namespace XenAdmin {
} }
} }
/// <summary>
/// Looks up a localized string similar to Downloading WLB report {0}.
/// </summary>
public static string ACTION_WLB_REPORT_TASK_DESCRIPTION {
get {
return ResourceManager.GetString("ACTION_WLB_REPORT_TASK_DESCRIPTION", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Downloading WLB report {0}.
/// </summary>
public static string ACTION_WLB_REPORT_TASK_NAME {
get {
return ResourceManager.GetString("ACTION_WLB_REPORT_TASK_NAME", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to A&amp;ctivate. /// Looks up a localized string similar to A&amp;ctivate.
/// </summary> /// </summary>

View File

@ -498,9 +498,6 @@
<data name="ACTION_EXPORT_POOL_RESOURCE_LIST_FROM_X" xml:space="preserve"> <data name="ACTION_EXPORT_POOL_RESOURCE_LIST_FROM_X" xml:space="preserve">
<value>Exporting pool resource list from '{0}'</value> <value>Exporting pool resource list from '{0}'</value>
</data> </data>
<data name="ACTION_EXPORT_TASK_DESCRIPTION" xml:space="preserve">
<value>Exporting {0} to backup file</value>
</data>
<data name="ACTION_EXPORT_TASK_NAME" xml:space="preserve"> <data name="ACTION_EXPORT_TASK_NAME" xml:space="preserve">
<value>Exporting {0}</value> <value>Exporting {0}</value>
</data> </data>
@ -1323,12 +1320,6 @@
<data name="ACTION_WLB_REPORT_SUCCESSFUL" xml:space="preserve"> <data name="ACTION_WLB_REPORT_SUCCESSFUL" xml:space="preserve">
<value>Downloaded</value> <value>Downloaded</value>
</data> </data>
<data name="ACTION_WLB_REPORT_TASK_DESCRIPTION" xml:space="preserve">
<value>Downloading WLB report {0}</value>
</data>
<data name="ACTION_WLB_REPORT_TASK_NAME" xml:space="preserve">
<value>Downloading WLB report {0}</value>
</data>
<data name="ACTIVATE" xml:space="preserve"> <data name="ACTIVATE" xml:space="preserve">
<value>A&amp;ctivate</value> <value>A&amp;ctivate</value>
</data> </data>

View File

@ -79,9 +79,7 @@ namespace XenAdmin.Actions.Wlb
{ {
Description = Messages.ACTION_WLB_REPORT_DOWNLOADING; Description = Messages.ACTION_WLB_REPORT_DOWNLOADING;
RelatedTask = XenAPI.Task.create(Session, RelatedTask = Task.create(Session, "wlb_report", $"Downloading WLB report {reportName}");
string.Format(Messages.ACTION_WLB_REPORT_TASK_NAME, reportName),
string.Format(Messages.ACTION_WLB_REPORT_TASK_DESCRIPTION, reportName));
UriBuilder uriBuilder = new UriBuilder(Session.Url); UriBuilder uriBuilder = new UriBuilder(Session.Url);
uriBuilder.Path = "wlb_report"; uriBuilder.Path = "wlb_report";