添加项目文件。

This commit is contained in:
HSL
2017-02-22 14:30:10 +08:00
parent 171b6b939c
commit dcdc6f6975
40 changed files with 15728 additions and 0 deletions

34
C-S软件系统模版.sln Normal file
View File

@@ -0,0 +1,34 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommonLibrary", "CommonLibrary\CommonLibrary.csproj", "{8C97F322-4306-40FC-AFCF-753384D80046}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "软件系统客户端模版", "软件系统客户端模版\软件系统客户端模版.csproj", "{1A4C9858-C8D6-45FB-802A-3513400D11F3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "软件系统服务端模版", "软件系统服务端模版\软件系统服务端模版.csproj", "{2AFB749C-A6CE-4B2A-B02D-4FC7BB8ADA30}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8C97F322-4306-40FC-AFCF-753384D80046}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8C97F322-4306-40FC-AFCF-753384D80046}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8C97F322-4306-40FC-AFCF-753384D80046}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8C97F322-4306-40FC-AFCF-753384D80046}.Release|Any CPU.Build.0 = Release|Any CPU
{1A4C9858-C8D6-45FB-802A-3513400D11F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1A4C9858-C8D6-45FB-802A-3513400D11F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1A4C9858-C8D6-45FB-802A-3513400D11F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1A4C9858-C8D6-45FB-802A-3513400D11F3}.Release|Any CPU.Build.0 = Release|Any CPU
{2AFB749C-A6CE-4B2A-B02D-4FC7BB8ADA30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2AFB749C-A6CE-4B2A-B02D-4FC7BB8ADA30}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2AFB749C-A6CE-4B2A-B02D-4FC7BB8ADA30}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2AFB749C-A6CE-4B2A-B02D-4FC7BB8ADA30}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

77
CommonLibrary/Class1.cs Normal file
View File

@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CommonLibrary
{
public class CommonLibrary
{
#region
/// <summary>
/// 主网络端口,此处随机定义了一个数据
/// </summary>
public static int Port_Main_Net { get; } = 17652;
/// <summary>
/// 同步网络访问的端口,此处随机定义了一个数据
/// </summary>
public static int Port_Second_Net { get; } = 14568;
/// <summary>
/// 用于软件系统更新的端口,此处随机定义了一个数据
/// </summary>
public static int Port_Update_Net { get; } = 17538;
/// <summary>
/// 用于软件远程更新的端口,此处随机定义了一个数据
/// </summary>
public static int Port_Update_Remote { get; } = 26435;
#endregion
}
/// <summary>
/// 用于网络通信的二级协议头说明
/// </summary>
public class CommonHeadCode
{
/// <summary>
/// 同步通信的头说明以字母A开头
/// </summary>
public class SimplifyHeadCode
{
public static string { get; } = "A001";//A开始的表明是系统相关的
public static string { get; } = "A002";
public static string { get; } = "A003";
public static string { get; } = "A004";
public static string { get; } = "A005";
public static string { get; } = "A006";
public static string { get; } = "A007";
public static string { get; } = "A008";
public static string { get; } = "B001";//B开头的是日志请求和清空
public static string { get; } = "B002";
public static string { get; } = "B003";
public static string { get; } = "B004";
public static string { get; } = "B005";
public static string { get; } = "B006";
}
/// <summary>
/// 异步通信的头说明以字母H开头后面跟I,G,K,L,M
/// </summary>
public class MultiNetHeadCode
{
public static string 线 { get; } = "H001";
public static string { get; } = "H002";
public static string { get; } = "H003";
}
//可以在下面进行扩展,需要保证长度都是统一的
}
}

View File

@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>8c97f322-4306-40fc-afcf-753384d80046</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CommonLibrary</RootNamespace>
<AssemblyName>CommonLibrary</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<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="System.Data"/>
<Reference Include="System.Xml"/>
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</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>

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("CommonLibrary")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("CommonLibrary")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//将 ComVisible 设置为 false 将使此程序集中的类型
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("8c97f322-4306-40fc-afcf-753384d80046")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

1419
Public/BasicFramework.XML Normal file

File diff suppressed because it is too large Load Diff

BIN
Public/BasicFramework.dll Normal file

Binary file not shown.

1427
Public/IndustryEthernet.XML Normal file

File diff suppressed because it is too large Load Diff

BIN
Public/IndustryEthernet.dll Normal file

Binary file not shown.

BIN
Public/Newtonsoft.Json.dll Normal file

Binary file not shown.

8922
Public/Newtonsoft.Json.xml Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,174 @@
namespace
{
partial class FormLog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.userButton_login = new BasicFramework.UserButton();
this.userButton1 = new BasicFramework.UserButton();
this.userButton2 = new BasicFramework.UserButton();
this.userButton3 = new BasicFramework.UserButton();
this.userButton4 = new BasicFramework.UserButton();
this.userButton5 = new BasicFramework.UserButton();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.Location = new System.Drawing.Point(12, 12);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(596, 457);
this.textBox1.TabIndex = 0;
//
// userButton_login
//
this.userButton_login.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.userButton_login.BackColor = System.Drawing.Color.Transparent;
this.userButton_login.CustomerInformation = "";
this.userButton_login.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190)))));
this.userButton_login.Font = new System.Drawing.Font("微软雅黑", 9F);
this.userButton_login.Location = new System.Drawing.Point(619, 11);
this.userButton_login.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.userButton_login.Name = "userButton_login";
this.userButton_login.Size = new System.Drawing.Size(103, 26);
this.userButton_login.TabIndex = 6;
this.userButton_login.UIText = "网络日志查看";
this.userButton_login.Click += new System.EventHandler(this.userButton_login_Click);
//
// userButton1
//
this.userButton1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.userButton1.BackColor = System.Drawing.Color.Transparent;
this.userButton1.CustomerInformation = "";
this.userButton1.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190)))));
this.userButton1.Font = new System.Drawing.Font("微软雅黑", 9F);
this.userButton1.Location = new System.Drawing.Point(619, 45);
this.userButton1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.userButton1.Name = "userButton1";
this.userButton1.Size = new System.Drawing.Size(103, 26);
this.userButton1.TabIndex = 7;
this.userButton1.UIText = "网络日志清空";
this.userButton1.Click += new System.EventHandler(this.userButton1_Click);
//
// userButton2
//
this.userButton2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.userButton2.BackColor = System.Drawing.Color.Transparent;
this.userButton2.CustomerInformation = "";
this.userButton2.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190)))));
this.userButton2.Font = new System.Drawing.Font("微软雅黑", 9F);
this.userButton2.Location = new System.Drawing.Point(619, 118);
this.userButton2.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.userButton2.Name = "userButton2";
this.userButton2.Size = new System.Drawing.Size(103, 26);
this.userButton2.TabIndex = 8;
this.userButton2.UIText = "同步日志查看";
this.userButton2.Click += new System.EventHandler(this.userButton2_Click);
//
// userButton3
//
this.userButton3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.userButton3.BackColor = System.Drawing.Color.Transparent;
this.userButton3.CustomerInformation = "";
this.userButton3.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190)))));
this.userButton3.Font = new System.Drawing.Font("微软雅黑", 9F);
this.userButton3.Location = new System.Drawing.Point(619, 152);
this.userButton3.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.userButton3.Name = "userButton3";
this.userButton3.Size = new System.Drawing.Size(103, 26);
this.userButton3.TabIndex = 9;
this.userButton3.UIText = "同步日志清空";
this.userButton3.Click += new System.EventHandler(this.userButton3_Click);
//
// userButton4
//
this.userButton4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.userButton4.BackColor = System.Drawing.Color.Transparent;
this.userButton4.CustomerInformation = "";
this.userButton4.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190)))));
this.userButton4.Font = new System.Drawing.Font("微软雅黑", 9F);
this.userButton4.Location = new System.Drawing.Point(619, 225);
this.userButton4.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.userButton4.Name = "userButton4";
this.userButton4.Size = new System.Drawing.Size(103, 26);
this.userButton4.TabIndex = 10;
this.userButton4.UIText = "更新日志查看";
this.userButton4.Click += new System.EventHandler(this.userButton4_Click);
//
// userButton5
//
this.userButton5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.userButton5.BackColor = System.Drawing.Color.Transparent;
this.userButton5.CustomerInformation = "";
this.userButton5.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190)))));
this.userButton5.Font = new System.Drawing.Font("微软雅黑", 9F);
this.userButton5.Location = new System.Drawing.Point(619, 259);
this.userButton5.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.userButton5.Name = "userButton5";
this.userButton5.Size = new System.Drawing.Size(103, 26);
this.userButton5.TabIndex = 11;
this.userButton5.UIText = "更新日志清空";
this.userButton5.Click += new System.EventHandler(this.userButton5_Click);
//
// FormLog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(732, 492);
this.Controls.Add(this.userButton5);
this.Controls.Add(this.userButton4);
this.Controls.Add(this.userButton3);
this.Controls.Add(this.userButton2);
this.Controls.Add(this.userButton1);
this.Controls.Add(this.userButton_login);
this.Controls.Add(this.textBox1);
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Name = "FormLog";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "网络日志查看";
this.Load += new System.EventHandler(this.FormLog_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox textBox1;
private BasicFramework.UserButton userButton_login;
private BasicFramework.UserButton userButton1;
private BasicFramework.UserButton userButton2;
private BasicFramework.UserButton userButton3;
private BasicFramework.UserButton userButton4;
private BasicFramework.UserButton userButton5;
}
}

View File

@@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using IndustryEthernet;
using CommonLibrary;
namespace
{
public partial class FormLog : Form
{
public FormLog(Net_Simplify_Client client)
{
InitializeComponent();
net_simplify_client = client;
}
private Net_Simplify_Client net_simplify_client = null;
private void FormLog_Load(object sender, EventArgs e)
{
}
private void ReadFromServer(string head_code)
{
OperateResultString result = net_simplify_client.ReadFromServer(head_code);
if (result.IsSuccess) textBox1.Text = result.Content;
else textBox1.Text = result.ToMessageShowString();
}
private void ClearFromServer(string head_code)
{
OperateResultString result = net_simplify_client.ReadFromServer(head_code);
if (result.IsSuccess) textBox1.Text = "清除成功";
else textBox1.Text = result.ToMessageShowString();
}
private void userButton_login_Click(object sender, EventArgs e)
{
ReadFromServer(CommonHeadCode.SimplifyHeadCode.);
}
private void userButton1_Click(object sender, EventArgs e)
{
ClearFromServer(CommonHeadCode.SimplifyHeadCode.);
}
private void userButton2_Click(object sender, EventArgs e)
{
ReadFromServer(CommonHeadCode.SimplifyHeadCode.);
}
private void userButton3_Click(object sender, EventArgs e)
{
ClearFromServer(CommonHeadCode.SimplifyHeadCode.);
}
private void userButton4_Click(object sender, EventArgs e)
{
ReadFromServer(CommonHeadCode.SimplifyHeadCode.);
}
private void userButton5_Click(object sender, EventArgs e)
{
ClearFromServer(CommonHeadCode.SimplifyHeadCode.);
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,190 @@
namespace
{
partial class FormLogin
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBox_userName = new System.Windows.Forms.TextBox();
this.textBox_password = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.userButton_login = new BasicFramework.UserButton();
this.label_version = new System.Windows.Forms.Label();
this.label_copyright = new System.Windows.Forms.Label();
this.label_status = new System.Windows.Forms.Label();
this.checkBox_remeber = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(35, 59);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(74, 21);
this.label1.TabIndex = 0;
this.label1.Text = "用户名:";
//
// label2
//
this.label2.Font = new System.Drawing.Font("微软雅黑", 21F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.Location = new System.Drawing.Point(12, 9);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(396, 36);
this.label2.TabIndex = 1;
this.label2.Text = "[软件系统的名称]";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// textBox_userName
//
this.textBox_userName.Location = new System.Drawing.Point(115, 57);
this.textBox_userName.Name = "textBox_userName";
this.textBox_userName.Size = new System.Drawing.Size(189, 26);
this.textBox_userName.TabIndex = 2;
this.textBox_userName.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox_userName_KeyDown);
//
// textBox_password
//
this.textBox_password.Location = new System.Drawing.Point(115, 98);
this.textBox_password.Name = "textBox_password";
this.textBox_password.PasswordChar = '*';
this.textBox_password.Size = new System.Drawing.Size(189, 26);
this.textBox_password.TabIndex = 4;
this.textBox_password.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox_password_KeyDown);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label3.Location = new System.Drawing.Point(35, 100);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(73, 21);
this.label3.TabIndex = 3;
this.label3.Text = "密 码:";
//
// userButton_login
//
this.userButton_login.BackColor = System.Drawing.Color.Transparent;
this.userButton_login.CustomerInformation = "";
this.userButton_login.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190)))));
this.userButton_login.Font = new System.Drawing.Font("微软雅黑", 12F);
this.userButton_login.Location = new System.Drawing.Point(318, 57);
this.userButton_login.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.userButton_login.Name = "userButton_login";
this.userButton_login.Size = new System.Drawing.Size(76, 67);
this.userButton_login.TabIndex = 5;
this.userButton_login.UIText = "登录";
this.userButton_login.Click += new System.EventHandler(this.userButton_login_Click);
//
// label_version
//
this.label_version.AutoSize = true;
this.label_version.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label_version.ForeColor = System.Drawing.Color.Gray;
this.label_version.Location = new System.Drawing.Point(1, 176);
this.label_version.Name = "label_version";
this.label_version.Size = new System.Drawing.Size(44, 17);
this.label_version.TabIndex = 6;
this.label_version.Text = "版本:";
//
// label_copyright
//
this.label_copyright.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label_copyright.ForeColor = System.Drawing.Color.Gray;
this.label_copyright.Location = new System.Drawing.Point(215, 176);
this.label_copyright.Name = "label_copyright";
this.label_copyright.Size = new System.Drawing.Size(206, 17);
this.label_copyright.TabIndex = 7;
this.label_copyright.Text = "本软件著作权归某某某所有";
this.label_copyright.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// label_status
//
this.label_status.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label_status.ForeColor = System.Drawing.Color.Blue;
this.label_status.Location = new System.Drawing.Point(15, 151);
this.label_status.Name = "label_status";
this.label_status.Size = new System.Drawing.Size(393, 19);
this.label_status.TabIndex = 8;
this.label_status.Text = "[登录的消息提示]";
this.label_status.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// checkBox_remeber
//
this.checkBox_remeber.AutoSize = true;
this.checkBox_remeber.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.checkBox_remeber.Location = new System.Drawing.Point(115, 127);
this.checkBox_remeber.Name = "checkBox_remeber";
this.checkBox_remeber.Size = new System.Drawing.Size(87, 21);
this.checkBox_remeber.TabIndex = 9;
this.checkBox_remeber.Text = "记住密码?";
this.checkBox_remeber.UseVisualStyleBackColor = true;
//
// FormLogin
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(420, 194);
this.Controls.Add(this.checkBox_remeber);
this.Controls.Add(this.label_status);
this.Controls.Add(this.label_copyright);
this.Controls.Add(this.label_version);
this.Controls.Add(this.userButton_login);
this.Controls.Add(this.textBox_password);
this.Controls.Add(this.label3);
this.Controls.Add(this.textBox_userName);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.MaximizeBox = false;
this.Name = "FormLogin";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "系统登录";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormLogin_FormClosing);
this.Load += new System.EventHandler(this.FormLogin_Load);
this.Shown += new System.EventHandler(this.FormLogin_Shown);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox_userName;
private System.Windows.Forms.TextBox textBox_password;
private System.Windows.Forms.Label label3;
private BasicFramework.UserButton userButton_login;
private System.Windows.Forms.Label label_version;
private System.Windows.Forms.Label label_copyright;
private System.Windows.Forms.Label label_status;
private System.Windows.Forms.CheckBox checkBox_remeber;
}
}

View File

