-
Notifications
You must be signed in to change notification settings - Fork 0
/
HsmComponent.cs
98 lines (71 loc) · 2.87 KB
/
HsmComponent.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using HSMActorModelPoC.HSMOperations;
using System.Data;
using HSMActorModelPoC.HSMStats;
namespace HSMActorModelPoC
{
public partial class HsmComponent : UserControl
{
#region Props
private int _number;
public int Number { get { return _number; } }
public int QueuedCommandCount { set { txtQueuedCount.Text = value.ToString(); } }
public int ProcessedCommandCount { set { txtProcessedCount.Text = value.ToString(); } }
public int LoadTps { set { txtLoadTPS.Text = value.ToString(); } }
public int MaxTps { set { txtMaxTPS.Text = value.ToString(); } }
public List<string> Keys { get { return lstCurKeys.Items.Cast<string>().ToList(); } }
#endregion
#region Constructors
public HsmComponent()
{
InitializeComponent();
}
public HsmComponent(int number)
{
InitializeComponent();
_number = number;
grpHSM.Text = "HSM #" + _number;
this.grpHSM.BackColor = Color.LightBlue;
}
#endregion
#region Events
private void lnkLblAddKey_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
var selectedKeyToAdd = lstKeys.SelectedItem as string;
if (selectedKeyToAdd != null && !lstCurKeys.Items.Contains(selectedKeyToAdd))
{
int index = 0;
for (index = 0; index < lstCurKeys.Items.Count; index++)
{
var item = lstCurKeys.Items[index];
if (item == null || item.ToString().CompareTo(selectedKeyToAdd) > 0) break;
}
lstCurKeys.Items.Insert(index, selectedKeyToAdd);
HSMKeyStore.AddKey(_number, selectedKeyToAdd);
}
}
private void lnkLblDelKey_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (lstCurKeys.SelectedItem is not null)
{
var key = lstCurKeys.SelectedItem as string;
lstCurKeys.Items.Remove(lstCurKeys.SelectedItem);
HSMKeyStore.RemoveKey(_number, key);
if (lstCurKeys.Items.Count > 0) lstCurKeys.SelectedIndex = lstCurKeys.Items.Count - 1;
}
}
#endregion
#region Methods
public void SetTPS()
{
var hsmStat = HsmClusterStats.GetHSMStat(_number);
if (hsmStat != null)
{
QueuedCommandCount = hsmStat.QueuedCommandCount;
ProcessedCommandCount = hsmStat.ProcessedCommandCount;
txtLoadTPS.Text = hsmStat.CurrentLoadTPS.ToString();
txtMaxTPS.Text = hsmStat.MaxTPS.ToString();
}
}
#endregion
}
}