2009-06-19 07:39:16 +00:00
using System ;
2013-07-23 13:16:18 +02:00
using System.Linq ;
2016-11-25 22:18:35 +01:00
using umbraco.BusinessLogic ;
2013-07-23 10:50:48 +10:00
using Umbraco.Core.Logging ;
2009-06-19 07:39:16 +00:00
namespace umbraco.editorControls
{
2013-07-23 13:16:18 +02:00
/// <summary>
/// Summary description for cms.businesslogic.datatype.DefaultDataKeyValue.
/// </summary>
2013-10-21 18:36:46 +11:00
[Obsolete("IDataType and all other references to the legacy property editors are no longer used this will be removed from the codebase in future versions")]
2009-06-19 07:39:16 +00:00
public class DefaultDataKeyValue : cms . businesslogic . datatype . DefaultData
2013-07-23 13:16:18 +02:00
{
public DefaultDataKeyValue ( cms . businesslogic . datatype . BaseDataType DataType )
: base ( DataType )
{ }
2009-06-19 07:39:16 +00:00
2013-07-23 13:16:18 +02:00
/// <summary>
/// Gets the values of from cmsDataTypePreValues table by id and puts them into a CDATA section
/// </summary>
/// <param name="xmlDocument"></param>
/// <returns></returns>
public override System . Xml . XmlNode ToXMl ( System . Xml . XmlDocument xmlDocument )
{
var value = string . Empty ;
try
{
// Don't query if there's nothing to query for..
if ( string . IsNullOrWhiteSpace ( Value . ToString ( ) ) = = false )
{
2016-11-25 22:18:35 +01:00
using ( var sqlHelper = Application . SqlHelper )
using ( var dr = sqlHelper . ExecuteReader ( string . Format ( "Select [value] from cmsDataTypeprevalues where id in ({0})" , sqlHelper . EscapeString ( Value . ToString ( ) ) ) ) )
2013-07-23 13:16:18 +02:00
{
2016-11-25 22:18:35 +01:00
while ( dr . Read ( ) )
{
value + = value . Length = = 0
? dr . GetString ( "value" )
: string . Format ( ",{0}" , dr . GetString ( "value" ) ) ;
}
2013-07-23 13:16:18 +02:00
}
}
}
catch ( Exception ex )
{
LogHelper . Error < DefaultDataKeyValue > ( "An exception occurred converting the property data to XML" , ex ) ;
}
return xmlDocument . CreateCDataSection ( value ) ;
}
}
2009-06-19 07:39:16 +00:00
}