@@ -0,0 +1,302 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using IndustryEthernet;
using Newtonsoft.Json.Linq;
namespace
{
//=================================================================================================
// 登录窗口,此处实现了一些常用的代码,具体的版本号验证及账户验证需要根据实际需求实现
//=================================================================================================
public partial class FormLogin : Form
{
public FormLogin()
{
InitializeComponent();
}
#region
/// <summary>
/// 指示窗体是否已经显示
/// </summary>
private bool IsWindowShow { get; set; } = false;
private void FormLogin_Load(object sender, EventArgs e)
{
label_status.Visible = false;
UserClient.JsonSettings.FileSavePath = Application.StartupPath + @"\settings.txt";
UserClient.JsonSettings.LoadSettings();//根据实际实际情况选中解密算法默认采用DES加密解密算法
label_version.Text = "版本:" + UserClient.CurrentVersion.ToString();
}
private void FormLogin_Shown(object sender, EventArgs e)
{
IsWindowShow = true;
//加载数据
textBox_userName.Text = UserClient.JsonSettings.LoginName ?? "";
textBox_password.Text = UserClient.JsonSettings.Password ?? "";
checkBox_remeber.Checked = UserClient.JsonSettings.Password != "";
//初始化输入焦点
if (UserClient.JsonSettings.Password != "") userButton_login.Focus();
else if (UserClient.JsonSettings.LoginName != "") textBox_password.Focus();
else textBox_userName.Focus();
}
private void FormLogin_FormClosing(object sender, FormClosingEventArgs e)
{
//退出
IsWindowShow = false;
//延时
Thread.Sleep(100);
}
#endregion
#region
private void textBox_userName_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter) textBox_password.Focus();
}
private void textBox_password_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter) userButton_login.PerformClick();
}
private void userButton_login_Click(object sender, EventArgs e)
{
label_status.Visible = true;
//验证输入
if (string.IsNullOrEmpty(textBox_userName.Text))
{
label_status.Text = "请输入用户名";
textBox_userName.Focus();
return;
}
if(string.IsNullOrEmpty(textBox_password.Text))
{
label_status.Text = "请输入密码";
textBox_password.Focus();
return;
}
label_status.Text = "正在验证维护状态...";
UISettings(false);
ThreadAccountLogin = new Thread(ThreadCheckAccount);
ThreadAccountLogin.IsBackground = true;
ThreadAccountLogin.Start();
}
/// <summary>
/// 界面的UI使能操作
/// </summary>
/// <param name="enable">值</param>
private void UISettings(bool enable)
{
textBox_userName.Enabled = enable;
textBox_password.Enabled = enable;
userButton_login.Enabled = enable;
checkBox_remeber.Enabled = enable;
}
#endregion
#region
/// <summary>
/// 用于访问服务器数据的网络对象类,必须修改这个端口参数,否则运行失败
/// </summary>
private Net_Simplify_Client net_simplify_client = new Net_Simplify_Client(
new System.Net.IPEndPoint(System.Net.IPAddress.Parse(UserClient.ServerIp), CommonLibrary.CommonLibrary.Port_Second_Net));
/// <summary>
/// 用于验证的后台线程
/// </summary>
private Thread ThreadAccountLogin = null;
/// <summary>
/// 用户账户验证的后台端
/// </summary>
private void ThreadCheckAccount()
{
//定义委托
Action<string> message_show = delegate (string message)
{
label_status.Text = message;
};
Action start_update = delegate
{
//需要该exe支持否则将无法是实现自动版本控制
string update_file_name = Application.StartupPath + @"\软件自动更新.exe";
try
{
System.Diagnostics.Process.Start(update_file_name);
}
catch
{
MessageBox.Show("更新程序启动失败,请检查文件是否丢失,联系管理员获取。");
}
};
Action thread_finish = delegate
{
UISettings(true);
};
//延时
Thread.Sleep(200);
//请求指令头数据,该数据需要更具实际情况更改
OperateResultString result = net_simplify_client.ReadFromServer(CommonLibrary.CommonHeadCode.SimplifyHeadCode.);
if(result.IsSuccess)
{
//例如返回结果为1说明允许登录0则说明服务器处于维护中并将信息显示
if (result.Content != "1")
{
if (IsHandleCreated) Invoke(message_show, result.Content.Substring(1));
if (IsHandleCreated) Invoke(thread_finish);
return;
}
}
else
{
//访问失败
if (IsHandleCreated) Invoke(message_show, result.Message);
if (IsHandleCreated) Invoke(thread_finish);
return;
}
//版本验证
if (IsHandleCreated) Invoke(message_show, "正在验证版本...");
else return;
//延时
Thread.Sleep(200);
result = net_simplify_client.ReadFromServer(CommonLibrary.CommonHeadCode.SimplifyHeadCode.);
if (result.IsSuccess)
{
//服务器应该返回服务器的版本号
BasicFramework.SystemVersion sv = new BasicFramework.SystemVersion(result.Content);
if (UserClient.CurrentVersion != sv)
{
//保存新版本信息
UserClient.JsonSettings.IsNewVersionRunning = true;
UserClient.JsonSettings.SaveSettings();
//和当前系统版本号不一致,启动更新
if (IsHandleCreated) Invoke(start_update);
return;
}
}
else
{
//访问失败
if (IsHandleCreated) Invoke(message_show, result.Message);
if (IsHandleCreated) Invoke(thread_finish);
return;
}
//检查账户
if (IsHandleCreated) Invoke(message_show, "正在检查账户...");
else return;
//延时
Thread.Sleep(200);
//===================================================================================
// 根据实际情况校验,选择数据库校验或是将用户名密码发至服务器校验
// 以下展示了服务器校验的方法如您需要数据库校验请删除下面并改成SQL访问验证的方式
//包装数据
Newtonsoft.Json.Linq.JObject json = new Newtonsoft.Json.Linq.JObject();
json.Add(BasicFramework.UserAccount.UserNameText, new Newtonsoft.Json.Linq.JValue(textBox_userName.Text));
json.Add(BasicFramework.UserAccount.PasswordText, new Newtonsoft.Json.Linq.JValue(textBox_password.Text));
result = net_simplify_client.ReadFromServer(CommonLibrary.CommonHeadCode.SimplifyHeadCode.+json.ToString());
if (result.IsSuccess)
{
//服务器应该返回账户的信息
BasicFramework.UserAccount account = JObject.Parse(result.Content).ToObject<BasicFramework.UserAccount>();
if(!account.LoginEnable)
{
//不允许登录
if (IsHandleCreated) Invoke(message_show, account.ForbidMessage);
if (IsHandleCreated) Invoke(thread_finish);
return;
}
UserClient.UserAccount = account;
}
else
{
//访问失败
if (IsHandleCreated) Invoke(message_show, result.Message);
if (IsHandleCreated) Invoke(thread_finish);
return;
}
//登录成功,进行保存用户名称和密码
UserClient.JsonSettings.LoginName = textBox_userName.Text;
UserClient.JsonSettings.Password = checkBox_remeber.Checked ? textBox_password.Text : "";
UserClient.JsonSettings.SaveSettings();
//================================================================================
//验证结束后,根据需要是否下载服务器的数据,或是等到进入主窗口下载也可以
//如果有参数决定主窗口的显示方式,那么必要在下面向服务器请求数据
//以下展示了初始化参数的功能
if (IsHandleCreated) Invoke(message_show, "正在下载参数...");
else return;
//延时
Thread.Sleep(200);
result = net_simplify_client.ReadFromServer(CommonLibrary.CommonHeadCode.SimplifyHeadCode.);
if(result.IsSuccess)
{
//服务器返回初始化的数据,此处进行数据的提取,有可能包含了多个数据
json = Newtonsoft.Json.Linq.JObject.Parse(result.Content);
//例如公告数据
UserClient.Announcement = BasicFramework.SoftBasic.GetValueFromJsonObject(json, nameof(UserClient.Announcement), "");
}
else
{
//访问失败
if (IsHandleCreated) Invoke(message_show, result.Message);
if (IsHandleCreated) Invoke(thread_finish);
return;
}
//启动主窗口
if (IsHandleCreated) Invoke(new Action(() =>
{
DialogResult = DialogResult.OK;
return;
}));
}
#endregion
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,481 @@
namespace
{
partial class FormMainWindow
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel_Version = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel3 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel_status = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel4 = new System.Windows.Forms.ToolStripStatusLabel();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.panel1 = new System.Windows.Forms.Panel();
this.label7 = new System.Windows.Forms.Label();
this.listBox1 = new System.Windows.Forms.ListBox();
this.label_address = new System.Windows.Forms.Label();
this.label_last = new System.Windows.Forms.Label();
this.label_times = new System.Windows.Forms.Label();
this.label_register = new System.Windows.Forms.Label();
this.label_grade = new System.Windows.Forms.Label();
this.label_userName = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.label_Announcement = new System.Windows.Forms.Label();
this.label_factory = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.statusStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabel1,
this.toolStripStatusLabel2,
this.toolStripStatusLabel_Version,
this.toolStripStatusLabel3,
this.toolStripStatusLabel_status,
this.toolStripStatusLabel4});
this.statusStrip1.Location = new System.Drawing.Point(0, 454);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(921, 22);
this.statusStrip1.TabIndex = 0;
this.statusStrip1.Text = "statusStrip1";
//
// toolStripStatusLabel1
//
this.toolStripStatusLabel1.ForeColor = System.Drawing.Color.Gray;
this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
this.toolStripStatusLabel1.Size = new System.Drawing.Size(152, 17);
this.toolStripStatusLabel1.Text = "本软件著作权归某某某所有";
//
// toolStripStatusLabel2
//
this.toolStripStatusLabel2.Name = "toolStripStatusLabel2";
this.toolStripStatusLabel2.Size = new System.Drawing.Size(68, 17);
this.toolStripStatusLabel2.Text = " 版本:";
//
// toolStripStatusLabel_Version
//
this.toolStripStatusLabel_Version.ForeColor = System.Drawing.Color.Purple;
this.toolStripStatusLabel_Version.Name = "toolStripStatusLabel_Version";
this.toolStripStatusLabel_Version.Size = new System.Drawing.Size(43, 17);
this.toolStripStatusLabel_Version.Text = "V1.0.0";
//
// toolStripStatusLabel3
//
this.toolStripStatusLabel3.Name = "toolStripStatusLabel3";
this.toolStripStatusLabel3.Size = new System.Drawing.Size(108, 17);
this.toolStripStatusLabel3.Text = " 客户端状态:";
//
// toolStripStatusLabel_status
//
this.toolStripStatusLabel_status.Name = "toolStripStatusLabel_status";
this.toolStripStatusLabel_status.Size = new System.Drawing.Size(101, 17);
this.toolStripStatusLabel_status.Text = "正在连接服务器...";
//
// toolStripStatusLabel4
//
this.toolStripStatusLabel4.Name = "toolStripStatusLabel4";
this.toolStripStatusLabel4.Size = new System.Drawing.Size(84, 17);
this.toolStripStatusLabel4.Text = " 温馨提示:";
//
// menuStrip1
//
this.menuStrip1.BackColor = System.Drawing.SystemColors.Control;
this.menuStrip1.Font = new System.Drawing.Font("Microsoft YaHei UI", 15F);
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(921, 33);
this.menuStrip1.TabIndex = 1;
this.menuStrip1.Text = "menuStrip1";
//
// 管理员ToolStripMenuItem
//
this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem});
this.ToolStripMenuItem.Name = "管理员ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(84, 29);
this.ToolStripMenuItem.Text = "管理员";
//
// 更改公告ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "更改公告ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 30);
this.ToolStripMenuItem.Text = "更改公告";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 日志查看ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "日志查看ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 30);
this.ToolStripMenuItem.Text = "日志查看";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 账户管理ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "账户管理ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 30);
this.ToolStripMenuItem.Text = "账户管理";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 远程更新ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "远程更新ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 30);
this.ToolStripMenuItem.Text = "远程更新";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 设置ToolStripMenuItem
//
this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem});
this.ToolStripMenuItem.Name = "设置ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(64, 29);
this.ToolStripMenuItem.Text = "设置";
//
// 修改密码ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "修改密码ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 30);
this.ToolStripMenuItem.Text = "修改密码";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 关于ToolStripMenuItem
//
this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem});
this.ToolStripMenuItem.Name = "关于ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(64, 29);
this.ToolStripMenuItem.Text = "关于";
//
// 关于本软件ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "关于本软件ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(184, 30);
this.ToolStripMenuItem.Text = "关于本软件";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 更新日志ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "更新日志ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(184, 30);
this.ToolStripMenuItem.Text = "更新日志";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 版本号说明ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "版本号说明ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(184, 30);
this.ToolStripMenuItem.Text = "版本号说明";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// panel1
//
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel1.Controls.Add(this.label_factory);
this.panel1.Controls.Add(this.label9);
this.panel1.Controls.Add(this.label7);
this.panel1.Controls.Add(this.listBox1);
this.panel1.Controls.Add(this.label_address);
this.panel1.Controls.Add(this.label_last);
this.panel1.Controls.Add(this.label_times);
this.panel1.Controls.Add(this.label_register);
this.panel1.Controls.Add(this.label_grade);
this.panel1.Controls.Add(this.label_userName);
this.panel1.Controls.Add(this.label6);
this.panel1.Controls.Add(this.label5);
this.panel1.Controls.Add(this.label4);
this.panel1.Controls.Add(this.label3);
this.panel1.Controls.Add(this.label2);
this.panel1.Controls.Add(this.label1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Right;
this.panel1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.panel1.Location = new System.Drawing.Point(697, 33);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(224, 421);
this.panel1.TabIndex = 2;
//
// label7
//
this.label7.AutoSize = true;
this.label7.ForeColor = System.Drawing.Color.DimGray;
this.label7.Location = new System.Drawing.Point(8, 146);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(104, 17);
this.label7.TabIndex = 13;
this.label7.Text = "所有在线客户端:";
//
// listBox1
//
this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listBox1.FormattingEnabled = true;
this.listBox1.ItemHeight = 17;
this.listBox1.Location = new System.Drawing.Point(11, 166);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(200, 242);
this.listBox1.TabIndex = 12;
//
// label_address
//
this.label_address.AutoSize = true;
this.label_address.Location = new System.Drawing.Point(82, 109);
this.label_address.Name = "label_address";
this.label_address.Size = new System.Drawing.Size(13, 17);
this.label_address.TabIndex = 11;
this.label_address.Text = "-";
//
// label_last
//
this.label_last.AutoSize = true;
this.label_last.Location = new System.Drawing.Point(82, 92);
this.label_last.Name = "label_last";
this.label_last.Size = new System.Drawing.Size(13, 17);
this.label_last.TabIndex = 10;
this.label_last.Text = "-";
//
// label_times
//
this.label_times.AutoSize = true;
this.label_times.Location = new System.Drawing.Point(82, 75);
this.label_times.Name = "label_times";
this.label_times.Size = new System.Drawing.Size(13, 17);
this.label_times.TabIndex = 9;
this.label_times.Text = "-";
//
// label_register
//
this.label_register.AutoSize = true;
this.label_register.Location = new System.Drawing.Point(82, 58);
this.label_register.Name = "label_register";
this.label_register.Size = new System.Drawing.Size(13, 17);
this.label_register.TabIndex = 8;
this.label_register.Text = "-";
//
// label_grade
//
this.label_grade.AutoSize = true;
this.label_grade.Location = new System.Drawing.Point(82, 24);
this.label_grade.Name = "label_grade";
this.label_grade.Size = new System.Drawing.Size(13, 17);
this.label_grade.TabIndex = 7;
this.label_grade.Text = "-";
//
// label_userName
//
this.label_userName.AutoSize = true;
this.label_userName.Location = new System.Drawing.Point(82, 7);
this.label_userName.Name = "label_userName";
this.label_userName.Size = new System.Drawing.Size(13, 17);
this.label_userName.TabIndex = 6;
this.label_userName.Text = "-";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(8, 109);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(79, 17);
this.label6.TabIndex = 5;
this.label6.Text = "上次登录IP";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(8, 92);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(68, 17);
this.label5.TabIndex = 4;
this.label5.Text = "最近登录:";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(8, 75);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(68, 17);
this.label4.TabIndex = 3;
this.label4.Text = "登录频次:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(8, 58);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(68, 17);
this.label3.TabIndex = 2;
this.label3.Text = "注册时间:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(8, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(68, 17);
this.label2.TabIndex = 1;
this.label2.Text = "权限等级:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(8, 7);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 17);
this.label1.TabIndex = 0;
this.label1.Text = "用户名:";
//
// label_Announcement
//
this.label_Announcement.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label_Announcement.Font = new System.Drawing.Font("楷体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label_Announcement.ForeColor = System.Drawing.Color.Red;
this.label_Announcement.Location = new System.Drawing.Point(283, 0);
this.label_Announcement.Name = "label_Announcement";
this.label_Announcement.Size = new System.Drawing.Size(638, 33);
this.label_Announcement.TabIndex = 3;
this.label_Announcement.Text = "[公告]";
this.label_Announcement.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label_factory
//
this.label_factory.AutoSize = true;
this.label_factory.Location = new System.Drawing.Point(82, 41);
this.label_factory.Name = "label_factory";
this.label_factory.Size = new System.Drawing.Size(13, 17);
this.label_factory.TabIndex = 15;
this.label_factory.Text = "-";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(8, 41);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(68, 17);
this.label9.TabIndex = 14;
this.label9.Text = "所属分厂:";
//
// FormMainWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(921, 476);
this.Controls.Add(this.label_Announcement);
this.Controls.Add(this.panel1);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Name = "FormMainWindow";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "主界面";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormMainWindow_FormClosing);
this.Load += new System.EventHandler(this.FormMainWindow_Load);
this.Shown += new System.EventHandler(this.FormMainWindow_Shown);
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel2;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel_Version;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel3;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel_status;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel4;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Label label_address;
private System.Windows.Forms.Label label_last;
private System.Windows.Forms.Label label_times;
private System.Windows.Forms.Label label_register;
private System.Windows.Forms.Label label_grade;
private System.Windows.Forms.Label label_userName;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label_Announcement;
private System.Windows.Forms.Label label_factory;
private System.Windows.Forms.Label label9;
}
}

View File

@@ -0,0 +1,307 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BasicFramework;
using IndustryEthernet;
using Newtonsoft.Json.Linq;
using CommonLibrary;
using System.Threading;
//============================================================================
// 模版日期 2017-02-21
// 创建人 胡少林
// 版权所有 胡少林
// 授权说明 模版仅授权个人使用如需商用请联系hsl200909@163.com洽谈
// 说明 JSON组件引用自james newton-king遵循MIT授权协议
//============================================================================
//============================================================================
//
// 注意:本代码的相关操作未作密码验证,如有需要,请自行完成
// 示例具体示例参照Form1_FormClosing(object sender, FormClosingEventArgs e)方法
// 如果遇到启动调试就退出了请注释掉Program.cs文件中的指允许启动一个实例的代码
//
//============================================================================
namespace
{
public partial class FormMainWindow : Form
{
public FormMainWindow()
{
InitializeComponent();
}
#region
/// <summary>
/// 指示窗口是否显示的标志
/// </summary>
private bool IsWindowShow { get; set; } = false;
private void FormMainWindow_Load(object sender, EventArgs e)
{
//窗口载入
label_userName.Text = UserClient.UserAccount.UserName;
label_grade.Text = AccountGrade.GetDescription(UserClient.UserAccount.Grade);
label_factory.Text = UserClient.UserAccount.Factory;
label_register.Text = UserClient.UserAccount.RegisterTime.ToString();
label_last.Text = UserClient.UserAccount.LastLoginTime.ToString();
label_times.Text = UserClient.UserAccount.LoginFrequency.ToString();
label_address.Text = UserClient.UserAccount.LastLoginIpAddress;
//绑定事件仅执行一次不能放到show方法里
net_socket_client.MessageAlerts += Net_socket_client_MessageAlerts;
net_socket_client.LoginFailed += Net_socket_client_LoginFailed;
net_socket_client.LoginSuccess += Net_socket_client_LoginSuccess;
net_socket_client.AcceptByte += Net_socket_client_AcceptByte;
net_socket_client.AcceptString += Net_socket_client_AcceptString;
//启动网络服务
Net_Socket_Client_Initialization();
label_Announcement.Text = UserClient.Announcement;
toolStripStatusLabel_Version.Text = UserClient.CurrentVersion.ToString();
}
private void FormMainWindow_Shown(object sender, EventArgs e)
{
//窗口显示
IsWindowShow = true;
//是否显示更新日志
if(UserClient.JsonSettings.IsNewVersionRunning)
{
UserClient.JsonSettings.IsNewVersionRunning = false;
UserClient.JsonSettings.SaveSettings();
ToolStripMenuItem_Click(null, new EventArgs());
}
//根据权限使能菜单
if(UserClient.UserAccount.Grade<AccountGrade.SuperAdministrator)
{
ToolStripMenuItem.Enabled = false;
ToolStripMenuItem.Enabled = false;
ToolStripMenuItem.Enabled = false;
}
}
private void FormMainWindow_FormClosing(object sender, FormClosingEventArgs e)
{
//窗口关闭
IsWindowShow = false;
net_socket_client.ClientClose();
//等待一秒退出
FormWaitInfomation fwm = new FormWaitInfomation("正在退出程序...", 1000);
fwm.ShowDialog();
fwm.Dispose();
}
#endregion
#region
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
//实例化一个密码修改的窗口,并指定了实现修改的具体方法,指定了密码长度
FormPasswordModify fpm = new FormPasswordModify(UserClient.UserAccount.Password,
p => {
JObject json = new JObject();json.Add(UserAccount.UserNameText, UserClient.UserAccount.UserName);
json.Add(UserAccount.PasswordText, p);
return net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode. + json.ToString()).IsSuccess;
}, 6, 8);
fpm.ShowDialog();
fpm.Dispose();
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
FormAbout fa = new FormAbout("软件系统", UserClient.CurrentVersion, 2017, "张三");
fa.ShowDialog();
fa.Dispose();
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
//更新情况复位
if (UserClient.JsonSettings.IsNewVersionRunning)
{
UserClient.JsonSettings.IsNewVersionRunning = false;
UserClient.JsonSettings.SaveSettings();
}
FormUpdateLog ful = new FormUpdateLog(UserClient.HistoryVersions);
ful.ShowDialog();
ful.Dispose();
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
FormAboutVersion fav = new FormAboutVersion(UserClient.CurrentVersion);
fav.ShowDialog();
fav.Dispose();
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
FormInputAndAction fiaa = new FormInputAndAction(str => net_simplify_client.ReadFromServer(
CommonHeadCode.SimplifyHeadCode. + str).IsSuccess,UserClient.Announcement);
fiaa.ShowDialog();
fiaa.Dispose();
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
FormLog flg = new FormLog(net_simplify_client);
flg.ShowDialog();
flg.Dispose();
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
FormAccountManage fam = new FormAccountManage(() =>
{
OperateResultString result = net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode.);
if (result.IsSuccess) return result.Content;
else return result.ToMessageShowString();
},m => net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode. + m).IsSuccess);
fam.ShowDialog();
fam.Dispose();
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
//暂不支持,期待下个版本
MessageBox.Show("暂不支持该特性");
}
#endregion
#region
private Net_Socket_Client net_socket_client = new Net_Socket_Client();
private void Net_Socket_Client_Initialization()
{
try
{
net_socket_client.EndPointServer = new System.Net.IPEndPoint(
System.Net.IPAddress.Parse(UserClient.ServerIp),
CommonLibrary.CommonLibrary.Port_Main_Net);
net_socket_client.ClientAlias = UserClient.UserAccount.UserName;
net_socket_client.ClientStart();
}
catch(Exception ex)
{
SoftBasic.ShowExceptionMessage(ex);
}
}
private void Net_socket_client_AcceptString(HuTcpState object1, string object2)
{
//接收到服务器发来的字符串数据
string head_code = object2.Substring(0, 4);
if (head_code == CommonHeadCode.MultiNetHeadCode.)
{
if (IsHandleCreated) Invoke(new Action(() =>
{
FormPopup fpp = new FormPopup(object2.Substring(4), Color.DodgerBlue, 10000);
fpp.Show();
}));
}
else if (head_code == CommonHeadCode.MultiNetHeadCode.线)
{
if (IsHandleCreated) Invoke(new Action(() =>
{
listBox1.DataSource = object2.Substring(4).Split('#');
}));
}
else if (head_code == CommonHeadCode.MultiNetHeadCode.)
{
if (IsHandleCreated) Invoke(new Action(() =>
{
Close();
}));
}
else if(head_code==CommonHeadCode.SimplifyHeadCode.)
{
//此处应用到了同步类的指令头
if (IsHandleCreated) Invoke(new Action(() =>
{
UserClient.Announcement = object2.Substring(4);
label_Announcement.Text= object2.Substring(4);
FormPopup fpp = new FormPopup(object2.Substring(4), Color.DodgerBlue, 10000);
fpp.Show();
}));
}
}
private void Net_socket_client_AcceptByte(HuTcpState object1, byte[] object2)
{
//接收到服务器发来的字节数据
}
private void Net_socket_client_LoginSuccess()
{
//登录成功,或重新登录成功的事件,有些数据的初始化可以放在此处
if (IsHandleCreated) Invoke(new Action(() =>
{
toolStripStatusLabel_status.Text = "客户端启动成功";
}));
}
private void Net_socket_client_LoginFailed(int object1)
{
//登录失败的情况,如果连续三次连接失败,请考虑退出系统
if (object1 > 3)
{
if (IsHandleCreated) Invoke(new Action(() =>
{
Close();
}));
}
}
private void Net_socket_client_MessageAlerts(string object1)
{
//信息提示
if (IsHandleCreated) Invoke(new Action(() =>
{
toolStripStatusLabel_status.Text = object1;
}));
}
#endregion
#region
//=========================================================================================
//
// 在本界面任意地方调用net_simplify_client.ReadFromServer("[指令头]")即可获取服务器数据
// 处理结果之前先进行判定,具体参照示例
//
//=========================================================================================
/// <summary>
/// 用于界面请求访问服务器数据所用
/// </summary>
private Net_Simplify_Client net_simplify_client = new Net_Simplify_Client(
new System.Net.IPEndPoint(System.Net.IPAddress.Parse(UserClient.ServerIp),
CommonLibrary.CommonLibrary.Port_Second_Net));
#endregion
}
}

View File

@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>138, 17</value>
</metadata>
</root>

View File

@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
//=====================================================================
//为了强制只启动一个应用程序的实例
Process process = Process.GetCurrentProcess();
//遍历应用程序的同名进程组
foreach (Process p in Process.GetProcessesByName(process.ProcessName))
{
//不是同一进程则关闭刚刚创建的进程
if (p.Id != process.Id)
{
//此处显示原先的窗口需要一定的时间,不然无法显示
ShowWindowAsync(p.MainWindowHandle, 9);
SetForegroundWindow(p.MainWindowHandle);
System.Threading.Thread.Sleep(10);
Application.Exit();//关闭当前的应用程序
return;
}
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//===================================================================
//运行主窗口之前先进行账户的验证
FormLogin login = new FormLogin();
if (login.ShowDialog() == DialogResult.OK)
{
login.Dispose();
Application.Run(new FormMainWindow());
}
else
{
login.Dispose();
}
}
[DllImport("User32.dll")]
private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
[DllImport("User32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("软件系统客户端模版")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("软件系统客户端模版")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//将 ComVisible 设置为 false 将使此程序集中的类型
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("1a4c9858-c8d6-45fb-802a-3513400d11f3")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 4.0.30319.42000
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace .Properties
{
/// <summary>
/// 强类型资源类,用于查找本地化字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// 返回此类使用的缓存 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("软件系统客户端模版.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 覆盖当前线程的 CurrentUICulture 属性
/// 使用此强类型的资源类的资源查找。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace .Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace
{
//====================================================================================================
// 模版说明:
//====================================================================================================
public class UserClient
{
public static BasicFramework.JsonSettings JsonSettings = new BasicFramework.JsonSettings();
/// <summary>
/// 本软件的当前版本,用来验证更新的关键依据
/// </summary>
public static BasicFramework.SystemVersion CurrentVersion { get; } = new BasicFramework.SystemVersion("1.0.0");
/// <summary>
/// 服务器的IP地址默认为127.0.0.1,可用于单机调试
/// </summary>
public static string ServerIp { get; } = "127.0.0.1";
/// <summary>
/// 所有版本更新信息的对象
/// </summary>
public static BasicFramework.ClassSystemVersion HistoryVersions { get; } = new BasicFramework.ClassSystemVersion()
{
Versions = new List<BasicFramework.VersionInfo>()
{
//写入所有的历史版本信息,这样就能在更新日志的界面查看到信息
new BasicFramework.VersionInfo()
{
VersionNum=new BasicFramework.SystemVersion("1.0.0"),
ReleaseDate=new DateTime(2017,1,1),//该版本发布的日期
UpdateDetails=new StringBuilder("1.本系统第一版本正式发布使用。"+Environment.NewLine+
"2.提供了多客户端用时在线的功能。"+Environment.NewLine+
"3.需要用户自行添加"),
},
},
};
/// <summary>
/// 设置或获取系统的公告
/// </summary>
public static string Announcement { get; set; } = "";
/// <summary>
/// 当前系统的登录账户
/// </summary>
public static BasicFramework.UserAccount UserAccount { get; set; } = new BasicFramework.UserAccount();
}
}

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net35" />
</packages>

View File

@@ -0,0 +1,119 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1A4C9858-C8D6-45FB-802A-3513400D11F3}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>软件系统客户端模版</RootNamespace>
<AssemblyName>软件系统客户端模版</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="BasicFramework, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Public\BasicFramework.dll</HintPath>
</Reference>
<Reference Include="CommonLibrary">
<HintPath>..\CommonLibrary\bin\Debug\CommonLibrary.dll</HintPath>
</Reference>
<Reference Include="IndustryEthernet, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Public\IndustryEthernet.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net35\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FormLog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormLog.Designer.cs">
<DependentUpon>FormLog.cs</DependentUpon>
</Compile>
<Compile Include="FormLogin.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormLogin.Designer.cs">
<DependentUpon>FormLogin.cs</DependentUpon>
</Compile>
<Compile Include="FormMainWindow.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormMainWindow.Designer.cs">
<DependentUpon>FormMainWindow.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UserClient.cs" />
<EmbeddedResource Include="FormLog.resx">
<DependentUpon>FormLog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FormLogin.resx">
<DependentUpon>FormLogin.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FormMainWindow.resx">
<DependentUpon>FormMainWindow.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</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>

View File

@@ -0,0 +1,302 @@
namespace
{
partial class Form1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false。</param>
protected override void Dispose(bool disposing)
{
//紧急存储数据
UserServer.ServerSettings.SaveToFile();
UserServer.ServerAccounts.SaveFile();
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel_version = new System.Windows.Forms.ToolStripStatusLabel();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.listBox1 = new System.Windows.Forms.ListBox();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.statusStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabel1,
this.toolStripStatusLabel2,
this.toolStripStatusLabel_version});
this.statusStrip1.Location = new System.Drawing.Point(0, 408);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(758, 22);
this.statusStrip1.TabIndex = 0;
this.statusStrip1.Text = "statusStrip1";
//
// toolStripStatusLabel1
//
this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
this.toolStripStatusLabel1.Size = new System.Drawing.Size(131, 17);
this.toolStripStatusLabel1.Text = "本软件著作权归***所有";
//
// toolStripStatusLabel2
//
this.toolStripStatusLabel2.Name = "toolStripStatusLabel2";
this.toolStripStatusLabel2.Size = new System.Drawing.Size(88, 17);
this.toolStripStatusLabel2.Text = " 软件版本:";
//
// toolStripStatusLabel_version
//
this.toolStripStatusLabel_version.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(192)))));
this.toolStripStatusLabel_version.Name = "toolStripStatusLabel_version";
this.toolStripStatusLabel_version.Size = new System.Drawing.Size(43, 17);
this.toolStripStatusLabel_version.Text = "V1.0.0";
//
// menuStrip1
//
this.menuStrip1.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.menuStrip1.Font = new System.Drawing.Font("微软雅黑", 12F);
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(758, 29);
this.menuStrip1.TabIndex = 1;
this.menuStrip1.Text = "menuStrip1";
//
// 设置ToolStripMenuItem
//
this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem});
this.ToolStripMenuItem.Name = "设置ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(54, 25);
this.ToolStripMenuItem.Text = "设置";
//
// 版本控制ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "版本控制ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(152, 26);
this.ToolStripMenuItem.Text = "版本控制";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 维护切换ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "维护切换ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(152, 26);
this.ToolStripMenuItem.Text = "维护切换";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 消息发送ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "消息发送ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(152, 26);
this.ToolStripMenuItem.Text = "消息发送";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 一键断开ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "一键断开ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(152, 26);
this.ToolStripMenuItem.Text = "一键断开";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 关于ToolStripMenuItem
//
this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem,
this.ToolStripMenuItem});
this.ToolStripMenuItem.Name = "关于ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(54, 25);
this.ToolStripMenuItem.Text = "关于";
//
// 关于软件ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "关于软件ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(160, 26);
this.ToolStripMenuItem.Text = "关于软件";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 版本号说明ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "版本号说明ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(160, 26);
this.ToolStripMenuItem.Text = "版本号说明";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 启动服务器ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "启动服务器ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(102, 25);
this.ToolStripMenuItem.Text = "启动服务器";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// label3
//
this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label3.BackColor = System.Drawing.Color.LimeGreen;
this.label3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.label3.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label3.Location = new System.Drawing.Point(661, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(97, 29);
this.label3.TabIndex = 7;
this.label3.Text = "可登录";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label4
//
this.label4.ForeColor = System.Drawing.Color.Chocolate;
this.label4.Location = new System.Drawing.Point(146, 40);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(80, 17);
this.label4.TabIndex = 12;
this.label4.Text = "0";
this.label4.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// textBox1
//
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.Location = new System.Drawing.Point(237, 60);
this.textBox1.Multiline = true;
this.textBox1.Name = "textBox1";
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.textBox1.Size = new System.Drawing.Size(511, 344);
this.textBox1.TabIndex = 11;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(234, 40);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(68, 17);
this.label2.TabIndex = 10;
this.label2.Text = "系统消息:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 40);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(80, 17);
this.label1.TabIndex = 9;
this.label1.Text = "在线客户端:";
//
// listBox1
//
this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.listBox1.FormattingEnabled = true;
this.listBox1.ItemHeight = 17;
this.listBox1.Location = new System.Drawing.Point(10, 60);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(216, 344);
this.listBox1.TabIndex = 8;
//
// 账户管理ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "账户管理ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(152, 26);
this.ToolStripMenuItem.Text = "账户管理";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(758, 430);
this.Controls.Add(this.label4);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.label3);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.menuStrip1);
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.MainMenuStrip = this.menuStrip1;
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "服务器端程序";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
this.Load += new System.EventHandler(this.Form1_Load);
this.Shown += new System.EventHandler(this.Form1_Shown);
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel2;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel_version;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
}
}

