Esempio n. 1
0
        ///////////////////////

        protected override SyncAttempt <XElement> SerializeCore(IDataType item)
        {
            var node = InitializeBaseNode(item, item.Name, item.Level);

            var info = new XElement("Info",
                                    new XElement("Name", item.Name),
                                    new XElement("EditorAlias", item.EditorAlias),
                                    new XElement("DatabaseType", item.DatabaseType));

            // new XElement("SortOrder", item.SortOrder));

            if (item.Level != 1)
            {
                var folderNode = this.GetFolderNode(dataTypeService.GetContainers(item));
                if (folderNode != null)
                {
                    info.Add(folderNode);
                }
            }

            node.Add(info);

            var config = SerializeConfiguration(item);

            if (config != null)
            {
                node.Add(config);
            }

            return(SyncAttempt <XElement> .Succeed(item.Name, node, typeof(IDataType), ChangeType.Export));
        }
Esempio n. 2
0
        private void UpdateHomeDocumentType()
        {
            const string
                propertyName    = "Tenant Preferences",
                dataTypeName    = "Total Code Tenant Properties",
                oldDataTypeName = "Total Tode Tenant Properties";

            try
            {
                var existingDataType = dataTypeService.GetDataType(oldDataTypeName);
                if (existingDataType != null)
                {
                    existingDataType.Name = dataTypeName;
                    dataTypeService.Save(existingDataType);

                    var container   = dataTypeService.GetContainers(CONTAINER, 1).FirstOrDefault();
                    var containerId = -1;

                    if (container != null)
                    {
                        containerId = container.Id;
                    }

                    dataTypeService.Move(existingDataType, containerId);
                    ConnectorContext.AuditService.Add(AuditType.Move, -1, existingDataType.Id, "Data Type", $"Data Type '{propertyName}' has been updated and moved");
                }
            }
            catch (System.Exception ex)
            {
                logger.Error(typeof(_16_MoveTenantPreferencesPropertyType), ex.Message);
                logger.Error(typeof(_16_MoveTenantPreferencesPropertyType), ex.StackTrace);
            }
        }
Esempio n. 3
0
        public XElement Serialize(IDataType dataType)
        {
            var xml = new XElement("DataType");

            xml.Add(new XAttribute("Name", dataType.Name));
            //The 'ID' when exporting is actually the property editor alias (in pre v7 it was the IDataType GUID id)
            xml.Add(new XAttribute("Id", dataType.EditorAlias));
            xml.Add(new XAttribute("Definition", dataType.Key));
            xml.Add(new XAttribute("DatabaseType", dataType.DatabaseType.ToString()));
            xml.Add(new XAttribute("Configuration", JsonConvert.SerializeObject(dataType.Configuration, PropertyEditors.ConfigurationEditor.ConfigurationJsonSettings)));

            var folderNames = string.Empty;

            if (dataType.Level != 1)
            {
                //get url encoded folder names
                var folders = _dataTypeService.GetContainers(dataType)
                              .OrderBy(x => x.Level)
                              .Select(x => HttpUtility.UrlEncode(x.Name));

                folderNames = string.Join("/", folders.ToArray());
            }

            if (string.IsNullOrWhiteSpace(folderNames) == false)
            {
                xml.Add(new XAttribute("Folders", folderNames));
            }

            return(xml);
        }
Esempio n. 4
0
    public XElement Serialize(IDataType dataType)
    {
        var xml = new XElement("DataType");

        xml.Add(new XAttribute("Name", dataType.Name !));

        // The 'ID' when exporting is actually the property editor alias (in pre v7 it was the IDataType GUID id)
        xml.Add(new XAttribute("Id", dataType.EditorAlias));
        xml.Add(new XAttribute("Definition", dataType.Key));
        xml.Add(new XAttribute("DatabaseType", dataType.DatabaseType.ToString()));
        xml.Add(new XAttribute("Configuration", _configurationEditorJsonSerializer.Serialize(dataType.Configuration)));

        var folderNames = string.Empty;
        var folderKeys  = string.Empty;

        if (dataType.Level != 1)
        {
            // get URL encoded folder names
            IOrderedEnumerable <EntityContainer> folders = _dataTypeService.GetContainers(dataType)
                                                           .OrderBy(x => x.Level);

            folderNames = string.Join("/", folders.Select(x => WebUtility.UrlEncode(x.Name)).ToArray());
            folderKeys  = string.Join("/", folders.Select(x => x.Key).ToArray());
        }

        if (string.IsNullOrWhiteSpace(folderNames) == false)
        {
            xml.Add(new XAttribute("Folders", folderNames));
            xml.Add(new XAttribute("FolderKeys", folderKeys));
        }

        return(xml);
    }
        /// <summary>
        /// Exports an <see cref="IDataTypeDefinition"/> item to xml as an <see cref="XElement"/>
        /// </summary>
        /// <param name="dataTypeService"></param>
        /// <param name="dataTypeDefinition">IDataTypeDefinition type to export</param>
        /// <returns><see cref="XElement"/> containing the xml representation of the IDataTypeDefinition object</returns>
        public XElement Serialize(IDataTypeService dataTypeService, IDataTypeDefinition dataTypeDefinition)
        {
            var prevalues    = new XElement("PreValues");
            var prevalueList = dataTypeService.GetPreValuesCollectionByDataTypeId(dataTypeDefinition.Id)
                               .FormatAsDictionary();

            var sort = 0;

            foreach (var pv in prevalueList)
            {
                var prevalue = new XElement("PreValue");
                prevalue.Add(new XAttribute("Id", pv.Value.Id));
                prevalue.Add(new XAttribute("Value", pv.Value.Value ?? ""));
                prevalue.Add(new XAttribute("Alias", pv.Key));
                prevalue.Add(new XAttribute("SortOrder", sort));
                prevalues.Add(prevalue);
                sort++;
            }

            var xml = new XElement("DataType", prevalues);

            xml.Add(new XAttribute("Name", dataTypeDefinition.Name));
            //The 'ID' when exporting is actually the property editor alias (in pre v7 it was the IDataType GUID id)
            xml.Add(new XAttribute("Id", dataTypeDefinition.PropertyEditorAlias));
            xml.Add(new XAttribute("Definition", dataTypeDefinition.Key));
            xml.Add(new XAttribute("DatabaseType", dataTypeDefinition.DatabaseType.ToString()));

            var folderNames = string.Empty;

            if (dataTypeDefinition.Level != 1)
            {
                //get url encoded folder names
                var folders = dataTypeService.GetContainers(dataTypeDefinition)
                              .OrderBy(x => x.Level)
                              .Select(x => HttpUtility.UrlEncode(x.Name));

                folderNames = string.Join("/", folders.ToArray());
            }

            if (string.IsNullOrWhiteSpace(folderNames) == false)
            {
                xml.Add(new XAttribute("Folders", folderNames));
            }

            return(xml);
        }
Esempio n. 6
0
        public int CreateFolder(string name)
        {
            var folder = _dataTypeService.GetContainers(name, 1)
                         .FirstOrDefault();

            if (folder == null)
            {
                var attempt = _dataTypeService.CreateContainer(-1, name);
                if (attempt.Success)
                {
                    LogHelper.Info <DataTypeBuilder>("Created Folder: {0}", () => name);
                    return(attempt.Result.Entity.Id);
                }
                else
                {
                    LogHelper.Warn <DataTypeBuilder>("Failed to create folder: {0}", () => name);
                    return(-1);
                }
            }
            LogHelper.Info <DataTypeBuilder>("Found Existing Folder: {0} {1}", () => folder.Id, () => folder.Name);
            return(folder.Id);
        }
        public void Initialize()
        {
            try
            {
                var contentType = contentTypeService.Get(DOCUMENT_TYPE_ALIAS);

                if (contentType == null)
                {
                    return;
                }

                if (!contentType.PropertyGroups.Any(x => x.Name == NOTIFICATION_SETTINGS_TAB))
                {
                    contentType.AddPropertyGroup(NOTIFICATION_SETTINGS_TAB);
                }

                const string ddlNotificationPositions = "ddl Notification Positions";

                var dataTypeContainer   = dataTypeService.GetContainers(DATA_TYPE_CONTAINER, 1).FirstOrDefault();
                var dataTypeContainerId = -1;

                if (dataTypeContainer != null)
                {
                    dataTypeContainerId = dataTypeContainer.Id;
                }
                var exists = dataTypeService.GetDataType(ddlNotificationPositions) != null;
                if (!exists)
                {
                    var created = Web.Composing.Current.PropertyEditors.TryGet("Umbraco.DropDown.Flexible", out IDataEditor editor);
                    if (editor != null)
                    {
                        var positionList = new List <ValueListConfiguration.ValueListItem>();
                        positionList.Add(new ValueListConfiguration.ValueListItem {
                            Id = 1, Value = "Top Right"
                        });
                        positionList.Add(new ValueListConfiguration.ValueListItem {
                            Id = 2, Value = "Bottom Right"
                        });
                        positionList.Add(new ValueListConfiguration.ValueListItem {
                            Id = 3, Value = "Bottom Left"
                        });
                        positionList.Add(new ValueListConfiguration.ValueListItem {
                            Id = 4, Value = "Top Left"
                        });
                        positionList.Add(new ValueListConfiguration.ValueListItem {
                            Id = 5, Value = "Top Center"
                        });
                        positionList.Add(new ValueListConfiguration.ValueListItem {
                            Id = 6, Value = "Bottom Center"
                        });

                        DataType ddlNotificationPositionsDataType = new DataType(editor, dataTypeContainerId)
                        {
                            Name          = ddlNotificationPositions,
                            ParentId      = dataTypeContainerId,
                            Configuration = new DropDownFlexibleConfiguration()
                            {
                                Multiple = false,
                                Items    = positionList
                            }
                        };
                        dataTypeService.Save(ddlNotificationPositionsDataType);
                    }
                }
                var isNewPropertyAdded = false;
                if (!contentType.PropertyTypeExists("notificationPosition"))
                {
                    isNewPropertyAdded = true;
                    var ddlPositionsDataType = dataTypeService.GetDataType(ddlNotificationPositions);

                    PropertyType ddlPositionsPropType = new PropertyType(ddlPositionsDataType, "notificationPosition")
                    {
                        Name       = "Position",
                        Variations = ContentVariation.Culture
                    };
                    contentType.AddPropertyType(ddlPositionsPropType, NOTIFICATION_SETTINGS_TAB);
                }

                if (!contentType.PropertyTypeExists("notificationBgColor"))
                {
                    isNewPropertyAdded = true;
                    PropertyType notificationBackgroundColor = new PropertyType(dataTypeService.GetDataType(6018), "notificationBgColor")
                    {
                        Name       = "Background Color",
                        Variations = ContentVariation.Culture
                    };
                    contentType.AddPropertyType(notificationBackgroundColor, NOTIFICATION_SETTINGS_TAB);
                }

                if (!contentType.PropertyTypeExists("notificationWidth"))
                {
                    isNewPropertyAdded = true;
                    PropertyType widthPropType = new PropertyType(dataTypeService.GetDataType(-88), "notificationWidth")
                    {
                        Name        = "Width",
                        Description = "If required enter only numeric value",
                        Variations  = ContentVariation.Culture
                    };
                    contentType.AddPropertyType(widthPropType, NOTIFICATION_SETTINGS_TAB);
                }

                if (isNewPropertyAdded)
                {
                    contentTypeService.Save(contentType);
                    ConnectorContext.AuditService.Add(AuditType.New, -1, contentType.Id, "Document Type", $"Document Type '{DOCUMENT_TYPE_ALIAS}' has been updated");
                }
            }

            catch (Exception ex)
            {
                logger.Error(typeof(_39_HomeDocTypeNotificationSettings), ex.Message);
                logger.Error(typeof(_39_HomeDocTypeNotificationSettings), ex.StackTrace);
            }
        }
Esempio n. 8
0
        private void Reconfigure()
        {
            try
            {
                var homeDocType = contentTypeService.Get(DOCUMENT_TYPE_ALIAS);
                homeDocType.AddPropertyGroup(TAB_NAME);

                //if (!homeDocType.PropertyTypeExists("gameMessage"))
                //{

                //    var richTextEditor = dataTypeService.GetDataType("Full Rich Text Editor");
                //    PropertyType richTextPropType = new PropertyType(dataTypeService.GetDataType(richTextEditor.Id), "gameMessage")
                //    {
                //        Name = "Game Terms and Conditions",
                //        Description = "Terms and Conditions for playing games",
                //        Variations = ContentVariation.Culture
                //    };
                //    homeDocType.AddPropertyType(richTextPropType, TAB_NAME);
                //}

                if (homeDocType.PropertyTypeExists("gameMessage"))
                {
                    homeDocType.RemovePropertyType("gameMessage");
                    contentTypeService.Save(homeDocType);
                }

                if (!homeDocType.PropertyTypeExists("gameAgreeText"))
                {
                    PropertyType gameAgreePropType = new PropertyType(dataTypeService.GetDataType(-88), "gameAgreeText")
                    {
                        Name        = "Agreement text",
                        Description = "Agreement text with checkbox",
                        Variations  = ContentVariation.Culture
                    };
                    homeDocType.AddPropertyType(gameAgreePropType, TAB_NAME);

                    PropertyType playButtonTextPropType = new PropertyType(dataTypeService.GetDataType(-88), "playButtonText")
                    {
                        Name        = "Play Button Text",
                        Description = "Text for the play button",
                        Variations  = ContentVariation.Culture
                    };
                    homeDocType.AddPropertyType(playButtonTextPropType, TAB_NAME);

                    PropertyType demoButtonTextPropType = new PropertyType(dataTypeService.GetDataType(-88), "demoButtonText")
                    {
                        Name        = "Demo Button Text",
                        Description = "Text for the demo button",
                        Variations  = ContentVariation.Culture
                    };
                    homeDocType.AddPropertyType(demoButtonTextPropType, TAB_NAME);

                    var mediaPickerContainer   = dataTypeService.GetContainers(DATA_TYPE_CONTAINER, 1).FirstOrDefault();
                    var mediaPickerContainerId = -1;

                    if (mediaPickerContainer != null)
                    {
                        mediaPickerContainerId = mediaPickerContainer.Id;
                    }

                    var mediaPickerDataType = dataTypeService.GetDataType("Demo Page Media Picker");


                    PropertyType demoPageImages = new PropertyType(dataTypeService.GetDataType(mediaPickerDataType.Id), "demoPageImages")
                    {
                        Name        = "Game Mode Images",
                        Description = "Images to display in the Game Mode Dialog",
                        Variations  = ContentVariation.Culture
                    };
                    homeDocType.AddPropertyType(demoPageImages, TAB_NAME);

                    contentTypeService.Save(homeDocType);
                    ConnectorContext.AuditService.Add(AuditType.Save, -1, homeDocType.Id, "DocumentType", $"Document Type '{DOCUMENT_TYPE_ALIAS}' has been updated");
                }
            }

            catch (Exception ex)
            {
                logger.Error(typeof(_24_HomeDocumentTypeGameModeDialog), ex.Message);
                logger.Error(typeof(_24_HomeDocumentTypeGameModeDialog), ex.StackTrace);
            }
        }
        private void UpdateDocumentType()
        {
            const string
                propertyAlias       = "bannerSlider",
                propertyName        = "Banner Slider",
                propertyDescription = "Slider with banner images";

            try
            {
                #region Nested Document Type
                var container   = contentTypeService.GetContainers(DOCUMENT_TYPE_CONTAINER, 1).FirstOrDefault();
                int containerId = -1;

                if (container != null)
                {
                    containerId = container.Id;
                }

                var contentType = contentTypeService.Get(NESTED_DOCUMENT_TYPE_ALIAS);
                if (contentType == null)
                {
                    ContentType docType = (ContentType)contentType ?? new ContentType(containerId)
                    {
                        Name          = NESTED_DOCUMENT_TYPE_NAME,
                        Alias         = NESTED_DOCUMENT_TYPE_ALIAS,
                        AllowedAsRoot = false,
                        Description   = NESTED_DOCUMENT_TYPE_DESCRIPTION,
                        Icon          = NESTED_DOCUMENT_TYPE_ICON,
                        IsElement     = true,
                        SortOrder     = 0,
                        ParentId      = contentTypeService.Get(NESTED_DOCUMENT_TYPE_PARENT_ALIAS).Id,
                        Variations    = ContentVariation.Culture
                    };

                    docType.AddPropertyGroup(SLIDERS_TAB);

                    #region Nested Document Type Properties
                    PropertyType ImagePropType = new PropertyType(dataTypeService.GetDataType(-88), "sliderItemImage")
                    {
                        Name        = "Image",
                        Description = "Image used in the Slider",
                        Variations  = ContentVariation.Nothing
                    };
                    docType.AddPropertyType(ImagePropType, SLIDERS_TAB);

                    PropertyType ButtonLabelPropType = new PropertyType(dataTypeService.GetDataType(-88), "sliderItemButtonLabel")
                    {
                        Name        = " Button Label",
                        Description = "Label for the Button",
                        Variations  = ContentVariation.Nothing
                    };
                    docType.AddPropertyType(ButtonLabelPropType, SLIDERS_TAB);

                    PropertyType TitlePropType = new PropertyType(dataTypeService.GetDataType(-88), "sliderItemTitle")
                    {
                        Name        = "Title",
                        Description = "Title for the banner item",
                        Variations  = ContentVariation.Nothing
                    };
                    docType.AddPropertyType(TitlePropType, SLIDERS_TAB);

                    PropertyType SubtitlePropType = new PropertyType(dataTypeService.GetDataType(-88), "sliderItemSubtitle")
                    {
                        Name        = "Subtitle",
                        Description = "Subtitle for the banner item",
                        Variations  = ContentVariation.Nothing
                    };
                    docType.AddPropertyType(SubtitlePropType, SLIDERS_TAB);

                    PropertyType UrlPropType = new PropertyType(dataTypeService.GetDataType(-88), "sliderItemUrl")
                    {
                        Name        = "Url",
                        Description = "The Link to the item",
                        Variations  = ContentVariation.Nothing
                    };
                    docType.AddPropertyType(UrlPropType, SLIDERS_TAB);
                    #endregion

                    contentTypeService.Save(docType);
                    ConnectorContext.AuditService.Add(AuditType.New, -1, docType.Id, "Document Type", $"Document Type '{NESTED_DOCUMENT_TYPE_ALIAS}' has been created");
                }

                else
                {
                    if (contentType.PropertyTypeExists("sliderItemImage") && contentType.PropertyTypes.Single(x => x.Alias == "sliderItemImage").DataTypeId == -88)
                    {
                        var mediaPickerContainer   = dataTypeService.GetContainers(DATA_TYPE_CONTAINER, 1).FirstOrDefault();
                        var mediaPickerContainerId = -1;

                        if (mediaPickerContainer != null)
                        {
                            mediaPickerContainerId = mediaPickerContainer.Id;
                        }

                        var dataTypeExists = dataTypeService.GetDataType("sliderItemImageMediaPicker") != null;
                        if (!dataTypeExists)
                        {
                            var created = Web.Composing.Current.PropertyEditors.TryGet("Umbraco.MediaPicker", out IDataEditor editor);
                            if (created)
                            {
                                DataType mediaPickerSliderImage = new DataType(editor, mediaPickerContainerId)
                                {
                                    Name          = "sliderItemImageMediaPicker",
                                    ParentId      = mediaPickerContainerId,
                                    Configuration = new MediaPickerConfiguration
                                    {
                                        DisableFolderSelect = true,
                                        Multiple            = false,
                                        OnlyImages          = true
                                    }
                                };
                                dataTypeService.Save(mediaPickerSliderImage);
                                contentType.PropertyTypes.Single(x => x.Alias == "sliderItemImage").DataTypeId = mediaPickerSliderImage.Id;
                                contentTypeService.Save(contentType);
                            }
                        }
                    }
                }
                #endregion

                #region Update Home Document Type
                var homeDocumentType = contentTypeService.Get(DOCUMENT_TYPE_ALIAS);

                var dataTypeContainer   = dataTypeService.GetContainers(DATA_TYPE_CONTAINER, 1).FirstOrDefault();
                var dataTypeContainerId = -1;

                if (dataTypeContainer != null)
                {
                    dataTypeContainerId = dataTypeContainer.Id;
                }

                var exists = dataTypeService.GetDataType(propertyName) != null;
                if (!exists)
                {
                    var created = Web.Composing.Current.PropertyEditors.TryGet("Umbraco.NestedContent", out IDataEditor editor);
                    if (!created)
                    {
                        DataType bannerSliderNestedDataType = new DataType(editor, dataTypeContainerId)
                        {
                            Name          = propertyName,
                            ParentId      = dataTypeContainerId,
                            Configuration = new NestedContentConfiguration
                            {
                                MinItems       = 0,
                                MaxItems       = 999,
                                ConfirmDeletes = true,
                                HideLabel      = false,
                                ShowIcons      = true,
                                ContentTypes   = new[]
                                {
                                    new NestedContentConfiguration.ContentType {
                                        Alias = NESTED_DOCUMENT_TYPE_ALIAS, TabAlias = SLIDERS_TAB
                                    }
                                }
                            }
                        };
                        dataTypeService.Save(bannerSliderNestedDataType);
                    }
                }
                if (!homeDocumentType.PropertyTypeExists("bannerSlider"))
                {
                    var          bannerSliderNestedDataType = dataTypeService.GetDataType(propertyName);
                    PropertyType BannerSlider = new PropertyType(bannerSliderNestedDataType, propertyAlias)
                    {
                        Name        = propertyName,
                        Description = propertyDescription,
                        Variations  = ContentVariation.Culture
                    };

                    var propertyGroup = homeDocumentType.PropertyGroups.SingleOrDefault(x => x.Name == SLIDERS_TAB);
                    if (propertyGroup == null)
                    {
                        homeDocumentType.AddPropertyGroup(SLIDERS_TAB);
                    }

                    homeDocumentType.AddPropertyType(BannerSlider, SLIDERS_TAB);
                    contentTypeService.Save(homeDocumentType);

                    ConnectorContext.AuditService.Add(AuditType.Save, -1, homeDocumentType.Id, "Document Type", $"Document Type '{DOCUMENT_TYPE_ALIAS}' has been updated");
                }

                #endregion
            }
            catch (System.Exception ex)
            {
                logger.Error(typeof(_17_HomeDocumentTypeSlider), ex.Message);
                logger.Error(typeof(_17_HomeDocumentTypeSlider), ex.StackTrace);
            }
        }
Esempio n. 10
0
 protected override IEnumerable <EntityContainer> GetContainers(IDataType item)
 => dataTypeService.GetContainers(item);
Esempio n. 11
0
        private void Reconfigure()
        {
            try
            {
                var oldControlAlias = "links";
                var contentType     = contentTypeService.Get(DOCUMENT_TYPE_ALIAS);

                if (contentType == null)
                {
                    return;
                }

                if (!contentType.PropertyTypeExists(oldControlAlias))
                {
                    return;
                }


                var MNTPpropertyName          = "Total Code MNTP Menu - Single Site";
                var NestedContentPropertyName = "Nested Content Footer Link Group";

                var dataTypeContainer   = dataTypeService.GetContainers(DATA_TYPE_CONTAINER, 1).FirstOrDefault();
                var dataTypeContainerId = -1;

                if (dataTypeContainer != null)
                {
                    dataTypeContainerId = dataTypeContainer.Id;
                }

                var exists = dataTypeService.GetDataType(MNTPpropertyName) != null;
                if (!exists)
                {
                    var created = Web.Composing.Current.PropertyEditors.TryGet("Umbraco.MultiNodeTreePicker", out IDataEditor editor);
                    if (editor != null)
                    {
                        DataType MNTPMenu_SingleSite = new DataType(editor, dataTypeContainerId)
                        {
                            Name          = MNTPpropertyName,
                            ParentId      = dataTypeContainerId,
                            Configuration = new MultiNodePickerConfiguration()
                            {
                                MaxNumber  = 1,
                                MinNumber  = 1,
                                ShowOpen   = false,
                                TreeSource = new MultiNodePickerConfigurationTreeSource()
                                {
                                    StartNodeQuery = "$site",
                                    ObjectType     = "content"
                                },
                            }
                        };
                        dataTypeService.Save(MNTPMenu_SingleSite);
                    }
                }


                var container   = contentTypeService.GetContainers(DOCUMENT_TYPE_CONTAINER, 1).FirstOrDefault();
                int containerId = -1;

                if (container != null)
                {
                    containerId = container.Id;
                }

                contentType = contentTypeService.Get(NESTED_FOOTERLINKSSETTING_DOCUMENT_TYPE_ALIAS);
                if (contentType == null)
                {
                    ContentType docType = (ContentType)contentType ?? new ContentType(containerId)
                    {
                        Name          = NESTED_FOOTERLINKSSETTING_DOCUMENT_TYPE_NAME,
                        Alias         = NESTED_FOOTERLINKSSETTING_DOCUMENT_TYPE_ALIAS,
                        AllowedAsRoot = false,
                        Description   = "",
                        Icon          = NESTED_DOCUMENT_TYPE_ICON,
                        IsElement     = true,
                        SortOrder     = 0,
                        ParentId      = 1087,
                        Variations    = ContentVariation.Culture
                    };

                    docType.AddPropertyGroup(NESTED_TAB_NAME);

                    #region Nested Document Type Properties

                    var          FooterContent_MNTPpropertyName = dataTypeService.GetDataType(MNTPpropertyName);
                    PropertyType internalLinkPropType           = new PropertyType(FooterContent_MNTPpropertyName, "internalLink")
                    {
                        Name        = "Internal Link",
                        Description = "",
                        Variations  = ContentVariation.Culture
                    };
                    docType.AddPropertyType(internalLinkPropType, NESTED_TAB_NAME);

                    PropertyType ExternalLinkTextPropType = new PropertyType(dataTypeService.GetDataType(-88), "externalLinkText")
                    {
                        Name        = "External Link Text",
                        Description = "",
                        Variations  = ContentVariation.Culture,
                    };
                    docType.AddPropertyType(ExternalLinkTextPropType, NESTED_TAB_NAME);

                    PropertyType LinkUrlPropType = new PropertyType(dataTypeService.GetDataType(-88), "externalLinkUrl")
                    {
                        Name             = "External Link URL",
                        Description      = "",
                        Variations       = ContentVariation.Culture,
                        ValidationRegExp = "https?://[a-zA-Z0-9-.]+.[a-zA-Z]{2,}"
                    };
                    docType.AddPropertyType(LinkUrlPropType, NESTED_TAB_NAME);


                    #endregion

                    contentTypeService.Save(docType);
                    ConnectorContext.AuditService.Add(AuditType.New, -1, docType.Id, "Document Type", $"Document Type '{NESTED_FOOTERLINKSSETTING_DOCUMENT_TYPE_ALIAS}' has been created");
                }


                exists = dataTypeService.GetDataType(NestedContentPropertyName) != null;
                if (!exists)
                {
                    var created = Web.Composing.Current.PropertyEditors.TryGet("Umbraco.NestedContent", out IDataEditor editor);
                    if (editor != null)
                    {
                        DataType bannerSliderNestedDataType = new DataType(editor, dataTypeContainerId)
                        {
                            Name          = NestedContentPropertyName,
                            ParentId      = dataTypeContainerId,
                            Configuration = new NestedContentConfiguration
                            {
                                MinItems       = 0,
                                MaxItems       = 999,
                                ConfirmDeletes = true,
                                HideLabel      = false,
                                ShowIcons      = true,
                                ContentTypes   = new[]
                                {
                                    new NestedContentConfiguration.ContentType {
                                        Alias = NESTED_FOOTERLINKSSETTING_DOCUMENT_TYPE_ALIAS, TabAlias = NESTED_TAB_NAME
                                    }
                                }
                            }
                        };
                        dataTypeService.Save(bannerSliderNestedDataType);
                    }
                }
                contentType = contentTypeService.Get(DOCUMENT_TYPE_ALIAS);
                contentType.RemovePropertyType(oldControlAlias);


                var          FooterContent_NestedContentPropertyName = dataTypeService.GetDataType(NestedContentPropertyName);
                PropertyType linksPropType = new PropertyType(FooterContent_NestedContentPropertyName, "footerLinks")
                {
                    Name        = "Links",
                    Description = "",
                    Variations  = ContentVariation.Culture
                };
                contentType.AddPropertyType(linksPropType, NESTED_TAB_NAME);

                contentTypeService.Save(contentType);
                ConnectorContext.AuditService.Add(AuditType.New, -1, contentType.Id, "Document Type", $"Document Type '{DOCUMENT_TYPE_ALIAS}' has been created");
            }
            catch (Exception ex)
            {
                logger.Error(typeof(_35_FooterLinkGroupChangesDocumentType), ex.Message);
                logger.Error(typeof(_35_FooterLinkGroupChangesDocumentType), ex.StackTrace);
            }
        }
        private void Reconfigure()
        {
            const string
                propertyAlias       = "gameSlider",
                propertyName        = "Game Slider",
                propertyDescription = "Slider with game banners";

            try
            {
                var casinoDocType = contentTypeService.Get(DOCUMENT_TYPE_ALIAS);
                // Create the Template if it doesn't exist
                if (fileService.GetTemplate(TEMPLATE_ALIAS) == null)
                {
                    //then create the template
                    Template  newTemplate    = new Template(TEMPLATE_NAME, TEMPLATE_ALIAS);
                    ITemplate masterTemplate = fileService.GetTemplate(PARENT_TEMPLATE_ALIAS);
                    newTemplate.SetMasterTemplate(masterTemplate);
                    fileService.SaveTemplate(newTemplate);

                    // Set template for document type
                    casinoDocType.AddTemplate(contentTypeService, newTemplate);

                    ContentHelper.CopyPhysicalAssets(new ReconfigureCasinoPageEmbeddedResources());

                    ConnectorContext.AuditService.Add(AuditType.Save, -1, newTemplate.Id, "Template", $"Teplate '{TEMPLATE_NAME}' has been created and assigned");
                }

                var dataTypeContainer   = dataTypeService.GetContainers(DATA_TYPE_CONTAINER, 1).FirstOrDefault();
                var dataTypeContainerId = -1;

                if (dataTypeContainer != null)
                {
                    dataTypeContainerId = dataTypeContainer.Id;
                }
                var exists = dataTypeService.GetDataType(propertyName) != null;
                if (!exists)
                {
                    var created = Web.Composing.Current.PropertyEditors.TryGet("Umbraco.NestedContent", out IDataEditor editor);
                    if (created)
                    {
                        DataType bannerSliderNestedDataType = new DataType(editor, dataTypeContainerId)
                        {
                            Name          = propertyName,
                            ParentId      = dataTypeContainerId,
                            Configuration = new NestedContentConfiguration
                            {
                                MinItems       = 0,
                                MaxItems       = 999,
                                ConfirmDeletes = true,
                                HideLabel      = false,
                                ShowIcons      = true,
                                ContentTypes   = new[]
                                {
                                    new NestedContentConfiguration.ContentType {
                                        Alias = NESTED_DOCUMENT_TYPE_ALIAS, TabAlias = SLIDERS_TAB
                                    }
                                }
                            }
                        };
                        dataTypeService.Save(bannerSliderNestedDataType);
                        ConnectorContext.AuditService.Add(AuditType.Save, -1, casinoDocType.Id, "Document Type", $"Document Type '{DOCUMENT_TYPE_ALIAS}' has been updated");
                    }
                }
                if (!casinoDocType.PropertyTypeExists(propertyAlias))
                {
                    var          bannerSliderNestedDataType = dataTypeService.GetDataType(propertyName);
                    PropertyType BannerSlider = new PropertyType(bannerSliderNestedDataType, propertyAlias)
                    {
                        Name        = propertyName,
                        Description = propertyDescription,
                        Variations  = ContentVariation.Culture
                    };
                    casinoDocType.AddPropertyGroup(SLIDERS_TAB);
                    casinoDocType.AddPropertyType(BannerSlider, SLIDERS_TAB);
                    contentTypeService.Save(casinoDocType);
                }
            }

            catch (Exception ex)
            {
                logger.Error(typeof(_10_CasinoPageIntegration), ex.Message);
                logger.Error(typeof(_10_CasinoPageIntegration), ex.StackTrace);
            }
        }
