support de message queue

This commit is contained in:
2024-01-24 09:02:46 +01:00
parent aea402d11e
commit 3a7ec384c3
4 changed files with 32 additions and 24 deletions
+5 -1
View File
@@ -19,7 +19,11 @@ class ExcelUtil {
if (store === undefined || store.length === 0) {
store = "random"
}
let newContact = new ContactPojo(phoneNumber, passportNumber, lastName, firstName, mail, store);
let ipCountry = info[5];
if (ipCountry === undefined || ipCountry.length === 0) {
ipCountry = "FR"
}
let newContact = new ContactPojo(phoneNumber, passportNumber, lastName, firstName, mail, store, ipCountry);
contactList.push(newContact);
}
}
+2 -3
View File
@@ -1,15 +1,14 @@
class ContactPojo {
constructor(phoneNumber, passportNumber, lastName, firstName, mail, store) {
constructor(phoneNumber, passportNumber, lastName, firstName, mail, store, ipCountry) {
this.phoneNumber = phoneNumber;
this.passportNumber = passportNumber;
this.lastName = lastName;
this.firstName = firstName;
this.mail = mail;
this.store = store;
this.ipCountry = ipCountry;
}
}
module.exports = ContactPojo
+5 -4
View File
@@ -1,7 +1,8 @@
const amqp = require("amqplib");
const QUEUE_HOST = "amqp://appointment:ZyuhJZ2xEYWhElhpJjy7YEpZGZwNYJz2fHIu@appointment.lpaconsulting.fr:5672"
const REQUEST_DATA_QUEUE = 'REQUEST_DATA';
const REQUEST_DATA_QUEUE_FR = 'REQUEST_DATA';
const REQUEST_DATA_QUEUE_DE = 'REQUEST_DATA_DE';
class Sender {
channel;
@@ -10,11 +11,11 @@ class Sender {
async initConnection() {
this.connection = await amqp.connect(QUEUE_HOST);
this.channel = await this.connection.createChannel();
await this.channel.assertQueue(REQUEST_DATA_QUEUE, {persistent: true});
await this.channel.assertQueue(REQUEST_DATA_QUEUE_FR, {persistent: true});
}
sendMessage(msg) {
this.channel.sendToQueue(REQUEST_DATA_QUEUE, Buffer.from(msg))
sendMessage(msg, queue_name = REQUEST_DATA_QUEUE_FR) {
this.channel.sendToQueue(queue_name, Buffer.from(msg))
}
}
+20 -16
View File
@@ -870,7 +870,11 @@ class CommandorPage {
cookiesString = cookiesString + cookie.name + "=" + cookie.value + ";"
})
console.log(cookiesString);
this.sender.sendMessage(cookiesString)
if (this.contact.ipCountry === "DE")
this.sender.sendMessage(cookiesString, "REQUEST_DATA_DE")
else
this.sender.sendMessage(cookiesString)
// let content = await this.page.content()
// console.log(content)
await this.page.bringToFront();
@@ -1202,21 +1206,21 @@ class CommandorPage {
async enableDisableAirPlanMode() {
logWithDevice("will enable/disable airplane mode", this.device)
try {
// await this.device.shell("cmd connectivity airplane-mode enable")
await exceutShellCmd(this.device, "cmd connectivity airplane-mode enable")
await delay(1000)
await exceutShellCmd(this.device, "cmd connectivity airplane-mode disable")
// await this.device.shell("cmd connectivity airplane-mode disable")
await delay(2000)
} catch (e) {
try {
await this.device.shell("cmd connectivity airplane-mode disable")
} catch (e) {
console.log(e)
}
console.log(e)
}
// try {
// // await this.device.shell("cmd connectivity airplane-mode enable")
// await exceutShellCmd(this.device, "cmd connectivity airplane-mode enable")
// await delay(1000)
// await exceutShellCmd(this.device, "cmd connectivity airplane-mode disable")
// // await this.device.shell("cmd connectivity airplane-mode disable")
// await delay(2000)
// } catch (e) {
// try {
// await this.device.shell("cmd connectivity airplane-mode disable")
// } catch (e) {
// console.log(e)
// }
// console.log(e)
// }
}
async tapGoogleDisconnectBtn() {