Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
WinPak_API
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
son nguyen
WinPak_API
Commits
a94db97c
Commit
a94db97c
authored
Jan 08, 2025
by
son nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update form request
parent
0b0dd3f3
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
136 additions
and
47 deletions
+136
-47
ApiController.cs
...SharpClient/WPCommSharpClient/Controller/ApiController.cs
+16
-26
FormLockRequest.cs
...pClient/WPCommSharpClient/FormRequests/FormLockRequest.cs
+13
-0
FormLoginRequest.cs
...Client/WPCommSharpClient/FormRequests/FormLoginRequest.cs
+15
-0
LoggingConfig.cs
...ommSharpClient/WPCommSharpClient/Helpers/LoggingConfig.cs
+0
-0
ResponseResult.cs
...mmSharpClient/WPCommSharpClient/Helpers/ResponseResult.cs
+0
-0
Program.cs
...Server API/WPCommSharpClient/WPCommSharpClient/Program.cs
+1
-9
app.manifest
...CommSharpClient/WPCommSharpClient/Properties/app.manifest
+73
-0
WPCallbackClient.cs
...I/WPCommSharpClient/WPCommSharpClient/WPCallbackClient.cs
+0
-4
WPCommSharpClient.csproj
...ommSharpClient/WPCommSharpClient/WPCommSharpClient.csproj
+17
-7
appsettings.json
... API/WPCommSharpClient/WPCommSharpClient/appsettings.json
+1
-1
No files found.
API Samples/WIN-PAK Comm Server API/WPCommSharpClient/WPCommSharpClient/Controller/ApiController.cs
View file @
a94db97c
...
@@ -8,6 +8,7 @@ using System;
...
@@ -8,6 +8,7 @@ using System;
using
System.Reflection
;
using
System.Reflection
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
System.Web.Http
;
using
System.Web.Http
;
using
WPCommSharpClient.FormRequests
;
namespace
WPCommSharpClient
namespace
WPCommSharpClient
{
{
...
@@ -24,7 +25,7 @@ namespace WPCommSharpClient
...
@@ -24,7 +25,7 @@ namespace WPCommSharpClient
[
HttpPost
]
[
HttpPost
]
[
Route
(
"api/login"
)]
[
Route
(
"api/login"
)]
public
async
Task
<
IHttpActionResult
>
Login
([
FromBody
]
LoginRequest
loginRequest
)
public
async
Task
<
IHttpActionResult
>
Login
([
FromBody
]
Form
LoginRequest
loginRequest
)
{
{
Log
.
Debug
(
"Calling login...."
);
Log
.
Debug
(
"Calling login...."
);
if
(
loginRequest
==
null
)
if
(
loginRequest
==
null
)
...
@@ -87,6 +88,7 @@ namespace WPCommSharpClient
...
@@ -87,6 +88,7 @@ namespace WPCommSharpClient
[
Route
(
"api/unLock"
)]
[
Route
(
"api/unLock"
)]
public
async
Task
<
IHttpActionResult
>
EntryUnLockById
([
FromBody
]
FormLockRequest
formLockRequest
)
public
async
Task
<
IHttpActionResult
>
EntryUnLockById
([
FromBody
]
FormLockRequest
formLockRequest
)
{
{
DateTime
startCallAPI
=
DateTime
.
Now
;
Log
.
Debug
(
"Calling unlock ...."
);
Log
.
Debug
(
"Calling unlock ...."
);
// Đọc cấu hình từ appsettings.json // 1 thu vien doc file json
// Đọc cấu hình từ appsettings.json // 1 thu vien doc file json
...
@@ -98,13 +100,19 @@ namespace WPCommSharpClient
...
@@ -98,13 +100,19 @@ namespace WPCommSharpClient
var
login
=
configuration
.
GetSection
(
"login"
);
var
login
=
configuration
.
GetSection
(
"login"
);
string
username
=
login
[
"username"
];
string
username
=
login
[
"username"
];
string
password
=
login
[
"password"
];
string
password
=
login
[
"password"
];
Log
.
Debug
(
"Username: "
,
username
);
Log
.
Debug
(
"Username: "
+
username
);
Log
.
Debug
(
"Password: "
,
password
);
Log
.
Debug
(
"Password: "
+
password
);
if
(
string
.
IsNullOrEmpty
(
username
)
||
string
.
IsNullOrEmpty
(
password
))
if
(
string
.
IsNullOrEmpty
(
username
)
||
string
.
IsNullOrEmpty
(
password
))
{
{
Log
.
Error
(
"Not found username or password!"
);
Log
.
Error
(
"Not found username or password!"
);
return
Json
(
ResponseResult
<
Object
>.
ErrorResult
(
"Not found username or password!"
));
return
Json
(
ResponseResult
<
Object
>.
ErrorResult
(
"Not found username or password!"
));
}
}
// goị tới login của server
// _client: mặc định với _client là đối tượng có sẵn
// 3 : tức nhận cả Alarm và Event( 1: Alarm, 2: Event )
// username
// password
// 1: id của user đăng nhâp(ở đây đăng nhập với user mặc định ban đầu của winPak là 1)
bool
isConnected
=
_server
.
InitServer
(
_client
,
3
,
username
,
password
,
1
);
bool
isConnected
=
_server
.
InitServer
(
_client
,
3
,
username
,
password
,
1
);
if
(
isConnected
)
if
(
isConnected
)
{
{
...
@@ -116,8 +124,11 @@ namespace WPCommSharpClient
...
@@ -116,8 +124,11 @@ namespace WPCommSharpClient
try
try
{
{
// Hàm nhận vào 1 giá trị là Hardware ID
_server
.
EntryPointUnLockByHID
(
formLockRequest
.
HID
.
Value
);
_server
.
EntryPointUnLockByHID
(
formLockRequest
.
HID
.
Value
);
Log
.
Debug
(
"UnLock successful for HID={HID}"
,
formLockRequest
.
HID
);
Log
.
Debug
(
"UnLock successful for HID={HID}"
,
formLockRequest
.
HID
);
TimeSpan
totalTime
=
(
DateTime
.
Now
-
startCallAPI
);
Log
.
Debug
(
$"Total time:
{
totalTime
.
TotalMilliseconds
}
ms"
);
return
Json
(
ResponseResult
<
String
>.
SuccessResult
(
null
,
"UnLock successful."
));
return
Json
(
ResponseResult
<
String
>.
SuccessResult
(
null
,
"UnLock successful."
));
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
...
@@ -159,26 +170,5 @@ namespace WPCommSharpClient
...
@@ -159,26 +170,5 @@ namespace WPCommSharpClient
return
Json
(
ResponseResult
<
object
>.
ErrorResult
(
"An error occurred while checking the server status."
));
return
Json
(
ResponseResult
<
object
>.
ErrorResult
(
"An error occurred while checking the server status."
));
}
}
}
}
}
public
class
InfoDeviceView
{
}
public
class
LoginRequest
{
public
string
UserName
{
get
;
set
;
}
public
string
Password
{
get
;
set
;
}
public
string
Domain
{
get
;
set
;
}
}
public
class
FormLockRequest
{
public
int
?
HID
{
get
;
set
;
}
}
}
}
}
API Samples/WIN-PAK Comm Server API/WPCommSharpClient/WPCommSharpClient/FormRequests/FormLockRequest.cs
0 → 100644
View file @
a94db97c
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
WPCommSharpClient.FormRequests
{
public
class
FormLockRequest
{
public
int
?
HID
{
get
;
set
;
}
}
}
API Samples/WIN-PAK Comm Server API/WPCommSharpClient/WPCommSharpClient/FormRequests/FormLoginRequest.cs
0 → 100644
View file @
a94db97c
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
WPCommSharpClient.FormRequests
{
public
class
FormLoginRequest
{
public
string
UserName
{
get
;
set
;
}
public
string
Password
{
get
;
set
;
}
public
string
Domain
{
get
;
set
;
}
}
}
API Samples/WIN-PAK Comm Server API/WPCommSharpClient/WPCommSharpClient/LoggingConfig.cs
→
API Samples/WIN-PAK Comm Server API/WPCommSharpClient/WPCommSharpClient/
Helpers/
LoggingConfig.cs
View file @
a94db97c
File moved
API Samples/WIN-PAK Comm Server API/WPCommSharpClient/WPCommSharpClient/ResponseResult.cs
→
API Samples/WIN-PAK Comm Server API/WPCommSharpClient/WPCommSharpClient/
Helpers/
ResponseResult.cs
View file @
a94db97c
File moved
API Samples/WIN-PAK Comm Server API/WPCommSharpClient/WPCommSharpClient/Program.cs
View file @
a94db97c
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
using
System.Windows.Forms
;
using
static
System
.
Windows
.
Forms
.
VisualStyles
.
VisualStyleElement
;
using
Microsoft.Extensions.Configuration
;
using
System
;
using
System.Windows.Forms
;
using
System.Web.Http
;
using
Microsoft.Owin.Hosting
;
using
Microsoft.Owin.Hosting
;
using
Serilog
;
using
Serilog
;
using
Microsoft.Extensions.Configuration
;
namespace
WPCommSharpClient
namespace
WPCommSharpClient
{
{
static
class
Program
static
class
Program
...
...
API Samples/WIN-PAK Comm Server API/WPCommSharpClient/WPCommSharpClient/Properties/app.manifest
0 → 100644
View file @
a94db97c
<?xml version="1.0" encoding="utf-8"?>
<assembly
manifestVersion=
"1.0"
xmlns=
"urn:schemas-microsoft-com:asm.v1"
>
<assemblyIdentity
version=
"1.0.0.0"
name=
"MyApplication.app"
/>
<trustInfo
xmlns=
"urn:schemas-microsoft-com:asm.v2"
>
<security>
<requestedPrivileges
xmlns=
"urn:schemas-microsoft-com:asm.v3"
>
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel
level=
"asInvoker"
uiAccess=
"false"
/>
</requestedPrivileges>
<applicationRequestMinimum>
<defaultAssemblyRequest
permissionSetReference=
"Custom"
/>
<PermissionSet
class=
"System.Security.PermissionSet"
version=
"1"
Unrestricted=
"true"
ID=
"Custom"
SameSite=
"site"
/>
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility
xmlns=
"urn:schemas-microsoft-com:compatibility.v1"
>
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
</application>
</compatibility>
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config.
Makes the application long-path aware. See https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
-->
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>
\ No newline at end of file
API Samples/WIN-PAK Comm Server API/WPCommSharpClient/WPCommSharpClient/WPCallbackClient.cs
View file @
a94db97c
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
using
Accw
;
using
Accw
;
using
System.Threading
;
namespace
WPCommSharpClient
namespace
WPCommSharpClient
{
{
...
...
API Samples/WIN-PAK Comm Server API/WPCommSharpClient/WPCommSharpClient/WPCommSharpClient.csproj
View file @
a94db97c
...
@@ -11,6 +11,8 @@
...
@@ -11,6 +11,8 @@
<AssemblyName>
WPCommSharpClient
</AssemblyName>
<AssemblyName>
WPCommSharpClient
</AssemblyName>
<TargetFrameworkVersion>
v4.8
</TargetFrameworkVersion>
<TargetFrameworkVersion>
v4.8
</TargetFrameworkVersion>
<FileAlignment>
512
</FileAlignment>
<FileAlignment>
512
</FileAlignment>
<IsWebBootstrapper>
false
</IsWebBootstrapper>
<TargetFrameworkProfile
/>
<PublishUrl>
publish\
</PublishUrl>
<PublishUrl>
publish\
</PublishUrl>
<Install>
true
</Install>
<Install>
true
</Install>
<InstallFrom>
Disk
</InstallFrom>
<InstallFrom>
Disk
</InstallFrom>
...
@@ -23,10 +25,8 @@
...
@@ -23,10 +25,8 @@
<MapFileExtensions>
true
</MapFileExtensions>
<MapFileExtensions>
true
</MapFileExtensions>
<ApplicationRevision>
0
</ApplicationRevision>
<ApplicationRevision>
0
</ApplicationRevision>
<ApplicationVersion>
1.0.0.%2a
</ApplicationVersion>
<ApplicationVersion>
1.0.0.%2a
</ApplicationVersion>
<IsWebBootstrapper>
false
</IsWebBootstrapper>
<UseApplicationTrust>
false
</UseApplicationTrust>
<UseApplicationTrust>
false
</UseApplicationTrust>
<BootstrapperEnabled>
true
</BootstrapperEnabled>
<BootstrapperEnabled>
true
</BootstrapperEnabled>
<TargetFrameworkProfile
/>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "
>
<PropertyGroup
Condition=
" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "
>
<PlatformTarget>
AnyCPU
</PlatformTarget>
<PlatformTarget>
AnyCPU
</PlatformTarget>
...
@@ -48,6 +48,15 @@
...
@@ -48,6 +48,15 @@
<ErrorReport>
prompt
</ErrorReport>
<ErrorReport>
prompt
</ErrorReport>
<WarningLevel>
4
</WarningLevel>
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup>
<TargetZone>
LocalIntranet
</TargetZone>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>
false
</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>
Properties\app.manifest
</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<Reference
Include=
"Microsoft.Bcl.AsyncInterfaces, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"
>
<Reference
Include=
"Microsoft.Bcl.AsyncInterfaces, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"
>
<HintPath>
..\packages\Microsoft.Bcl.AsyncInterfaces.9.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll
</HintPath>
<HintPath>
..\packages\Microsoft.Bcl.AsyncInterfaces.9.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll
</HintPath>
...
@@ -170,7 +179,9 @@
...
@@ -170,7 +179,9 @@
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile
Include=
"Controller\ApiController.cs"
/>
<Compile
Include=
"Controller\ApiController.cs"
/>
<Compile
Include=
"LoggingConfig.cs"
/>
<Compile
Include=
"FormRequests\FormLockRequest.cs"
/>
<Compile
Include=
"FormRequests\FormLoginRequest.cs"
/>
<Compile
Include=
"Helpers\LoggingConfig.cs"
/>
<Compile
Include=
"MainView.cs"
>
<Compile
Include=
"MainView.cs"
>
<SubType>
Form
</SubType>
<SubType>
Form
</SubType>
</Compile>
</Compile>
...
@@ -179,7 +190,7 @@
...
@@ -179,7 +190,7 @@
</Compile>
</Compile>
<Compile
Include=
"Program.cs"
/>
<Compile
Include=
"Program.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"ResponseResult.cs"
/>
<Compile
Include=
"
Helpers\
ResponseResult.cs"
/>
<Compile
Include=
"Startup.cs"
/>
<Compile
Include=
"Startup.cs"
/>
<Compile
Include=
"WPCallbackClient.cs"
/>
<Compile
Include=
"WPCallbackClient.cs"
/>
<EmbeddedResource
Include=
"MainView.resx"
>
<EmbeddedResource
Include=
"MainView.resx"
>
...
@@ -199,6 +210,7 @@
...
@@ -199,6 +210,7 @@
<CopyToOutputDirectory>
Always
</CopyToOutputDirectory>
<CopyToOutputDirectory>
Always
</CopyToOutputDirectory>
</None>
</None>
<None
Include=
"packages.config"
/>
<None
Include=
"packages.config"
/>
<None
Include=
"Properties\app.manifest"
/>
<None
Include=
"Properties\Settings.settings"
>
<None
Include=
"Properties\Settings.settings"
>
<Generator>
SettingsSingleFileGenerator
</Generator>
<Generator>
SettingsSingleFileGenerator
</Generator>
<LastGenOutput>
Settings.Designer.cs
</LastGenOutput>
<LastGenOutput>
Settings.Designer.cs
</LastGenOutput>
...
@@ -240,9 +252,7 @@
...
@@ -240,9 +252,7 @@
<Install>
false
</Install>
<Install>
false
</Install>
</BootstrapperPackage>
</BootstrapperPackage>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup
/>
<Folder
Include=
"Logs\"
/>
</ItemGroup>
<Import
Project=
"$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
<Import
Project=
"$(MSBuildToolsPath)\Microsoft.CSharp.targets"
/>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Other similar extension points exist, see Microsoft.Common.targets.
...
...
API Samples/WIN-PAK Comm Server API/WPCommSharpClient/WPCommSharpClient/appsettings.json
View file @
a94db97c
{
{
"BaseAddress"
:
"http://192.168.1.
25
:4000/"
,
"BaseAddress"
:
"http://192.168.1.
48
:4000/"
,
"Logging"
:
{
"Logging"
:
{
...
...
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