feature/IO-2924-Refactor-Production-Board-For-Sockets - Checkpoint

Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
Dave Richer
2024-09-16 11:48:17 -04:00
parent a2d95dbce3
commit 5c54cf6c44
7 changed files with 30 additions and 29 deletions

View File

@@ -60,12 +60,11 @@ async function registerSocketEvents(socket) {
// CDK-specific socket events
function registerCdkEvents(socket) {
socket.on("cdk-export-job", (jobid) => CdkJobExport(socket, jobid));
socket.on("cdk-selected-customer", async (selectedCustomerId) => {
await createLogEvent(socket, "DEBUG", `User selected customer ID ${selectedCustomerId}`);
CdkSelectedCustomer(socket, selectedCustomerId).catch((err) =>
console.error(`Error in cdk-selected-customer: ${err}`)
);
await setSessionData(socket.id, "selectedCustomer", selectedCustomerId);
CdkSelectedCustomer(socket, selectedCustomerId);
await setSessionData(socket.id, "selectedCustomerId ", selectedCustomerId);
});
socket.on("cdk-get-makes", async (cdk_dealerid, callback) => {
@@ -73,16 +72,15 @@ function registerCdkEvents(socket) {
const makes = await CdkGetMakes(socket, cdk_dealerid);
callback(makes);
} catch (error) {
await createLogEvent(socket, "ERROR", `Error in cdk-get-makes WS call. ${JSON.stringify(error)}`);
await createLogEvent(socket, "ERROR", `Error in cdk-get-makes WS call. ${JSON.stringify(error, null, 2)}`);
}
});
socket.on("cdk-calculate-allocations", async (jobid, callback) => {
const allocations = await CdkCalculateAllocations(socket, jobid);
await createLogEvent(socket, "DEBUG", `Allocations calculated.`);
await createLogEvent(socket, "TRACE", `Allocations details: ${JSON.stringify(allocations)}`);
await createLogEvent(socket, "TRACE", `Allocations details: ${JSON.stringify(allocations, null, 2)}`);
callback(allocations);
await setSessionData(socket.id, "cdk_allocations", allocations);
});
}
@@ -91,18 +89,18 @@ function registerPbsArEvents(socket) {
socket.on("pbs-calculate-allocations", async (jobid, callback) => {
const allocations = await CdkCalculateAllocations(socket, jobid);
await createLogEvent(socket, "DEBUG", `PBS AR allocations calculated.`);
await createLogEvent(socket, "TRACE", `Allocations details: ${JSON.stringify(allocations)}`);
await createLogEvent(socket, "TRACE", `Allocations details: ${JSON.stringify(allocations, null, 2)}`);
callback(allocations);
await setSessionData(socket.id, "pbs_allocations", allocations);
});
socket.on("pbs-export-job", (jobid) => PbsExportJob(socket, jobid));
socket.on("pbs-selected-customer", async (selectedCustomerId) => {
await createLogEvent(socket, "DEBUG", `PBS AR selected customer ID ${selectedCustomerId}`);
PbsSelectedCustomer(socket, selectedCustomerId).catch((err) =>
console.error(`Error in pbs-selected-customer: ${err}`)
);
await setSessionData(socket.id, "selectedCustomer", selectedCustomerId);
await setSessionData(socket.id, "selectedCustomerId", selectedCustomerId);
});
}
@@ -111,13 +109,13 @@ function registerPbsApEvents(socket) {
socket.on("pbs-calculate-allocations-ap", async (billids, callback) => {
const allocations = await PbsCalculateAllocationsAp(socket, billids);
await createLogEvent(socket, "DEBUG", `PBS AP allocations calculated.`);
await createLogEvent(socket, "TRACE", `Allocations details: ${JSON.stringify(allocations)}`);
await createLogEvent(socket, "TRACE", `Allocations details: ${JSON.stringify(allocations, null, 2)}`);
callback(allocations);
await setSessionData(socket.id, "pbs_ap_allocations", allocations);
});
socket.on("pbs-export-ap", async ({ billids, txEnvelope }) => {
await setSessionData(socket.id, "pbs_txEnvelope", txEnvelope);
await setSessionData(socket.id, "txEnvelope", txEnvelope);
PbsExportAp(socket, {
billids,
txEnvelope