Compare commits
3 Commits
9c06f80dd7
...
677582d4bb
| Author | SHA1 | Date | |
|---|---|---|---|
| 677582d4bb | |||
| 6466d17905 | |||
| ebf3d3069b |
28
AppCode/Formatters/Formatters.cs
Normal file
28
AppCode/Formatters/Formatters.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc.Formatters;
|
||||||
|
|
||||||
|
namespace CA_ANC.Formatters;
|
||||||
|
public class Formatters {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ByteArrayInputFormatter : InputFormatter
|
||||||
|
{
|
||||||
|
public ByteArrayInputFormatter()
|
||||||
|
{
|
||||||
|
SupportedMediaTypes.Add(Microsoft.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream"));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool CanReadType(Type type)
|
||||||
|
{
|
||||||
|
return type == typeof(byte[]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async override Task<InputFormatterResult> ReadRequestBodyAsync(InputFormatterContext context)
|
||||||
|
{
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
await context.HttpContext.Request.Body.CopyToAsync(stream);
|
||||||
|
return await InputFormatterResult.SuccessAsync(stream.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
73
Controllers/CartController.cs
Normal file
73
Controllers/CartController.cs
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Http;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
using CVRLIB.CARTS;
|
||||||
|
using static CVRLIB.CVSTRINGS.TextFuncs;
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using CVRLIB;
|
||||||
|
|
||||||
|
namespace VSERVERWS.Controllers {
|
||||||
|
|
||||||
|
//https://vserverws.cvr.cvrco.ca/api/cart/CartStatus
|
||||||
|
|
||||||
|
[Route("api/Cart/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class CartController : ControllerBase {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult CartStatus() {
|
||||||
|
|
||||||
|
var rOBJ = new { STATUS = "OK" };
|
||||||
|
|
||||||
|
return new JsonResult(rOBJ);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<IActionResult> SubmitCartData([FromBody] byte[] data) {
|
||||||
|
|
||||||
|
var JSON = await NonSecureDecryptByteAToStringAsync(data);
|
||||||
|
|
||||||
|
var rOBJ = new TryCartOperationResult();
|
||||||
|
|
||||||
|
try {
|
||||||
|
var tCART = JsonConvert.DeserializeObject<ShoppingCart>(JSON);
|
||||||
|
|
||||||
|
if (tCART != null) {
|
||||||
|
|
||||||
|
tCART.TrySyncToInventory(CVGlobal.INVENTORY);
|
||||||
|
|
||||||
|
await tCART.SaveToDBAsync();
|
||||||
|
|
||||||
|
rOBJ.AddResult(true, "CART_SAVE_TO_DB");
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
rOBJ.AddResult(false, "CONVERT_TO_JSON", "Failed to convert to json from byte data.");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
|
||||||
|
rOBJ.AddResult(false, "CART_SAVE_TRY", ex.Message, ex);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//return new result
|
||||||
|
return new JsonResult(rOBJ);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -35,7 +35,7 @@ namespace VSERVERWS.Controllers {
|
|||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult PaymentStatus() {
|
public IActionResult PaymentStatus() {
|
||||||
|
//api/Payment/PaymentStatus
|
||||||
|
|
||||||
|
|
||||||
CVRPRINTER_MF264dw? CVP2 = CVP_MF264dw;
|
CVRPRINTER_MF264dw? CVP2 = CVP_MF264dw;
|
||||||
@ -115,7 +115,7 @@ namespace VSERVERWS.Controllers {
|
|||||||
|
|
||||||
if (DateTime.Now.Subtract(LastError).Hours > 2) {
|
if (DateTime.Now.Subtract(LastError).Hours > 2) {
|
||||||
Email E = new Email();
|
Email E = new Email();
|
||||||
E.SEND_FROM = Email.SEND_FROM_ENUM.OFFICE365;
|
E.SEND_FROM = SEND_FROM_ENUM.OFFICE365;
|
||||||
|
|
||||||
string B = "Payment System Printer error / offline: Check applicable printer(s) for error or offline!";
|
string B = "Payment System Printer error / offline: Check applicable printer(s) for error or offline!";
|
||||||
string S = "<cc> Payment System Printer Error: Check Printer(s)!";
|
string S = "<cc> Payment System Printer Error: Check Printer(s)!";
|
||||||
@ -148,7 +148,7 @@ namespace VSERVERWS.Controllers {
|
|||||||
object? rOBJ = null;
|
object? rOBJ = null;
|
||||||
|
|
||||||
Email E = new Email();
|
Email E = new Email();
|
||||||
E.SEND_FROM = Email.SEND_FROM_ENUM.OFFICE365;
|
E.SEND_FROM = SEND_FROM_ENUM.OFFICE365;
|
||||||
|
|
||||||
bool DupRetry = false;
|
bool DupRetry = false;
|
||||||
|
|
||||||
|
|||||||
47
Program.cs
47
Program.cs
@ -1,18 +1,32 @@
|
|||||||
|
|
||||||
|
using CVRLIB.CVENVIRONMENT;
|
||||||
|
using static CVRLIB.CVGlobal;
|
||||||
|
|
||||||
|
using CA_ANC.Formatters;
|
||||||
|
using CVRLIB;
|
||||||
|
using CVRLIB.Inventory;
|
||||||
|
using CVRLIB.Customers;
|
||||||
|
|
||||||
//ZXING.dll does not copy properly to publish folder, copy manually from another lib, ie cvrlib-nf.
|
//ZXING.dll does not copy properly to publish folder, copy manually from another lib, ie cvrlib-nf.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddRazorPages();
|
builder.Services.AddRazorPages();
|
||||||
|
|
||||||
builder.Services.AddControllers().AddJsonOptions((options => {
|
//builder.Services.AddControllers().AddJsonOptions((options => {
|
||||||
//was changing PRINTER_NAME to printeR_NAME (pascal Case: https://github.com/dotnet/runtime/issues/30887)
|
// //was changing PRINTER_NAME to printeR_NAME (pascal Case: https://github.com/dotnet/runtime/issues/30887)
|
||||||
options.JsonSerializerOptions.PropertyNamingPolicy = null;
|
// options.JsonSerializerOptions.PropertyNamingPolicy = null;
|
||||||
}));
|
//}));
|
||||||
|
|
||||||
|
|
||||||
|
builder.Services
|
||||||
|
.AddControllers(options => { options.InputFormatters.Add(new ByteArrayInputFormatter()); })
|
||||||
|
.AddNewtonsoftJson()
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
@ -27,6 +41,14 @@ if (!app.Environment.IsDevelopment()) {
|
|||||||
VSERVERWS.Global.Globals.IsDevelopment = app.Environment.IsDevelopment();
|
VSERVERWS.Global.Globals.IsDevelopment = app.Environment.IsDevelopment();
|
||||||
|
|
||||||
|
|
||||||
|
VSERVERWS.Global.Globals.LoadPrinters();
|
||||||
|
|
||||||
|
|
||||||
|
CVGlobal.TryGlobalPRELoadCVCollections(new[] { typeof(CVINVENTORY), typeof(CVCustomers) });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
@ -42,4 +64,19 @@ app.MapRazorPages();
|
|||||||
app.Run();
|
app.Run();
|
||||||
|
|
||||||
|
|
||||||
VSERVERWS.Global.Globals.LoadPrinters();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public partial class Program {
|
||||||
|
|
||||||
|
public static CVSECRETS? CVS { get; set; } = null;
|
||||||
|
public static string AppPath { get; set; } = "";
|
||||||
|
public static string HTTPROOT { get; set; } = "";
|
||||||
|
public static bool IsDevMode { get; set; } = false;
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0-windows</TargetFramework>
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
@ -9,19 +9,43 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="11.3.0" />
|
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="11.3.0" />
|
||||||
<PackageReference Include="Magick.NET.Core" Version="11.3.0" />
|
<PackageReference Include="Magick.NET.Core" Version="11.3.0" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.16" />
|
||||||
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />
|
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
|
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
|
||||||
|
<PackageReference Include="System.Text.Json" Version="7.0.2" />
|
||||||
<PackageReference Include="ZXing.Net" Version="0.16.8" />
|
<PackageReference Include="ZXing.Net" Version="0.16.8" />
|
||||||
<FrameworkReference Include="Microsoft.WindowsDesktop.App" />
|
<FrameworkReference Include="Microsoft.WindowsDesktop.App" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="CVRLIB">
|
<Choose>
|
||||||
<HintPath>..\..\VB.NET\CVRLIB\CVRLIB\bin\Release\netstandard2.0\CVRLIB.dll</HintPath>
|
<When Condition=" '$(Configuration)'=='Debug' ">
|
||||||
</Reference>
|
<ItemGroup>
|
||||||
<Reference Include="CVRLIB-NF">
|
<Reference Include="CVRLIB">
|
||||||
<HintPath>..\..\VB.NET\CVRLIB-NF\CVRLIB-NF\bin\Release\CVRLIB-NF.dll</HintPath>
|
<HintPath>..\..\VB.NET\CVRLIB\CVRLIB\bin\Debug\netstandard2.0\CVRLIB.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
<Reference Include="CVRLIB-NF">
|
||||||
|
<HintPath>..\..\VB.NET\CVRLIB-NF\CVRLIB-NF\bin\Debug\CVRLIB-NF.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="HtmlFactory">
|
||||||
|
<HintPath>..\HtmlFactory\HtmlFactory\bin\Debug\netstandard2.0\HtmlFactory.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
</When>
|
||||||
|
<When Condition=" '$(Configuration)'=='Release' ">
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="CVRLIB">
|
||||||
|
<HintPath>..\..\VB.NET\CVRLIB\CVRLIB\bin\Release\netstandard2.0\CVRLIB.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="CVRLIB-NF">
|
||||||
|
<HintPath>..\..\VB.NET\CVRLIB-NF\CVRLIB-NF\bin\Release\CVRLIB-NF.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="HtmlFactory">
|
||||||
|
<HintPath>..\HtmlFactory\HtmlFactory\bin\Release\netstandard2.0\HtmlFactory.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
</When>
|
||||||
|
</Choose>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user