add bindSerial param
This commit is contained in:
+13
-11
@@ -63,7 +63,7 @@ async function needToBook(contact, mongoManager, alreadyBooked) {
|
|||||||
return needToBook
|
return needToBook
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startBook(contactPojo, device, sender, selectedStore, audioAnalyse, alertBeep, port) {
|
async function startBook(contactPojo, device, sender, selectedStore, alertBeep, port) {
|
||||||
console.log(`model: ${device.model}`);
|
console.log(`model: ${device.model}`);
|
||||||
console.log(`serial: ${device.serial}`);
|
console.log(`serial: ${device.serial}`);
|
||||||
let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
||||||
@@ -74,7 +74,7 @@ async function startBook(contactPojo, device, sender, selectedStore, audioAnalys
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (await needToBook(contactPojo, mongoManager, alreadyBooked)) {
|
if (await needToBook(contactPojo, mongoManager, alreadyBooked)) {
|
||||||
let commandor = new CommandorPage(contactPojo, device, sender, mongoManager, selectedStore, audioAnalyse, alertBeep, port);
|
let commandor = new CommandorPage(contactPojo, device, sender, mongoManager, selectedStore, alertBeep, port);
|
||||||
//read contacts form excel
|
//read contacts form excel
|
||||||
return await commandor.loadPage();
|
return await commandor.loadPage();
|
||||||
} else {
|
} else {
|
||||||
@@ -82,14 +82,14 @@ async function startBook(contactPojo, device, sender, selectedStore, audioAnalys
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startWithList(contacts, device, sender, selectedStore, audioAnalyse, alertBeep, port) {
|
async function startWithList(contacts, device, sender, selectedStore, alertBeep, port) {
|
||||||
let duplicatedList = [].concat(contacts).concat(contacts).concat(contacts)
|
let duplicatedList = [].concat(contacts).concat(contacts).concat(contacts)
|
||||||
await duplicatedList.reduce(async (promise, contactPojo) => {
|
await duplicatedList.reduce(async (promise, contactPojo) => {
|
||||||
// This line will wait for the last async function to finish.
|
// This line will wait for the last async function to finish.
|
||||||
// The first iteration uses an already resolved Promise
|
// The first iteration uses an already resolved Promise
|
||||||
// so, it will immediately continue.
|
// so, it will immediately continue.
|
||||||
await promise;
|
await promise;
|
||||||
const contents = await startBook(contactPojo, device, sender, selectedStore, audioAnalyse, alertBeep, port);
|
const contents = await startBook(contactPojo, device, sender, selectedStore, alertBeep, port);
|
||||||
console.log(contents);
|
console.log(contents);
|
||||||
}, Promise.resolve());
|
}, Promise.resolve());
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ function getContactListForDevice(device, allContactList) {
|
|||||||
return contactList;
|
return contactList;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = true, alertBeep = false) {
|
async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', bindSerial = true, alertBeep = false) {
|
||||||
let allContactList = excelUtil.readContacts(pathToExcelFile);
|
let allContactList = excelUtil.readContacts(pathToExcelFile);
|
||||||
let contactList;
|
let contactList;
|
||||||
if (endNumber <= allContactList.length) {
|
if (endNumber <= allContactList.length) {
|
||||||
@@ -159,8 +159,6 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
|||||||
const output = execSync(cmd, {encoding: 'utf-8'}); // the default is 'buffer'
|
const output = execSync(cmd, {encoding: 'utf-8'}); // the default is 'buffer'
|
||||||
console.log('Output was:\n', output);
|
console.log('Output was:\n', output);
|
||||||
}
|
}
|
||||||
// start chrome
|
|
||||||
// device.shell("am start -n com.brave.browser/com.google.android.apps.chrome.Main")
|
|
||||||
return attributedPort
|
return attributedPort
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +188,7 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
|||||||
} else if (includeMode === DeviceExcludeMode.APPOINTMENT) {
|
} else if (includeMode === DeviceExcludeMode.APPOINTMENT) {
|
||||||
device_to_excludes = appointment_to_include
|
device_to_excludes = appointment_to_include
|
||||||
} else if (includeMode === DeviceExcludeMode.ZERO) {
|
} else if (includeMode === DeviceExcludeMode.ZERO) {
|
||||||
device_to_excludes = []
|
device_to_excludes = ["127.0.0.1:6555"]
|
||||||
}
|
}
|
||||||
let filteredDeviceList;
|
let filteredDeviceList;
|
||||||
if (includeMode === DeviceExcludeMode.ZERO) {
|
if (includeMode === DeviceExcludeMode.ZERO) {
|
||||||
@@ -205,10 +203,14 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
|||||||
for (let i = 0; i < filteredDeviceList.length; i++) {
|
for (let i = 0; i < filteredDeviceList.length; i++) {
|
||||||
let device = filteredDeviceList[i];
|
let device = filteredDeviceList[i];
|
||||||
let port = startForwordingForDevice(device)
|
let port = startForwordingForDevice(device)
|
||||||
let _contactList = listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1))
|
let _contactList = []
|
||||||
// let _contactList = getContactListForDevice(device, listWithoutBlackContact)
|
if (bindSerial) {
|
||||||
|
_contactList = getContactListForDevice(device, listWithoutBlackContact)
|
||||||
|
} else {
|
||||||
|
_contactList = listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1))
|
||||||
|
}
|
||||||
console.log("contactList: for device:" + device.serial + " has " + _contactList.length)
|
console.log("contactList: for device:" + device.serial + " has " + _contactList.length)
|
||||||
startWithList(_contactList, device, sender, selectedStore, audioAnalyse, alertBeep, port);
|
startWithList(_contactList, device, sender, selectedStore, alertBeep, port);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ function logWithDevice(message, device) {
|
|||||||
const searchTexts = ['hermes+rdv+online+paris', 'hermes+rdv+enligne+paris', 'hermes+rdv+en+ligne+paris', 'hermes+rendezvous+en+ligne+paris', 'hermes+appointment+online+paris', 'hermes+appointment+online+paris', 'appointment+hermes+paris+on+line', 'hermes+rendez+vous+online+paris', 'hermes+rendez+vous+paris+en+ligne', 'hermes+rendez+vous+paris+enligne', 'hermes+rendez+vous+paris+online', 'online+appointment+hermes+paris', 'hermes+online+appointment+paris', 'paris+hermes+online+appointment']
|
const searchTexts = ['hermes+rdv+online+paris', 'hermes+rdv+enligne+paris', 'hermes+rdv+en+ligne+paris', 'hermes+rendezvous+en+ligne+paris', 'hermes+appointment+online+paris', 'hermes+appointment+online+paris', 'appointment+hermes+paris+on+line', 'hermes+rendez+vous+online+paris', 'hermes+rendez+vous+paris+en+ligne', 'hermes+rendez+vous+paris+enligne', 'hermes+rendez+vous+paris+online', 'online+appointment+hermes+paris', 'hermes+online+appointment+paris', 'paris+hermes+online+appointment']
|
||||||
|
|
||||||
class CommandorPage {
|
class CommandorPage {
|
||||||
constructor(contact, device, sender, mongoManager, selectedStore = DEFAULT_STORE, audioAnalyse = false, alertBeep = false, port = 9000, shareCookiesWithRequests = true) {
|
constructor(contact, device, sender, mongoManager, selectedStore = DEFAULT_STORE, alertBeep = false, port = 9000, shareCookiesWithRequests = true) {
|
||||||
this.contact = contact;
|
this.contact = contact;
|
||||||
// to remove this line if we want to use store in contacts
|
// to remove this line if we want to use store in contacts
|
||||||
// this.contact.store = DEFAULT_STORE
|
// this.contact.store = DEFAULT_STORE
|
||||||
|
|||||||
Reference in New Issue
Block a user