22
22
using ApplyTagRequest = Aquarius . TimeSeries . Client . ServiceModels . Acquisition . ApplyTagRequest ;
23
23
using Attachment = Aquarius . TimeSeries . Client . ServiceModels . Publish . Attachment ;
24
24
using GetTags = Aquarius . TimeSeries . Client . ServiceModels . Provisioning . GetTags ;
25
+ using TagValueType = Aquarius . TimeSeries . Client . ServiceModels . Provisioning . TagValueType ;
25
26
26
27
namespace ObservationReportExporter
27
28
{
@@ -329,10 +330,7 @@ private void ValidateTimeSeriesConfiguration()
329
330
if ( ! Context . AttachmentTags . Any ( ) )
330
331
return ;
331
332
332
- var locationTags = TimeSeries
333
- . Provisioning
334
- . Get ( new GetTags ( ) )
335
- . Results
333
+ var locationTags = GetConfiguredTags ( )
336
334
. Where ( t => t . AppliesToAttachments )
337
335
. ToDictionary ( t => t . Key , t => t , StringComparer . InvariantCultureIgnoreCase ) ;
338
336
@@ -351,6 +349,62 @@ private void ValidateTimeSeriesConfiguration()
351
349
}
352
350
}
353
351
352
+ private List < Tag > GetConfiguredTags ( )
353
+ {
354
+ if ( TimeSeries . ServerVersion . IsLessThan ( MinimumUnifiedTagsAndExtendedAttributesVersion ) )
355
+ {
356
+ return TimeSeries
357
+ . Provisioning
358
+ . Get ( new GetHackTags ( ) )
359
+ . Results
360
+ . Select ( Convert )
361
+ . ToList ( ) ;
362
+ }
363
+
364
+ return TimeSeries
365
+ . Provisioning
366
+ . Get ( new GetTags ( ) )
367
+ . Results ;
368
+ }
369
+
370
+ private static readonly AquariusServerVersion MinimumUnifiedTagsAndExtendedAttributesVersion = AquariusServerVersion . Create ( "21.3" ) ;
371
+
372
+ private static Tag Convert ( HackTag hackValue )
373
+ {
374
+ return new Tag
375
+ {
376
+ Key = hackValue . Key ,
377
+ UniqueId = hackValue . UniqueId ,
378
+ AppliesToAttachments = hackValue . AppliesToAttachments ,
379
+ AppliesToLocationNotes = hackValue . AppliesToLocationNotes ,
380
+ AppliesToLocations = hackValue . AppliesToLocations ,
381
+ AppliesToReports = hackValue . AppliesToReports ,
382
+ AppliesToSensorsGauges = hackValue . AppliesToSensorsGauges ,
383
+ PickListValues = hackValue . PickListValues ,
384
+ ValueType = Convert ( hackValue . ValueType ) ,
385
+ } ;
386
+ }
387
+
388
+ private static TagValueType ? Convert ( HackTagValueType ? hackValue )
389
+ {
390
+ if ( ! hackValue . HasValue || ! SupportedTypes . TryGetValue ( hackValue . Value , out var tagValue ) )
391
+ return null ;
392
+
393
+ return tagValue ;
394
+ }
395
+
396
+ private static readonly Dictionary < HackTagValueType , TagValueType > SupportedTypes =
397
+ new Dictionary < HackTagValueType , TagValueType >
398
+ {
399
+ { HackTagValueType . Unknown , TagValueType . Unknown } ,
400
+ { HackTagValueType . None , TagValueType . None } ,
401
+ { HackTagValueType . PickList , TagValueType . PickList } ,
402
+ { HackTagValueType . Text , TagValueType . String } , // This is reason for all this fudge code
403
+ { HackTagValueType . Number , TagValueType . Number } ,
404
+ { HackTagValueType . Boolean , TagValueType . Boolean } ,
405
+ { HackTagValueType . DateTime , TagValueType . DateTime }
406
+ } ;
407
+
354
408
private void ExportAllLocations ( )
355
409
{
356
410
var exportedLocations = GetExportedLocations ( )
0 commit comments