Following code review, adds a few adjustments to the code.

This commit is contained in:
Carmen Agimof 2015-07-21 11:03:34 +01:00
parent b919565a5a
commit 2720d1bc23
2 changed files with 17 additions and 19 deletions

View File

@ -177,19 +177,19 @@ namespace XenAdmin.Wizards.PatchingWizard
{
if (selectedHosts != null && !selectedHosts.Contains(host))
{
string alertName = null;
string alertUuid = null;
if (SelectedUpdateAlert != null)
{
alertName = SelectedUpdateAlert.Name;
alertUuid = SelectedUpdateAlert.uuid;
}
else if (FileFromDiskAlert != null)
{
alertName = FileFromDiskAlert.Name;
alertUuid = FileFromDiskAlert.uuid;
}
if (alertName != null)
if (alertUuid != null)
{
if (isPatchApplied(alertName, host))
if (isPatchApplied(alertUuid, host))
{
row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_PATCH_ALREADY_APPLIED;
}
@ -202,12 +202,12 @@ namespace XenAdmin.Wizards.PatchingWizard
}
}
private bool isPatchApplied(string name, Host host)
private bool isPatchApplied(string uuid, Host host)
{
List<Pool_patch> hostPatches = host.AppliedPatches();
foreach (Pool_patch patch in hostPatches)
{
if (patch.Name.Equals(name))
if (patch.uuid.Equals(uuid))
{
return true;
}

View File

@ -45,7 +45,7 @@ namespace XenAdmin.Wizards.PatchingWizard
get { return _patch; }
}
public Dictionary<Alert, string> AllDownloadedPatches = new Dictionary<Alert, string>();
public Dictionary<string, string> AllDownloadedPatches = new Dictionary<string, string>();
public readonly List<VDI> AllCreatedSuppPackVdis = new List<VDI>();
public Dictionary<Host, VDI> SuppPackVdis = new Dictionary<Host, VDI>();
@ -65,16 +65,18 @@ namespace XenAdmin.Wizards.PatchingWizard
if (direction == PageLoadedDirection.Forward)
{
flickerFreeListBox1.Items.Clear();
if (SelectedUpdateAlert != null && String.IsNullOrEmpty(SelectedNewPatch)&&
(!AllDownloadedPatches.Any(kvp => kvp.Key.uuid == SelectedUpdateAlert.uuid)
|| String.IsNullOrEmpty(AllDownloadedPatches[SelectedUpdateAlert])
|| !File.Exists(AllDownloadedPatches[SelectedUpdateAlert])))
var selectedPatch = SelectedUpdateAlert != null ? ((XenServerPatchAlert)SelectedUpdateAlert).Patch : null;
if (selectedPatch != null && String.IsNullOrEmpty(SelectedNewPatch) &&
(!AllDownloadedPatches.Any(kvp => kvp.Key == selectedPatch.Uuid)
|| String.IsNullOrEmpty(AllDownloadedPatches[selectedPatch.Uuid])
|| !File.Exists(AllDownloadedPatches[selectedPatch.Uuid])))
{
DownloadFile();
}
else
{
if (selectedPatch != null && AllDownloadedPatches.ContainsKey(selectedPatch.Uuid))
SelectedNewPatch = AllDownloadedPatches[selectedPatch.Uuid];
PrepareUploadActions();
TryUploading();
}
@ -154,11 +156,7 @@ namespace XenAdmin.Wizards.PatchingWizard
switch (SelectedUpdateType)
{
case UpdateType.NewRetail:
if (_patch == null)
{
action = new UploadPatchAction(selectedServer.Connection, SelectedNewPatch, true);
}
else if (!PatchExistsOnPool(_patch, selectedServer))
if (_patch == null || !PatchExistsOnPool(_patch, selectedServer))
{
action = new UploadPatchAction(selectedServer.Connection, SelectedNewPatch, true);
}
@ -379,7 +377,7 @@ namespace XenAdmin.Wizards.PatchingWizard
if (action is DownloadAndUnzipXenServerPatchAction)
{
SelectedNewPatch = ((DownloadAndUnzipXenServerPatchAction)action).PatchPath;
AllDownloadedPatches.Add(SelectedUpdateAlert, SelectedNewPatch);
AllDownloadedPatches.Add((SelectedUpdateAlert as XenServerPatchAlert).Patch.Uuid, SelectedNewPatch);
_patch = null;
PrepareUploadActions();
TryUploading();