2015-07-01 16:58:58 +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.ComponentModel;
|
2015-08-27 01:30:02 +02:00
|
|
|
|
using System.Drawing;
|
2015-07-01 16:58:58 +02:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using XenAdmin.Actions;
|
|
|
|
|
using XenAdmin.Core;
|
|
|
|
|
using XenAdmin.Dialogs.VMProtectionRecovery;
|
2015-08-21 16:18:18 +02:00
|
|
|
|
using XenAdmin.Model;
|
2015-07-01 16:58:58 +02:00
|
|
|
|
using XenAdmin.Network;
|
|
|
|
|
using XenAPI;
|
|
|
|
|
using XenCenterLib;
|
|
|
|
|
|
|
|
|
|
|
2015-07-29 09:44:41 +02:00
|
|
|
|
namespace XenAdmin.Dialogs.HealthCheck
|
2015-07-01 16:58:58 +02:00
|
|
|
|
{
|
2015-07-29 09:44:41 +02:00
|
|
|
|
public partial class HealthCheckOverviewDialog : XenDialogBase
|
2015-07-01 16:58:58 +02:00
|
|
|
|
{
|
|
|
|
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
|
|
|
|
2016-02-18 14:09:53 +01:00
|
|
|
|
internal override string HelpName { get { return "HealthCheckOverviewDialog"; } }
|
|
|
|
|
|
2015-07-29 09:44:41 +02:00
|
|
|
|
public HealthCheckOverviewDialog()
|
2015-07-01 16:58:58 +02:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2015-08-27 01:30:02 +02:00
|
|
|
|
Core.HealthCheck.CheckForAnalysisResultsCompleted += HealthCheck_CheckForUpdatesCompleted;
|
2015-07-01 16:58:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Pool currentSelected = null;
|
|
|
|
|
|
|
|
|
|
void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Error != null)
|
|
|
|
|
{
|
|
|
|
|
log.Error(e.Error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Program.Invoke(this, () => RefreshGrid((List<DataGridViewRow>)e.Result));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RefreshGrid(List<DataGridViewRow> rows)
|
|
|
|
|
{
|
|
|
|
|
Program.AssertOnEventThread();
|
|
|
|
|
|
|
|
|
|
var selectedPool = currentSelected;
|
|
|
|
|
poolsDataGridView.SuspendLayout();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
poolsDataGridView.Rows.Clear();
|
|
|
|
|
|
|
|
|
|
foreach (var row in rows)
|
|
|
|
|
{
|
|
|
|
|
if (poolsDataGridView.ColumnCount > 0)
|
|
|
|
|
{
|
|
|
|
|
poolsDataGridView.Rows.Add(row);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
RefreshButtons();
|
|
|
|
|
RefreshDetailsPanel();
|
|
|
|
|
if (selectedPool != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (DataGridViewRow row in poolsDataGridView.Rows)
|
|
|
|
|
{
|
|
|
|
|
if (row is PoolRow &&
|
|
|
|
|
(row as PoolRow).Pool.uuid == selectedPool.uuid)
|
|
|
|
|
{
|
|
|
|
|
poolsDataGridView.ClearSelection();
|
|
|
|
|
row.Selected = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
poolsDataGridView.ResumeLayout();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object worker_DoWork(object sender, object argument)
|
|
|
|
|
{
|
|
|
|
|
var list = new List<DataGridViewRow>();
|
|
|
|
|
foreach (IXenConnection xenConnection in ConnectionsManager.XenConnectionsCopy)
|
|
|
|
|
{
|
|
|
|
|
if (!xenConnection.IsConnected || Helpers.FeatureForbidden(xenConnection, Host.RestrictHealthCheck))
|
|
|
|
|
continue;
|
|
|
|
|
var pool = Helpers.GetPoolOfOne(xenConnection);
|
|
|
|
|
if (pool != null)
|
|
|
|
|
{
|
|
|
|
|
var poolRow = new PoolRow(pool);
|
|
|
|
|
list.Add(poolRow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Pool_BatchCollectionChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
LoadPools();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QueuedBackgroundWorker worker = new QueuedBackgroundWorker();
|
|
|
|
|
private void LoadPools()
|
|
|
|
|
{
|
|
|
|
|
worker.RunWorkerAsync(worker_DoWork, worker_RunWorkerCompleted);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region PoolRow
|
|
|
|
|
private class PoolRow : DataGridViewRow
|
|
|
|
|
{
|
|
|
|
|
private DataGridViewTextAndImageCell _nameCell = new DataGridViewTextAndImageCell();
|
|
|
|
|
private DataGridViewTextAndImageCell _statusCell = new DataGridViewTextAndImageCell();
|
|
|
|
|
public readonly Pool Pool;
|
|
|
|
|
public PoolRow(Pool pool)
|
|
|
|
|
{
|
|
|
|
|
Cells.Add(_nameCell);
|
|
|
|
|
Cells.Add(_statusCell);
|
|
|
|
|
Pool = pool;
|
|
|
|
|
RefreshRow();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RefreshRow()
|
|
|
|
|
{
|
|
|
|
|
_nameCell.Value = Pool.Name;
|
|
|
|
|
_nameCell.Image = null;
|
2015-07-29 09:44:41 +02:00
|
|
|
|
_statusCell.Value = Pool.HealthCheckSettings.StatusDescription;
|
2015-08-27 01:30:02 +02:00
|
|
|
|
_statusCell.Image = Pool.HealthCheckSettings.Status != HealthCheckStatus.Enabled || !Pool.HealthCheckSettings.HasAnalysisResult
|
|
|
|
|
? null
|
|
|
|
|
: GetSeverityImage(Pool.HealthCheckSettings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Image GetSeverityImage(HealthCheckSettings healthCheckSettings)
|
|
|
|
|
{
|
|
|
|
|
if (healthCheckSettings.ReportAnalysisIssuesDetected == 0)
|
|
|
|
|
return Properties.Resources._000_Tick_h32bit_16;
|
|
|
|
|
switch (healthCheckSettings.ReportAnalysisSeverity)
|
|
|
|
|
{
|
|
|
|
|
case DiagnosticAlertSeverity.Error:
|
|
|
|
|
return Properties.Resources._000_error_h32bit_16;
|
|
|
|
|
case DiagnosticAlertSeverity.Warning:
|
|
|
|
|
return Properties.Resources._000_Alert2_h32bit_16;
|
|
|
|
|
default:
|
|
|
|
|
return Properties.Resources._000_Info3_h32bit_16;
|
|
|
|
|
}
|
2015-07-01 16:58:58 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void RefreshButtons()
|
|
|
|
|
{
|
|
|
|
|
if (poolsDataGridView.SelectedRows.Count == 1 && poolsDataGridView.SelectedRows[0] is PoolRow)
|
|
|
|
|
{
|
|
|
|
|
currentSelected = (Pool)((PoolRow)poolsDataGridView.SelectedRows[0]).Pool;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (poolsDataGridView.SelectedRows.Count == 0)
|
|
|
|
|
currentSelected = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
poolDetailsPanel.Visible = (currentSelected != null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RefreshDetailsPanel()
|
|
|
|
|
{
|
|
|
|
|
if (poolsDataGridView.SelectedRows.Count != 1 || !(poolsDataGridView.SelectedRows[0] is PoolRow))
|
|
|
|
|
{
|
|
|
|
|
poolNameLabel.Text = "";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var poolRow = (PoolRow)poolsDataGridView.SelectedRows[0];
|
2015-09-09 10:39:45 +02:00
|
|
|
|
var healthcheckSettings = poolRow.Pool.HealthCheckSettings;
|
2015-07-01 16:58:58 +02:00
|
|
|
|
poolNameLabel.Text = poolRow.Pool.Name.Ellipsise(120);
|
2015-09-09 10:39:45 +02:00
|
|
|
|
scheduleLabel.Text = GetScheduleDescription(healthcheckSettings);
|
|
|
|
|
lastUploadLabel.Visible = lastUploadDateLabel.Visible = !string.IsNullOrEmpty(healthcheckSettings.LastSuccessfulUpload);
|
|
|
|
|
lastUploadDateLabel.Text = GetLastUploadDescription(healthcheckSettings);
|
|
|
|
|
|
|
|
|
|
// show the "Last failed upload" if we have a failed upload AND
|
|
|
|
|
// there is no successful upload or the failed upload happened after a successful upload
|
|
|
|
|
var lastFailedUploadTime = healthcheckSettings.LastFailedUploadTime;
|
|
|
|
|
bool showFailedUpload = lastFailedUploadTime > DateTime.MinValue
|
|
|
|
|
&& (string.IsNullOrEmpty(healthcheckSettings.LastSuccessfulUpload) || lastFailedUploadTime > healthcheckSettings.LastSuccessfulUploadTime);
|
|
|
|
|
failedUploadLabel.Visible = failedUploadDateLabel.Visible = showFailedUpload;
|
|
|
|
|
if (showFailedUpload)
|
|
|
|
|
failedUploadDateLabel.Text = HelpersGUI.DateTimeToString(lastFailedUploadTime.ToLocalTime(), Messages.DATEFORMAT_DMY_HM, true);
|
2015-09-09 14:26:53 +02:00
|
|
|
|
|
2015-09-03 12:49:53 +02:00
|
|
|
|
UpdateButtonsVisibility(poolRow.Pool);
|
2015-07-01 16:58:58 +02:00
|
|
|
|
|
2015-07-29 09:44:41 +02:00
|
|
|
|
healthCheckStatusPanel.Visible = poolRow.Pool.HealthCheckSettings.Status == HealthCheckStatus.Enabled;
|
|
|
|
|
notEnrolledPanel.Visible = poolRow.Pool.HealthCheckSettings.Status != HealthCheckStatus.Enabled;
|
|
|
|
|
UpdateUploadRequestDescription(poolRow.Pool.HealthCheckSettings);
|
2015-08-27 01:30:02 +02:00
|
|
|
|
|
|
|
|
|
UpdateAnalysisResult(poolRow.Pool.HealthCheckSettings);
|
2015-07-01 16:58:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-29 09:44:41 +02:00
|
|
|
|
public string GetScheduleDescription(HealthCheckSettings healthCheckSettings)
|
2015-07-01 16:58:58 +02:00
|
|
|
|
{
|
|
|
|
|
{
|
2015-07-29 09:44:41 +02:00
|
|
|
|
var time = new DateTime(1900, 1, 1, healthCheckSettings.TimeOfDay, 0, 0);
|
|
|
|
|
return healthCheckSettings.Status == HealthCheckStatus.Enabled
|
|
|
|
|
? string.Format(Messages.HEALTHCHECK_SCHEDULE_DESCRIPTION, healthCheckSettings.IntervalInWeeks,
|
|
|
|
|
healthCheckSettings.DayOfWeek, HelpersGUI.DateTimeToString(time, Messages.DATEFORMAT_HM, true))
|
2015-07-01 16:58:58 +02:00
|
|
|
|
: string.Empty;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-29 09:44:41 +02:00
|
|
|
|
public void UpdateUploadRequestDescription(HealthCheckSettings healthCheckSettings)
|
2015-07-01 16:58:58 +02:00
|
|
|
|
{
|
|
|
|
|
{
|
2015-07-29 09:44:41 +02:00
|
|
|
|
if (!healthCheckSettings.CanRequestNewUpload)
|
2015-07-01 16:58:58 +02:00
|
|
|
|
{
|
2015-07-06 18:02:55 +02:00
|
|
|
|
uploadRequestLinkLabel.Text = string.Format(Messages.HEALTHCHECK_ON_DEMAND_REQUESTED_AT,
|
2015-07-29 09:44:41 +02:00
|
|
|
|
HelpersGUI.DateTimeToString(healthCheckSettings.NewUploadRequestTime.ToLocalTime(),
|
2015-07-06 18:02:55 +02:00
|
|
|
|
Messages.DATEFORMAT_HM, true));
|
2015-07-01 16:58:58 +02:00
|
|
|
|
uploadRequestLinkLabel.LinkArea = new LinkArea(0, 0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
uploadRequestLinkLabel.Text = Messages.HEALTHCHECK_ON_DEMAND_REQUEST;
|
|
|
|
|
uploadRequestLinkLabel.LinkArea = new LinkArea(0, uploadRequestLinkLabel.Text.Length);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-29 09:44:41 +02:00
|
|
|
|
public string GetLastUploadDescription(HealthCheckSettings healthCheckSettings)
|
2015-07-06 18:02:55 +02:00
|
|
|
|
{
|
2015-07-29 09:44:41 +02:00
|
|
|
|
if (!string.IsNullOrEmpty(healthCheckSettings.LastSuccessfulUpload))
|
2015-07-06 18:02:55 +02:00
|
|
|
|
{
|
2015-07-07 19:25:15 +02:00
|
|
|
|
DateTime lastSuccessfulUpload;
|
2015-07-29 09:44:41 +02:00
|
|
|
|
if (HealthCheckSettings.TryParseStringToDateTime(healthCheckSettings.LastSuccessfulUpload, out lastSuccessfulUpload))
|
2015-07-06 18:02:55 +02:00
|
|
|
|
{
|
2015-07-07 19:25:15 +02:00
|
|
|
|
return HelpersGUI.DateTimeToString(lastSuccessfulUpload.ToLocalTime(), Messages.DATEFORMAT_DMY_HM, true);
|
2015-07-06 18:02:55 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-07 19:25:15 +02:00
|
|
|
|
return string.Empty;
|
2015-07-06 18:02:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-27 01:30:02 +02:00
|
|
|
|
public void UpdateAnalysisResult(HealthCheckSettings healthCheckSettings)
|
|
|
|
|
{
|
|
|
|
|
issuesLabel.Text = healthCheckSettings.StatusDescription;
|
|
|
|
|
ReportAnalysisLinkLabel.Visible = healthCheckSettings.HasAnalysisResult;
|
|
|
|
|
|
|
|
|
|
if (healthCheckSettings.HasAnalysisResult)
|
|
|
|
|
switch (healthCheckSettings.ReportAnalysisSeverity)
|
|
|
|
|
{
|
|
|
|
|
case DiagnosticAlertSeverity.Error:
|
|
|
|
|
issuesLabel.ForeColor = Color.Red;
|
|
|
|
|
break;
|
|
|
|
|
case DiagnosticAlertSeverity.Warning:
|
|
|
|
|
issuesLabel.ForeColor = Color.OrangeRed;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
issuesLabel.ForeColor =
|
|
|
|
|
healthCheckSettings.ReportAnalysisIssuesDetected > 0 ? SystemColors.ControlText : Color.Green;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
issuesLabel.ForeColor = SystemColors.ControlText;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
refreshLinkLabel.Visible = healthCheckSettings.HasUpload && !healthCheckSettings.HasAnalysisResult;
|
|
|
|
|
|
|
|
|
|
if (healthCheckSettings.HasOldAnalysisResult)
|
|
|
|
|
{
|
|
|
|
|
previousUploadPanel.Visible = healthCheckSettings.HasOldAnalysisResult;
|
|
|
|
|
|
|
|
|
|
DateTime previousUpload;
|
|
|
|
|
if (HealthCheckSettings.TryParseStringToDateTime(healthCheckSettings.ReportAnalysisUploadTime,
|
|
|
|
|
out previousUpload))
|
|
|
|
|
{
|
|
|
|
|
previousUploadDateLabel.Text = HelpersGUI.DateTimeToString(previousUpload.ToLocalTime(),
|
|
|
|
|
Messages.DATEFORMAT_DMY_HM, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
previousUploadPanel.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-03 12:49:53 +02:00
|
|
|
|
public void UpdateButtonsVisibility(Pool pool)
|
|
|
|
|
{
|
|
|
|
|
refreshLinkLabel.Visible =
|
|
|
|
|
editLinkLabel.Visible =
|
|
|
|
|
disableLinkLabel.Visible =
|
|
|
|
|
uploadRequestLinkLabel.Visible =
|
|
|
|
|
enrollNowLinkLabel.Visible = Core.HealthCheck.PassedRbacChecks(pool.Connection);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-29 09:44:41 +02:00
|
|
|
|
private void HealthCheckOverviewDialog_Load(object sender, EventArgs e)
|
2015-07-01 16:58:58 +02:00
|
|
|
|
{
|
|
|
|
|
LoadPools();
|
|
|
|
|
foreach (IXenConnection xenConnection in ConnectionsManager.XenConnectionsCopy)
|
|
|
|
|
{
|
|
|
|
|
xenConnection.Cache.RegisterBatchCollectionChanged<Pool>(Pool_BatchCollectionChanged);
|
|
|
|
|
}
|
2015-07-24 15:12:46 +02:00
|
|
|
|
showAgainCheckBox.Checked = Properties.Settings.Default.ShowHealthCheckEnrollmentReminder;
|
2015-07-01 16:58:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
RefreshButtons();
|
|
|
|
|
RefreshDetailsPanel();
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-29 09:44:41 +02:00
|
|
|
|
private void HealthCheckOOverviewDialog_FormClosed(object sender, FormClosedEventArgs e)
|
2015-07-01 16:58:58 +02:00
|
|
|
|
{
|
|
|
|
|
foreach (IXenConnection xenConnection in ConnectionsManager.XenConnectionsCopy)
|
|
|
|
|
{
|
|
|
|
|
xenConnection.Cache.DeregisterBatchCollectionChanged<Pool>(Pool_BatchCollectionChanged);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonCancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-24 15:20:18 +02:00
|
|
|
|
private void editlinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
2015-07-01 16:58:58 +02:00
|
|
|
|
{
|
|
|
|
|
if (poolsDataGridView.SelectedRows.Count != 1 || !(poolsDataGridView.SelectedRows[0] is PoolRow))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var poolRow = (PoolRow)poolsDataGridView.SelectedRows[0];
|
2015-07-29 09:44:41 +02:00
|
|
|
|
new HealthCheckSettingsDialog(poolRow.Pool, false).ShowDialog(this);
|
2015-07-01 16:58:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DialogResult ShowDialog(IWin32Window parent, List<IXenObject> selectedItems)
|
|
|
|
|
{
|
|
|
|
|
SelectPool(selectedItems);
|
|
|
|
|
return ShowDialog(parent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RefreshView(List<IXenObject> selectedItems)
|
|
|
|
|
{
|
|
|
|
|
SelectPool(selectedItems);
|
|
|
|
|
LoadPools();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SelectPool(List<IXenObject> selectedItems)
|
|
|
|
|
{
|
|
|
|
|
IXenObject xo = selectedItems.Count > 0 ? selectedItems.FirstOrDefault() : null;
|
|
|
|
|
if (xo is Pool)
|
|
|
|
|
currentSelected = xo as Pool;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void enrollNowLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (poolsDataGridView.SelectedRows.Count != 1 || !(poolsDataGridView.SelectedRows[0] is PoolRow))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var poolRow = (PoolRow)poolsDataGridView.SelectedRows[0];
|
2015-07-29 09:44:41 +02:00
|
|
|
|
new HealthCheckSettingsDialog(poolRow.Pool, true).ShowDialog(this);
|
2015-07-01 16:58:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void uploadRequestLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (poolsDataGridView.SelectedRows.Count != 1 || !(poolsDataGridView.SelectedRows[0] is PoolRow))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var poolRow = (PoolRow)poolsDataGridView.SelectedRows[0];
|
2015-07-29 09:44:41 +02:00
|
|
|
|
var healthCheckSettings = poolRow.Pool.HealthCheckSettings;
|
|
|
|
|
if (healthCheckSettings.CanRequestNewUpload)
|
2015-07-01 13:06:19 +02:00
|
|
|
|
{
|
2015-07-29 09:44:41 +02:00
|
|
|
|
healthCheckSettings.NewUploadRequest = HealthCheckSettings.DateTimeToString(DateTime.UtcNow);
|
|
|
|
|
var token = healthCheckSettings.GetSecretyInfo(poolRow.Pool.Connection, HealthCheckSettings.UPLOAD_TOKEN_SECRET);
|
2015-08-27 01:30:02 +02:00
|
|
|
|
var diagnosticToken = healthCheckSettings.GetSecretyInfo(poolRow.Pool.Connection, HealthCheckSettings.UPLOAD_TOKEN_SECRET);
|
2015-07-29 09:44:41 +02:00
|
|
|
|
var user = healthCheckSettings.GetSecretyInfo(poolRow.Pool.Connection, HealthCheckSettings.UPLOAD_CREDENTIAL_USER_SECRET);
|
|
|
|
|
var password = healthCheckSettings.GetSecretyInfo(poolRow.Pool.Connection, HealthCheckSettings.UPLOAD_CREDENTIAL_PASSWORD_SECRET);
|
2015-08-27 01:30:02 +02:00
|
|
|
|
new SaveHealthCheckSettingsAction(poolRow.Pool, healthCheckSettings, token, diagnosticToken, user, password, false).RunAsync();
|
2015-07-01 16:58:58 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-24 15:12:46 +02:00
|
|
|
|
|
|
|
|
|
private void showAgainCheckBox_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Properties.Settings.Default.ShowHealthCheckEnrollmentReminder != showAgainCheckBox.Checked)
|
|
|
|
|
{
|
|
|
|
|
Properties.Settings.Default.ShowHealthCheckEnrollmentReminder = showAgainCheckBox.Checked;
|
|
|
|
|
Settings.TrySaveSettings();
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-24 15:20:18 +02:00
|
|
|
|
|
|
|
|
|
private void disableLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (poolsDataGridView.SelectedRows.Count != 1 || !(poolsDataGridView.SelectedRows[0] is PoolRow))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var poolRow = (PoolRow)poolsDataGridView.SelectedRows[0];
|
|
|
|
|
if (poolRow.Pool == null)
|
|
|
|
|
return;
|
2015-07-29 09:44:41 +02:00
|
|
|
|
var healthCheckSettings = poolRow.Pool.HealthCheckSettings;
|
|
|
|
|
if (healthCheckSettings.Status == HealthCheckStatus.Enabled)
|
2015-07-24 15:20:18 +02:00
|
|
|
|
{
|
|
|
|
|
string msg = Helpers.GetPool(poolRow.Pool.Connection) == null
|
|
|
|
|
? Messages.CONFIRM_DISABLE_HEALTH_CHECK_SERVER
|
|
|
|
|
: Messages.CONFIRM_DISABLE_HEALTH_CHECK_POOL;
|
|
|
|
|
using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(null, msg, Messages.XENCENTER),
|
|
|
|
|
ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo))
|
|
|
|
|
{
|
|
|
|
|
if (dlg.ShowDialog(this) != DialogResult.Yes)
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-07-29 09:44:41 +02:00
|
|
|
|
healthCheckSettings.Status = HealthCheckStatus.Disabled;
|
2015-08-27 01:30:02 +02:00
|
|
|
|
new SaveHealthCheckSettingsAction(poolRow.Pool, healthCheckSettings, null, null, null, null, false).RunAsync();
|
2015-07-24 15:20:18 +02:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-08-27 01:30:02 +02:00
|
|
|
|
|
|
|
|
|
private void ReportAnalysisLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (poolsDataGridView.SelectedRows.Count != 1 || !(poolsDataGridView.SelectedRows[0] is PoolRow))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var poolRow = (PoolRow)poolsDataGridView.SelectedRows[0];
|
|
|
|
|
if (poolRow.Pool == null)
|
|
|
|
|
return;
|
|
|
|
|
var url = poolRow.Pool.HealthCheckSettings.GetReportAnalysisLink(Registry.HealthCheckDiagnosticDomainName);
|
|
|
|
|
if (!string.IsNullOrEmpty(url))
|
|
|
|
|
Program.OpenURL(url);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void viewReportLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (poolsDataGridView.SelectedRows.Count != 1 || !(poolsDataGridView.SelectedRows[0] is PoolRow))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var poolRow = (PoolRow)poolsDataGridView.SelectedRows[0];
|
|
|
|
|
if (poolRow.Pool == null)
|
|
|
|
|
return;
|
|
|
|
|
var url = poolRow.Pool.HealthCheckSettings.GetReportAnalysisLink(Registry.HealthCheckDiagnosticDomainName);
|
|
|
|
|
if (!string.IsNullOrEmpty(url))
|
|
|
|
|
Program.OpenURL(url);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void refreshLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var poolRow = (PoolRow)poolsDataGridView.SelectedRows[0];
|
|
|
|
|
if (poolRow.Pool == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-09-03 12:49:53 +02:00
|
|
|
|
Core.HealthCheck.CheckForAnalysisResults(poolRow.Pool.Connection, false);
|
2015-08-27 01:30:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HealthCheck_CheckForUpdatesCompleted(bool succeeded)
|
|
|
|
|
{
|
|
|
|
|
Program.Invoke(Program.MainWindow, LoadPools);
|
|
|
|
|
}
|
2015-08-27 14:50:35 +02:00
|
|
|
|
|
|
|
|
|
private void PolicyStatementLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
|
|
|
|
{
|
2015-09-10 14:08:49 +02:00
|
|
|
|
new HealthCheckPolicyStatementDialog().ShowDialog(this);
|
2015-08-27 14:50:35 +02:00
|
|
|
|
}
|
2015-07-01 16:58:58 +02:00
|
|
|
|
}
|
|
|
|
|
}
|