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.Drawing;
|
|
|
|
using System.IO;
|
2013-11-04 15:09:50 +01:00
|
|
|
using System.Linq;
|
2013-06-24 13:41:48 +02:00
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
using System.Xml;
|
|
|
|
|
|
|
|
using XenAdmin.Controls;
|
|
|
|
using XenAdmin.Core;
|
|
|
|
using XenAPI;
|
|
|
|
using XenAdmin.Actions;
|
|
|
|
using XenAdmin.Dialogs;
|
|
|
|
|
|
|
|
|
|
|
|
namespace XenAdmin.Wizards.BugToolWizardFiles
|
|
|
|
{
|
|
|
|
public partial class BugToolPageSelectCapabilities : XenTabPage
|
|
|
|
{
|
|
|
|
#region Private fields
|
|
|
|
private List<Host> _hostList = new List<Host>();
|
|
|
|
private List<Capability> _capabilities = new List<Capability>();
|
|
|
|
|
|
|
|
private Dictionary<Host, List<Capability>> hostCapabilities;
|
|
|
|
private List<GetSystemStatusCapabilities> actions;
|
|
|
|
private ActionProgressDialog dialog;
|
|
|
|
private bool cancelled;
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
public BugToolPageSelectCapabilities()
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
//set this here due to a framework bug
|
|
|
|
splitContainer1.Panel1MinSize = 250;
|
|
|
|
splitContainer1.Panel2MinSize = 200;
|
2016-01-28 22:43:15 +01:00
|
|
|
this.linkLabel1.Visible = !XenAdmin.Core.HiddenFeatures.LinkLabelHidden;
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override string Text{get { return Messages.BUGTOOL_PAGE_CAPABILITIES_TEXT; }}
|
|
|
|
|
|
|
|
public override string PageTitle { get { return Messages.BUGTOOL_PAGE_CAPABILITIES_PAGETITLE; } }
|
|
|
|
|
|
|
|
public override string HelpID { get { return "SelectReportContents"; } }
|
|
|
|
|
|
|
|
public override bool EnableNext()
|
|
|
|
{
|
|
|
|
return wizardCheckAnyChecked();
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void PageLoaded(PageLoadedDirection direction)
|
|
|
|
{
|
|
|
|
base.PageLoaded(direction);
|
|
|
|
if (direction == PageLoadedDirection.Forward)
|
|
|
|
{
|
|
|
|
ClearButton.Enabled = wizardCheckAnyChecked();
|
|
|
|
SelectButton.Enabled = wizardCheckAnyUnchecked();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private bool wizardCheckAnyChecked()
|
|
|
|
{
|
2013-11-04 15:09:50 +01:00
|
|
|
foreach (DataGridViewRow row in dataGridViewItems.Rows)
|
|
|
|
{
|
|
|
|
var capRow = row as CapabilityRow;
|
|
|
|
if (capRow != null && capRow.Capability.Checked)
|
2013-06-24 13:41:48 +02:00
|
|
|
return true;
|
2013-11-04 15:09:50 +01:00
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private bool wizardCheckAnyUnchecked()
|
|
|
|
{
|
2013-11-04 15:09:50 +01:00
|
|
|
foreach (DataGridViewRow row in dataGridViewItems.Rows)
|
|
|
|
{
|
|
|
|
var capRow = row as CapabilityRow;
|
|
|
|
if (capRow != null && !capRow.Capability.Checked)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="HostList"></param>
|
|
|
|
/// <returns>If success of not - false with stop moving to next page</returns>
|
|
|
|
public bool GetCommonCapabilities(List<Host> HostList)
|
|
|
|
{
|
|
|
|
if (!cancelled && Helpers.ListsContentsEqual<Host>(_hostList, HostList))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
_hostList = HostList;
|
2013-11-04 15:09:50 +01:00
|
|
|
dataGridViewItems.Rows.Clear();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
if (dialog != null && dialog.Visible)
|
|
|
|
dialog.Close();
|
|
|
|
|
|
|
|
hostCapabilities = new Dictionary<Host, List<Capability>>();
|
|
|
|
actions = new List<GetSystemStatusCapabilities>();
|
|
|
|
cancelled = false;
|
|
|
|
dialog = new ActionProgressDialog(Messages.SERVER_STATUS_REPORT_GET_CAPABILITIES);
|
|
|
|
dialog.ShowCancel = true;
|
|
|
|
dialog.CancelClicked += new EventHandler(dialog_CancelClicked);
|
|
|
|
|
|
|
|
foreach (Host host in _hostList)
|
|
|
|
{
|
|
|
|
GetSystemStatusCapabilities action = new GetSystemStatusCapabilities(host);
|
|
|
|
actions.Add(action);
|
|
|
|
action.Completed += Common_action_Completed;
|
|
|
|
action.RunAsync();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_hostList.Count > 0)
|
|
|
|
dialog.ShowDialog(this);
|
|
|
|
|
|
|
|
return !cancelled;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void dialog_CancelClicked(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
dialog.Close();
|
|
|
|
cancelled = true;
|
|
|
|
|
|
|
|
// Need to unhook events on current actions, to stop them
|
|
|
|
// interfeering when they return in 20mins
|
|
|
|
foreach (GetSystemStatusCapabilities action in actions)
|
|
|
|
action.Completed -= Common_action_Completed;
|
|
|
|
}
|
|
|
|
|
2013-08-05 15:28:21 +02:00
|
|
|
private void Common_action_Completed(ActionBase sender)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2015-04-16 15:17:02 +02:00
|
|
|
Program.Invoke(this, delegate()
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
|
|
|
if (cancelled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
GetSystemStatusCapabilities caps = sender as GetSystemStatusCapabilities;
|
|
|
|
if (caps == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hostCapabilities[caps.Host] =
|
|
|
|
caps.Succeeded ? parseXMLToList(caps) : null;
|
|
|
|
|
|
|
|
if (hostCapabilities.Count >= _hostList.Count)
|
|
|
|
{
|
|
|
|
dialog.Close();
|
|
|
|
CombineCapabilitiesLists();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private List<Capability> parseXMLToList(Actions.GetSystemStatusCapabilities action)
|
|
|
|
{
|
|
|
|
List<Capability> capabilities = new List<Capability>();
|
|
|
|
|
|
|
|
XmlDocument doc = new XmlDocument();
|
|
|
|
doc.LoadXml(action.Result);
|
|
|
|
foreach (XmlNode node in doc.GetElementsByTagName("capability"))
|
|
|
|
{
|
|
|
|
Capability c = new Capability();
|
|
|
|
foreach (XmlAttribute a in node.Attributes)
|
|
|
|
{
|
|
|
|
string name = a.Name;
|
|
|
|
string value = a.Value;
|
|
|
|
|
|
|
|
if (name == "content-type")
|
|
|
|
c.ContentType = value == "text/plain" ? ContentType.text_plain : ContentType.application_data;
|
|
|
|
else if (name == "default-checked")
|
|
|
|
c.DefaultChecked = value == "yes" ? true : false;
|
|
|
|
else if (name == "key")
|
|
|
|
c.Key = value;
|
|
|
|
else if (name == "max-size")
|
|
|
|
c.MaxSize = Int64.Parse(value);
|
|
|
|
else if (name == "min-size")
|
|
|
|
c.MinSize = Int64.Parse(value);
|
|
|
|
else if (name == "max-time")
|
|
|
|
c.MaxTime = Int64.Parse(value);
|
|
|
|
else if (name == "min-time")
|
|
|
|
c.MinTime = Int64.Parse(value);
|
|
|
|
else if (name == "pii")
|
|
|
|
c.PII = value == "yes" ? PrivateInformationIncluded.yes :
|
|
|
|
value == "no" ? PrivateInformationIncluded.no :
|
|
|
|
value == "maybe" ? PrivateInformationIncluded.maybe : PrivateInformationIncluded.customized;
|
|
|
|
}
|
|
|
|
|
|
|
|
capabilities.Add(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
return capabilities;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void CombineCapabilitiesLists()
|
|
|
|
{
|
|
|
|
List<Capability> combination = null;
|
|
|
|
|
|
|
|
foreach (List<Capability> capabilities in hostCapabilities.Values)
|
|
|
|
{
|
|
|
|
if (capabilities == null)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (combination == null)
|
|
|
|
{
|
|
|
|
combination = capabilities;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
combination = Helpers.ListsCommonItems<Capability>(combination, capabilities);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (combination == null || combination.Count <= 0)
|
|
|
|
{
|
|
|
|
new ThreeButtonDialog(
|
|
|
|
new ThreeButtonDialog.Details(
|
|
|
|
SystemIcons.Error,
|
|
|
|
Messages.SERVER_STATUS_REPORT_CAPABILITIES_FAILED,
|
|
|
|
Messages.SERVER_STATUS_REPORT)).ShowDialog(this);
|
|
|
|
|
|
|
|
cancelled = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_capabilities = combination;
|
|
|
|
|
|
|
|
_capabilities.Add(GetClientCapability());
|
|
|
|
|
|
|
|
Sort_capabilities();
|
|
|
|
|
|
|
|
buildList();
|
|
|
|
}
|
|
|
|
|
|
|
|
private Capability GetClientCapability()
|
|
|
|
{
|
|
|
|
Capability clientCap = new Capability();
|
|
|
|
clientCap.ContentType = ContentType.text_plain;
|
|
|
|
clientCap.DefaultChecked = true;
|
|
|
|
clientCap.Key = "client-logs";
|
|
|
|
clientCap.MaxSize = getLogSize();
|
|
|
|
clientCap.MinSize = clientCap.MaxSize;
|
|
|
|
clientCap.MaxTime = -1;
|
|
|
|
clientCap.MinTime = -1;
|
|
|
|
clientCap.PII = PrivateInformationIncluded.yes;
|
|
|
|
|
|
|
|
return clientCap;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Sort_capabilities()
|
|
|
|
{
|
|
|
|
_capabilities.Sort(new Comparison<Capability>(delegate(Capability obj1, Capability obj2)
|
|
|
|
{
|
|
|
|
int piicompare = obj1.PII.CompareTo(obj2.PII);
|
|
|
|
if (piicompare == 0)
|
|
|
|
return StringUtility.NaturalCompare(obj1.ToString(), obj2.ToString());
|
|
|
|
else
|
|
|
|
return piicompare;
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
2013-11-04 15:09:50 +01:00
|
|
|
private void OnCheckedCapabilitiesChanged()
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2013-11-04 15:09:50 +01:00
|
|
|
string totalSize, totalTime;
|
|
|
|
CalculateTotalSizeAndTime(out totalSize, out totalTime);
|
|
|
|
TotalSizeValue.Text = totalSize;
|
|
|
|
TotalTimeValue.Text = totalTime;
|
2013-06-24 13:41:48 +02:00
|
|
|
ClearButton.Enabled = wizardCheckAnyChecked();
|
|
|
|
SelectButton.Enabled = wizardCheckAnyUnchecked();
|
2013-11-04 15:09:50 +01:00
|
|
|
OnPageUpdated();
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void buildList()
|
|
|
|
{
|
2013-11-04 15:09:50 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
dataGridViewItems.SuspendLayout();
|
|
|
|
dataGridViewItems.Rows.Clear();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
2013-11-04 15:09:50 +01:00
|
|
|
var list = new List<DataGridViewRow>();
|
|
|
|
foreach (Capability c in _capabilities)
|
|
|
|
list.Add(new CapabilityRow(c));
|
|
|
|
|
|
|
|
dataGridViewItems.Rows.AddRange(list.ToArray());
|
|
|
|
}
|
|
|
|
finally
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2013-11-04 15:09:50 +01:00
|
|
|
dataGridViewItems.ResumeLayout();
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
2013-11-04 15:09:50 +01:00
|
|
|
|
|
|
|
OnCheckedCapabilitiesChanged();
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private long getLogSize()
|
|
|
|
{
|
|
|
|
String path = Program.GetLogFile_();
|
|
|
|
if (path != null)
|
|
|
|
{
|
|
|
|
// Size of XenCenter.log
|
|
|
|
FileInfo logFileInfo = new FileInfo(path);
|
|
|
|
long total = logFileInfo.Length;
|
|
|
|
|
|
|
|
// Add size of any XenCenter.log.x
|
|
|
|
DirectoryInfo di = new DirectoryInfo(Path.GetDirectoryName(path));
|
|
|
|
Regex regex = new Regex(Regex.Escape(Path.GetFileName(path)) + @"\.\d+");
|
|
|
|
foreach (FileInfo file in di.GetFiles())
|
|
|
|
{
|
|
|
|
if (regex.IsMatch(file.Name))
|
|
|
|
total += file.Length;
|
|
|
|
}
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 50 * Util.BINARY_MEGA;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 15:09:50 +01:00
|
|
|
private void CalculateTotalSizeAndTime(out string totalSize, out string totalTime)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2013-11-04 15:09:50 +01:00
|
|
|
var sizeMinList = new List<long>();
|
|
|
|
var sizeMaxList = new List<long>();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
2013-11-04 15:09:50 +01:00
|
|
|
var timeMinList = new List<long>();
|
|
|
|
var timeMaxList = new List<long>();
|
|
|
|
|
|
|
|
foreach (var row in dataGridViewItems.Rows)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2013-11-04 15:09:50 +01:00
|
|
|
var capRow = row as CapabilityRow;
|
|
|
|
if (capRow != null && capRow.Capability.Checked)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2013-11-04 15:09:50 +01:00
|
|
|
var c = capRow.Capability;
|
2013-06-24 13:41:48 +02:00
|
|
|
int m = c.Key == "client-logs" ? 1 : _hostList.Count;
|
2013-11-04 15:09:50 +01:00
|
|
|
|
|
|
|
sizeMinList.Add(c.MinSize * m);
|
|
|
|
sizeMaxList.Add(c.MaxSize * m);
|
|
|
|
|
|
|
|
timeMinList.Add(c.MinTime * m);
|
|
|
|
timeMaxList.Add(c.MaxTime * m);
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
}
|
2013-11-04 15:09:50 +01:00
|
|
|
totalSize = Helpers.StringFromMaxMinSizeList(sizeMinList, sizeMaxList);
|
|
|
|
totalTime = Helpers.StringFromMaxMinTimeList(timeMinList, timeMaxList);
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2013-11-04 15:09:50 +01:00
|
|
|
public IEnumerable<Capability> Capabilities
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2013-11-04 15:09:50 +01:00
|
|
|
return from DataGridViewRow row in dataGridViewItems.Rows
|
|
|
|
let capRow = row as CapabilityRow
|
|
|
|
where capRow != null && capRow.Capability.Checked
|
|
|
|
select capRow.Capability;
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#region Control event handlers
|
|
|
|
|
2013-11-04 15:09:50 +01:00
|
|
|
private void dataGridViewItems_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2013-11-04 15:09:50 +01:00
|
|
|
var row1 = dataGridViewItems.Rows[e.RowIndex1] as CapabilityRow;
|
|
|
|
var row2 = dataGridViewItems.Rows[e.RowIndex2] as CapabilityRow;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
2013-11-04 15:09:50 +01:00
|
|
|
if (row1 != null && row2 != null && e.Column.Index == columnImage.Index)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2013-11-04 15:09:50 +01:00
|
|
|
e.SortResult = row1.Capability.PII.CompareTo(row2.Capability.PII);
|
|
|
|
e.Handled = true;
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 15:09:50 +01:00
|
|
|
private void dataGridViewItems_SelectionChanged(object sender, EventArgs e)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2013-11-04 15:09:50 +01:00
|
|
|
if (dataGridViewItems.SelectedRows.Count > 0)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2013-11-04 15:09:50 +01:00
|
|
|
var row = dataGridViewItems.SelectedRows[0] as CapabilityRow;
|
|
|
|
if (row == null)
|
|
|
|
return;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
2013-11-04 15:09:50 +01:00
|
|
|
DescriptionValue.Text = row.Capability.Description;
|
|
|
|
SizeValue.Text = row.Capability.EstimatedSize;
|
|
|
|
TimeValue.Text = row.Capability.EstimatedTime;
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 15:09:50 +01:00
|
|
|
private void dataGridViewItems_CellClick(object sender, DataGridViewCellEventArgs e)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2013-11-04 15:09:50 +01:00
|
|
|
if (e.ColumnIndex != columnCheck.Index)
|
|
|
|
return;
|
|
|
|
if (e.RowIndex < 0 || e.RowIndex >= dataGridViewItems.RowCount)
|
|
|
|
return;
|
|
|
|
|
|
|
|
var row = dataGridViewItems.Rows[e.RowIndex] as CapabilityRow;
|
|
|
|
if (row == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
row.Capability.Checked = !row.Capability.Checked;
|
|
|
|
row.Update();
|
|
|
|
OnCheckedCapabilitiesChanged();
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
System.Diagnostics.Process.Start(InvisibleMessages.PRIVACY);
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
new ThreeButtonDialog(
|
|
|
|
new ThreeButtonDialog.Details(
|
|
|
|
SystemIcons.Error,
|
|
|
|
Messages.HOMEPAGE_ERROR_MESSAGE,
|
|
|
|
Messages.XENCENTER)).ShowDialog(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void SelectButton_Click(object sender, EventArgs e)
|
|
|
|
{
|
2013-11-04 15:09:50 +01:00
|
|
|
foreach (DataGridViewRow row in dataGridViewItems.Rows)
|
|
|
|
{
|
|
|
|
var capRow = row as CapabilityRow;
|
|
|
|
if (capRow != null && !capRow.Capability.Checked)
|
|
|
|
{
|
|
|
|
capRow.Capability.Checked = true;
|
|
|
|
capRow.Update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OnCheckedCapabilitiesChanged();
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void ClearButton_Click(object sender, EventArgs e)
|
|
|
|
{
|
2013-11-04 15:09:50 +01:00
|
|
|
foreach (DataGridViewRow row in dataGridViewItems.Rows)
|
|
|
|
{
|
|
|
|
var capRow = row as CapabilityRow;
|
|
|
|
if (capRow != null && capRow.Capability.Checked)
|
|
|
|
{
|
|
|
|
capRow.Capability.Checked = false;
|
|
|
|
capRow.Update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OnCheckedCapabilitiesChanged();
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
2013-11-04 15:09:50 +01:00
|
|
|
|
|
|
|
private class CapabilityRow : DataGridViewRow
|
|
|
|
{
|
|
|
|
public readonly Capability Capability;
|
|
|
|
|
|
|
|
private readonly DataGridViewCheckBoxCell cellCheck = new DataGridViewCheckBoxCell();
|
|
|
|
private readonly DataGridViewTextBoxCell cellItem = new DataGridViewTextBoxCell();
|
|
|
|
private readonly DataGridViewImageCell cellImage = new DataGridViewImageCell();
|
|
|
|
|
|
|
|
public CapabilityRow(Capability capability)
|
|
|
|
{
|
|
|
|
Capability = capability;
|
|
|
|
Cells.AddRange(cellCheck, cellItem, cellImage);
|
|
|
|
Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Update()
|
|
|
|
{
|
|
|
|
cellCheck.Value = Capability.Checked;
|
|
|
|
cellItem.Value = Capability.Name;
|
|
|
|
|
|
|
|
switch(Capability.PII)
|
|
|
|
{
|
|
|
|
case PrivateInformationIncluded.maybe:
|
2014-06-03 17:49:13 +02:00
|
|
|
cellImage.Value = Properties.Resources.alert2_16;
|
2013-11-04 15:09:50 +01:00
|
|
|
break;
|
|
|
|
case PrivateInformationIncluded.customized:
|
2014-06-03 17:49:13 +02:00
|
|
|
cellImage.Value = Properties.Resources.alert3_16;
|
2013-11-04 15:09:50 +01:00
|
|
|
break;
|
|
|
|
case PrivateInformationIncluded.no:
|
2014-06-03 17:49:13 +02:00
|
|
|
cellImage.Value = Properties.Resources.alert4_16;
|
2013-11-04 15:09:50 +01:00
|
|
|
break;
|
|
|
|
case PrivateInformationIncluded.yes:
|
|
|
|
default:
|
2014-06-03 17:49:13 +02:00
|
|
|
cellImage.Value = Properties.Resources.alert1_16;
|
2013-11-04 15:09:50 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
cellImage.ToolTipText = Capability.PiiText;
|
|
|
|
}
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public enum ContentType { text_plain, application_data };
|
|
|
|
|
|
|
|
public enum PrivateInformationIncluded { yes, maybe, customized, no};
|
|
|
|
|
|
|
|
public class Capability : IComparable<Capability>, IEquatable<Capability>
|
|
|
|
{
|
|
|
|
public ContentType ContentType;
|
|
|
|
bool _defaultChecked;
|
|
|
|
public long MaxSize;
|
|
|
|
public long MinSize;
|
|
|
|
public long MaxTime;
|
|
|
|
public long MinTime;
|
|
|
|
public PrivateInformationIncluded PII;
|
2013-11-04 15:09:50 +01:00
|
|
|
private string _key;
|
|
|
|
private string _name;
|
|
|
|
private string _description;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
public bool Checked;
|
|
|
|
|
|
|
|
public bool DefaultChecked
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return _defaultChecked;
|
|
|
|
}
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_defaultChecked = value;
|
|
|
|
Checked = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public string PiiText
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2013-11-04 15:09:50 +01:00
|
|
|
switch (PII)
|
|
|
|
{
|
|
|
|
case PrivateInformationIncluded.yes:
|
|
|
|
return Messages.PII_YES;
|
|
|
|
case PrivateInformationIncluded.maybe:
|
|
|
|
return Messages.PII_MAYBE;
|
|
|
|
case PrivateInformationIncluded.customized:
|
|
|
|
return Messages.PII_CUSTOMISED;
|
|
|
|
case PrivateInformationIncluded.no:
|
|
|
|
default:
|
|
|
|
return Messages.PII_NO;
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 15:09:50 +01:00
|
|
|
public string Key
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2013-11-04 15:09:50 +01:00
|
|
|
return _key;
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
2013-11-04 15:09:50 +01:00
|
|
|
set
|
|
|
|
{
|
|
|
|
_key = value;
|
|
|
|
|
|
|
|
_name = Core.PropertyManager.GetFriendlyName(string.Format("Label-host.system_status-{0}", _key));
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(_name))
|
|
|
|
_name = _key;
|
|
|
|
|
|
|
|
_description = Core.PropertyManager.GetFriendlyName(string.Format("Description-host.system_status-{0}", _key));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public string Name
|
|
|
|
{
|
|
|
|
get { return _name; }
|
|
|
|
}
|
|
|
|
|
|
|
|
public string Description
|
|
|
|
{
|
|
|
|
get { return _description; }
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public string EstimatedSize
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return Helpers.StringFromMaxMinSize(MinSize, MaxSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public string EstimatedTime
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return Helpers.StringFromMaxMinTime(MinTime, MaxTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
{
|
2013-11-04 15:09:50 +01:00
|
|
|
return _name;
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public int CompareTo(Capability other)
|
|
|
|
{
|
|
|
|
return StringUtility.NaturalCompare(this.Key, other.Key);
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool Equals(Capability other)
|
|
|
|
{
|
|
|
|
return this.Key.Equals(other.Key);
|
|
|
|
}
|
|
|
|
}
|
2013-11-04 15:09:50 +01:00
|
|
|
}
|