Commit a94db97c authored by son nguyen's avatar son nguyen

update form request

parent 0b0dd3f3
......@@ -8,6 +8,7 @@ using System;
using System.Reflection;
using System.Threading.Tasks;
using System.Web.Http;
using WPCommSharpClient.FormRequests;
namespace WPCommSharpClient
{
......@@ -24,7 +25,7 @@ namespace WPCommSharpClient
[HttpPost]
[Route("api/login")]
public async Task<IHttpActionResult> Login([FromBody] LoginRequest loginRequest)
public async Task<IHttpActionResult> Login([FromBody] FormLoginRequest loginRequest)
{
Log.Debug("Calling login....");
if (loginRequest == null)
......@@ -87,6 +88,7 @@ namespace WPCommSharpClient
[Route("api/unLock")]
public async Task<IHttpActionResult> EntryUnLockById([FromBody] FormLockRequest formLockRequest)
{
DateTime startCallAPI = DateTime.Now;
Log.Debug("Calling unlock ....");
// Đọc cấu hình từ appsettings.json // 1 thu vien doc file json
......@@ -98,13 +100,19 @@ namespace WPCommSharpClient
var login = configuration.GetSection("login");
string username = login["username"];
string password = login["password"];
Log.Debug("Username: ", username);
Log.Debug("Password: ", password);
Log.Debug("Username: " + username);
Log.Debug("Password: " + password);
if(string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
{
Log.Error("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);
if(isConnected)
{
......@@ -115,9 +123,12 @@ namespace WPCommSharpClient
}
try
{
_server.EntryPointUnLockByHID(formLockRequest.HID.Value);
{
// Hàm nhận vào 1 giá trị là Hardware ID
_server.EntryPointUnLockByHID(formLockRequest.HID.Value);
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."));
}
catch (Exception ex)
......@@ -159,26 +170,5 @@ namespace WPCommSharpClient
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; }
}
}
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; }
}
}
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; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using System;
using System.Windows.Forms;
using System.Web.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Owin.Hosting;
using Serilog;
using Microsoft.Extensions.Configuration;
namespace WPCommSharpClient
{
static class Program
......
<?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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using Accw;
using System.Threading;
namespace WPCommSharpClient
{
......
......@@ -11,6 +11,8 @@
<AssemblyName>WPCommSharpClient</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
......@@ -23,10 +25,8 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
......@@ -48,6 +48,15 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>false</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<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>
......@@ -170,7 +179,9 @@
</ItemGroup>
<ItemGroup>
<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">
<SubType>Form</SubType>
</Compile>
......@@ -179,7 +190,7 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ResponseResult.cs" />
<Compile Include="Helpers\ResponseResult.cs" />
<Compile Include="Startup.cs" />
<Compile Include="WPCallbackClient.cs" />
<EmbeddedResource Include="MainView.resx">
......@@ -199,6 +210,7 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
<None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
......@@ -240,9 +252,7 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Folder Include="Logs\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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.
......
{
"BaseAddress": "http://192.168.1.25:4000/",
"BaseAddress": "http://192.168.1.48:4000/",
"Logging": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment