/// <summary> /// Parses an instance of a <see cref="TagConfiguration"/> object to update this instance's properties. /// </summary> /// <param name="configuration"></param> public void FromConfiguration(TagConfiguration configuration) { try { this.suppressPropertyChangedEvents = true; this.objectId = configuration.ObjectId; this.Domain = configuration.Domain; this.Account = configuration.Account; this.PasswordHash = configuration.PasswordHash; this.PasswordHashMethod = configuration.PasswordHashMethod; this.LegalJid = configuration.LegalJid; this.RegistryJid = configuration.RegistryJid; this.ProvisioningJid = configuration.ProvisioningJid; this.HttpFileUploadJid = configuration.HttpFileUploadJid; this.HttpFileUploadMaxSize = configuration.HttpFileUploadMaxSize; this.LogJid = configuration.LogJid; this.MucJid = configuration.MucJid; this.PinHash = configuration.PinHash; this.UsePin = configuration.UsePin; this.LegalIdentity = configuration.LegalIdentity; // Do this last, as listeners will read the other properties when the event is fired. this.Step = configuration.Step; } finally { this.suppressPropertyChangedEvents = false; } }
public UAIniSetting() { InitializeComponent(); //设置默认选择项 opcConfig = ConfigurationManagerExtend.SectionsCast <OpcAddressConfiguration>("Address").FirstOrDefault().Value; tagConfig = ConfigurationManagerExtend.SectionsCast <TagConfiguration>("Tag").FirstOrDefault().Value; this.cmbOpcProtocol.Items.AddRange(new object[] { OpcProtocol.DA, OpcProtocol.UA }); this.cmbUseSecurity.Items.AddRange(new object[] { true, false }); this.cmbReconnectEnable.Items.AddRange(new object[] { true, false }); this.cmbOpcProtocol.SelectedIndexChanged += new System.EventHandler(this.cmbOpcProtocol_SelectedIndexChanged); this.cmbUseSecurity.SelectedIndexChanged += new System.EventHandler(this.cmbUseSecurity_SelectedIndexChanged); this.cmbOpcProtocol.SelectedItem = opcConfig.OpcProtocolByEnum; this.txtIP.Text = opcConfig.DaAddress.Ip; this.cmbServerName.Items.Add(opcConfig.DaAddress.ServerName); this.cmbServerName.SelectedIndex = 0; this.txtUri.Text = opcConfig.UaAddress.Uri; this.txtUserName.Text = opcConfig.UaAddress.UserName; this.txtPassword.Text = opcConfig.UaAddress.Password; this.cmbUseSecurity.SelectedItem = opcConfig.UaAddress.UseSecurity; this.cmbReconnectEnable.SelectedItem = opcConfig.ReconnectEnable; this.cmbReconnectInterval.SelectedItem = opcConfig.ReconnectInterval.ToString(); this.cmbTagsQueueNum.SelectedItem = tagConfig.TagsQueueNum.ToString(); LayoutInit(); }
private async Task CreateOrRestoreConfiguration() { TagConfiguration configuration; try { configuration = await this.sdk.StorageService.FindFirstDeleteRest <TagConfiguration>(); } catch (Exception findException) { this.sdk.LogService.LogException(findException, this.GetClassAndMethod(MethodBase.GetCurrentMethod())); configuration = null; } if (configuration is null) { configuration = new TagConfiguration(); try { await this.sdk.StorageService.Insert(configuration); } catch (Exception insertException) { this.sdk.LogService.LogException(insertException, this.GetClassAndMethod(MethodBase.GetCurrentMethod())); } } this.sdk.TagProfile.FromConfiguration(configuration); }
public static void Seed(AppDbContext context) { UserConfiguration.Seed(context); TagConfiguration.Seed(context); context.SaveChanges(); }
public static void Seed(AppDbContext context) { BehaviourTypeConfiguration.Seed(context); CardConfiguration.Seed(context); FrequencyTypeConfiguration.Seed(context); UserConfiguration.Seed(context); TagConfiguration.Seed(context); DashboardConfiguration.Seed(context); DashboardCardConfiguration.Seed(context); }
/// <summary> /// Sets tags on a content property, based on the property editor tags configuration. /// </summary> /// <param name="property">The property.</param> /// <param name="value">The property value.</param> /// <param name="tagConfiguration">The datatype configuration.</param> /// <param name="culture">A culture, for multi-lingual properties.</param> /// <remarks> /// <para>The value is either a string (delimited string) or an enumeration of strings (tag list).</para> /// <para>This is used both by the content repositories to initialize a property with some tag values, and by the /// content controllers to update a property with values received from the property editor.</para> /// </remarks> internal static void SetTagsValue(this Property property, object value, TagConfiguration tagConfiguration, string culture) { if (property == null) { throw new ArgumentNullException(nameof(property)); } if (tagConfiguration == null) { throw new ArgumentNullException(nameof(tagConfiguration)); } var storageType = tagConfiguration.StorageType; var delimiter = tagConfiguration.Delimiter; SetTagsValue(property, value, storageType, delimiter, culture); }
public void Conform() { var tags = new List <string>(); tags.Add("legalTag"); tags.Add("_my_little.pony"); tags.Add("-us"); tags.Add("apache$"); TagConfiguration.CoerceLegalTags(tags); Assert.AreEqual("legalTag", tags[0]); Assert.AreEqual("z_my_little.pony", tags[1]); Assert.AreEqual("z-us", tags[2]); Assert.AreEqual("apache_", tags[3]); }
private async Task AutoSave() { if (this.sdk.TagProfile.IsDirty) { this.sdk.TagProfile.ResetIsDirty(); try { TagConfiguration tc = this.sdk.TagProfile.ToConfiguration(); try { await this.sdk.StorageService.Update(tc); } catch (KeyNotFoundException) { await this.sdk.StorageService.Insert(tc); } } catch (Exception ex) { this.sdk.LogService.LogException(ex, this.GetClassAndMethod(MethodBase.GetCurrentMethod())); } } }
/// <summary> /// Converts the current instance into a <see cref="TagConfiguration"/> object for serialization. /// </summary> /// <returns></returns> public TagConfiguration ToConfiguration() { TagConfiguration clone = new TagConfiguration { ObjectId = this.objectId, Domain = this.Domain, Account = this.Account, PasswordHash = this.PasswordHash, PasswordHashMethod = this.PasswordHashMethod, LegalJid = this.LegalJid, RegistryJid = this.RegistryJid, ProvisioningJid = this.ProvisioningJid, HttpFileUploadJid = this.HttpFileUploadJid, HttpFileUploadMaxSize = this.HttpFileUploadMaxSize, LogJid = this.LogJid, MucJid = this.MucJid, PinHash = this.PinHash, UsePin = this.UsePin, LegalIdentity = this.LegalIdentity, Step = this.Step }; return(clone); }
/// <summary> /// Maps the dto property values to the persisted model /// </summary> internal void MapPropertyValuesForPersistence <TPersisted, TSaved>( TSaved contentItem, ContentPropertyCollectionDto dto, Func <TSaved, IProperty, object> getPropertyValue, Action <TSaved, IProperty, object> savePropertyValue, string culture) where TPersisted : IContentBase where TSaved : IContentSave <TPersisted> { // map the property values foreach (ContentPropertyDto propertyDto in dto.Properties) { // get the property editor if (propertyDto.PropertyEditor == null) { _logger.LogWarning("No property editor found for property {PropertyAlias}", propertyDto.Alias); continue; } // get the value editor // nothing to save/map if it is readonly IDataValueEditor valueEditor = propertyDto.PropertyEditor.GetValueEditor(); if (valueEditor.IsReadOnly) { continue; } // get the property IProperty property = contentItem.PersistedContent.Properties[propertyDto.Alias]; // prepare files, if any matching property and culture ContentPropertyFile[] files = contentItem.UploadedFiles .Where(x => x.PropertyAlias == propertyDto.Alias && x.Culture == propertyDto.Culture && x.Segment == propertyDto.Segment) .ToArray(); foreach (ContentPropertyFile file in files) { file.FileName = file.FileName.ToSafeFileName(ShortStringHelper); } // create the property data for the property editor var data = new ContentPropertyData(propertyDto.Value, propertyDto.DataType.Configuration) { ContentKey = contentItem.PersistedContent.Key, PropertyTypeKey = property.PropertyType.Key, Files = files }; // let the editor convert the value that was received, deal with files, etc object value = valueEditor.FromEditor(data, getPropertyValue(contentItem, property)); // set the value - tags are special TagsPropertyEditorAttribute tagAttribute = propertyDto.PropertyEditor.GetTagAttribute(); if (tagAttribute != null) { TagConfiguration tagConfiguration = ConfigurationEditor.ConfigurationAs <TagConfiguration>(propertyDto.DataType.Configuration); if (tagConfiguration.Delimiter == default) { tagConfiguration.Delimiter = tagAttribute.Delimiter; } var tagCulture = property.PropertyType.VariesByCulture() ? culture : null; property.SetTagsValue(_serializer, value, tagConfiguration, tagCulture); } else { savePropertyValue(contentItem, property, value); } } }