Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张东亮
/
NS100
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 02196bad
由
张东亮
编写于
2023-04-25 16:36:39 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
tmp
1 个父辈
9e753723
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
262 行增加
和
2 行删除
Model/AutoGenRule.cs
Model/FilePath.cs
Model/Model.csproj
SmartScan/Common.cs
SmartScan/Form/FrmMain.cs
SmartScan/SetControl/UsrMacro - 副本.cs
Model/AutoGenRule.cs
0 → 100644
查看文件 @
02196ba
using
Newtonsoft.Json
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Web.Script.Serialization
;
namespace
Model
{
/// <summary>
/// 关键字自动生成信息
/// </summary>
public
class
AutoGenRule
{
/// <summary>
/// 关键字
/// </summary>
public
string
Keyword
{
get
;
set
;
}
=
""
;
/// <summary>
/// 生成规则
/// </summary>
public
string
GenRule
{
get
;
set
;
}
=
""
;
/// <summary>
/// 前缀
/// </summary>
public
string
Prefix
{
get
;
set
;
}
=
""
;
/// <summary>
/// 后缀
/// </summary>
public
string
Postfix
{
get
;
set
;
}
=
""
;
/// <summary>
/// 数字的长度
/// </summary>
public
int
NumLength
{
get
;
set
;
}
=
1
;
/// <summary>
/// 当数字位数不够时,是否填充0
/// </summary>
public
bool
IsFillZero
{
get
;
set
;
}
=
false
;
/// <summary>
/// 序号每日重置
/// </summary>
public
bool
NumAutoResetByDate
{
get
;
set
;
}
=
true
;
/// <summary>
/// 是否启用后缀数字
/// </summary>
public
bool
AutoGenID
{
get
;
set
;
}
=
false
;
public
static
List
<
AutoGenRule
>
LoadFile
()
{
List
<
AutoGenRule
>
rules
=
new
List
<
AutoGenRule
>();
try
{
if
(!
File
.
Exists
(
Model
.
FilePath
.
CONFIG_AUTOGENRULES
))
return
rules
;
string
rtxt
=
File
.
ReadAllText
(
Model
.
FilePath
.
CONFIG_AUTOGENRULES
);
JavaScriptSerializer
serializer
=
new
();
rules
=
(
List
<
AutoGenRule
>)
serializer
.
DeserializeObject
(
rtxt
);
return
rules
;
}
catch
(
Exception
ex
)
{
LogNet
.
log
.
Error
(
"Load AutoGenRule File"
,
ex
);
}
return
rules
;
}
public
static
void
Save
(
List
<
AutoGenRule
>
rules
)
{
try
{
// if (!File.Exists(Model.FilePath.CONFIG_AUTOGENRULES))
JavaScriptSerializer
serializer
=
new
JavaScriptSerializer
();
string
json
=
serializer
.
Serialize
(
rules
);
File
.
WriteAllText
(
Model
.
FilePath
.
CONFIG_AUTOGENRULES
,
json
);
}
catch
(
Exception
ex
)
{
LogNet
.
log
.
Error
(
"LoadFile"
,
ex
);
}
}
}
}
Model/FilePath.cs
查看文件 @
02196ba
...
@@ -24,5 +24,6 @@ namespace Model
...
@@ -24,5 +24,6 @@ namespace Model
public
static
readonly
string
CONFIG_EXTENSION
=
Environment
.
CurrentDirectory
+
"\\Config\\Extension.json"
;
public
static
readonly
string
CONFIG_EXTENSION
=
Environment
.
CurrentDirectory
+
"\\Config\\Extension.json"
;
public
static
readonly
string
CONFIG_REELID
=
Environment
.
CurrentDirectory
+
"\\Config\\ReelID"
;
public
static
readonly
string
CONFIG_REELID
=
Environment
.
CurrentDirectory
+
"\\Config\\ReelID"
;
public
static
readonly
string
CONFIG_DATABASE
=
Environment
.
CurrentDirectory
+
"\\Config\\Database.db3"
;
public
static
readonly
string
CONFIG_DATABASE
=
Environment
.
CurrentDirectory
+
"\\Config\\Database.db3"
;
public
static
readonly
string
CONFIG_AUTOGENRULES
=
Environment
.
CurrentDirectory
+
"\\Config\\AutoGenRules.json"
;
}
}
}
}
Model/Model.csproj
查看文件 @
02196ba
...
@@ -65,6 +65,7 @@
...
@@ -65,6 +65,7 @@
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Web" />
<Reference Include="System.ServiceModel.Web" />
<Reference Include="System.Web" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data.DataSetExtensions" />
...
@@ -77,6 +78,7 @@
...
@@ -77,6 +78,7 @@
</Reference>
</Reference>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile Include="AutoGenRule.cs" />
<Compile Include="ExtensionControl.cs" />
<Compile Include="ExtensionControl.cs" />
<Compile Include="ExtensionFunction.cs" />
<Compile Include="ExtensionFunction.cs" />
<Compile Include="FilePath.cs" />
<Compile Include="FilePath.cs" />
...
...
SmartScan/Common.cs
查看文件 @
02196ba
using
System
;
using
Model
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.Drawing
;
...
@@ -24,6 +25,7 @@ namespace SmartScan
...
@@ -24,6 +25,7 @@ namespace SmartScan
public
static
int
mateMaxCodeID
;
public
static
int
mateMaxCodeID
;
public
static
readonly
string
[]
CODE_SPLIT
=
new
string
[]
{
","
,
";"
,
":"
,
"@"
,
"#"
,
"$"
,
"%"
,
"&"
,
"-"
,
"_"
,
"+"
,
"|"
,
"!"
,
"^"
,
"*"
,
"?"
,
"/"
,
"\\"
,
"[Space]"
,
"[Tab]"
};
public
static
readonly
string
[]
CODE_SPLIT
=
new
string
[]
{
","
,
";"
,
":"
,
"@"
,
"#"
,
"$"
,
"%"
,
"&"
,
"-"
,
"_"
,
"+"
,
"|"
,
"!"
,
"^"
,
"*"
,
"?"
,
"/"
,
"\\"
,
"[Space]"
,
"[Tab]"
};
public
static
List
<
AutoGenRule
>
AutoGenRules
;
}
}
}
}
SmartScan/Form/FrmMain.cs
查看文件 @
02196ba
...
@@ -260,7 +260,7 @@ namespace SmartScan
...
@@ -260,7 +260,7 @@ namespace SmartScan
//语言
//语言
CboLanguage
.
Items
.
AddRange
(
Language
.
Name
);
CboLanguage
.
Items
.
AddRange
(
Language
.
Name
);
CboLanguage
.
SelectedText
=
Common
.
config
.
Language
;
CboLanguage
.
SelectedText
=
Common
.
config
.
Language
;
Common
.
AutoGenRules
=
AutoGenRule
.
LoadFile
();
if
(
Common
.
config
.
OpenMaximize
)
Maximize
();
if
(
Common
.
config
.
OpenMaximize
)
Maximize
();
...
...
SmartScan/SetControl/UsrMacro - 副本.cs
0 → 100644
查看文件 @
02196ba
using
System
;
using
System.Collections.Generic
;
using
System.Windows.Forms
;
using
DocumentFormat.OpenXml.Wordprocessing
;
using
Model
;
namespace
SmartScan
{
public
partial
class
UsrMacro
:
UserControl
,
ISetMenu
{
private
readonly
List
<
string
>
keyCopy
;
private
readonly
List
<
AutoGenRule
>
autoGenRulesCopy
;
AutoGenRule
genRule
;
public
UsrMacro
()
{
InitializeComponent
();
keyCopy
=
new
(
Common
.
macroKey
);
autoGenRulesCopy
=
new
(
Common
.
AutoGenRules
);
LstKey
.
Items
.
AddRange
(
keyCopy
.
ToArray
());
setRIkey
();
if
(
autoGenRulesCopy
.
Count
>
0
)
{
genRule
=
autoGenRulesCopy
[
0
];
}
else
{
genRule
=
new
AutoGenRule
();
}
TxtReelIDMatch
.
Text
=
genRule
.
GenRule
;
TxtPrefix
.
Text
=
genRule
.
Prefix
;
TxtPostfix
.
Text
=
genRule
.
Postfix
;
NumReelIDPlaces
.
Value
=
genRule
.
NumLength
;
ChkReelIDFillZero
.
Checked
=
genRule
.
IsFillZero
;
ChkResetidbydate
.
Checked
=
genRule
.
NumAutoResetByDate
;
Asa
.
FaceControl
.
Language
.
SetLanguage
(
this
);
}
public
Asa
.
FaceControl
.
FacePanel
GetPanel
()
{
return
facePanel1
;
}
public
void
Save
()
{
Common
.
macroKey
.
Clear
();
Common
.
macroKey
.
AddRange
(
keyCopy
);
System
.
IO
.
File
.
WriteAllLines
(
FilePath
.
CONFIG_MACRO_KEY
,
Common
.
macroKey
.
ToArray
());
Common
.
config
.
ReelIDMatch
=
TxtReelIDMatch
.
Text
;
Common
.
config
.
ReelIDPrefix
=
TxtPrefix
.
Text
;
Common
.
config
.
ReelIDPostfix
=
TxtPostfix
.
Text
;
Common
.
config
.
ReelIDPlaces
=
(
int
)
NumReelIDPlaces
.
Value
;
Common
.
config
.
ReelIDFillZero
=
ChkReelIDFillZero
.
Checked
;
Common
.
config
.
ReelIDAutoResetByDate
=
ChkResetidbydate
.
Checked
;
Common
.
AutoGenRules
.
Clear
();
Common
.
AutoGenRules
.
AddRange
(
autoGenRulesCopy
);
AutoGenRule
.
Save
(
Common
.
AutoGenRules
);
}
void
setRIkey
()
{
LstKey
.
Items
.
Clear
();
LstKey
.
Items
.
AddRange
(
keyCopy
.
ToArray
());
for
(
int
i
=
0
;
i
<
LstKey
.
Items
.
Count
;
i
++)
{
var
rule
=
autoGenRulesCopy
.
Find
(
s
=>
s
.
Keyword
.
Equals
(
LstKey
.
Items
[
i
]));
if
(
rule
!=
null
)
{
LstKey
.
Items
[
i
]
=
"[Auto]"
+
rule
.
Keyword
;
}
}
}
private
void
LstKey_SelectedIndexChanged
(
object
sender
,
EventArgs
e
)
{
if
(
LstKey
.
SelectedIndex
>=
0
)
{
TxtKey
.
Text
=
keyCopy
[
LstKey
.
SelectedIndex
];
genRule
=
autoGenRulesCopy
.
Find
(
s
=>
s
.
Keyword
.
Equals
(
TxtKey
.
Text
));
}
}
private
void
BtnAddKey_Click
(
object
sender
,
EventArgs
e
)
{
string
text
=
TxtKey
.
Text
;
int
index
=
keyCopy
.
FindIndex
(
match
=>
match
==
text
);
if
(
index
==
-
1
)
{
keyCopy
.
Add
(
text
);
LstKey
.
Items
.
Add
(
text
);
autoGenRulesCopy
.
Add
(
new
AutoGenRule
()
{
Keyword
=
text
);
}
else
{
string
hint
=
Asa
.
FaceControl
.
Language
.
Dialog
(
"KeyExists"
);
hint
=
hint
.
Replace
(
"[name]"
,
text
);
new
Asa
.
FaceControl
.
FaceMessageBox
(
""
,
hint
,
MessageBoxButtons
.
OK
).
ShowDialog
();
}
}
private
void
BtnDelKey_Click
(
object
sender
,
EventArgs
e
)
{
if
(
LstKey
.
SelectedIndex
==
-
1
)
return
;
keyCopy
.
RemoveAt
(
LstKey
.
SelectedIndex
);
LstKey
.
Items
.
RemoveAt
(
LstKey
.
SelectedIndex
);
var
rule
=
autoGenRulesCopy
.
Find
(
s
=>
s
.
Keyword
.
Equals
(
keyCopy
[
LstKey
.
SelectedIndex
]));
if
(
rule
!=
null
)
{
}
autoGenRulesCopy
.
Remove
(
rule
);
}
private
void
BtnUpdateKey_Click
(
object
sender
,
EventArgs
e
)
{
if
(
LstKey
.
SelectedIndex
==
-
1
)
return
;
string
text
=
TxtKey
.
Text
;
int
index
=
keyCopy
.
FindIndex
(
match
=>
match
==
text
);
if
(
index
==
-
1
)
{
keyCopy
[
LstKey
.
SelectedIndex
]
=
text
;
LstKey
.
Items
[
LstKey
.
SelectedIndex
]
=
text
;
setRIkey
();
}
else
{
string
hint
=
Asa
.
FaceControl
.
Language
.
Dialog
(
"KeyExists"
);
hint
=
hint
.
Replace
(
"[name]"
,
text
);
new
Asa
.
FaceControl
.
FaceMessageBox
(
""
,
hint
,
MessageBoxButtons
.
OK
).
ShowDialog
();
}
}
private
void
BtnAppendKey_Click
(
object
sender
,
EventArgs
e
)
{
if
(
LstKey
.
SelectedIndex
==
-
1
)
return
;
string
key
=
"["
+
LstKey
.
Text
+
"]"
;
TxtReelIDMatch
.
AppendText
(
key
);
}
private
void
btn_up_Click
(
object
sender
,
EventArgs
e
)
{
if
(
LstKey
.
SelectedIndex
==
-
1
||
LstKey
.
SelectedIndex
==
0
)
return
;
keyCopy
.
Insert
(
LstKey
.
SelectedIndex
-
1
,
keyCopy
[
LstKey
.
SelectedIndex
]);
keyCopy
.
RemoveAt
(
LstKey
.
SelectedIndex
+
1
);
LstKey
.
Items
.
Clear
();
LstKey
.
Items
.
AddRange
(
keyCopy
.
ToArray
());
LstKey
.
SelectedIndex
=
LstKey
.
SelectedIndex
-
1
;
}
private
void
btn_down_Click
(
object
sender
,
EventArgs
e
)
{
if
(
LstKey
.
SelectedIndex
==
-
1
||
LstKey
.
SelectedIndex
==
keyCopy
.
Count
-
1
)
return
;
keyCopy
.
Insert
(
LstKey
.
SelectedIndex
+
2
,
keyCopy
[
LstKey
.
SelectedIndex
]);
keyCopy
.
RemoveAt
(
LstKey
.
SelectedIndex
);
LstKey
.
Items
.
Clear
();
LstKey
.
Items
.
AddRange
(
keyCopy
.
ToArray
());
LstKey
.
SelectedIndex
=
LstKey
.
SelectedIndex
+
1
;
}
private
void
btn_setriid_Click
(
object
sender
,
EventArgs
e
)
{
if
(
LstKey
.
SelectedIndex
==
-
1
)
return
;
if
(
keyCopy
[
LstKey
.
SelectedIndex
]
==
Common
.
config
.
ReelIDKeyWord
)
Common
.
config
.
ReelIDKeyWord
=
""
;
else
Common
.
config
.
ReelIDKeyWord
=
keyCopy
[
LstKey
.
SelectedIndex
];
setRIkey
();
}
private
void
btn_adddatetime_Click
(
object
sender
,
EventArgs
e
)
{
string
key
=
"[datetime:yyyyMMddHHmmss]"
;
TxtReelIDMatch
.
AppendText
(
key
);
}
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论