vn-cc-vmp/IOXml.js

40 lines
886 B
JavaScript
Raw Permalink 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];
}
2017-04-11 08:03:39 +00:00
function setXml(path,data,callback){
fs.writeFile(__dirname + path,data,{encoding:'utf8'},function(err){
if (err) {
callback(err,null);
return;
}
callback(null);
});
}
exports.setXml = setXml;
2017-04-10 08:56:51 +00:00
exports.getXml = getXml;