Ejemplo n.º 1
0
 public bool DeepEquals(ContentTypeDescription?other)
 {
     return(other is not null &&
            CType == other.CType &&
            Name == other.Name &&
            ContentDescription == other.ContentDescription &&
            PreviewImage == other.PreviewImage &&
            Priority == other.Priority &&
            Reminder == other.Reminder &&
            Properties.DeepEqualsList(other.Properties) &&
            TagMetadata.DeepEqualsList(other.TagMetadata) &&
            TagMetadataItems.DeepEqualsDictionary(other.TagMetadataItems) &&
            UsageExamples.DeepEqualsListNaive(other.UsageExamples) &&
            ShowInContentEditor == other.ShowInContentEditor &&
            TypeOf == other.TypeOf &&
            BindIdentifierToProperty == other.BindIdentifierToProperty &&
            BoundRegex == other.BoundRegex &&
            ForceIdentifierBinding == other.ForceIdentifierBinding &&
            AllowComments == other.AllowComments &&
            AutoEnglishPropertyFallback == other.AutoEnglishPropertyFallback &&
            BulkUploadable == other.BulkUploadable &&
            Previews.DeepEqualsList(other.Previews) &&
            SuppressCmsPath == other.SuppressCmsPath &&
            PropertySections.DeepEqualsList(other.PropertySections));
 }
Ejemplo n.º 2
0
 private void SetMetadata(TagMetadata data)
 {
     this._data     = data;
     this.Subtitle  = data.Title;
     this.ImagePath = data.TagUri;
     this.Title     = data.Value;
     this.Code      = data.Value;
 }
Ejemplo n.º 3
0
        private static Dictionary <string, TagMetadata> CalculateTagMetadata(List <Post> downloadedPosts, List <Post> rejectedPosts, string tagMetadataPath = null)
        {
            var tagMetadata = new Dictionary <string, TagMetadata>();

            foreach (var post in downloadedPosts)
            {
                var tags = post.tags.Split(" ");

                foreach (var tag in tags)
                {
                    if (tagMetadata.ContainsKey(tag))
                    {
                        tagMetadata[tag].total++;
                        tagMetadata[tag].totalDownloaded++;
                    }
                    else
                    {
                        tagMetadata[tag] = new TagMetadata {
                            tag = tag, total = 1, totalDownloaded = 1
                        };
                    }
                }
            }

            foreach (var post in rejectedPosts)
            {
                var tags = post.tags.Split(" ");

                foreach (var tag in tags)
                {
                    if (tagMetadata.ContainsKey(tag))
                    {
                        tagMetadata[tag].total++;
                    }
                    else
                    {
                        tagMetadata[tag] = new TagMetadata {
                            tag = tag, total = 1, totalDownloaded = 0
                        };
                    }
                }
            }

            if (tagMetadataPath != null)
            {
                File.WriteAllLines(tagMetadataPath, tagMetadata.Keys.Select(key => $"{key},{tagMetadata[key].totalDownloaded},{tagMetadata[key].total},{Math.Round(((double)tagMetadata[key].totalDownloaded / tagMetadata[key].total) * 100, 2)}%"));
            }
            Console.WriteLine("Done scoring tags.");
            return(tagMetadata);
        }
Ejemplo n.º 4
0
        public object Create(object parent, object configContext, XmlNode section)
        {
            List <TagMetadata> myConfigObject = new List <TagMetadata>();

            foreach (XmlNode childNode in section.ChildNodes)
            {
                var r = new TagMetadata();

                r.TagName          = childNode.Attributes["tag"] != null ? childNode.Attributes["tag"].Value : null;
                r.NameAttrValue    = childNode.Attributes["name"] != null ? childNode.Attributes["name"].Value : null;
                r.ComparedAttrName = childNode.Attributes["attr"] != null ? childNode.Attributes["attr"].Value : null;

                myConfigObject.Add(r);
            }
            return(myConfigObject);
        }
