Compare commits

4 Commits

12 changed files with 379 additions and 46 deletions

View File

@ -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;

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\WiX.3.11.2\build\wix.props" Condition="Exists('..\packages\WiX.3.11.2\build\wix.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -28,11 +29,13 @@
<PublisherName>Tim Young</PublisherName>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage>
<ApplicationRevision>53</ApplicationRevision>
<ApplicationRevision>54</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -263,6 +266,7 @@
<DependentUpon>VLANConfig.cs</DependentUpon>
</EmbeddedResource>
<None Include="EduNetworkBuilder_TemporaryKey.pfx" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@ -475,6 +479,12 @@
<Content Include="Resources\NBIco.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>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}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\WiX.3.11.2\build\wix.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\WiX.3.11.2\build\wix.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View File

@ -35,53 +35,63 @@
this.btnLink = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.cbLinkType = new System.Windows.Forms.ComboBox();
this.pbSource = new System.Windows.Forms.PictureBox();
this.pbDest = new System.Windows.Forms.PictureBox();
this.lblInstructions = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pbSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pbDest)).BeginInit();
this.SuspendLayout();
//
// lbSrcHost
//
this.lbSrcHost.FormattingEnabled = true;
this.lbSrcHost.ItemHeight = 16;
this.lbSrcHost.Location = new System.Drawing.Point(9, 18);
this.lbSrcHost.ItemHeight = 29;
this.lbSrcHost.Location = new System.Drawing.Point(20, 185);
this.lbSrcHost.Margin = new System.Windows.Forms.Padding(5);
this.lbSrcHost.Name = "lbSrcHost";
this.lbSrcHost.Size = new System.Drawing.Size(103, 84);
this.lbSrcHost.Size = new System.Drawing.Size(177, 149);
this.lbSrcHost.TabIndex = 0;
this.lbSrcHost.SelectedIndexChanged += new System.EventHandler(this.lbSrcHost_SelectedIndexChanged);
//
// lbSrcNic
//
this.lbSrcNic.FormattingEnabled = true;
this.lbSrcNic.ItemHeight = 16;
this.lbSrcNic.Location = new System.Drawing.Point(118, 18);
this.lbSrcNic.ItemHeight = 29;
this.lbSrcNic.Location = new System.Drawing.Point(210, 185);
this.lbSrcNic.Margin = new System.Windows.Forms.Padding(5);
this.lbSrcNic.Name = "lbSrcNic";
this.lbSrcNic.Size = new System.Drawing.Size(89, 84);
this.lbSrcNic.Size = new System.Drawing.Size(153, 149);
this.lbSrcNic.TabIndex = 1;
this.lbSrcNic.SelectedIndexChanged += new System.EventHandler(this.lbSrcNic_SelectedIndexChanged);
//
// lbDstNic
//
this.lbDstNic.FormattingEnabled = true;
this.lbDstNic.ItemHeight = 16;
this.lbDstNic.Location = new System.Drawing.Point(399, 18);
this.lbDstNic.ItemHeight = 29;
this.lbDstNic.Location = new System.Drawing.Point(702, 185);
this.lbDstNic.Margin = new System.Windows.Forms.Padding(5);
this.lbDstNic.Name = "lbDstNic";
this.lbDstNic.Size = new System.Drawing.Size(89, 84);
this.lbDstNic.Size = new System.Drawing.Size(153, 149);
this.lbDstNic.TabIndex = 3;
this.lbDstNic.SelectedIndexChanged += new System.EventHandler(this.lbDstNic_SelectedIndexChanged);
//
// lbDstHost
//
this.lbDstHost.FormattingEnabled = true;
this.lbDstHost.ItemHeight = 16;
this.lbDstHost.Location = new System.Drawing.Point(290, 18);
this.lbDstHost.ItemHeight = 29;
this.lbDstHost.Location = new System.Drawing.Point(512, 185);
this.lbDstHost.Margin = new System.Windows.Forms.Padding(5);
this.lbDstHost.Name = "lbDstHost";
this.lbDstHost.Size = new System.Drawing.Size(103, 84);
this.lbDstHost.Size = new System.Drawing.Size(177, 149);
this.lbDstHost.TabIndex = 2;
this.lbDstHost.SelectedIndexChanged += new System.EventHandler(this.lbDstHost_SelectedIndexChanged);
//
// btnLink
//
this.btnLink.Location = new System.Drawing.Point(210, 18);
this.btnLink.Location = new System.Drawing.Point(372, 185);
this.btnLink.Margin = new System.Windows.Forms.Padding(5);
this.btnLink.Name = "btnLink";
this.btnLink.Size = new System.Drawing.Size(75, 23);
this.btnLink.Size = new System.Drawing.Size(131, 42);
this.btnLink.TabIndex = 4;
this.btnLink.Text = "Link";
this.btnLink.UseVisualStyleBackColor = true;
@ -89,9 +99,10 @@
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(210, 47);
this.btnCancel.Location = new System.Drawing.Point(372, 237);
this.btnCancel.Margin = new System.Windows.Forms.Padding(5);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.Size = new System.Drawing.Size(131, 42);
this.btnCancel.TabIndex = 5;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
@ -100,16 +111,47 @@
// cbLinkType
//
this.cbLinkType.FormattingEnabled = true;
this.cbLinkType.Location = new System.Drawing.Point(210, 76);
this.cbLinkType.Location = new System.Drawing.Point(372, 290);
this.cbLinkType.Margin = new System.Windows.Forms.Padding(5);
this.cbLinkType.Name = "cbLinkType";
this.cbLinkType.Size = new System.Drawing.Size(75, 24);
this.cbLinkType.Size = new System.Drawing.Size(128, 37);
this.cbLinkType.TabIndex = 6;
//
// pbSource
//
this.pbSource.Location = new System.Drawing.Point(120, 28);
this.pbSource.Name = "pbSource";
this.pbSource.Size = new System.Drawing.Size(167, 149);
this.pbSource.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pbSource.TabIndex = 7;
this.pbSource.TabStop = false;
//
// pbDest
//
this.pbDest.Location = new System.Drawing.Point(607, 28);
this.pbDest.Name = "pbDest";
this.pbDest.Size = new System.Drawing.Size(167, 149);
this.pbDest.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pbDest.TabIndex = 8;
this.pbDest.TabStop = false;
//
// lblInstructions
//
this.lblInstructions.AutoSize = true;
this.lblInstructions.Location = new System.Drawing.Point(15, 351);
this.lblInstructions.Name = "lblInstructions";
this.lblInstructions.Size = new System.Drawing.Size(79, 29);
this.lblInstructions.TabIndex = 9;
this.lblInstructions.Text = "label1";
//
// LinkEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleDimensions = new System.Drawing.SizeF(14F, 29F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(495, 117);
this.ClientSize = new System.Drawing.Size(866, 389);
this.Controls.Add(this.lblInstructions);
this.Controls.Add(this.pbDest);
this.Controls.Add(this.pbSource);
this.Controls.Add(this.cbLinkType);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnLink);
@ -119,10 +161,14 @@
this.Controls.Add(this.lbSrcHost);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Icon = global::EduNetworkBuilder.Properties.Resources.NBIco;
this.Margin = new System.Windows.Forms.Padding(5);
this.Name = "LinkEditor";
this.Text = "LinkEditor";
this.Shown += new System.EventHandler(this.LinkEditor_Shown);
((System.ComponentModel.ISupportInitialize)(this.pbSource)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pbDest)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
@ -135,5 +181,8 @@
private System.Windows.Forms.Button btnLink;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.ComboBox cbLinkType;
private System.Windows.Forms.PictureBox pbSource;
private System.Windows.Forms.PictureBox pbDest;
private System.Windows.Forms.Label lblInstructions;
}
}

