If needs ups, power starts off off. More Needs UPS stuff.

This commit is contained in:
Tim Young 2018-02-16 12:45:08 +00:00
parent dc1d22b2d4
commit f397456649
3 changed files with 45 additions and 0 deletions

View File

@ -733,6 +733,11 @@ namespace EduNetworkBuilder
NetworkDevice ND = DeviceFromName(nt.sHost);
if (ND != null) ND.PowerOff = true;
}
if (nt.TheTest == NetTestType.DeviceNeedsUPS && !nt.TaskWasDone)
{
NetworkDevice ND = DeviceFromName(nt.sHost);
if (ND != null) ND.PowerOff = true;
}
}
if (report_as_done && PuzzleCount == 0 && PreviouslyUnsolved)
{
@ -1741,6 +1746,17 @@ namespace EduNetworkBuilder
}
}
public void RegisterUPSAdded(string source)
{
foreach (NetTest one in NetTests)
{
if (one.sHost == source && one.TheTest == NetTestType.DeviceNeedsUPS)
{
one.SetDone();
}
}
}
/****************************************
* Do On All Devices
* **************************************/

View File

@ -887,6 +887,16 @@ namespace EduNetworkBuilder
pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_Replace_Click;
}
}
if (myNetwork.ItemHasTest(ReleasedOn.hostname, NetTestType.DeviceNeedsUPS))
{
if (!myNetwork.ItemTestIsComplete(ReleasedOn.hostname, NetTestType.DeviceNeedsUPS))
{
//If the item is bad and has not been replaced, then add a context menu to replace it
pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("NB_AddUPS"));
pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_AddUPS_Click;
}
}
}
}
else //we are locked out.
@ -989,6 +999,21 @@ namespace EduNetworkBuilder
UpdateVisuals();
}
}
//We will still do this for devices that are spraying the network
private void pbNetworkView_AddUPS_Click(object sender, EventArgs e)
{
if (ItemClickedOn != null)
{
if (ItemClickedOn == null) return;
//Changing a UPS makes sure the power is off when done.
ItemClickedOn.PowerOff = true;
//Mark the replace test as "done"
myNetwork.RegisterDeviceReset(ItemClickedOn.hostname); //replacing something powers it off
myNetwork.RegisterUPSAdded(ItemClickedOn.hostname); //Add the UPS.
UpdateVisuals();
}
}
private void ColorizeDevice(NetworkDevice Item, string Text)
{

View File

@ -2001,6 +2001,10 @@
<value>The device is not responding.</value>
<comment>NC_Burned = The device is not responding.</comment>
</data>
<data name="NB_AddUPS" xml:space="preserve">
<value>Add UPS</value>
<comment>NB_AddUPS = Add UPS</comment>
</data>
<data name="NT_TstDescriptFrozenDevice" xml:space="preserve">
<value>Device is Frozen</value>
<comment>NT_TstDescriptFrozenDevice</comment>