Ejemplo n.º 5
0
        private void GenerateButton_Click(object sender, EventArgs e)
        {
            if (GetSelectedDAQHandle() == 0 || GetSelectedDeviceHandle() == 0)
            {
                MessageBox.Show("You must select a DAQ and a device to generate a CoreMini.");
                return;
            }
            UpdateDAQ();
            List <uint> messageHandles = new List <uint>();
            List <uint> signalHandles  = new List <uint>();

            foreach (ListViewItem item in SelectedChannelsListView.Items)
            {
                TagMetadata metadata = (TagMetadata)item.Tag;
                if (metadata.Type == TagMetadata.MetadataType.Message)
                {
                    messageHandles.Add(metadata.Handle);
                }
                else
                {
                    signalHandles.Add(metadata.Handle);
                }
            }

            GenerateParameters parameters = new GenerateParameters(
                messageHandles,
                signalHandles,
                CollectionNameTextBox.Text,
                int.Parse(MessageCountTextBox.Text),
                SleepMode,
                WakeMode,
                double.Parse(BusActivityThresholdTextBox.Text),
                RemoteWakeupCheckBox.Checked,
                StartNewFileOnWakeupCheckBox.Checked,
                double.Parse(OverallTimeoutTextBox.Text),
                double.Parse(ConnectionTimeoutTextBox.Text),
                double.Parse(VoltageCutoffTextBox.Text));

            Log("Generating CoreMini.");
            VehicleScapeAPI.Result result = VehicleScapeInterface.Generate(parameters, GetSelectedDAQHandle(), GetSelectedDeviceHandle());
            Log("Result: " + VehicleScapeAPI.ResultToString(result));
        }
Ejemplo n.º 6
0
        public static List<TagMetadata> ParseSmiliesFromHtml(HtmlDocument doc)
        {
            List<TagMetadata> list = null;
            try
            {
                list = new List<TagMetadata>();
                var nodes = doc.DocumentNode.Descendants(SMILEY_NODE_PARENT_ELEMENT)
                    .Where(node => node.GetAttributeValue("class", "").Equals(SMILEY_NODE_ATTRIBUTE_VALUE));

                foreach (var node in nodes)
                {
                    TagMetadata data = new TagMetadata()
                        .ParseValue(node)
                        .ParseTitleAndUri(node);

                    list.Add(data);
                }
            }
            catch (Exception) { }
            return list;
        }
