Adds updates check started/completed event handlers

Signed-off-by: Christophe25 <christopher.lancaste1@citrix.com>
This commit is contained in:
Christophe25 2022-01-07 15:49:18 +00:00 committed by Konstantina Chremmou
parent 0a0533a59f
commit c1c8c3d1c3
4 changed files with 205 additions and 147 deletions

View File

@ -180,6 +180,7 @@ namespace XenAdmin
this.toolStripSeparator23 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItemCertificate = new XenAdmin.Commands.CommandToolStripMenuItem();
this.toolStripMenuItemInstallCertificate = new XenAdmin.Commands.CommandToolStripMenuItem();
this.toolStripMenuItemResetCertificate = new XenAdmin.Commands.CommandToolStripMenuItem();
this.maintenanceModeToolStripMenuItem1 = new XenAdmin.Commands.CommandToolStripMenuItem();
this.controlDomainMemoryToolStripMenuItem = new XenAdmin.Commands.CommandToolStripMenuItem();
this.RemoveCrashdumpsToolStripMenuItem = new XenAdmin.Commands.CommandToolStripMenuItem();
@ -274,6 +275,7 @@ namespace XenAdmin
this.pluginItemsPlaceHolderToolStripMenuItem8 = new System.Windows.Forms.ToolStripMenuItem();
this.aboutXenSourceAdminToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.MainMenuBar = new XenAdmin.Controls.MenuStripEx();
this.updateClientToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.securityGroupsToolStripMenuItem = new XenAdmin.Commands.CommandToolStripMenuItem();
this.MenuPanel = new System.Windows.Forms.Panel();
this.StatusStrip = new System.Windows.Forms.StatusStrip();
@ -282,7 +284,6 @@ namespace XenAdmin
this.statusLabelErrors = new System.Windows.Forms.ToolStripStatusLabel();
this.statusLabelUpdates = new System.Windows.Forms.ToolStripStatusLabel();
this.statusLabelAlerts = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripMenuItemResetCertificate = new XenAdmin.Commands.CommandToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@ -1286,6 +1287,12 @@ namespace XenAdmin
this.toolStripMenuItemInstallCertificate.Name = "toolStripMenuItemInstallCertificate";
resources.ApplyResources(this.toolStripMenuItemInstallCertificate, "toolStripMenuItemInstallCertificate");
//
// toolStripMenuItemResetCertificate
//
this.toolStripMenuItemResetCertificate.Command = new XenAdmin.Commands.ResetCertificateCommand();
this.toolStripMenuItemResetCertificate.Name = "toolStripMenuItemResetCertificate";
resources.ApplyResources(this.toolStripMenuItemResetCertificate, "toolStripMenuItemResetCertificate");
//
// maintenanceModeToolStripMenuItem1
//
this.maintenanceModeToolStripMenuItem1.Command = new XenAdmin.Commands.HostMaintenanceModeCommand();
@ -1914,11 +1921,22 @@ namespace XenAdmin
this.templatesToolStripMenuItem,
this.toolsToolStripMenuItem,
this.windowToolStripMenuItem,
this.helpToolStripMenuItem});
this.helpToolStripMenuItem,
this.updateClientToolStripMenuItem});
this.MainMenuBar.Name = "MainMenuBar";
this.MainMenuBar.MenuActivate += new System.EventHandler(this.MainMenuBar_MenuActivate);
this.MainMenuBar.MouseClick += new System.Windows.Forms.MouseEventHandler(this.MainMenuBar_MouseClick);
//
// updateClientToolStripMenuItem
//
this.updateClientToolStripMenuItem.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.updateClientToolStripMenuItem.BackColor = System.Drawing.SystemColors.Window;
resources.ApplyResources(this.updateClientToolStripMenuItem, "updateClientToolStripMenuItem");
this.updateClientToolStripMenuItem.Image = global::XenAdmin.Properties.Resources._075_WarningRound_h32bit_16;
this.updateClientToolStripMenuItem.Margin = new System.Windows.Forms.Padding(0, 0, 5, 0);
this.updateClientToolStripMenuItem.Name = "updateClientToolStripMenuItem";
this.updateClientToolStripMenuItem.Click += new System.EventHandler(this.updateToolStripMenuItem_Click);
//
// securityGroupsToolStripMenuItem
//
this.securityGroupsToolStripMenuItem.Name = "securityGroupsToolStripMenuItem";
@ -1993,12 +2011,6 @@ namespace XenAdmin
this.statusLabelAlerts.VisitedLinkColor = System.Drawing.SystemColors.ControlDarkDark;
this.statusLabelAlerts.Click += new System.EventHandler(this.statusLabelAlerts_Click);
//
// toolStripMenuItemResetCertificate
//
this.toolStripMenuItemResetCertificate.Command = new XenAdmin.Commands.ResetCertificateCommand();
this.toolStripMenuItemResetCertificate.Name = "toolStripMenuItemResetCertificate";
resources.ApplyResources(this.toolStripMenuItemResetCertificate, "toolStripMenuItemResetCertificate");
//
// MainWindow
//
resources.ApplyResources(this, "$this");
@ -2281,6 +2293,7 @@ namespace XenAdmin
private XenAdmin.Commands.CommandToolStripMenuItem toolStripMenuItemWlb;
private XenAdmin.Commands.CommandToolStripMenuItem toolStripMenuItemCertificate;
private XenAdmin.Commands.CommandToolStripMenuItem toolStripMenuItemResetCertificate;
private System.Windows.Forms.ToolStripMenuItem updateClientToolStripMenuItem;
}
}

