vn-cc-vmp/getXml.js

27 lines
634 B
JavaScript
Raw Normal View History

2017-04-10 08:56:51 +00:00
var fs = require('fs');
function getXml(path,callback){
fs.readFile(__dirname + path,'utf8', function(err, data) {
if (err) {
callback(err,null);
return;
}
var sqlReplaced = data.replace(/#\w+/g,replaceFunc)
console.log(sqlReplaced);
callback(null,sqlReplaced);
});
}
function replaceFunc (token)
{
var fecha = require('fecha');
var key = token.substr (1);
var values={
"AgentParty":8713783248188,
"MessageDateTime":fecha.format(new Date(),'YYYY-MM-DDThh:mm:ss+01:00')
};
return values[key];
}
exports.getXml = getXml;