un-cli 0.0.72 → 0.0.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cmd.txt CHANGED
@@ -1,2 +1,2 @@
1
- update subnetworks --all --desc
1
+ updateisconnected
2
2
  exit
package/index.html CHANGED
@@ -87,12 +87,14 @@
87
87
 
88
88
  cmbService = document.getElementById("cmbService")
89
89
  while (cmbService.firstChild) cmbService.removeChild(cmbService.firstChild)
90
-
90
+
91
+ token = await getToken(parameters);
92
+
93
+ //if we logged in successfully
91
94
  const opt = document.createElement("option")
92
95
  opt.textContent = "(All Services)"
93
96
  cmbService.appendChild (opt)
94
97
 
95
- token = await getToken(parameters);
96
98
  const services = await portal.services()
97
99
  const featureServices = services.services.filter(s => s.type == "FeatureServer")
98
100
  featureServices.forEach(s=> {
@@ -390,16 +392,16 @@ async function loadAttributeRules () {
390
392
  }
391
393
  async function loadSQLLogs () {
392
394
 
393
- //build table
394
- const tblResult = document.getElementById("tblResult");
395
- //clear
396
- while(tblResult.firstChild) tblResult.removeChild(tblResult.firstChild)
397
-
395
+ //build table
396
+ const tblResult = document.getElementById("tblResult");
397
+ //clear
398
+ while(tblResult.firstChild) tblResult.removeChild(tblResult.firstChild)
399
+
398
400
 
399
- parameters.service = cmbService.options[cmbService.selectedIndex].text
400
-
401
-
402
- let mins = document.getElementById("txtAge").value //query logs for the last 30 minutes
401
+ parameters.service = cmbService.options[cmbService.selectedIndex].text
402
+
403
+
404
+ let mins = document.getElementById("txtAge").value //query logs for the last 30 minutes
403
405
 
404
406
 
405
407
  console.log(`Querying cursor sql logs for ${parameters.service} for the last ${mins} minutes ...`)
@@ -407,30 +409,7 @@ while(tblResult.firstChild) tblResult.removeChild(tblResult.firstChild)
407
409
  //startTime is the most recent
408
410
  //endTime is the oldest
409
411
 
410
-
411
-
412
- /*
413
- const topLogCount = 100;
414
- const startTime = Date.now()
415
- const endTime = Date.now() - mins*60*1000
416
- let services = [theService + ".MapServer"]
417
- if (theService == "(All Services)")
418
- services = "*"
419
- let result= await adminLog.query([code], services, topLogCount, startTime ,endTime , "DEBUG")
420
- let jsonRes = await result.json()
421
- let allMessages = [].concat(jsonRes.logMessages)
422
- allMessages = allMessages.filter(m => m.message.indexOf("EndCursor;") > -1)
423
- while (jsonRes.hasMore)
424
- {
425
- //start paging
426
- logger.info(`Aggregating messages... total so far ${allMessages.length} entries but more left, pulling logs between ${new Date(jsonRes.endTime)} and ${new Date(endTime)}`)
427
- result= await adminLog.query([102023], services, pageSize, jsonRes.endTime, endTime, "DEBUG")
428
- jsonRes = await result.json()
429
-
430
- allMessages = allMessages.concat(jsonRes.logMessages.filter(m => m.message.indexOf("EndCursor;") > -1))
431
- }
432
- */
433
-
412
+
434
413
  //page query the admin log
435
414
  let allMessages = await adminLogQueryWithPaging(mins, parameters.service, [102023], "EndCursor;", "DEBUG")
436
415
 
@@ -534,7 +513,7 @@ while(tblResult.firstChild) tblResult.removeChild(tblResult.firstChild)
534
513
  const cLog = document.createElement("td");
535
514
  const cLogText = document.createElement("input")
536
515
  cLogText.type = "text"
537
- cLogText.style = "width:500px"
516
+ cLogText.style = "width:800px"
538
517
  cLogText.value = m.message.substr( m.message.indexOf("SQL: ") + 5, m.message.length)
539
518
  cLogText.readOnly= true;
540
519
  cLog.appendChild(cLogText)
@@ -555,12 +534,6 @@ while(tblResult.firstChild) tblResult.removeChild(tblResult.firstChild)
555
534
 
556
535
  })
557
536
 
558
-
559
-
560
-
561
-
562
-
563
-
564
537
  //await populateMessages(allMessages)
565
538
 
566
539
 
@@ -718,27 +691,8 @@ function numberWithCommas(x) {
718
691
  }
719
692
 
720
693
 
721
- /*
722
- const topLogCount = 100;f
723
- const startTime = Date.now()
724
- const endTime = Date.now() - mins*60*1000
725
- let services = [theService + ".MapServer"]
726
- if (theService == "(All Services)")
727
- services = "*"
728
- let result= await adminLog.query([code], services, topLogCount, startTime ,endTime , "DEBUG")
729
- let jsonRes = await result.json()
730
- let allMessages = [].concat(jsonRes.logMessages)
731
- allMessages = allMessages.filter(m => m.message.indexOf("EndCursor;") > -1)
732
- while (jsonRes.hasMore)
733
- {
734
- //start paging
735
- logger.info(`Aggregating messages... total so far ${allMessages.length} entries but more left, pulling logs between ${new Date(jsonRes.endTime)} and ${new Date(endTime)}`)
736
- result= await adminLog.query([102023], services, pageSize, jsonRes.endTime, endTime, "DEBUG")
737
- jsonRes = await result.json()
738
-
739
- allMessages = allMessages.concat(jsonRes.logMessages.filter(m => m.message.indexOf("EndCursor;") > -1))
740
- }
741
- */
694
+
695
+
742
696
  </script>
743
697
  </body>
744
698
  </html>
package/index.mjs CHANGED
@@ -7,7 +7,7 @@ import { AdminLog } from "./adminlog.mjs"
7
7
  import logger from "./logger.mjs"
8
8
  import fetch from "node-fetch"
9
9
  //update version
10
- let version = "0.0.72";
10
+ let version = "0.0.75";
11
11
  const GENERATE_TOKEN_TIME_MIN = 30;
12
12
 
13
13
  let rl = null;
@@ -53,10 +53,10 @@ function parseInput(){
53
53
 
54
54
  if (Object.values(params).includes(null))
55
55
  {
56
- console.log ("HELP: uncli --portal https://unportal.domain.com/portal --service servicename --user username --password password [--gdbversion* user.version --server https://federatedserver.domain.com/server --file commandfile* --verify true|false]")
57
- console.log("--file commandfile is optional and you can pass a path to a file with a list of command to execute. ")
58
- console.log("--gdbversion is optional and allows the UN to be opened in that version. When not specified sde.DEFAULT is used.")
59
- console.log("--server is optional except when there are more than one federated server sites to the portal. If the portal only has one server it will be selected.")
56
+ logger.info ("HELP: uncli --portal https://unportal.domain.com/portal --service servicename --user username --password password [--gdbversion* user.version --server https://federatedserver.domain.com/server --file commandfile* --verify true|false]")
57
+ logger.info("--file commandfile is optional and you can pass a path to a file with a list of command to execute. ")
58
+ logger.info("--gdbversion is optional and allows the UN to be opened in that version. When not specified sde.DEFAULT is used.")
59
+ logger.info("--server is optional except when there are more than one federated server sites to the portal. If the portal only has one server it will be selected.")
60
60
  process.exit();
61
61
  }
62
62
 
@@ -73,7 +73,7 @@ async function getToken(parameters) {
73
73
  }
74
74
 
75
75
  async function regenerateToken(parameters) {
76
- console.log("Regenerating token.")
76
+ logger.info("Regenerating token.")
77
77
  const token = await getToken(parameters);
78
78
  un.token = token;
79
79
  executeInput("clear");
@@ -175,6 +175,8 @@ const inputs = {
175
175
  "export subnetworks --all [--folder]": "Export all subnetworks with ACK --folder where exported files are saved",
176
176
  "export subnetworks --new [--folder]": "Export all subnetworks with ACK that haven't been exported --folder where exported files are saved",
177
177
  "export subnetworks --deleted": "Export all subnetworks with ACK that are deleted ",
178
+ "updateisconnected": "Run update is connected ",
179
+
178
180
  "count": "Lists the number of rows in all feature layers.",
179
181
  "count --system": "Lists the number of rows in system layers.",
180
182
  "connect --service": "Connects to the another service",
@@ -193,7 +195,7 @@ const inputs = {
193
195
  },
194
196
  "^whoami$": async () => {
195
197
 
196
- console.log(`${parameters.user}@${parameters.service}@${parameters.gdbversion}`)
198
+ logger.info(`${parameters.user}@${parameters.service}@${parameters.gdbversion}`)
197
199
 
198
200
  },
199
201
  "^def --layers$|^layers$": async () => {
@@ -231,20 +233,20 @@ const inputs = {
231
233
 
232
234
  const subnetworks = await un.getSubnetworks();
233
235
  if (subnetworks.features.length === 0) {
234
- console.log("No dirty subnetworks found.")
236
+ logger.info("No dirty subnetworks found.")
235
237
  return;
236
238
  }
237
239
  const subs = subnetworks.features.map(a => a.attributes)
238
240
  console.table(subs)
239
241
  const rowCount = subs.length;
240
- console.log (`${numberWithCommas(rowCount)} rows returned.`)
242
+ logger.info (`${numberWithCommas(rowCount)} rows returned.`)
241
243
  },
242
244
  "^topology$": async () => {
243
245
  const moments = ["initialEnableTopology","fullValidateTopology","partialValidateTopology","enableTopology","disableTopology","definitionModification","updateIsConnected"]
244
246
  const networkMoments = await un.queryMoment(moments)
245
247
  // networkMoments.forEach (m => momentsText += `\n${m.moment} : ${m.time === 0 ? "N/A": new Date(m.time*1000)} ${m.duration === 0 ? "" : ` Duration: ${Math.round(m.duration/1000)}s `} `)
246
248
  // networkMoments.forEach (m => momentsText += `\n${m.moment} : ${m.time === 0 ? "N/A": new Date(m.time*1000)} ${m.duration === 0 ? "" : ` Duration: ${Math.round(m.duration/1000)}s `} `)
247
- // console.log('\x1b[36m%s\x1b[0m', 'I am cyan'); //cyan
249
+ // logger.info('\x1b[36m%s\x1b[0m', 'I am cyan'); //cyan
248
250
  const topoMoments = networkMoments.networkMoments.map(m => {
249
251
  const t = m.time === 0 ? "N/A": new Date(m.time*1000)
250
252
  const d = m.duration === 0 ? "N/A" : numberWithCommas(Math.round(m.duration)) + " ms"
@@ -260,7 +262,7 @@ const inputs = {
260
262
  console.table(topoMoments)
261
263
  },
262
264
  "^topology --enable$": async () => {
263
- console.log("Enabling topology ...");
265
+ logger.info("Enabling topology ...");
264
266
  const fromDate = new Date();
265
267
  const result = await un.enableTopology()
266
268
  const toDate = new Date();
@@ -270,34 +272,44 @@ const inputs = {
270
272
  },
271
273
  "^topology --disable$": async () => {
272
274
  const fromDate = new Date();
273
- console.log("Disabling topology ...");
275
+ logger.info("Disabling topology ...");
274
276
  const result = await un.disableTopology()
275
277
  const toDate = new Date();
276
278
  const timeEnable = toDate.getTime() - fromDate.getTime();
277
279
  result.duration = numberWithCommas(Math.round(timeEnable)) + " ms"
278
280
  console.table(result)
279
281
  },
282
+
283
+ "^updateisconnected$": async () => {
284
+ const fromDate = new Date();
285
+ logger.info("Updating is connected ...");
286
+ const result = await un.updateIsConnected()
287
+ const toDate = new Date();
288
+ const timeEnable = toDate.getTime() - fromDate.getTime();
289
+ result.duration = numberWithCommas(Math.round(timeEnable)) + " ms"
290
+ console.table(result)
291
+ },
280
292
  "^evaluate$": async () => {
281
293
  const fromDate = new Date();
282
- console.log("Building Evaluation Blocks ...");
294
+ logger.info("Building Evaluation Blocks ...");
283
295
  //return evaluation blocks for layer 5
284
296
  const blocks = await buildEvaluationBlocks(5);
285
297
 
286
- console.log("Evaluating Attribute Rules ...");
298
+ logger.info("Evaluating Attribute Rules ...");
287
299
  //blocks.forEach(b => un.evaluate (null, b, ["validationRules", "calculationRules"], async = false, gdbVersion = "sde.DEFAULT"))
288
- //Object.keys(blocks).forEach(k => console.log(blocks[k]))
300
+ //Object.keys(blocks).forEach(k => logger.info(blocks[k]))
289
301
  const promises = []
290
302
  Object.keys(blocks).forEach(k => promises.push(un.evaluate (null, blocks[k], ["validationRules", "calculationRules"] )))
291
303
 
292
- console.log("done sending all requests.. now waiting for response ")
304
+ logger.info("done sending all requests.. now waiting for response ")
293
305
 
294
- Promise.all(promises).then(a=>console.log("done")).catch(a=>console.log("failed" + JSON.stringify(a)))
306
+ Promise.all(promises).then(a=>logger.info("done")).catch(a=>logger.info("failed" + JSON.stringify(a)))
295
307
 
296
308
  const result = {}
297
309
  const toDate = new Date();
298
310
  const timeEnable = toDate.getTime() - fromDate.getTime();
299
311
  result.duration = numberWithCommas(Math.round(timeEnable)) + " ms"
300
- console.log(result)
312
+ logger.info(result)
301
313
  },
302
314
 
303
315
  //partition so that we can run and commit incrementally..
@@ -305,7 +317,7 @@ const inputs = {
305
317
  //timeouts
306
318
  //in case failure you don't lose everything
307
319
  "^topology --validate -fn$": async () => {
308
- console.log("Validating Network topology ...");
320
+ logger.info("Validating Network topology ...");
309
321
 
310
322
  const fullExtent = un.featureServiceJson.fullExtent;
311
323
  /*
@@ -343,7 +355,7 @@ const inputs = {
343
355
  const timeEnable = toDate.getTime() - fromDate.getTime();
344
356
  const duration = numberWithCommas(Math.round(timeEnable)) + " ms"
345
357
  console.clear()
346
- console.log("Validating extent " + e.xmin)
358
+ logger.info("Validating extent " + e.xmin)
347
359
  console.table({duration})
348
360
 
349
361
  })
@@ -352,7 +364,7 @@ const inputs = {
352
364
  },
353
365
 
354
366
  "^topology --validate$": async () => {
355
- console.log("Validating Network topology ...");
367
+ logger.info("Validating Network topology ...");
356
368
  const fromDate = new Date();
357
369
  const result = await un.validateNetworkTopology()
358
370
  const toDate = new Date();
@@ -363,35 +375,35 @@ const inputs = {
363
375
  "^subnetworks --dirty$": async () => {
364
376
  const subnetworks = await un.getSubnetworks("isdirty=1");
365
377
  if (subnetworks.features.length === 0) {
366
- console.log("No dirty subnetworks found.")
378
+ logger.info("No dirty subnetworks found.")
367
379
  return;
368
380
  }
369
381
 
370
382
  const subs = subnetworks.features.map(a => a.attributes)
371
383
  console.table(subs)
372
384
  const rowCount = subs.length;
373
- console.log (`${numberWithCommas(rowCount)} rows returned.`)
385
+ logger.info (`${numberWithCommas(rowCount)} rows returned.`)
374
386
  },
375
387
  "^subnetworks --deleted$": async () => {
376
388
  const subnetworks = await un.getSubnetworks("isdirty=1 and isdeleted=1");
377
389
  if (subnetworks.features.length === 0) {
378
- console.log("No dirty and deleted subnetworks found.")
390
+ logger.info("No dirty and deleted subnetworks found.")
379
391
  return;
380
392
  }
381
393
 
382
394
  const subs = subnetworks.features.map(a => a.attributes)
383
395
  console.table(subs)
384
396
  const rowCount = subs.length;
385
- console.log (`${numberWithCommas(rowCount)} rows returned.`)
397
+ logger.info (`${numberWithCommas(rowCount)} rows returned.`)
386
398
  },
387
399
 
388
400
  "^update subnetworks --deleted$" : async () => {
389
- console.log("Querying all subnetworks that are dirty and deleted.");
401
+ logger.info("Querying all subnetworks that are dirty and deleted.");
390
402
  let subnetworks = await un.queryDistinct(500002, "domainnetworkname,tiername,subnetworkname", "isdirty=1 and isdeleted=1","domainnetworkname,tiername,subnetworkname");
391
- console.log(`Discovered ${subnetworks.features.length} dirty deleted subnetworks.`);
403
+ logger.info(`Discovered ${subnetworks.features.length} dirty deleted subnetworks.`);
392
404
  for (let i = 0; i < subnetworks.features.length; i++) {
393
405
  const f = subnetworks.features[i]
394
- console.log("Updating Subnetwork " + v(f.attributes,"subnetworkName"));
406
+ logger.info("Updating Subnetwork " + v(f.attributes,"subnetworkName"));
395
407
 
396
408
  const fromDate = new Date();
397
409
 
@@ -404,7 +416,7 @@ const inputs = {
404
416
  subnetworkResult.duration = numberWithCommas(Math.round(timeEnable)) + " ms"
405
417
 
406
418
 
407
- console.log(`Result ${JSON.stringify(subnetworkResult)}`)
419
+ logger.info(`Result ${JSON.stringify(subnetworkResult)}`)
408
420
  }
409
421
  },
410
422
 
@@ -422,27 +434,28 @@ const inputs = {
422
434
  if (failedSubnetworks.length > 0 )
423
435
  failedSubWhereClause = " AND SUBNETWORKNAME NOT IN (" + failedSubnetworks.join(",") + ")"
424
436
 
425
- console.log("Querying all subnetworks that are dirty.");
437
+ logger.info("Querying all subnetworks that are dirty.");
426
438
  subnetworks = await un.queryDistinct(500002, "domainnetworkname,tiername,subnetworkname", "isdirty=1 " + failedSubWhereClause, `domainnetworkname ${sort},tiername ${sort},subnetworkname ${sort}`);
427
- console.log(`Discovered ${subnetworks.features.length} dirty subnetworks.`);
439
+ logger.info(`Discovered ${subnetworks.features.length} dirty subnetworks.`);
428
440
 
429
441
  for (let i = 0; i < subnetworks.features.length; i++) {
430
442
  const f = subnetworks.features[i]
431
443
  const subnetworkName = v(f.attributes,"subnetworkName")
432
- console.log("Updating Subnetwork " + subnetworkName);
444
+ logger.info("Updating Subnetwork " + subnetworkName);
433
445
 
434
446
  const fromDate = new Date();
435
447
 
436
448
  const subnetworkResult = await un.updateSubnetworks(v(f.attributes,"domainNetworkName"), v(f.attributes,"tierName"), v(f.attributes,"subnetworkName"),false);
437
449
  //check if we have processed this subnetwork (maybe be an error)
438
- if (subnetworkResult.success == false)
450
+ const tier = un.getTier(v(f.attributes,"domainNetworkName"), v(f.attributes,"tierName"))
451
+ if (subnetworkResult.success == false || tier.manageSubnetwork?.propertySetItems?.includes("IsDirty"))
439
452
  failedSubnetworks.push("'" + subnetworkName + "'")
440
453
 
441
454
  const toDate = new Date();
442
455
  const timeEnable = toDate.getTime() - fromDate.getTime();
443
456
  subnetworkResult.duration = numberWithCommas(Math.round(timeEnable)) + " ms"
444
457
 
445
- console.log(`Result ${JSON.stringify(subnetworkResult)}`)
458
+ logger.info(`Result ${JSON.stringify(subnetworkResult)}`)
446
459
  }
447
460
 
448
461
  }
@@ -450,19 +463,21 @@ const inputs = {
450
463
 
451
464
  },
452
465
  "^update subnetworks --all --async$" : async () => {
453
- console.log("Querying all subnetworks that are dirty.");
466
+ logger.info("Querying all subnetworks that are dirty.");
454
467
  let subnetworks = await un.queryDistinct(500002, "domainnetworkname,tiername,subnetworkname", "isdirty=1", "domainnetworkname,tiername,subnetworkname");
455
- console.log(`Discovered ${subnetworks.features.length} dirty subnetworks.`);
468
+ logger.info(`Discovered ${subnetworks.features.length} dirty subnetworks.`);
456
469
  for (let i = 0; i < subnetworks.features.length; i++) {
457
470
  const f = subnetworks.features[i]
458
- console.log("Sending job for " + v(f.attributes,"subnetworkName"));
471
+ logger.info("Sending job for " + v(f.attributes,"subnetworkName"));
459
472
  const subnetworkResult = await un.updateSubnetworks(v(f.attributes,"domainNetworkName"), v(f.attributes,"tierName"), v(f.attributes,"subnetworkName"),true);
460
- console.log(`Result from submitting job ${JSON.stringify(subnetworkResult)}`)
473
+ logger.info(`Result from submitting job ${JSON.stringify(subnetworkResult)}`)
461
474
  }
462
475
  },
463
476
  "^export subnetworks --all --folder .*$|^export subnetworks --all$" : async input => {
464
477
 
465
478
  let subnetworks
479
+ let sort = "asc";
480
+ if (input.indexOf("--desc") > 0) sort = "desc"
466
481
  //create folder
467
482
  const file = input.match(/--folder .*/gm)
468
483
  let inputDir = "Exported"
@@ -470,33 +485,40 @@ const inputs = {
470
485
  inputDir = file[0].replace("--folder ", "")
471
486
  //create directory if doesn't exists
472
487
  if (!fs.existsSync(inputDir)) fs.mkdirSync(inputDir)
473
-
488
+ let exportedSubnetworks = [];
489
+
474
490
  do {
475
491
 
476
- console.log("Querying all subnetworks that are clean.");
477
- subnetworks = await un.queryDistinct(500002, "domainnetworkname,tiername,subnetworkname", "isdirty=0","domainnetworkname,tiername,subnetworkname");
478
- console.log(`Discovered ${subnetworks.features.length} subnetworks that can be exported.`);
492
+ let exportedSubnetworksWhereClause = ""
493
+
494
+ if (exportedSubnetworks.length > 0 )
495
+ exportedSubnetworksWhereClause = " AND SUBNETWORKNAME NOT IN (" + exportedSubnetworks.join(",") + ")"
496
+
497
+ logger.info("Querying all subnetworks that are clean.");
498
+ subnetworks = await un.queryDistinct(500002, "domainnetworkname,tiername,subnetworkname", "isdirty=0 " + exportedSubnetworksWhereClause,`domainnetworkname ${sort},tiername ${sort},subnetworkname ${sort}`);
499
+ logger.info(`Discovered ${subnetworks.features.length} subnetworks that can be exported.`);
479
500
  for (let i = 0; i < subnetworks.features.length; i++) {
480
501
  const f = subnetworks.features[i]
481
502
  const subnetworkName = v(f.attributes,"subnetworkName")
482
- console.log("Exporting subnetworks " + v(f.attributes,"subnetworkName"));
503
+ logger.info("Exporting subnetworks " + v(f.attributes,"subnetworkName"));
483
504
 
484
505
  const fromDate = new Date();
485
506
 
486
507
  const subnetworkResult = await un.exportSubnetworks(v(f.attributes,"domainNetworkName"), v(f.attributes,"tierName"), v(f.attributes,"subnetworkName"),false);
487
-
488
-
508
+
489
509
  //code
490
-
510
+ exportedSubnetworks.push("'" + v(f.attributes,"subnetworkName") + "'")
511
+
491
512
  const toDate = new Date();
492
513
  const timeEnable = toDate.getTime() - fromDate.getTime();
493
514
  subnetworkResult.duration = numberWithCommas(timeEnable) + " ms"
494
515
  //if undefined exit
495
516
  if (!subnetworkResult.url)
496
517
  {
497
- console.log("Export subnetwork failed " + JSON.stringify(subnetworkResult))
518
+ logger.info("Export subnetwork failed " + JSON.stringify(subnetworkResult))
498
519
  continue;
499
520
  }
521
+
500
522
 
501
523
  //fetch the json and write it to disk
502
524
  const subContent = await fetch(subnetworkResult.url);
@@ -507,11 +529,11 @@ const inputs = {
507
529
  fs.writeFileSync(`${inputDir}/${subnetworkName}.json`, jsonExport)
508
530
 
509
531
 
510
- console.log(`Result ${JSON.stringify(subnetworkResult)} written to file ${process.cwd()}/${inputDir}/${subnetworkName}.json`)
532
+ logger.info(`Result ${JSON.stringify(subnetworkResult)} written to file ${process.cwd()}/${inputDir}/${subnetworkName}.json`)
511
533
 
512
534
  }
513
535
  }
514
- while (subnetworks.features.length > 0)
536
+ while (subnetworks?.features?.length > 0)
515
537
 
516
538
  },
517
539
 
@@ -527,20 +549,20 @@ const inputs = {
527
549
  if (!fs.existsSync(inputDir)) fs.mkdirSync(inputDir)
528
550
 
529
551
 
530
- console.log("Querying all subnetworks that are clean and not exported.");
552
+ logger.info("Querying all subnetworks that are clean and not exported.");
531
553
  let subnetworks = await un.queryDistinct(500002, "domainnetworkname,tiername,subnetworkname", "isdirty = 0 and (LASTACKEXPORTSUBNETWORK is null or LASTACKEXPORTSUBNETWORK < LASTUPDATESUBNETWORK)","domainnetworkname,tiername,subnetworkname");
532
- console.log(`Discovered ${subnetworks.features.length} subnetworks that can be exported.`);
554
+ logger.info(`Discovered ${subnetworks.features.length} subnetworks that can be exported.`);
533
555
  for (let i = 0; i < subnetworks.features.length; i++) {
534
556
  const f = subnetworks.features[i]
535
557
  const subnetworkName = v(f.attributes,"subnetworkName")
536
- console.log(`Exporting subnetwork ${subnetworkName}` );
558
+ logger.info(`Exporting subnetwork ${subnetworkName}` );
537
559
  const subnetworkResult = await un.exportSubnetworks(v(f.attributes,"domainNetworkName"), v(f.attributes,"tierName"), v(f.attributes,"subnetworkName"),false);
538
560
  //fetch the json and write it to disk
539
561
  const subContent = await fetch(subnetworkResult.url);
540
562
  const jsonExport = await subContent.text();
541
563
  fs.writeFileSync(`${inputDir}/${subnetworkName}.json`, JSON.stringify(jsonExport))
542
564
 
543
- console.log(`Result ${JSON.stringify(subnetworkResult)} written to file ${process.cwd()}/${inputDir}/${subnetworkName}.json`)
565
+ logger.info(`Result ${JSON.stringify(subnetworkResult)} written to file ${process.cwd()}/${inputDir}/${subnetworkName}.json`)
544
566
  }
545
567
 
546
568
 
@@ -550,7 +572,7 @@ const inputs = {
550
572
  "^ia$": async input => {
551
573
 
552
574
  const result = await un.returnInvalidAssociations();
553
- console.log("Invalid Associations " + JSON.stringify(result))
575
+ logger.info("Invalid Associations " + JSON.stringify(result))
554
576
  },
555
577
  "^connect --service": async input =>{
556
578
 
@@ -564,19 +586,23 @@ const inputs = {
564
586
  },
565
587
  "^trace --subnetwork": async input => {
566
588
  //get subnetwork name
589
+ try {
567
590
 
591
+
568
592
  const fromDate = new Date();
569
-
593
+ const inputDir= "Exported"
594
+ let full = true;
595
+ // if (input.indexOf("--full") > 0) full = true
570
596
 
571
597
  const inputParam = input.match(/--subnetwork .*/gm)
572
598
  let subnetworkName = null;
573
599
  if (inputParam != null && inputParam.length > 0)
574
600
  subnetworkName = inputParam[0].replace("--subnetwork ", "")
575
601
 
576
- console.log(`Tracing subnetwork ${subnetworkName}`);
602
+ logger.info(`Tracing subnetwork ${subnetworkName}`);
577
603
  const result = await un.subnetworkTraceSimple(subnetworkName)
578
604
  if (result == null) {
579
- console.log(`Subnetwork ${subnetworkName} doesn't exist`);
605
+ logger.info(`Subnetwork ${subnetworkName} doesn't exist`);
580
606
  return null;
581
607
  }
582
608
  const toDate = new Date();
@@ -584,8 +610,44 @@ const inputs = {
584
610
  const newResult = {}
585
611
  newResult.duration = numberWithCommas(Math.round(timeRun)) + " ms"
586
612
  newResult.elementsCount = result.traceResults.elements.length;
587
- console.table(newResult)
613
+ const traceRes = {}
614
+ logger.info("Grouping trace results...")
615
+ result.traceResults.elements.forEach(e => {
616
+ const layerid = un.getLayerIdfromSourceId(e.networkSourceId).layerId
617
+ if (!traceRes["l" + layerid])
618
+ traceRes["l" + layerid] = []
619
+ traceRes["l" + layerid].push(e.objectId)
620
+
621
+ })
622
+ console.table(newResult)
588
623
 
624
+ //if the trace is full turn around the pull all features
625
+ if (full){
626
+
627
+ //loop through all layers and query
628
+ logger.info("Removing duplicates")
629
+
630
+ console.log(traceRes)
631
+
632
+ //send all queries async
633
+ const allQueries = []
634
+ Object.keys(traceRes).forEach (k => {
635
+ traceRes[k] = [...new Set(traceRes[k])]
636
+ allQueries.push(un.query(k.replace("l",""), "", k, traceRes[k]))
637
+ })
638
+ logger.info(`${Object.keys(traceRes)} queries sent, waiting for response..`)
639
+ const result = await Promise.all(allQueries)
640
+ logger.info("All queries returned.")
641
+ fs.writeFileSync(`${inputDir}/traceout${subnetworkName}.json`, JSON.stringify(result))
642
+ logger.info(`Result written to file ${inputDir}/traceout${subnetworkName}.json`)
643
+
644
+ //logger.info(JSON.stringify(result))
645
+
646
+ }
647
+ }
648
+ catch(ex){
649
+ logger.error(JSON.stringify(ex))
650
+ }
589
651
  },
590
652
  "^export subnetworks --deleted$" : async input => {
591
653
 
@@ -598,19 +660,19 @@ const inputs = {
598
660
  if (!fs.existsSync(inputDir)) fs.mkdirSync(inputDir)
599
661
 
600
662
 
601
- console.log("Querying all subnetworks that are clean and deleted.");
663
+ logger.info("Querying all subnetworks that are clean and deleted.");
602
664
  let subnetworks = await un.queryDistinct(500002, "domainnetworkname,tiername,subnetworkname", "isdirty = 0 and isdeleted=1");
603
- console.log(`Discovered ${subnetworks.features.length} subnetworks that can be exported.`);
665
+ logger.info(`Discovered ${subnetworks.features.length} subnetworks that can be exported.`);
604
666
  for (let i = 0; i < subnetworks.features.length; i++) {
605
667
  const f = subnetworks.features[i]
606
668
  const subnetworkName = v(f.attributes,"subnetworkName")
607
- console.log(`Exporting subnetwork ${subnetworkName}` );
669
+ logger.info(`Exporting subnetwork ${subnetworkName}` );
608
670
  const subnetworkResult = await un.exportSubnetworks(v(f.attributes,"domainNetworkName"), v(f.attributes,"tierName"), v(f.attributes,"subnetworkName"),false);
609
671
 
610
672
  //if undefined exit
611
673
  if (!subnetworkResult.url)
612
674
  {
613
- console.log("Export subnetwork failed " + JSON.stringify(subnetworkResult))
675
+ logger.info("Export subnetwork failed " + JSON.stringify(subnetworkResult))
614
676
  continue;
615
677
  }
616
678
 
@@ -619,7 +681,7 @@ const inputs = {
619
681
  const jsonExport = await subContent.text();
620
682
  fs.writeFileSync(`${inputDir}/${subnetworkName}.json`, JSON.stringify(jsonExport))
621
683
 
622
- console.log(`Result ${JSON.stringify(subnetworkResult)} written to file ${process.cwd()}/${inputDir}/${subnetworkName}.json`)
684
+ logger.info(`Result ${JSON.stringify(subnetworkResult)} written to file ${process.cwd()}/${inputDir}/${subnetworkName}.json`)
623
685
  }
624
686
 
625
687
 
@@ -628,7 +690,7 @@ const inputs = {
628
690
  "^cwd$" : async input => {
629
691
 
630
692
 
631
- console.log(process.cwd())
693
+ logger.info(process.cwd())
632
694
 
633
695
  },
634
696
 
@@ -640,14 +702,14 @@ const inputs = {
640
702
  //create directory if doesn't exists
641
703
  if (!fs.existsSync(inputDir)) fs.mkdirSync(inputDir)
642
704
  fs.writeFileSync(`${inputDir}/${Math.random()}`, Math.random())
643
- console.log(inputDir)
705
+ logger.info(inputDir)
644
706
 
645
707
 
646
708
  },
647
709
 
648
710
 
649
711
  "^count$": async () => {
650
- console.log("Querying all layers....")
712
+ logger.info("Querying all layers....")
651
713
  const layerProperties = [
652
714
  "id",
653
715
  "name",
@@ -681,12 +743,12 @@ const inputs = {
681
743
 
682
744
 
683
745
  console.table(layerCount)
684
- console.log(`Total number of rows in all layers : ${numberWithCommas(totalRows)} .`)
746
+ logger.info(`Total number of rows in all layers : ${numberWithCommas(totalRows)} .`)
685
747
  },
686
748
 
687
749
 
688
750
  "^count --system$": async () => {
689
- console.log("Querying all system layers....")
751
+ logger.info("Querying all system layers....")
690
752
 
691
753
  const systemLayers = un.getSystemLayers();
692
754
  let totalRows = 0;
@@ -709,7 +771,7 @@ const inputs = {
709
771
  }
710
772
 
711
773
  console.table(layerCount)
712
- console.log(`Total number of rows in all system layers : ${numberWithCommas(totalRows)} .`)
774
+ logger.info(`Total number of rows in all system layers : ${numberWithCommas(totalRows)} .`)
713
775
 
714
776
  },
715
777
 
@@ -724,7 +786,7 @@ const inputs = {
724
786
  mins = inputParam[0].replace("--age ", "")
725
787
 
726
788
 
727
- console.log(`Querying attribute rules logs for ${parameters.service} for the last ${mins} minutes ...`)
789
+ logger.info(`Querying attribute rules logs for ${parameters.service} for the last ${mins} minutes ...`)
728
790
 
729
791
  const startTime = Date.now() - mins*60*1000
730
792
  const endTime = Date.now();
@@ -774,7 +836,7 @@ const inputs = {
774
836
  if (inputParam != null && inputParam.length > 0)
775
837
  mins = inputParam[0].replace("--age ", "")
776
838
 
777
- console.log(`Querying trace logs for ${parameters.service} for the last ${mins} minutes ...`)
839
+ logger.info(`Querying trace logs for ${parameters.service} for the last ${mins} minutes ...`)
778
840
  const startTime = Date.now() - mins*60*1000
779
841
  const endTime = Date.now();
780
842
  let result= await adminLog.query([102002], [parameters.service+ ".MapServer"], topLogCount, startTime ,endTime , "VERBOSE")
@@ -815,7 +877,7 @@ const inputs = {
815
877
  delete newMessage.message
816
878
 
817
879
  console.table([newMessage])
818
- console.log(m.message)
880
+ logger.info(m.message)
819
881
  })
820
882
 
821
883
  },
@@ -833,7 +895,7 @@ const inputs = {
833
895
  mins = inputParam[0].replace("--age ", "")
834
896
 
835
897
 
836
- console.log(`Querying validate logs for ${parameters.service} for the last ${mins} minutes ...`)
898
+ logger.info(`Querying validate logs for ${parameters.service} for the last ${mins} minutes ...`)
837
899
  const startTime = Date.now() - mins*60*1000
838
900
  const endTime = Date.now();
839
901
  let result= await adminLog.query([102003], [parameters.service+ ".MapServer"], topLogCount, startTime ,endTime , "VERBOSE")
@@ -898,7 +960,7 @@ const inputs = {
898
960
  delete newMessage.message
899
961
 
900
962
  console.table([newMessage])
901
- console.log(m.message)
963
+ logger.info(m.message)
902
964
  })
903
965
 
904
966
 
@@ -917,7 +979,7 @@ const inputs = {
917
979
  if (inputParam != null && inputParam.length > 0)
918
980
  mins = inputParam[0].replace("--age ", "")
919
981
 
920
- console.log(`Querying subnetwork logs for ${parameters.service} for the last ${mins} minutes ...`)
982
+ logger.info(`Querying subnetwork logs for ${parameters.service} for the last ${mins} minutes ...`)
921
983
  const startTime = Date.now() - mins*60*1000
922
984
  const endTime = Date.now();
923
985
  let result= await adminLog.query([102003], [parameters.service+ ".MapServer"], topLogCount, startTime ,endTime , "VERBOSE")
@@ -982,7 +1044,7 @@ const inputs = {
982
1044
  delete newMessage.message
983
1045
 
984
1046
  console.table([newMessage])
985
- console.log(m.message)
1047
+ logger.info(m.message)
986
1048
  })
987
1049
 
988
1050
 
@@ -999,7 +1061,7 @@ const inputs = {
999
1061
  if (inputParam != null && inputParam.length > 0)
1000
1062
  mins = inputParam[0].replace("--age ", "")
1001
1063
 
1002
- console.log(`Querying cursor sql logs for ${parameters.service} for the last ${mins} minutes ...`)
1064
+ logger.info(`Querying cursor sql logs for ${parameters.service} for the last ${mins} minutes ...`)
1003
1065
  const startTime = Date.now() - mins*60*1000
1004
1066
  const endTime = Date.now();
1005
1067
  let result= await adminLog.query([102023], [parameters.service+ ".MapServer"], topLogCount, startTime ,endTime , "DEBUG")
@@ -1015,7 +1077,7 @@ const inputs = {
1015
1077
 
1016
1078
  allMessages = allMessages.concat(jsonRes.logMessages.filter(m => m.message.indexOf("EndCursor;") > -1))
1017
1079
  }
1018
- console.log ("Filtering messages...")
1080
+ logger.info ("Filtering messages...")
1019
1081
 
1020
1082
  allMessages = allMessages
1021
1083
  .map( m=> {
@@ -1029,21 +1091,21 @@ const inputs = {
1029
1091
  .slice(0, 10) ;//first 10
1030
1092
 
1031
1093
 
1032
- console.log("-----Top 10 SQL----")
1094
+ logger.info("-----Top 10 SQL----")
1033
1095
  let i =0;
1034
1096
  allMessages= allMessages.forEach(m =>
1035
1097
  {
1036
1098
 
1037
1099
  const x = m.message.split(";")
1038
1100
  x.shift()
1039
- console.log(`id: ${i++}`)
1040
- console.log(`\tAt: ${new Date(m.time)} (${m.time})`)
1041
- console.log(`\tUser: ${m.user}`)
1042
- console.log(`\tTotal Time: ${numberWithCommas(Math.round(m.elapsed*1000))} ms (Total time the cursor was opened)`)
1043
- console.log(`\tQuery Time: ${numberWithCommas(m.totalExecutionElapsed)} ms (includes search + data access nextRow)`)
1044
- console.log(`\tQuery:`)
1045
- x.forEach(a => console.log(`\t${a}`))
1046
- console.log(`\n`)
1101
+ logger.info(`id: ${i++}`)
1102
+ logger.info(`\tAt: ${new Date(m.time)} (${m.time})`)
1103
+ logger.info(`\tUser: ${m.user}`)
1104
+ logger.info(`\tTotal Time: ${numberWithCommas(Math.round(m.elapsed*1000))} ms (Total time the cursor was opened)`)
1105
+ logger.info(`\tQuery Time: ${numberWithCommas(m.totalExecutionElapsed)} ms (includes search + data access nextRow)`)
1106
+ logger.info(`\tQuery:`)
1107
+ x.forEach(a => logger.info(`\t${a}`))
1108
+ logger.info(`\n`)
1047
1109
 
1048
1110
  })
1049
1111
 
@@ -1155,11 +1217,11 @@ const inputs = {
1155
1217
  console.table(rules)
1156
1218
 
1157
1219
  const totalARExecution = rules.reduce( (prev, cur) => prev + cur["Total Cost (ms)"], 0)
1158
- console.log(`Total time spend executing attribute rules (${Math.round(totalARExecution)} ms) (${Math.round(totalARExecution/1000)} s) (${Math.round(totalARExecution/(1000*60))} m)`)
1220
+ logger.info(`Total time spend executing attribute rules (${Math.round(totalARExecution)} ms) (${Math.round(totalARExecution/1000)} s) (${Math.round(totalARExecution/(1000*60))} m)`)
1159
1221
 
1160
1222
  },
1161
1223
 
1162
- "^version$": () => console.log(version),
1224
+ "^version$": () => logger.info(version),
1163
1225
  "^clear$|^cls$": () => console.clear(),
1164
1226
  "^quit$": () => {
1165
1227
  if (rl) rl.close();
@@ -1184,7 +1246,7 @@ const inputs = {
1184
1246
 
1185
1247
  while(true) {
1186
1248
  const result = await un.query(layerId, `1=1`, undefined, undefined, ["globalId"], "sde.DEFAULT", offset, recordCount)
1187
- console.log(`Processing ${recordCount} rows`)
1249
+ logger.info(`Processing ${recordCount} rows`)
1188
1250
  //for each assocaition check if its valid
1189
1251
  for (let i = 0 ; i < result.features.length; i++){
1190
1252
  const row = result.features[i]
@@ -1299,7 +1361,7 @@ function numberWithCommas(x) {
1299
1361
  /*
1300
1362
  rl.question("What is your name ? ", function(name) {
1301
1363
  rl.question("Where do you live ? ", function(country) {
1302
- console.log(`${name}, is a citizen of ${country}`);
1364
+ logger.info(`${name}, is a citizen of ${country}`);
1303
1365
  rl.close();
1304
1366
  });
1305
1367
  });
@@ -1312,7 +1374,7 @@ function setupReadLine() {
1312
1374
  });
1313
1375
 
1314
1376
  rl.on("close", function() {
1315
- console.log("\nbye");
1377
+ logger.info("\nbye");
1316
1378
  process.exit(0);
1317
1379
  });
1318
1380
 
@@ -1334,7 +1396,7 @@ export async function run (){
1334
1396
  console.error(`Minimum required node js is ${minVer} your version is ${process.version}`)
1335
1397
  process.exit(0);
1336
1398
  }
1337
- console.log(`uncli ${version} is experimental command line utility for basic utility network services. Use as is.`)
1399
+ logger.info(`uncli ${version} is experimental command line utility for basic utility network services. Use as is.`)
1338
1400
  parameters = await parseInput( )
1339
1401
  //set certificate verification
1340
1402
  const verifyCert = parameters["verify"] === 'true' ? 1 : 0;
package/logger.mjs CHANGED
@@ -1,9 +1,23 @@
1
1
  const logger = {}
2
- logger.info = console.log
3
- logger.error = console.error
2
+ logger.info = m => console.log (`${shortDate()}: ${m}`)
3
+ logger.error =m => console.error (`${shortDate()}: ${m}`)
4
4
 
5
5
  export default logger;
6
6
 
7
+ function shortDate()
8
+ {
9
+
10
+ const t = new Date();
11
+ const date = ('0' + t.getDate()).slice(-2);
12
+ const month = ('0' + (t.getMonth() + 1)).slice(-2);
13
+ const year = t.getFullYear();
14
+ const hours = ('0' + t.getHours()).slice(-2);
15
+ const minutes = ('0' + t.getMinutes()).slice(-2);
16
+ const seconds = ('0' + t.getSeconds()).slice(-2);
17
+ const time = `${month}/${date}/${year}:${hours}:${minutes}:${seconds}`;
18
+ return time;
19
+ }
20
+
7
21
  /*
8
22
  import winston from "winston"
9
23
 
package/makerequest.mjs CHANGED
@@ -28,25 +28,28 @@ export function makeRequest (opts) {
28
28
 
29
29
  let f;
30
30
  try {
31
+
31
32
  const nodeFetch = await import ("node-fetch");
32
33
  f = nodeFetch.default;
33
34
  }
34
35
  catch(ex) {
35
36
  f = fetch;
36
37
  }
37
-
38
-
38
+
39
+ let jsonRes
40
+
39
41
  const result = await f(opts.url, {
40
42
  "method" : opts.method,
41
43
  "headers": headers,
42
44
  "body": params
43
45
  });
44
46
 
45
- const jsonRes = await result.json();
46
-
47
+ jsonRes = await result.json();
48
+
47
49
  if (typeof jsonRes !== "object")
48
50
  jsonRes = JSON.parse(jsonRes);
49
51
 
52
+
50
53
  resolve(jsonRes);
51
54
 
52
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "un-cli",
3
- "version": "0.0.72",
3
+ "version": "0.0.75",
4
4
  "description": "Command line interface for working with ArcGIS Utility Network Extension",
5
5
  "main": "index.mjs",
6
6
  "bin": {
package/un.mjs CHANGED
File without changes
@@ -21,12 +21,14 @@ export class UtilityNetwork {
21
21
  this.featureServiceUrl = featureServiceUrl;
22
22
  this.token = token;
23
23
  this.gdbVersion = gdbVersion;
24
+ this.sourceMapping = {}
24
25
  }
25
26
 
26
27
  ///first function one should call after creating an instance of a utility network
27
28
  load ()
28
29
  {
29
30
  let thisObj = this;
31
+
30
32
  return new Promise (function (resolve, reject)
31
33
  {
32
34
  //run async mode
@@ -68,7 +70,30 @@ export class UtilityNetwork {
68
70
 
69
71
  thisObj.dataElement = undataElement.layerDataElements[0].dataElement;
70
72
  thisObj.layerDefinition = unLayerDef
71
- thisObj.subnetLineLayerId = thisObj.getSubnetLineLayerId();
73
+ thisObj.subnetLineLayerId = thisObj.getSubnetLineLayerId();
74
+
75
+ //build out source mapping hash
76
+ let domainNetworks = thisObj.dataElement.domainNetworks;
77
+ let layerObj = undefined;
78
+
79
+ for (let i = 0; i < domainNetworks.length; i ++)
80
+ {
81
+ let domainNetwork = domainNetworks[i];
82
+ for (let j = 0; j < domainNetwork.junctionSources.length; j ++)
83
+ {
84
+ layerObj = {type: domainNetwork.junctionSources[j].shapeType, layerId: domainNetwork.junctionSources[j].layerId}
85
+ layerObj.type = layerObj.type.replace("esriGeometry", "").toLowerCase();
86
+ thisObj.sourceMapping["s" + domainNetwork.junctionSources[j].sourceId] = layerObj
87
+ }
88
+
89
+ for (let j = 0; j < domainNetwork.edgeSources.length; j ++)
90
+ {
91
+ layerObj = {type: domainNetwork.edgeSources[j].shapeType, layerId: domainNetwork.edgeSources[j].layerId}
92
+ layerObj.type = layerObj.type.replace("esriGeometry", "").toLowerCase();
93
+ thisObj.sourceMapping["s" + domainNetwork.edgeSources[j].sourceId] = layerObj
94
+ }
95
+ }
96
+
72
97
  resolve(thisObj);
73
98
  }
74
99
  else
@@ -333,16 +358,49 @@ export class UtilityNetwork {
333
358
  if (objectids != undefined)
334
359
  queryJson.objectIds = objectids;
335
360
  queryJson.layerId = layerId
336
- return new Promise((resolve, reject) => {
361
+ return new Promise(async(resolve, reject) => {
362
+
363
+
364
+
365
+ let rowsJson;
366
+ let allRowsJson;
367
+ let recordOffset = 0;
368
+
369
+ try {
370
+
371
+ do {
372
+ queryJson.resultOffset = recordOffset;
373
+ rowsJson = await makeRequest({method: 'POST', params: queryJson, url: this.featureServiceUrl + "/" + layerId + "/query"}) ;
374
+ recordOffset = recordOffset + resultRecordCount + 1;
375
+ rowsJson.obj = obj;
376
+
377
+ if (!allRowsJson)
378
+ allRowsJson = rowsJson
379
+ else
380
+ allRowsJson?.features.push(...rowsJson?.features)
381
+ //page the result until done
382
+ }
383
+ while(rowsJson?.exceededTransferLimit == true)
384
+
385
+ resolve(allRowsJson);
386
+ }
387
+ catch(ex){
388
+ reject("failed to query" + JSON.stringify(ex))
389
+ }
337
390
 
338
- makeRequest({method: 'POST', params: queryJson, url: this.featureServiceUrl + "/" + layerId + "/query"}).then(rowsJson=> {
339
- rowsJson.obj = obj;
340
- resolve(rowsJson);
341
- }).catch(rej => reject("failed to query"));
342
391
 
392
+
393
+
343
394
  });
344
395
 
345
-
396
+
397
+
398
+ // }
399
+ // while(jsonRes?.exceededTransferLimit == true)
400
+ // if (!allJsonRes)
401
+ // allJsonRes = jsonRes
402
+ // else
403
+ // allJsonRes?.features.push(...jsonRes?.features)
346
404
  }
347
405
  //get the terminal configuration using the id
348
406
  getTerminalConfiguration(terminalConfigurationId)
@@ -538,8 +596,10 @@ export class UtilityNetwork {
538
596
  //get layer id from Source Id used to map sourceid to layer id
539
597
  getLayerIdfromSourceId(sourceId)
540
598
  {
599
+
600
+ return this.sourceMapping["s" + sourceId]
601
+ /*
541
602
  let domainNetworks = this.dataElement.domainNetworks;
542
- let layerObj = undefined;
543
603
 
544
604
  for (let i = 0; i < domainNetworks.length; i ++)
545
605
  {
@@ -561,6 +621,7 @@ export class UtilityNetwork {
561
621
 
562
622
  if (layerObj != undefined)
563
623
  layerObj.type = layerObj.type.replace("esriGeometry", "").toLowerCase();
624
+ */
564
625
 
565
626
  return layerObj;
566
627
  }
@@ -958,6 +1019,27 @@ export class UtilityNetwork {
958
1019
 
959
1020
 
960
1021
 
1022
+ updateIsConnected(async=false) {
1023
+
1024
+ let thisObj = this;
1025
+ let ar = thisObj.featureServiceUrl.split("/");
1026
+ ar[ar.length-1]="UtilityNetworkServer";
1027
+ let updateisconnectedURL = ar.join("/") + "/updateIsConnected"
1028
+
1029
+ let payload = {
1030
+ f: "json",
1031
+ token: this.token,
1032
+ async: async
1033
+ }
1034
+ let un = this;
1035
+
1036
+ return makeRequest({method:'POST', params: payload, url: updateisconnectedURL })
1037
+
1038
+
1039
+
1040
+ }
1041
+
1042
+
961
1043
  updateSubnetworks(domainNetworkName, tierName, subnetworkName, async=false) {
962
1044
 
963
1045
  let thisObj = this;