Пример #1
0
    new CronJob(config.timeScheduler, function() {
      console.log('\nCheck for new updates:'.cyan, new Date());

      //Get a token valid for 21600 minutes
      service.getToken().then(function(response){

        // Recover new entities which hasn't been closed and has been modified
        var options = {
          serviceUrl: feature_service,
          query: {
            f: 'json',
            where:  '(last_edited_date > last_emailed_date OR last_emailed_date is null) ',
            outFields: '*',
          }
        };

        if(config.whereFilter){
          options.query.where += 'AND ' + config.whereFilter;
        }

        service.getFeatures(options).then(function(res){
          if(res.error && res.error.code === 400){
            console.log("\nError: ".red, res.error.message);
            //console.log("\nQuery: ".red, options.query);
            options.query.f = "html";
            console.log("\nQuery: ".red, options.serviceUrl + "/query?" + qs.stringify(options.query));
            return 0;
          }

          console.log("\nEntities unclosed:".yellow, res.features.length);

          // Process every pending feature
          for(var i in res.features){
            util.processFeature({
              config: config,
              service: service,
              feature_service: feature_service,
              res: res,
              i: i
            });
          }

        });
      });
    }, null, true, 'Europe/Madrid');
Пример #2
0
    oldLog  = console.log,
    DEBUG   = true;

var feature_service, arcgis;

// If DEBUG is true we will show log messages
console.log = function(message,param){
  if(DEBUG === true){
    oldLog.apply(console, arguments);
  }
};

console.log("\nChecking configuration...".green);

service.getToken().then(function(response){
  arcgis = ArcGIS({
    'token': response.token,
    'domain': config.organization.root_url + ':' + config.organization.port + '/' + config.organization.arcgisPath
  });
  console.log("\nNew access token:".green, ((response.token)? "done": "error"));

  arcgis.item(config.portal_item.trim()).then(function (item) {
    // Checking if feature service is public (if so -> error)

    if(item.access === 'public'){
      var itemURL = 'http://' + config.organization.root_url + '/' + config.organization.portalPath + '/home/item.html?id=' + config.portal_item;
      console.log('\nThe item can not public:'.red, itemURL);
    }else if(item.type !== 'Feature Service'){
      console.log('\nThe item type is not "Feature service" it is:'.red, item.type);
    }else{