Ejemplo n.º 7
0
        private static TagMetadata ParseTag(HtmlNode node)
        {
            TagMetadata tag = new TagMetadata();
            var imgNode = node.Descendants("img").FirstOrDefault();
            if (imgNode != null)
            {
                tag.TagUri = imgNode.GetAttributeValue("src", string.Empty);
                tag.Title = imgNode.GetAttributeValue("alt", string.Empty);
            }

            var inputNode = node.Descendants("input").FirstOrDefault();
            if (inputNode != null)
                tag.Value = inputNode.GetAttributeValue("value", string.Empty);

            return tag;
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates a new <see cref="ElasticsearchTagDefinition"/> object.
 /// </summary>
 /// <param name="historian">The owning historian.</param>
 /// <param name="id">The tag ID.</param>
 /// <param name="settings">The tag settings.</param>
 /// <param name="metadata">The tag metadata.</param>
 /// <param name="security">The tag security configuration.</param>
 /// <param name="initialTagValues">The initial tag values, to use with the exception and compression filters.</param>
 /// <param name="changeHistory">The change history information for the tag.</param>
 /// <exception cref="ArgumentNullException"><paramref name="historian"/> is <see langword="null"/>.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="security"/> is <see langword="null"/>.</exception>
 internal ElasticsearchTagDefinition(ElasticsearchHistorian historian, Guid id, TagSettings settings, TagMetadata metadata, TagSecurity security, InitialTagValues initialTagValues, IEnumerable <TagChangeHistoryEntry> changeHistory) : base(historian, id.ToString(), settings, metadata, security, initialTagValues, changeHistory)
 {
     _historian = historian ?? throw new ArgumentNullException(nameof(historian));
     IdAsGuid   = id;
 }
        public bool Equals(ContentTypeDescription input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     CType == input.CType ||
                     (CType != null && CType.Equals(input.CType))
                     ) &&
                 (
                     Name == input.Name ||
                     (Name != null && Name.Equals(input.Name))
                 ) &&
                 (
                     ContentDescription == input.ContentDescription ||
                     (ContentDescription != null && ContentDescription.Equals(input.ContentDescription))
                 ) &&
                 (
                     PreviewImage == input.PreviewImage ||
                     (PreviewImage != null && PreviewImage.Equals(input.PreviewImage))
                 ) &&
                 (
                     Priority == input.Priority ||
                     (Priority.Equals(input.Priority))
                 ) &&
                 (
                     Reminder == input.Reminder ||
                     (Reminder != null && Reminder.Equals(input.Reminder))
                 ) &&
                 (
                     Properties == input.Properties ||
                     (Properties != null && Properties.SequenceEqual(input.Properties))
                 ) &&
                 (
                     TagMetadata == input.TagMetadata ||
                     (TagMetadata != null && TagMetadata.SequenceEqual(input.TagMetadata))
                 ) &&
                 (
                     TagMetadataItems == input.TagMetadataItems ||
                     (TagMetadataItems != null && TagMetadataItems.SequenceEqual(input.TagMetadataItems))
                 ) &&
                 (
                     UsageExamples == input.UsageExamples ||
                     (UsageExamples != null && UsageExamples.SequenceEqual(input.UsageExamples))
                 ) &&
                 (
                     ShowInContentEditor == input.ShowInContentEditor ||
                     (ShowInContentEditor != null && ShowInContentEditor.Equals(input.ShowInContentEditor))
                 ) &&
                 (
                     TypeOf == input.TypeOf ||
                     (TypeOf != null && TypeOf.Equals(input.TypeOf))
                 ) &&
                 (
                     BindIdentifierToProperty == input.BindIdentifierToProperty ||
                     (BindIdentifierToProperty != null && BindIdentifierToProperty.Equals(input.BindIdentifierToProperty))
                 ) &&
                 (
                     BoundRegex == input.BoundRegex ||
                     (BoundRegex != null && BoundRegex.Equals(input.BoundRegex))
                 ) &&
                 (
                     ForceIdentifierBinding == input.ForceIdentifierBinding ||
                     (ForceIdentifierBinding != null && ForceIdentifierBinding.Equals(input.ForceIdentifierBinding))
                 ) &&
                 (
                     AllowComments == input.AllowComments ||
                     (AllowComments != null && AllowComments.Equals(input.AllowComments))
                 ) &&
                 (
                     AutoEnglishPropertyFallback == input.AutoEnglishPropertyFallback ||
                     (AutoEnglishPropertyFallback != null && AutoEnglishPropertyFallback.Equals(input.AutoEnglishPropertyFallback))
                 ) &&
                 (
                     BulkUploadable == input.BulkUploadable ||
                     (BulkUploadable != null && BulkUploadable.Equals(input.BulkUploadable))
                 ) &&
                 (
                     Previews == input.Previews ||
                     (Previews != null && Previews.SequenceEqual(input.Previews))
                 ) &&
                 (
                     SuppressCmsPath == input.SuppressCmsPath ||
                     (SuppressCmsPath != null && SuppressCmsPath.Equals(input.SuppressCmsPath))
                 ) &&
                 (
                     PropertySections == input.PropertySections ||
                     (PropertySections != null && PropertySections.SequenceEqual(input.PropertySections))
                 ));
        }
Ejemplo n.º 10
0
 public void SetMetadata(TagMetadata data)
 {
     this._data = data;
     this.Title = data.Title;
     FormatImage(data.TagUri);
 }
Ejemplo n.º 11
0
 public void Update(ContentTypeDescription?other)
 {
     if (other is null)
     {
         return;
     }
     if (CType != other.CType)
     {
         CType = other.CType;
         OnPropertyChanged(nameof(CType));
     }
     if (Name != other.Name)
     {
         Name = other.Name;
         OnPropertyChanged(nameof(Name));
     }
     if (ContentDescription != other.ContentDescription)
     {
         ContentDescription = other.ContentDescription;
         OnPropertyChanged(nameof(ContentDescription));
     }
     if (PreviewImage != other.PreviewImage)
     {
         PreviewImage = other.PreviewImage;
         OnPropertyChanged(nameof(PreviewImage));
     }
     if (Priority != other.Priority)
     {
         Priority = other.Priority;
         OnPropertyChanged(nameof(Priority));
     }
     if (Reminder != other.Reminder)
     {
         Reminder = other.Reminder;
         OnPropertyChanged(nameof(Reminder));
     }
     if (!Properties.DeepEqualsList(other.Properties))
     {
         Properties = other.Properties;
         OnPropertyChanged(nameof(Properties));
     }
     if (!TagMetadata.DeepEqualsList(other.TagMetadata))
     {
         TagMetadata = other.TagMetadata;
         OnPropertyChanged(nameof(TagMetadata));
     }
     if (!TagMetadataItems.DeepEqualsDictionary(other.TagMetadataItems))
     {
         TagMetadataItems = other.TagMetadataItems;
         OnPropertyChanged(nameof(TagMetadataItems));
     }
     if (!UsageExamples.DeepEqualsListNaive(other.UsageExamples))
     {
         UsageExamples = other.UsageExamples;
         OnPropertyChanged(nameof(UsageExamples));
     }
     if (ShowInContentEditor != other.ShowInContentEditor)
     {
         ShowInContentEditor = other.ShowInContentEditor;
         OnPropertyChanged(nameof(ShowInContentEditor));
     }
     if (TypeOf != other.TypeOf)
     {
         TypeOf = other.TypeOf;
         OnPropertyChanged(nameof(TypeOf));
     }
     if (BindIdentifierToProperty != other.BindIdentifierToProperty)
     {
         BindIdentifierToProperty = other.BindIdentifierToProperty;
         OnPropertyChanged(nameof(BindIdentifierToProperty));
     }
     if (BoundRegex != other.BoundRegex)
     {
         BoundRegex = other.BoundRegex;
         OnPropertyChanged(nameof(BoundRegex));
     }
     if (ForceIdentifierBinding != other.ForceIdentifierBinding)
     {
         ForceIdentifierBinding = other.ForceIdentifierBinding;
         OnPropertyChanged(nameof(ForceIdentifierBinding));
     }
     if (AllowComments != other.AllowComments)
     {
         AllowComments = other.AllowComments;
         OnPropertyChanged(nameof(AllowComments));
     }
     if (AutoEnglishPropertyFallback != other.AutoEnglishPropertyFallback)
     {
         AutoEnglishPropertyFallback = other.AutoEnglishPropertyFallback;
         OnPropertyChanged(nameof(AutoEnglishPropertyFallback));
     }
     if (BulkUploadable != other.BulkUploadable)
     {
         BulkUploadable = other.BulkUploadable;
         OnPropertyChanged(nameof(BulkUploadable));
     }
     if (!Previews.DeepEqualsList(other.Previews))
     {
         Previews = other.Previews;
         OnPropertyChanged(nameof(Previews));
     }
     if (SuppressCmsPath != other.SuppressCmsPath)
     {
         SuppressCmsPath = other.SuppressCmsPath;
         OnPropertyChanged(nameof(SuppressCmsPath));
     }
     if (!PropertySections.DeepEqualsList(other.PropertySections))
     {
         PropertySections = other.PropertySections;
         OnPropertyChanged(nameof(PropertySections));
     }
 }
Ejemplo n.º 12
0
 public SmileyDataModel(TagMetadata data)
     : this()
 {
     SetMetadata(data);
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Creates a new <see cref="RedisTagDefinition"/> object.
        /// </summary>
        /// <param name="historian">The owning historian.</param>
        /// <param name="id">The tag ID.</param>
        /// <param name="settings">The tag settings.</param>
        /// <param name="metadata">The metadata for the tag.</param>
        /// <param name="initialTagValues">The initial tag values, used to prime the exception and compression filters for the tag.</param>
        /// <param name="changeHistory">The change history for the tag.</param>
        private RedisTagDefinition(RedisHistorian historian, string id, TagSettings settings, TagMetadata metadata, InitialTagValues initialTagValues, IEnumerable <TagChangeHistoryEntry> changeHistory) : base(historian, id, settings, metadata, CreateTagSecurity(), initialTagValues, changeHistory)
        {
            _historian           = historian ?? throw new ArgumentNullException(nameof(historian));
            _tagDefinitionKey    = _historian.GetKeyForTagDefinition(Id);
            _snapshotKey         = _historian.GetKeyForSnapshotData(Id);
            _archiveKey          = _historian.GetKeyForRawData(Id);
            _archiveCandidateKey = _historian.GetKeyForArchiveCandidateData(Id);

            _archiveCandidateValue = new ArchiveCandidateValue(initialTagValues?.LastExceptionValue, initialTagValues?.CompressionAngleMinimum ?? Double.NaN, initialTagValues?.CompressionAngleMaximum ?? Double.NaN);

            Updated += TagUpdated;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Loads a tag definition from the Redis database.
        /// </summary>
        /// <param name="historian">The Redis historian to load the tag from.</param>
        /// <param name="tagId">The ID of the tag to load.</param>
        /// <param name="cancellationToken">The cancellation token for the request.</param>
        /// <returns>
        /// A task that will return the loaded tag definition.
        /// </returns>
        internal static async Task <RedisTagDefinition> Load(RedisHistorian historian, string tagId, CancellationToken cancellationToken)
        {
            var values = await historian.Connection.GetDatabase().HashGetAllAsync(historian.GetKeyForTagDefinition(tagId)).ConfigureAwait(false);

            cancellationToken.ThrowIfCancellationRequested();

            string      name        = null;
            string      description = null;
            string      units       = null;
            TagDataType dataType    = default(TagDataType);
            string      stateSet    = null;

            bool exceptionFilterEnabled = false;
            TagValueFilterDeviationType exceptionFilterLimitType = default(TagValueFilterDeviationType);
            double   exceptionFilterLimit      = 0;
            TimeSpan exceptionFilterWindowSize = default(TimeSpan);

            bool compressionFilterEnabled = false;
            TagValueFilterDeviationType compressionFilterLimitType = default(TagValueFilterDeviationType);
            double   compressionFilterLimit      = 0;
            TimeSpan compressionFilterWindowSize = default(TimeSpan);

            DateTime createdAt  = DateTime.MinValue;
            string   creator    = null;
            DateTime modifiedAt = DateTime.MinValue;
            string   modifiedBy = null;

            foreach (var item in values)
            {
                switch (item.Name.ToString())
                {
                case "NAME":
                    name = item.Value;
                    break;

                case "DESC":
                    description = item.Value;
                    break;

                case "UNITS":
                    units = item.Value;
                    break;

                case "TYPE":
                    dataType = (TagDataType)((int)item.Value);
                    break;

                case "SSET":
                    stateSet = item.Value;
                    break;

                case "EXC_ENABLED":
                    exceptionFilterEnabled = Convert.ToBoolean((int)item.Value);
                    break;

                case "EXC_LIMIT_TYPE":
                    exceptionFilterLimitType = (TagValueFilterDeviationType)((int)item.Value);
                    break;

                case "EXC_LIMIT":
                    exceptionFilterLimit = (double)item.Value;
                    break;

                case "EXC_WINDOW":
                    exceptionFilterWindowSize = TimeSpan.Parse(item.Value);
                    break;

                case "COM_ENABLED":
                    compressionFilterEnabled = Convert.ToBoolean((int)item.Value);
                    break;

                case "COM_LIMIT_TYPE":
                    compressionFilterLimitType = (TagValueFilterDeviationType)((int)item.Value);
                    break;

                case "COM_LIMIT":
                    compressionFilterLimit = (double)item.Value;
                    break;

                case "COM_WINDOW":
                    compressionFilterWindowSize = TimeSpan.Parse(item.Value);
                    break;

                case "MD_CREATEDAT":
                    createdAt = new DateTime((long)item.Value, DateTimeKind.Utc);
                    break;

                case "MD_CREATEDBY":
                    creator = item.Value;
                    break;

                case "MD_MODIFIEDAT":
                    modifiedAt = new DateTime((long)item.Value, DateTimeKind.Utc);
                    break;

                case "MD_MODIFIEDBY":
                    modifiedBy = item.Value;
                    break;
                }
            }

            if (String.IsNullOrWhiteSpace(name))
            {
                name = tagId;
            }

            var settings = new TagSettings()
            {
                Name                    = name,
                Description             = description,
                Units                   = units,
                DataType                = dataType,
                StateSet                = stateSet,
                ExceptionFilterSettings = new TagValueFilterSettingsUpdate()
                {
                    IsEnabled  = exceptionFilterEnabled,
                    LimitType  = exceptionFilterLimitType,
                    Limit      = exceptionFilterLimit,
                    WindowSize = exceptionFilterWindowSize
                },
                CompressionFilterSettings = new TagValueFilterSettingsUpdate()
                {
                    IsEnabled  = compressionFilterEnabled,
                    LimitType  = compressionFilterLimitType,
                    Limit      = compressionFilterLimit,
                    WindowSize = compressionFilterWindowSize
                }
            };

            var metadata = new TagMetadata(createdAt, creator, modifiedAt, modifiedBy);

            var snapshotTask         = LoadSnapshotValue(historian, tagId, cancellationToken);
            var lastArchivedTask     = LoadLastArchivedValue(historian, tagId, cancellationToken);
            var archiveCandidateTask = LoadArchiveCandidateValue(historian, tagId, cancellationToken);

            await Task.WhenAll(snapshotTask, lastArchivedTask, archiveCandidateTask).ConfigureAwait(false);

            cancellationToken.ThrowIfCancellationRequested();

            var initialValues = new InitialTagValues(snapshotTask.Result, lastArchivedTask.Result, archiveCandidateTask.Result.Value, archiveCandidateTask.Result.CompressionAngleMinimum, archiveCandidateTask.Result.CompressionAngleMaximum);

            var result = new RedisTagDefinition(historian,
                                                tagId,
                                                settings,
                                                metadata,
                                                initialValues,
                                                null);

            return(result);
        }
Ejemplo n.º 15
0
 public void SetMetadata(TagMetadata data)
 {
     this._data = data;
     this.Title = data.Title;
     FormatImage(data.TagUri);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Creates a new <see cref="InMemoryTagDefinition"/> object.
 /// </summary>
 /// <param name="historian">The owning historian.</param>
 /// <param name="id">The tag ID.</param>
 /// <param name="tagSettings">The tag settings.</param>
 /// <param name="metadata">The tag metadata.</param>
 /// <exception cref="ArgumentNullException"><paramref name="historian"/> is <see langword="null"/>.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="tagSettings"/> is <see langword="null"/>.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="metadata"/> is <see langword="null"/>.</exception>
 /// <exception cref="ValidationException"><paramref name="tagSettings"/> is not valid.</exception>
 internal InMemoryTagDefinition(InMemoryHistorian historian, string id, TagSettings tagSettings, TagMetadata metadata) : base(historian, id, tagSettings, metadata, CreateTagSecurity(), null, null)
 {
     _historian = historian ?? throw new ArgumentNullException(nameof(historian));
 }