public override void Migrate()
        {
            // get all Umbraco.Tags datatypes
            var dataTypeDtos = Database.Fetch <DataTypeDto>(Context.SqlContext.Sql()
                                                            .Select <DataTypeDto>()
                                                            .From <DataTypeDto>()
                                                            .Where <DataTypeDto>(x => x.EditorAlias == Constants.PropertyEditors.Aliases.Tags));

            // get a dummy editor for deserialization
            var editor = new TagConfigurationEditor();

            foreach (var dataTypeDto in dataTypeDtos)
            {
                // need to check storageType on raw dictionary, as TagConfiguration would have a default value
                var dictionary = JsonConvert.DeserializeObject <JObject>(dataTypeDto.Configuration);

                // if missing, use TagConfiguration to properly update the configuration
                // due to ... reasons ... the key can start with a lower or upper 'S'
                if (!dictionary.ContainsKey("storageType") && !dictionary.ContainsKey("StorageType"))
                {
                    var configuration = (TagConfiguration)editor.FromDatabase(dataTypeDto.Configuration);
                    configuration.StorageType = TagsStorageType.Csv;
                    dataTypeDto.Configuration = ConfigurationEditor.ToDatabase(configuration);
                    Database.Update(dataTypeDto);
                }
            }
        }
示例#2
0
        public override void Migrate()
        {
            var dataTypes = GetDataTypes("Umbraco.Date");

            foreach (var dataType in dataTypes)
            {
                DateTimeConfiguration config;
                try
                {
                    config = (DateTimeConfiguration) new CustomDateTimeConfigurationEditor().FromDatabase(
                        dataType.Configuration);
                }
                catch (Exception ex)
                {
                    Logger.Error <DropDownPropertyEditorsMigration>(
                        ex,
                        "Invalid property editor configuration detected: \"{Configuration}\", cannot convert editor, values will be cleared",
                        dataType.Configuration);

                    continue;
                }

                config.OffsetTime = false;

                dataType.EditorAlias   = Constants.PropertyEditors.Aliases.DateTime;
                dataType.Configuration = ConfigurationEditor.ToDatabase(config);

                Database.Update(dataType);
            }
        }
示例#3
0
    public static DataTypeDto BuildDto(IDataType entity, IConfigurationEditorJsonSerializer serializer)
    {
        var dataTypeDto = new DataTypeDto
        {
            EditorAlias   = entity.EditorAlias,
            NodeId        = entity.Id,
            DbType        = entity.DatabaseType.ToString(),
            Configuration = ConfigurationEditor.ToDatabase(entity.Configuration, serializer),
            NodeDto       = BuildNodeDto(entity),
        };

        return(dataTypeDto);
    }
示例#4
0
    private void UpdateDataType(DataTypeDto dataType, ValueListConfiguration config, bool isMultiple)
    {
        dataType.DbType      = ValueStorageType.Nvarchar.ToString();
        dataType.EditorAlias = Constants.PropertyEditors.Aliases.DropDownListFlexible;

        var flexConfig = new DropDownFlexibleConfiguration {
            Items = config.Items, Multiple = isMultiple
        };

        dataType.Configuration = ConfigurationEditor.ToDatabase(flexConfig, _configurationEditorJsonSerializer);

        Database.Update(dataType);
    }
    protected override void Migrate()
    {
        List <DataTypeDto> dataTypes = GetDataTypes(Constants.PropertyEditors.Legacy.Aliases.Date);

        foreach (DataTypeDto dataType in dataTypes)
        {
            DateTimeConfiguration config;
            try
            {
                config = (DateTimeConfiguration) new CustomDateTimeConfigurationEditor(
                    _ioHelper,
                    _editorConfigurationParser).FromDatabase(
                    dataType.Configuration, _configurationEditorJsonSerializer);

                // If the Umbraco.Date type is the default from V7 and it has never been updated, then the
                // configuration is empty, and the format stuff is handled by in JS by moment.js. - We can't do that
                // after the migration, so we force the format to the default from V7.
                if (string.IsNullOrEmpty(dataType.Configuration))
                {
                    config.Format = "YYYY-MM-DD";
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(
                    ex,
                    "Invalid property editor configuration detected: \"{Configuration}\", cannot convert editor, values will be cleared",
                    dataType.Configuration);

                continue;
            }

            config.OffsetTime = false;

            dataType.EditorAlias   = Constants.PropertyEditors.Aliases.DateTime;
            dataType.Configuration = ConfigurationEditor.ToDatabase(config, _configurationEditorJsonSerializer);

            Database.Update(dataType);
        }
    }