View File

@@ -0,0 +1,452 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using IndustryEthernet;
using System.Threading;
using CommonLibrary;
using BasicFramework;
//============================================================================
// 模版日期 2017-02-21
// 创建人 胡少林
// 版权所有 胡少林
// 授权说明 模版仅授权个人使用如需商用请联系hsl200909@163.com洽谈
// 说明 JSON组件引用自james newton-king遵循MIT授权协议
//============================================================================
//============================================================================
//
// 注意:本代码的相关操作未作密码验证,如有需要,请自行完成
// 示例具体示例参照Form1_FormClosing(object sender, FormClosingEventArgs e)方法
//
//============================================================================
//============================================================================
//
// 本项目模版不包含 软件自动更新.exe
// 如需支持自动升级 请联系hsl200909@163.com获取
// 软件自动更新.exe 将绑定IP和端口后授权销售30元人民币一组永久使用
//
//============================================================================
namespace
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
#region +
/// <summary>
/// 指示窗口是否处于显示中
/// </summary>
private bool IsWindowShow { get; set; } = false;
/// <summary>
/// 指示系统是否启动
/// </summary>
private bool IsSystemStart { get; set; } = false;
private void Form1_Load(object sender, EventArgs e)
{
//保存路径初始化
UserServer.ServerSettings.FileSavePath = Application.StartupPath + @"\settings.txt";
//加载参数
UserServer.ServerSettings.LoadByFile();
toolStripStatusLabel_version.Text = UserServer.ServerSettings.SystemVersion.ToString();
//加载账户信息
UserServer.ServerAccounts.FileSavePath= Application.StartupPath + @"\accounts.txt";
UserServer.ServerAccounts.LoadByFile();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
//密码验证的示例,此处关闭窗口验证
BasicFramework.FormPasswordCheck fpc = new BasicFramework.FormPasswordCheck("123456");
if (fpc.ShowDialog() == DialogResult.OK)
{
IsWindowShow = false;
Thread.Sleep(20);
}
else
{
//取消关闭
e.Cancel = true;
}
//紧急数据的保存已经放置到dispose方法中即时发生BUG或直接关机也能存储数据
}
private void Form1_Shown(object sender, EventArgs e)
{
IsWindowShow = true;
MaintenanceInitialization();
Refresh();
ToolStripMenuItem.PerformClick();
}
#endregion
#region
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!IsSystemStart)
{
Net_Simplify_Server_Initialization();
Net_Socket_Server_Initialization();
Net_SoftUpdate_Server_Initialization();
Net_File_Update_Initialization();
ToolStripMenuItem.Text = "已启动";
ToolStripMenuItem.BackColor = Color.LimeGreen;
IsSystemStart = true;
}
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
BasicFramework.FormVersionControl fvc = new BasicFramework.FormVersionControl(UserServer.ServerSettings);
fvc.ShowDialog();
fvc.Dispose();
toolStripStatusLabel_version.Text = UserServer.ServerSettings.SystemVersion.ToString();
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
BasicFramework.FormMaintenance fm = new BasicFramework.FormMaintenance(UserServer.ServerSettings);
fm.ShowDialog();
fm.Dispose();
MaintenanceInitialization();
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
//将消息群发给所有的客户端,并使用消息弹窗的方式显示
FormInputAndAction fiaa = new FormInputAndAction(m =>{
net_socket_server.SendAllClients(CommonHeadCode.MultiNetHeadCode. + m); return true;});
fiaa.ShowDialog();
fiaa.Dispose();
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
//关闭信号发送至所有在线客户端
net_socket_server.SendAllClients(CommonHeadCode.MultiNetHeadCode.);
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
BasicFramework.FormAbout fm = new BasicFramework.FormAbout(
"您的软件名称",
UserServer.ServerSettings.SystemVersion,
2017,
"某某某");
fm.ShowDialog();
fm.Dispose();
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
//该部分比较复杂,需要对委托,匿名委托概念比较清晰
FormAccountManage fam = new FormAccountManage(() => UserServer.ServerAccounts.GetAllAccountsJson(),
m => { UserServer.ServerAccounts.LoadAllAccountsJson(m); return true; });
fam.ShowDialog();
fam.Dispose();
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
BasicFramework.FormAboutVersion fav = new BasicFramework.FormAboutVersion(UserServer.ServerSettings.SystemVersion);
fav.ShowDialog();
fav.Dispose();
}
private void MaintenanceInitialization()
{
//维护状态变更
if (UserServer.ServerSettings.Can_Account_Login)
{
label3.Text = "可登录";
label3.BackColor = Color.LimeGreen;
}
else
{
label3.Text = "维护中";
label3.BackColor = Color.Tomato;
}
}
#endregion
#region
/// <summary>
/// 支持软件自动更新的后台服务引擎
/// </summary>
private Net_SoftUpdate_Server net_soft_update_Server = new Net_SoftUpdate_Server();
private void Net_SoftUpdate_Server_Initialization()
{
try
{
net_soft_update_Server.log_record.log_save_path = Application.StartupPath + @"\update_log.txt";
//在服务器的这个路径下放置客户端运行的所有文件不要包含settings文件不要从此处运行
//只放置exe和dll组件必须放置软件自动更新.exe
net_soft_update_Server.FileUpdatePath = @"C:\ClientFiles";
//根据指定端口启动服务,需要自己指定,本处为示例
net_soft_update_Server.AutoUpdateEngineStart(CommonLibrary.CommonLibrary.Port_Update_Net);
}
catch (Exception ex)
{
BasicFramework.SoftBasic.ShowExceptionMessage(ex);
}
}
#endregion
#region
/// <summary>
/// 用于局域网异地更新服务器的客户端程序的引擎,仅限客户端
/// </summary>
private Net_File_Server net_file_update = new Net_File_Server();
/// <summary>
/// 软件异地更新的初始化,如不需要可以不启动,该功能需要稳定性测试
/// </summary>
private void Net_File_Update_Initialization()
{
try
{
net_file_update.FilesPath = @"C:\ClientFiles";//服务器客户端需要更新的路径,与上述一致
net_file_update.log_record.log_save_path = Application.StartupPath + @"\update_file_log.txt";
//需要指定启动端口,本次为示例
net_file_update.Server_Start(CommonLibrary.CommonLibrary.Port_Update_Remote);
}
catch (Exception ex)
{
BasicFramework.SoftBasic.ShowExceptionMessage(ex);
}
}
#endregion
#region
/// <summary>
/// 用户同步数据传送的引擎
/// </summary>
private Net_Simplify_Server net_simplify_server = new Net_Simplify_Server();
/// <summary>
/// 同步传送数据的初始化
/// </summary>
private void Net_Simplify_Server_Initialization()
{
try
{
net_simplify_server.log_record.log_save_path = Application.StartupPath + @"\simplify_log.txt";
net_simplify_server.ReceiveStringEvent += Net_simplify_server_ReceiveStringEvent;
net_simplify_server.ReceivedBytesEvent += Net_simplify_server_ReceivedBytesEvent;
//应该指定特殊的端口,此处为示例
net_simplify_server.Server_Start(CommonLibrary.CommonLibrary.Port_Second_Net);
}
catch (Exception ex)
{
BasicFramework.SoftBasic.ShowExceptionMessage(ex);
}
}
/// <summary>
/// 接收来自客户端的字节数据
/// </summary>
/// <param name="object1">客户端的地址</param>
/// <param name="object2">字节数据,根据实际情况选择是否使用</param>
private void Net_simplify_server_ReceivedBytesEvent(HuStateOne object1, byte[] object2)
{
net_simplify_server.SendMessage(object1, object2);
}
/// <summary>
/// 接收到来自客户端的数据,此处需要放置维护验证,更新验证等等操作
/// </summary>
/// <param name="object1">客户端的地址</param>
/// <param name="object2">消息数据,应该使用指令头+数据组成</param>
private void Net_simplify_server_ReceiveStringEvent(HuStateOne object1, string object2)
{
//如果此处充斥大量if语句影响观感则考虑进行指令头分类操作
//必须返回结果调用SendMessage(object1,[实际数据]);
string head_code = object2.Substring(0, 4);
if (head_code == CommonHeadCode.SimplifyHeadCode.)
{
net_simplify_server.SendMessage(object1, UserServer.ServerSettings.Can_Account_Login ? "1" : "0" +
UserServer.ServerSettings.Account_Forbidden_Reason);
}
else if (head_code == CommonHeadCode.SimplifyHeadCode.)
{
net_simplify_server.SendMessage(object1, UserServer.ServerSettings.SystemVersion.ToString());
}
else if (head_code == CommonHeadCode.SimplifyHeadCode.)
{
Newtonsoft.Json.Linq.JObject json = new Newtonsoft.Json.Linq.JObject();
json.Add(nameof(UserServer.ServerSettings.Announcement), new Newtonsoft.Json.Linq.JValue(UserServer.ServerSettings.Announcement));
net_simplify_server.SendMessage(object1, json.ToString());
}
else if (head_code == CommonHeadCode.SimplifyHeadCode.)
{
//此处使用的是组件自带的验证的方式如果使用SQL数据库另行验证
Newtonsoft.Json.Linq.JObject json = Newtonsoft.Json.Linq.JObject.Parse(object2.Substring(4));
//提取账户,密码
string name = SoftBasic.GetValueFromJsonObject(json, UserAccount.UserNameText, "");
string password= SoftBasic.GetValueFromJsonObject(json, UserAccount.PasswordText, "");
net_simplify_server.SendMessage(object1, UserServer.ServerAccounts.CheckAccountJson(
name, password, ((System.Net.IPEndPoint)(object1._WorkSocket.RemoteEndPoint)).Address.ToString()));
}
else if (head_code == CommonHeadCode.SimplifyHeadCode.)
{
UserServer.ServerSettings.Announcement = object2.Substring(4);
//通知所有客户端更新公告
net_socket_server.SendAllClients(object2);
net_simplify_server.SendMessage(object1, "成功");
}
else if (head_code == CommonHeadCode.SimplifyHeadCode.)
{
//返回服务器的账户信息
net_simplify_server.SendMessage(object1, UserServer.ServerAccounts.GetAllAccountsJson());
}
else if (head_code == CommonHeadCode.SimplifyHeadCode.)
{
//更新服务器的账户信息
UserServer.ServerAccounts.LoadAllAccountsJson(object2.Substring(4));
net_simplify_server.SendMessage(object1, "成功");
}
else if (head_code == CommonHeadCode.SimplifyHeadCode.)
{
//更新服务器的账户密码
//此处使用的是组件自带的验证的方式如果使用SQL数据库另行验证
Newtonsoft.Json.Linq.JObject json = Newtonsoft.Json.Linq.JObject.Parse(object2.Substring(4));
//提取账户,密码
string name = SoftBasic.GetValueFromJsonObject(json, UserAccount.UserNameText, "");
string password = SoftBasic.GetValueFromJsonObject(json, UserAccount.PasswordText, "");
UserServer.ServerAccounts.UpdatePassword(name, password);
net_simplify_server.SendMessage(object1, "成功");
}
else if(head_code== CommonHeadCode.SimplifyHeadCode.)
{
net_simplify_server.SendMessage(object1, net_socket_server.LogReacord.GetLogText());
}
else if (head_code == CommonHeadCode.SimplifyHeadCode.)
{
net_socket_server.LogReacord.ClearLogText();
net_simplify_server.SendMessage(object1, "成功");
}
else if (head_code == CommonHeadCode.SimplifyHeadCode.)
{
net_simplify_server.SendMessage(object1, net_simplify_server.log_record.GetLogText());
}
else if (head_code == CommonHeadCode.SimplifyHeadCode.)
{
net_simplify_server.log_record.ClearLogText();
net_simplify_server.SendMessage(object1, "成功");
}
else if (head_code == CommonHeadCode.SimplifyHeadCode.)
{
net_simplify_server.SendMessage(object1, net_soft_update_Server.log_record.GetLogText());
}
else if (head_code == CommonHeadCode.SimplifyHeadCode.)
{
net_soft_update_Server.log_record.ClearLogText();
net_simplify_server.SendMessage(object1, "成功");
}
else
{
net_simplify_server.SendMessage(object1, object2);
}
}
#endregion
#region
//异步客户端管理引擎
private Net_Socket_Server net_socket_server = new Net_Socket_Server();
/// <summary>
/// 异步传送数据的初始化
/// </summary>
private void Net_Socket_Server_Initialization()
{
try
{
net_socket_server.LogReacord.log_save_path = Application.StartupPath + @"\net_log.txt";
net_socket_server.IsSaveLogClientLineChange = true;
net_socket_server.ClientOnline += Net_socket_server_ClientOnline;
net_socket_server.ClientOffline += Net_socket_server_ClientOffline;
net_socket_server.MessageAlerts += Net_socket_server_MessageAlerts;
net_socket_server.AcceptByte += Net_socket_server_AcceptByte;
net_socket_server.AcceptString += Net_socket_server_AcceptString;
//测试端口,应根据实际使用时指定
net_socket_server.SocketStart(CommonLibrary.CommonLibrary.Port_Main_Net);
}
catch (Exception ex)
{
BasicFramework.SoftBasic.ShowExceptionMessage(ex);
}
}
private void Net_socket_server_AcceptString(HuTcpState object1, string object2)
{
//如果此处充斥大量if语句影响观感则考虑进行指令头分类操作客户端异步发送的字符串都会到此处处理
string head_code = object2.Substring(0, 4);
}
private void Net_socket_server_AcceptByte(HuTcpState object1, byte[] object2)
{
//如果此处充斥大量if语句影响观感则考虑进行指令头分类操作客户端异步发送的字节数组都会到此处处理
}
private void Net_socket_server_MessageAlerts(string object1)
{
//同上的方法,此处处理数据时处于后台线程
if (IsWindowShow && IsHandleCreated)
{
BeginInvoke(new Action(() =>
{
textBox1.AppendText(object1 + Environment.NewLine);
}));
}
}
private void Net_socket_server_ClientOffline(HuTcpState object1, string object2)
{
Net_socket_clients_change(DateTime.Now.ToString("MM-dd HH:mm:ss ") + object1._IpEnd_Point.Address.ToString() + "" +
object1._Login_Alias + " " + object2);
}
private void Net_socket_server_ClientOnline(HuTcpState object1)
{
Net_socket_clients_change(DateTime.Now.ToString("MM-dd HH:mm:ss ") + object1._IpEnd_Point.Address.ToString() + "" +
object1._Login_Alias + " 上线");
}
private void Net_socket_clients_change(string str)
{
if (IsWindowShow && IsHandleCreated)
{
BeginInvoke(new Action(() =>
{
textBox1.AppendText(str + Environment.NewLine);
listBox1.DataSource = net_socket_server.AllClients.Split('#');
label4.Text = net_socket_server.ClientCount.ToString();
//此处决定要不要将在线客户端的数据发送所有客户端
net_socket_server.SendAllClients(CommonHeadCode.MultiNetHeadCode.线 + net_socket_server.AllClients);
}));
}
}
#endregion
}
}

View File

@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>138, 17</value>
</metadata>
</root>

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Process process = Process.GetCurrentProcess();
//遍历应用程序的同名进程组
foreach (Process p in Process.GetProcessesByName(process.ProcessName))
{
//不是同一进程则关闭刚刚创建的进程
if (p.Id != process.Id)
{
//此处显示原先的窗口需要一定的时间,不然无法显示
ShowWindowAsync(p.MainWindowHandle, 9);
SetForegroundWindow(p.MainWindowHandle);
System.Threading.Thread.Sleep(10);
Application.Exit();//关闭当前的应用程序
return;
}
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
[DllImport("User32.dll")]
private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
[DllImport("User32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("软件系统服务端模版")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("软件系统服务端模版")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//将 ComVisible 设置为 false 将使此程序集中的类型
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("2afb749c-a6ce-4b2a-b02d-4fc7bb8ada30")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 4.0.30319.42000
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace .Properties
{
/// <summary>
/// 强类型资源类,用于查找本地化字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// 返回此类使用的缓存 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("软件系统服务端模版.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 覆盖当前线程的 CurrentUICulture 属性
/// 使用此强类型的资源类的资源查找。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace .Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BasicFramework;
//=========================================================================================
//
// 模版说明使用BasicFramework框架和网络框架实现了服务器模版包含了基础的创建操作
//
//=========================================================================================
namespace
{
/// <summary>
/// 服务器类,存储系统运行的静态参数
/// </summary>
public class UserServer
{
/// <summary>
/// 版本号,公告,是否允许登录,不能登录存储
/// </summary>
public static ServerSettings ServerSettings { get; set; } = new ServerSettings();
/// <summary>
/// 所有账户信息的存储对象具体的账户类可以根据UserAccount进行扩充
/// </summary>
public static ServerAccounts<UserAccount> ServerAccounts { get; set; } = new ServerAccounts<UserAccount>(
new List<UserAccount>() {
//示例:新增一个默认的超级管理员
new UserAccount()
{
UserName="admin",
Password="123456",
Factory="总公司",
RegisterTime=DateTime.Now,
LastLoginTime=DateTime.Now,
LoginEnable=true,
Grade=AccountGrade.SuperAdministrator,
ForbidMessage="该帐号已被停用",
LoginFrequency=0,
LastLoginIpAddress="",
}
});
}
/// <summary>
/// 一个扩展的用户账户示例,代替服务器和客户端的账户类即可
/// </summary>
public class UserAccountEx : UserAccount
{
/// <summary>
/// 示例,扩展一个手机号的属性
/// </summary>
public string Phone { get; set; } = "";
public override void DeepCopy<T>(T account)
{
base.DeepCopy<T>(account);
UserAccountEx accountex = account as UserAccountEx;
if (accountex != null)
{
//所有新增的属性在此进行复制
accountex.Phone = Phone;
}
}
}
}

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net35" />
</packages>

View File

@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{2AFB749C-A6CE-4B2A-B02D-4FC7BB8ADA30}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>软件系统服务端模版</RootNamespace>
<AssemblyName>软件系统服务端模版</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="BasicFramework, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Public\BasicFramework.dll</HintPath>
</Reference>
<Reference Include="CommonLibrary">
<HintPath>..\CommonLibrary\bin\Debug\CommonLibrary.dll</HintPath>
</Reference>
<Reference Include="IndustryEthernet, Version=3.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Public\IndustryEthernet.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net35\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UserServer.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</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>