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
d1141d25
Commit
d1141d25
authored
Dec 01, 2021
by
段廷瑞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、自动更新功能优化;增加进度文本功能及异步UI支持
parent
7ed9a8f5
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
428 additions
and
34 deletions
+428
-34
Tools.exe.config
AppHome/Tools.exe.config
+1
-1
links.xml
AppHome/config/links.xml
+6
-0
wProgressText.Designer.cs
Tools/MyCommon/wProgressText.Designer.cs
+63
-0
wProgressText.cs
Tools/MyCommon/wProgressText.cs
+66
-0
wProgressText.resx
Tools/MyCommon/wProgressText.resx
+120
-0
Utils.cs
Tools/MyUtils/Utils.cs
+80
-1
Tools.csproj
Tools/Tools.csproj
+9
-0
wUploadUpdate.Designer.cs
Tools/UI/sys/wUploadUpdate.Designer.cs
+13
-13
wUploadUpdate.cs
Tools/UI/sys/wUploadUpdate.cs
+70
-19
No files found.
AppHome/Tools.exe.config
View file @
d1141d25
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
<
appSettings
>
<
appSettings
>
<
add
key
=
"LoginInfo"
value
=
"wwF/xpBzWek="
/>
<
add
key
=
"LoginInfo"
value
=
"wwF/xpBzWek="
/>
<
add
key
=
"LoginVerify"
value
=
"v86f5Q3Xa7U="
/>
<
add
key
=
"LoginVerify"
value
=
"v86f5Q3Xa7U="
/>
<
add
key
=
"UpdateTime"
value
=
"2021-11-26 1
4:21:49.650
"
/>
<
add
key
=
"UpdateTime"
value
=
"2021-11-26 1
6:12:01.887
"
/>
</
appSettings
>
</
appSettings
>
<
startup
>
<
startup
>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.8"
/>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.8"
/>
...
...
AppHome/config/links.xml
View file @
d1141d25
...
@@ -96,4 +96,10 @@
...
@@ -96,4 +96,10 @@
<UserId>
sa
</UserId>
<UserId>
sa
</UserId>
<Pwd>
a*1
</Pwd>
<Pwd>
a*1
</Pwd>
</links>
</links>
<links>
<Link>
192.168.1.31
</Link>
<DbName>
FTT_PDM
</DbName>
<UserId>
sa
</UserId>
<Pwd>
a*1
</Pwd>
</links>
</DocumentElement>
</DocumentElement>
\ No newline at end of file
Tools/MyCommon/wProgressText.Designer.cs
0 → 100644
View file @
d1141d25
namespace
Tools.MyCommon
{
partial
class
wProgressText
{
/// <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
.
SuspendLayout
();
//
// label1
//
this
.
label1
.
BackColor
=
System
.
Drawing
.
Color
.
LightGreen
;
this
.
label1
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
label1
.
ForeColor
=
System
.
Drawing
.
Color
.
Black
;
this
.
label1
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
label1
.
Name
=
"label1"
;
this
.
label1
.
Size
=
new
System
.
Drawing
.
Size
(
179
,
22
);
this
.
label1
.
TabIndex
=
1
;
this
.
label1
.
Text
=
"label1"
;
this
.
label1
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleCenter
;
//
// wProgressBar
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
6F
,
12F
);
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
BackColor
=
System
.
Drawing
.
SystemColors
.
Window
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
179
,
22
);
this
.
Controls
.
Add
(
this
.
label1
);
this
.
FormBorderStyle
=
System
.
Windows
.
Forms
.
FormBorderStyle
.
None
;
this
.
Name
=
"wProgressBar"
;
this
.
Text
=
"wProgressBar"
;
this
.
ResumeLayout
(
false
);
}
#
endregion
private
System
.
Windows
.
Forms
.
Label
label1
;
}
}
\ No newline at end of file
Tools/MyCommon/wProgressText.cs
0 → 100644
View file @
d1141d25
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Data
;
using
System.Drawing
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
//
using
Tools.MyUtils
;
namespace
Tools.MyCommon
{
public
partial
class
wProgressText
:
wBasic
{
int
_max
=
0
;
public
wProgressText
()
{
InitializeComponent
();
//隐藏窗体边框
this
.
ShowInTaskbar
=
false
;
//不显示在任务栏
this
.
FormBorderStyle
=
FormBorderStyle
.
None
;
this
.
MaximumSize
=
new
Size
(
180
,
22
);
this
.
MinimumSize
=
new
Size
(
180
,
22
);
this
.
FormClosing
+=
WProgressText_FormClosing
;
}
/// <summary>
/// 事件-窗口关闭
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private
void
WProgressText_FormClosing
(
object
sender
,
FormClosingEventArgs
e
)
{
Task
.
Run
(()
=>
Thread
.
Sleep
(
200
)).
Wait
();
//窗口结束时停顿0.2秒
}
/// <summary>
/// 设置进度条最大值
/// </summary>
/// <param name="total"></param>
public
void
SetMaximum
(
int
max
)
{
this
.
AsyncUI
(()
=>
{
this
.
_max
=
max
;
this
.
label1
.
Text
=
$"共
{
max
}
条数据 已处理0条"
;
this
.
Text
=
$"0/
{
max
}
"
;
});
}
/// <summary>
/// 设置进度条当前位置
/// </summary>
/// <param name="pos"></param>
public
void
SetPosition
(
int
pos
)
{
this
.
AsyncUI
(()
=>
{
this
.
label1
.
Text
=
$"共
{
_max
}
条数据 已处理
{
pos
}
条"
;
this
.
Text
=
$"
{
pos
}
/
{
_max
}
"
;
});
}
}
}
Tools/MyCommon/wProgressText.resx
0 → 100644
View file @
d1141d25
<?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/MyUtils/Utils.cs
View file @
d1141d25
using
System
;
using
ICSharpCode.SharpZipLib.Zip
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Configuration
;
using
System.Configuration
;
using
System.Data
;
using
System.Data
;
...
@@ -9,6 +10,7 @@ using System.Security.Cryptography;
...
@@ -9,6 +10,7 @@ using System.Security.Cryptography;
using
System.Text
;
using
System.Text
;
//
//
using
System.Windows.Forms
;
using
System.Windows.Forms
;
using
Tools.MyCommon
;
namespace
Tools.MyUtils
namespace
Tools.MyUtils
{
{
...
@@ -262,6 +264,59 @@ namespace Tools.MyUtils
...
@@ -262,6 +264,59 @@ namespace Tools.MyUtils
#
endregion
#
endregion
#
region
ZIP
压缩
/// <summary>
/// Zip:打包专用压缩方法(进度提示)
/// </summary>
/// <param name="bar">进度提示</param>
/// <param name="zipFileName">压缩文件保存路径</param>
/// <param name="fileNames">待压缩的文件列表</param>
/// <param name="rootPath">待压缩文件的根路径:用于定位压缩相对路径</param>
public
static
void
ZipCompress4Package
(
wProgressText
bar
,
string
zipFileName
,
List
<
string
>
fileNames
,
string
rootPath
)
{
try
{
using
(
ZipOutputStream
zip
=
new
ZipOutputStream
(
File
.
Create
(
zipFileName
)))
{
zip
.
SetLevel
(
9
);
// 压缩级别 0-9
byte
[]
buffer
=
new
byte
[
1024
];
//缓冲区大小
int
iCount
=
0
;
bar
?.
SetMaximum
(
fileNames
.
Count
);
foreach
(
string
path
in
fileNames
)
{
//进度条显示
bar
?.
SetPosition
(++
iCount
);
//EntryName用以指定压缩层级
string
EntryName
=
path
.
Substring
(
$@"
{
rootPath
}
\"
.
Length
);
//这里取根目录的相对路径
//创建新入口
ZipEntry
entry
=
new
ZipEntry
(
EntryName
)
{
DateTime
=
DateTime
.
Now
};
zip
.
PutNextEntry
(
entry
);
//写入源数据
using
(
FileStream
fs
=
File
.
OpenRead
(
path
))
{
int
size
;
while
((
size
=
fs
.
Read
(
buffer
,
0
,
buffer
.
Length
))
>
0
)
{
zip
.
Write
(
buffer
,
0
,
size
);
}
}
}
zip
.
Finish
();
zip
.
Close
();
}
}
catch
(
Exception
ex
)
{
TipException
(
ex
);
}
}
#
endregion
#
region
winform
:提示;帮助窗口;异步
UI
支持
#
region
winform
:提示;帮助窗口;异步
UI
支持
/// <summary>
/// <summary>
...
@@ -541,6 +596,29 @@ namespace Tools.MyUtils
...
@@ -541,6 +596,29 @@ namespace Tools.MyUtils
return
a
<=
high
&&
a
>=
low
;
return
a
<=
high
&&
a
>=
low
;
}
}
#
endregion
#
region
(
扩展
)
控件异步
UI
/// <summary>
/// 异步UI:执行方法
/// </summary>
/// <param name="ctrl"></param>
/// <param name="action"></param>
public
static
void
AsyncUI
(
this
Control
ctrl
,
Action
action
)
{
if
(
ctrl
.
Disposing
||
ctrl
.
IsDisposed
)
return
;
//
if
(
ctrl
.
InvokeRequired
)
{
ctrl
.
Invoke
(
action
);
}
else
{
action
();
}
}
#
endregion
#
endregion
#
region
图片分离
#
region
图片分离
...
@@ -933,6 +1011,7 @@ namespace Tools.MyUtils
...
@@ -933,6 +1011,7 @@ namespace Tools.MyUtils
}
}
#
endregion
#
endregion
}
}
}
}
Tools/Tools.csproj
View file @
d1141d25
...
@@ -106,6 +106,12 @@
...
@@ -106,6 +106,12 @@
<Compile
Include=
"MyCommon\controls\TabControlEx.Designer.cs"
>
<Compile
Include=
"MyCommon\controls\TabControlEx.Designer.cs"
>
<DependentUpon>
TabControlEx.cs
</DependentUpon>
<DependentUpon>
TabControlEx.cs
</DependentUpon>
</Compile>
</Compile>
<Compile
Include=
"MyCommon\wProgressText.cs"
>
<SubType>
Form
</SubType>
</Compile>
<Compile
Include=
"MyCommon\wProgressText.Designer.cs"
>
<DependentUpon>
wProgressText.cs
</DependentUpon>
</Compile>
<Compile
Include=
"MyData\AnlysisHelper.cs"
/>
<Compile
Include=
"MyData\AnlysisHelper.cs"
/>
<Compile
Include=
"MyData\DBHelper.cs"
/>
<Compile
Include=
"MyData\DBHelper.cs"
/>
<Compile
Include=
"MyData\SqlHelper.cs"
/>
<Compile
Include=
"MyData\SqlHelper.cs"
/>
...
@@ -340,6 +346,9 @@
...
@@ -340,6 +346,9 @@
<EmbeddedResource
Include=
"MyCommon\controls\TabControlEx.resx"
>
<EmbeddedResource
Include=
"MyCommon\controls\TabControlEx.resx"
>
<DependentUpon>
TabControlEx.cs
</DependentUpon>
<DependentUpon>
TabControlEx.cs
</DependentUpon>
</EmbeddedResource>
</EmbeddedResource>
<EmbeddedResource
Include=
"MyCommon\wProgressText.resx"
>
<DependentUpon>
wProgressText.cs
</DependentUpon>
</EmbeddedResource>
<EmbeddedResource
Include=
"MyUtils\wDbSetting.resx"
>
<EmbeddedResource
Include=
"MyUtils\wDbSetting.resx"
>
<DependentUpon>
wDbSetting.cs
</DependentUpon>
<DependentUpon>
wDbSetting.cs
</DependentUpon>
</EmbeddedResource>
</EmbeddedResource>
...
...
Tools/UI/sys/wUploadUpdate.Designer.cs
View file @
d1141d25
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
/// </summary>
/// </summary>
private
void
InitializeComponent
()
private
void
InitializeComponent
()
{
{
this
.
btn
Upload
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btn
GenZip
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
label1
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label1
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label2
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label2
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label3
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label3
=
new
System
.
Windows
.
Forms
.
Label
();
...
@@ -43,17 +43,17 @@
...
@@ -43,17 +43,17 @@
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
pictureBox1
)).
BeginInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
pictureBox1
)).
BeginInit
();
this
.
SuspendLayout
();
this
.
SuspendLayout
();
//
//
// btn
Upload
// btn
GenZip
//
//
this
.
btn
Upload
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btn
GenZip
.
FlatStyle
=
System
.
Windows
.
Forms
.
FlatStyle
.
Flat
;
this
.
btn
Upload
.
Location
=
new
System
.
Drawing
.
Point
(
74
,
303
);
this
.
btn
GenZip
.
Location
=
new
System
.
Drawing
.
Point
(
74
,
303
);
this
.
btn
Upload
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
3
,
4
,
3
,
4
);
this
.
btn
GenZip
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
3
,
4
,
3
,
4
);
this
.
btn
Upload
.
Name
=
"btnUpload
"
;
this
.
btn
GenZip
.
Name
=
"btnGenZip
"
;
this
.
btn
Upload
.
Size
=
new
System
.
Drawing
.
Size
(
117
,
33
);
this
.
btn
GenZip
.
Size
=
new
System
.
Drawing
.
Size
(
117
,
33
);
this
.
btn
Upload
.
TabIndex
=
2
;
this
.
btn
GenZip
.
TabIndex
=
2
;
this
.
btn
Upload
.
Text
=
"选择
压缩包"
;
this
.
btn
GenZip
.
Text
=
"生成
压缩包"
;
this
.
btn
Upload
.
UseVisualStyleBackColor
=
true
;
this
.
btn
GenZip
.
UseVisualStyleBackColor
=
true
;
this
.
btn
Upload
.
Click
+=
new
System
.
EventHandler
(
this
.
btnUpload
_Click
);
this
.
btn
GenZip
.
Click
+=
new
System
.
EventHandler
(
this
.
btnGenZip
_Click
);
//
//
// label1
// label1
//
//
...
@@ -181,7 +181,7 @@
...
@@ -181,7 +181,7 @@
this
.
Controls
.
Add
(
this
.
label3
);
this
.
Controls
.
Add
(
this
.
label3
);
this
.
Controls
.
Add
(
this
.
label2
);
this
.
Controls
.
Add
(
this
.
label2
);
this
.
Controls
.
Add
(
this
.
label1
);
this
.
Controls
.
Add
(
this
.
label1
);
this
.
Controls
.
Add
(
this
.
btn
Upload
);
this
.
Controls
.
Add
(
this
.
btn
GenZip
);
this
.
Controls
.
Add
(
this
.
pictureBox1
);
this
.
Controls
.
Add
(
this
.
pictureBox1
);
this
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
FormBorderStyle
=
System
.
Windows
.
Forms
.
FormBorderStyle
.
FixedToolWindow
;
this
.
FormBorderStyle
=
System
.
Windows
.
Forms
.
FormBorderStyle
.
FixedToolWindow
;
...
@@ -198,7 +198,7 @@
...
@@ -198,7 +198,7 @@
#
endregion
#
endregion
private
System
.
Windows
.
Forms
.
PictureBox
pictureBox1
;
private
System
.
Windows
.
Forms
.
PictureBox
pictureBox1
;
private
System
.
Windows
.
Forms
.
Button
btn
Upload
;
private
System
.
Windows
.
Forms
.
Button
btn
GenZip
;
private
System
.
Windows
.
Forms
.
Label
label1
;
private
System
.
Windows
.
Forms
.
Label
label1
;
private
System
.
Windows
.
Forms
.
Label
label2
;
private
System
.
Windows
.
Forms
.
Label
label2
;
private
System
.
Windows
.
Forms
.
Label
label3
;
private
System
.
Windows
.
Forms
.
Label
label3
;
...
...
Tools/UI/sys/wUploadUpdate.cs
View file @
d1141d25
...
@@ -17,10 +17,36 @@ namespace Tools.UI.sys
...
@@ -17,10 +17,36 @@ namespace Tools.UI.sys
{
{
public
partial
class
wUploadUpdate
:
wEditBasic
public
partial
class
wUploadUpdate
:
wEditBasic
{
{
/// <summary>
/// 进度文本提示
/// </summary>
wProgressText
_bar
=
null
;
/// <summary>
/// 生成的压缩文件列表
/// </summary>
List
<
string
>
GenZipFileList
=
new
List
<
string
>();
/// <summary>
/// 构造函数
/// </summary>
public
wUploadUpdate
()
public
wUploadUpdate
()
{
{
InitializeComponent
();
InitializeComponent
();
}
}
/// <summary>
/// 析构函数
/// </summary>
~
wUploadUpdate
()
{
//删除所有的压缩包
this
.
GenZipFileList
.
ForEach
(
file
=>
{
if
(
File
.
Exists
(
file
))
{
File
.
Delete
(
file
);
}
});
}
private
void
wUploadUpdate_Load
(
object
sender
,
EventArgs
e
)
private
void
wUploadUpdate_Load
(
object
sender
,
EventArgs
e
)
{
{
...
@@ -57,36 +83,61 @@ namespace Tools.UI.sys
...
@@ -57,36 +83,61 @@ namespace Tools.UI.sys
return
base
.
SaveCheck
();
return
base
.
SaveCheck
();
}
}
private
void
btn
Upload
_Click
(
object
sender
,
EventArgs
e
)
private
void
btn
GenZip
_Click
(
object
sender
,
EventArgs
e
)
{
{
//对话框
//显示进度条窗口
OpenFileDialog
dlg
=
new
OpenFileDialog
()
this
.
_bar
=
new
wProgressText
();
{
this
.
_bar
.
TopMost
=
true
;
//顶层显示;
Multiselect
=
false
,
this
.
_bar
.
Show
();
Filter
=
"压缩包|*.zip"
,
//异步调用
InitialDirectory
=
Environment
.
GetFolderPath
(
Environment
.
SpecialFolder
.
Desktop
),
Task
.
Run
(()
=>
{
};
string
Name
=
"工具平台"
;
//结果处理
string
RootPath
=
Directory
.
GetParent
(
Utils
.
StartupPath
).
FullName
;
if
(
dlg
.
ShowDialog
()
==
DialogResult
.
OK
)
string
ZipFileName
=
$@"
{
RootPath
}
\
{
Name
}
-
{
DateTime
.
Now
.
ToString
(
"yyyyMMdd-hhmmss"
)}
.zip"
;
{
this
.
GenZipFileList
.
Add
(
ZipFileName
);
//记录压缩文件名称,可能点多次
//路径检查
string
path
=
$@"
{
RootPath
}
\AppHome"
;
if
(!
Directory
.
Exists
(
path
))
return
;
//打包所有文件
DirectoryInfo
dirInfo
=
new
DirectoryInfo
(
path
);
var
fileInfos
=
dirInfo
.
GetFiles
(
"*.*"
,
SearchOption
.
AllDirectories
).
ToList
();
fileInfos
=
fileInfos
.
Where
(
f
=>
!
f
.
FullName
.
Contains
(
"AutoUpdate"
)
&&
!
f
.
FullName
.
Contains
(
"Tools.exe."
)
).
ToList
();
//剔除自动更新相关目录
//构造压缩文件路径集合
List
<
string
>
FileNames
=
new
List
<
string
>();
FileNames
.
AddRange
(
fileInfos
.
Select
(
f
=>
f
.
FullName
));
//调用压缩方法
Utils
.
ZipCompress4Package
(
this
.
_bar
,
ZipFileName
,
FileNames
,
RootPath
);
//赋值基本信息
//赋值基本信息
var
bytes
=
File
.
ReadAllBytes
(
dlg
.
FileName
);
var
bytes
=
File
.
ReadAllBytes
(
ZipFileName
);
var
drv
=
this
.
_ds
.
Tables
[
0
].
DefaultView
[
0
];
var
name
=
Path
.
GetFileName
(
dlg
.
FileName
);
var
size
=
(
bytes
.
Length
/
1000
M
/
1000
M
).
ToString
(
"0.##"
);
var
size
=
(
bytes
.
Length
/
1000
M
/
1000
M
).
ToString
(
"0.##"
);
this
.
tbUName
.
Text
=
name
;
var
name
=
Path
.
GetFileName
(
ZipFileName
);
this
.
tbUSize
.
Text
=
size
;
//数据源赋值
var
drv
=
this
.
_ds
.
Tables
[
0
].
DefaultView
[
0
];
drv
[
"UName"
]
=
name
;
drv
[
"UName"
]
=
name
;
drv
[
"USize"
]
=
size
;
drv
[
"USize"
]
=
size
;
drv
[
"UData"
]
=
bytes
;
drv
[
"UData"
]
=
bytes
;
drv
.
EndEdit
();
drv
.
EndEdit
();
//上传成功,更新图片
//更新UI
this
.
pictureBox1
.
Image
=
Properties
.
Resources
.
压缩包
;
this
.
AsyncUI
(()
=>
{
}
this
.
tbUName
.
Text
=
name
;
this
.
tbUSize
.
Text
=
size
;
this
.
pictureBox1
.
Image
=
Properties
.
Resources
.
压缩包
;
});
}).
ContinueWith
((
x
)
=>
{
if
(
x
.
IsCompleted
)
this
.
AsyncUI
(()
=>
this
.
_bar
.
Close
());
});
}
}
private
void
btnSave_Click
(
object
sender
,
EventArgs
e
)
private
void
btnSave_Click
(
object
sender
,
EventArgs
e
)
{
{
this
.
Save
();
this
.
Save
();
//刷新更新日期,即默认本机为最新版本
Utils
.
AppSettings
(
APP
.
UPDATE_TIME
,
DateTime
.
Now
.
ToString
(
"yyyy-MM-dd HH:mm:ss.fff"
));
}
}
}
}
}
}
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