Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张东亮
/
NS100
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit b5f34519
由
张东亮
编写于
2023-04-11 09:34:14 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1
1 个父辈
b1a35793
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
66 行增加
和
12 行删除
SmartScan/Form/FrmLoading.cs
SmartScan/Program.cs
SmartScan/WebCallWork.cs
SmartScan/Form/FrmLoading.cs
查看文件 @
b5f3451
...
@@ -24,7 +24,6 @@ namespace SmartScan
...
@@ -24,7 +24,6 @@ namespace SmartScan
FileInfo
fileInfo
=
new
FileInfo
(
current
.
MainModule
.
FileName
);
FileInfo
fileInfo
=
new
FileInfo
(
current
.
MainModule
.
FileName
);
DateTime
dateTime
=
fileInfo
.
LastWriteTime
;
DateTime
dateTime
=
fileInfo
.
LastWriteTime
;
string
version
=
$
"{dateTime.Year%10}.{dateTime.Month}.{dateTime.Day.ToString("
00
")}{dateTime.Hour.ToString("
00
")}"
;
string
version
=
$
"{dateTime.Year%10}.{dateTime.Month}.{dateTime.Day.ToString("
00
")}{dateTime.Hour.ToString("
00
")}"
;
LogNet
.
log
=
log4net
.
LogManager
.
GetLogger
(
"SmartScan"
);
LogNet
.
log
.
Info
(
$
"===== 程序开始 {version} ====="
);
LogNet
.
log
.
Info
(
$
"===== 程序开始 {version} ====="
);
Common
.
config
=
new
BLL
.
Config
();
Common
.
config
=
new
BLL
.
Config
();
...
...
SmartScan/Program.cs
查看文件 @
b5f3451
...
@@ -18,24 +18,78 @@ namespace SmartScan
...
@@ -18,24 +18,78 @@ namespace SmartScan
[
STAThread
]
[
STAThread
]
static
void
Main
(
string
[]
args
)
static
void
Main
(
string
[]
args
)
{
{
LogNet
.
log
=
log4net
.
LogManager
.
GetLogger
(
"SmartScan"
);
Application
.
SetUnhandledExceptionMode
(
UnhandledExceptionMode
.
CatchException
);
Application
.
ThreadException
+=
Application_ThreadException
;
AppDomain
.
CurrentDomain
.
UnhandledException
+=
CurrentDomain_UnhandledException
;
bool
isShow
=
false
;
Environment
.
CurrentDirectory
=
Application
.
StartupPath
;
Environment
.
CurrentDirectory
=
Application
.
StartupPath
;
_
=
new
Mutex
(
true
,
Application
.
ProductName
,
out
bool
ret
);
_
=
new
Mutex
(
true
,
Application
.
ProductName
,
out
bool
ret
);
if
(!
ret
)
if
(!
ret
)
{
{
IntPtr
formhwnd
=
FindWindow
(
null
,
"BarCode Rule Setting"
);
IntPtr
formhwnd
=
FindWindow
(
null
,
"BarCode Rule Setting"
);
if
(
formhwnd
==
IntPtr
.
Zero
)
if
(
formhwnd
==
IntPtr
.
Zero
)
formhwnd
=
FindWindow
(
null
,
"条码规则设置"
);
formhwnd
=
FindWindow
(
null
,
"条码规则设置"
);
LogNet
.
log
.
Info
(
$
"查找条码规则窗口句柄:{formhwnd}"
);
if
(
formhwnd
!=
IntPtr
.
Zero
)
{
ShowWindow
(
formhwnd
,
SW_RESTORE
);
SwitchToThisWindow
(
formhwnd
,
true
);
}
else
{
Process
currentproc
=
Process
.
GetCurrentProcess
();
Process
[]
processcollection
=
Process
.
GetProcessesByName
(
Application
.
ProductName
);
// 该程序已经运行,
if
(
processcollection
.
Length
>=
1
)
{
foreach
(
Process
process
in
processcollection
)
{
if
(
process
.
Id
!=
currentproc
.
Id
)
{
// 如果进程的句柄为0,即代表没有找到该窗体,即该窗体隐藏的情况时
if
(
process
.
MainWindowHandle
.
ToInt32
().
Equals
(
0
))
{
string
formTitle
=
"物料注册系统"
;
// 获得窗体句柄
formhwnd
=
FindWindow
(
null
,
formTitle
);
if
(
formhwnd
!=
IntPtr
.
Zero
)
{
// 重新显示该窗体并切换到带入到前台
ShowWindow
(
formhwnd
,
SW_RESTORE
);
SwitchToThisWindow
(
formhwnd
,
true
);
}
else
{
formTitle
=
"Material Registration System"
;
formhwnd
=
FindWindow
(
null
,
formTitle
);
// 重新显示该窗体并切换到带入到前台
ShowWindow
(
formhwnd
,
SW_RESTORE
);
ShowWindow
(
formhwnd
,
SW_RESTORE
);
SwitchToThisWindow
(
formhwnd
,
true
);
SwitchToThisWindow
(
formhwnd
,
true
);
//MessageBox.Show("该程序已经启动", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
LogNet
.
log
.
Info
(
$
"窗体隐藏,查找软件窗口句柄:{formhwnd}"
);
isShow
=
true
;
break
;
}
else
{
// 如果窗体没有隐藏,就直接切换到该窗体并带入到前台
// 因为窗体除了隐藏到托盘,还可以最小化
SwitchToThisWindow
(
process
.
MainWindowHandle
,
true
);
LogNet
.
log
.
Info
(
$
"窗体没有隐藏,查找软件窗口句柄:{formhwnd}"
);
isShow
=
true
;
break
;
}
}
}
}
}
return
;
return
;
}
}
if
(!
isShow
)
Application
.
SetUnhandledExceptionMode
(
UnhandledExceptionMode
.
CatchException
);
{
Application
.
ThreadException
+=
Application_ThreadException
;
AppDomain
.
CurrentDomain
.
UnhandledException
+=
CurrentDomain_UnhandledException
;
Application
.
EnableVisualStyles
();
Application
.
EnableVisualStyles
();
Application
.
SetCompatibleTextRenderingDefault
(
false
);
Application
.
SetCompatibleTextRenderingDefault
(
false
);
//BLL.Config.Backgrounder = true;
//BLL.Config.Backgrounder = true;
...
@@ -79,6 +133,7 @@ namespace SmartScan
...
@@ -79,6 +133,7 @@ namespace SmartScan
}
}
else
else
Application
.
Run
(
Common
.
frmMain
);
Application
.
Run
(
Common
.
frmMain
);
}
Exit
();
Exit
();
}
}
...
...
SmartScan/WebCallWork.cs
查看文件 @
b5f3451
...
@@ -64,8 +64,7 @@ namespace SmartScan
...
@@ -64,8 +64,7 @@ namespace SmartScan
if
(
workCodeInfo
.
Count
==
0
)
if
(
workCodeInfo
.
Count
==
0
)
return
new
WebResultCode
()
{
ErrorCode
=
-
1
,
Msg
=
"扫码失败"
};
return
new
WebResultCode
()
{
ErrorCode
=
-
1
,
Msg
=
"扫码失败"
};
Common
.
mateEdit
.
CurrntBitmap
=
bitmap
;
bool
rtn
=
Common
.
mateEdit
.
MatchingTemplate
(
workCodeInfo
,
Common
.
config
.
DefaultMaterialName
,
false
,
out
string
mateName
,
out
workCodeKeyword
,
out
originalCodeIsUsed
);
bool
rtn
=
Common
.
mateEdit
.
MatchingTemplate
(
workCodeInfo
,
Common
.
config
.
DefaultMaterialName
,
false
,
out
string
mateName
,
out
workCodeKeyword
,
out
originalCodeIsUsed
);
LogNet
.
log
.
Info
(
"Work SetKey hasMatch:"
+
rtn
);
LogNet
.
log
.
Info
(
"Work SetKey hasMatch:"
+
rtn
);
...
@@ -82,15 +81,16 @@ namespace SmartScan
...
@@ -82,15 +81,16 @@ namespace SmartScan
LogNet
.
log
.
Info
(
"Work scan is done"
);
LogNet
.
log
.
Info
(
"Work scan is done"
);
List
<
KeyValuePair
<
string
,
string
>>
result
=
new
List
<
KeyValuePair
<
string
,
string
>>();
List
<
KeyValuePair
<
string
,
string
>>
result
=
new
List
<
KeyValuePair
<
string
,
string
>>();
foreach
(
var
wc
in
workCodeKeyword
)
{
foreach
(
var
wc
in
workCodeKeyword
)
result
.
Add
(
new
KeyValuePair
<
string
,
string
>(
wc
.
Key
,
wc
.
Value
));
{
result
.
Add
(
new
KeyValuePair
<
string
,
string
>(
wc
.
Key
,
wc
.
Value
));
}
}
return
new
WebResultCode
()
{
workCodeKeyword
=
result
,
workCodeInfo
=
workCodeInfo
};
return
new
WebResultCode
()
{
workCodeKeyword
=
result
,
workCodeInfo
=
workCodeInfo
};
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
LogNet
.
log
.
Error
(
"ProcessBitmap"
,
ex
);
LogNet
.
log
.
Error
(
"ProcessBitmap"
,
ex
);
return
new
WebResultCode
()
{
ErrorCode
=
-
1
,
Msg
=
"扫码失败:"
+
ex
};
return
new
WebResultCode
()
{
ErrorCode
=
-
1
,
Msg
=
"扫码失败:"
+
ex
};
}
}
}
}
}
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论