public static LocalizableString GetLocalizableValue(UserConnection userConnection, string schemaName, string columnName, Guid recordId) { EntitySchemaQuery esq; EntitySchemaQueryColumn column; var result = new LocalizableString(); EntitySchemaManager entitySchemaManager = userConnection.EntitySchemaManager; SysUserInfo currentUser = userConnection.CurrentUser; CultureInfo currentUserCulture = currentUser.Culture; EntitySchema schema = entitySchemaManager.GetInstanceByName(schemaName); if (UseMultilanguageData) { esq = new EntitySchemaQuery(entitySchemaManager, schemaName); column = esq.AddColumn(columnName); esq.Filters.Add(esq.CreateFilterWithParameters( FilterComparisonType.Equal, schema.GetPrimaryColumnName(), recordId)); } else { Guid columnUId = schema.Columns.GetByName(columnName).UId; string lczSchemaName = schema.GetLocalizableStringsSchemaName(); esq = new EntitySchemaQuery(entitySchemaManager, lczSchemaName); column = esq.AddColumn("Value"); esq.Filters.Add(esq.CreateFilterWithParameters(FilterComparisonType.Equal, "ColumnUId", columnUId)); esq.Filters.Add(esq.CreateFilterWithParameters(FilterComparisonType.Equal, "Record", recordId)); esq.Filters.Add( esq.CreateFilterWithParameters(FilterComparisonType.Equal, "SysCulture", currentUser.SysCultureId)); } EntityCollection entities = esq.GetEntityCollection(userConnection); if (entities.Count > 0) { Entity entity = entities.First(); string lczValue = entity.GetTypedColumnValue <string>(column.Name); result.SetCultureValue(currentUserCulture, lczValue); } return(result); }
public void SaveLocalizableValue(string configJSON, string valuesJSON) { LocalizableStringConfig config = (LocalizableStringConfig)Json.Deserialize(configJSON, typeof(LocalizableStringConfig)); LocalizableValueConfig[] values = (LocalizableValueConfig[])Json.Deserialize(valuesJSON, typeof(LocalizableValueConfig[])); if (config == null) { return; } var result = new LocalizableString(); foreach (var lValue in values) { result.SetCultureValue(CultureInfo.GetCultureInfo(lValue.key), lValue.value); } var schema = UserConnection.EntitySchemaManager.GetInstanceByName(config.entityName); var entity = schema.CreateEntity(UserConnection); if (entity.FetchFromDB(config.recordId)) { CommonUtilities.SaveLocalizableValue(entity, result, config.columnName); } }