Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
G
GS.Terminal.VisitorSelfService
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
终端组
GS.Terminal.VisitorSelfService
Commits
65fba3a4
Commit
65fba3a4
authored
May 14, 2021
by
姜春辉
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加终端注册
parent
ed89aaf3
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
1 deletion
+54
-1
GS.Terminal.VisitorSelfService.csproj
....VisitorSelfService/GS.Terminal.VisitorSelfService.csproj
+3
-0
packages.config
...elfService/GS.Terminal.VisitorSelfService/packages.config
+1
-0
GS.Terminal.VisitorSelfService.Logic.csproj
...Service.Logic/GS.Terminal.VisitorSelfService.Logic.csproj
+3
-0
Program.cs
...ice/Logic/GS.Terminal.VisitorSelfService.Logic/Program.cs
+9
-1
WebApi.cs
...gic/GS.Terminal.VisitorSelfService.Logic/Remote/WebApi.cs
+37
-0
packages.config
...ogic/GS.Terminal.VisitorSelfService.Logic/packages.config
+1
-0
No files found.
Src/GS.Terminal.VisitorSelfService/GS.Terminal.VisitorSelfService/GS.Terminal.VisitorSelfService.csproj
View file @
65fba3a4
...
...
@@ -90,6 +90,9 @@
<Reference
Include=
"System.Data.SQLite, Version=1.0.112.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL"
>
<HintPath>
..\packages\System.Data.SQLite.Core.1.0.112.0\lib\net451\System.Data.SQLite.dll
</HintPath>
</Reference>
<Reference
Include=
"System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"
>
<HintPath>
..\packages\System.ValueTuple.4.5.0\lib\netstandard1.0\System.ValueTuple.dll
</HintPath>
</Reference>
<Reference
Include=
"System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
>
<HintPath>
..\packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll
</HintPath>
</Reference>
...
...
Src/GS.Terminal.VisitorSelfService/GS.Terminal.VisitorSelfService/packages.config
View file @
65fba3a4
...
...
@@ -9,4 +9,5 @@
<
package
id
=
"Newtonsoft.Json"
version
=
"10.0.2"
targetFramework
=
"net452"
/>
<
package
id
=
"OpenCvSharp3-AnyCPU"
version
=
"4.0.0.20181129"
targetFramework
=
"net452"
/>
<
package
id
=
"System.Data.SQLite.Core"
version
=
"1.0.112.0"
targetFramework
=
"net452"
/>
<
package
id
=
"System.ValueTuple"
version
=
"4.5.0"
targetFramework
=
"net452"
/>
</
packages
>
\ No newline at end of file
Src/GS.Terminal.VisitorSelfService/Logic/GS.Terminal.VisitorSelfService.Logic/GS.Terminal.VisitorSelfService.Logic.csproj
View file @
65fba3a4
...
...
@@ -92,6 +92,9 @@
<Reference
Include=
"System"
/>
<Reference
Include=
"System.Core"
/>
<Reference
Include=
"System.Drawing"
/>
<Reference
Include=
"System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"
>
<HintPath>
..\..\packages\System.ValueTuple.4.5.0\lib\netstandard1.0\System.ValueTuple.dll
</HintPath>
</Reference>
<Reference
Include=
"System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"
>
<HintPath>
..\..\packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll
</HintPath>
</Reference>
...
...
Src/GS.Terminal.VisitorSelfService/Logic/GS.Terminal.VisitorSelfService.Logic/Program.cs
View file @
65fba3a4
using
GS.Terminal.VisitorSelfService.Logic.ThirdAddon
;
using
GS.Terminal.VisitorSelfService.Logic.Remote
;
using
GS.Terminal.VisitorSelfService.Logic.ThirdAddon
;
using
GS.Unitive.Framework.Core
;
using
GS.Unitive.Framework.Persistent
;
using
Microsoft.VisualBasic.ApplicationServices
;
...
...
@@ -44,6 +45,13 @@ namespace GS.Terminal.VisitorSelfService.Logic
_ObjectSpace
=
manager
.
CreateObjectSpace
(
_Context
,
"c1"
);
_ObjectSpace
.
UpdateDataSchema
();
Handlers
.
Product
();
var
signature
=
WebApi
.
Signature
();
if
(!
signature
.
success
)
{
var
ex
=
new
Exception
(
$"终端注册失败,失败原因:
{
signature
.
message
}
"
);
_Context
.
Logger
.
Error
(
"启动失败"
,
ex
);
throw
ex
;
}
TerminalConsole
.
StartHeart
(
LocalSetting
.
AppConfig
.
ServerIP
,
LocalSetting
.
AddonDefaultConfig
.
HeartPort
,
30
*
1000
);
ThirdAddon
.
LogicShell
.
ShowView
(
vmLocator
.
MenuPage
);
}
...
...
Src/GS.Terminal.VisitorSelfService/Logic/GS.Terminal.VisitorSelfService.Logic/Remote/WebApi.cs
View file @
65fba3a4
...
...
@@ -3,6 +3,7 @@ using System;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Net.Http
;
using
System.Net.NetworkInformation
;
using
System.Text
;
using
System.Threading.Tasks
;
...
...
@@ -11,6 +12,7 @@ namespace GS.Terminal.VisitorSelfService.Logic.Remote
public
static
class
WebApi
{
private
static
SafeObjectPool
.
ObjectPool
<
HttpClient
>
_httpclientPool
=
null
;
private
static
string
_token
=
""
;
static
WebApi
()
{
_httpclientPool
=
new
SafeObjectPool
.
ObjectPool
<
HttpClient
>(
10
,
()
=>
...
...
@@ -19,6 +21,8 @@ namespace GS.Terminal.VisitorSelfService.Logic.Remote
_client
.
BaseAddress
=
new
Uri
(
LocalSetting
.
AppConfig
.
WebPath
);
_client
.
Timeout
=
TimeSpan
.
FromSeconds
(
30
);
_client
.
DefaultRequestHeaders
.
UserAgent
.
Add
(
new
System
.
Net
.
Http
.
Headers
.
ProductInfoHeaderValue
(
"GS.Terminal.VisitorSelfService"
,
Program
.
_logicVersion
));
if
(!
string
.
IsNullOrEmpty
(
_token
))
_client
.
DefaultRequestHeaders
.
Add
(
"Authorization"
,
$"Bearer
{
_token
}
"
);
return
_client
;
});
}
...
...
@@ -116,5 +120,38 @@ namespace GS.Terminal.VisitorSelfService.Logic.Remote
}
return
default
(
T
);
}
public
static
string
GetMACAddress
()
{
NetworkInterface
[]
interfaces
=
NetworkInterface
.
GetAllNetworkInterfaces
();
NetworkInterface
current
=
interfaces
.
FirstOrDefault
(
ss
=>
ss
.
OperationalStatus
==
OperationalStatus
.
Up
);
if
(
current
==
null
)
//如果当前没有可用的就选第一个
current
=
interfaces
.
FirstOrDefault
();
return
BitConverter
.
ToString
(
current
.
GetPhysicalAddress
().
GetAddressBytes
());
}
/// <summary>
/// 设备签到
/// </summary>
/// <returns></returns>
public
static
(
bool
success
,
string
message
)
Signature
()
{
var
token
=
GetTAsync
<
TerminalToken
>(
$"/api/GS.WebApi.Terminal/TerminalConsole/Signature?tCode=
{
LocalSetting
.
AppConfig
.
tCode
}
&tMacCode=
{
GetMACAddress
()}
"
).
Result
;
if
(
token
==
null
)
return
(
false
,
"网络异常,设备注册失败"
);
if
(!
token
.
Status
)
return
(
false
,
$"设备注册失败.原因:
{
token
.
Message
}
"
);
_token
=
token
.
tToken
;
return
(
true
,
_token
);
}
}
public
class
TerminalToken
{
/// <summary>
/// 返回状态
/// </summary>
public
bool
Status
{
get
;
set
;
}
=
true
;
/// <summary>
/// 返回消息
/// </summary>
public
string
Message
{
get
;
set
;
}
public
string
tToken
{
get
;
set
;
}
public
DateTime
expDate
{
get
;
set
;
}
}
}
Src/GS.Terminal.VisitorSelfService/Logic/GS.Terminal.VisitorSelfService.Logic/packages.config
View file @
65fba3a4
...
...
@@ -9,5 +9,6 @@
<
package
id
=
"OpenCvSharp3-AnyCPU"
version
=
"4.0.0.20181129"
targetFramework
=
"net452"
/>
<
package
id
=
"SafeObjectPool"
version
=
"2.3.1"
targetFramework
=
"net452"
/>
<
package
id
=
"SuperSocket.ClientEngine.Core"
version
=
"0.10.0"
targetFramework
=
"net452"
/>
<
package
id
=
"System.ValueTuple"
version
=
"4.5.0"
targetFramework
=
"net452"
/>
<
package
id
=
"WebSocket4Net"
version
=
"0.15.2"
targetFramework
=
"net452"
/>
</
packages
>
\ No newline at end of file
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