Get Action list to save

This commit is contained in:
Tim Young 2018-05-14 08:05:56 -05:00
parent 048d461894
commit 76b87b0d18
11 changed files with 41 additions and 9 deletions

View File

@ -12,11 +12,7 @@ namespace EduNetworkBuilder
Network StartingState = null; Network StartingState = null;
public List<NetworkAction> NetActions = new List<NetworkAction>(); public List<NetworkAction> NetActions = new List<NetworkAction>();
NetworkAction CurrentNetAction = null; NetworkAction CurrentNetAction = null;
bool _HasUnsavedChanges = false; public bool HasUnsavedChanges = false;
public bool HasUnsavedChanges {
get { return _HasUnsavedChanges; }
private set { _HasUnsavedChanges = value; }
}
public Network GetNet { get { return StartingState; } } public Network GetNet { get { return StartingState; } }
public int GetActionCount { get { if (CurrentNetAction == null) return 0; return CurrentNetAction.Actions.Count; } } public int GetActionCount { get { if (CurrentNetAction == null) return 0; return CurrentNetAction.Actions.Count; } }
@ -119,6 +115,7 @@ namespace EduNetworkBuilder
/// This tells us if it has been stored to the long-term action list. /// This tells us if it has been stored to the long-term action list.
/// </summary> /// </summary>
public bool HasBeenStored = false; public bool HasBeenStored = false;
public NetworkAction() { }
public NetworkAction(string Name) public NetworkAction(string Name)
{ {
NetworkName = Name; NetworkName = Name;

View File

@ -24,6 +24,7 @@ namespace EduNetworkBuilder
private IPAddress theNetmask; private IPAddress theNetmask;
private IPAddress theGateway; private IPAddress theGateway;
public NB_IPAddress() { } //used for reflection
public NB_IPAddress(string ip, string mask, IPAddressType WhatType) public NB_IPAddress(string ip, string mask, IPAddressType WhatType)
{ {
myType = WhatType; myType = WhatType;

View File

@ -297,6 +297,7 @@ namespace EduNetworkBuilder
public string Destination; public string Destination;
public FirewallRuleType Action; public FirewallRuleType Action;
public FirewallRule() { }
public FirewallRule(string source, string dest, FirewallRuleType action) public FirewallRule(string source, string dest, FirewallRuleType action)
{ {
Source = source; Source = source;

View File

@ -227,6 +227,16 @@ namespace EduNetworkBuilder
//return the id and increment it. //return the id and increment it.
return NextID++; return NextID++;
} }
/// <summary>
/// We are saving the ReplayActions. Right now, we are doing this for automatic testing
/// of the puzzles. Regression Testing
/// </summary>
public void SaveActions()
{
NB.WriteToXmlFile(@"c:\Users\TimYo\Desktop\EduNetworkReplay.xml", UserActions);
}
public void Save(bool UsingMono) public void Save(bool UsingMono)
{ {
if(UsingMono) if(UsingMono)

View File

@ -23,6 +23,7 @@ namespace EduNetworkBuilder
public bool TaskWasDone = false; public bool TaskWasDone = false;
public int PacketNumber = -1; public int PacketNumber = -1;
public NetTest() { }
public NetTest(string srcHost, string dstHost, NetTestType tTest) public NetTest(string srcHost, string dstHost, NetTestType tTest)
{ {
sHost = srcHost; sHost = srcHost;

View File

@ -2863,9 +2863,23 @@ namespace EduNetworkBuilder
StoreReplay(); StoreReplay();
} }
void SaveReplayFile()
{
NBSettings ourSettings = NB.GetSettings();
if (OurSettings != null && OurSettings.ReplayMode)
{
ActionCollection AC = OurSettings.GetUserActionCollection();
if (AC.HasUnsavedChanges)
{
ourSettings.SaveActions();
}
}
}
private void saveReplayToolStripMenuItem_Click(object sender, EventArgs e) private void saveReplayToolStripMenuItem_Click(object sender, EventArgs e)
{ {
SaveReplayFile();
} }
} }
} }

View File

@ -36,6 +36,8 @@ namespace EduNetworkBuilder
public int IFCount { get { return interfaces.Count; } } public int IFCount { get { return interfaces.Count; } }
public NetworkCard() { }
public NetworkCard(int index, int HostID, string hostname, NicType theType = NicType.eth) public NetworkCard(int index, int HostID, string hostname, NicType theType = NicType.eth)
{ {
myNicType = theType; myNicType = theType;

View File

@ -41,6 +41,7 @@ namespace EduNetworkBuilder
public int BadSprayCount = 0; public int BadSprayCount = 0;
public List<int> PacketIDsPassedThrough = new List<int>(); public List<int> PacketIDsPassedThrough = new List<int>();
public NetworkDevice() { }
public NetworkDevice(NetworkComponentType what, string tHostname, Point tLocation, NicType firstNic = NicType.eth) public NetworkDevice(NetworkComponentType what, string tHostname, Point tLocation, NicType firstNic = NicType.eth)
{ {
hostname = tHostname; hostname = tHostname;

View File

@ -17,6 +17,9 @@ namespace EduNetworkBuilder
public HostNicID AttachedToHostNic; public HostNicID AttachedToHostNic;
public List<VLANInfo> VLANs = new List<VLANInfo>() { new VLANInfo(1, VLANTagType.Untagged ) }; public List<VLANInfo> VLANs = new List<VLANInfo>() { new VLANInfo(1, VLANTagType.Untagged ) };
//We should have a feature: none, IP_in_IP_Tunnel, encrypted_vpn, vlan, etc //We should have a feature: none, IP_in_IP_Tunnel, encrypted_vpn, vlan, etc
public NetworkInterface() { }
public NetworkInterface(string name, string IP, string Mask, HostNicID AttachedTo) public NetworkInterface(string name, string IP, string Mask, HostNicID AttachedTo)
{ {
nic_name = name; nic_name = name;

View File

@ -17,6 +17,8 @@ namespace EduNetworkBuilder
public LinkType theLinkType = LinkType.normal; public LinkType theLinkType = LinkType.normal;
public bool isVisibleLink = true; //False for wireless. Skip drawing a line if it is there public bool isVisibleLink = true; //False for wireless. Skip drawing a line if it is there
public NetworkLink() { }
public NetworkLink(HostNicID source, HostNicID dest, LinkType type = LinkType.normal) public NetworkLink(HostNicID source, HostNicID dest, LinkType type = LinkType.normal)
{ {
SrcNic = source; SrcNic = source;