Many more changes to get to a build for testing
This commit is contained in:
@@ -37,7 +37,8 @@ namespace Sockeye.Api.Controllers
|
|||||||
public async Task<IActionResult> Get()
|
public async Task<IActionResult> Get()
|
||||||
{
|
{
|
||||||
var report = await _healthCheckService.CheckHealthAsync();
|
var report = await _healthCheckService.CheckHealthAsync();
|
||||||
Response.Headers.Append("Cache-Control", "no-store, no-cache");
|
//Response.Headers.Append("Cache-Control", "no-store, no-cache");
|
||||||
|
Response.Headers["Cache-Control"] = "no-store, no-cache";
|
||||||
return report.Status == HealthStatus.Healthy ? Ok(report.Status.ToString()) : StatusCode(503, report.Status.ToString());
|
return report.Status == HealthStatus.Healthy ? Ok(report.Status.ToString()) : StatusCode(503, report.Status.ToString());
|
||||||
}
|
}
|
||||||
}//eoc
|
}//eoc
|
||||||
|
|||||||
@@ -1,78 +1,78 @@
|
|||||||
using System.Threading.Tasks;
|
// using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
// using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Routing;
|
// using Microsoft.AspNetCore.Routing;
|
||||||
using Microsoft.Extensions.Logging;
|
// using Microsoft.Extensions.Logging;
|
||||||
using Sockeye.Models;
|
// using Sockeye.Models;
|
||||||
using Sockeye.Api.ControllerHelpers;
|
// using Sockeye.Api.ControllerHelpers;
|
||||||
using Newtonsoft.Json.Linq;
|
// using Newtonsoft.Json.Linq;
|
||||||
using System;
|
// using System;
|
||||||
using Sockeye.Biz;
|
// using Sockeye.Biz;
|
||||||
|
|
||||||
namespace Sockeye.Api.Controllers
|
// namespace Sockeye.Api.Controllers
|
||||||
{
|
// {
|
||||||
|
|
||||||
[Produces("application/json")]
|
// [Produces("application/json")]
|
||||||
[Route("api/order")]
|
// [Route("api/order")]
|
||||||
public class OrderController : ControllerBase //RECEIVE ORDERS FROM VENDOR (MyCommerce)
|
// public class OrderController : ControllerBase //RECEIVE ORDERS FROM VENDOR (MyCommerce)
|
||||||
{
|
// {
|
||||||
|
|
||||||
private readonly AyContext ct;
|
// private readonly AyContext ct;
|
||||||
private readonly ILogger<OrderController> log;
|
// private readonly ILogger<OrderController> log;
|
||||||
private readonly ApiServerState serverState;
|
// private readonly ApiServerState serverState;
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// ctor
|
// /// ctor
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
/// <param name="dbcontext"></param>
|
// /// <param name="dbcontext"></param>
|
||||||
/// <param name="logger"></param>
|
// /// <param name="logger"></param>
|
||||||
/// <param name="apiServerState"></param>
|
// /// <param name="apiServerState"></param>
|
||||||
public OrderController(AyContext dbcontext, ILogger<OrderController> logger, ApiServerState apiServerState)
|
// public OrderController(AyContext dbcontext, ILogger<OrderController> logger, ApiServerState apiServerState)
|
||||||
{
|
// {
|
||||||
ct = dbcontext;
|
// ct = dbcontext;
|
||||||
log = logger;
|
// log = logger;
|
||||||
serverState = apiServerState;
|
// serverState = apiServerState;
|
||||||
}
|
// }
|
||||||
//Receive an order notification from ShareIt
|
// //Receive an order notification from ShareIt
|
||||||
//https://account.mycommerce.com/home/wiki/7479805
|
// //https://account.mycommerce.com/home/wiki/7479805
|
||||||
[HttpPost("shareit")]
|
// [HttpPost("shareit")]
|
||||||
public async Task<IActionResult> Post([FromHeader] string Authorization, [FromBody] JObject j)
|
// public async Task<IActionResult> Post([FromHeader] string Authorization, [FromBody] JObject j)
|
||||||
{
|
// {
|
||||||
if (!serverState.IsOpen)
|
// if (!serverState.IsOpen)
|
||||||
{
|
// {
|
||||||
var msg = ("Server state was not open when Vendor Order notification received; returning 503 (temp. unavailable) to them, they should retry when server open again.");
|
// var msg = ("Server state was not open when Vendor Order notification received; returning 503 (temp. unavailable) to them, they should retry when server open again.");
|
||||||
log.LogError(msg);
|
// log.LogError(msg);
|
||||||
await NotifyEventHelper.AddOpsProblemEvent(msg);
|
// await NotifyEventHelper.AddOpsProblemEvent(msg);
|
||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
// if (!ModelState.IsValid)
|
||||||
{
|
// {
|
||||||
return BadRequest(ModelState);
|
// return BadRequest(ModelState);
|
||||||
}
|
// }
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
(string username, string password) = Sockeye.Util.AutoOrderProcessingUtil.GetUsernameAndPasswordFromAuthorizeHeader(Authorization);
|
// (string username, string password) = Sockeye.Util.AutoOrderProcessingUtil.GetUsernameAndPasswordFromAuthorizeHeader(Authorization);
|
||||||
if (username == "Y24PYYDQSA1L12905N5MKU" && password == "MA8GMQK2PC3FDNT1RTR68R")
|
// if (username == "Y24PYYDQSA1L12905N5MKU" && password == "MA8GMQK2PC3FDNT1RTR68R")
|
||||||
{
|
// {
|
||||||
//save it to the database
|
// //save it to the database
|
||||||
var vn = new VendorNotification();
|
// var vn = new VendorNotification();
|
||||||
vn.Created = DateTime.UtcNow;
|
// vn.Created = DateTime.UtcNow;
|
||||||
vn.VendorId = 1;//MyCommerce/shareit is vendor 1, for now that's all that's needed
|
// vn.VendorId = 1;//MyCommerce/shareit is vendor 1, for now that's all that's needed
|
||||||
vn.VendorData = j.ToString();
|
// vn.VendorData = j.ToString();
|
||||||
await ct.VendorNotification.AddAsync(vn);
|
// await ct.VendorNotification.AddAsync(vn);
|
||||||
await ct.SaveChangesAsync();
|
// await ct.SaveChangesAsync();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
log.LogError(ex, "OrderController/shareit - Exception processing vendor notification, returned 503 to vendor");
|
// log.LogError(ex, "OrderController/shareit - Exception processing vendor notification, returned 503 to vendor");
|
||||||
await NotifyEventHelper.AddOpsProblemEvent("OrderController/shareit - Exception processing vendor notification, see log");
|
// await NotifyEventHelper.AddOpsProblemEvent("OrderController/shareit - Exception processing vendor notification, see log");
|
||||||
return StatusCode(503);//ask it to retry again later
|
// return StatusCode(503);//ask it to retry again later
|
||||||
}
|
// }
|
||||||
return Ok("ok");//shareit notifier looks for an OK response to know if it should resend or not https://account.mycommerce.com/home/wiki/7479805
|
// return Ok("ok");//shareit notifier looks for an OK response to know if it should resend or not https://account.mycommerce.com/home/wiki/7479805
|
||||||
}
|
// }
|
||||||
//------------
|
// //------------
|
||||||
|
|
||||||
|
|
||||||
}//eoc
|
// }//eoc
|
||||||
}//eons
|
// }//eons
|
||||||
@@ -128,7 +128,7 @@ namespace Sockeye
|
|||||||
fileTarget.FileName = Path.Combine(ServerBootConfig.SOCKEYE_LOG_PATH, "log-sockeye.txt");
|
fileTarget.FileName = Path.Combine(ServerBootConfig.SOCKEYE_LOG_PATH, "log-sockeye.txt");
|
||||||
fileTarget.Layout = "${longdate}|${uppercase:${level}}|${logger}|${message:exceptionSeparator==>:withException=true}";
|
fileTarget.Layout = "${longdate}|${uppercase:${level}}|${logger}|${message:exceptionSeparator==>:withException=true}";
|
||||||
fileTarget.ArchiveFileName = Path.Combine(ServerBootConfig.SOCKEYE_LOG_PATH, "log-sockeye-{#}.txt");
|
fileTarget.ArchiveFileName = Path.Combine(ServerBootConfig.SOCKEYE_LOG_PATH, "log-sockeye-{#}.txt");
|
||||||
fileTarget.ArchiveNumbering = ArchiveNumberingMode.Rolling;//so expect to see 1 to 10 or 0 to ten as may be
|
//fileTarget.ArchiveNumbering = ArchiveNumberingMode.Rolling;//so expect to see 1 to 10 or 0 to ten as may be
|
||||||
fileTarget.ArchiveAboveSize = 1000000;//1mb maximum file size
|
fileTarget.ArchiveAboveSize = 1000000;//1mb maximum file size
|
||||||
fileTarget.MaxArchiveFiles = 9;//max 10 files totalling 10mb, the current log-sockeye.txt and log-sockeye-[0-9].txt
|
fileTarget.MaxArchiveFiles = 9;//max 10 files totalling 10mb, the current log-sockeye.txt and log-sockeye-[0-9].txt
|
||||||
|
|
||||||
@@ -197,7 +197,9 @@ namespace Sockeye
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NLog: setup the logger first to catch all errors
|
// NLog: setup the logger first to catch all errors
|
||||||
var logger = NLogBuilder.ConfigureNLog(logConfig).GetLogger("BOOT");
|
// var logger = NLogBuilder.ConfigureNLog(logConfig).GetLogger("BOOT");
|
||||||
|
NLog.LogManager.Configuration = logConfig;
|
||||||
|
var logger = NLog.LogManager.GetLogger("BOOT");
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -519,7 +519,8 @@ namespace Sockeye.Biz
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
log.LogDebug($"Windows: Calling browserFetcher download async now:");
|
log.LogDebug($"Windows: Calling browserFetcher download async now:");
|
||||||
await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultChromiumRevision);
|
//await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultChromiumRevision);
|
||||||
|
await new BrowserFetcher().DownloadAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -532,17 +533,20 @@ namespace Sockeye.Biz
|
|||||||
|
|
||||||
//Keep for debugging headfully
|
//Keep for debugging headfully
|
||||||
// var DefaultArgs = "--no-sandbox";
|
// var DefaultArgs = "--no-sandbox";
|
||||||
var DefaultArgs = "--headless --no-sandbox";
|
//var DefaultArgs = "--headless --no-sandbox";
|
||||||
|
var DefaultArgs = new[] { "--no-sandbox" };
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(ServerBootConfig.SOCKEYE_REPORT_RENDER_BROWSER_PARAMS))
|
if (!string.IsNullOrWhiteSpace(ServerBootConfig.SOCKEYE_REPORT_RENDER_BROWSER_PARAMS))
|
||||||
{
|
{
|
||||||
log.LogDebug($"SOCKEYE_REPORT_RENDER_BROWSER_PARAMS will be used: {ServerBootConfig.SOCKEYE_REPORT_RENDER_BROWSER_PARAMS}");
|
log.LogDebug($"SOCKEYE_REPORT_RENDER_BROWSER_PARAMS will be used: {ServerBootConfig.SOCKEYE_REPORT_RENDER_BROWSER_PARAMS}");
|
||||||
lo.Args = new string[] { $"{ServerBootConfig.SOCKEYE_REPORT_RENDER_BROWSER_PARAMS}" };// SOCKEYE_REPORT_RENDER_BROWSER_PARAMS
|
//lo.Args = new string[] { $"{ServerBootConfig.SOCKEYE_REPORT_RENDER_BROWSER_PARAMS}" };// SOCKEYE_REPORT_RENDER_BROWSER_PARAMS
|
||||||
|
lo.Args = ServerBootConfig.SOCKEYE_REPORT_RENDER_BROWSER_PARAMS.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log.LogDebug($"SOCKEYE_REPORT_RENDER_BROWSER_PARAMS not set, using defaults '{DefaultArgs}'");
|
log.LogDebug($"SOCKEYE_REPORT_RENDER_BROWSER_PARAMS not set, using defaults '{DefaultArgs}'");
|
||||||
lo.Args = new string[] { DefaultArgs };
|
//lo.Args = new string[] { DefaultArgs };
|
||||||
|
lo.Args = DefaultArgs;
|
||||||
}
|
}
|
||||||
System.Text.StringBuilder PageLog = new System.Text.StringBuilder();
|
System.Text.StringBuilder PageLog = new System.Text.StringBuilder();
|
||||||
|
|
||||||
@@ -568,8 +572,9 @@ namespace Sockeye.Biz
|
|||||||
case ConsoleType.Error:
|
case ConsoleType.Error:
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var errorArgs = await Task.WhenAll(args.Message.Args.Select(arg => arg.ExecutionContext.EvaluateFunctionAsync("(arg) => arg instanceof Error ? arg.message : arg", arg)));
|
var errorArgs = await Task.WhenAll(args.Message.Args.Select(arg => arg.EvaluateFunctionAsync("(arg) => arg instanceof Error ? arg.message : arg")));
|
||||||
PageLog.AppendLine($"ERROR: {args.Message.Text} args: [{string.Join<object>(", ", errorArgs)}]");
|
// PageLog.AppendLine($"ERROR: {args.Message.Text} args: [{string.Join<object>(", ", errorArgs)}]");
|
||||||
|
PageLog.AppendLine($"ERROR: {args.Message.Text} args: [{string.Join(", ", errorArgs)}]");
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -863,7 +863,7 @@ namespace Sockeye.Util
|
|||||||
|
|
||||||
using (var file = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
using (var file = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||||
{
|
{
|
||||||
file.Read(bytes, 0, bytes.Length);
|
file.ReadExactly(bytes, 0, bytes.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
var headerPos = BitConverter.ToInt32(bytes, peHeaderOffset);
|
var headerPos = BitConverter.ToInt32(bytes, peHeaderOffset);
|
||||||
|
|||||||
Reference in New Issue
Block a user