update function sync SN to ERP

This commit is contained in:
joseph le 2023-09-26 16:50:19 +07:00
parent e88666aa98
commit 3c51af8631
2 changed files with 73 additions and 19 deletions

View File

@ -18,10 +18,23 @@ export default class ErpsController {
// console.log("check!")
const listLog: string[] = [];
const response = await axios.get("http://192.168.5.7:8080/");
const data = response.data;
const arrayLine = data
const responseAUTO = await axios.get(
"http://192.168.5.7:8080/AUTOlog/"
);
let data1 = response.data
.split("\n")
.filter((i) => i.search("<a href") !== -1 && i.search(".log") !== -1);
let data2 = responseAUTO.data
.split("\n")
.filter((i) => i.search("<a href") !== -1 && i.search(".log") !== -1);
const arrayLine = data1.concat(data2);
// const arrayLineAUTO = data
// .split("\n")
// .filter((i) => i.search("<a href") !== -1 && i.search(".log") !== -1);
arrayLine.map((u) => {
let temp = u
.slice(u.search("<a ") + 9, u.search("</a>"))
@ -32,7 +45,7 @@ export default class ErpsController {
parseInt(temp?.split("-")[0]) <= to
) {
listLog.push(
"http://192.168.5.7:8080/" +
(u.slice(u.search("<a ") + 9, u.search("</a>")).split(">")[1].includes("AUTO")?"http://192.168.5.7:8080/AUTOlog/":"http://192.168.5.7:8080/") +
u.slice(u.search("<a ") + 9, u.search("</a>")).split(">")[1] +
" "
);

View File

@ -1,5 +1,7 @@
// const puppeteer = require("puppeteer");
const axios = require("axios");
// (async () => {
// // Launch a headless browser
// const browser = await puppeteer.launch({
@ -176,22 +178,61 @@
// // Close the browser.
// await browser2.close();
// })();
const zulip = require("zulip-js");
// const zulip = require("zulip-js");
(async () => {
const config = {
username: "networktool-bot@zulip.ipsupply.com.au",
apiKey: "0jMAmOuhfLvBqKJikv5oAkyNM4RIEoAM",
realm: "https://zulip.ipsupply.com.au",
};
const client = await zulip(config);
const user_id = 45;
let params = {
to: "joseph.le@apactech.io",
type: "private",
content: "With mirth and laughter let old wrinkles come.",
};
console.log(await client.messages.send(params))
// (async () => {
// const config = {
// username: "networktool-bot@zulip.ipsupply.com.au",
// apiKey: "0jMAmOuhfLvBqKJikv5oAkyNM4RIEoAM",
// realm: "https://zulip.ipsupply.com.au",
// };
// const client = await zulip(config);
// const user_id = 45;
// let params = {
// to: "joseph.le@apactech.io",
// type: "private",
// content: "With mirth and laughter let old wrinkles come.",
// };
// console.log(await client.messages.send(params))
// })()
(async()=>{
let listLog = []
let from = 20230926
let to = 20230926
const response = await axios.get("http://192.168.5.7:8080/");
const responseAUTO = await axios.get(
"http://192.168.5.7:8080/AUTOlog/"
);
let data1 = response.data.split("\n")
.filter((i) => i.search("<a href") !== -1 && i.search(".log") !== -1);
let data2 = responseAUTO.data.split("\n")
.filter((i) => i.search("<a href") !== -1 && i.search(".log") !== -1);
const arrayLine = data1.concat(data2)
// const arrayLineAUTO = data
// .split("\n")
// .filter((i) => i.search("<a href") !== -1 && i.search(".log") !== -1);
arrayLine.map((u) => {
let temp = u
.slice(u.search("<a ") + 9, u.search("</a>"))
.split(">")[1];
if (
parseInt(temp?.split("-")[0]) >= from &&
parseInt(temp?.split("-")[0]) <= to
) {
listLog.push(
(u.slice(u.search("<a ") + 9, u.search("</a>")).split(">")[1].includes("AUTO")?"http://192.168.5.7:8080/AUTOlog/":"http://192.168.5.7:8080/") +
u.slice(u.search("<a ") + 9, u.search("</a>")).split(">")[1] +
" "
);
}
});
console.log(listLog)
})()