Move OcrClient to AddIn project

This commit is contained in:
Serghei Cebotari 2024-11-14 00:16:58 +03:00
parent ac20bbfc05
commit 2026e2a4e2
10 changed files with 34 additions and 58 deletions

View File

@ -1,28 +0,0 @@
namespace OcrClient.Models;
public class OcrResponse
{
public Result? Result { get; set; }
}
public class Result
{
public TextAnnotation? TextAnnotation { get; set; }
}
public class TextAnnotation
{
public List<Table>? Tables { get; set; }
}
public class Table
{
public string? RowCount { get; set; }
public string? ColumnCount { get; set; }
public List<Cell>? Cells { get; set; }
}
public class Cell
{
public string? RowIndex { get; set; }
public string? ColumnIndex { get; set; }
public string? Text { get; set; }
}

View File

@ -1,15 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;net6.0-windows</TargetFrameworks>
<LangVersion>10</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>
</Project>

View File

@ -1,5 +1,4 @@
using System.Net;
using OcrClient.Services;
namespace RhSolutions.AddIn;

View File

@ -0,0 +1,28 @@
namespace RhSolutions.Models;
public class OcrResponse
{
public Result Result { get; set; }
}
public class Result
{
public TextAnnotation TextAnnotation { get; set; }
}
public class TextAnnotation
{
public List<Table> Tables { get; set; }
}
public class Table
{
public string RowCount { get; set; }
public string ColumnCount { get; set; }
public List<Cell> Cells { get; set; }
}
public class Cell
{
public string RowIndex { get; set; }
public string ColumnIndex { get; set; }
public string Text { get; set; }
}

View File

@ -22,7 +22,7 @@
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.10" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Physical" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
<PackageReference Include="netDxf" Version="2022.11.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
@ -32,7 +32,6 @@
<ItemGroup>
<ProjectReference Include="..\RhSolutions.ProductSku\RhSolutions.ProductSku.csproj" />
<ProjectReference Include="..\SnippingTool\SnippingTool.csproj" />
<ProjectReference Include="..\OcrClient\OcrClient.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="Images\Coupling.png">

View File

@ -20,12 +20,8 @@ public class AddInConfiguration : IAddInConfiguration
public AddInConfiguration()
{
// EmbeddedFileProvider embeddedProvider = new (typeof(RhSolutionsAddIn).Assembly);
// using Stream stream = embeddedProvider.GetFileInfo("appsettings.json").CreateReadStream();
_configuration = new ConfigurationBuilder()
.AddUserSecrets<RhSolutionsAddIn>()
// .AddJsonStream(stream)
.Build();
_rootKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\RhSolutions\RhSolutions-AddIn");

View File

@ -1,6 +1,6 @@
using OcrClient.Models;
using System.Threading.Tasks;
namespace OcrClient.Services;
namespace RhSolutions.Services;
public interface IOcrClient
{

View File

@ -1,10 +1,10 @@
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using OcrClient.Models;
namespace OcrClient.Services;
namespace RhSolutions.Services;
public class YandexOcrClient : IOcrClient
{
@ -35,7 +35,7 @@ public class YandexOcrClient : IOcrClient
response.EnsureSuccessStatusCode();
string jsonResponse = await response.Content.ReadAsStringAsync();
OcrResponse? deserialized = JsonConvert.DeserializeObject<OcrResponse>(jsonResponse);
OcrResponse deserialized = JsonConvert.DeserializeObject<OcrResponse>(jsonResponse);
if (deserialized != null)
{

View File

@ -1,6 +1,5 @@
using System.Threading.Tasks;
using SnippingTool;
using OcrClient.Services;
using System.Windows.Forms;
using Application = Microsoft.Office.Interop.Excel.Application;

View File

@ -11,8 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RhSolutions.ProductSku", "R
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SnippingTool", "SnippingTool\SnippingTool.csproj", "{DDB517C7-DF61-4C26-B691-956D0E5906C3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OcrClient", "OcrClient\OcrClient.csproj", "{53F322B3-F477-4831-8E16-EA76934A0D59}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU