IO-3027 Add in bodyshop.id to logging in SFTP
Signed-off-by: Allan Carr <allan.carr@thinkimex.com>
This commit is contained in:
@@ -125,6 +125,7 @@ async function processShopData(shopsToProcess, start, end, skipUpload, allXMLRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
const xmlObj = {
|
const xmlObj = {
|
||||||
|
bodyshopid: bodyshop.id,
|
||||||
imexshopid: bodyshop.imexshopid,
|
imexshopid: bodyshop.imexshopid,
|
||||||
xml: builder.create({}, autoHouseObject).end({ allowEmptyTags: true }),
|
xml: builder.create({}, autoHouseObject).end({ allowEmptyTags: true }),
|
||||||
filename: `IM_${bodyshop.autohouseid}_${moment().format("DDMMYYYY_HHMMss")}.xml`,
|
filename: `IM_${bodyshop.autohouseid}_${moment().format("DDMMYYYY_HHMMss")}.xml`,
|
||||||
@@ -178,7 +179,10 @@ async function processShopData(shopsToProcess, start, end, skipUpload, allXMLRes
|
|||||||
async function uploadViaSFTP(xmlObj) {
|
async function uploadViaSFTP(xmlObj) {
|
||||||
const sftp = new Client();
|
const sftp = new Client();
|
||||||
sftp.on("error", (errors) =>
|
sftp.on("error", (errors) =>
|
||||||
logger.log("autohouse-sftp-connection-error", "ERROR", "api", null, { error: errors.message, stack: errors.stack })
|
logger.log("autohouse-sftp-connection-error", "ERROR", "api", xmlObj.bodyshopid, {
|
||||||
|
error: errors.message,
|
||||||
|
stack: errors.stack
|
||||||
|
})
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
//Connect to the FTP and upload all.
|
//Connect to the FTP and upload all.
|
||||||
@@ -186,13 +190,13 @@ async function uploadViaSFTP(xmlObj) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
xmlObj.result = await sftp.put(Buffer.from(xmlObj.xml), `${xmlObj.filename}`);
|
xmlObj.result = await sftp.put(Buffer.from(xmlObj.xml), `${xmlObj.filename}`);
|
||||||
logger.log("autohouse-sftp-upload", "DEBUG", "api", null, {
|
logger.log("autohouse-sftp-upload", "DEBUG", "api", xmlObj.bodyshopid, {
|
||||||
imexshopid: xmlObj.imexshopid,
|
imexshopid: xmlObj.imexshopid,
|
||||||
filename: xmlObj.filename,
|
filename: xmlObj.filename,
|
||||||
result: xmlObj.result
|
result: xmlObj.result
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.log("autohouse-sftp-upload-error", "ERROR", "api", null, {
|
logger.log("autohouse-sftp-upload-error", "ERROR", "api", xmlObj.bodyshopid, {
|
||||||
filename: xmlObj.filename,
|
filename: xmlObj.filename,
|
||||||
error: error.message,
|
error: error.message,
|
||||||
stack: error.stack
|
stack: error.stack
|
||||||
@@ -200,7 +204,7 @@ async function uploadViaSFTP(xmlObj) {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.log("autohouse-sftp-error", "ERROR", "api", null, { error: error.message, stack: error.stack });
|
logger.log("autohouse-sftp-error", "ERROR", "api", xmlObj.bodyshopid, { error: error.message, stack: error.stack });
|
||||||
throw error;
|
throw error;
|
||||||
} finally {
|
} finally {
|
||||||
sftp.end();
|
sftp.end();
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ async function processShopData(shopsToProcess, start, end, skipUpload, allXMLRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
const xmlObj = {
|
const xmlObj = {
|
||||||
|
bodyshopid: bodyshop.id,
|
||||||
imexshopid: bodyshop.imexshopid,
|
imexshopid: bodyshop.imexshopid,
|
||||||
xml: builder.create({}, claimsCorpObject).end({ allowEmptyTags: true }),
|
xml: builder.create({}, claimsCorpObject).end({ allowEmptyTags: true }),
|
||||||
filename: `${bodyshop.claimscorpid}-${moment().format("YYYYMMDDTHHMMss")}.xml`,
|
filename: `${bodyshop.claimscorpid}-${moment().format("YYYYMMDDTHHMMss")}.xml`,
|
||||||
@@ -181,7 +182,10 @@ async function processShopData(shopsToProcess, start, end, skipUpload, allXMLRes
|
|||||||
async function uploadViaSFTP(xmlObj) {
|
async function uploadViaSFTP(xmlObj) {
|
||||||
const sftp = new Client();
|
const sftp = new Client();
|
||||||
sftp.on("error", (errors) =>
|
sftp.on("error", (errors) =>
|
||||||
logger.log("claimscorp-sftp-connection-error", "ERROR", "api", null, { error: errors.message, stack: errors.stack })
|
logger.log("claimscorp-sftp-connection-error", "ERROR", "api", xmlObj.bodyshopid, {
|
||||||
|
error: errors.message,
|
||||||
|
stack: errors.stack
|
||||||
|
})
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
//Connect to the FTP and upload all.
|
//Connect to the FTP and upload all.
|
||||||
@@ -189,13 +193,13 @@ async function uploadViaSFTP(xmlObj) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
xmlObj.result = await sftp.put(Buffer.from(xmlObj.xml), `${xmlObj.filename}`);
|
xmlObj.result = await sftp.put(Buffer.from(xmlObj.xml), `${xmlObj.filename}`);
|
||||||
logger.log("claimscorp-sftp-upload", "DEBUG", "api", null, {
|
logger.log("claimscorp-sftp-upload", "DEBUG", "api", xmlObj.bodyshopid, {
|
||||||
imexshopid: xmlObj.imexshopid,
|
imexshopid: xmlObj.imexshopid,
|
||||||
filename: xmlObj.filename,
|
filename: xmlObj.filename,
|
||||||
result: xmlObj.result
|
result: xmlObj.result
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.log("claimscorp-sftp-upload-error", "ERROR", "api", null, {
|
logger.log("claimscorp-sftp-upload-error", "ERROR", "api", xmlObj.bodyshopid, {
|
||||||
filename: xmlObj.filename,
|
filename: xmlObj.filename,
|
||||||
error: error.message,
|
error: error.message,
|
||||||
stack: error.stack
|
stack: error.stack
|
||||||
@@ -203,7 +207,10 @@ async function uploadViaSFTP(xmlObj) {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.log("claimscorp-sftp-error", "ERROR", "api", null, { error: error.message, stack: error.stack });
|
logger.log("claimscorp-sftp-error", "ERROR", "api", xmlObj.bodyshopid, {
|
||||||
|
error: error.message,
|
||||||
|
stack: error.stack
|
||||||
|
});
|
||||||
throw error;
|
throw error;
|
||||||
} finally {
|
} finally {
|
||||||
sftp.end();
|
sftp.end();
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ async function processShopData(shopsToProcess, start, end, skipUpload, allXMLRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
const xmlObj = {
|
const xmlObj = {
|
||||||
|
bodyshopid: bodyshop.id,
|
||||||
imexshopid: bodyshop.imexshopid,
|
imexshopid: bodyshop.imexshopid,
|
||||||
xml: builder.create({}, kaizenObject).end({ allowEmptyTags: true }),
|
xml: builder.create({}, kaizenObject).end({ allowEmptyTags: true }),
|
||||||
filename: `${bodyshop.shopname}-${moment().format("YYYYMMDDTHHMMss")}.xml`,
|
filename: `${bodyshop.shopname}-${moment().format("YYYYMMDDTHHMMss")}.xml`,
|
||||||
@@ -178,7 +179,10 @@ async function processShopData(shopsToProcess, start, end, skipUpload, allXMLRes
|
|||||||
async function uploadViaSFTP(xmlObj) {
|
async function uploadViaSFTP(xmlObj) {
|
||||||
const sftp = new Client();
|
const sftp = new Client();
|
||||||
sftp.on("error", (errors) =>
|
sftp.on("error", (errors) =>
|
||||||
logger.log("kaizen-sftp-connection-error", "ERROR", "api", null, { error: errors.message, stack: errors.stack })
|
logger.log("kaizen-sftp-connection-error", "ERROR", "api", xmlObj.bodyshopid, {
|
||||||
|
error: errors.message,
|
||||||
|
stack: errors.stack
|
||||||
|
})
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
//Connect to the FTP and upload all.
|
//Connect to the FTP and upload all.
|
||||||
@@ -186,13 +190,13 @@ async function uploadViaSFTP(xmlObj) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
xmlObj.result = await sftp.put(Buffer.from(xmlObj.xml), `${xmlObj.filename}`);
|
xmlObj.result = await sftp.put(Buffer.from(xmlObj.xml), `${xmlObj.filename}`);
|
||||||
logger.log("kaizen-sftp-upload", "DEBUG", "api", null, {
|
logger.log("kaizen-sftp-upload", "DEBUG", "api", xmlObj.bodyshopid, {
|
||||||
imexshopid: xmlObj.imexshopid,
|
imexshopid: xmlObj.imexshopid,
|
||||||
filename: xmlObj.filename,
|
filename: xmlObj.filename,
|
||||||
result: xmlObj.result
|
result: xmlObj.result
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.log("kaizen-sftp-upload-error", "ERROR", "api", null, {
|
logger.log("kaizen-sftp-upload-error", "ERROR", "api", xmlObj.bodyshopid, {
|
||||||
filename: xmlObj.filename,
|
filename: xmlObj.filename,
|
||||||
error: error.message,
|
error: error.message,
|
||||||
stack: error.stack
|
stack: error.stack
|
||||||
@@ -200,7 +204,7 @@ async function uploadViaSFTP(xmlObj) {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.log("kaizen-sftp-error", "ERROR", "api", null, { error: error.message, stack: error.stack });
|
logger.log("kaizen-sftp-error", "ERROR", "api", xmlObj.bodyshopid, { error: error.message, stack: error.stack });
|
||||||
throw error;
|
throw error;
|
||||||
} finally {
|
} finally {
|
||||||
sftp.end();
|
sftp.end();
|
||||||
|
|||||||
Reference in New Issue
Block a user