Beispiel #1
0
  module.exports.getWeibullTableValues = function(partNumber, vintage, callback){
    try{
      if (!global.dbConn.connected)
        global.dbConn = ibmdb.openSync(config.dbConnString);

      var query= "select * from WEIBULL where IBMPN='"+partNumber.toUpperCase()+"'" +
                  " and BUILT_YEAR_MONTH='" + vintage + "'"
                  //" ORDER BY "+
                  //" CAST((REPLACE(BUILT_YEAR_MONTH,'_','-') || '-1' ) as DATE) DESC " +
                  " FETCH FIRST 1 ROWS ONLY "
      console.log('weibull', query)

      global.dbConn.query(query, function (err, rows, docs) {
        if (err) {
          console.log('Error getting WEIBULL: ', err);
          callback(err,null)
        } else {
          //console.log(err, rows, docs[0])
          callback(null, rows[0])
        }
      });

    } catch(e){
      console.log(e.message);
    }
  }
  module.exports.getWEIBULLTableValues = function(partNumber, builtYearMonth, options, callback){
    try{
      if (!global.dbConn.connected)
        global.dbConn = ibmdb.openSync(config.dbConnString);

      var query= "select * from WEIBULL_FULLDATA where IBMPN='"+partNumber.toUpperCase()+"'" +
                  " and BUILT_YEAR_MONTH = '" + builtYearMonth + "' " +
                  //" and CAST((REPLACE(BUILT_YEAR_MONTH,'_','-') || '-1' ) as DATE) >= current date - 12 months " +
                  " ORDER BY POH " + options.ascDesc
      console.log('weibull table', query)

      global.dbConn.query(query, function (err, rows, docs) {
        if (err) {
          console.log('Error getting TCO: ', err);
          callback(err,null)
        } else {
          //console.log(err, rows, docs)
          callback(null, rows)
        }
      });

    } catch(e){
      console.log(e.message);
    }
  }
Beispiel #3
0
    var Db2Store = function (opt, connection) {
        if (!(this instanceof Db2Store)) {
            throw new TypeError('Cannot call Db2Store constructor as a function');
        }

        var self = this;

        this._options = extend(true, {}, defaultOptions, opt || {});

        Store.call(this, this._options);

        if (connection) {
            debug('Using supplied connection, connected: %s', connection.connected);
            this._client = connection;
            if (!this._client.connected) {
                var err = new Error('The supplied db connection is not open');
                throw err;
            }
        } else {
            var dsn = this._options.use_ssl === true ? this._options.ssldsn : this._options.dsn;

            if (!dsn) {
                dsn = 'DRIVER={DB2};DATABASE=' + this._options.database +
                    ';UID=' + this._options.user +
                    ';PWD=' + this._options.password +
                    ';HOSTNAME=' + this._options.host +
                    ';PORT=' + this._options.port +
                    ';PROTOCOL=TCPIP;';

                if (this._options.use_ssl) {
                    dsn += 'Security=SSL;';
                }
            }

            if (dsn.match(/Security=SSL/i)) {
                debug('SSL enabled');
            }

            //debug('Using dsn "%s"', dsn);

            try {
                self._client = ibmdb.openSync(dsn);
            } catch (err) {
                debug('dashDB returned err', err);
                throw err;
            }
        }
    };
Beispiel #4
0
  module.exports.getAlertCount = function(partNumber, callback){
    try{
      if (!global.dbConn.connected)
        global.dbConn = ibmdb.openSync(config.dbConnString);

      var query= "select * from ARR_ALERTS_SUMMARY where IBMPN='"+partNumber.toUpperCase()+"'"
      
      global.dbConn.query(query, function (err, rows, docs) {
        if (err) {
          console.log('Error getting ARR_ALERTS: ', err);
          callback(err,null)
        } else {
          callback(null, rows[0])
        }
      });

    } catch(e){
      console.log(e.message);
    }
  }
Beispiel #5
0
  module.exports.getStopLight = function(partNumber, vintage, callback){
    try{
      if (!global.dbConn.connected)
        global.dbConn = ibmdb.openSync(config.dbConnString);

      var query= "select STOP_LIGHT from ARR where IBMPN='"+partNumber.toUpperCase()+"'"
      console.log('arr table', query)

      global.dbConn.query(query, function (err, rows, docs) {
        if (err) {
          console.log('Error getting ARR-stop-light: ', err);
          callback(err,null)
        } else {
          callback(null, rows[0])
        }
      });

    } catch(e){
      console.log(e.message);
    }
  }
Beispiel #6
0
  module.exports.getTCOFlag = function(partNumber, callback){
    try{
      if (!global.dbConn.connected)
        global.dbConn = ibmdb.openSync(config.dbConnString);

      var query= "select TCO_FLAG from TCO where IBMPN='"+partNumber.toUpperCase()+"'"
      console.log('tco table', query)

      global.dbConn.query(query, function (err, rows, docs) {
        if (err) {
          console.log('Error getting TCO-flag: ', err);
          callback(err,null)
        } else {
          callback(null, rows[0])
        }
      });

    } catch(e){
      console.log(e.message);
    }
  }
Beispiel #7
0
  module.exports.getARRTableValues = function(partNumber, callback){
    try{
      if (!global.dbConn.connected)
        global.dbConn = ibmdb.openSync(config.dbConnString);

      var query= "select * from ARR where IBMPN='"+partNumber.toUpperCase()+"'" +
                  " and CAST((REPLACE(BUILT_YEAR_MONTH,'_','-') || '-1' ) as DATE) >= current date - 12 months " +
                  " ORDER BY CAST((REPLACE(BUILT_YEAR_MONTH,'_','-') || '-1' ) as DATE) DESC"
      console.log('arr table', query)

      global.dbConn.query(query, function (err, rows, docs) {
        if (err) {
          console.log('Error getting ARR: ', err);
          callback(err,null)
        } else {
          //console.log(err, rows, docs)
          callback(null, rows)
        }
      });

    } catch(e){
      console.log(e.message);
    }
  }