public override string ConvertDbToString(Property property, PropertyType propertyType, IDataTypeService dataTypeService)
{
if(property.Value == null || property.Value.ToString() == "")
return string.Empty;
var archetype = ArchetypeHelper.Instance.DeserializeJsonToArchetype(property.Value.ToString(), propertyType.DataTypeDefinitionId);
foreach (var fieldset in archetype.Fieldsets)
{
foreach (var propDef in fieldset.Properties.Where(p => p.DataTypeGuid != null))
{
try
{
if(propDef == null || propDef.DataTypeGuid == null) continue;
var dtd = ArchetypeHelper.Instance.GetDataTypeByGuid(Guid.Parse(propDef.DataTypeGuid));
var propType = new PropertyType(dtd) {Alias = propDef.Alias};
var prop = new Property(propType, propDef.Value);
var propEditor = PropertyEditorResolver.Current.GetByAlias(dtd.PropertyEditorAlias);
propDef.Value = propEditor.ValueEditor.ConvertDbToString(prop, propType, dataTypeService);
}
catch (Exception ex)
{
LogHelper.Error<ArchetypePropertyValueEditor>(ex.Message, ex);
}
}
}
return archetype.SerializeForPersistence();
}