2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2026-06-13 14:38:43 +00:00
This commit is contained in:
2026-06-08 16:15:57 +03:00
parent 8143da2eee
commit 340798a5fa
111 changed files with 20647 additions and 27 deletions
+13
View File
@@ -0,0 +1,13 @@
// Echo.SignalR/EchoHub.cs
using Microsoft.AspNetCore.SignalR;
namespace Esiur.Tests.RPC.SignalRServer;
public class EchoHub : Hub
{
public byte[] EchoBytes(byte[] data) => data;
public BusinessDocument[] EchoDocuments(BusinessDocument[] docs) => docs;
public int[] EchoIntArray(int[] array) => array;
public string[] EchoStringArray(string[] array) => array;
public Dictionary<string, BusinessDocument> EchoMap(Dictionary<string, BusinessDocument> map) => map;
public DocType EchoEnumArray(DocType[] docTypes) => docTypes.Length == 0 ? DocType.Quote : docTypes[^1];
}
+194
View File
@@ -0,0 +1,194 @@
#nullable enable
using System;
using System.Collections.Generic;
namespace Esiur.Tests.RPC.SignalRServer
{
// ====================== Enums ======================
public enum Currency
{
IQD,
CNH,
USD,
EUR,
JPY,
GBP
}
public enum DocType
{
Quote,
Order,
Invoice,
CreditNote
}
public enum PaymentMethod
{
Cash,
Card,
Wire,
Crypto,
Other
}
public enum LineType
{
Product,
Service,
Discount,
Shipping
}
// Variant.Kind
public enum Kind
{
Null,
Bool,
Int64,
UInt64,
Double,
Decimal,
String,
Bytes,
DateTime,
Guid
}
// ====================== Variant & Entry helpers ======================
public sealed class Variant
{
public Kind Tag { get; set; }
public bool? Bool { get; set; }
public long? I64 { get; set; }
public ulong? U64 { get; set; }
public double? F64 { get; set; }
public string? Str { get; set; }
public byte[]? Bytes { get; set; }
public DateTime? Dt { get; set; }
public byte[]? Guid { get; set; }
}
public sealed class MetaEntry
{
public string Key { get; set; } = string.Empty;
public Variant Value { get; set; } = new Variant();
}
public sealed class ExtEntry
{
public string Key { get; set; } = string.Empty;
public Variant Value { get; set; } = new Variant();
}
// ====================== Party & Address ======================
public sealed class Address
{
public string Line1 { get; set; } = string.Empty;
public string? Line2 { get; set; }
public string City { get; set; } = string.Empty;
public string Region { get; set; } = string.Empty;
public string Country { get; set; } = string.Empty;
public string? PostalCode { get; set; }
}
public sealed class Party
{
public ulong Id { get; set; }
public string Name { get; set; } = string.Empty;
public string? TaxId { get; set; }
public string? Email { get; set; }
public string? Phone { get; set; }
public Address? Address { get; set; }
public string? PreferredLanguage { get; set; }
}
// ====================== DocumentHeader ======================
public sealed class DocumentHeader
{
// Guid serialized as bytes
public byte[] DocId { get; set; } = Array.Empty<byte>();
public DocType Type { get; set; }
public int Version { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public Currency Currency { get; set; }
public string? Notes { get; set; }
// corresponds to Dictionary<string, Variant>
public Dictionary<string, Variant> Meta { get; set; } = new();
}
// ====================== LineItem, Payment, Attachment ======================
public sealed class LineItem
{
public int LineNo { get; set; }
public LineType Type { get; set; }
public string SKU { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public double Qty { get; set; }
public string QtyUnit { get; set; } = string.Empty;
public double UnitPrice { get; set; }
public double? VatRate { get; set; }
public double? Discount { get; set; }
// Dictionary<string, Variant>
public Dictionary<string, Variant> Ext { get; set; } = new();
}
public sealed class Payment
{
public PaymentMethod Method { get; set; }
public double Amount { get; set; }
public string? Reference { get; set; }
public DateTime Timestamp { get; set; }
public double? Fee { get; set; }
public Currency Currency { get; set; }
}
public sealed class Attachment
{
public string Name { get; set; } = string.Empty;
public string MimeType { get; set; } = string.Empty;
public byte[] Data { get; set; } = Array.Empty<byte>();
}
// ====================== Top-level BusinessDocument ======================
public sealed class BusinessDocument
{
public DocumentHeader Header { get; set; } = new DocumentHeader();
public Party Seller { get; set; } = new Party();
public Party Buyer { get; set; } = new Party();
public LineItem[] Items { get; set; } = Array.Empty<LineItem>();
public Payment[] Payments { get; set; } = Array.Empty<Payment>();
public Attachment[] Attachments { get; set; } = Array.Empty<Attachment>();
public int[] RiskScores { get; set; } = Array.Empty<int>();
}
}
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.1" />
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.2.0" />
</ItemGroup>
</Project>
@@ -0,0 +1,6 @@
@RPC.SignalR_HostAddress = http://localhost:5026
GET {{RPC.SignalR_HostAddress}}/weatherforecast/
Accept: application/json
###
+16
View File
@@ -0,0 +1,16 @@
using Esiur.Tests.RPC.SignalRServer;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSignalR(o =>
{
o.EnableDetailedErrors = true;
o.MaximumReceiveMessageSize = 10 * 1024 * 1024; // 10 MB
});
var app = builder.Build();
app.MapHub<EchoHub>("/hub/echo");
app.Urls.Add("http://0.0.0.0:5200");
app.Run();
@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5026",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:7175;http://localhost:5026",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}