Skip to content

Commit

Permalink
fix: parallel windows hos-000 (#207)
Browse files Browse the repository at this point in the history
* fix: parallel windows hos-000

* feat: nsk hos-000
  • Loading branch information
hajonsoft authored Feb 24, 2024
1 parent 8126751 commit 6e62348
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hajonsoft-eagle",
"version": "2.6.9",
"version": "2.6.14",
"description": "HAJonSoft node app to submit passengers to visa systems",
"main": "index.js",
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/imap.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ async function fetchNusukIMAPOTP(recipient, password, subject, callback, isNotVi
callback("Error: " + err);
});

imap.once("end", function () {
callback("Error: Connection ended");
});
// imap.once("end", function () {
// callback("Error: Connection ended");
// });

imap.connect();
}
Expand Down
34 changes: 20 additions & 14 deletions src/nsh.js
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,9 @@ async function runParallel() {
for (let index = 0; index < Math.min(leads.length, 15); index++) {
const passenger = leads[index];
const newArgs = process.argv.map((v) => {
if (v.includes("/node")) {
return `"${v}"`;
}
if (v.startsWith("--submissionId")) {
return `${v} --passengerIds=${passenger.id} --auto -windowed`;
}
Expand All @@ -1510,22 +1513,25 @@ async function runParallel() {
}
return v;
});
commands.push(newArgs.join(" "));
const command = newArgs.join(" ");
console.log("📢[nsh.js:1517]: command: ", command);
commands.push(command);
childProcess.exec(command, function (error, stdout, stderr) {
if (error) {
console.log("Parallel Run Error: " + error.code);
}
if (stdout) {
console.log("Parallel Run: " + stdout);
}
if (stderr) {
console.log("Parallel Run: " + stderr);
}
});
}
const newCommand = commands.join(" & ");
console.log("📢[nsh.js:1491]: oneCommand: ", newCommand);
// const newCommand = commands.join(" & ");
// console.log("📢[nsh.js:1491]: oneCommand: ", newCommand);
// run the command using child process
childProcess.exec(newCommand, function (error, stdout, stderr) {
if (error) {
console.log("Parallel Run Error: " + error.code);
}
if (stdout) {
console.log("Parallel Run: " + stdout);
}
if (stderr) {
console.log("Parallel Run: " + stderr);
}
});


await page.browser().close();
}
Expand Down
18 changes: 16 additions & 2 deletions src/nsk.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,8 @@ async function pageContentHandler(currentConfig) {
}
}

async function pasteSimulatedPassport(passenger) {
async function pasteSimulatedPassport() {
const passenger = data.travellers[util.getSelectedTraveler()];
const blankPassportPath = getPath(`${passenger.passportNumber}_mrz.jpg`);
// Generate simulated passport image using the browser canvas api
const dataUrl = await page.evaluate((_passenger) => {
Expand All @@ -571,7 +572,7 @@ async function pasteSimulatedPassport(passenger) {
ctx.fillText(
_passenger.codeline?.replace(/\n/g, "")?.substring(0, 44),
14,
canvas.height - 60
canvas.height - 70
);
ctx.fillText(
_passenger.codeline?.replace(/\n/g, "")?.substring(44),
Expand Down Expand Up @@ -781,6 +782,19 @@ async function sendCurrentPassenger() {
},
});

await util.commander(page, {
controller: {
selector: "#mutamerForm > div.modal-body > div:nth-child(3) > h4",
title: "Simulate passport",
arabicTitle: "محاكاة جواز السفر",
name: "simulatePassport",
action: async () => {
// Open name fields for editing
await pasteSimulatedPassport();
},
},
});

await util.commit(page, passengersConfig.details, passenger);
const email = suggestEmail(passenger);
if (data.system.email.startsWith("@")) {
Expand Down

0 comments on commit 6e62348

Please sign in to comment.