replace as DoAction
This commit is contained in:
parent
1007492961
commit
f2b846465e
@ -168,7 +168,7 @@ namespace EduNetworkBuilder
|
||||
Network myNet = NB.GetNetwork();
|
||||
NetworkDevice source = myNet.GetDeviceFromID(SourceID);
|
||||
NetworkComponent sourceC = myNet.GetComponentFromID(SourceID);
|
||||
|
||||
NetworkLink sourceNL;
|
||||
switch (Action)
|
||||
{
|
||||
case NBAction.changecomponent:
|
||||
@ -182,9 +182,9 @@ namespace EduNetworkBuilder
|
||||
{ //It is a link. Delete the old, make the new. Mark as linked
|
||||
if(source != null)
|
||||
myNet.RemoveComponent(source);
|
||||
NetworkLink NL = (NetworkLink)ChangedComponent;
|
||||
myNet.MarkAsLinked(NL.Src, NL.GetUniqueIdentifier);
|
||||
myNet.MarkAsLinked(NL.Dst, NL.GetUniqueIdentifier);
|
||||
sourceNL = (NetworkLink)ChangedComponent;
|
||||
myNet.MarkAsLinked(sourceNL.Src, sourceNL.GetUniqueIdentifier);
|
||||
myNet.MarkAsLinked(sourceNL.Dst, sourceNL.GetUniqueIdentifier);
|
||||
myNet.AddItem(ChangedComponent);
|
||||
}
|
||||
break;
|
||||
@ -261,6 +261,30 @@ namespace EduNetworkBuilder
|
||||
source.TracerouteFromHere(Destination);
|
||||
break;
|
||||
case NBAction.replace:
|
||||
if(sourceC is NetworkDevice)
|
||||
{
|
||||
source.ClearIPs(); //reset the device
|
||||
source.IsBurned = false; //If it had been burned before, it is no longer burned
|
||||
source.PowerOff = true;
|
||||
source.BadSprayCount = 0;
|
||||
//Mark the replace test as "done"
|
||||
myNet.RegisterDeviceReset(source.hostname); //replacing something powers it off
|
||||
|
||||
myNet.RegisterDeviceReplaced(source.hostname); //replace it.
|
||||
}
|
||||
else if (sourceC is NetworkLink)
|
||||
{
|
||||
sourceNL = (NetworkLink)sourceC;
|
||||
|
||||
if (sourceNL.theLinkType != LinkType.wireless)
|
||||
{
|
||||
HostNicID sourceID = sourceNL.Src;
|
||||
HostNicID destID = sourceNL.Dst;
|
||||
myNet.RemoveComponent(sourceNL);
|
||||
NetworkLink nNL = new NetworkLink(sourceID, destID, LinkType.normal);
|
||||
myNet.AddItem(nNL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NBAction.replaceUPS:
|
||||
myNet.RegisterUPSAdded(source.hostname);
|
||||
|
@ -1194,16 +1194,18 @@ namespace EduNetworkBuilder
|
||||
{
|
||||
if (ItemClickedOn != null)
|
||||
{
|
||||
if (ItemClickedOn == null) return;
|
||||
ItemClickedOn.ClearIPs(); //reset the device
|
||||
ItemClickedOn.IsBurned = false; //If it had been burned before, it is no longer burned
|
||||
ItemClickedOn.PowerOff = true;
|
||||
ItemClickedOn.BadSprayCount = 0;
|
||||
NB.DoActionChangeComponent(ItemClickedOn);
|
||||
//Mark the replace test as "done"
|
||||
myNetwork.RegisterDeviceReset(ItemClickedOn.hostname); //replacing something powers it off
|
||||
|
||||
myNetwork.RegisterDeviceReplaced(ItemClickedOn.hostname); //replace it.
|
||||
//ItemClickedOn.ClearIPs(); //reset the device
|
||||
//ItemClickedOn.IsBurned = false; //If it had been burned before, it is no longer burned
|
||||
//ItemClickedOn.PowerOff = true;
|
||||
//ItemClickedOn.BadSprayCount = 0;
|
||||
//NB.DoActionChangeComponent(ItemClickedOn);
|
||||
////Mark the replace test as "done"
|
||||
//myNetwork.RegisterDeviceReset(ItemClickedOn.hostname); //replacing something powers it off
|
||||
|
||||
//myNetwork.RegisterDeviceReplaced(ItemClickedOn.hostname); //replace it.
|
||||
NB.DoActionReplaceDevice(ItemClickedOn.GetUniqueIdentifier);
|
||||
|
||||
UpdateVisuals();
|
||||
}
|
||||
}
|
||||
@ -1298,15 +1300,16 @@ namespace EduNetworkBuilder
|
||||
if (thing.Tag != null)
|
||||
{
|
||||
NetworkLink NL = (NetworkLink)thing.Tag;
|
||||
//This may delete the old link and make a new one
|
||||
if (NL.theLinkType != LinkType.wireless)
|
||||
{
|
||||
HostNicID source = NL.Src;
|
||||
HostNicID dest = NL.Dst;
|
||||
myNetwork.RemoveComponent(NL);
|
||||
NetworkLink nNL = new NetworkLink(source, dest, LinkType.normal);
|
||||
myNetwork.AddItem(nNL);
|
||||
}
|
||||
////This may delete the old link and make a new one
|
||||
//if (NL.theLinkType != LinkType.wireless)
|
||||
//{
|
||||
// HostNicID source = NL.Src;
|
||||
// HostNicID dest = NL.Dst;
|
||||
// myNetwork.RemoveComponent(NL);
|
||||
// NetworkLink nNL = new NetworkLink(source, dest, LinkType.normal);
|
||||
// myNetwork.AddItem(nNL);
|
||||
//}
|
||||
NB.DoActionReplaceDevice(NL.GetUniqueIdentifier);
|
||||
}
|
||||
myNetwork.TestForCompletion(true);
|
||||
pbNetworkView.Update();
|
||||
|
Loading…
Reference in New Issue
Block a user