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