Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
Ftt_Common
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Ftt_Common
Commits
7ed9a8f5
Commit
7ed9a8f5
authored
Nov 30, 2021
by
罗显健
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加:批量并行任务模拟 wMuiltTaskSimulate
parent
96ed1fb0
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
450 additions
and
4 deletions
+450
-4
Tools.csproj
Tools/Tools.csproj
+9
-0
wMuiltTaskSimulate.Designer.cs
Tools/UI/wMuiltTaskSimulate.Designer.cs
+186
-0
wMuiltTaskSimulate.cs
Tools/UI/wMuiltTaskSimulate.cs
+129
-0
wMuiltTaskSimulate.resx
Tools/UI/wMuiltTaskSimulate.resx
+120
-0
wExtend.cs
Tools/wExtend.cs
+6
-4
No files found.
Tools/Tools.csproj
View file @
7ed9a8f5
...
...
@@ -282,6 +282,12 @@
<Compile
Include=
"UI\wMonitorVisit.Designer.cs"
>
<DependentUpon>
wMonitorVisit.cs
</DependentUpon>
</Compile>
<Compile
Include=
"UI\wMuiltTaskSimulate.cs"
>
<SubType>
Form
</SubType>
</Compile>
<Compile
Include=
"UI\wMuiltTaskSimulate.Designer.cs"
>
<DependentUpon>
wMuiltTaskSimulate.cs
</DependentUpon>
</Compile>
<Compile
Include=
"UI\wSysModule.cs"
>
<SubType>
Form
</SubType>
</Compile>
...
...
@@ -422,6 +428,9 @@
<EmbeddedResource
Include=
"UI\wMonitorVisit.resx"
>
<DependentUpon>
wMonitorVisit.cs
</DependentUpon>
</EmbeddedResource>
<EmbeddedResource
Include=
"UI\wMuiltTaskSimulate.resx"
>
<DependentUpon>
wMuiltTaskSimulate.cs
</DependentUpon>
</EmbeddedResource>
<EmbeddedResource
Include=
"UI\wSysModule.resx"
>
<DependentUpon>
wSysModule.cs
</DependentUpon>
</EmbeddedResource>
...
...
Tools/UI/wMuiltTaskSimulate.Designer.cs
0 → 100644
View file @
7ed9a8f5
namespace
Tools.UI
{
partial
class
wMuiltTaskSimulate
{
/// <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
.
btnStart
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
lblTimes
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
txtTimes
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
txtWorks
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
lblWorks
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
groupBox1
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
txtMethod
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
label3
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
txtClass
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
label2
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
txtAssembly
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
label1
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
groupBox1
.
SuspendLayout
();
this
.
SuspendLayout
();
//
// btnStart
//
this
.
btnStart
.
Location
=
new
System
.
Drawing
.
Point
(
458
,
27
);
this
.
btnStart
.
Name
=
"btnStart"
;
this
.
btnStart
.
Size
=
new
System
.
Drawing
.
Size
(
75
,
23
);
this
.
btnStart
.
TabIndex
=
0
;
this
.
btnStart
.
Text
=
"运行"
;
this
.
btnStart
.
UseVisualStyleBackColor
=
true
;
this
.
btnStart
.
Click
+=
new
System
.
EventHandler
(
this
.
btnStart_Click
);
//
// lblTimes
//
this
.
lblTimes
.
AutoSize
=
true
;
this
.
lblTimes
.
Location
=
new
System
.
Drawing
.
Point
(
43
,
29
);
this
.
lblTimes
.
Name
=
"lblTimes"
;
this
.
lblTimes
.
Size
=
new
System
.
Drawing
.
Size
(
77
,
12
);
this
.
lblTimes
.
TabIndex
=
1
;
this
.
lblTimes
.
Text
=
"执行总次数:"
;
//
// txtTimes
//
this
.
txtTimes
.
Location
=
new
System
.
Drawing
.
Point
(
122
,
26
);
this
.
txtTimes
.
Name
=
"txtTimes"
;
this
.
txtTimes
.
Size
=
new
System
.
Drawing
.
Size
(
100
,
21
);
this
.
txtTimes
.
TabIndex
=
2
;
//
// txtWorks
//
this
.
txtWorks
.
Location
=
new
System
.
Drawing
.
Point
(
316
,
26
);
this
.
txtWorks
.
Name
=
"txtWorks"
;
this
.
txtWorks
.
Size
=
new
System
.
Drawing
.
Size
(
100
,
21
);
this
.
txtWorks
.
TabIndex
=
4
;
//
// lblWorks
//
this
.
lblWorks
.
AutoSize
=
true
;
this
.
lblWorks
.
Location
=
new
System
.
Drawing
.
Point
(
237
,
29
);
this
.
lblWorks
.
Name
=
"lblWorks"
;
this
.
lblWorks
.
Size
=
new
System
.
Drawing
.
Size
(
77
,
12
);
this
.
lblWorks
.
TabIndex
=
3
;
this
.
lblWorks
.
Text
=
"最大并行数:"
;
//
// groupBox1
//
this
.
groupBox1
.
Controls
.
Add
(
this
.
txtMethod
);
this
.
groupBox1
.
Controls
.
Add
(
this
.
label3
);
this
.
groupBox1
.
Controls
.
Add
(
this
.
txtClass
);
this
.
groupBox1
.
Controls
.
Add
(
this
.
label2
);
this
.
groupBox1
.
Controls
.
Add
(
this
.
txtAssembly
);
this
.
groupBox1
.
Controls
.
Add
(
this
.
label1
);
this
.
groupBox1
.
Location
=
new
System
.
Drawing
.
Point
(
45
,
65
);
this
.
groupBox1
.
Name
=
"groupBox1"
;
this
.
groupBox1
.
Size
=
new
System
.
Drawing
.
Size
(
497
,
136
);
this
.
groupBox1
.
TabIndex
=
5
;
this
.
groupBox1
.
TabStop
=
false
;
this
.
groupBox1
.
Text
=
"任务信息"
;
//
// txtMethod
//
this
.
txtMethod
.
Location
=
new
System
.
Drawing
.
Point
(
77
,
94
);
this
.
txtMethod
.
Name
=
"txtMethod"
;
this
.
txtMethod
.
Size
=
new
System
.
Drawing
.
Size
(
390
,
21
);
this
.
txtMethod
.
TabIndex
=
8
;
//
// label3
//
this
.
label3
.
AutoSize
=
true
;
this
.
label3
.
Location
=
new
System
.
Drawing
.
Point
(
13
,
97
);
this
.
label3
.
Name
=
"label3"
;
this
.
label3
.
Size
=
new
System
.
Drawing
.
Size
(
65
,
12
);
this
.
label3
.
TabIndex
=
7
;
this
.
label3
.
Text
=
"调用方法:"
;
//
// txtClass
//
this
.
txtClass
.
Location
=
new
System
.
Drawing
.
Point
(
77
,
58
);
this
.
txtClass
.
Name
=
"txtClass"
;
this
.
txtClass
.
Size
=
new
System
.
Drawing
.
Size
(
390
,
21
);
this
.
txtClass
.
TabIndex
=
6
;
//
// label2
//
this
.
label2
.
AutoSize
=
true
;
this
.
label2
.
Location
=
new
System
.
Drawing
.
Point
(
13
,
61
);
this
.
label2
.
Name
=
"label2"
;
this
.
label2
.
Size
=
new
System
.
Drawing
.
Size
(
53
,
12
);
this
.
label2
.
TabIndex
=
5
;
this
.
label2
.
Text
=
"业务类:"
;
//
// txtAssembly
//
this
.
txtAssembly
.
Location
=
new
System
.
Drawing
.
Point
(
77
,
20
);
this
.
txtAssembly
.
Name
=
"txtAssembly"
;
this
.
txtAssembly
.
Size
=
new
System
.
Drawing
.
Size
(
390
,
21
);
this
.
txtAssembly
.
TabIndex
=
4
;
//
// label1
//
this
.
label1
.
AutoSize
=
true
;
this
.
label1
.
Location
=
new
System
.
Drawing
.
Point
(
13
,
23
);
this
.
label1
.
Name
=
"label1"
;
this
.
label1
.
Size
=
new
System
.
Drawing
.
Size
(
53
,
12
);
this
.
label1
.
TabIndex
=
3
;
this
.
label1
.
Text
=
"程序集:"
;
//
// wMuiltTaskSimulate
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
6F
,
12F
);
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
591
,
222
);
this
.
Controls
.
Add
(
this
.
groupBox1
);
this
.
Controls
.
Add
(
this
.
txtWorks
);
this
.
Controls
.
Add
(
this
.
lblWorks
);
this
.
Controls
.
Add
(
this
.
btnStart
);
this
.
Controls
.
Add
(
this
.
txtTimes
);
this
.
Controls
.
Add
(
this
.
lblTimes
);
this
.
Name
=
"wMuiltTaskSimulate"
;
this
.
Text
=
"wMuiltTaskSimulate"
;
this
.
groupBox1
.
ResumeLayout
(
false
);
this
.
groupBox1
.
PerformLayout
();
this
.
ResumeLayout
(
false
);
this
.
PerformLayout
();
}
#
endregion
private
System
.
Windows
.
Forms
.
Button
btnStart
;
private
System
.
Windows
.
Forms
.
Label
lblTimes
;
private
System
.
Windows
.
Forms
.
TextBox
txtTimes
;
private
System
.
Windows
.
Forms
.
TextBox
txtWorks
;
private
System
.
Windows
.
Forms
.
Label
lblWorks
;
private
System
.
Windows
.
Forms
.
GroupBox
groupBox1
;
private
System
.
Windows
.
Forms
.
TextBox
txtMethod
;
private
System
.
Windows
.
Forms
.
Label
label3
;
private
System
.
Windows
.
Forms
.
TextBox
txtClass
;
private
System
.
Windows
.
Forms
.
Label
label2
;
private
System
.
Windows
.
Forms
.
TextBox
txtAssembly
;
private
System
.
Windows
.
Forms
.
Label
label1
;
}
}
\ No newline at end of file
Tools/UI/wMuiltTaskSimulate.cs
0 → 100644
View file @
7ed9a8f5
using
System
;
using
System.IO
;
using
System.Reflection
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
using
Tools.MyCommon
;
namespace
Tools.UI
{
/// <summary>
/// 批量任务模拟
/// </summary>
public
partial
class
wMuiltTaskSimulate
:
wBasic
{
static
wMuiltTaskSimulate
wInstance
;
public
wMuiltTaskSimulate
()
{
InitializeComponent
();
wInstance
=
this
;
// 以下测试项. 更改本解决方案下 test 项目属性中的“输出类型”为类库,输入并拷贝相关dll到本程序启动目录。
txtAssembly
.
Text
=
"test.dll"
;
txtClass
.
Text
=
"test.Cases.DboPerformanceTest"
;
txtMethod
.
Text
=
"RunDapper"
;
// RunFluentData,RunSqlHelper
txtTimes
.
Text
=
"1"
;
txtWorks
.
Text
=
"5"
;
}
int
totalTimes
=
0
,
maxWorks
=
0
;
private
void
Run
(
Action
callBack
)
{
int
finishCount
=
0
;
Task
.
Run
(()
=>
{
Parallel
.
For
(
0
,
totalTimes
,
new
ParallelOptions
{
MaxDegreeOfParallelism
=
maxWorks
},
i
=>
{
try
{
ShowMsg
(
$"准备执行第
{
i
}
任务"
);
Execute
(
txtAssembly
.
Text
,
txtClass
.
Text
,
txtMethod
.
Text
);
ShowMsg
(
$"第
{
i
}
任务执行完成!"
);
}
catch
(
Exception
ex
)
{
ShowMsg
(
ex
.
Message
);
}
finally
{
Interlocked
.
Increment
(
ref
finishCount
);
if
(
finishCount
>=
totalTimes
)
MyUtils
.
Utils
.
AsyncUI
(
wInstance
,
()
=>
callBack
());
}
});
});
}
private
void
btnStart_Click
(
object
sender
,
EventArgs
e
)
{
if
(!
CheckData
())
return
;
btnStart
.
Enabled
=
false
;
Run
(()
=>
btnStart
.
Enabled
=
true
);
}
private
bool
CheckData
()
{
if
(!
int
.
TryParse
(
txtTimes
.
Text
,
out
totalTimes
)
||
totalTimes
<
0
)
{
MessageBox
.
Show
(
"[执行总次数]无效,请重新输入!"
);
txtTimes
.
Focus
();
return
false
;
}
if
(!
int
.
TryParse
(
txtWorks
.
Text
,
out
maxWorks
)
||
maxWorks
<
0
)
{
MessageBox
.
Show
(
"[执行总次数]无效,请重新输入!"
);
txtTimes
.
Focus
();
return
false
;
}
return
true
;
}
/// <summary>
/// 执行计划任务。
/// </summary>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public
void
Execute
(
string
dllName
,
string
className
,
string
methodName
)
{
var
assembly
=
Path
.
Combine
(
AppDomain
.
CurrentDomain
.
BaseDirectory
,
dllName
);
if
(!
File
.
Exists
(
assembly
))
throw
new
Exception
(
$"程序集[
{
dllName
}
]不存在"
);
var
type
=
Assembly
.
LoadFrom
(
assembly
).
GetType
(
className
);
var
method
=
type
.
GetMethod
(
"RunDapper"
);
var
objInstance
=
Activator
.
CreateInstance
(
type
);
ShowMsg
(
$"任务执行、当前线程:
{
Thread
.
CurrentThread
.
ManagedThreadId
}
"
);
method
.
Invoke
(
objInstance
,
null
);
}
private
void
ShowMsg
(
string
content
)
{
Console
.
WriteLine
(
content
);
}
}
}
Tools/UI/wMuiltTaskSimulate.resx
0 → 100644
View file @
7ed9a8f5
<?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=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>
\ No newline at end of file
Tools/wExtend.cs
View file @
7ed9a8f5
...
...
@@ -60,6 +60,7 @@ namespace Tools
this
.
CreateModule
(
Tools_dev
,
typeof
(
UI
.
wModuleManager
),
"模块管理"
,
"tr:系统模块管理工具(支持生成SQL)"
),
this
.
CreateModule
(
Tools_dev
,
typeof
(
UI
.
wDbAnlysis
),
"SQL效率分析"
,
"tr:用于分析SQL查询效率(执行计划和IO计数)"
),
this
.
CreateModule
(
Tools_dev
,
typeof
(
UI
.
wSysChecker
),
"检查配置工具"
,
"tr:系统通用检查配置服务(通过存储过程检查)"
),
this
.
CreateModule
(
Tools_dev
,
typeof
(
UI
.
wMuiltTaskSimulate
),
"批量并行任务模拟"
,
"tr:多线程并行运行指定测试项目,用来做压力性能测试等。。。"
),
//-------------------------------
this
.
CreateModule
(
Tools_human
,
typeof
(
UI
.
wUser
),
"员工管理"
,
"tr:员工状态及头像管理"
),
this
.
CreateModule
(
Tools_human
,
typeof
(
UI
.
wEvaluationOfEmployee
),
"员工考核"
,
"tr:员工考核的记录工具"
),
...
...
@@ -80,7 +81,8 @@ namespace Tools
/// <returns></returns>
private
ModuleInfo
CreateModule
(
string
group
,
Type
frmType
,
string
text
,
string
tip
=
""
)
{
return
new
ModuleInfo
{
return
new
ModuleInfo
{
ViewFormType
=
frmType
,
GroupName
=
group
,
Text
=
text
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment