Example #1
0
        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);
        }
Example #2
0
 public static EntitySchema GetLocalizableStringsSchema(this EntitySchema schema)
 {
     return(schema.EntitySchemaManager.GetInstanceByName(schema.GetLocalizableStringsSchemaName()));
 }