View File

@ -63,7 +63,7 @@ using System.Linq;
using XenAdmin.Controls.GradientPanel;
using XenAdmin.Help;
using XenAdmin.Wizards;
using System.IO;
namespace XenAdmin
{
@ -142,6 +142,8 @@ namespace XenAdmin
private bool expandTreeNodesOnStartup;
private int connectionsInProgressOnStartup;
private ClientUpdateAlert updateAlert = null;
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
static extern uint RegisterApplicationRestart(string pszCommandline, uint dwFlags);
@ -262,6 +264,8 @@ namespace XenAdmin
OtherConfigAndTagsWatcher.RegisterEventHandlers();
Alert.RegisterAlertCollectionChanged(XenCenterAlerts_CollectionChanged);
Updates.UpdateAlertCollectionChanged += Updates_CollectionChanged;
Updates.CheckForUpdatesStarted += UpdatesCheck_Started;
Updates.CheckForUpdatesCompleted += UpdatesCheck_Completed;
ConnectionsManager.History.CollectionChanged += History_CollectionChanged;
//ConnectionsManager.XenConnections.CollectionChanged is registered in OnShown
Properties.Settings.Default.SettingChanging += Default_SettingChanging;
@ -275,6 +279,8 @@ namespace XenAdmin
OtherConfigAndTagsWatcher.DeregisterEventHandlers();
Alert.DeregisterAlertCollectionChanged(XenCenterAlerts_CollectionChanged);
Updates.UpdateAlertCollectionChanged -= Updates_CollectionChanged;
Updates.CheckForUpdatesStarted -= UpdatesCheck_Started;
Updates.CheckForUpdatesCompleted -= UpdatesCheck_Completed;
ConnectionsManager.History.CollectionChanged -= History_CollectionChanged;
ConnectionsManager.XenConnections.CollectionChanged -= XenConnection_CollectionChanged;
Properties.Settings.Default.SettingChanging -= Default_SettingChanging;
@ -2658,6 +2664,20 @@ namespace XenAdmin
});
}
private void UpdatesCheck_Completed(bool suceeded, string err)
{
Program.Invoke(this, () => {
updateAlert = Updates.UpdateAlerts.FirstOrDefault(update => update is ClientUpdateAlert) as ClientUpdateAlert;
updateClientToolStripMenuItem.Enabled = true;//updateAlert != null;
});
}
private void UpdatesCheck_Started()
{
Program.Invoke(this, () => { updateClientToolStripMenuItem.Enabled = false; });
}
private void CloseWhenActionsCanceled(object o)
{
int i = 0;
@ -3309,5 +3329,13 @@ namespace XenAdmin
{
navigationPane.SwitchToNotificationsView(NotificationsSubMode.Events);
}
private void updateToolStripMenuItem_Click(object sender, EventArgs e)
{
var downloadAndInstallClientAction = new DownloadAndUpdateClientAction(updateAlert.Name, new Uri(updateAlert.NewVersion.Url), Path.Combine(Path.GetTempPath(), $"{updateAlert.Name}.msi"), true);
using (var dlg = new ActionProgressDialog(downloadAndInstallClientAction, ProgressBarStyle.Marquee))
dlg.ShowDialog(Parent);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -997,7 +997,9 @@ namespace XenAdmin
/// </summary>
public static bool ForcedExiting = false;
public static Version Version => Assembly.GetExecutingAssembly().GetName().Version;
//public static Version Version => Assembly.GetExecutingAssembly().GetName().Version;
public static Version Version => new Version(1, 0, 0, 0);//Assembly.GetExecutingAssembly().GetName().Version;
public static string CurrentLanguage => Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName;