mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 15:29:26 +01:00
Use Tick() when setting both the PercentComplete and the Description to avoid firing OnChanged() twice.
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
1225e98225
commit
8f9afafb7a
@ -260,9 +260,13 @@ namespace XenAdmin.Actions
|
||||
NewAction?.Invoke(this);
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// If you want to set the PercentComplete and the Description at the
|
||||
/// same time, use Tick() in order to avoid firing OnChanged() twice
|
||||
/// </remarks>
|
||||
public string Description
|
||||
{
|
||||
get { return _description; }
|
||||
get => _description;
|
||||
set
|
||||
{
|
||||
if (_description != value)
|
||||
@ -277,7 +281,7 @@ namespace XenAdmin.Actions
|
||||
|
||||
public bool IsCompleted
|
||||
{
|
||||
get { return _isCompleted; }
|
||||
get => _isCompleted;
|
||||
set
|
||||
{
|
||||
if (_isCompleted != value)
|
||||
@ -289,14 +293,18 @@ namespace XenAdmin.Actions
|
||||
}
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// If you want to set the PercentComplete and the Description at the
|
||||
/// same time, use Tick() in order to avoid firing OnChanged() twice
|
||||
/// </remarks>
|
||||
public virtual int PercentComplete
|
||||
{
|
||||
get { return _percentComplete; }
|
||||
get => _percentComplete;
|
||||
set
|
||||
{
|
||||
if (_percentComplete != value)
|
||||
{
|
||||
System.Diagnostics.Debug.Assert(0 <= value && value <= 100, string.Format("value percent is {0}", value));
|
||||
System.Diagnostics.Debug.Assert(0 <= value && value <= 100, $"Percent is {value}");
|
||||
|
||||
var percent = value;
|
||||
if (percent < 0)
|
||||
@ -318,6 +326,8 @@ namespace XenAdmin.Actions
|
||||
{
|
||||
_description = description;
|
||||
|
||||
System.Diagnostics.Debug.Assert(0 <= percent && percent <= 100, $"Percent is {percent}");
|
||||
|
||||
if (percent < 0)
|
||||
percent = 0;
|
||||
else if (percent > 100)
|
||||
|
@ -77,8 +77,8 @@ namespace XenAdmin.Actions.DR
|
||||
DestroyVM(Session, vm);
|
||||
PercentComplete += increment;
|
||||
}
|
||||
Description = Messages.ACTION_VM_DESTROYED;
|
||||
PercentComplete = 100;
|
||||
|
||||
Tick(100, Messages.ACTION_VM_DESTROYED);
|
||||
}
|
||||
|
||||
|
||||
|
@ -101,8 +101,8 @@ namespace XenAdmin.Actions.DR
|
||||
}
|
||||
PercentComplete += increment;
|
||||
}
|
||||
Description = Messages.DELETED_VM_APPLIANCES;
|
||||
PercentComplete = 100;
|
||||
|
||||
Tick(100, Messages.DELETED_VM_APPLIANCES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,8 +130,8 @@ namespace XenAdmin.Actions.DR
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
PercentComplete = 100;
|
||||
Description = Messages.ACTION_VDI_LOAD_METADATA_DONE;
|
||||
|
||||
Tick(100, Messages.ACTION_VDI_LOAD_METADATA_DONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,9 +71,8 @@ namespace XenAdmin.Actions.DR
|
||||
{
|
||||
MetadataSession = Session.get_record(Session, MetadataSessionRef);
|
||||
}
|
||||
PercentComplete = 100;
|
||||
|
||||
Description = Messages.ACTION_VDI_OPEN_DATABASE_DONE;
|
||||
|
||||
Tick(100, Messages.ACTION_VDI_OPEN_DATABASE_DONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,8 +101,7 @@ namespace XenAdmin.Actions
|
||||
|
||||
PollToCompletion();
|
||||
Status = ReportStatus.succeeded;
|
||||
Description = Messages.COMPLETED;
|
||||
PercentComplete = 100;
|
||||
Tick(100, Messages.COMPLETED);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -64,8 +64,8 @@ namespace XenAdmin.Actions
|
||||
: PGPU.async_disable_dom0_access(Session, pGpu.opaque_ref);
|
||||
PollToCompletion(50, 100);
|
||||
}
|
||||
PercentComplete = 100;
|
||||
Description = string.Format(Messages.UPDATED_PROPERTIES, Helpers.GetName(Host).Ellipsise(50));
|
||||
|
||||
Tick(100, string.Format(Messages.UPDATED_PROPERTIES, Helpers.GetName(Host).Ellipsise(50)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,8 +98,8 @@ namespace XenAdmin.Actions
|
||||
|
||||
RunSubActions(exceptions);
|
||||
|
||||
PercentComplete = 100;
|
||||
Description = endDescription;
|
||||
Tick(100, endDescription);
|
||||
|
||||
if (exceptions.Count > 1)
|
||||
{
|
||||
foreach (Exception e in exceptions)
|
||||
|
@ -50,8 +50,7 @@ namespace XenAdmin.Actions
|
||||
{
|
||||
PercentComplete = 40;
|
||||
PIF.scan(Session, Host.opaque_ref);
|
||||
Description = Messages.COMPLETED;
|
||||
PercentComplete = 100;
|
||||
Tick(100, Messages.COMPLETED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,8 +143,8 @@ namespace XenAdmin.Actions
|
||||
PercentComplete += percentStep;
|
||||
}
|
||||
|
||||
PercentComplete = 100;
|
||||
Description = error != null ? Messages.COMPLETED_WITH_ERRORS : Messages.COMPLETED;
|
||||
Tick(100, error != null ? Messages.COMPLETED_WITH_ERRORS : Messages.COMPLETED);
|
||||
|
||||
if (error != null)
|
||||
{
|
||||
throw error;
|
||||
|
@ -163,8 +163,7 @@ namespace XenAdmin.Actions.OvfActions
|
||||
ManifestAndSign(env, appFolder, appFile);
|
||||
}
|
||||
|
||||
PercentComplete = 100;
|
||||
Description = Messages.COMPLETED;
|
||||
Tick(100, Messages.COMPLETED);
|
||||
}
|
||||
|
||||
private void ManifestAndSign(EnvelopeType ovfEnv, string appFolder, string appFile)
|
||||
|
@ -116,8 +116,7 @@ namespace XenAdmin.Actions.OvfActions
|
||||
}
|
||||
}
|
||||
|
||||
PercentComplete = 20;
|
||||
Description = string.Format(Messages.IMPORT_APPLIANCE_PREPARING, m_package.Name);
|
||||
Tick(20, string.Format(Messages.IMPORT_APPLIANCE_PREPARING, m_package.Name));
|
||||
|
||||
//create a copy of the OVF
|
||||
var envelopes = new List<EnvelopeType>();
|
||||
@ -170,8 +169,7 @@ namespace XenAdmin.Actions.OvfActions
|
||||
m_package.CleanUpWorkingDir();
|
||||
}
|
||||
|
||||
PercentComplete = 100;
|
||||
Description = Messages.COMPLETED;
|
||||
Tick(100, Messages.COMPLETED);
|
||||
|
||||
if (_startAutomatically && importedObject is XenRef<VM_appliance> applianceRef)
|
||||
{
|
||||
|
@ -74,8 +74,7 @@ namespace XenAdmin.Actions.OvfActions
|
||||
string systemid = m_vmMappings.Keys.ElementAt(0);
|
||||
var mapping = m_vmMappings.Values.ElementAt(0);
|
||||
|
||||
PercentComplete = 20;
|
||||
Description = Messages.IMPORTING_DISK_IMAGE;
|
||||
Tick(20, Messages.IMPORTING_DISK_IMAGE);
|
||||
|
||||
//create a copy of the ovf envelope
|
||||
EnvelopeType[] envs = OVF.Split(m_ovfEnvelope, "system", new object[] {new[] {systemid}});
|
||||
@ -100,8 +99,7 @@ namespace XenAdmin.Actions.OvfActions
|
||||
{
|
||||
importedObject = Process(curEnv, m_directory);
|
||||
|
||||
PercentComplete = 100;
|
||||
Description = Messages.COMPLETED;
|
||||
Tick(100, Messages.COMPLETED);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
@ -80,8 +80,7 @@ namespace XenAdmin.Actions
|
||||
if (pvsSite == null)
|
||||
{
|
||||
log.InfoFormat("PVS Site '{0}' cannot be configured, because it cannot be found.", siteName);
|
||||
PercentComplete = 100;
|
||||
Description = Messages.COMPLETED;
|
||||
Tick(100, Messages.COMPLETED);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -133,8 +132,8 @@ namespace XenAdmin.Actions
|
||||
PercentComplete += inc;
|
||||
}
|
||||
}
|
||||
PercentComplete = 100;
|
||||
Description = Messages.ACTION_CONFUGURE_PVS_SITE_DONE;
|
||||
|
||||
Tick(100, Messages.ACTION_CONFUGURE_PVS_SITE_DONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,8 +66,7 @@ namespace XenAdmin.Actions
|
||||
|
||||
RelatedTask = PVS_site.async_forget(Session, pvsSite.opaque_ref);
|
||||
PollToCompletion();
|
||||
Description = Messages.ACTION_DELETE_PVS_SITE_DONE;
|
||||
PercentComplete = 100;
|
||||
Tick(100, Messages.ACTION_DELETE_PVS_SITE_DONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,10 +73,9 @@ namespace XenAdmin.Actions
|
||||
HTTP_actions.get_pool_patch_download(
|
||||
bytes =>
|
||||
{
|
||||
PercentComplete = (int)(100 * (double)bytes / patch.size);
|
||||
|
||||
Description = string.Format(Messages.DOWNLOADING_PATCH_FROM, patch.Connection.Name,
|
||||
Util.DiskSizeString(bytes, 1, "F1"), Util.DiskSizeString(patch.size));
|
||||
Tick((int)(100 * (double)bytes / patch.size),
|
||||
string.Format(Messages.DOWNLOADING_PATCH_FROM, patch.Connection.Name,
|
||||
Util.DiskSizeString(bytes, 1, "F1"), Util.DiskSizeString(patch.size)));
|
||||
},
|
||||
() => XenAdminConfigManager.Provider.ForcedExiting || GetCancelling(),
|
||||
XenAdminConfigManager.Provider.GetProxyTimeout(true),
|
||||
|
@ -122,8 +122,7 @@ namespace XenAdmin.Actions
|
||||
foreach (var newVbd in newVbds)
|
||||
Connection.WaitForCache(VBD.create(Session, newVbd));
|
||||
|
||||
PercentComplete = 100;
|
||||
Description = Messages.MOVED;
|
||||
Tick(100, Messages.MOVED);
|
||||
log.DebugFormat("Moved VDI '{0}'", Helpers.GetName(vdi));
|
||||
}
|
||||
|
||||
|
@ -58,8 +58,8 @@ namespace XenAdmin.Actions
|
||||
RelatedTask = XenAPI.VM.async_revert(Session, m_Snapshot.opaque_ref);
|
||||
PollToCompletion();
|
||||
_finished = true;
|
||||
PercentComplete = 90;
|
||||
Description = String.Format(Messages.REVERTING_POWER_STATE, VM.Name());
|
||||
Tick(90, string.Format(Messages.REVERTING_POWER_STATE, VM.Name()));
|
||||
|
||||
try
|
||||
{
|
||||
RevertPowerState(m_Snapshot, VM);
|
||||
@ -69,8 +69,7 @@ namespace XenAdmin.Actions
|
||||
// ignored
|
||||
}
|
||||
|
||||
PercentComplete = 100;
|
||||
Description = String.Format(Messages.VM_REVERTED, m_Snapshot.Name());
|
||||
Tick(100, string.Format(Messages.VM_REVERTED, m_Snapshot.Name()));
|
||||
}
|
||||
|
||||
public override int PercentComplete
|
||||
|
@ -61,8 +61,8 @@ namespace XenAdmin.Actions
|
||||
{
|
||||
VM.set_appliance(Session, selectedVM.opaque_ref, vmApplianceRef.opaque_ref);
|
||||
}
|
||||
Description = string.Format(Messages.CREATED_VM_APPLIANCE, _record.Name());
|
||||
PercentComplete = 100;
|
||||
|
||||
Tick(100, string.Format(Messages.CREATED_VM_APPLIANCE, _record.Name()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,8 +64,9 @@ namespace XenAdmin.Actions
|
||||
{
|
||||
VM.set_snapshot_schedule(Session, selectedVM.opaque_ref, vmssref.opaque_ref);
|
||||
}
|
||||
Description = string.Format(Messages.CREATED_VMSS, _record.Name());
|
||||
PercentComplete = 60;
|
||||
|
||||
Tick(60, string.Format(Messages.CREATED_VMSS, _record.Name()));
|
||||
|
||||
if (_runNow)
|
||||
VMSS.snapshot_now(Session, vmssref);
|
||||
PercentComplete = 100;
|
||||
|
Loading…
Reference in New Issue
Block a user