View File

@ -45,6 +45,7 @@ namespace EduNetworkBuilder
lbSrcHost.SelectedIndex = tindex;
UpdateDeviceList();
}
pbSource.Image = new Bitmap(Source.GetImage());
}
if (Dest != null)
{
@ -54,6 +55,7 @@ namespace EduNetworkBuilder
lbDstHost.SelectedIndex = tindex;
UpdateDeviceList();
}
pbDest.Image = new Bitmap(Dest.GetImage());
}
}
@ -86,11 +88,12 @@ namespace EduNetworkBuilder
if (lbDstHost.SelectedItem != null)
DstHost = lbDstHost.SelectedItem.ToString();
string SrcNic = "";
NetworkDevice Src = null;
if (lbSrcNic.SelectedItem != null)
{
Src = myNet.DeviceFromName(lbSrcHost.SelectedItem.ToString());
SrcNic = lbSrcNic.SelectedItem.ToString();
int sNicIndex = lbSrcNic.SelectedIndex;
NetworkDevice Src = myNet.DeviceFromName(lbSrcHost.SelectedItem.ToString());
NetworkCard sNic = null;
if(Src != null) sNic = Src.NicFromName(lbSrcNic.SelectedItem.ToString());
if(sNic != null) srcNicType = sNic.GetNicType;
@ -176,7 +179,34 @@ namespace EduNetworkBuilder
lbDstNic.SelectedIndex = tint;
}
if(lbDstNic.SelectedIndex > -1 && lbSrcNic.SelectedIndex > -1)
if (lbSrcHost.SelectedItem != null)
{
Src = myNet.DeviceFromName(lbSrcHost.SelectedItem.ToString());
pbSource.Image = Src.GetImage();
pbSource.Invalidate();
}
else
{
pbSource.Image = null;
pbSource.Invalidate();
}
if (lbDstHost.SelectedItem != null)
{
NetworkDevice Dest = myNet.DeviceFromName(lbDstHost.SelectedItem.ToString());
if (Dest != null)
{
pbDest.Image = Dest.GetImage();
pbDest.Invalidate();
}
}
else
{
pbDest.Image = null;
pbDest.Invalidate();
}
if (lbDstNic.SelectedIndex > -1 && lbSrcNic.SelectedIndex > -1)
{
btnLink.Enabled = true;
}
@ -202,6 +232,43 @@ namespace EduNetworkBuilder
cbLinkType.SelectedItem = theLinkType;
else
cbLinkType.SelectedIndex = 0;
//Update the instructions.
lblInstructions.Text = ""; //empty them out if we do not need instructions
lbSrcHost.ResetForeColor() ;
lbSrcNic.ResetForeColor();
lbDstHost.ResetForeColor();
lbDstNic.ResetForeColor();
btnLink.ForeColor = Color.Black;
if (lbSrcHost.SelectedItem == null)
{
lblInstructions.Text = "Choose the source device.";
lbSrcHost.ForeColor = Color.Red;
}
else if (lbSrcNic.SelectedItem == null)
{
lblInstructions.Text = "Choose the NIC / Port on the source device.";
lbSrcNic.ForeColor = Color.Red;
}
else if (lbDstHost.SelectedItem == null)
{
lblInstructions.Text = "Choose the destination device.";
lbDstHost.ForeColor = Color.Red;
}
else if (lbDstNic.SelectedItem == null)
{
lblInstructions.Text = "Choose the NIC / Port on the destination device.";
lbDstNic.ForeColor = Color.Red;
}
else
{
//We have a valid link. We are ready to press the link.
lblInstructions.Text = "This is a valid link. Press LINK to continue";
btnLink.ForeColor = Color.Red;
}
processing = false;
}

