diff --git a/server/Controllers/HealthController.cs b/server/Controllers/HealthController.cs index 00bdaa4..57e0a4c 100644 --- a/server/Controllers/HealthController.cs +++ b/server/Controllers/HealthController.cs @@ -37,7 +37,8 @@ namespace Sockeye.Api.Controllers public async Task 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 diff --git a/server/Controllers/OrderController.cs b/server/Controllers/OrderController.cs index d3c92c8..e58f654 100644 --- a/server/Controllers/OrderController.cs +++ b/server/Controllers/OrderController.cs @@ -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 log; - private readonly ApiServerState serverState; +// private readonly AyContext ct; +// private readonly ILogger log; +// private readonly ApiServerState serverState; - /// - /// ctor - /// - /// - /// - /// - public OrderController(AyContext dbcontext, ILogger 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 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)); - } +// /// +// /// ctor +// /// +// /// +// /// +// /// +// public OrderController(AyContext dbcontext, ILogger 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 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 \ No newline at end of file +// }//eoc +// }//eons \ No newline at end of file diff --git a/server/Program.cs b/server/Program.cs index 1be6757..6151ed7 100644 --- a/server/Program.cs +++ b/server/Program.cs @@ -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 diff --git a/server/biz/ReportBiz.cs b/server/biz/ReportBiz.cs index 1c72364..89c09d7 100644 --- a/server/biz/ReportBiz.cs +++ b/server/biz/ReportBiz.cs @@ -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(", ", 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(", ", errorArgs)}]"); + PageLog.AppendLine($"ERROR: {args.Message.Text} args: [{string.Join(", ", errorArgs)}]"); } catch { } break; diff --git a/server/util/FileUtil.cs b/server/util/FileUtil.cs index b65474a..d1294c4 100644 --- a/server/util/FileUtil.cs +++ b/server/util/FileUtil.cs @@ -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);