diff --git a/ThaiNationalIDCard.NET.Example.ConsoleApp/Program.cs b/ThaiNationalIDCard.NET.Example.ConsoleApp/Program.cs index 23bc7ea..d561877 100644 --- a/ThaiNationalIDCard.NET.Example.ConsoleApp/Program.cs +++ b/ThaiNationalIDCard.NET.Example.ConsoleApp/Program.cs @@ -15,6 +15,7 @@ static void Main(string[] args) Console.WriteLine($"CitizenID: {personalPhoto.CitizenID}"); Console.WriteLine($"ThaiPersonalInfo: {personalPhoto.ThaiPersonalInfo}"); Console.WriteLine($"EnglishPersonalInfo: {personalPhoto.EnglishPersonalInfo}"); + Console.WriteLine($"DateOfBirth: {personalPhoto.DateOfBirth}"); Console.WriteLine($"Sex: {personalPhoto.Sex}"); Console.WriteLine($"AddressInfo: {personalPhoto.AddressInfo}"); Console.WriteLine($"IssueDate: {personalPhoto.IssueDate}"); diff --git a/ThaiNationalIDCard.NET.Example.WebApi/Controllers/ReadersController.cs b/ThaiNationalIDCard.NET.Example.WebApi/Controllers/ReadersController.cs deleted file mode 100644 index 921814b..0000000 --- a/ThaiNationalIDCard.NET.Example.WebApi/Controllers/ReadersController.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using System; -using ThaiNationalIDCard.NET.Models; - -namespace ThaiNationalIDCard.NET.Example.WebApi.Controllers -{ - [Route("api/[controller]")] - [ApiController] - public class ReadersController : ControllerBase - { - private readonly ThaiNationalIDCardReader cardReader; - - public ReadersController(ThaiNationalIDCardReader cardReader) - { - this.cardReader = cardReader; - } - - [HttpGet("Read")] - [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(PersonalPhoto))] - [ProducesResponseType(StatusCodes.Status400BadRequest)] - public IActionResult Read() - { - try - { - PersonalPhoto personalPhoto = cardReader.GetPersonalPhoto(); - - return Ok(personalPhoto); - } - catch (Exception e) - { - return BadRequest(e); - } - } - } -} \ No newline at end of file diff --git a/ThaiNationalIDCard.NET.Example.WebApi/Program.cs b/ThaiNationalIDCard.NET.Example.WebApi/Program.cs deleted file mode 100644 index b491573..0000000 --- a/ThaiNationalIDCard.NET.Example.WebApi/Program.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; - -namespace ThaiNationalIDCard.NET.Example.WebApi -{ - public class Program - { - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }); - } -} diff --git a/ThaiNationalIDCard.NET.Example.WebApi/Properties/launchSettings.json b/ThaiNationalIDCard.NET.Example.WebApi/Properties/launchSettings.json deleted file mode 100644 index 080bb32..0000000 --- a/ThaiNationalIDCard.NET.Example.WebApi/Properties/launchSettings.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:55527", - "sslPort": 0 - } - }, - "$schema": "http://json.schemastore.org/launchsettings.json", - "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "api/readers/read", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "ThaiNationalIDCard.Example.WebApi": { - "commandName": "Project", - "launchBrowser": true, - "launchUrl": "weatherforecast", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "http://localhost:5000" - } - } -} \ No newline at end of file diff --git a/ThaiNationalIDCard.NET.Example.WebApi/Startup.cs b/ThaiNationalIDCard.NET.Example.WebApi/Startup.cs deleted file mode 100644 index d8e1c7b..0000000 --- a/ThaiNationalIDCard.NET.Example.WebApi/Startup.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; - -namespace ThaiNationalIDCard.NET.Example.WebApi -{ - public class Startup - { - public IConfiguration Configuration { get; } - - public Startup(IConfiguration configuration) - { - Configuration = configuration; - } - - public void ConfigureServices(IServiceCollection services) - { - services.AddControllers(); - - services.AddScoped(); - } - - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - - app.UseRouting(); - - app.UseAuthorization(); - - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); - } - } -} diff --git a/ThaiNationalIDCard.NET.Example.WebApi/ThaiNationalIDCard.NET.Example.WebApi.csproj b/ThaiNationalIDCard.NET.Example.WebApi/ThaiNationalIDCard.NET.Example.WebApi.csproj deleted file mode 100644 index 3a1e758..0000000 --- a/ThaiNationalIDCard.NET.Example.WebApi/ThaiNationalIDCard.NET.Example.WebApi.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - netcoreapp3.1 - Pichid Detson - - - - - - - - - - - - - diff --git a/ThaiNationalIDCard.NET.Example.WebApi/appsettings.Development.json b/ThaiNationalIDCard.NET.Example.WebApi/appsettings.Development.json deleted file mode 100644 index 8983e0f..0000000 --- a/ThaiNationalIDCard.NET.Example.WebApi/appsettings.Development.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - } -} diff --git a/ThaiNationalIDCard.NET.Example.WebApi/appsettings.json b/ThaiNationalIDCard.NET.Example.WebApi/appsettings.json deleted file mode 100644 index d9d9a9b..0000000 --- a/ThaiNationalIDCard.NET.Example.WebApi/appsettings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" - } - }, - "AllowedHosts": "*" -} diff --git a/ThaiNationalIDCard.NET/Models/Personal.cs b/ThaiNationalIDCard.NET/Models/Personal.cs index e037996..0920b44 100644 --- a/ThaiNationalIDCard.NET/Models/Personal.cs +++ b/ThaiNationalIDCard.NET/Models/Personal.cs @@ -7,6 +7,7 @@ public class Personal public string CitizenID { get; set; } public PersonalInfo ThaiPersonalInfo { get; set; } public PersonalInfo EnglishPersonalInfo { get; set; } + public DateTime DateOfBirth { get; set; } public string Sex { get; set; } public AddressInfo AddressInfo { get; set; } public DateTime IssueDate { get; set; } diff --git a/ThaiNationalIDCard.NET/Models/PersonalPhoto.cs b/ThaiNationalIDCard.NET/Models/PersonalPhoto.cs index 5cac0bc..60e8b3c 100644 --- a/ThaiNationalIDCard.NET/Models/PersonalPhoto.cs +++ b/ThaiNationalIDCard.NET/Models/PersonalPhoto.cs @@ -9,6 +9,7 @@ public PersonalPhoto(Personal personal) CitizenID = personal.CitizenID; ThaiPersonalInfo = personal.ThaiPersonalInfo; EnglishPersonalInfo = personal.EnglishPersonalInfo; + DateOfBirth = personal.DateOfBirth; Sex = personal.Sex; AddressInfo = personal.AddressInfo; IssueDate = personal.IssueDate; diff --git a/ThaiNationalIDCard.NET/ThaiNationalIDCard.NET.csproj b/ThaiNationalIDCard.NET/ThaiNationalIDCard.NET.csproj index ec03455..3cc9298 100644 --- a/ThaiNationalIDCard.NET/ThaiNationalIDCard.NET.csproj +++ b/ThaiNationalIDCard.NET/ThaiNationalIDCard.NET.csproj @@ -10,6 +10,7 @@ https://github.com/bencomtech/ThaiNationalIDCard.NET https://github.com/bencomtech/ThaiNationalIDCard.NET + 1.0.0 diff --git a/ThaiNationalIDCard.NET/ThaiNationalIDCardReader.cs b/ThaiNationalIDCard.NET/ThaiNationalIDCardReader.cs index add5cee..0e53560 100644 --- a/ThaiNationalIDCard.NET/ThaiNationalIDCardReader.cs +++ b/ThaiNationalIDCard.NET/ThaiNationalIDCardReader.cs @@ -100,6 +100,13 @@ private Personal GetPersonalInfo() personal.ThaiPersonalInfo = new PersonalInfo(thaiPersonalInfo); personal.EnglishPersonalInfo = new PersonalInfo(englishPersonalInfo); + + string dateOfBirth = personalInfo.Substring(200, 8); + personal.DateOfBirth = new DateTime(Convert.ToInt32(dateOfBirth.Substring(0, 4)) - 543 + , Convert.ToInt32(dateOfBirth.Substring(4, 2)) + , Convert.ToInt32(dateOfBirth.Substring(6, 2)) + ); + personal.Sex = personalInfo.Substring(208, 1); string addressInfo = GetUTF8FromAsciiBytes(SendCommand(apdu.AddressInfoCommand));