auto commit
This commit is contained in:
23
C#.NET/source/YitIdGen.WinFormApp/Program.cs
Normal file
23
C#.NET/source/YitIdGen.WinFormApp/Program.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WInFormApp
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new StartForm());
|
||||
}
|
||||
}
|
||||
}
|
||||
90
C#.NET/source/YitIdGen.WinFormApp/StartForm.Designer.cs
generated
Normal file
90
C#.NET/source/YitIdGen.WinFormApp/StartForm.Designer.cs
generated
Normal file
@@ -0,0 +1,90 @@
|
||||
|
||||
namespace WInFormApp
|
||||
{
|
||||
partial class StartForm
|
||||
{
|
||||
/// <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.btnGen = new System.Windows.Forms.Button();
|
||||
this.txtIdList = new System.Windows.Forms.TextBox();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnGen
|
||||
//
|
||||
this.btnGen.Location = new System.Drawing.Point(12, 385);
|
||||
this.btnGen.Name = "btnGen";
|
||||
this.btnGen.Size = new System.Drawing.Size(170, 64);
|
||||
this.btnGen.TabIndex = 0;
|
||||
this.btnGen.Text = "注册";
|
||||
this.btnGen.UseVisualStyleBackColor = true;
|
||||
this.btnGen.Click += new System.EventHandler(this.btnGen_Click);
|
||||
//
|
||||
// txtIdList
|
||||
//
|
||||
this.txtIdList.Location = new System.Drawing.Point(12, 12);
|
||||
this.txtIdList.Multiline = true;
|
||||
this.txtIdList.Name = "txtIdList";
|
||||
this.txtIdList.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||
this.txtIdList.Size = new System.Drawing.Size(443, 346);
|
||||
this.txtIdList.TabIndex = 1;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(286, 385);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(170, 64);
|
||||
this.button1.TabIndex = 2;
|
||||
this.button1.Text = "注销";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click);
|
||||
//
|
||||
// StartForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(468, 514);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.txtIdList);
|
||||
this.Controls.Add(this.btnGen);
|
||||
this.Name = "StartForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "TestForm";
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button btnGen;
|
||||
private System.Windows.Forms.TextBox txtIdList;
|
||||
private System.Windows.Forms.Button button1;
|
||||
}
|
||||
}
|
||||
|
||||
74
C#.NET/source/YitIdGen.WinFormApp/StartForm.cs
Normal file
74
C#.NET/source/YitIdGen.WinFormApp/StartForm.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WInFormApp
|
||||
{
|
||||
public partial class StartForm : Form
|
||||
{
|
||||
public StartForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
[DllImport("yitidgengo.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern long NextId();
|
||||
|
||||
[DllImport("yitidgengo.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern long NextId2();
|
||||
|
||||
[DllImport("yitidgengo.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern long RegisterWorkerId(string ip, int port, string password, int maxWorkerIdNumber);
|
||||
//public static extern ulong RegisterWorkerId2();
|
||||
|
||||
[DllImport("yitidgengo.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern long UnRegisterWorkerId();
|
||||
|
||||
|
||||
[DllImport("yitidgen.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern void SetWorkerId(uint workerId);
|
||||
|
||||
[DllImport("yitidgen.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int Test();
|
||||
|
||||
[DllImport("yitidgen.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int GetWorkerId(string ip, int port);
|
||||
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void btnGen_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ip = "localhost";
|
||||
|
||||
//txtIdList.Text += RegisterWorkerId(Encoding.UTF8.GetBytes(ip), 6379) + "\r\n";
|
||||
txtIdList.Text += RegisterWorkerId(ip, 6379, "", 4) + "\r\n";
|
||||
//txtIdList.Text += RegisterWorkerId() + "\r\n";
|
||||
|
||||
//txtIdList.Text += Test() + "\r\n";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
txtIdList.Text = ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
UnRegisterWorkerId();
|
||||
// GetWorkerId("localhost", 6379);
|
||||
}
|
||||
}
|
||||
}
|
||||
60
C#.NET/source/YitIdGen.WinFormApp/StartForm.resx
Normal file
60
C#.NET/source/YitIdGen.WinFormApp/StartForm.resx
Normal file
@@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
19
C#.NET/source/YitIdGen.WinFormApp/YitIdGen.WinFormApp.csproj
Normal file
19
C#.NET/source/YitIdGen.WinFormApp/YitIdGen.WinFormApp.csproj
Normal file
@@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net5.0-windows</TargetFramework>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="yitidgen.dll" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="yitidgen.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
BIN
C#.NET/source/YitIdGen.WinFormApp/yitidgen.dll
Normal file
BIN
C#.NET/source/YitIdGen.WinFormApp/yitidgen.dll
Normal file
Binary file not shown.
@@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yitter.IdGenerator", "Yitte
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yitter.IdGenTest", "Yitter.IdGenTest\Yitter.IdGenTest.csproj", "{67426F7D-0A3B-4645-B4D7-5487215D3E2B}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YitIdGen.WinFormApp", "YitIdGen.WinFormApp\YitIdGen.WinFormApp.csproj", "{1035D82E-3F37-4940-AA32-5D1E0E53AFA5}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -21,6 +23,10 @@ Global
|
||||
{67426F7D-0A3B-4645-B4D7-5487215D3E2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{67426F7D-0A3B-4645-B4D7-5487215D3E2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{67426F7D-0A3B-4645-B4D7-5487215D3E2B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1035D82E-3F37-4940-AA32-5D1E0E53AFA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1035D82E-3F37-4940-AA32-5D1E0E53AFA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1035D82E-3F37-4940-AA32-5D1E0E53AFA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1035D82E-3F37-4940-AA32-5D1E0E53AFA5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace Yitter.OrgSystem.TestA
|
||||
public IList<long> idList = new List<long>();
|
||||
private int GenIdCount;
|
||||
private int WorkerId;
|
||||
|
||||
|
||||
public GenTest(IIdGenerator idGen, int genIdCount, int workerId)
|
||||
{
|
||||
|
||||
@@ -55,9 +55,9 @@ namespace Yitter.OrgSystem.TestA
|
||||
|
||||
while (true)
|
||||
{
|
||||
//RunSingle();
|
||||
RunSingle();
|
||||
//CallDll();
|
||||
//Go(options);
|
||||
CallDll();
|
||||
Thread.Sleep(1000); // 每隔1秒执行一次Go
|
||||
}
|
||||
}
|
||||
@@ -65,13 +65,13 @@ namespace Yitter.OrgSystem.TestA
|
||||
//[DllImport("yitidgenc.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
//public static extern long NextId();
|
||||
|
||||
[DllImport("yitidgenc.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
[DllImport("yitidgengo.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern long NextId();
|
||||
|
||||
[DllImport("yitidgenc.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
[DllImport("yitidgen.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern void SetWorkerId(uint workerId);
|
||||
|
||||
[DllImport("yitidgenc.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
[DllImport("yitidgen.dll", CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern int TestId();
|
||||
|
||||
private static void CallDll()
|
||||
|
||||
Reference in New Issue
Block a user