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
7a63ecf0
Commit
7a63ecf0
authored
Aug 15, 2025
by
罗显健
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【编号:21348】项目打包升级
parent
44ef276f
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
290 additions
and
151 deletions
+290
-151
FrmMain.Designer.cs
Ftt.PatchPack/FrmMain.Designer.cs
+157
-77
FrmMain.cs
Ftt.PatchPack/FrmMain.cs
+53
-38
FrmProject.cs
Ftt.PatchPack/FrmProject.cs
+11
-25
Project.cs
Ftt.PatchPack/Project.cs
+69
-11
No files found.
Ftt.PatchPack/FrmMain.Designer.cs
View file @
7a63ecf0
This diff is collapsed.
Click to expand it.
Ftt.PatchPack/FrmMain.cs
View file @
7a63ecf0
...
@@ -33,12 +33,9 @@ namespace Ftt.PatchPack
...
@@ -33,12 +33,9 @@ namespace Ftt.PatchPack
private
void
FrmMain_Load
(
object
sender
,
EventArgs
e
)
private
void
FrmMain_Load
(
object
sender
,
EventArgs
e
)
{
{
InitForm
();
InitForm
();
}
}
private
void
InitForm
()
private
void
InitForm
()
{
{
LogVisible
(
false
);
projects
=
ProjectHelp
.
Read
();
projects
=
ProjectHelp
.
Read
();
if
(
projects
==
null
)
projects
=
new
Dictionary
<
string
,
Project
>();
if
(
projects
==
null
)
projects
=
new
Dictionary
<
string
,
Project
>();
foreach
(
var
cli
in
projects
)
foreach
(
var
cli
in
projects
)
...
@@ -79,8 +76,7 @@ namespace Ftt.PatchPack
...
@@ -79,8 +76,7 @@ namespace Ftt.PatchPack
}
}
#
endregion
#
endregion
#
region
按钮操作
#
region
【项目】添加、复制、修改、删除
private
void
btnAdd_Click
(
object
sender
,
EventArgs
e
)
private
void
btnAdd_Click
(
object
sender
,
EventArgs
e
)
{
{
Project
project
=
new
Project
();
Project
project
=
new
Project
();
...
@@ -92,6 +88,28 @@ namespace Ftt.PatchPack
...
@@ -92,6 +88,28 @@ namespace Ftt.PatchPack
}
}
}
}
}
}
private
void
btnCopy_Click
(
object
sender
,
EventArgs
e
)
{
if
(
lstProject
.
SelectedItems
.
Count
==
0
)
{
MessageBox
.
Show
(
"请选择需要复制的项目"
);
return
;
}
if
(!
projects
.
TryGetValue
(
lstProject
.
SelectedItems
[
0
].
Text
,
out
Project
project
))
{
MessageBox
.
Show
(
"复制项目失败!"
);
return
;
}
var
newProject
=
project
.
Copy
();
using
(
FrmProject
frmProject
=
new
FrmProject
(
projects
,
ref
newProject
))
{
if
(
frmProject
.
ShowDialog
()
==
DialogResult
.
Yes
)
{
lstProject
.
Items
.
Add
(
newProject
.
Name
);
}
}
}
private
void
btnEdit_Click
(
object
sender
,
EventArgs
e
)
private
void
btnEdit_Click
(
object
sender
,
EventArgs
e
)
{
{
...
@@ -113,9 +131,12 @@ namespace Ftt.PatchPack
...
@@ -113,9 +131,12 @@ namespace Ftt.PatchPack
private
void
btnDel_Click
(
object
sender
,
EventArgs
e
)
private
void
btnDel_Click
(
object
sender
,
EventArgs
e
)
{
{
var
items
=
lstProject
.
CheckedItems
;
var
items
=
lstProject
.
CheckedItems
;
if
(
items
.
Count
==
0
)
return
;
if
(
items
.
Count
==
0
)
{
if
(
MessageBox
.
Show
(
"确定要删除选择的项目?"
,
""
,
MessageBoxButtons
.
YesNo
)
!=
DialogResult
.
Yes
)
return
;
MessageBox
.
Show
(
"请选择需要删除的项目!"
);
return
;
}
if
(
MessageBox
.
Show
(
$"是否确定要删除勾选的
{
items
.
Count
}
个项目?"
,
"询问"
,
MessageBoxButtons
.
YesNo
)
!=
DialogResult
.
Yes
)
return
;
for
(
int
index
=
items
.
Count
-
1
;
index
>=
0
;
index
--)
for
(
int
index
=
items
.
Count
-
1
;
index
>=
0
;
index
--)
{
{
...
@@ -130,7 +151,9 @@ namespace Ftt.PatchPack
...
@@ -130,7 +151,9 @@ namespace Ftt.PatchPack
ProjectHelp
.
Save
(
projects
);
// 删除后,需要保存
ProjectHelp
.
Save
(
projects
);
// 删除后,需要保存
}
}
#
endregion
#
region
按钮操作
private
void
btnPatch_Click
(
object
sender
,
EventArgs
e
)
private
void
btnPatch_Click
(
object
sender
,
EventArgs
e
)
{
{
var
items
=
lstProject
.
CheckedItems
;
var
items
=
lstProject
.
CheckedItems
;
...
@@ -153,10 +176,11 @@ namespace Ftt.PatchPack
...
@@ -153,10 +176,11 @@ namespace Ftt.PatchPack
item
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
item
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
}
}
tabControl1
.
SelectTab
(
tabPageLog
);
//打包的时候,切换到日志页签
int
success
=
0
;
int
success
=
0
;
Cursor
.
Current
=
Cursors
.
WaitCursor
;
Cursor
.
Current
=
Cursors
.
WaitCursor
;
Project
.
MergeSqlFile
=
ckbMergeSql
.
Checked
;
InitProjectPackCfg
();
foreach
(
ListViewItem
item
in
items
)
foreach
(
ListViewItem
item
in
items
)
{
{
if
(
projects
.
TryGetValue
(
item
.
Text
,
out
Project
project
)
&&
project
!=
null
)
if
(
projects
.
TryGetValue
(
item
.
Text
,
out
Project
project
)
&&
project
!=
null
)
...
@@ -181,7 +205,7 @@ namespace Ftt.PatchPack
...
@@ -181,7 +205,7 @@ namespace Ftt.PatchPack
}
}
finally
finally
{
{
ProjectHelp
.
DeleteDirectoryIfExists
(
project
.
MergeSqlTempFullPath
);
ProjectHelp
.
DeleteDirectoryIfExists
(
project
.
MergeSqlTempFullPath
);
//删除合并脚本的临时目录
Application
.
DoEvents
();
Application
.
DoEvents
();
}
}
}
}
...
@@ -189,7 +213,6 @@ namespace Ftt.PatchPack
...
@@ -189,7 +213,6 @@ namespace Ftt.PatchPack
Cursor
.
Current
=
Cursors
.
Default
;
Cursor
.
Current
=
Cursors
.
Default
;
int
fail
=
totalCount
-
success
;
int
fail
=
totalCount
-
success
;
if
(
fail
>
0
)
ckbShowLog
.
Checked
=
true
;
string
strFail
=
fail
==
0
?
""
:
$",失败
{
fail
}
个"
;
string
strFail
=
fail
==
0
?
""
:
$",失败
{
fail
}
个"
;
MessageBox
.
Show
(
$"打包项目
{
totalCount
}
个,成功
{
success
}
个
{
strFail
}
。"
);
MessageBox
.
Show
(
$"打包项目
{
totalCount
}
个,成功
{
success
}
个
{
strFail
}
。"
);
...
@@ -208,36 +231,19 @@ namespace Ftt.PatchPack
...
@@ -208,36 +231,19 @@ namespace Ftt.PatchPack
System
.
Diagnostics
.
Process
.
Start
(
PackageFileDirectory
);
System
.
Diagnostics
.
Process
.
Start
(
PackageFileDirectory
);
}
}
/// <summary>
private
void
ckbPackTemplate_CheckedChanged
(
object
sender
,
EventArgs
e
)
/// 显示日志
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private
void
ckbShowLog_CheckedChanged
(
object
sender
,
EventArgs
e
)
{
{
LogVisible
(
ckbShowLog
.
Checked
);
if
(
ckbPackTemplate
.
Checked
)
}
#
endregion
#
region
内部方法
private
void
LogVisible
(
bool
visible
)
{
if
(
this
.
InvokeRequired
)
{
{
this
.
BeginInvoke
(
new
Action
<
bool
>(
LogVisible
),
visible
);
if
(
MessageBox
.
Show
(
"Template模版文件一般由项目组自己维护,是否确定打包?"
,
"警告"
,
MessageBoxButtons
.
OKCancel
,
MessageBoxIcon
.
Warning
)
==
DialogResult
.
Cancel
)
}
{
else
ckbPackTemplate
.
Checked
=
false
;
{
}
if
(
visible
)
this
.
Width
+=
gpbLog
.
Width
;
else
this
.
Width
-=
gpbLog
.
Width
;
gpbLog
.
Visible
=
visible
;
}
}
}
}
#
endregion
#
region
内部方法
/// <summary>
/// <summary>
/// 写日志
/// 写日志
/// </summary>
/// </summary>
...
@@ -253,6 +259,15 @@ namespace Ftt.PatchPack
...
@@ -253,6 +259,15 @@ namespace Ftt.PatchPack
txtLog
.
AppendText
(
content
+
"\r\n"
);
txtLog
.
AppendText
(
content
+
"\r\n"
);
}
}
}
}
/// <summary>
/// 初始化项目打包配置
/// </summary>
private
void
InitProjectPackCfg
()
{
Project
.
MergeSqlFile
=
ckbMergeSql
.
Checked
;
Project
.
PackTemplate
=
ckbPackTemplate
.
Checked
;
}
#
endregion
#
endregion
}
}
}
}
Ftt.PatchPack/FrmProject.cs
View file @
7a63ecf0
...
@@ -120,47 +120,33 @@ namespace Ftt.PatchPack
...
@@ -120,47 +120,33 @@ namespace Ftt.PatchPack
project
.
RelativeAppFilePath
=
txtRelativeAppFilePath
.
Text
.
Trim
();
project
.
RelativeAppFilePath
=
txtRelativeAppFilePath
.
Text
.
Trim
();
project
.
ExeName
=
this
.
txtExeName
.
Text
.
Trim
();
project
.
ExeName
=
this
.
txtExeName
.
Text
.
Trim
();
project
.
RelativeDbFilePath
=
txtRelativeDbFilePath
.
Text
.
Trim
();
project
.
RelativeDbFilePath
=
txtRelativeDbFilePath
.
Text
.
Trim
();
project
.
Name
=
txtProjectName
.
Text
.
Trim
();
if
(
project
.
Name
==
null
)
// 新增
if
(
this
.
dictionary
.
ContainsKey
(
project
.
Name
))
{
{
project
.
Name
=
txtProjectName
.
Text
.
Trim
();
if
(
dictionary
[
project
.
Name
]
!=
project
//如果是同一个对象,则不需要提示
&&
MessageBox
.
Show
(
null
,
$"项目【
{
project
.
Name
}
】已存在,是否替换?"
,
"提示"
,
MessageBoxButtons
.
YesNo
)
!=
DialogResult
.
Yes
)
if
(
this
.
dictionary
.
ContainsKey
(
project
.
Name
))
return
;
{
if
(
MessageBox
.
Show
(
null
,
"已存在,是否替换"
,
"提示"
,
MessageBoxButtons
.
YesNo
)
==
DialogResult
.
Yes
)
dictionary
[
project
.
Name
]
=
project
;
dictionary
[
project
.
Name
]
=
project
;
this
.
DialogResult
=
DialogResult
.
No
;
//替换项目无需添加,返回No
else
return
;
}
else
{
dictionary
.
Add
(
project
.
Name
,
project
);
}
}
}
else
else
{
{
// 移除原始的,再添加新的
dictionary
.
Remove
(
this
.
project
.
Name
);
project
.
Name
=
txtProjectName
.
Text
.
Trim
();
dictionary
.
Add
(
project
.
Name
,
project
);
dictionary
.
Add
(
project
.
Name
,
project
);
base
.
DialogResult
=
DialogResult
.
Yes
;
//需要添加到列表,返回Yes
}
}
ProjectHelp
.
Save
(
dictionary
);
ProjectHelp
.
Save
(
dictionary
);
MessageBox
.
Show
(
"保存成功!"
);
MessageBox
.
Show
(
"保存成功!"
);
base
.
DialogResult
=
DialogResult
.
Yes
;
this
.
Close
();
this
.
Close
();
}
}
catch
(
Exception
exception
)
catch
(
Exception
exception
)
{
{
base
.
DialogResult
=
DialogResult
.
None
;
MessageBox
.
Show
(
exception
.
ToString
());
MessageBox
.
Show
(
exception
.
ToString
());
}
}
}
}
private
void
btnCancle_Click
(
object
sender
,
EventArgs
e
)
private
void
btnCancle_Click
(
object
sender
,
EventArgs
e
)
...
...
Ftt.PatchPack/Project.cs
View file @
7a63ecf0
...
@@ -12,6 +12,18 @@ namespace Ftt.PatchPack
...
@@ -12,6 +12,18 @@ namespace Ftt.PatchPack
{
{
public
class
Project
public
class
Project
{
{
#
region
静态属性
/// <summary>
/// 是否合并sql文件,默认:否.
/// </summary>
public
static
bool
MergeSqlFile
=
false
;
/// <summary>
/// 是否打包模板文件,默认:否。
/// </summary>
public
static
bool
PackTemplate
=
false
;
#
endregion
#
region
属性定义
#
region
属性定义
/// <summary>
/// <summary>
...
@@ -53,10 +65,6 @@ namespace Ftt.PatchPack
...
@@ -53,10 +65,6 @@ namespace Ftt.PatchPack
/// </summary>
/// </summary>
public
string
RelativeDbFilePath
{
get
;
set
;
}
=
@"开发文档\数据库脚本"
;
public
string
RelativeDbFilePath
{
get
;
set
;
}
=
@"开发文档\数据库脚本"
;
/// <summary>
/// 是否合并sql文件.
/// </summary>
public
static
bool
MergeSqlFile
=
false
;
/// <summary>
/// <summary>
/// 合并Sql文件的临时目录,在<see cref="RelativeDbFilePath"/>目录下。
/// 合并Sql文件的临时目录,在<see cref="RelativeDbFilePath"/>目录下。
...
@@ -68,10 +76,16 @@ namespace Ftt.PatchPack
...
@@ -68,10 +76,16 @@ namespace Ftt.PatchPack
/// </summary>
/// </summary>
static
string
MergeSqlRelativePath
=
"MergeTemp"
;
static
string
MergeSqlRelativePath
=
"MergeTemp"
;
/// <summary>
/// 永久有效的年份标记:2099
/// <para>该年份文件夹内的文件、在有效期内的需要打包</para>
/// </summary>
static
int
ForeverValidYear
=
2099
;
#
endregion
#
endregion
/// <summary>
/// <summary>
/// 额外打包的文件(存在且更
更
新时间符合Dll的更新时间)。比如:更新 2021-11-26 17:30:39 lxj
/// 额外打包的文件(存在且更新时间符合Dll的更新时间)。比如:更新 2021-11-26 17:30:39 lxj
/// </summary>
/// </summary>
static
List
<
string
>
ContainFiles
=
new
List
<
string
>
{
"Notice.xml"
};
static
List
<
string
>
ContainFiles
=
new
List
<
string
>
{
"Notice.xml"
};
static
List
<
string
>
ExceptFiles
=
new
List
<
string
>
{
"U.Memopad.dll"
};
static
List
<
string
>
ExceptFiles
=
new
List
<
string
>
{
"U.Memopad.dll"
};
...
@@ -173,7 +187,12 @@ namespace Ftt.PatchPack
...
@@ -173,7 +187,12 @@ namespace Ftt.PatchPack
valid
.
AddRange
(
GetValidPatchFile
(
imgPath
,
"*.*"
,
SearchOption
.
TopDirectoryOnly
,
imgPath
,
$"
{
ExeName
}
\\Image"
,
PatchTimeFrame_Xml
));
valid
.
AddRange
(
GetValidPatchFile
(
imgPath
,
"*.*"
,
SearchOption
.
TopDirectoryOnly
,
imgPath
,
$"
{
ExeName
}
\\Image"
,
PatchTimeFrame_Xml
));
}
}
//当需要打包模板文件时,打包Template目录下的所有文件(时间范围同xml)
var
templatePath
=
Path
.
Combine
(
AbsoluteRootDirectory
,
RelativeAppFilePath
,
"Template"
);
if
(
PackTemplate
&&
System
.
IO
.
Directory
.
Exists
(
templatePath
))
{
valid
.
AddRange
(
GetValidPatchFile
(
templatePath
,
"*.*"
,
SearchOption
.
TopDirectoryOnly
,
templatePath
,
$"
{
ExeName
}
\\Template"
,
PatchTimeFrame_Xml
));
}
#
endregion
#
endregion
...
@@ -208,7 +227,10 @@ namespace Ftt.PatchPack
...
@@ -208,7 +227,10 @@ namespace Ftt.PatchPack
foreach
(
var
dire
in
dires
)
foreach
(
var
dire
in
dires
)
{
{
valid
.
AddRange
(
GetValidPatchFile
(
dire
.
FullName
,
"*.sql"
,
SearchOption
.
AllDirectories
,
path
,
"DB"
,
-
1
));
// 脚本文件夹里的文件永久有效。
// 2099-xx-xx文件内的脚本需要取有效期内的。其他日期的文件夹为增量脚本已通过校验,需要取所有。
var
hours
=
ParseToDateTime
(
dire
.
Name
).
Year
==
ForeverValidYear
?
PatchTimeFrame_Sql
:
-
1
;
valid
.
AddRange
(
GetValidPatchFile
(
dire
.
FullName
,
"*.sql"
,
SearchOption
.
AllDirectories
,
path
,
"DB"
,
hours
));
// 脚本文件夹里的文件永久有效。
}
}
}
}
...
@@ -254,6 +276,23 @@ namespace Ftt.PatchPack
...
@@ -254,6 +276,23 @@ namespace Ftt.PatchPack
Int32
.
TryParse
(
ConfigurationManager
.
AppSettings
[
"PatchTimeFrame_Xml"
],
out
PatchTimeFrame_Xml
);
Int32
.
TryParse
(
ConfigurationManager
.
AppSettings
[
"PatchTimeFrame_Xml"
],
out
PatchTimeFrame_Xml
);
}
}
/// <summary>
/// 复制项目
/// </summary>
/// <returns></returns>
public
Project
Copy
()
{
return
new
Project
{
Name
=
"请输入新项目名称"
,
ExeName
=
this
.
ExeName
,
AbsoluteRootDirectory
=
this
.
AbsoluteRootDirectory
,
RelativeAppFilePath
=
this
.
RelativeAppFilePath
,
RelativeDbFilePath
=
this
.
RelativeDbFilePath
,
MergeSqlTempFullPath
=
this
.
MergeSqlTempFullPath
};
}
#
endregion
#
endregion
#
region
私有方法
#
region
私有方法
...
@@ -276,9 +315,7 @@ namespace Ftt.PatchPack
...
@@ -276,9 +315,7 @@ namespace Ftt.PatchPack
{
{
DirectoryInfo
directoryInfo
=
new
DirectoryInfo
(
dir
);
DirectoryInfo
directoryInfo
=
new
DirectoryInfo
(
dir
);
var
dtFile
=
ParseToDateTime
(
directoryInfo
.
Name
);
// 文件夹的命名规则,必须是日期格式
if
(!
IsValidDBScriptFolderName
(
directoryInfo
.
Name
,
hours
))
continue
;
// 文件夹的命名规则,必须是日期格式
if
(!
IsValid
(
dtFile
,
hours
))
continue
;
validPath
.
Add
(
directoryInfo
);
validPath
.
Add
(
directoryInfo
);
}
}
...
@@ -305,8 +342,15 @@ namespace Ftt.PatchPack
...
@@ -305,8 +342,15 @@ namespace Ftt.PatchPack
FileInfo
destMergeFile
=
null
;
//合并文件锚点
FileInfo
destMergeFile
=
null
;
//合并文件锚点
foreach
(
var
sourceFile
in
sqlFiles
)
foreach
(
var
sourceFile
in
sqlFiles
)
{
{
//2099-xx-xx 的文件夹内,还有子文件夹。层级比其他日期的要多一层,合并时用到的临时目录也需要多一层。
if
(
sourceFile
.
RelativePatchPath
.
StartsWith
(
"DB\\2099"
))
{
var
subPath
=
Path
.
Combine
(
MergeSqlTempFullPath
,
sourceFile
.
RelativePatchPath
);
if
(!
Directory
.
Exists
(
subPath
))
Directory
.
CreateDirectory
(
subPath
);
//创建所有层级的子目录,打包结束会被删除
}
var
tmpFile
=
Path
.
Combine
(
MergeSqlTempFullPath
,
$"
{
sourceFile
.
RelativePatchPath
}
_
{
sourceFile
.
Name
}
"
);
var
tmpFile
=
Path
.
Combine
(
MergeSqlTempFullPath
,
$"
{
sourceFile
.
RelativePatchPath
}
_
{
sourceFile
.
Name
}
"
);
File
.
Copy
(
sourceFile
.
FullName
,
tmpFile
,
true
);
File
.
Copy
(
sourceFile
.
FullName
,
tmpFile
,
true
);
//把待合并的sql文件复制到临时目录。
if
(
ProjectHelp
.
CanMergeSqlFile
(
tmpFile
))
if
(
ProjectHelp
.
CanMergeSqlFile
(
tmpFile
))
{
{
...
@@ -428,6 +472,18 @@ namespace Ftt.PatchPack
...
@@ -428,6 +472,18 @@ namespace Ftt.PatchPack
return
date
;
return
date
;
}
}
/// <summary>
/// 校验脚本文件夹名称是否合法
/// </summary>
/// <param name="folderName">文件夹名称(日期格式)</param>
/// <param name="hours">打包期限,单位小时</param>
/// <returns></returns>
private
bool
IsValidDBScriptFolderName
(
string
folderName
,
double
hours
)
{
DateTime
date
=
ParseToDateTime
(
folderName
);
return
IsValid
(
date
,
hours
);
}
#
endregion
#
endregion
}
}
...
@@ -447,6 +503,8 @@ namespace Ftt.PatchPack
...
@@ -447,6 +503,8 @@ namespace Ftt.PatchPack
fileName
=
@"config\project.json"
;
fileName
=
@"config\project.json"
;
if
(
File
.
Exists
(
oldPath
))
if
(
File
.
Exists
(
oldPath
))
{
{
if
(!
Directory
.
Exists
(
Application
.
StartupPath
))
Directory
.
CreateDirectory
(
Application
.
StartupPath
);
File
.
Copy
(
oldPath
,
FilePath
,
true
);
File
.
Copy
(
oldPath
,
FilePath
,
true
);
File
.
Delete
(
oldPath
);
File
.
Delete
(
oldPath
);
}
}
...
...
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