Compare commits
3 Commits
9347ab03a6
...
8181f31d27
| Author | SHA1 | Date | |
|---|---|---|---|
| 8181f31d27 | |||
| ecb0873f7f | |||
| de55203a12 |
@ -1,22 +1,32 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using System.Web;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
|
||||||
using CVRLIB.CARTS;
|
using CVRLIB.CARTS;
|
||||||
using static CVRLIB.CVSTRINGS.TextFuncs;
|
using static CVRLIB.CVSTRINGS.TextFuncs;
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using CVRLIB;
|
using CVRLIB;
|
||||||
|
using CVRLIB.Generic;
|
||||||
|
|
||||||
namespace VSERVERWS.Controllers {
|
|
||||||
|
|
||||||
//https://vserverws.cvr.cvrco.ca/api/cart/CartStatus
|
using ZXing;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
[Route("api/Cart/[action]")]
|
|
||||||
[ApiController]
|
|
||||||
public class CartController : ControllerBase {
|
namespace VSERVERWS.Controllers;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//https://vserverws.cvr.cvrco.ca/api/cart/CartStatus
|
||||||
|
|
||||||
|
[Route("api/Cart/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class CartController : ControllerBase {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -29,6 +39,88 @@ namespace VSERVERWS.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//https://localhost:7210/api/Cart/SubmitCartHTML?id=1337&source=beta%2Ecvr%2Ecvrco%2Eca
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Consumes("text/plain")]
|
||||||
|
public async Task<IActionResult> SubmitCartHTML(string id, string source) {
|
||||||
|
|
||||||
|
var rTOR = new TryOperationResult();
|
||||||
|
|
||||||
|
var isEncrypted = false;
|
||||||
|
var tdata = "";
|
||||||
|
var data = "";
|
||||||
|
|
||||||
|
var HTML_PATH = Program.XDRIVE + "\\CVRCO\\BU\\Carts\\HTML";
|
||||||
|
|
||||||
|
var inSource = HttpUtility.UrlDecode(source);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(inSource)) {
|
||||||
|
HTML_PATH = HTML_PATH + "\\" + inSource;
|
||||||
|
|
||||||
|
if (!Directory.Exists(HTML_PATH)) {
|
||||||
|
Directory.CreateDirectory(HTML_PATH);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
rTOR.AddResult(false, "READ_SOURCE", "no source provided!");
|
||||||
|
|
||||||
|
return new JsonResult(rTOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
using (var SR = new StreamReader(Request.Body)) {
|
||||||
|
data = await SR.ReadToEndAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!Directory.Exists(HTML_PATH)) {
|
||||||
|
Directory.CreateDirectory(HTML_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tdata.Contains("<html>")) { isEncrypted = true; }
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (isEncrypted) {
|
||||||
|
tdata = NonSecureDecryptHexStringToString(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tdata.Contains("<html>")) {
|
||||||
|
throw new Exception("Invalid html string");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
using (var FS = new FileStream(HTML_PATH + "\\" + id + ".txt", FileMode.Create, FileAccess.Write, FileShare.None)) {
|
||||||
|
using (var SW = new StreamWriter(FS)) {
|
||||||
|
|
||||||
|
if (isEncrypted) {
|
||||||
|
await SW.WriteAsync(data);
|
||||||
|
} else {
|
||||||
|
await SW.WriteAsync(NonSecureEncryptStringToHexString(tdata));
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
rTOR.AddResult(true, "TRY_SAVE_HTML_CART");
|
||||||
|
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
|
||||||
|
rTOR.AddResult(false, "TRY_SAVE_HTML_CART", ex.Message, ex);
|
||||||
|
|
||||||
|
Debug.WriteLine(ex.Message);
|
||||||
|
Debug.WriteLine(ex.StackTrace);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new JsonResult(rTOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
@ -69,5 +161,4 @@ namespace VSERVERWS.Controllers {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
26
Program.cs
26
Program.cs
@ -38,8 +38,19 @@ if (!app.Environment.IsDevelopment()) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VSERVERWS.Global.Globals.IsDevelopment = app.Environment.IsDevelopment();
|
|
||||||
|
|
||||||
|
var env = builder.Environment;
|
||||||
|
|
||||||
|
//X:\CVRCO\C#\VSERVERWS\VSERVERWS\wwwroot
|
||||||
|
AppPath = env.WebRootPath;
|
||||||
|
|
||||||
|
//X:\CVRCO\C#\VSERVERWS\VSERVERWS\
|
||||||
|
HTTPROOT = env.ContentRootPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
VSERVERWS.Global.Globals.IsDevelopment = app.Environment.IsDevelopment();
|
||||||
|
//VSERVERWS.Global.Globals.IsDevelopment = false;
|
||||||
|
|
||||||
VSERVERWS.Global.Globals.LoadPrinters();
|
VSERVERWS.Global.Globals.LoadPrinters();
|
||||||
|
|
||||||
@ -79,4 +90,17 @@ public partial class Program {
|
|||||||
public static string HTTPROOT { get; set; } = "";
|
public static string HTTPROOT { get; set; } = "";
|
||||||
public static bool IsDevMode { get; set; } = false;
|
public static bool IsDevMode { get; set; } = false;
|
||||||
|
|
||||||
|
|
||||||
|
public static string XDRIVE {
|
||||||
|
get {
|
||||||
|
|
||||||
|
if (Directory.Exists("X:\\Shares\\cvrdata")) {
|
||||||
|
return "X:\\Shares\\cvrdata";
|
||||||
|
} else {
|
||||||
|
return "X:";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -7,15 +7,16 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="11.3.0" />
|
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="13.4.0" />
|
||||||
<PackageReference Include="Magick.NET.Core" Version="11.3.0" />
|
<PackageReference Include="Magick.NET.Core" Version="13.4.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.16" />
|
<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.7" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
|
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
|
||||||
|
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
|
||||||
<PackageReference Include="System.Text.Json" Version="7.0.2" />
|
<PackageReference Include="System.Text.Json" Version="7.0.2" />
|
||||||
<PackageReference Include="System.Threading.RateLimiting" Version="7.0.0" />
|
<PackageReference Include="System.Threading.RateLimiting" Version="7.0.0" />
|
||||||
<PackageReference Include="ZXing.Net" Version="0.16.8" />
|
<PackageReference Include="ZXing.Net" Version="0.16.9" />
|
||||||
<FrameworkReference Include="Microsoft.WindowsDesktop.App" />
|
<FrameworkReference Include="Microsoft.WindowsDesktop.App" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user