Esempio n. 1
0
        public ChannelInfoViewModel(ChannelInfo channel, ChannelMeta channelMeta)
        {
            _channel     = channel;
            _channelMeta = channelMeta;

            this.Datasets = channel.Datasets
                            .Where(dataset => !dataset.Id.EndsWith("_status"))
                            .Select(dataset => new DatasetInfoViewModel(dataset, this)).ToList();
        }
Esempio n. 2
0
 private Channel CreateChannelResponse(ChannelInfo channel, ChannelMeta channelMeta)
 {
     return(new Channel()
     {
         Id = channel.Id,
         Name = channel.Name,
         Group = channel.Group,
         Unit = !string.IsNullOrWhiteSpace(channelMeta.Unit)
                 ? channelMeta.Unit
                 : channel.Unit,
         Description = !string.IsNullOrWhiteSpace(channelMeta.Description)
                 ? channelMeta.Description
                 : channel.Description,
         SpecialInfo = channelMeta.SpecialInfo
     });
 }
Esempio n. 3
0
        private static bool ApplyAggregationFilter(ChannelInfo channel, ChannelMeta channelMeta, Dictionary <AggregationFilter, string> filters, ILogger logger)
        {
            bool result = true;

            // channel
            if (filters.ContainsKey(AggregationFilter.IncludeChannel))
            {
                result &= Regex.IsMatch(channel.Name, filters[AggregationFilter.IncludeChannel]);
            }

            if (filters.ContainsKey(AggregationFilter.ExcludeChannel))
            {
                result &= !Regex.IsMatch(channel.Name, filters[AggregationFilter.ExcludeChannel]);
            }

            // group
            if (filters.ContainsKey(AggregationFilter.IncludeGroup))
            {
                result &= channel.Group.Split('\n').Any(groupName => Regex.IsMatch(groupName, filters[AggregationFilter.IncludeGroup]));
            }

            if (filters.ContainsKey(AggregationFilter.ExcludeGroup))
            {
                result &= !channel.Group.Split('\n').Any(groupName => Regex.IsMatch(groupName, filters[AggregationFilter.ExcludeGroup]));
            }

            // unit
            if (filters.ContainsKey(AggregationFilter.IncludeUnit))
            {
#warning Remove this special case check.
                if (channel.Unit == null)
                {
                    logger.LogWarning("Unit 'null' value detected.");
                    result &= false;
                }
                else
                {
                    var unit = !string.IsNullOrWhiteSpace(channelMeta.Unit)
                        ? channelMeta.Unit
                        : channel.Unit;

                    result &= Regex.IsMatch(unit, filters[AggregationFilter.IncludeUnit]);
                }
            }

            if (filters.ContainsKey(AggregationFilter.ExcludeUnit))
            {
#warning Remove this special case check.
                if (channel.Unit == null)
                {
                    logger.LogWarning("Unit 'null' value detected.");
                    result &= true;
                }
                else
                {
                    var unit = !string.IsNullOrWhiteSpace(channelMeta.Unit)
                        ? channelMeta.Unit
                        : channel.Unit;

                    result &= !Regex.IsMatch(unit, filters[AggregationFilter.ExcludeUnit]);
                }
            }

            return(result);
        }