View File

@ -1078,6 +1078,14 @@ namespace EduNetworkBuilder
return randomizedList;
}
public static void AddNetMessage(string host, string message)
{
Network thenet = GetNetwork();
//Console.WriteLine("Adding message: " + host + " : " + message);
if (thenet == null) return; //we cannot add it. do not blow up
thenet.AddMessage(new PacketMessage(host, message));
}
public static bool OpenURLInExternalBrowser(string URL)
{
Uri uriResult;

View File

@ -1696,7 +1696,7 @@ namespace EduNetworkBuilder
//We are doing a replay and enough time has passed from the last replay...
NBSettings Settings = NB.GetSettings();
ActionCollection AC = Settings.GetUserActionCollection();
ActionClass Success = AC.RunAction(NextReplayIndex++);
ActionClass Success = AC.RunAction(NextReplayIndex++, true); //note all changes as we do them
NextReplayAction = DateTime.UtcNow.AddMilliseconds(NB.MillisecondsBetweenReplays);

View File

@ -978,6 +978,17 @@ namespace EduNetworkBuilder
return null;
}
public string AllInterfacesString(bool UseCidr= false)
{
string thestring = "";
foreach (NetworkInterface oneIF in interfaces)
{
if (thestring != "") thestring += ",";
thestring += oneIF.InterfaceString(UseCidr);
}
return thestring;
}
public NB_IPAddress FirstIP()
{
List<NB_IPAddress> addresses = IPAddressList();

View File

@ -99,7 +99,7 @@ namespace EduNetworkBuilder
{
}
public virtual void UpdateFromComponent(NetworkComponent CopyFrom)
public virtual void UpdateFromComponent(NetworkComponent CopyFrom, bool NoteAllChanges = false)
{
}

View File

@ -755,6 +755,15 @@ namespace EduNetworkBuilder
}
}
/// <summary>
/// Return a copy of the image for this device
/// </summary>
/// <returns></returns>
public Image GetImage()
{
return new Bitmap(MyImage);
}
//This function heavily borrowed from: http://stackoverflow.com/questions/1563038/fast-work-with-bitmaps-in-c-sharp
public Image ColoredImage(Image BaseImage)
{
@ -1509,28 +1518,109 @@ namespace EduNetworkBuilder
return arps;
}
public override void UpdateFromComponent(NetworkComponent CopyFrom)
public override void UpdateFromComponent(NetworkComponent CopyFrom, bool NoteAllChanges = false)
{
if (CopyFrom.GetType() != this.GetType()) return; //we cannot copy from it if it is different
NetworkDevice ndCopyFrom = (NetworkDevice)CopyFrom;
if (Object.ReferenceEquals(this, CopyFrom)) return; //No need to copy values to itself
hostname = ndCopyFrom.hostname;
Network mainnet = NB.GetNetwork();
string indent = " ";
//if(NoteAllChanges && mainnet != null) mainnet.AddMessage(new PacketMessage("", indent + NB.Translate("NDUpdateComponent")));
if (hostname != ndCopyFrom.hostname)
{
if (NoteAllChanges && mainnet != null) mainnet.AddMessage(new PacketMessage("", indent + "hostname: " + hostname + " -> " + ndCopyFrom.hostname));
hostname = ndCopyFrom.hostname;
}
Size = ndCopyFrom.Size;
DefaultGW = ndCopyFrom.DefaultGW;
if (DefaultGW.GetIPString != ndCopyFrom.DefaultGW.GetIPString)
{
if (NoteAllChanges && mainnet != null) mainnet.AddMessage(new PacketMessage("", indent + "DefaultGW: " + DefaultGW.GetIPString + " -> " + ndCopyFrom.DefaultGW.GetIPString));
DefaultGW = ndCopyFrom.DefaultGW;
}
if (ndCopyFrom.MyImage != null)
MyImage = new Bitmap(ndCopyFrom.MyImage);
else
MyImage = null;
CanAddNics = ndCopyFrom.CanAddNics;
CanServeDHCP = ndCopyFrom.CanServeDHCP;
CanUseDHCP = ndCopyFrom.CanUseDHCP;
MustUseDHCP = ndCopyFrom.MustUseDHCP;
isDHCPServer = ndCopyFrom.isDHCPServer;
isDNSServer = ndCopyFrom.isDNSServer;
HasAdvFirewall = ndCopyFrom.HasAdvFirewall;
if (CanAddNics != ndCopyFrom.CanAddNics)
{
if (NoteAllChanges && mainnet != null) mainnet.AddMessage(new PacketMessage("", indent + "CanAddNics: " + CanAddNics + " -> " + ndCopyFrom.CanAddNics));
CanAddNics = ndCopyFrom.CanAddNics;
}
if (CanServeDHCP != ndCopyFrom.CanServeDHCP)
{
if (NoteAllChanges && mainnet != null) mainnet.AddMessage(new PacketMessage("", indent + "CanServeDHCP: " + CanServeDHCP + " -> " + ndCopyFrom.CanServeDHCP));
CanServeDHCP = ndCopyFrom.CanServeDHCP;
}
if (CanUseDHCP != ndCopyFrom.CanUseDHCP)
{
if (NoteAllChanges && mainnet != null) mainnet.AddMessage(new PacketMessage("", indent + "CanUseDHCP: " + CanUseDHCP + " -> " + ndCopyFrom.CanUseDHCP));
CanUseDHCP = ndCopyFrom.CanUseDHCP;
}
if (MustUseDHCP != ndCopyFrom.MustUseDHCP)
{
if (NoteAllChanges && mainnet != null) mainnet.AddMessage(new PacketMessage("", indent + "MustUseDHCP: " + MustUseDHCP + " -> " + ndCopyFrom.MustUseDHCP));
MustUseDHCP = ndCopyFrom.MustUseDHCP;
}
if (isDHCPServer != ndCopyFrom.isDHCPServer)
{
if (NoteAllChanges && mainnet != null) mainnet.AddMessage(new PacketMessage("", indent + "IsDHCPServer: " + isDHCPServer + " -> " + ndCopyFrom.isDHCPServer));
isDHCPServer = ndCopyFrom.isDHCPServer;
}
if (isDNSServer != ndCopyFrom.isDNSServer)
{
if (NoteAllChanges && mainnet != null) mainnet.AddMessage(new PacketMessage("", indent + "IsDNSserver: " + isDNSServer + " -> " + ndCopyFrom.isDNSServer));
isDNSServer = ndCopyFrom.isDNSServer;
}
if (HasAdvFirewall != ndCopyFrom.HasAdvFirewall)
{
if (NoteAllChanges && mainnet != null) mainnet.AddMessage(new PacketMessage("", indent + "HasAdvancedFirewall: " + HasAdvFirewall + " -> " + ndCopyFrom.HasAdvFirewall));
HasAdvFirewall = ndCopyFrom.HasAdvFirewall;
}
MyLocation = ndCopyFrom.MyLocation;
//Process NICs.
if (NoteAllChanges && mainnet != null)
{
//List all nics that we are dropping
foreach (NetworkCard nic in NICs)
{
NetworkCard foundnic = ndCopyFrom.NicFromName(nic.NicName());
if (foundnic == null)
mainnet.AddMessage(new PacketMessage("", indent + "DropNIC: " + nic.NicName()));
else
{
//The nic still exists. Note any major changes. IP, netmask
if((foundnic.myNicType == NicType.wport || foundnic.myNicType == NicType.wlan) && foundnic.SSID != nic.SSID)
mainnet.AddMessage(new PacketMessage("", indent + "SSID: " + nic.SSID + " -> " + foundnic.SSID));
if ((foundnic.myNicType == NicType.vpn || foundnic.myNicType == NicType.vpn) && foundnic.EncryptionKey != nic.EncryptionKey)
mainnet.AddMessage(new PacketMessage("", indent + "EncryptionKey: " + nic.EncryptionKey + " -> " + foundnic.EncryptionKey));
//Compare interfaces - should be done at nic level...
if (foundnic.AllInterfacesString() != nic.AllInterfacesString())
mainnet.AddMessage(new PacketMessage("", indent + "Interfaces: " + nic.AllInterfacesString(true) + " -> " + foundnic.AllInterfacesString(true)));
}
}
//List all nics that we are dropping
foreach (NetworkCard nic in ndCopyFrom.NICs)
{
NetworkCard mynic = NicFromName(nic.NicName());
if (mynic == null)
mainnet.AddMessage(new PacketMessage("", indent + "AddNIC: " + nic.NicName() + " " +nic.AllInterfacesString()));
}
}
//Now, copy across the NICs
NICs.Clear();
foreach(NetworkCard nic in ndCopyFrom.NICs)
{

View File

@ -1,7 +1,12 @@
{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033\deflangfe1033{\fonttbl{\f0\fswiss\fprq2\fcharset0 Calibri;}}
{\colortbl ;\red0\green0\blue255;}
{\*\generator Riched20 10.0.22621}{\*\mmathPr\mdispDef1\mwrapIndent1440 }\viewkind4\uc1
\pard\nowidctlpar\sa200\sl276\slmult1\b\f0\fs22\lang9 Version 1.0.52\par
\pard\nowidctlpar\sa200\sl276\slmult1\b\f0\fs22\lang9 Version 1.0.54\b0\par
* Minor changefor developers allowing more information about what is happening during regression testing. \par
\b Version 1.0.53\par
*\b0 Show a line between devices when dragging ethernet cables. Makes it easier to see.\par
* Tried highlighting what you are supposed to be filling out next, when creating network links.\b\par
Version 1.0.52\par
\b0 * Change publish URL to an actual domain.\b\par
Version 1.0.51\par
\b0 * Added small time-based delay when printing packets; on fast computers the packets would fly by too fast.\par

View File

@ -2129,4 +2129,72 @@
<value>Regression testing</value>
<comment>LBW_Regression_Testing = Regression testing</comment>
</data>
<data name="AC_AddDevice" xml:space="preserve">
<value>Add Device</value>
<comment>AC_AddDevice = Add Device</comment>
</data>
<data name="AC_ChangeDevice" xml:space="preserve">
<value>Change Device</value>
<comment>AC_ChangeDevice = Change Device</comment>
</data>
<data name="AC_ClearArp" xml:space="preserve">
<value>Clear ARP</value>
<comment>AC_ClearArp = Clear ARP</comment>
</data>
<data name="AC_DeleteDevice" xml:space="preserve">
<value>Delete Device</value>
<comment>AC_DeleteDevice = Delete Device</comment>
</data>
<data name="AC_DeleteLink" xml:space="preserve">
<value>Delete link</value>
<comment>AC_DeleteLink = Delete link</comment>
</data>
<data name="AC_DoPing" xml:space="preserve">
<value>Do ping</value>
<comment>AC_DoPing = Do ping</comment>
</data>
<data name="AC_DoTraceroute" xml:space="preserve">
<value>Do Traceroute</value>
<comment>AC_DoTraceroute = Do Traceroute</comment>
</data>
<data name="AC_MoveDevice" xml:space="preserve">
<value>Move Device</value>
<comment>AC_MoveDevice = Move Device</comment>
</data>
<data name="AC_Powering_OFF" xml:space="preserve">
<value>Powering Off</value>
<comment>AC_Powering_OFF = Powering Off</comment>
</data>
<data name="AC_Powering_ON" xml:space="preserve">
<value>Powering On</value>
<comment>AC_Powering_OFF - Powering On</comment>
</data>
<data name="AC_Replace_Device" xml:space="preserve">
<value>Replace Device</value>
<comment>AC_Replace_Device = Replace Device</comment>
</data>
<data name="AC_Replace_Link" xml:space="preserve">
<value>Replace Link</value>
<comment>AC_Replace_Link = Replace Link</comment>
</data>
<data name="AC_Replace_UPS" xml:space="preserve">
<value>Replace UPS</value>
<comment>AC_Replace_UPS = Replace UPS</comment>
</data>
<data name="AC_RequestARP" xml:space="preserve">
<value>Request ARP</value>
<comment>AC_RequestARP = Request ARP</comment>
</data>
<data name="AC_RequestDHCP" xml:space="preserve">
<value>Request DHCP</value>
<comment>AC_RequestDHCP = Request DHCP</comment>
</data>
<data name="AC_Resetting" xml:space="preserve">
<value>Resetting</value>
<comment>AC_Resetting = Resetting</comment>
</data>
<data name="NDUpdateComponent" xml:space="preserve">
<value>Updating Device</value>
<comment>NDUpdateComponent = Update Device</comment>
</data>
</root>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="WiX" version="3.11.2" targetFramework="net45" />
</packages>