Minor code improvements.

Signed-off-by: Konstantina Chremmou <Konstantina.Chremmou@cloud.com>
This commit is contained in:
Konstantina Chremmou 2023-08-02 18:24:09 +01:00
parent b5e843c53d
commit d609514469
3 changed files with 12 additions and 6 deletions

View File

@ -39,6 +39,8 @@ namespace XenAdmin.Diagnostics.Checks
{
public class OutOfSyncWithCdnCheck : PoolCheck
{
private const int DAYS_SINCE_LAST_SYNC = 7;
public OutOfSyncWithCdnCheck(Pool pool)
: base (pool)
{
@ -53,8 +55,8 @@ namespace XenAdmin.Diagnostics.Checks
{
if (Helpers.XapiEqualOrGreater_23_18_0(Pool.Connection))
{
if (DateTime.UtcNow - Pool.last_update_sync >= TimeSpan.FromDays(7))
return new CdnOutOfSyncProblem(this, Pool);
if (DateTime.UtcNow - Pool.last_update_sync >= TimeSpan.FromDays(DAYS_SINCE_LAST_SYNC))
return new CdnOutOfSyncProblem(this, Pool, DAYS_SINCE_LAST_SYNC);
}
return null;

View File

@ -38,12 +38,15 @@ namespace XenAdmin.Diagnostics.Problems.PoolProblem
{
public class CdnOutOfSyncProblem : PoolProblem
{
public CdnOutOfSyncProblem(Check check, Pool pool)
private readonly int _days;
public CdnOutOfSyncProblem(Check check, Pool pool, int days)
: base(check, pool)
{
_days = days;
}
public override string Description => $"{Pool.Connection.Name}:{string.Format(Messages.ALERT_CDN_OUT_OF_SYNC_TITLE, 7)}";
public override string Description => $"{Pool.Connection.Name}:{string.Format(Messages.ALERT_CDN_OUT_OF_SYNC_TITLE, _days)}";
public override string HelpMessage => Messages.UPDATES_GENERAL_TAB_SYNC_NOW;

View File

@ -28,6 +28,7 @@
* SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
@ -264,7 +265,7 @@ namespace XenAdmin.TabPages.CdnUpdates
{
var msg = allLivePatches ? Messages.HOTFIX_POST_UPDATE_LIVEPATCH_ACTIONS : Messages.HOTFIX_POST_UPDATE_ACTIONS;
var text = string.Format(msg, string.Join("\n", guidance.Select(Cdn.FriendlyInstruction)));
var text = string.Format(msg, string.Join(Environment.NewLine, guidance.Select(Cdn.FriendlyInstruction)));
var img = allLivePatches ? Images.StaticImages.livepatch_16 : Images.StaticImages.rightArrowLong_Blue_16;
SetValues(text, img);
@ -276,7 +277,7 @@ namespace XenAdmin.TabPages.CdnUpdates
{
public RpmsRow(string[] rpms)
{
SetValues(string.Join("\n", rpms), null);
SetValues(string.Join(Environment.NewLine, rpms), null);
}
}
}