Esempio n. 13
0
        private void CreateDocumentType()
        {
            try
            {
                var richTextContainer   = dataTypeService.GetContainers(DATA_TYPE_CONTAINER, 1).FirstOrDefault();
                var richTextContainerId = -1;

                if (richTextContainer != null)
                {
                    richTextContainerId = richTextContainer.Id;
                }

                var dataTypeExists = dataTypeService.GetDataType("Full Rich Text Editor") != null;
                if (!dataTypeExists)
                {
                    var created = Web.Composing.Current.PropertyEditors.TryGet("Umbraco.TinyMCE", out IDataEditor editor);
                    if (created)
                    {
                        DataType richTextEditor = new DataType(editor, richTextContainerId)
                        {
                            Name          = "Full Rich Text Editor",
                            ParentId      = richTextContainerId,
                            Configuration = new RichTextConfiguration
                            {
                                Editor    = JObject.Parse("{\"toolbar\":[\"ace\",\"removeformat\",\"undo\",\"redo\",\"cut\",\"copy\",\"paste\",\"styleselect\",\"bold\",\"italic\",\"underline\",\"strikethrough\",\"alignleft\",\"aligncenter\",\"alignright\",\"alignjustify\",\"bullist\",\"numlist\",\"outdent\",\"indent\",\"link\",\"unlink\",\"anchor\",\"umbmediapicker\",\"umbmacro\",\"table\",\"umbembeddialog\",\"hr\",\"subscript\",\"superscript\",\"charmap\",\"rtl\",\"ltr\"],\"stylesheets\":[],\"maxImageSize\":500,\"mode\":\"classic\"}"),
                                HideLabel = true
                            }
                        };
                        dataTypeService.Save(richTextEditor);

                        var container   = contentTypeService.GetContainers(CONTAINER, 1).FirstOrDefault();
                        var containerId = container.Id;

                        string propertyName        = "Page Content",
                               propertyDescription = "Text to be displayed on the Page";

                        // categories page
                        var contentCategoriesType = contentTypeService.Get(CATEGORIES_DOCUMENT_TYPE_ALIAS);
                        if (contentCategoriesType != null)
                        {
                            PropertyType richTextPropType = new PropertyType(dataTypeService.GetDataType(richTextEditor.Id), "pageContent")
                            {
                                Name        = propertyName,
                                Description = propertyDescription,
                                Variations  = ContentVariation.Culture
                            };
                            contentCategoriesType.AddPropertyType(richTextPropType, TAB);
                            contentTypeService.Save(contentCategoriesType);
                            ConnectorContext.AuditService.Add(AuditType.Save, -1, contentCategoriesType.Id, "Document Type", $"Document Type '{CATEGORIES_DOCUMENT_TYPE_ALIAS}' has been updated");
                        }

                        // category page
                        var contentCategoryType = contentTypeService.Get(CATEGORY_DOCUMENT_TYPE_ALIAS);
                        if (contentCategoryType != null)
                        {
                            PropertyType richTextPropType = new PropertyType(dataTypeService.GetDataType(richTextEditor.Id), "pageContent")
                            {
                                Name        = propertyName,
                                Description = propertyDescription,
                                Variations  = ContentVariation.Culture
                            };
                            contentCategoryType.AddPropertyType(richTextPropType, TAB);
                            contentTypeService.Save(contentCategoryType);
                            ConnectorContext.AuditService.Add(AuditType.Save, -1, contentCategoryType.Id, "Document Type", $"Document Type '{CATEGORY_DOCUMENT_TYPE_ALIAS}' has been updated");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(typeof(_20_ContentPagesReconfiguration), ex.Message);
                logger.Error(typeof(_20_ContentPagesReconfiguration), ex.StackTrace);
            }
        }