Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CP-40844: Adds download source action that gets the latest source code in the production stage #3153

Merged
merged 19 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f0e75f2
CP-40844 adds download source action that gets the latest source code…
CitrixChris Jun 5, 2023
fc75da7
CP-40844 fixes misnamed method and adds sourceurl parameter to brandm…
CitrixChris Sep 6, 2023
fc2877f
CP-40844 Source url now uses XCUpdates url and just substitues the na…
CitrixChris Sep 8, 2023
32009af
CP-40844 Adds source url to xenadmin-build.ps1
CitrixChris Sep 8, 2023
5878f21
CP-40844 defines log4net in each class not just inherited
CitrixChris Sep 8, 2023
7d57754
CP-40844 removes unused class variable
CitrixChris Sep 20, 2023
a8c6616
CP-40844 removes unneeded class variable and uses parent property ins…
CitrixChris Oct 5, 2023
723624e
CP-40844 reduces public exposure of member variables/properties
CitrixChris Oct 5, 2023
be934fa
CP-40844 merges download x file actions into single file.
CitrixChris Oct 5, 2023
432e0a8
CP-40844 overide ReleaseDownloadedContent in DownloadAndUpdateClientA…
CitrixChris Oct 5, 2023
a3f5924
CP-40844 minor fixes/tidy up
CitrixChris Oct 5, 2023
8dcacef
CP-40844 defaults the download latest source button to be invisible.
CitrixChris Oct 16, 2023
8cbd911
CP-40844 if there is no client update detected then we shouldnt show …
CitrixChris Oct 16, 2023
d5ef4d7
CP-40844 Directs user to xenserver website to download source if auto…
CitrixChris Oct 24, 2023
0fe7691
CP-40844 updates source param to sourceUrl in XCUpdates.xml
CitrixChris Oct 24, 2023
3222bd0
CP-40844 moves strings to Messages and applys source name string to r…
CitrixChris Oct 24, 2023
bd7eaad
CP-40844 removes sourceurl from brand manager
CitrixChris Oct 24, 2023
91bd5e0
CP-40844 uses string literal rather than string join
CitrixChris Oct 24, 2023
ed71d8e
Some more corrections.
kc284 Oct 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 43 additions & 6 deletions XenAdmin/Alerts/Types/ClientUpdateAlert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using XenAdmin.Actions;
using XenAdmin.Actions.GUIActions;
using XenAdmin.Actions.Updates;
using XenAdmin.Core;
using XenAdmin.Dialogs;

using XenAdmin.Dialogs.WarningDialogs;
using XenCenterLib;

namespace XenAdmin.Alerts
{
Expand Down Expand Up @@ -123,28 +125,63 @@ public static void DownloadAndInstallNewClient(ClientUpdateAlert updateAlert, IW

if (currentTasks)
{
if (new Dialogs.WarningDialogs.CloseXenCenterWarningDialog(true).ShowDialog(parent) != DialogResult.OK)
using (var dlg = new CloseXenCenterWarningDialog(true))
{
downloadAndInstallClientAction.ReleaseInstaller();
return;
if (dlg.ShowDialog(parent) != DialogResult.OK)
{
downloadAndInstallClientAction.ReleaseDownloadedContent();
return;
}
}
}

try
{
Process.Start(outputPathAndFileName);
log.DebugFormat("Update {0} found and install started", updateAlert.Name);
downloadAndInstallClientAction.ReleaseInstaller();
downloadAndInstallClientAction.ReleaseDownloadedContent();
Application.Exit();
}
catch (Exception e)
{
log.Error("Exception occurred when starting the installation process.", e);
downloadAndInstallClientAction.ReleaseInstaller(true);
downloadAndInstallClientAction.ReleaseDownloadedContent(true);

using (var dlg = new ErrorDialog(Messages.UPDATE_CLIENT_FAILED_INSTALLER_LAUNCH))
dlg.ShowDialog(parent);
}
}

public static void DownloadSource(IWin32Window parent)
{
// If no update no need to show where to save dialog
var clientVersion = Updates.ClientVersions.FirstOrDefault();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is also called from the item under the help menu when alerts are absent, in which case it won't download the source. Maybe make the clientVersion a parameter and set it accordingly in the item click handlers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will as the clientVersions is the pre-processed list of updates, it only becomes an update alert if the installed version < update version


if (clientVersion == null)
{
// There is no XCUpdates.xml so direct to website.
Program.OpenURL(InvisibleMessages.WEBSITE_DOWNLOADS);
}
else
{
string outputPathAndFileName;
using (var saveSourceDialog = new SaveFileDialog())
{
saveSourceDialog.FileName = $"{BrandManager.BrandConsole}-v{clientVersion.Version}-source.zip";
saveSourceDialog.DefaultExt = "zip";
saveSourceDialog.Filter = "(*.zip)|*.zip|All files (*.*)|*.*";
saveSourceDialog.InitialDirectory = Win32.GetKnownFolderPath(Win32.KnownFolders.Downloads);

if (saveSourceDialog.ShowDialog(parent) != DialogResult.OK)
{
return;
}
outputPathAndFileName = saveSourceDialog.FileName;
}

var downloadSourceAction = new DownloadSourceAction(clientVersion.Name, new Uri(clientVersion.SourceUrl), outputPathAndFileName);
downloadSourceAction.RunAsync();
}
}
}
}
2 changes: 1 addition & 1 deletion XenAdmin/Alerts/Types/GuiOldAlert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public GuiOldAlert()

public override Action FixLinkAction
{
get { return () => Program.OpenURL(InvisibleMessages.OUT_OF_DATE_WEBSITE); }
get { return () => Program.OpenURL(InvisibleMessages.WEBSITE_DOWNLOADS); }
}

public override string FixLinkText => Messages.ALERT_NEW_VERSION_DOWNLOAD;
Expand Down
2 changes: 1 addition & 1 deletion XenAdmin/Core/Updates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class Updates

private static List<XenServerVersion> XenServerVersionsForAutoCheck = new List<XenServerVersion>();
private static List<XenServerPatch> XenServerPatches = new List<XenServerPatch>();
private static List<ClientVersion> ClientVersions = new List<ClientVersion>();
public static List<ClientVersion> ClientVersions = new List<ClientVersion>();
public static List<XenServerVersion> XenServerVersions = new List<XenServerVersion>();

private static readonly List<Alert> updateAlerts = new List<Alert>();
Expand Down
20 changes: 19 additions & 1 deletion XenAdmin/MainWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 21 additions & 2 deletions XenAdmin/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
using XenAdmin.Controls.GradientPanel;
using XenAdmin.Dialogs.ServerUpdates;
using XenAdmin.Help;
using XenAdmin.Actions.Updates;

namespace XenAdmin
{
Expand Down Expand Up @@ -269,6 +270,7 @@ public MainWindow(string[] args)
statusButtonAlerts.Visible = statusButtonUpdates.Visible = statusButtonCdnUpdates.Visible = statusButtonProgress.Visible = statusButtonErrors.Visible = false;
statusButtonUpdates.ToolTipText = string.Format(statusButtonUpdates.ToolTipText, BrandManager.ProductVersion821);
statusButtonCdnUpdates.ToolTipText = string.Format(statusButtonCdnUpdates.ToolTipText, BrandManager.ProductBrand, BrandManager.ProductVersionPost82);
downloadLatestSourceToolStripMenuItem.Text = Messages.DOWNLOAD_LATEST_SOURCE;
}

