exports.Load = function (req, res, next) {
var bodyParser = require('body-parser');
var crypto = require('crypto');
var Connection = require('tedious').Connection;
var _ = require('underscore');
var Request = require('tedious').Request;
var TYPES = require('tedious').TYPES;
if (!req.params.data ){
res.setHeader('Access-Control-Allow-Origin');
res.send('{"error":"invalid data"}');
next();
}else{
var obj = JSON.parse(req.params.data);
var ini_uid = obj.uid;
var ini_key = obj.key;
var connection = new Connection(config);
connection.on('connect', function(err){
if(err){
console.log(err);
next();
}else{
var request = new Request("SELECT * FROM ТУТ WHERE ВОТ", function(err, rowCount, rows){
connection.close();
next();
})
request.on('row', function(columns) {
if(columns[11].value == ini_key){
///
var connection = new Connection(config);
connection.on('connect', function(err) {
request = new Request("SELECT * FROM ВОТ ЭТО WHERE ВОТ ТАКОЕ ORDER BY ЧТО-ТО DESC ", function(err, rowCount) {
connection.close();
});
request.on('row', function(columns) {
res.setHeader('Access-Control-Allow-Origin');
res.json({error: columns });
return next();
});
connection.execSql(request);
});
}else{
res.json({error: "invalid data" });
res.setHeader('Access-Control-Allow-Origin');
return next();
}
})
connection.execSql(request);
}
})
}
return;
};