diff --git a/EduNetworkBuilder/ActionClass.cs b/EduNetworkBuilder/ActionClass.cs index 20a6367..b250d37 100644 --- a/EduNetworkBuilder/ActionClass.cs +++ b/EduNetworkBuilder/ActionClass.cs @@ -62,12 +62,12 @@ namespace EduNetworkBuilder } } - public ActionClass RunAction(int WhichIndex) + public ActionClass RunAction(int WhichIndex, bool NoteAllChanges = false) { if (CurrentNetAction == null) return null; if (WhichIndex < CurrentNetAction.Actions.Count) { - CurrentNetAction.Actions[WhichIndex].DoAction(); + CurrentNetAction.Actions[WhichIndex].DoAction(NoteAllChanges); return CurrentNetAction.Actions[WhichIndex]; } return null; @@ -180,19 +180,21 @@ namespace EduNetworkBuilder public NetworkComponentType newItemType = NetworkComponentType.none; //Making new device public NetworkComponent ChangedComponent = null; - public void DoAction() + public void DoAction(bool NoteAllChanges=false) { Network myNet = NB.GetNetwork(); NetworkDevice source = myNet.GetDeviceFromID(SourceID); NetworkComponent sourceC = myNet.GetComponentFromID(SourceID); NetworkLink sourceNL; + string indent = " "; switch (Action) { case NBAction.changecomponent: //This could be a link or a device we are changing. if(ChangedComponent is NetworkDevice) { - source.UpdateFromComponent(ChangedComponent); //Copy any changes across + if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_ChangeDevice") + " " + source.hostname); } + source.UpdateFromComponent(ChangedComponent, NoteAllChanges); //Copy any changes across source.SetImageFromType(); //The image was not saved. Re-make it } else @@ -200,6 +202,7 @@ namespace EduNetworkBuilder if(source != null) myNet.RemoveComponent(source); sourceNL = (NetworkLink)ChangedComponent; + if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_Replace_Link") + " " + sourceNL.Src.HostName + " - " + sourceNL.Dst.HostName); } myNet.MarkAsLinked(sourceNL.Src, sourceNL.GetUniqueIdentifier); myNet.MarkAsLinked(sourceNL.Dst, sourceNL.GetUniqueIdentifier); myNet.AddItem(ChangedComponent); @@ -212,6 +215,7 @@ namespace EduNetworkBuilder source.ChangeLocation(Location); source.UnHide(); //In case it was hidden if (NB.DebugActions) { Console.WriteLine("Changing location for: " + source + " " + Location.X + ":" +Location.Y); } + if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_MoveDevice") + " " + source.hostname + " - " +Location.X + ":" + Location.Y); } } break; case NBAction.deletecomponent: @@ -228,6 +232,7 @@ namespace EduNetworkBuilder } myNet.RemoveComponent(source); if (NB.DebugActions) { Console.WriteLine("Deleting a device: " + source.hostname); } + if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_DeleteDevice") + " " + source.hostname + " - " + source.myType.ToString()); } } else if(sourceC != null && sourceC is NetworkLink) { if (myNet.ItemIsCritical(sourceC.hostname)) @@ -236,6 +241,7 @@ namespace EduNetworkBuilder SourceL.Destroy(); //Mark both ends as being deleted myNet.RemoveComponent(SourceL); //Get rid of this link if (NB.DebugActions) { Console.WriteLine("Deleting a link: " + source.hostname); } + if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_DeleteLink") + " " + SourceL.Src.HostName + " - " + SourceL.Dst.HostName); } } break; case NBAction.newdevice: @@ -254,13 +260,15 @@ namespace EduNetworkBuilder if (myNet.BlockedByTree(BottomLeft)) CanDo = false; if (CanDo) { - ChangedComponent = (NetworkDevice)myNet.AddItem(newItemType, Location); - if (NB.DebugActions && source != null) { Console.WriteLine("Adding a Device: " + source.hostname); } + NetworkDevice newdevice = (NetworkDevice)myNet.AddItem(newItemType, Location); + + if (NB.DebugActions && source != null) { Console.WriteLine("Adding a Device: " + newdevice.hostname); } + if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_AddDevice") + " " + newdevice.hostname + " - " + newdevice.myType.ToString()); } } else { NB.SetBuilderWindowStatis(NB.Translate("NB_TreePlacementError")); - if (NB.DebugActions) { Console.WriteLine("Unable to add device: " + source.hostname); } + if (NB.DebugActions) { Console.WriteLine("Unable to add device: " + ChangedComponent.hostname); } } break; case NBAction.dhcp: @@ -268,27 +276,33 @@ namespace EduNetworkBuilder { source.DHCPRequestFromHere(); if (NB.DebugActions) { Console.WriteLine("Requesting DHCP: " + source.hostname); } + if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_RequestDHCP") + " " + source.hostname); } } break; case NBAction.arp: if (source != null) { + //We have not implimented this well. But, here it is anyway. We would do this if showing ethernet stuff source.AskArpFromHere(Destination); - if (NB.DebugActions) { Console.WriteLine("Requesting DHCP: " + source.hostname); } + if (NB.DebugActions) { Console.WriteLine("Requesting ARP: " + source.hostname); } + if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_RequestARP") + " " + source.hostname + " - " + Destination.GetIPString); } } break; case NBAction.cleararp: if (source != null) { + //We have not implimented this well. But, here it is anyway. We would do this if showing ethernet stuff source.ClearArps(); if (NB.DebugActions) { Console.WriteLine("Clearing ARP: " + source.hostname); } + if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_ClearArp") + " " + source.hostname + " - " + Destination.GetIPString); } } break; case NBAction.ping: if (source != null) { source.PingFromHere(Destination); - if (NB.DebugActions) { Console.WriteLine("Pinging " + Destination.GetIPString + " from " + source.hostname); } + if (NB.DebugActions) { Console.WriteLine("Pinging " + Destination.GetIPString + " from " + source.hostname); } + if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_DoPing") + " " + source.hostname + " - " + Destination.GetIPString); } } break; case NBAction.traceroute: @@ -296,6 +310,7 @@ namespace EduNetworkBuilder { source.TracerouteFromHere(Destination); if (NB.DebugActions) { Console.WriteLine("Traceroute: " + Destination.GetIPString + " from " + source.hostname); } + if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_DoTraceroute") + " " + source.hostname + " - " + Destination.GetIPString ); } } break; case NBAction.replace: @@ -310,6 +325,7 @@ namespace EduNetworkBuilder myNet.RegisterDeviceReplaced(source.hostname); //replace it. if (NB.DebugActions) { Console.WriteLine("Replacing device: " + source.hostname); } + if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_Replace_Device") + " " + source.hostname); } } else if (sourceC is NetworkLink) { @@ -322,27 +338,32 @@ namespace EduNetworkBuilder myNet.RemoveComponent(sourceNL); NetworkLink nNL = new NetworkLink(sourceID, destID, LinkType.normal); myNet.AddItem(nNL); - if (NB.DebugActions) { Console.WriteLine("Replacing link: " + source.hostname); } + if (NB.DebugActions) { Console.WriteLine("Replacing link: " + sourceID.HostName + " - " + destID.HostName); } + if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_Replace_Link") + " " + sourceID.HostName + " - " + destID.HostName); } } } break; case NBAction.replaceUPS: myNet.RegisterUPSAdded(source.hostname); if (NB.DebugActions) { Console.WriteLine("Replacing UPS on: " + source.hostname); } + if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_Replace_UPS") + " " + source.hostname); } break; case NBAction.poweroff: source.PowerOff = true; myNet.RegisterDeviceReset(source.hostname); if (NB.DebugActions) { Console.WriteLine("Powering off: " + source.hostname); } + if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_Powering_OFF") + " " + source.hostname); } break; case NBAction.poweron: source.PowerOff = false; if (NB.DebugActions) { Console.WriteLine("Powering on: " + source.hostname); } + if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_Powering_ON") + " " + source.hostname); } //We might see about exploding the device here. break; case NBAction.reset: source.ClearIPs(); //reset the device - IPs and VLANs if (NB.DebugActions) { Console.WriteLine("Resetting: " + source.hostname); } + if (NoteAllChanges) { NB.AddNetMessage("", indent + NB.Translate("AC_Resetting") + " " + source.hostname); } //We might see about exploding the device here. break; diff --git a/EduNetworkBuilder/EduNetworkBuilder.csproj b/EduNetworkBuilder/EduNetworkBuilder.csproj index ba76e26..d511b4b 100644 --- a/EduNetworkBuilder/EduNetworkBuilder.csproj +++ b/EduNetworkBuilder/EduNetworkBuilder.csproj @@ -1,5 +1,6 @@  + Debug @@ -28,11 +29,13 @@ Tim Young true publish.htm - 53 + 54 1.0.0.%2a false true true + + AnyCPU @@ -263,6 +266,7 @@ VLANConfig.cs + SettingsSingleFileGenerator Settings.Designer.cs @@ -475,6 +479,12 @@ + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + +