From 5362e017d9880d741ea37b238bd66df17f297cbf Mon Sep 17 00:00:00 2001 From: "Danila.Kislitsyn" Date: Wed, 3 Mar 2021 15:18:45 +0300 Subject: [PATCH 1/5] inti classes --- Regula.DocumentReader.sln | 9 ++- .../Program.cs | 8 +++ .../Ext/Autheticity/AuthenticityResult.cs | 10 +++ .../Model/Ext/Autheticity/Autheticity.cs | 68 +++++++++++++++++++ .../Model/Ext/Autheticity/FiberChecks.cs | 10 +++ .../Model/Ext/Autheticity/IdentChecks.cs | 10 +++ .../Model/Ext/Autheticity/ImageIdentChecks.cs | 10 +++ .../Ext/Autheticity/OCRSecurityTextChecks.cs | 10 +++ .../Ext/Autheticity/SecurityFeatureChecks.cs | 10 +++ 9 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/AuthenticityResult.cs create mode 100644 src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/Autheticity.cs create mode 100644 src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/FiberChecks.cs create mode 100644 src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/IdentChecks.cs create mode 100644 src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/ImageIdentChecks.cs create mode 100644 src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/OCRSecurityTextChecks.cs create mode 100644 src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/SecurityFeatureChecks.cs diff --git a/Regula.DocumentReader.sln b/Regula.DocumentReader.sln index b6f9bcf..d4ed18f 100644 --- a/Regula.DocumentReader.sln +++ b/Regula.DocumentReader.sln @@ -2,8 +2,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30503.244 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Regula.DocumentReader.WebClient", "src\Regula.DocumentReader.WebClient\Regula.DocumentReader.WebClient.csproj", "{21FC9582-EA65-4043-ABF6-BD436E3CCD10}" -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Regula.DocumentReader.NetCoreExample", "src\Regula.DocumentReader.NetCoreExample\Regula.DocumentReader.NetCoreExample.csproj", "{21FC9582-EA65-4043-ABF6-BD436E3CCD10}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Regula.DocumentReader.WebClient", "src\Regula.DocumentReader.WebClient\Regula.DocumentReader.WebClient.csproj", "{21FC9582-EA65-4043-ABF6-BD436E3CCD10}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Regula.DocumentReader.NetCoreExample", "src\Regula.DocumentReader.NetCoreExample\Regula.DocumentReader.NetCoreExample.csproj", "{EA417402-2843-4CA5-B712-4CD9425C02E4}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -15,6 +16,10 @@ Global {21FC9582-EA65-4043-ABF6-BD436E3CCD10}.Debug|Any CPU.Build.0 = Debug|Any CPU {21FC9582-EA65-4043-ABF6-BD436E3CCD10}.Release|Any CPU.ActiveCfg = Release|Any CPU {21FC9582-EA65-4043-ABF6-BD436E3CCD10}.Release|Any CPU.Build.0 = Release|Any CPU + {EA417402-2843-4CA5-B712-4CD9425C02E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EA417402-2843-4CA5-B712-4CD9425C02E4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EA417402-2843-4CA5-B712-4CD9425C02E4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EA417402-2843-4CA5-B712-4CD9425C02E4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Regula.DocumentReader.NetCoreExample/Program.cs b/src/Regula.DocumentReader.NetCoreExample/Program.cs index f136f52..1ec5350 100644 --- a/src/Regula.DocumentReader.NetCoreExample/Program.cs +++ b/src/Regula.DocumentReader.NetCoreExample/Program.cs @@ -4,6 +4,7 @@ using Regula.DocumentReader.WebClient.Api; using Regula.DocumentReader.WebClient.Model; using Regula.DocumentReader.WebClient.Model.Ext; +using Regula.DocumentReader.WebClient.Model.Ext.Autheticity; namespace Regula.DocumentReader.NetCoreExample { @@ -62,6 +63,13 @@ public static void Main() int docNumberMrzValidity = docNumberField.SourceValidity(Source.MRZ); int docNumberMrzVisualMatching = docNumberField.CrossSourceComparison(Source.MRZ, Source.VISUAL); + var docAuthenticity = response.Authenticity(); + var docIRB900 = docAuthenticity.IrB900Checks(); + var docIRB900Blank = docIRB900.checksByElement(SecurityFeatureType.BLANK); + + var docImagePattern = docAuthenticity.imagePattern(); + var docImagePatternBlank = docImagePattern.checksByElement(SecurityFeatureType.BLANK); + Console.WriteLine("-----------------------------------------------------------------"); Console.WriteLine($" Document Overall Status: {docOverallStatus}"); Console.WriteLine($" Document Optical Text Status: {docOpticalTextStatus}"); diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/AuthenticityResult.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/AuthenticityResult.cs new file mode 100644 index 0000000..c8dc9af --- /dev/null +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/AuthenticityResult.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity +{ + class AuthenticityResult + { + } +} diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/Autheticity.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/Autheticity.cs new file mode 100644 index 0000000..f5d562e --- /dev/null +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/Autheticity.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity +{ + public static class Authenticity + { + + public static SecurityFeatureChecks UvLuminescenceChecks(this AuthenticityCheckList auth) + { + return auth.securityFeatureOrNull(AuthenticityResultType.UV_LUMINESCENCE); + } + + public static int IrB900Checks(this AuthenticityCheckList auth) + { + return 0; + } + + public static int ImagePattern(this AuthenticityCheckList auth) + { + return 0; + } + + private static AuthenticityCheckResult resultByType(this AuthenticityCheckList auth, int type) + { + var ls = auth.List; + foreach (var checkRes in ls) + { + if (checkRes.Type == type) + return checkRes; + } + return null; + } + + private static FiberChecks filberOrNull(this AuthenticityCheckList auth, int type) + { + AuthenticityCheckResult result = auth.resultByType(type); + return null; + } + + private static IdentChecks identOrNull(this AuthenticityCheckList auth, int type) + { + AuthenticityCheckResult result = auth.resultByType(type); + return null; + } + + private static ImageIdentChecks imageIdentOrNull(this AuthenticityCheckList auth, int type) + { + AuthenticityCheckResult result = auth.resultByType(type); + return null; + } + + private static OCRSecurityTextChecks ocrSecurityTextOrNull(this AuthenticityCheckList auth, int type) + { + AuthenticityCheckResult result = auth.resultByType(type); + return null; + } + + private static SecurityFeatureChecks securityFeatureOrNull(this AuthenticityCheckList auth, int type) + { + AuthenticityCheckResult result = auth.resultByType(type); + return null; + } + + } + +} diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/FiberChecks.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/FiberChecks.cs new file mode 100644 index 0000000..50ce0cf --- /dev/null +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/FiberChecks.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity +{ + class FiberChecks + { + } +} diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/IdentChecks.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/IdentChecks.cs new file mode 100644 index 0000000..ba29b2c --- /dev/null +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/IdentChecks.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity +{ + class IdentChecks + { + } +} diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/ImageIdentChecks.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/ImageIdentChecks.cs new file mode 100644 index 0000000..73cde03 --- /dev/null +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/ImageIdentChecks.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity +{ + class ImageIdentChecks + { + } +} diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/OCRSecurityTextChecks.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/OCRSecurityTextChecks.cs new file mode 100644 index 0000000..0e27050 --- /dev/null +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/OCRSecurityTextChecks.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity +{ + class OCRSecurityTextChecks + { + } +} diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/SecurityFeatureChecks.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/SecurityFeatureChecks.cs new file mode 100644 index 0000000..ed24e5e --- /dev/null +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/SecurityFeatureChecks.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity +{ + class SecurityFeatureChecks + { + } +} From fd0473d3f5b11cff90140e0dbd50f2dd045f287a Mon Sep 17 00:00:00 2001 From: "Danila.Kislitsyn" Date: Thu, 4 Mar 2021 11:02:10 +0300 Subject: [PATCH 2/5] set up the extensions --- .../Program.cs | 6 +- .../Ext/Autheticity/AuthenticityResult.cs | 21 ++++- .../Model/Ext/Autheticity/Autheticity.cs | 89 +++++++++++++++---- .../Model/Ext/Autheticity/FiberChecks.cs | 4 +- .../Model/Ext/Autheticity/IdentChecks.cs | 11 ++- .../Model/Ext/Autheticity/ImageIdentChecks.cs | 5 +- .../Ext/Autheticity/OCRSecurityTextChecks.cs | 6 +- .../Ext/Autheticity/SecurityFeatureChecks.cs | 11 ++- 8 files changed, 125 insertions(+), 28 deletions(-) diff --git a/src/Regula.DocumentReader.NetCoreExample/Program.cs b/src/Regula.DocumentReader.NetCoreExample/Program.cs index 1ec5350..0ddaa47 100644 --- a/src/Regula.DocumentReader.NetCoreExample/Program.cs +++ b/src/Regula.DocumentReader.NetCoreExample/Program.cs @@ -65,10 +65,10 @@ public static void Main() var docAuthenticity = response.Authenticity(); var docIRB900 = docAuthenticity.IrB900Checks(); - var docIRB900Blank = docIRB900.checksByElement(SecurityFeatureType.BLANK); + var docIRB900Blank = docIRB900.ChecksByElement(SecurityFeatureType.BLANK); - var docImagePattern = docAuthenticity.imagePattern(); - var docImagePatternBlank = docImagePattern.checksByElement(SecurityFeatureType.BLANK); + var docImagePattern = docAuthenticity.ImagePattern(); + var docImagePatternBlank = docImagePattern.ChecksByElement(SecurityFeatureType.BLANK); Console.WriteLine("-----------------------------------------------------------------"); Console.WriteLine($" Document Overall Status: {docOverallStatus}"); diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/AuthenticityResult.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/AuthenticityResult.cs index c8dc9af..391a5fa 100644 --- a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/AuthenticityResult.cs +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/AuthenticityResult.cs @@ -1,10 +1,29 @@ using System; using System.Collections.Generic; using System.Text; +using System.Linq; namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity { - class AuthenticityResult + public abstract class AuthenticityResult where T : class { + AuthenticityCheckResult authenticityCheckResult; + + public AuthenticityResult(AuthenticityCheckResult authenticityCheckResult) + { + this.authenticityCheckResult = authenticityCheckResult; + } + + public AuthenticityCheckResult Payload() + { + return this.authenticityCheckResult; + } + + public List Items() + { + var ls = this.authenticityCheckResult.List; + + return (ls as IEnumerable).Cast().ToList(); + } } } diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/Autheticity.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/Autheticity.cs index f5d562e..5227484 100644 --- a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/Autheticity.cs +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/Autheticity.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.Text; +using System.Linq; namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity { @@ -12,55 +12,110 @@ public static SecurityFeatureChecks UvLuminescenceChecks(this AuthenticityCheckL return auth.securityFeatureOrNull(AuthenticityResultType.UV_LUMINESCENCE); } - public static int IrB900Checks(this AuthenticityCheckList auth) + public static SecurityFeatureChecks IrB900Checks(this AuthenticityCheckList auth) { - return 0; + return auth.securityFeatureOrNull(AuthenticityResultType.IR_B900); } - public static int ImagePattern(this AuthenticityCheckList auth) + public static IdentChecks ImagePattern(this AuthenticityCheckList auth) { - return 0; + return auth.identOrNull(AuthenticityResultType.IMAGE_PATTERN); } + public static SecurityFeatureChecks AxialProtectionChecks(this AuthenticityCheckList auth) + { + return auth.securityFeatureOrNull(AuthenticityResultType.AXIAL_PROTECTION); + } + + public static FiberChecks UVFiberChecks(this AuthenticityCheckList auth) + { + return auth.filberOrNull(AuthenticityResultType.UV_FIBERS); + } + + public static OCRSecurityTextChecks OCRSecurityTextChecks(this AuthenticityCheckList auth) + { + return auth.ocrSecurityTextOrNull(AuthenticityResultType.OCR_SECURITY_TEXT); + } + + public static ImageIdentChecks IpiChecks(this AuthenticityCheckList auth) + { + return auth.imageIdentOrNull(AuthenticityResultType.IPI); + } + + public static SecurityFeatureChecks EmbededImageChecks(this AuthenticityCheckList auth) + { + return auth.securityFeatureOrNull(AuthenticityResultType.PHOTO_EMBED_TYPE); + } + + public static SecurityFeatureChecks HologramsChecks(this AuthenticityCheckList auth) + { + return auth.securityFeatureOrNull(AuthenticityResultType.HOLOGRAMS); + } + + public static SecurityFeatureChecks ImageAreaChecks(this AuthenticityCheckList auth) + { + return auth.securityFeatureOrNull(AuthenticityResultType.PHOTO_AREA); + } + + public static IdentChecks portraitComparisonChecks(this AuthenticityCheckList auth) + { + return auth.identOrNull(AuthenticityResultType.PORTRAIT_COMPARISON); + } + + public static SecurityFeatureChecks BarcodeFormatCheckChecks(this AuthenticityCheckList auth) + { + return auth.securityFeatureOrNull(AuthenticityResultType.BARCODE_FORMAT_CHECK); + } + + public static IdentChecks KinegramChecks(this AuthenticityCheckList auth) + { + return auth.identOrNull(AuthenticityResultType.KINEGRAM); + } + + public static IdentChecks LetterScreenChecks(this AuthenticityCheckList auth) + { + return auth.identOrNull(AuthenticityResultType.LETTER_SCREEN); + } + + private static AuthenticityCheckResult resultByType(this AuthenticityCheckList auth, int type) { - var ls = auth.List; - foreach (var checkRes in ls) - { - if (checkRes.Type == type) - return checkRes; - } - return null; + var res = auth.List.FirstOrDefault(t => t.Type == type); + + return res; } private static FiberChecks filberOrNull(this AuthenticityCheckList auth, int type) { AuthenticityCheckResult result = auth.resultByType(type); - return null; + + return result != null ? new FiberChecks(result) : null; } private static IdentChecks identOrNull(this AuthenticityCheckList auth, int type) { AuthenticityCheckResult result = auth.resultByType(type); - return null; + return result != null ? new IdentChecks(result) : null; } private static ImageIdentChecks imageIdentOrNull(this AuthenticityCheckList auth, int type) { AuthenticityCheckResult result = auth.resultByType(type); - return null; + return result != null ? new ImageIdentChecks(result) : null; } private static OCRSecurityTextChecks ocrSecurityTextOrNull(this AuthenticityCheckList auth, int type) { AuthenticityCheckResult result = auth.resultByType(type); - return null; + + return result != null ? new OCRSecurityTextChecks(result) : null; } private static SecurityFeatureChecks securityFeatureOrNull(this AuthenticityCheckList auth, int type) { AuthenticityCheckResult result = auth.resultByType(type); - return null; + + return result != null ? new SecurityFeatureChecks(result) : null; } } diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/FiberChecks.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/FiberChecks.cs index 50ce0cf..e048305 100644 --- a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/FiberChecks.cs +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/FiberChecks.cs @@ -4,7 +4,9 @@ namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity { - class FiberChecks + public class FiberChecks : AuthenticityResult { + public FiberChecks(AuthenticityCheckResult authenticityCheckResult) : base(authenticityCheckResult) + { } } } diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/IdentChecks.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/IdentChecks.cs index ba29b2c..c32a71d 100644 --- a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/IdentChecks.cs +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/IdentChecks.cs @@ -1,10 +1,17 @@ using System; using System.Collections.Generic; -using System.Text; +using System.Linq; namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity { - class IdentChecks + public class IdentChecks : AuthenticityResult { + public IdentChecks(AuthenticityCheckResult authenticityCheckResult) : base(authenticityCheckResult) + { } + + public IdentResult ChecksByElement(int type) + { + return this.Items().FirstOrDefault(t => t.Type == type); + } } } diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/ImageIdentChecks.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/ImageIdentChecks.cs index 73cde03..d672ddc 100644 --- a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/ImageIdentChecks.cs +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/ImageIdentChecks.cs @@ -4,7 +4,10 @@ namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity { - class ImageIdentChecks + public class ImageIdentChecks : AuthenticityResult { + public ImageIdentChecks(AuthenticityCheckResult authenticityCheckResult) : base(authenticityCheckResult) + { } + } } diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/OCRSecurityTextChecks.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/OCRSecurityTextChecks.cs index 0e27050..850692d 100644 --- a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/OCRSecurityTextChecks.cs +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/OCRSecurityTextChecks.cs @@ -4,7 +4,11 @@ namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity { - class OCRSecurityTextChecks + public class OCRSecurityTextChecks : AuthenticityResult { + public OCRSecurityTextChecks(AuthenticityCheckResult authenticityCheckResult) : base(authenticityCheckResult) + { + + } } } diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/SecurityFeatureChecks.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/SecurityFeatureChecks.cs index ed24e5e..ed1a57d 100644 --- a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/SecurityFeatureChecks.cs +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/SecurityFeatureChecks.cs @@ -1,10 +1,17 @@ using System; using System.Collections.Generic; -using System.Text; +using System.Linq; namespace Regula.DocumentReader.WebClient.Model.Ext.Autheticity { - class SecurityFeatureChecks + public class SecurityFeatureChecks : AuthenticityResult { + public SecurityFeatureChecks(AuthenticityCheckResult authenticityResult) : base(authenticityResult) + { } + + public SecurityFeatureResult ChecksByElement(int type) + { + return this.Items().FirstOrDefault(t => t.Type == type); + } } } From a1d97a5abc58b4ee4ce2e1c2b48c6ce751a923a5 Mon Sep 17 00:00:00 2001 From: "Danila.Kislitsyn" Date: Thu, 4 Mar 2021 11:10:20 +0300 Subject: [PATCH 3/5] debug --- src/Regula.DocumentReader.WebClient/Api/ProcessApi.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Regula.DocumentReader.WebClient/Api/ProcessApi.cs b/src/Regula.DocumentReader.WebClient/Api/ProcessApi.cs index ab6da2c..cb608f9 100644 --- a/src/Regula.DocumentReader.WebClient/Api/ProcessApi.cs +++ b/src/Regula.DocumentReader.WebClient/Api/ProcessApi.cs @@ -1,4 +1,4 @@ -/* +/* * Regula Document Reader Web API * * Documents recognition as easy as reading two bytes. # Clients: * [JavaScript](https://github.com/regulaforensics/DocumentReader-web-js-client) client for the browser and node.js based on axios * [Java](https://github.com/regulaforensics/DocumentReader-web-java-client) client compatible with jvm and android * [Python](https://github.com/regulaforensics/DocumentReader-web-python-client) 3.5+ client * [C#](https://github.com/regulaforensics/DocumentReader-web-csharp-client) client for .NET & .NET Core From 75c9247bf3813e4f79a34754c984a62db1fb3db0 Mon Sep 17 00:00:00 2001 From: "Danila.Kislitsyn" Date: Thu, 4 Mar 2021 11:41:09 +0300 Subject: [PATCH 4/5] fix the code --- .../Program.cs | 19 ++++++++++--------- .../Ext/Autheticity/AuthenticityResult.cs | 2 +- .../Model/Ext/Autheticity/Autheticity.cs | 2 +- .../Model/Ext/Autheticity/IdentChecks.cs | 2 +- .../Ext/Autheticity/SecurityFeatureChecks.cs | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Regula.DocumentReader.NetCoreExample/Program.cs b/src/Regula.DocumentReader.NetCoreExample/Program.cs index 0ddaa47..6e36d4e 100644 --- a/src/Regula.DocumentReader.NetCoreExample/Program.cs +++ b/src/Regula.DocumentReader.NetCoreExample/Program.cs @@ -28,15 +28,16 @@ public static void Main() var uvPage0 = File.ReadAllBytes("UV.jpg"); var requestParams = new RecognitionParams() - .WithScenario(Scenario.FULL_PROCESS) + .WithScenario(Scenario.FULL_AUTH) .WithResultTypeOutput(new List { - // actual results, keep only required - Result.STATUS, Result.TEXT, Result.IMAGES, Result.DOCUMENT_TYPE, - // legacy results - Result.MRZ_TEXT, Result.VISUAL_TEXT, Result.BARCODE_TEXT, Result.RFID_TEXT, - Result.VISUAL_GRAPHICS, Result.BARCODE_GRAPHICS, Result.RFID_GRAPHICS, - Result.LEXICAL_ANALYSIS + // actual results + Result.STATUS, Result.AUTHENTICITY, Result.TEXT, Result.IMAGES, + Result.DOCUMENT_TYPE, Result.DOCUMENT_TYPE_CANDIDATES, + // legacy results + Result.MRZ_TEXT, Result.VISUAL_TEXT, Result.BARCODE_TEXT, Result.RFID_TEXT, + Result.VISUAL_GRAPHICS, Result.BARCODE_GRAPHICS, Result.RFID_GRAPHICS, + Result.LEXICAL_ANALYSIS }); var request = new RecognitionRequest(requestParams, new List{ @@ -65,10 +66,10 @@ public static void Main() var docAuthenticity = response.Authenticity(); var docIRB900 = docAuthenticity.IrB900Checks(); - var docIRB900Blank = docIRB900.ChecksByElement(SecurityFeatureType.BLANK); + var docIRB900Blank = docIRB900?.ChecksByElement(SecurityFeatureType.BLANK); var docImagePattern = docAuthenticity.ImagePattern(); - var docImagePatternBlank = docImagePattern.ChecksByElement(SecurityFeatureType.BLANK); + var docImagePatternBlank = docImagePattern?.ChecksByElement(SecurityFeatureType.BLANK); Console.WriteLine("-----------------------------------------------------------------"); Console.WriteLine($" Document Overall Status: {docOverallStatus}"); diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/AuthenticityResult.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/AuthenticityResult.cs index 391a5fa..6b2c9b8 100644 --- a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/AuthenticityResult.cs +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/AuthenticityResult.cs @@ -23,7 +23,7 @@ public List Items() { var ls = this.authenticityCheckResult.List; - return (ls as IEnumerable).Cast().ToList(); + return ls as List; } } } diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/Autheticity.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/Autheticity.cs index 5227484..3e4b81f 100644 --- a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/Autheticity.cs +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/Autheticity.cs @@ -80,7 +80,7 @@ public static IdentChecks LetterScreenChecks(this AuthenticityCheckList auth) private static AuthenticityCheckResult resultByType(this AuthenticityCheckList auth, int type) { - var res = auth.List.FirstOrDefault(t => t.Type == type); + var res = auth?.List.FirstOrDefault(t => t.Type == type); return res; } diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/IdentChecks.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/IdentChecks.cs index c32a71d..cdaab73 100644 --- a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/IdentChecks.cs +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/IdentChecks.cs @@ -11,7 +11,7 @@ public IdentChecks(AuthenticityCheckResult authenticityCheckResult) : base(authe public IdentResult ChecksByElement(int type) { - return this.Items().FirstOrDefault(t => t.Type == type); + return this.Items()?.FirstOrDefault(t => t.Type == type); } } } diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/SecurityFeatureChecks.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/SecurityFeatureChecks.cs index ed1a57d..8700c0b 100644 --- a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/SecurityFeatureChecks.cs +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/SecurityFeatureChecks.cs @@ -11,7 +11,7 @@ public SecurityFeatureChecks(AuthenticityCheckResult authenticityResult) : base( public SecurityFeatureResult ChecksByElement(int type) { - return this.Items().FirstOrDefault(t => t.Type == type); + return this.Items()?.FirstOrDefault(t => t.Type == type); } } } From a9afe52bef9eeabe66b2e4c85ea02ae591f225a5 Mon Sep 17 00:00:00 2001 From: Hleb Albau Date: Thu, 4 Mar 2021 15:27:29 +0300 Subject: [PATCH 5/5] add missing type, make aac pageable --- .../Model/Ext/Autheticity/Autheticity.cs | 12 ++++++------ .../Model/Ext/RecognitionResponse.cs | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/Autheticity.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/Autheticity.cs index 3e4b81f..6881167 100644 --- a/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/Autheticity.cs +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/Autheticity/Autheticity.cs @@ -32,6 +32,11 @@ public static FiberChecks UVFiberChecks(this AuthenticityCheckList auth) return auth.filberOrNull(AuthenticityResultType.UV_FIBERS); } + public static IdentChecks IRVisibilityChecks(this AuthenticityCheckList auth) + { + return auth.identOrNull(AuthenticityResultType.IR_VISIBILITY); + } + public static OCRSecurityTextChecks OCRSecurityTextChecks(this AuthenticityCheckList auth) { return auth.ocrSecurityTextOrNull(AuthenticityResultType.OCR_SECURITY_TEXT); @@ -80,15 +85,12 @@ public static IdentChecks LetterScreenChecks(this AuthenticityCheckList auth) private static AuthenticityCheckResult resultByType(this AuthenticityCheckList auth, int type) { - var res = auth?.List.FirstOrDefault(t => t.Type == type); - - return res; + return auth?.List.FirstOrDefault(t => t.Type == type); } private static FiberChecks filberOrNull(this AuthenticityCheckList auth, int type) { AuthenticityCheckResult result = auth.resultByType(type); - return result != null ? new FiberChecks(result) : null; } @@ -107,14 +109,12 @@ private static ImageIdentChecks imageIdentOrNull(this AuthenticityCheckList auth private static OCRSecurityTextChecks ocrSecurityTextOrNull(this AuthenticityCheckList auth, int type) { AuthenticityCheckResult result = auth.resultByType(type); - return result != null ? new OCRSecurityTextChecks(result) : null; } private static SecurityFeatureChecks securityFeatureOrNull(this AuthenticityCheckList auth, int type) { AuthenticityCheckResult result = auth.resultByType(type); - return result != null ? new SecurityFeatureChecks(result) : null; } diff --git a/src/Regula.DocumentReader.WebClient/Model/Ext/RecognitionResponse.cs b/src/Regula.DocumentReader.WebClient/Model/Ext/RecognitionResponse.cs index 8a7ce09..2c5926a 100644 --- a/src/Regula.DocumentReader.WebClient/Model/Ext/RecognitionResponse.cs +++ b/src/Regula.DocumentReader.WebClient/Model/Ext/RecognitionResponse.cs @@ -28,13 +28,13 @@ public Images Images() return result?.Images; } - public AuthenticityCheckList Authenticity() + public AuthenticityCheckList Authenticity(int pageIdx=0) { - var result = ResultByType(Result.AUTHENTICITY); + var result = ResultByType(Result.AUTHENTICITY, pageIdx); return result?.AuthenticityCheckList; } - public T ResultByType(int type) where T: ResultItem + public T ResultByType(int type, int pageIdx=0) where T: ResultItem { foreach(var item in OriginalResponse.ContainerList.List) {