Update function sendDeviceInfor to mail

This commit is contained in:
joseph le 2023-10-10 13:24:43 +07:00
parent 297ca11585
commit 3c91f9b5cf
1 changed files with 4 additions and 33 deletions

View File

@ -1,12 +1,10 @@
import Env from "@ioc:Adonis/Core/Env";
import fs from "fs";
import moment from "moment/moment";
import dotenv from "dotenv";
import nodeMailer from "nodemailer";
import LogDetectFile from "App/Models/LogDetectFile";
import InfoDevice from "App/Models/InfoDevice";
import KeyValue from "App/Models/KeyValue";
dotenv.config();
export const sendDeviceInfora = async () => {
try {
@ -21,12 +19,12 @@ export const sendDeviceInfora = async () => {
.map((obj) => obj.$attributes.value);
const listInformation = [];
let dataFile = await LogDetectFile.all();
// console.log(dataFile)
// console.log(dataFile)
let html = "";
//List file today
const listFile = fs.readdirSync(Env.get("FOLDER_LOGS"));
const listFile = fs
.readdirSync(Env.get("FOLDER_LOGS"))
.filter((f) => f.includes(date) && f.split(".")[f.split(".").length - 1]);
//Configure mail
const transporter = nodeMailer.createTransport({
pool: true,
@ -167,30 +165,6 @@ export const sendDeviceInfora = async () => {
// let memory =
if (index > 0) {
if (PID !== "" && SN !== "") {
// let RAM =
// showVersion
// .filter((line) => line.includes("bytes of memory"))
// .join("<br>")
// .match(regexMemory) !== null
// ? (
// parseInt(
// showVersion
// .filter((line) =>
// line.includes("bytes of memory")
// )
// .join("<br>")
// .match(regexMemory)[0]
// ) /
// 1024 /
// 1024
// ).toFixed(2) + "G"
// : "";
// let flash = showVersion
// .filter((line) =>
// line.toLocaleLowerCase().includes("compactflash")
// )
// .join("<br>");
listInformation.push({
PID: PID,
VID: VID,
@ -378,9 +352,6 @@ export const sendDeviceInfora = async () => {
await InfoDevice.createMany(listInformation);
}
}, 5000);
// const match = "show inventory".match(regexInventory);
// console.log(match)
} catch (error) {
console.log(error);
}