summaryrefslogtreecommitdiffstats
path: root/admportal/server/router/routes/helpers.js
diff options
context:
space:
mode:
Diffstat (limited to 'admportal/server/router/routes/helpers.js')
-rw-r--r--admportal/server/router/routes/helpers.js66
1 files changed, 0 insertions, 66 deletions
diff --git a/admportal/server/router/routes/helpers.js b/admportal/server/router/routes/helpers.js
deleted file mode 100644
index 6ac8215f..00000000
--- a/admportal/server/router/routes/helpers.js
+++ /dev/null
@@ -1,66 +0,0 @@
-
-var _ = require('lodash');
-var csvtojson = require('csvtojson');
-var async = require('async');
-var uuid = require('node-uuid'); // generate a uuid with "uuid.v1()"
-var path = require('path');
-var fs = require("fs");
-var moment = require('moment');
-
-var helpers = module.exports;
-
-function puts(obj) { console.log(obj); }
-function putd(obj) { console.log(obj); }
-helpers.puts = puts;
-helpers.putd = putd;
-
-
-helpers.readCsv = function(filedir, filename, callback) {
-
-
- var Converter=csvtojson.Converter;
- var csvFileName=path.join(filedir,filename);
- var fileStream=fs.createReadStream(csvFileName);
- fileStream.on('error', function(err){
- callback(err, null);
- });
- var param={noheader:true, checkType:false};
- var csvConverter=new Converter(param);
- csvConverter.on("end_parsed",function(jsonObj){
- var returnValue = jsonObj;
- callback(null, returnValue);
- });
- fileStream.on('error', function(err) {
- putd(err);
- callback(err,"");
- });
- fileStream.pipe(csvConverter);
-}
-
-helpers.getParam = function(csv, matchField, matchValue, returnField) {
- dataRow=_.find(csv, matchField, matchValue);
- dataValue=dataRow[returnField];
- return dataValue;
-}
-
-helpers.writeOutput = function(req, filename, jsonOutput, callback) {
- try {
- fs.writeFileSync(filename, jsonOutput);
- }
- catch(err){
- callback(err);
- }
-}
-
-helpers.getFileName = function(req, defFilename) {
-
- var fileObj = null;
- for (var x=0; x < req.files.length; x++)
- {
- var fileObj = req.files[x];
- if ( fileObj.filename.indexOf(defFilename) != -1 ){
- return fileObj.filename;
- }
- }
- return null;
-}