From 26dbe5cc522f2593ce4e91672835ab0e0e4139fc Mon Sep 17 00:00:00 2001 From: BlubbFish Date: Wed, 21 Apr 2010 11:34:01 +0000 Subject: [PATCH] =?UTF-8?q?Server=20hinzugef=C3=BCgt;=20Auslesen=20des=20M?= =?UTF-8?q?en=C3=BCs=20und=20der=20Ip=20adressen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NetMonitor.sln | 42 ++++++++++++++ NetMonitorCliend.sln | 20 ------- NetMonitorCliend/Form1.Designer.cs | 4 -- NetMonitorCliend/Form1.cs | 24 +++++--- NetMonitorCliend/Networks.cs | 5 +- NetMonitorCliend/network.ini | 6 +- NetMonitorServer/NetMonitorServer.csproj | 64 +++++++++++++++++++++ NetMonitorServer/Program.cs | 24 ++++++++ NetMonitorServer/Properties/AssemblyInfo.cs | 36 ++++++++++++ NetMonitorServer/Service1.Designer.cs | 37 ++++++++++++ NetMonitorServer/Service1.cs | 27 +++++++++ 11 files changed, 251 insertions(+), 38 deletions(-) create mode 100644 NetMonitor.sln delete mode 100644 NetMonitorCliend.sln create mode 100644 NetMonitorServer/NetMonitorServer.csproj create mode 100644 NetMonitorServer/Program.cs create mode 100644 NetMonitorServer/Properties/AssemblyInfo.cs create mode 100644 NetMonitorServer/Service1.Designer.cs create mode 100644 NetMonitorServer/Service1.cs diff --git a/NetMonitor.sln b/NetMonitor.sln new file mode 100644 index 0000000..52d2865 --- /dev/null +++ b/NetMonitor.sln @@ -0,0 +1,42 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetMonitorCliend", "NetMonitorCliend\NetMonitorCliend.csproj", "{718693A0-06A3-4765-801D-33842861AA61}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetMonitorServer", "NetMonitorServer\NetMonitorServer.csproj", "{7813196F-D729-44A2-81C7-82BB83E207F5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {718693A0-06A3-4765-801D-33842861AA61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {718693A0-06A3-4765-801D-33842861AA61}.Debug|Any CPU.Build.0 = Debug|Any CPU + {718693A0-06A3-4765-801D-33842861AA61}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {718693A0-06A3-4765-801D-33842861AA61}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {718693A0-06A3-4765-801D-33842861AA61}.Debug|x86.ActiveCfg = Debug|Any CPU + {718693A0-06A3-4765-801D-33842861AA61}.Release|Any CPU.ActiveCfg = Release|Any CPU + {718693A0-06A3-4765-801D-33842861AA61}.Release|Any CPU.Build.0 = Release|Any CPU + {718693A0-06A3-4765-801D-33842861AA61}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {718693A0-06A3-4765-801D-33842861AA61}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {718693A0-06A3-4765-801D-33842861AA61}.Release|x86.ActiveCfg = Release|Any CPU + {7813196F-D729-44A2-81C7-82BB83E207F5}.Debug|Any CPU.ActiveCfg = Debug|x86 + {7813196F-D729-44A2-81C7-82BB83E207F5}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {7813196F-D729-44A2-81C7-82BB83E207F5}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {7813196F-D729-44A2-81C7-82BB83E207F5}.Debug|x86.ActiveCfg = Debug|x86 + {7813196F-D729-44A2-81C7-82BB83E207F5}.Debug|x86.Build.0 = Debug|x86 + {7813196F-D729-44A2-81C7-82BB83E207F5}.Release|Any CPU.ActiveCfg = Release|x86 + {7813196F-D729-44A2-81C7-82BB83E207F5}.Release|Mixed Platforms.ActiveCfg = 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.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/NetMonitorCliend.sln b/NetMonitorCliend.sln deleted file mode 100644 index fcf16bb..0000000 --- a/NetMonitorCliend.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetMonitorCliend", "NetMonitorCliend\NetMonitorCliend.csproj", "{718693A0-06A3-4765-801D-33842861AA61}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {718693A0-06A3-4765-801D-33842861AA61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {718693A0-06A3-4765-801D-33842861AA61}.Debug|Any CPU.Build.0 = Debug|Any CPU - {718693A0-06A3-4765-801D-33842861AA61}.Release|Any CPU.ActiveCfg = Release|Any CPU - {718693A0-06A3-4765-801D-33842861AA61}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/NetMonitorCliend/Form1.Designer.cs b/NetMonitorCliend/Form1.Designer.cs index 5ea552a..f9bd87a 100644 --- a/NetMonitorCliend/Form1.Designer.cs +++ b/NetMonitorCliend/Form1.Designer.cs @@ -48,8 +48,6 @@ this.trayIcon = new System.Windows.Forms.NotifyIcon(this.components); this.trayMenu = new System.Windows.Forms.ContextMenuStrip(this.components); this.trayMenuNetzwerk = new System.Windows.Forms.ToolStripMenuItem(); - this.homeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.fhgToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); this.trayMenu.SuspendLayout(); @@ -209,8 +207,6 @@ private System.Windows.Forms.NotifyIcon trayIcon; private System.Windows.Forms.ContextMenuStrip trayMenu; private System.Windows.Forms.ToolStripMenuItem trayMenuNetzwerk; - private System.Windows.Forms.ToolStripMenuItem homeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem fhgToolStripMenuItem; private InIReader networkini; } } diff --git a/NetMonitorCliend/Form1.cs b/NetMonitorCliend/Form1.cs index 348c9c8..841b145 100644 --- a/NetMonitorCliend/Form1.cs +++ b/NetMonitorCliend/Form1.cs @@ -25,16 +25,24 @@ namespace NetMonitorCliend this.WindowState = System.Windows.Forms.FormWindowState.Normal; } - private void homeToolStripMenuItem_Click(object sender, EventArgs e) + private void TrayMenuNet_Click(object sender, EventArgs e) { - this.sc.setNetworkAuto(); - } + ToolStripMenuItem Item = (ToolStripMenuItem)sender; + String ip = networkini.getValue(Item.Name, "Ip"); + String subnet = networkini.getValue(Item.Name, "Subnet"); + String gateway = networkini.getValue(Item.Name, "Gateway"); + String dns = networkini.getValue(Item.Name, "Dns"); + String wins = networkini.getValue(Item.Name, "Wins"); + + if (ip == "auto" && dns == "auto" && wins == "auto") + this.sc.setNetworkAuto(); + else + { + this.sc.setNetworkIp(ip, subnet, gateway); + this.sc.setNetworkDNS(dns); + this.sc.setNetworkWINS(wins); + } - private void fhgToolStripMenuItem_Click(object sender, EventArgs e) - { - this.sc.setNetworkIp("129.26.164.16","255.255.248.0","129.26.160.1"); - this.sc.setNetworkDNS("129.26.165.177"); - this.sc.setNetworkWINS("129.26.165.167"); } } } diff --git a/NetMonitorCliend/Networks.cs b/NetMonitorCliend/Networks.cs index 01be436..bd97d0f 100644 --- a/NetMonitorCliend/Networks.cs +++ b/NetMonitorCliend/Networks.cs @@ -25,7 +25,6 @@ namespace NetMonitorCliend this.trayMenuNetzwerk.Size = new System.Drawing.Size(152, 22); this.trayMenuNetzwerk.Text = "Netzwerk"; - ArrayList networks = networkini.getSections(); ToolStripItem[] tsi = new ToolStripItem[networks.Count]; @@ -33,10 +32,10 @@ namespace NetMonitorCliend foreach (String net in networks) { ToolStripMenuItem TrayItemNet = new ToolStripMenuItem(); - TrayItemNet.Name = networkini.getValue(net, "Name") + "ToolStripMenuItem"; + TrayItemNet.Name = net; TrayItemNet.Size = new System.Drawing.Size(152, 22); TrayItemNet.Text = networkini.getValue(net, "Name"); - TrayItemNet.Click += new System.EventHandler(this.homeToolStripMenuItem_Click); + TrayItemNet.Click += new System.EventHandler(this.TrayMenuNet_Click); tsi[i++] = TrayItemNet; } diff --git a/NetMonitorCliend/network.ini b/NetMonitorCliend/network.ini index 8bb791f..5e9f1a4 100644 --- a/NetMonitorCliend/network.ini +++ b/NetMonitorCliend/network.ini @@ -1,5 +1,5 @@ [network1] Name=Home - -[network2] -Name=FHG \ No newline at end of file +Ip=auto +Dns=auto +Wins=auto \ No newline at end of file diff --git a/NetMonitorServer/NetMonitorServer.csproj b/NetMonitorServer/NetMonitorServer.csproj new file mode 100644 index 0000000..95102d8 --- /dev/null +++ b/NetMonitorServer/NetMonitorServer.csproj @@ -0,0 +1,64 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {7813196F-D729-44A2-81C7-82BB83E207F5} + WinExe + Properties + NetMonitorServer + NetMonitorServer + v4.0 + Client + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + Component + + + Service1.cs + + + + + + + \ No newline at end of file diff --git a/NetMonitorServer/Program.cs b/NetMonitorServer/Program.cs new file mode 100644 index 0000000..e6532af --- /dev/null +++ b/NetMonitorServer/Program.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.ServiceProcess; +using System.Text; + +namespace NetMonitorServer +{ + static class Program + { + /// + /// The main entry point for the application. + /// + static void Main() + { + ServiceBase[] ServicesToRun; + ServicesToRun = new ServiceBase[] + { + new Service1() + }; + ServiceBase.Run(ServicesToRun); + } + } +} diff --git a/NetMonitorServer/Properties/AssemblyInfo.cs b/NetMonitorServer/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..cf9872b --- /dev/null +++ b/NetMonitorServer/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("NetMonitorServer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("NetMonitorServer")] +[assembly: AssemblyCopyright("Copyright © 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("255d9beb-a9f8-4063-bf63-3e1038d3e780")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/NetMonitorServer/Service1.Designer.cs b/NetMonitorServer/Service1.Designer.cs new file mode 100644 index 0000000..e4a5312 --- /dev/null +++ b/NetMonitorServer/Service1.Designer.cs @@ -0,0 +1,37 @@ +namespace NetMonitorServer +{ + partial class Service1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.ServiceName = "Service1"; + } + + #endregion + } +} diff --git a/NetMonitorServer/Service1.cs b/NetMonitorServer/Service1.cs new file mode 100644 index 0000000..a913a14 --- /dev/null +++ b/NetMonitorServer/Service1.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Diagnostics; +using System.Linq; +using System.ServiceProcess; +using System.Text; + +namespace NetMonitorServer +{ + public partial class Service1 : ServiceBase + { + public Service1() + { + InitializeComponent(); + } + + protected override void OnStart(string[] args) + { + } + + protected override void OnStop() + { + } + } +}