private void RegisterEvents()
Expand Down Expand Up @@ -966,7 +968,7 @@ private void connection_CachePopulated(IXenConnection connection)
Program.Invoke(Program.MainWindow, delegate
{
var msg = string.Format(Messages.GUI_OUT_OF_DATE, BrandManager.BrandConsole, Helpers.GetName(coordinator));
var url = InvisibleMessages.OUT_OF_DATE_WEBSITE;
var url = InvisibleMessages.WEBSITE_DOWNLOADS;
var title = string.Format(Messages.CONNECTION_REFUSED_TITLE, Helpers.GetName(coordinator).Ellipsise(80));
var error = $"{msg}\n{url}";

Expand Down Expand Up @@ -994,7 +996,7 @@ private void connection_CachePopulated(IXenConnection connection)
{
var msg = string.Format(Messages.GUI_NOT_COMPATIBLE, BrandManager.BrandConsole, BrandManager.ProductVersion712,
BrandManager.ProductVersion80, Helpers.GetName(coordinator));
var url = InvisibleMessages.OUT_OF_DATE_WEBSITE;
var url = InvisibleMessages.WEBSITE_DOWNLOADS;
var title = string.Format(Messages.CONNECTION_REFUSED_TITLE, Helpers.GetName(coordinator).Ellipsise(80));
var error = $"{msg}\n{url}";

Expand Down Expand Up @@ -2715,7 +2717,14 @@ private void SetClientUpdateAlert()
{
updateAlert = Updates.ClientUpdateAlerts.FirstOrDefault();
if (updateAlert != null)
{
CitrixChris marked this conversation as resolved.
Show resolved Hide resolved
relNotesToolStripMenuItem.Text = string.Format(Messages.MAINWINDOW_UPDATE_RELEASE, updateAlert.NewVersion.Version);
downloadSourceToolStripMenuItem.Text = string.Format(Messages.DOWNLOAD_SOURCE, BrandManager.BrandConsole, updateAlert.NewVersion.Version);
}
var clientVersion = Updates.ClientVersions.FirstOrDefault();
downloadLatestSourceToolStripMenuItem.Text = clientVersion != null
? string.Format(Messages.DOWNLOAD_SOURCE, BrandManager.BrandConsole, clientVersion.Version)
: string.Format(Messages.DOWNLOAD_LATEST_SOURCE, BrandManager.BrandConsole);
updateClientToolStripMenuItem.Visible = updateAlert != null;
}

Expand Down Expand Up @@ -3391,5 +3400,15 @@ private void configureUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
using (var dialog = new ConfigUpdatesDialog())
dialog.ShowDialog(this);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aplogies if I'm missing something, but why have we added two items?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one to be in the alert notification menu one to be in the help menu

private void downloadSourceToolStripMenuItem_Click(object sender, EventArgs e)
{
ClientUpdateAlert.DownloadSource(this);
}

private void downloadLatestSourceToolStripMenuItem_Click(object sender, EventArgs e)
{
ClientUpdateAlert.DownloadSource(this);
}
}
}
25 changes: 23 additions & 2 deletions XenAdmin/MainWindow.resx
Copy link
Member

@danilo-delbusso danilo-delbusso Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a large number of changes here that are hard to decipher like this. Is this VS22 doing its thing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were added automatically by VS some time ago. I have removed them in this PR #3223 because it was through a PR of mine that were added in the first place. Since you have requested more changes in the current PR, it might be easier to merge the aforementioned one and then rebase again the current one on master.

Generally I think the problem is that in the remote past people had the habit to modify the Desginger.cs manually, hence VS tries now to rearrange things every time we open the Designer or change something. Also, there are controls that contain things in the constructor that do not make sense at design time, so I think this also plays a role to what VS changes automatically.

Original file line number Diff line number Diff line change
Expand Up @@ -2772,6 +2772,9 @@
<data name="pluginItemsPlaceHolderToolStripMenuItem8.Text" xml:space="preserve">
<value>PluginItemsPlaceHolder</value>
</data>
<data name="downloadLatestSourceToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>186, 22</value>
</data>
<data name="aboutXenSourceAdminToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>186, 22</value>
</data>
Expand All @@ -2797,17 +2800,23 @@
<value>Microsoft Sans Serif, 8.25pt</value>
</data>
<data name="downloadInstallToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>173, 22</value>
<value>180, 22</value>
</data>
<data name="downloadInstallToolStripMenuItem.Text" xml:space="preserve">
<value>Download and &amp;Install</value>
</data>
<data name="relNotesToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>173, 22</value>
<value>180, 22</value>
</data>
<data name="relNotesToolStripMenuItem.Text" xml:space="preserve">
<value>v{0} &amp;Release Notes</value>
</data>
<data name="downloadSourceToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
</data>
<data name="downloadSourceToolStripMenuItem.Text" xml:space="preserve">
<value>Download v{0} source</value>
</data>
<data name="updateClientToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>87, 20</value>
</data>
Expand Down Expand Up @@ -4143,6 +4152,12 @@
<data name="&gt;&gt;pluginItemsPlaceHolderToolStripMenuItem8.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;downloadLatestSourceToolStripMenuItem.Name" xml:space="preserve">
<value>downloadLatestSourceToolStripMenuItem</value>
</data>
<data name="&gt;&gt;downloadLatestSourceToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;aboutXenSourceAdminToolStripMenuItem.Name" xml:space="preserve">
<value>aboutXenSourceAdminToolStripMenuItem</value>
</data>
Expand All @@ -4167,6 +4182,12 @@
<data name="&gt;&gt;relNotesToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;downloadSourceToolStripMenuItem.Name" xml:space="preserve">
<value>downloadSourceToolStripMenuItem</value>
</data>
<data name="&gt;&gt;downloadSourceToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;securityGroupsToolStripMenuItem.Name" xml:space="preserve">
<value>securityGroupsToolStripMenuItem</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public class XenCenterUpdateAlertTests
public void VerifyStoredDataWithDefaultConstructor()
{
var version = new ClientVersion("6.0.2", "xc", true, false, "http://url",
new DateTime(2011, 12, 09).ToString(), "abcde");

new DateTime(2011, 12, 09).ToString(), "abcde", "http://sourceurl");
ClassVerifiers.VerifyGetters(new ClientUpdateAlert(version),
new UpdateAlertClassUnitTestData
{
Expand Down
4 changes: 3 additions & 1 deletion XenModel/Actions/Updates/ClientVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ public class ClientVersion
public string Lang;
public DateTime TimeStamp;
public string Checksum;
public string SourceUrl;

public ClientVersion(string version_lang, string name, bool latest, bool latest_cr, string url, string timestamp, string checksum)
public ClientVersion(string version_lang, string name, bool latest, bool latest_cr, string url, string timestamp, string checksum, string sourceUrl)
{
ParseVersion(version_lang);
Name = name;
Expand All @@ -53,6 +54,7 @@ public ClientVersion(string version_lang, string name, bool latest, bool latest_
Url = url;
DateTime.TryParse(timestamp, out TimeStamp);
Checksum = checksum;
SourceUrl = sourceUrl;
}

private void ParseVersion(string version_lang)
Expand Down
Loading
Loading