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()
|
||||
{
|
||||
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());
|
||||
}
|
||||
}//eoc
|
||||
|
||||
@@ -1,78 +1,78 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Sockeye.Models;
|
||||
using Sockeye.Api.ControllerHelpers;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using Sockeye.Biz;
|
||||
// using System.Threading.Tasks;
|
||||
// using Microsoft.AspNetCore.Mvc;
|
||||
// using Microsoft.AspNetCore.Routing;
|
||||
// using Microsoft.Extensions.Logging;
|
||||
// using Sockeye.Models;
|
||||
// using Sockeye.Api.ControllerHelpers;
|
||||
// using Newtonsoft.Json.Linq;
|
||||
// using System;
|
||||
// using Sockeye.Biz;
|
||||
|
||||
namespace Sockeye.Api.Controllers
|
||||
{
|
||||
// namespace Sockeye.Api.Controllers
|
||||
// {
|
||||
|
||||
[Produces("application/json")]
|
||||
[Route("api/order")]
|
||||
public class OrderController : ControllerBase //RECEIVE ORDERS FROM VENDOR (MyCommerce)
|
||||
{
|
||||
// [Produces("application/json")]
|
||||
// [Route("api/order")]
|
||||
// public class OrderController : ControllerBase //RECEIVE ORDERS FROM VENDOR (MyCommerce)
|
||||
// {
|
||||
|
||||
private readonly AyContext ct;
|
||||
private readonly ILogger<OrderController> log;
|
||||
private readonly ApiServerState serverState;
|
||||
// private readonly AyContext ct;
|
||||
// private readonly ILogger<OrderController> log;
|
||||
// private readonly ApiServerState serverState;
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
/// <param name="dbcontext"></param>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="apiServerState"></param>
|
||||
public OrderController(AyContext dbcontext, ILogger<OrderController> logger, ApiServerState apiServerState)
|
||||
{
|
||||
ct = dbcontext;
|
||||
log = logger;
|
||||
serverState = apiServerState;
|
||||
}
|
||||
//Receive an order notification from ShareIt
|
||||
//https://account.mycommerce.com/home/wiki/7479805
|
||||
[HttpPost("shareit")]
|
||||
public async Task<IActionResult> Post([FromHeader] string Authorization, [FromBody] JObject j)
|
||||
{
|
||||
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.");
|
||||
log.LogError(msg);
|
||||
await NotifyEventHelper.AddOpsProblemEvent(msg);
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
}
|
||||
// /// <summary>
|
||||
// /// ctor
|
||||
// /// </summary>
|
||||
// /// <param name="dbcontext"></param>
|
||||
// /// <param name="logger"></param>
|
||||
// /// <param name="apiServerState"></param>
|
||||
// public OrderController(AyContext dbcontext, ILogger<OrderController> logger, ApiServerState apiServerState)
|
||||
// {
|
||||
// ct = dbcontext;
|
||||
// log = logger;
|
||||
// serverState = apiServerState;
|
||||
// }
|
||||
// //Receive an order notification from ShareIt
|
||||
// //https://account.mycommerce.com/home/wiki/7479805
|
||||
// [HttpPost("shareit")]
|
||||
// public async Task<IActionResult> Post([FromHeader] string Authorization, [FromBody] JObject j)
|
||||
// {
|
||||
// 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.");
|
||||
// log.LogError(msg);
|
||||
// await NotifyEventHelper.AddOpsProblemEvent(msg);
|
||||
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
// }
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
try
|
||||
{
|
||||
(string username, string password) = Sockeye.Util.AutoOrderProcessingUtil.GetUsernameAndPasswordFromAuthorizeHeader(Authorization);
|
||||
if (username == "Y24PYYDQSA1L12905N5MKU" && password == "MA8GMQK2PC3FDNT1RTR68R")
|
||||
{
|
||||
//save it to the database
|
||||
var vn = new VendorNotification();
|
||||
vn.Created = DateTime.UtcNow;
|
||||
vn.VendorId = 1;//MyCommerce/shareit is vendor 1, for now that's all that's needed
|
||||
vn.VendorData = j.ToString();
|
||||
await ct.VendorNotification.AddAsync(vn);
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
log.LogError(ex, "OrderController/shareit - Exception processing vendor notification, returned 503 to vendor");
|
||||
await NotifyEventHelper.AddOpsProblemEvent("OrderController/shareit - Exception processing vendor notification, see log");
|
||||
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
|
||||
}
|
||||
//------------
|
||||
// if (!ModelState.IsValid)
|
||||
// {
|
||||
// return BadRequest(ModelState);
|
||||
// }
|
||||
// try
|
||||
// {
|
||||
// (string username, string password) = Sockeye.Util.AutoOrderProcessingUtil.GetUsernameAndPasswordFromAuthorizeHeader(Authorization);
|
||||
// if (username == "Y24PYYDQSA1L12905N5MKU" && password == "MA8GMQK2PC3FDNT1RTR68R")
|
||||
// {
|
||||
// //save it to the database
|
||||
// var vn = new VendorNotification();
|
||||
// vn.Created = DateTime.UtcNow;
|
||||
// vn.VendorId = 1;//MyCommerce/shareit is vendor 1, for now that's all that's needed
|
||||
// vn.VendorData = j.ToString();
|
||||
// await ct.VendorNotification.AddAsync(vn);
|
||||
// await ct.SaveChangesAsync();
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// log.LogError(ex, "OrderController/shareit - Exception processing vendor notification, returned 503 to vendor");
|
||||
// await NotifyEventHelper.AddOpsProblemEvent("OrderController/shareit - Exception processing vendor notification, see log");
|
||||
// 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
|
||||
// }
|
||||
// //------------
|
||||
|
||||
|
||||
}//eoc
|
||||
}//eons
|
||||
// }//eoc
|
||||
// }//eons
|
||||
@@ -128,7 +128,7 @@ namespace Sockeye
|
||||
fileTarget.FileName = Path.Combine(ServerBootConfig.SOCKEYE_LOG_PATH, "log-sockeye.txt");
|
||||
fileTarget.Layout = "${longdate}|${uppercase:${level}}|${logger}|${message:exceptionSeparator==>:withException=true}";
|
||||
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.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
|
||||
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
|
||||
|
||||
|
||||
@@ -519,7 +519,8 @@ namespace Sockeye.Biz
|
||||
else
|
||||
{
|
||||
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
|
||||
// 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))
|
||||
{
|
||||
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
|
||||
{
|
||||
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();
|
||||
|
||||
@@ -568,8 +572,9 @@ namespace Sockeye.Biz
|
||||
case ConsoleType.Error:
|
||||
try
|
||||
{
|
||||
var errorArgs = await Task.WhenAll(args.Message.Args.Select(arg => arg.ExecutionContext.EvaluateFunctionAsync("(arg) => arg instanceof Error ? arg.message : arg", arg)));
|
||||
PageLog.AppendLine($"ERROR: {args.Message.Text} args: [{string.Join<object>(", ", errorArgs)}]");
|
||||
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(", ", errorArgs)}]");
|
||||
}
|
||||
catch { }
|
||||
break;
|
||||
|
||||
@@ -863,7 +863,7 @@ namespace Sockeye.Util
|
||||
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user