40 lines
886 B
JavaScript
40 lines
886 B
JavaScript
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];
|
|
|
|
}
|
|
|
|
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;
|
|
exports.getXml = getXml; |