Konsolenversion
This commit is contained in:
parent
4b0236cbd6
commit
475a235837
@ -5,6 +5,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetMonitorClient", "NetMoni
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetMonitorServer", "NetMonitorServer\NetMonitorServer.csproj", "{7813196F-D729-44A2-81C7-82BB83E207F5}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetMonitorServer", "NetMonitorServer\NetMonitorServer.csproj", "{7813196F-D729-44A2-81C7-82BB83E207F5}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetMonitorConsole", "NetMonitorConsole\NetMonitorConsole.csproj", "{148AA47C-FA4D-4807-9EB0-5AEAC36C1524}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -35,6 +37,16 @@ Global
|
|||||||
{7813196F-D729-44A2-81C7-82BB83E207F5}.Release|Mixed Platforms.Build.0 = Release|x86
|
{7813196F-D729-44A2-81C7-82BB83E207F5}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||||
{7813196F-D729-44A2-81C7-82BB83E207F5}.Release|x86.ActiveCfg = Release|x86
|
{7813196F-D729-44A2-81C7-82BB83E207F5}.Release|x86.ActiveCfg = Release|x86
|
||||||
{7813196F-D729-44A2-81C7-82BB83E207F5}.Release|x86.Build.0 = Release|x86
|
{7813196F-D729-44A2-81C7-82BB83E207F5}.Release|x86.Build.0 = Release|x86
|
||||||
|
{148AA47C-FA4D-4807-9EB0-5AEAC36C1524}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||||
|
{148AA47C-FA4D-4807-9EB0-5AEAC36C1524}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||||
|
{148AA47C-FA4D-4807-9EB0-5AEAC36C1524}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||||
|
{148AA47C-FA4D-4807-9EB0-5AEAC36C1524}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{148AA47C-FA4D-4807-9EB0-5AEAC36C1524}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{148AA47C-FA4D-4807-9EB0-5AEAC36C1524}.Release|Any CPU.ActiveCfg = Release|x86
|
||||||
|
{148AA47C-FA4D-4807-9EB0-5AEAC36C1524}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||||
|
{148AA47C-FA4D-4807-9EB0-5AEAC36C1524}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||||
|
{148AA47C-FA4D-4807-9EB0-5AEAC36C1524}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{148AA47C-FA4D-4807-9EB0-5AEAC36C1524}.Release|x86.Build.0 = Release|x86
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -14,7 +14,8 @@ namespace NetMonitorClient
|
|||||||
{
|
{
|
||||||
public enum Options
|
public enum Options
|
||||||
{
|
{
|
||||||
Show
|
Show,
|
||||||
|
Edit
|
||||||
}
|
}
|
||||||
internal enum RWFlag
|
internal enum RWFlag
|
||||||
{
|
{
|
||||||
@ -35,6 +36,10 @@ namespace NetMonitorClient
|
|||||||
{
|
{
|
||||||
this.acess = RWFlag.Read;
|
this.acess = RWFlag.Read;
|
||||||
}
|
}
|
||||||
|
if (option == Options.Edit)
|
||||||
|
{
|
||||||
|
this.acess = RWFlag.Write;
|
||||||
|
}
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
ReadNetworksSettings();
|
ReadNetworksSettings();
|
||||||
SetRWSettings();
|
SetRWSettings();
|
||||||
@ -60,6 +65,24 @@ namespace NetMonitorClient
|
|||||||
this.RadioWinsAuto.Enabled = false;
|
this.RadioWinsAuto.Enabled = false;
|
||||||
this.RadioWinsManu.Enabled = false;
|
this.RadioWinsManu.Enabled = false;
|
||||||
}
|
}
|
||||||
|
if (this.acess == RWFlag.Write)
|
||||||
|
{
|
||||||
|
this.BoxDns.ReadOnly = false;
|
||||||
|
this.BoxGateway.ReadOnly = false;
|
||||||
|
this.BoxIpAdresse.ReadOnly = false;
|
||||||
|
this.BoxName.ReadOnly = false;
|
||||||
|
this.BoxSubnet.ReadOnly = false;
|
||||||
|
this.BoxWins.ReadOnly = false;
|
||||||
|
this.Text = "Netzwerke Ändern";
|
||||||
|
this.RadioAllAuto.Enabled = true;
|
||||||
|
this.RadioAllManu.Enabled = true;
|
||||||
|
this.RadioDnsAuto.Enabled = true;
|
||||||
|
this.RadioDnsManu.Enabled = true;
|
||||||
|
this.RadioIpAuto.Enabled = true;
|
||||||
|
this.RadioIpManu.Enabled = true;
|
||||||
|
this.RadioWinsAuto.Enabled = true;
|
||||||
|
this.RadioWinsManu.Enabled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReadNetworksSettings()
|
private void ReadNetworksSettings()
|
||||||
|
19
NetMonitorClient/Form1.Designer.cs
generated
19
NetMonitorClient/Form1.Designer.cs
generated
@ -83,21 +83,22 @@
|
|||||||
this.ProgramMenuDateiNetzwerkeAnsehen,
|
this.ProgramMenuDateiNetzwerkeAnsehen,
|
||||||
this.ProgramMenuDateiNetzwerkeBearbeiten});
|
this.ProgramMenuDateiNetzwerkeBearbeiten});
|
||||||
this.ProgramMenuDateiNetzwerke.Name = "ProgramMenuDateiNetzwerke";
|
this.ProgramMenuDateiNetzwerke.Name = "ProgramMenuDateiNetzwerke";
|
||||||
this.ProgramMenuDateiNetzwerke.Size = new System.Drawing.Size(129, 22);
|
this.ProgramMenuDateiNetzwerke.Size = new System.Drawing.Size(152, 22);
|
||||||
this.ProgramMenuDateiNetzwerke.Text = "Netzwerke";
|
this.ProgramMenuDateiNetzwerke.Text = "Netzwerke";
|
||||||
//
|
//
|
||||||
// ProgramMenuDateiNetzwerkeAnsehen
|
// ProgramMenuDateiNetzwerkeAnsehen
|
||||||
//
|
//
|
||||||
this.ProgramMenuDateiNetzwerkeAnsehen.Name = "ProgramMenuDateiNetzwerkeAnsehen";
|
this.ProgramMenuDateiNetzwerkeAnsehen.Name = "ProgramMenuDateiNetzwerkeAnsehen";
|
||||||
this.ProgramMenuDateiNetzwerkeAnsehen.Size = new System.Drawing.Size(130, 22);
|
this.ProgramMenuDateiNetzwerkeAnsehen.Size = new System.Drawing.Size(152, 22);
|
||||||
this.ProgramMenuDateiNetzwerkeAnsehen.Text = "Ansehen";
|
this.ProgramMenuDateiNetzwerkeAnsehen.Text = "Ansehen";
|
||||||
this.ProgramMenuDateiNetzwerkeAnsehen.Click += new System.EventHandler(this.ProgramMenuDateiNetzwerkeAnsehen_Click);
|
this.ProgramMenuDateiNetzwerkeAnsehen.Click += new System.EventHandler(this.ProgramMenuDateiNetzwerkeAnsehen_Click);
|
||||||
//
|
//
|
||||||
// ProgramMenuDateiNetzwerkeBearbeiten
|
// ProgramMenuDateiNetzwerkeBearbeiten
|
||||||
//
|
//
|
||||||
this.ProgramMenuDateiNetzwerkeBearbeiten.Name = "ProgramMenuDateiNetzwerkeBearbeiten";
|
this.ProgramMenuDateiNetzwerkeBearbeiten.Name = "ProgramMenuDateiNetzwerkeBearbeiten";
|
||||||
this.ProgramMenuDateiNetzwerkeBearbeiten.Size = new System.Drawing.Size(130, 22);
|
this.ProgramMenuDateiNetzwerkeBearbeiten.Size = new System.Drawing.Size(152, 22);
|
||||||
this.ProgramMenuDateiNetzwerkeBearbeiten.Text = "Bearbeiten";
|
this.ProgramMenuDateiNetzwerkeBearbeiten.Text = "Bearbeiten";
|
||||||
|
this.ProgramMenuDateiNetzwerkeBearbeiten.Click += new System.EventHandler(this.ProgramMenuDateiNetzwerkeBearbeiten_Click);
|
||||||
//
|
//
|
||||||
// ProgramMenuDateiEmail
|
// ProgramMenuDateiEmail
|
||||||
//
|
//
|
||||||
@ -105,25 +106,25 @@
|
|||||||
this.ProgramMenuDateiEmailAnsehen,
|
this.ProgramMenuDateiEmailAnsehen,
|
||||||
this.ProgramMenuDateiEmailHinzufuegen});
|
this.ProgramMenuDateiEmailHinzufuegen});
|
||||||
this.ProgramMenuDateiEmail.Name = "ProgramMenuDateiEmail";
|
this.ProgramMenuDateiEmail.Name = "ProgramMenuDateiEmail";
|
||||||
this.ProgramMenuDateiEmail.Size = new System.Drawing.Size(129, 22);
|
this.ProgramMenuDateiEmail.Size = new System.Drawing.Size(152, 22);
|
||||||
this.ProgramMenuDateiEmail.Text = "E-Mail";
|
this.ProgramMenuDateiEmail.Text = "E-Mail";
|
||||||
//
|
//
|
||||||
// ProgramMenuDateiEmailAnsehen
|
// ProgramMenuDateiEmailAnsehen
|
||||||
//
|
//
|
||||||
this.ProgramMenuDateiEmailAnsehen.Name = "ProgramMenuDateiEmailAnsehen";
|
this.ProgramMenuDateiEmailAnsehen.Name = "ProgramMenuDateiEmailAnsehen";
|
||||||
this.ProgramMenuDateiEmailAnsehen.Size = new System.Drawing.Size(136, 22);
|
this.ProgramMenuDateiEmailAnsehen.Size = new System.Drawing.Size(152, 22);
|
||||||
this.ProgramMenuDateiEmailAnsehen.Text = "Ansehen";
|
this.ProgramMenuDateiEmailAnsehen.Text = "Ansehen";
|
||||||
//
|
//
|
||||||
// ProgramMenuDateiEmailHinzufuegen
|
// ProgramMenuDateiEmailHinzufuegen
|
||||||
//
|
//
|
||||||
this.ProgramMenuDateiEmailHinzufuegen.Name = "ProgramMenuDateiEmailHinzufuegen";
|
this.ProgramMenuDateiEmailHinzufuegen.Name = "ProgramMenuDateiEmailHinzufuegen";
|
||||||
this.ProgramMenuDateiEmailHinzufuegen.Size = new System.Drawing.Size(136, 22);
|
this.ProgramMenuDateiEmailHinzufuegen.Size = new System.Drawing.Size(152, 22);
|
||||||
this.ProgramMenuDateiEmailHinzufuegen.Text = "Hinzufügen";
|
this.ProgramMenuDateiEmailHinzufuegen.Text = "Hinzufügen";
|
||||||
//
|
//
|
||||||
// ProgramMenuDateiBeenden
|
// ProgramMenuDateiBeenden
|
||||||
//
|
//
|
||||||
this.ProgramMenuDateiBeenden.Name = "ProgramMenuDateiBeenden";
|
this.ProgramMenuDateiBeenden.Name = "ProgramMenuDateiBeenden";
|
||||||
this.ProgramMenuDateiBeenden.Size = new System.Drawing.Size(129, 22);
|
this.ProgramMenuDateiBeenden.Size = new System.Drawing.Size(152, 22);
|
||||||
this.ProgramMenuDateiBeenden.Text = "Beenden";
|
this.ProgramMenuDateiBeenden.Text = "Beenden";
|
||||||
//
|
//
|
||||||
// ProgramMenuDienst
|
// ProgramMenuDienst
|
||||||
@ -138,13 +139,13 @@
|
|||||||
// ProgramMenuDienstStarten
|
// ProgramMenuDienstStarten
|
||||||
//
|
//
|
||||||
this.ProgramMenuDienstStarten.Name = "ProgramMenuDienstStarten";
|
this.ProgramMenuDienstStarten.Name = "ProgramMenuDienstStarten";
|
||||||
this.ProgramMenuDienstStarten.Size = new System.Drawing.Size(118, 22);
|
this.ProgramMenuDienstStarten.Size = new System.Drawing.Size(152, 22);
|
||||||
this.ProgramMenuDienstStarten.Text = "Starten";
|
this.ProgramMenuDienstStarten.Text = "Starten";
|
||||||
//
|
//
|
||||||
// ProgramMenuDienstStoppen
|
// ProgramMenuDienstStoppen
|
||||||
//
|
//
|
||||||
this.ProgramMenuDienstStoppen.Name = "ProgramMenuDienstStoppen";
|
this.ProgramMenuDienstStoppen.Name = "ProgramMenuDienstStoppen";
|
||||||
this.ProgramMenuDienstStoppen.Size = new System.Drawing.Size(118, 22);
|
this.ProgramMenuDienstStoppen.Size = new System.Drawing.Size(152, 22);
|
||||||
this.ProgramMenuDienstStoppen.Text = "Stoppen";
|
this.ProgramMenuDienstStoppen.Text = "Stoppen";
|
||||||
//
|
//
|
||||||
// ProgramMenuNetzwerke
|
// ProgramMenuNetzwerke
|
||||||
|
@ -12,16 +12,6 @@ namespace NetMonitorClient
|
|||||||
{
|
{
|
||||||
public partial class Netzmonitor : Form
|
public partial class Netzmonitor : Form
|
||||||
{
|
{
|
||||||
private enum netsetter
|
|
||||||
{
|
|
||||||
Auto,
|
|
||||||
IpAuto,
|
|
||||||
Ip,
|
|
||||||
DnsAuto,
|
|
||||||
Dns,
|
|
||||||
WinsAuto,
|
|
||||||
Wins
|
|
||||||
}
|
|
||||||
private ServiceControl sc;
|
private ServiceControl sc;
|
||||||
public Netzmonitor()
|
public Netzmonitor()
|
||||||
{
|
{
|
||||||
@ -48,33 +38,10 @@ namespace NetMonitorClient
|
|||||||
private void TrayMenuNet_Click(object sender, EventArgs e)
|
private void TrayMenuNet_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ToolStripMenuItem Item = (ToolStripMenuItem)sender;
|
ToolStripMenuItem Item = (ToolStripMenuItem)sender;
|
||||||
String name = networkini.getValue(Item.Name, "Name");
|
Networksetter netsetter = new Networksetter(Item.Name, networkini, sc);
|
||||||
String ip = networkini.getValue(Item.Name, "Ip");
|
netsetter.setNetwork();
|
||||||
String subnet = networkini.getValue(Item.Name, "Subnet");
|
this.showPopup(netsetter.getPopupBool(), netsetter.getPopupTitel(), netsetter.getPopupText());
|
||||||
String gateway = networkini.getValue(Item.Name, "Gateway");
|
this.StatusLog.Items.AddRange(netsetter.getLog().ToArray());
|
||||||
String dns = networkini.getValue(Item.Name, "Dns");
|
|
||||||
String wins = networkini.getValue(Item.Name, "Wins");
|
|
||||||
String adapter = networkini.getValue(Item.Name, "Adapter");
|
|
||||||
|
|
||||||
if (ip == "auto" && dns == "auto" && wins == "auto")
|
|
||||||
{
|
|
||||||
setNetworkAuto(adapter, name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (ip == "auto")
|
|
||||||
setNetworkIpAuto(adapter, name);
|
|
||||||
else
|
|
||||||
setNetworkIp(ip, subnet, gateway, adapter, name);
|
|
||||||
if (dns == "auto")
|
|
||||||
setNetworkDnsAuto(adapter, name);
|
|
||||||
else
|
|
||||||
setNetworkDns(dns, adapter, name);
|
|
||||||
if (wins == "auto")
|
|
||||||
setNetworkWinsAuto(adapter, name);
|
|
||||||
else
|
|
||||||
setNetworkWins(wins, adapter, name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showPopup(bool p, string titel, string text)
|
private void showPopup(bool p, string titel, string text)
|
||||||
@ -98,5 +65,10 @@ namespace NetMonitorClient
|
|||||||
{
|
{
|
||||||
new EditNetworks(EditNetworks.Options.Show).ShowDialog(this);
|
new EditNetworks(EditNetworks.Options.Show).ShowDialog(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ProgramMenuDateiNetzwerkeBearbeiten_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
new EditNetworks(EditNetworks.Options.Edit).ShowDialog(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ using System.Text.RegularExpressions;
|
|||||||
|
|
||||||
namespace NetMonitorClient
|
namespace NetMonitorClient
|
||||||
{
|
{
|
||||||
class InIReader
|
public class InIReader
|
||||||
{
|
{
|
||||||
private StreamReader file;
|
private StreamReader file;
|
||||||
private ArrayList cont = new ArrayList();
|
private ArrayList cont = new ArrayList();
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
<OutputPath>E:\Programme\NetMonitor\</OutputPath>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
@ -86,6 +86,7 @@
|
|||||||
<Compile Include="Networks.cs">
|
<Compile Include="Networks.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Networksetter.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<EmbeddedResource Include="EditNetworks.resx">
|
<EmbeddedResource Include="EditNetworks.resx">
|
||||||
|
@ -9,93 +9,6 @@ namespace NetMonitorClient
|
|||||||
{
|
{
|
||||||
partial class Netzmonitor
|
partial class Netzmonitor
|
||||||
{
|
{
|
||||||
private void setNetworkAuto(string adapter, string name)
|
|
||||||
{
|
|
||||||
setNetwork(netsetter.Auto, null, null, null, adapter, name, null, null);
|
|
||||||
}
|
|
||||||
private void setNetworkIpAuto(string adapter, string name)
|
|
||||||
{
|
|
||||||
setNetwork(netsetter.IpAuto, null, null, null, adapter, name, null, null);
|
|
||||||
}
|
|
||||||
private void setNetworkIp(string ip, string subnet, string gateway, string adapter, string name)
|
|
||||||
{
|
|
||||||
setNetwork(netsetter.Ip, ip, subnet, gateway, adapter, name, null, null);
|
|
||||||
}
|
|
||||||
private void setNetworkDnsAuto(string adapter, string name)
|
|
||||||
{
|
|
||||||
setNetwork(netsetter.DnsAuto, null, null, null, adapter, name, null, null);
|
|
||||||
}
|
|
||||||
private void setNetworkDns(string dns, string adapter, string name)
|
|
||||||
{
|
|
||||||
setNetwork(netsetter.Dns, null, null, null, adapter, name, dns, null);
|
|
||||||
}
|
|
||||||
private void setNetworkWinsAuto(string adapter, string name)
|
|
||||||
{
|
|
||||||
setNetwork(netsetter.WinsAuto, null, null, null, adapter, name, null, null);
|
|
||||||
}
|
|
||||||
private void setNetworkWins(string wins, string adapter, string name)
|
|
||||||
{
|
|
||||||
setNetwork(netsetter.Wins, null, null, null, adapter, name, null, wins);
|
|
||||||
}
|
|
||||||
private void setNetwork(netsetter option, string ip, string subnet, string gateway, string adapter, string name, string dns, string wins)
|
|
||||||
{
|
|
||||||
bool status = false;
|
|
||||||
String text = "";
|
|
||||||
if (option == netsetter.Ip)
|
|
||||||
{
|
|
||||||
text = "Ip: " + ip + ";Subnet: " + subnet + ";Gateway: " + gateway;
|
|
||||||
this.StatusLog.Items.Add("Gesendet: " + text);
|
|
||||||
Application.DoEvents();
|
|
||||||
status = this.sc.setNetworkIp(ip, subnet, gateway, adapter);
|
|
||||||
}
|
|
||||||
if (option == netsetter.Auto)
|
|
||||||
{
|
|
||||||
text = "Netzwerk auf Auto";
|
|
||||||
this.StatusLog.Items.Add("Gesendet: " + text);
|
|
||||||
Application.DoEvents();
|
|
||||||
status = this.sc.setNetworkAuto(adapter);
|
|
||||||
}
|
|
||||||
if (option == netsetter.IpAuto)
|
|
||||||
{
|
|
||||||
text = "Ip auf Auto";
|
|
||||||
this.StatusLog.Items.Add("Gesendet: " + text);
|
|
||||||
Application.DoEvents();
|
|
||||||
status = this.sc.setNetworkIpAuto(adapter);
|
|
||||||
}
|
|
||||||
if (option == netsetter.DnsAuto)
|
|
||||||
{
|
|
||||||
text = "Dns auf Auto";
|
|
||||||
this.StatusLog.Items.Add("Gesendet: " + text);
|
|
||||||
Application.DoEvents();
|
|
||||||
status = this.sc.setNetworkDnsAuto(adapter);
|
|
||||||
}
|
|
||||||
if (option == netsetter.WinsAuto)
|
|
||||||
{
|
|
||||||
text = "Wins auf Auto";
|
|
||||||
this.StatusLog.Items.Add("Gesendet: " + text);
|
|
||||||
Application.DoEvents();
|
|
||||||
status = this.sc.setNetworkWinsAuto(adapter);
|
|
||||||
}
|
|
||||||
if (option == netsetter.Dns)
|
|
||||||
{
|
|
||||||
text = "Dns: " + dns;
|
|
||||||
this.StatusLog.Items.Add("Gesendet: " + text);
|
|
||||||
Application.DoEvents();
|
|
||||||
status = this.sc.setNetworkDNS(dns, adapter);
|
|
||||||
}
|
|
||||||
if (option == netsetter.Wins)
|
|
||||||
{
|
|
||||||
text = "Wins: " + wins;
|
|
||||||
this.StatusLog.Items.Add("Gesendet: " + text);
|
|
||||||
Application.DoEvents();
|
|
||||||
status = this.sc.setNetworkWINS(wins, adapter);
|
|
||||||
}
|
|
||||||
this.StatusLog.Items.Add("Antwort: " + ((status) ? "Ok" : "Fehler"));
|
|
||||||
Application.DoEvents();
|
|
||||||
this.showPopup(status, name, text);
|
|
||||||
Application.DoEvents();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InitNetworks()
|
private void InitNetworks()
|
||||||
{
|
{
|
||||||
this.networkini = new InIReader("network.ini");
|
this.networkini = new InIReader("network.ini");
|
||||||
|
177
NetMonitorClient/Networksetter.cs
Normal file
177
NetMonitorClient/Networksetter.cs
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace NetMonitorClient
|
||||||
|
{
|
||||||
|
public class Networksetter
|
||||||
|
{
|
||||||
|
private ServiceControl sc;
|
||||||
|
private InIReader networkini;
|
||||||
|
private string net_name;
|
||||||
|
private List<string> loglist;
|
||||||
|
|
||||||
|
private bool Pstatus;
|
||||||
|
private string Pname;
|
||||||
|
private string Ptext;
|
||||||
|
private enum netsetter
|
||||||
|
{
|
||||||
|
Auto,
|
||||||
|
IpAuto,
|
||||||
|
Ip,
|
||||||
|
DnsAuto,
|
||||||
|
Dns,
|
||||||
|
WinsAuto,
|
||||||
|
Wins
|
||||||
|
}
|
||||||
|
public Networksetter(string name, InIReader ini, ServiceControl serv)
|
||||||
|
{
|
||||||
|
this.net_name = name;
|
||||||
|
this.networkini = ini;
|
||||||
|
loglist = new List<string>();
|
||||||
|
this.sc = serv;
|
||||||
|
}
|
||||||
|
public void setNetwork()
|
||||||
|
{
|
||||||
|
String name = networkini.getValue(net_name, "Name");
|
||||||
|
String ip = networkini.getValue(net_name, "Ip");
|
||||||
|
String subnet = networkini.getValue(net_name, "Subnet");
|
||||||
|
String gateway = networkini.getValue(net_name, "Gateway");
|
||||||
|
String dns = networkini.getValue(net_name, "Dns");
|
||||||
|
String wins = networkini.getValue(net_name, "Wins");
|
||||||
|
String adapter = networkini.getValue(net_name, "Adapter");
|
||||||
|
|
||||||
|
if (ip == "auto" && dns == "auto" && wins == "auto")
|
||||||
|
{
|
||||||
|
setNetworkAuto(adapter, name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ip == "auto")
|
||||||
|
setNetworkIpAuto(adapter, name);
|
||||||
|
else
|
||||||
|
setNetworkIp(ip, subnet, gateway, adapter, name);
|
||||||
|
if (dns == "auto")
|
||||||
|
setNetworkDnsAuto(adapter, name);
|
||||||
|
else
|
||||||
|
setNetworkDns(dns, adapter, name);
|
||||||
|
if (wins == "auto")
|
||||||
|
setNetworkWinsAuto(adapter, name);
|
||||||
|
else
|
||||||
|
setNetworkWins(wins, adapter, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void setNetworkAuto(string adapter, string name)
|
||||||
|
{
|
||||||
|
setNetwork(netsetter.Auto, null, null, null, adapter, name, null, null);
|
||||||
|
}
|
||||||
|
private void setNetworkIpAuto(string adapter, string name)
|
||||||
|
{
|
||||||
|
setNetwork(netsetter.IpAuto, null, null, null, adapter, name, null, null);
|
||||||
|
}
|
||||||
|
private void setNetworkIp(string ip, string subnet, string gateway, string adapter, string name)
|
||||||
|
{
|
||||||
|
setNetwork(netsetter.Ip, ip, subnet, gateway, adapter, name, null, null);
|
||||||
|
}
|
||||||
|
private void setNetworkDnsAuto(string adapter, string name)
|
||||||
|
{
|
||||||
|
setNetwork(netsetter.DnsAuto, null, null, null, adapter, name, null, null);
|
||||||
|
}
|
||||||
|
private void setNetworkDns(string dns, string adapter, string name)
|
||||||
|
{
|
||||||
|
setNetwork(netsetter.Dns, null, null, null, adapter, name, dns, null);
|
||||||
|
}
|
||||||
|
private void setNetworkWinsAuto(string adapter, string name)
|
||||||
|
{
|
||||||
|
setNetwork(netsetter.WinsAuto, null, null, null, adapter, name, null, null);
|
||||||
|
}
|
||||||
|
private void setNetworkWins(string wins, string adapter, string name)
|
||||||
|
{
|
||||||
|
setNetwork(netsetter.Wins, null, null, null, adapter, name, null, wins);
|
||||||
|
}
|
||||||
|
private void setNetwork(netsetter option, string ip, string subnet, string gateway, string adapter, string name, string dns, string wins)
|
||||||
|
{
|
||||||
|
bool status = false;
|
||||||
|
List<string> text = new List<string>();
|
||||||
|
if (option == netsetter.Ip)
|
||||||
|
{
|
||||||
|
text.Add("Ip: " + ip + ";Subnet: " + subnet + ";Gateway: " + gateway);
|
||||||
|
loglist.Add("Gesendet: " + text);
|
||||||
|
System.Windows.Forms.Application.DoEvents();
|
||||||
|
status = this.sc.setNetworkIp(ip, subnet, gateway, adapter);
|
||||||
|
}
|
||||||
|
if (option == netsetter.Auto)
|
||||||
|
{
|
||||||
|
text.Add("Netzwerk auf Auto");
|
||||||
|
loglist.Add("Gesendet: " + text);
|
||||||
|
System.Windows.Forms.Application.DoEvents();
|
||||||
|
status = this.sc.setNetworkAuto(adapter);
|
||||||
|
}
|
||||||
|
if (option == netsetter.IpAuto)
|
||||||
|
{
|
||||||
|
text.Add("Ip auf Auto");
|
||||||
|
loglist.Add("Gesendet: " + text);
|
||||||
|
System.Windows.Forms.Application.DoEvents();
|
||||||
|
status = this.sc.setNetworkIpAuto(adapter);
|
||||||
|
}
|
||||||
|
if (option == netsetter.DnsAuto)
|
||||||
|
{
|
||||||
|
text.Add("Dns auf Auto");
|
||||||
|
loglist.Add("Gesendet: " + text);
|
||||||
|
System.Windows.Forms.Application.DoEvents();
|
||||||
|
status = this.sc.setNetworkDnsAuto(adapter);
|
||||||
|
}
|
||||||
|
if (option == netsetter.WinsAuto)
|
||||||
|
{
|
||||||
|
text.Add("Wins auf Auto");
|
||||||
|
loglist.Add("Gesendet: " + text);
|
||||||
|
System.Windows.Forms.Application.DoEvents();
|
||||||
|
status = this.sc.setNetworkWinsAuto(adapter);
|
||||||
|
}
|
||||||
|
if (option == netsetter.Dns)
|
||||||
|
{
|
||||||
|
text.Add("Dns: " + dns);
|
||||||
|
loglist.Add("Gesendet: " + text);
|
||||||
|
status = this.sc.setNetworkDNS(dns, adapter);
|
||||||
|
}
|
||||||
|
if (option == netsetter.Wins)
|
||||||
|
{
|
||||||
|
text.Add("Wins: " + wins);
|
||||||
|
loglist.Add("Gesendet: " + text);
|
||||||
|
System.Windows.Forms.Application.DoEvents();
|
||||||
|
status = this.sc.setNetworkWINS(wins, adapter);
|
||||||
|
}
|
||||||
|
loglist.Add("Antwort: " + ((status) ? "Ok" : "Fehler"));
|
||||||
|
System.Windows.Forms.Application.DoEvents();
|
||||||
|
setPopup(status, name, String.Join("\n",text.ToArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setPopup(bool status, string name, string text)
|
||||||
|
{
|
||||||
|
this.Pstatus = status;
|
||||||
|
this.Pname = name;
|
||||||
|
this.Ptext = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal bool getPopupBool()
|
||||||
|
{
|
||||||
|
return this.Pstatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal string getPopupTitel()
|
||||||
|
{
|
||||||
|
return this.Pname;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal string getPopupText()
|
||||||
|
{
|
||||||
|
return this.Ptext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<string> getLog()
|
||||||
|
{
|
||||||
|
return this.loglist;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@ using System.Net;
|
|||||||
|
|
||||||
namespace NetMonitorClient
|
namespace NetMonitorClient
|
||||||
{
|
{
|
||||||
class ServiceControl
|
public class ServiceControl
|
||||||
{
|
{
|
||||||
private UdpClient net_send;
|
private UdpClient net_send;
|
||||||
private IPEndPoint net_send_port;
|
private IPEndPoint net_send_port;
|
||||||
|
43
NetMonitorConsole/CMDArgs.cs
Normal file
43
NetMonitorConsole/CMDArgs.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace NetMonitorConsole
|
||||||
|
{
|
||||||
|
class CMDArgs
|
||||||
|
{
|
||||||
|
private string[] args;
|
||||||
|
public enum Worker
|
||||||
|
{
|
||||||
|
Network,
|
||||||
|
Nothing
|
||||||
|
}
|
||||||
|
private Worker work;
|
||||||
|
public CMDArgs(string[] arg)
|
||||||
|
{
|
||||||
|
this.args = arg;
|
||||||
|
work = Worker.Nothing;
|
||||||
|
setWorker();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setWorker()
|
||||||
|
{
|
||||||
|
if (args.Length >= 1 && args[0].ToLower() == "-n")
|
||||||
|
work = Worker.Network;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
internal Worker getWorker()
|
||||||
|
{
|
||||||
|
return work;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal string getNetworkName()
|
||||||
|
{
|
||||||
|
if (work == Worker.Network)
|
||||||
|
return args[1];
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
64
NetMonitorConsole/NetMonitorConsole.csproj
Normal file
64
NetMonitorConsole/NetMonitorConsole.csproj
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||||
|
<ProductVersion>8.0.30703</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{148AA47C-FA4D-4807-9EB0-5AEAC36C1524}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>NetMonitorConsole</RootNamespace>
|
||||||
|
<AssemblyName>NetMonitorConsole</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
|
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>E:\Programme\NetMonitor\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="CMDArgs.cs" />
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\NetMonitorClient\NetMonitorClient.csproj">
|
||||||
|
<Project>{718693A0-06A3-4765-801D-33842861AA61}</Project>
|
||||||
|
<Name>NetMonitorClient</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- 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">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
38
NetMonitorConsole/Program.cs
Normal file
38
NetMonitorConsole/Program.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using NetMonitorClient;
|
||||||
|
|
||||||
|
namespace NetMonitorConsole
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
private static ServiceControl sc;
|
||||||
|
private static InIReader networkini;
|
||||||
|
private static CMDArgs arg;
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("NetMonitorConsole: Programm zum setzen der Netzwerkeinstellungen");
|
||||||
|
sc = new ServiceControl("NetMonitorServer");
|
||||||
|
networkini = new InIReader("network.ini");
|
||||||
|
arg = new CMDArgs(args);
|
||||||
|
switch (arg.getWorker())
|
||||||
|
{
|
||||||
|
case CMDArgs.Worker.Network:
|
||||||
|
setNetwork();
|
||||||
|
break;
|
||||||
|
case CMDArgs.Worker.Nothing:
|
||||||
|
Console.WriteLine("usage: NetMonitorConsole.exe: -n [networkid]");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setNetwork()
|
||||||
|
{
|
||||||
|
Networksetter netsetter = new Networksetter(arg.getNetworkName(), networkini, sc);
|
||||||
|
netsetter.setNetwork();
|
||||||
|
Console.WriteLine(String.Join("\n",netsetter.getLog().ToArray()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
NetMonitorConsole/Properties/AssemblyInfo.cs
Normal file
36
NetMonitorConsole/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||||
|
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||||
|
// die mit einer Assembly verknüpft sind.
|
||||||
|
[assembly: AssemblyTitle("NetMonitorConsole")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("NetMonitorConsole")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2010")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
|
||||||
|
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
|
||||||
|
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
|
||||||
|
[assembly: Guid("8bc2ac0e-a728-4329-845c-6bf9dc353a6f")]
|
||||||
|
|
||||||
|
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||||
|
//
|
||||||
|
// Hauptversion
|
||||||
|
// Nebenversion
|
||||||
|
// Buildnummer
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||||
|
// übernehmen, indem Sie "*" eingeben:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
Loading…
Reference in New Issue
Block a user