2013-06-24 13:41:48 +02:00
|
|
|
|
/* Copyright (c) Citrix Systems Inc.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms,
|
|
|
|
|
* with or without modification, are permitted provided
|
|
|
|
|
* that the following conditions are met:
|
|
|
|
|
*
|
|
|
|
|
* * Redistributions of source code must retain the above
|
|
|
|
|
* copyright notice, this list of conditions and the
|
|
|
|
|
* following disclaimer.
|
|
|
|
|
* * Redistributions in binary form must reproduce the above
|
|
|
|
|
* copyright notice, this list of conditions and the
|
|
|
|
|
* following disclaimer in the documentation and/or other
|
|
|
|
|
* materials provided with the distribution.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
|
|
|
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
|
|
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using XenAdmin.Controls;
|
|
|
|
|
using XenAdmin.Controls.DataGridViewEx;
|
|
|
|
|
using XenAdmin.Core;
|
|
|
|
|
using XenAdmin.Network;
|
|
|
|
|
using XenAdmin.Properties;
|
|
|
|
|
using XenAPI;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using XenAdmin.Dialogs;
|
|
|
|
|
using System.Drawing;
|
2015-07-14 11:05:13 +02:00
|
|
|
|
using XenAdmin.Alerts;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace XenAdmin.Wizards.PatchingWizard
|
|
|
|
|
{
|
|
|
|
|
public partial class PatchingWizard_SelectPatchPage : XenTabPage
|
|
|
|
|
{
|
2015-07-14 11:05:13 +02:00
|
|
|
|
private bool CheckForUpdatesInProgress;
|
2015-07-20 15:28:44 +02:00
|
|
|
|
public XenServerPatchAlert SelectedUpdateAlert;
|
2015-07-20 16:27:41 +02:00
|
|
|
|
public XenServerPatchAlert FileFromDiskAlert;
|
2015-07-14 11:05:13 +02:00
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
public PatchingWizard_SelectPatchPage()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2015-07-14 11:05:13 +02:00
|
|
|
|
PopulatePatchesBox();
|
|
|
|
|
dataGridViewPatches.Sort(ColumnDate, ListSortDirection.Descending);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-10 12:25:11 +02:00
|
|
|
|
|
|
|
|
|
private void CheckForUpdates_CheckForUpdatesStarted()
|
|
|
|
|
{
|
|
|
|
|
Program.Invoke(Program.MainWindow, () =>
|
|
|
|
|
{
|
|
|
|
|
RestoreDismUpdatesButton.Enabled = false;
|
|
|
|
|
RefreshListButton.Enabled = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-07-14 11:05:13 +02:00
|
|
|
|
private void CheckForUpdates_CheckForUpdatesCompleted(bool succeeded, string errorMessage)
|
|
|
|
|
{
|
|
|
|
|
Program.Invoke(Program.MainWindow, delegate
|
|
|
|
|
{
|
|
|
|
|
PopulatePatchesBox();
|
|
|
|
|
RefreshListButton.Enabled = true;
|
|
|
|
|
CheckForUpdatesInProgress = false;
|
|
|
|
|
OnPageUpdated();
|
2015-08-10 12:25:11 +02:00
|
|
|
|
RestoreDismUpdatesButton.Enabled = true;
|
2015-07-14 11:05:13 +02:00
|
|
|
|
});
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-20 15:28:44 +02:00
|
|
|
|
public void SelectDownloadAlert(XenServerPatchAlert alert)
|
|
|
|
|
{
|
|
|
|
|
downloadUpdateRadioButton.Checked = true;
|
|
|
|
|
foreach (PatchGridViewRow row in dataGridViewPatches.Rows)
|
|
|
|
|
{
|
|
|
|
|
if(row.UpdateAlert.Equals(alert))
|
|
|
|
|
{
|
|
|
|
|
row.Selected = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
public override string Text
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Messages.PATCHINGWIZARD_SELECTPATCHPAGE_TEXT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string PageTitle
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Messages.PATCHINGWIZARD_SELECTPATCHPAGE_TITLE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string HelpID
|
|
|
|
|
{
|
|
|
|
|
get { return "SelectUpdate"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void PageLoaded(PageLoadedDirection direction)
|
2015-07-14 11:05:13 +02:00
|
|
|
|
{
|
2013-06-24 13:41:48 +02:00
|
|
|
|
base.PageLoaded(direction);
|
2015-07-14 11:05:13 +02:00
|
|
|
|
RefreshListButton.Enabled = true;
|
2015-08-10 12:25:11 +02:00
|
|
|
|
Updates.CheckForUpdatesStarted += CheckForUpdates_CheckForUpdatesStarted;
|
2015-07-14 11:05:13 +02:00
|
|
|
|
Updates.CheckForUpdatesCompleted += CheckForUpdates_CheckForUpdatesCompleted;
|
|
|
|
|
|
|
|
|
|
if (direction == PageLoadedDirection.Forward)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2015-07-14 11:05:13 +02:00
|
|
|
|
PopulatePatchesBox();
|
|
|
|
|
UpdateEnablement();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void PageLeave(PageLoadedDirection direction, ref bool cancel)
|
|
|
|
|
{
|
|
|
|
|
if (direction == PageLoadedDirection.Forward)
|
|
|
|
|
{
|
2015-07-20 16:27:41 +02:00
|
|
|
|
var fileName = fileNameTextBox.Text;
|
2015-07-09 17:32:08 +02:00
|
|
|
|
if (downloadUpdateRadioButton.Checked)
|
|
|
|
|
{
|
2015-07-14 11:05:13 +02:00
|
|
|
|
if (dataGridViewPatches.SelectedRows.Count > 0 && ((PatchGridViewRow)(dataGridViewPatches.SelectedRows[0])).UpdateAlert.WebPageLabel.EndsWith(".xsoem"))
|
|
|
|
|
{
|
2015-07-09 17:32:08 +02:00
|
|
|
|
SelectedUpdateType = UpdateType.NewOem;
|
2015-07-14 11:05:13 +02:00
|
|
|
|
}
|
2015-07-09 17:32:08 +02:00
|
|
|
|
else
|
2015-07-14 11:05:13 +02:00
|
|
|
|
{
|
|
|
|
|
SelectedUpdateType = UpdateType.NewRetail;
|
|
|
|
|
}
|
2015-07-09 17:32:08 +02:00
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
else
|
2015-07-20 16:27:41 +02:00
|
|
|
|
{
|
2015-07-09 17:32:08 +02:00
|
|
|
|
if (isValidFile())
|
|
|
|
|
{
|
|
|
|
|
if (fileName.EndsWith(".xsoem"))
|
|
|
|
|
SelectedUpdateType = UpdateType.NewOem;
|
|
|
|
|
else if (fileName.EndsWith(".xsupdate"))
|
|
|
|
|
SelectedUpdateType = UpdateType.NewRetail;
|
|
|
|
|
else if (fileName.EndsWith(".iso"))
|
|
|
|
|
SelectedUpdateType = UpdateType.NewSuppPack;
|
|
|
|
|
else
|
|
|
|
|
SelectedUpdateType = UpdateType.Existing;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-14 11:05:13 +02:00
|
|
|
|
SelectedUpdateAlert = downloadUpdateRadioButton.Checked
|
2015-07-20 15:28:44 +02:00
|
|
|
|
? (XenServerPatchAlert)((PatchGridViewRow)dataGridViewPatches.SelectedRows[0]).UpdateAlert
|
2013-06-24 13:41:48 +02:00
|
|
|
|
: null;
|
2015-07-20 16:27:41 +02:00
|
|
|
|
FileFromDiskAlert = selectFromDiskRadioButton.Checked
|
|
|
|
|
? GetAlertFromFileName(fileName)
|
|
|
|
|
: null;
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
if (SelectedExistingPatch != null && !SelectedExistingPatch.Connection.IsConnected)
|
|
|
|
|
{
|
|
|
|
|
cancel = true;
|
|
|
|
|
PageLeaveCancelled(string.Format(Messages.UPDATES_WIZARD_CANNOT_DOWNLOAD_PATCH,
|
|
|
|
|
SelectedExistingPatch.Connection.Name));
|
|
|
|
|
}
|
|
|
|
|
else if (!string.IsNullOrEmpty(SelectedNewPatch) && !File.Exists(SelectedNewPatch))
|
|
|
|
|
{
|
|
|
|
|
cancel = true;
|
|
|
|
|
PageLeaveCancelled(string.Format(Messages.UPDATES_WIZARD_FILE_NOT_FOUND, SelectedNewPatch));
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-14 11:05:13 +02:00
|
|
|
|
Updates.CheckForUpdatesCompleted -= CheckForUpdates_CheckForUpdatesCompleted;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
base.PageLeave(direction, ref cancel);
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-20 16:27:41 +02:00
|
|
|
|
private XenServerPatchAlert GetAlertFromFileName(string fileName)
|
|
|
|
|
{
|
|
|
|
|
foreach (PatchGridViewRow row in dataGridViewPatches.Rows)
|
|
|
|
|
{
|
|
|
|
|
if (row.UpdateAlert.Name == Path.GetFileNameWithoutExtension(fileName))
|
|
|
|
|
{
|
|
|
|
|
return (XenServerPatchAlert)row.UpdateAlert;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
private void PageLeaveCancelled(string message)
|
|
|
|
|
{
|
|
|
|
|
new ThreeButtonDialog(
|
|
|
|
|
new ThreeButtonDialog.Details(SystemIcons.Warning, message, Messages.UPDATES_WIZARD)).ShowDialog(this);
|
|
|
|
|
|
|
|
|
|
((PatchGridViewRow)dataGridViewPatches.SelectedRows[0]).UpdateDetails();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PopulatePatchesBox()
|
|
|
|
|
{
|
|
|
|
|
dataGridViewPatches.Rows.Clear();
|
2015-07-14 11:05:13 +02:00
|
|
|
|
var updates = new List<Alert>(Updates.UpdateAlerts);
|
|
|
|
|
if (dataGridViewPatches.SortedColumn != null)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2015-07-14 11:05:13 +02:00
|
|
|
|
if (dataGridViewPatches.SortedColumn.Index == ColumnUpdate.Index)
|
|
|
|
|
updates.Sort(Alert.CompareOnTitle);
|
|
|
|
|
else if (dataGridViewPatches.SortedColumn.Index == ColumnDate.Index)
|
|
|
|
|
updates.Sort(Alert.CompareOnDate);
|
|
|
|
|
else if (dataGridViewPatches.SortedColumn.Index == ColumnDescription.Index)
|
|
|
|
|
updates.Sort(Alert.CompareOnAppliesTo);
|
|
|
|
|
|
|
|
|
|
if (dataGridViewPatches.SortOrder == SortOrder.Descending)
|
|
|
|
|
updates.Reverse();
|
|
|
|
|
}
|
|
|
|
|
foreach (Alert alert in updates)
|
2015-07-20 15:28:44 +02:00
|
|
|
|
{
|
|
|
|
|
if (alert is XenServerPatchAlert)
|
2015-07-14 11:05:13 +02:00
|
|
|
|
{
|
2015-07-20 15:28:44 +02:00
|
|
|
|
PatchGridViewRow row = new PatchGridViewRow(alert);
|
|
|
|
|
if (!dataGridViewPatches.Rows.Contains(row))
|
|
|
|
|
{
|
|
|
|
|
dataGridViewPatches.Rows.Add(row);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
2015-07-14 11:05:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void PageCancelled()
|
|
|
|
|
{
|
|
|
|
|
Updates.CheckForUpdatesCompleted -= CheckForUpdates_CheckForUpdatesCompleted;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool EnableNext()
|
|
|
|
|
{
|
2015-07-14 11:05:13 +02:00
|
|
|
|
if (CheckForUpdatesInProgress)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-07-09 17:32:08 +02:00
|
|
|
|
if (downloadUpdateRadioButton.Checked)
|
2015-07-20 15:28:44 +02:00
|
|
|
|
{
|
2015-07-09 17:32:08 +02:00
|
|
|
|
if (dataGridViewPatches.SelectedRows.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
DataGridViewExRow row = (DataGridViewExRow)dataGridViewPatches.SelectedRows[0];
|
|
|
|
|
if (row.Enabled)
|
2015-07-20 15:28:44 +02:00
|
|
|
|
{
|
2015-07-09 17:32:08 +02:00
|
|
|
|
return true;
|
2015-07-20 15:28:44 +02:00
|
|
|
|
}
|
2015-07-09 17:32:08 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (selectFromDiskRadioButton.Checked)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2015-07-09 17:32:08 +02:00
|
|
|
|
if (isValidFile())
|
|
|
|
|
{
|
2013-06-24 13:41:48 +02:00
|
|
|
|
return true;
|
2015-07-09 17:32:08 +02:00
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-09 17:32:08 +02:00
|
|
|
|
private bool isValidFile()
|
|
|
|
|
{
|
|
|
|
|
var fileName = fileNameTextBox.Text;
|
|
|
|
|
return !string.IsNullOrEmpty(fileName) && File.Exists(fileName) && (fileName.EndsWith(".xsoem") || fileName.EndsWith(".xsupdate") || fileName.EndsWith(".iso"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
private void UpdateEnablement()
|
|
|
|
|
{
|
2015-07-14 11:05:13 +02:00
|
|
|
|
dataGridViewPatches.HideSelection = !downloadUpdateRadioButton.Checked;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
OnPageUpdated();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BrowseButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Showing this dialog has the (undocumented) side effect of changing the working directory
|
|
|
|
|
// to that of the file selected. This means a handle to the directory persists, making
|
|
|
|
|
// it undeletable until the program exits, or the working dir moves on. So, save and
|
|
|
|
|
// restore the working dir...
|
2015-07-09 17:32:08 +02:00
|
|
|
|
selectFromDiskRadioButton.Checked = true;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
String oldDir = "";
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
oldDir = Directory.GetCurrentDirectory();
|
|
|
|
|
OpenFileDialog dlg = new OpenFileDialog();
|
|
|
|
|
dlg.Multiselect = false;
|
|
|
|
|
dlg.ShowReadOnly = false;
|
|
|
|
|
dlg.Filter = Messages.PATCHINGWIZARD_SELECTPATCHPAGE_UPDATESEXT;
|
|
|
|
|
dlg.FilterIndex = 0;
|
|
|
|
|
dlg.CheckFileExists = true;
|
|
|
|
|
dlg.ShowHelp = false;
|
|
|
|
|
dlg.Title = Messages.PATCHINGWIZARD_SELECTPATCHPAGE_CHOOSE;
|
|
|
|
|
|
|
|
|
|
if (dlg.ShowDialog(this) == DialogResult.OK && dlg.CheckFileExists)
|
|
|
|
|
{
|
2015-07-14 11:05:13 +02:00
|
|
|
|
AddFile(dlg.FileName);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
OnPageUpdated();
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
Directory.SetCurrentDirectory(oldDir);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddFile(string fileName)
|
|
|
|
|
{
|
2015-01-20 15:22:29 +01:00
|
|
|
|
if (fileName.EndsWith(".xsoem") || fileName.EndsWith(".xsupdate") || fileName.EndsWith(".iso"))
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2015-07-14 11:05:13 +02:00
|
|
|
|
fileNameTextBox.Text = fileName;
|
|
|
|
|
selectFromDiskRadioButton.Checked = true;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, Messages.UPDATES_WIZARD_NOTVALID_EXTENSION, Messages.UPDATES)).ShowDialog(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UpdateType SelectedUpdateType { get; set; }
|
|
|
|
|
|
|
|
|
|
public Pool_patch SelectedExistingPatch { get; set; }
|
|
|
|
|
|
|
|
|
|
public string SelectedNewPatch
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2015-07-09 17:32:08 +02:00
|
|
|
|
if (downloadUpdateRadioButton.Checked)
|
|
|
|
|
{
|
|
|
|
|
return SelectedUpdateType == UpdateType.NewRetail || SelectedUpdateType == UpdateType.NewOem || SelectedUpdateType == UpdateType.NewSuppPack
|
|
|
|
|
? ((PatchGridViewRow)dataGridViewPatches.SelectedRows[0]).PathPatch
|
|
|
|
|
: null;
|
|
|
|
|
}
|
|
|
|
|
else if (selectFromDiskRadioButton.Checked)
|
|
|
|
|
{
|
|
|
|
|
return SelectedUpdateType == UpdateType.NewRetail || SelectedUpdateType == UpdateType.NewOem || SelectedUpdateType == UpdateType.NewSuppPack
|
|
|
|
|
? fileNameTextBox.Text
|
|
|
|
|
: null;
|
|
|
|
|
}
|
|
|
|
|
else return null;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-14 11:05:13 +02:00
|
|
|
|
private void dataGridViewPatches_SelectionChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UpdateEnablement();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fileNameTextBox_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
selectFromDiskRadioButton.Checked = true;
|
|
|
|
|
UpdateEnablement();
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
private void dataGridViewPatches_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button != MouseButtons.Left)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (e.RowIndex < 0)
|
|
|
|
|
// The click is on a column header
|
|
|
|
|
return;
|
|
|
|
|
PatchGridViewRow row = (PatchGridViewRow)dataGridViewPatches.Rows[e.RowIndex];
|
|
|
|
|
row.toggleExpandedState();
|
|
|
|
|
UpdateEnablement();
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-14 11:05:13 +02:00
|
|
|
|
private void RefreshListButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CheckForUpdatesInProgress = true;
|
|
|
|
|
Updates.CheckForUpdates(true);
|
|
|
|
|
PopulatePatchesBox();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void selectFromDiskRadioButton_CheckedChanged(object sender, EventArgs e)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
UpdateEnablement();
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-14 11:05:13 +02:00
|
|
|
|
private void dataGridViewPatches_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Alert alert1 = ((PatchGridViewRow)dataGridViewPatches.Rows[e.RowIndex1]).UpdateAlert;
|
|
|
|
|
Alert alert2 = ((PatchGridViewRow)dataGridViewPatches.Rows[e.RowIndex2]).UpdateAlert;
|
|
|
|
|
|
|
|
|
|
if (e.Column.Index == ColumnDate.Index)
|
|
|
|
|
{
|
|
|
|
|
int sortResult = DateTime.Compare(alert1.Timestamp, alert2.Timestamp);
|
|
|
|
|
e.SortResult = (dataGridViewPatches.SortOrder == SortOrder.Descending) ? sortResult *= -1 : sortResult;
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dataGridViewPatches_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (dataGridViewPatches.Columns[e.ColumnIndex].SortMode == DataGridViewColumnSortMode.Automatic)
|
|
|
|
|
PopulatePatchesBox();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fileNameTextBox_Enter(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
selectFromDiskRadioButton.Checked = true;
|
|
|
|
|
UpdateEnablement();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dataGridViewPatches_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
|
|
|
|
{ // The click is on a column header
|
|
|
|
|
if (e.RowIndex == -1)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
PatchGridViewRow row = dataGridViewPatches.Rows[e.RowIndex] as PatchGridViewRow;
|
|
|
|
|
if (row != null && e.ColumnIndex == 3)
|
|
|
|
|
{
|
|
|
|
|
row.UpdateAlert.FixLinkAction();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dataGridViewPatches_Enter(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
downloadUpdateRadioButton.Checked = true;
|
|
|
|
|
UpdateEnablement();
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
private class PatchGridViewRow : DataGridViewExRow, IEquatable<PatchGridViewRow>
|
|
|
|
|
{
|
2015-07-14 11:05:13 +02:00
|
|
|
|
private readonly Alert _alert;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
private bool expanded = false;
|
|
|
|
|
|
|
|
|
|
private bool _isFile = false;
|
|
|
|
|
private string _patchPath;
|
|
|
|
|
|
|
|
|
|
private DataGridViewImageCell _imageCell;
|
|
|
|
|
private DataGridViewTextBoxCell _nameCell;
|
|
|
|
|
private DataGridViewTextBoxCell _descriptionCell;
|
2015-07-14 11:05:13 +02:00
|
|
|
|
private DataGridViewTextBoxCell _dateCell;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
private DataGridViewTextBoxCell _statusCell;
|
2015-07-09 17:59:14 +02:00
|
|
|
|
private DataGridViewLinkCell _webPageCell;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2015-07-14 11:05:13 +02:00
|
|
|
|
public PatchGridViewRow(Alert alert)
|
|
|
|
|
{
|
|
|
|
|
_alert = alert;
|
|
|
|
|
_nameCell = new DataGridViewTextBoxCell();
|
|
|
|
|
_descriptionCell = new DataGridViewTextBoxCell();
|
|
|
|
|
_dateCell = new DataGridViewTextBoxCell();
|
|
|
|
|
_webPageCell = new DataGridViewLinkCell();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2015-07-14 11:05:13 +02:00
|
|
|
|
Cells.Add(_nameCell);
|
|
|
|
|
Cells.Add(_descriptionCell);
|
|
|
|
|
Cells.Add(_dateCell);
|
|
|
|
|
Cells.Add(_webPageCell);
|
|
|
|
|
|
|
|
|
|
_nameCell.Value = String.Format(alert.Name);
|
|
|
|
|
_descriptionCell.Value = String.Format(alert.Description);
|
|
|
|
|
_dateCell.Value = HelpersGUI.DateTimeToString(alert.Timestamp.ToLocalTime(), Messages.DATEFORMAT_DMY, true);
|
|
|
|
|
_webPageCell.Value = Messages.PATCHING_WIZARD_WEBPAGE_CELL;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PatchGridViewRow(string patchPath)
|
|
|
|
|
{
|
|
|
|
|
_isFile = true;
|
|
|
|
|
_patchPath = patchPath;
|
|
|
|
|
SetupCells();
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-14 11:05:13 +02:00
|
|
|
|
public Alert UpdateAlert
|
|
|
|
|
{
|
|
|
|
|
get { return _alert; }
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string PathPatch
|
|
|
|
|
{
|
|
|
|
|
get { return _patchPath; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetupCells()
|
|
|
|
|
{
|
|
|
|
|
_imageCell = new DataGridViewExImageCell();
|
|
|
|
|
_nameCell = new DataGridViewTextBoxCell();
|
|
|
|
|
_descriptionCell = new DataGridViewTextBoxCell();
|
|
|
|
|
_statusCell = new DataGridViewTextBoxCell();
|
2015-07-09 17:59:14 +02:00
|
|
|
|
_webPageCell = new DataGridViewLinkCell();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
Cells.Add(_imageCell);
|
|
|
|
|
Cells.Add(_nameCell);
|
|
|
|
|
Cells.Add(_descriptionCell);
|
|
|
|
|
Cells.Add(_statusCell);
|
2015-07-09 17:59:14 +02:00
|
|
|
|
Cells.Add(_webPageCell);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
this.UpdateDetails();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateFileDetails(string description, string status)
|
|
|
|
|
{
|
|
|
|
|
_descriptionCell.Value = description;
|
|
|
|
|
_statusCell.Value = status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateDetails()
|
|
|
|
|
{
|
|
|
|
|
_imageCell.Value = expanded ? Resources.expanded_triangle : Resources.contracted_triangle;
|
2015-07-09 17:59:14 +02:00
|
|
|
|
_webPageCell.Value = Messages.PATCHING_WIZARD_WEBPAGE_CELL;
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
if (_isFile)
|
|
|
|
|
{
|
|
|
|
|
_nameCell.Value = System.IO.Path.GetFileName(_patchPath);
|
|
|
|
|
FileInfo fileInfo = new FileInfo(_patchPath);
|
|
|
|
|
|
|
|
|
|
string description = expanded
|
|
|
|
|
? fileInfo.Exists
|
|
|
|
|
? String.Format(Messages.PATCH_EXPANDED_DESCRIPTION
|
|
|
|
|
, _patchPath, fileInfo.CreationTime,
|
2015-01-20 15:22:29 +01:00
|
|
|
|
fileInfo.LastWriteTime, Util.DiskSizeString(fileInfo.Length))
|
2013-06-24 13:41:48 +02:00
|
|
|
|
: String.Format(Messages.PATCH_NOT_FOUND_EXPANDED_DESCRIPTION,
|
|
|
|
|
_patchPath)
|
|
|
|
|
: _patchPath;
|
|
|
|
|
|
|
|
|
|
UpdateFileDetails(description, fileInfo.Exists ? Messages.NOT_UPLOADED : Messages.PATCH_NOT_FOUND);
|
2015-07-14 11:05:13 +02:00
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void toggleExpandedState()
|
|
|
|
|
{
|
|
|
|
|
expanded = !expanded;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool Equals(PatchGridViewRow other)
|
|
|
|
|
{
|
2015-07-14 11:05:13 +02:00
|
|
|
|
if (other.UpdateAlert != null && this.UpdateAlert != null && this.UpdateAlert.uuid == other.UpdateAlert.uuid)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
return true;
|
|
|
|
|
if (other.PathPatch != null && this.PathPatch != null && this.PathPatch == other.PathPatch)
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
{
|
|
|
|
|
return base.GetHashCode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
{
|
|
|
|
|
if (obj is PatchGridViewRow)
|
|
|
|
|
return this.Equals((PatchGridViewRow)obj);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-07-23 15:04:43 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RestoreDismUpdatesButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Updates.RestoreDismissedUpdates();
|
2015-07-14 11:05:13 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2015-01-20 15:22:29 +01:00
|
|
|
|
public enum UpdateType { NewRetail, NewOem, Existing, NewSuppPack}
|
2015-07-14 11:05:13 +02:00
|
|
|
|
}
|