add current ip to db
This commit is contained in:
@@ -17,6 +17,7 @@ class ReserveResultPojo {
|
||||
this.source_from = ""
|
||||
this.serial = ""
|
||||
this.hostName = hostName
|
||||
this.currentIp = ""
|
||||
this.created_at = new Date().toLocaleString()
|
||||
}
|
||||
|
||||
@@ -33,7 +34,8 @@ class ReserveResultPojo {
|
||||
source_from: this.source_from,
|
||||
serial: this.serial,
|
||||
created_at: this.created_at,
|
||||
hostName: this.hostName
|
||||
hostName: this.hostName,
|
||||
current_ip: this.currentIp
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -173,8 +173,6 @@ class CommandorPage {
|
||||
// await this.device.shell(swipCmd);
|
||||
await delay(3 * getRandomWaitTime());
|
||||
}
|
||||
// await this.openGoogle()
|
||||
// await delay(3 * getRandomWaitTime());
|
||||
await this.clickOnHomeBtn();
|
||||
await this.checkResultWithOcr();
|
||||
}
|
||||
@@ -762,6 +760,9 @@ class CommandorPage {
|
||||
}
|
||||
|
||||
async push_message_to_db(publishType, url) {
|
||||
let currentIp = await this.getCurrentIP()
|
||||
logWithDevice("currentIp is " + currentIp, this.device)
|
||||
|
||||
let splitedUrl = url.split("/");
|
||||
let id = splitedUrl[splitedUrl.length - 1];
|
||||
if (id === "register") {
|
||||
@@ -773,6 +774,7 @@ class CommandorPage {
|
||||
// save to mongoDb
|
||||
let reserve = ReserveResultPojo.create_from_contact(this.contact, id, url, this.choosedStore, publishType);
|
||||
reserve.source_from = this.device.model();
|
||||
reserve.currentIp = currentIp
|
||||
reserve.serial = this.device.serial();
|
||||
await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict())
|
||||
if (!this.page.isClosed()) {
|
||||
@@ -1002,11 +1004,6 @@ class CommandorPage {
|
||||
// reconnect to page and get url
|
||||
if (!this.isTerminated) {
|
||||
await this.connect_to_browser(OCRResult.SUCCESS)
|
||||
// if (!this.isTerminated) {
|
||||
// logWithDevice("will save success appointment", this.device)
|
||||
// await this.push_message_to_queue(PublishType.SUCCESS);
|
||||
// await this.closePage()
|
||||
// }
|
||||
}
|
||||
break;
|
||||
case
|
||||
@@ -1373,10 +1370,22 @@ class CommandorPage {
|
||||
await delay(2000);
|
||||
}
|
||||
|
||||
async startPage(device, activity) {
|
||||
let cmd = `adb -s ${device.serial()} shell am start -n ${activity}`
|
||||
logWithDevice("cmd is " + cmd, this.device)
|
||||
await exec(cmd);
|
||||
async getCurrentIP() {
|
||||
let findIp = ""
|
||||
try {
|
||||
findIp = await this.page.evaluate(async () => {
|
||||
const response = await fetch("https://api.ipify.org/", {
|
||||
"headers": {
|
||||
"content-type": "application/x-www-form-urlencoded; charset=UTF-8"
|
||||
},
|
||||
"method": "GET"
|
||||
});
|
||||
return await response.text();
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
return findIp
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user