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);
|
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
|
public string Description
|
||||||
{
|
{
|
||||||
get { return _description; }
|
get => _description;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_description != value)
|
if (_description != value)
|
||||||
@ -277,7 +281,7 @@ namespace XenAdmin.Actions
|
|||||||
|
|
||||||
public bool IsCompleted
|
public bool IsCompleted
|
||||||
{
|
{
|
||||||
get { return _isCompleted; }
|
get => _isCompleted;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_isCompleted != value)
|
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
|
public virtual int PercentComplete
|
||||||
{
|
{
|
||||||
get { return _percentComplete; }
|
get => _percentComplete;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_percentComplete != value)
|
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;
|
var percent = value;
|
||||||
if (percent < 0)
|
if (percent < 0)
|
||||||
@ -318,6 +326,8 @@ namespace XenAdmin.Actions
|
|||||||
{
|
{
|
||||||
_description = description;
|
_description = description;
|
||||||
|
|
||||||
|
System.Diagnostics.Debug.Assert(0 <= percent && percent <= 100, $"Percent is {percent}");
|
||||||
|
|
||||||
if (percent < 0)
|
if (percent < 0)
|
||||||
percent = 0;
|
percent = 0;
|
||||||
else if (percent > 100)
|
else if (percent > 100)
|
||||||
|
@ -77,8 +77,8 @@ namespace XenAdmin.Actions.DR
|
|||||||
DestroyVM(Session, vm);
|
DestroyVM(Session, vm);
|
||||||
PercentComplete += increment;
|
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;
|
PercentComplete += increment;
|
||||||
}
|
}
|
||||||
Description = Messages.DELETED_VM_APPLIANCES;
|
|
||||||
PercentComplete = 100;
|
Tick(100, Messages.DELETED_VM_APPLIANCES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,8 +130,8 @@ namespace XenAdmin.Actions.DR
|
|||||||
// ignored
|
// 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);
|
MetadataSession = Session.get_record(Session, MetadataSessionRef);
|
||||||
}
|
}
|
||||||
PercentComplete = 100;
|
|
||||||
|
Tick(100, Messages.ACTION_VDI_OPEN_DATABASE_DONE);
|
||||||
Description = Messages.ACTION_VDI_OPEN_DATABASE_DONE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,8 +101,7 @@ namespace XenAdmin.Actions
|
|||||||
|
|
||||||
PollToCompletion();
|
PollToCompletion();
|
||||||
Status = ReportStatus.succeeded;
|
Status = ReportStatus.succeeded;
|
||||||
Description = Messages.COMPLETED;
|
Tick(100, Messages.COMPLETED);
|
||||||
PercentComplete = 100;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -64,8 +64,8 @@ namespace XenAdmin.Actions
|
|||||||
: PGPU.async_disable_dom0_access(Session, pGpu.opaque_ref);
|
: PGPU.async_disable_dom0_access(Session, pGpu.opaque_ref);
|
||||||
PollToCompletion(50, 100);
|
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);
|
RunSubActions(exceptions);
|
||||||
|
|
||||||
PercentComplete = 100;
|
Tick(100, endDescription);
|
||||||
Description = endDescription;
|
|
||||||
if (exceptions.Count > 1)
|
if (exceptions.Count > 1)
|
||||||
{
|
{
|
||||||
foreach (Exception e in exceptions)
|
foreach (Exception e in exceptions)
|
||||||
|
@ -50,8 +50,7 @@ namespace XenAdmin.Actions
|
|||||||
{
|
{
|
||||||
PercentComplete = 40;
|
PercentComplete = 40;
|
||||||
PIF.scan(Session, Host.opaque_ref);
|
PIF.scan(Session, Host.opaque_ref);
|
||||||
Description = Messages.COMPLETED;
|
Tick(100, Messages.COMPLETED);
|
||||||
PercentComplete = 100;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,8 +143,8 @@ namespace XenAdmin.Actions
|
|||||||
PercentComplete += percentStep;
|
PercentComplete += percentStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
PercentComplete = 100;
|
Tick(100, error != null ? Messages.COMPLETED_WITH_ERRORS : Messages.COMPLETED);
|
||||||
Description = error != null ? Messages.COMPLETED_WITH_ERRORS : Messages.COMPLETED;
|
|
||||||
if (error != null)
|
if (error != null)
|
||||||
{
|
{
|
||||||
throw error;
|
throw error;
|
||||||
|
@ -163,8 +163,7 @@ namespace XenAdmin.Actions.OvfActions
|
|||||||
ManifestAndSign(env, appFolder, appFile);
|
ManifestAndSign(env, appFolder, appFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
PercentComplete = 100;
|
Tick(100, Messages.COMPLETED);
|
||||||
Description = Messages.COMPLETED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ManifestAndSign(EnvelopeType ovfEnv, string appFolder, string appFile)
|
private void ManifestAndSign(EnvelopeType ovfEnv, string appFolder, string appFile)
|
||||||
|
@ -116,8 +116,7 @@ namespace XenAdmin.Actions.OvfActions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PercentComplete = 20;
|
Tick(20, string.Format(Messages.IMPORT_APPLIANCE_PREPARING, m_package.Name));
|
||||||
Description = string.Format(Messages.IMPORT_APPLIANCE_PREPARING, m_package.Name);
|
|
||||||
|
|
||||||
//create a copy of the OVF
|
//create a copy of the OVF
|
||||||
var envelopes = new List<EnvelopeType>();
|
var envelopes = new List<EnvelopeType>();
|
||||||
@ -170,8 +169,7 @@ namespace XenAdmin.Actions.OvfActions
|
|||||||
m_package.CleanUpWorkingDir();
|
m_package.CleanUpWorkingDir();
|
||||||
}
|
}
|
||||||
|
|
||||||
PercentComplete = 100;
|
Tick(100, Messages.COMPLETED);
|
||||||
Description = Messages.COMPLETED;
|
|
||||||
|
|
||||||
if (_startAutomatically && importedObject is XenRef<VM_appliance> applianceRef)
|
if (_startAutomatically && importedObject is XenRef<VM_appliance> applianceRef)
|
||||||
{
|
{
|
||||||
|
@ -74,8 +74,7 @@ namespace XenAdmin.Actions.OvfActions
|
|||||||
string systemid = m_vmMappings.Keys.ElementAt(0);
|
string systemid = m_vmMappings.Keys.ElementAt(0);
|
||||||
var mapping = m_vmMappings.Values.ElementAt(0);
|
var mapping = m_vmMappings.Values.ElementAt(0);
|
||||||
|
|
||||||
PercentComplete = 20;
|
Tick(20, Messages.IMPORTING_DISK_IMAGE);
|
||||||
Description = Messages.IMPORTING_DISK_IMAGE;
|
|
||||||
|
|
||||||
//create a copy of the ovf envelope
|
//create a copy of the ovf envelope
|
||||||
EnvelopeType[] envs = OVF.Split(m_ovfEnvelope, "system", new object[] {new[] {systemid}});
|
EnvelopeType[] envs = OVF.Split(m_ovfEnvelope, "system", new object[] {new[] {systemid}});
|
||||||
@ -100,8 +99,7 @@ namespace XenAdmin.Actions.OvfActions
|
|||||||
{
|
{
|
||||||
importedObject = Process(curEnv, m_directory);
|
importedObject = Process(curEnv, m_directory);
|
||||||
|
|
||||||
PercentComplete = 100;
|
Tick(100, Messages.COMPLETED);
|
||||||
Description = Messages.COMPLETED;
|
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
|
@ -80,8 +80,7 @@ namespace XenAdmin.Actions
|
|||||||
if (pvsSite == null)
|
if (pvsSite == null)
|
||||||
{
|
{
|
||||||
log.InfoFormat("PVS Site '{0}' cannot be configured, because it cannot be found.", siteName);
|
log.InfoFormat("PVS Site '{0}' cannot be configured, because it cannot be found.", siteName);
|
||||||
PercentComplete = 100;
|
Tick(100, Messages.COMPLETED);
|
||||||
Description = Messages.COMPLETED;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,8 +132,8 @@ namespace XenAdmin.Actions
|
|||||||
PercentComplete += inc;
|
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);
|
RelatedTask = PVS_site.async_forget(Session, pvsSite.opaque_ref);
|
||||||
PollToCompletion();
|
PollToCompletion();
|
||||||
Description = Messages.ACTION_DELETE_PVS_SITE_DONE;
|
Tick(100, Messages.ACTION_DELETE_PVS_SITE_DONE);
|
||||||
PercentComplete = 100;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,10 +73,9 @@ namespace XenAdmin.Actions
|
|||||||
HTTP_actions.get_pool_patch_download(
|
HTTP_actions.get_pool_patch_download(
|
||||||
bytes =>
|
bytes =>
|
||||||
{
|
{
|
||||||
PercentComplete = (int)(100 * (double)bytes / patch.size);
|
Tick((int)(100 * (double)bytes / patch.size),
|
||||||
|
string.Format(Messages.DOWNLOADING_PATCH_FROM, patch.Connection.Name,
|
||||||
Description = string.Format(Messages.DOWNLOADING_PATCH_FROM, patch.Connection.Name,
|
Util.DiskSizeString(bytes, 1, "F1"), Util.DiskSizeString(patch.size)));
|
||||||
Util.DiskSizeString(bytes, 1, "F1"), Util.DiskSizeString(patch.size));
|
|
||||||
},
|
},
|
||||||
() => XenAdminConfigManager.Provider.ForcedExiting || GetCancelling(),
|
() => XenAdminConfigManager.Provider.ForcedExiting || GetCancelling(),
|
||||||
XenAdminConfigManager.Provider.GetProxyTimeout(true),
|
XenAdminConfigManager.Provider.GetProxyTimeout(true),
|
||||||
|
@ -122,8 +122,7 @@ namespace XenAdmin.Actions
|
|||||||
foreach (var newVbd in newVbds)
|
foreach (var newVbd in newVbds)
|
||||||
Connection.WaitForCache(VBD.create(Session, newVbd));
|
Connection.WaitForCache(VBD.create(Session, newVbd));
|
||||||
|
|
||||||
PercentComplete = 100;
|
Tick(100, Messages.MOVED);
|
||||||
Description = Messages.MOVED;
|
|
||||||
log.DebugFormat("Moved VDI '{0}'", Helpers.GetName(vdi));
|
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);
|
RelatedTask = XenAPI.VM.async_revert(Session, m_Snapshot.opaque_ref);
|
||||||
PollToCompletion();
|
PollToCompletion();
|
||||||
_finished = true;
|
_finished = true;
|
||||||
PercentComplete = 90;
|
Tick(90, string.Format(Messages.REVERTING_POWER_STATE, VM.Name()));
|
||||||
Description = String.Format(Messages.REVERTING_POWER_STATE, VM.Name());
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
RevertPowerState(m_Snapshot, VM);
|
RevertPowerState(m_Snapshot, VM);
|
||||||
@ -69,8 +69,7 @@ namespace XenAdmin.Actions
|
|||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
|
|
||||||
PercentComplete = 100;
|
Tick(100, string.Format(Messages.VM_REVERTED, m_Snapshot.Name()));
|
||||||
Description = String.Format(Messages.VM_REVERTED, m_Snapshot.Name());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int PercentComplete
|
public override int PercentComplete
|
||||||
|
@ -61,8 +61,8 @@ namespace XenAdmin.Actions
|
|||||||
{
|
{
|
||||||
VM.set_appliance(Session, selectedVM.opaque_ref, vmApplianceRef.opaque_ref);
|
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);
|
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)
|
if (_runNow)
|
||||||
VMSS.snapshot_now(Session, vmssref);
|
VMSS.snapshot_now(Session, vmssref);
|
||||||
PercentComplete = 100;
|
PercentComplete = 100;
|
||||||
|
Loading…
Reference in New Issue
Block a user