replace as DoAction
This commit is contained in:
parent
1007492961
commit
f2b846465e
@ -168,7 +168,7 @@ namespace EduNetworkBuilder
|
|||||||
Network myNet = NB.GetNetwork();
|
Network myNet = NB.GetNetwork();
|
||||||
NetworkDevice source = myNet.GetDeviceFromID(SourceID);
|
NetworkDevice source = myNet.GetDeviceFromID(SourceID);
|
||||||
NetworkComponent sourceC = myNet.GetComponentFromID(SourceID);
|
NetworkComponent sourceC = myNet.GetComponentFromID(SourceID);
|
||||||
|
NetworkLink sourceNL;
|
||||||
switch (Action)
|
switch (Action)
|
||||||
{
|
{
|
||||||
case NBAction.changecomponent:
|
case NBAction.changecomponent:
|
||||||
@ -182,9 +182,9 @@ namespace EduNetworkBuilder
|
|||||||
{ //It is a link. Delete the old, make the new. Mark as linked
|
{ //It is a link. Delete the old, make the new. Mark as linked
|
||||||
if(source != null)
|
if(source != null)
|
||||||
myNet.RemoveComponent(source);
|
myNet.RemoveComponent(source);
|
||||||
NetworkLink NL = (NetworkLink)ChangedComponent;
|
sourceNL = (NetworkLink)ChangedComponent;
|
||||||
myNet.MarkAsLinked(NL.Src, NL.GetUniqueIdentifier);
|
myNet.MarkAsLinked(sourceNL.Src, sourceNL.GetUniqueIdentifier);
|
||||||
myNet.MarkAsLinked(NL.Dst, NL.GetUniqueIdentifier);
|
myNet.MarkAsLinked(sourceNL.Dst, sourceNL.GetUniqueIdentifier);
|
||||||
myNet.AddItem(ChangedComponent);
|
myNet.AddItem(ChangedComponent);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -261,6 +261,30 @@ namespace EduNetworkBuilder
|
|||||||
source.TracerouteFromHere(Destination);
|
source.TracerouteFromHere(Destination);
|
||||||
break;
|
break;
|
||||||
case NBAction.replace:
|
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;
|
break;
|
||||||
case NBAction.replaceUPS:
|
case NBAction.replaceUPS:
|
||||||
myNet.RegisterUPSAdded(source.hostname);
|
myNet.RegisterUPSAdded(source.hostname);
|
||||||
|
@ -1194,16 +1194,18 @@ namespace EduNetworkBuilder
|
|||||||
{
|
{
|
||||||
if (ItemClickedOn != null)
|
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();
|
UpdateVisuals();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1298,15 +1300,16 @@ namespace EduNetworkBuilder
|
|||||||
if (thing.Tag != null)
|
if (thing.Tag != null)
|
||||||
{
|
{
|
||||||
NetworkLink NL = (NetworkLink)thing.Tag;
|
NetworkLink NL = (NetworkLink)thing.Tag;
|
||||||
//This may delete the old link and make a new one
|
////This may delete the old link and make a new one
|
||||||
if (NL.theLinkType != LinkType.wireless)
|
//if (NL.theLinkType != LinkType.wireless)
|
||||||
{
|
//{
|
||||||
HostNicID source = NL.Src;
|
// HostNicID source = NL.Src;
|
||||||
HostNicID dest = NL.Dst;
|
// HostNicID dest = NL.Dst;
|
||||||
myNetwork.RemoveComponent(NL);
|
// myNetwork.RemoveComponent(NL);
|
||||||
NetworkLink nNL = new NetworkLink(source, dest, LinkType.normal);
|
// NetworkLink nNL = new NetworkLink(source, dest, LinkType.normal);
|
||||||
myNetwork.AddItem(nNL);
|
// myNetwork.AddItem(nNL);
|
||||||
}
|
//}
|
||||||
|
NB.DoActionReplaceDevice(NL.GetUniqueIdentifier);
|
||||||
}
|
}
|
||||||
myNetwork.TestForCompletion(true);
|
myNetwork.TestForCompletion(true);
|
||||||
pbNetworkView.Update();
|
pbNetworkView.Update();
|
||||||
|
Loading…
Reference in New Issue
Block a user