private void selectTypeCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            var types = PageFolderFacade.GetAllFolderTypes().ToList();

            Bindings.Add("Types", types);
            Bindings.Add("SelectedType", types[0]);
        }
        public Guid AddPost(string title, string description, string publicationStatus)
        {
            IPage page = PageManager.GetPageById(PageId, true);

            if (page != null)
            {
                var entry = DataFacade.BuildNew <Entries>();
                entry.Date              = DateTime.Now;
                entry.Title             = title;
                entry.Content           = RelativeMediaUrl(MarkupTransformationServices.TidyHtml(description).Output.Root);
                entry.PublicationStatus = publicationStatus;
                entry.Tags              = string.Empty;
                entry.Teaser            = string.Empty;
                entry.Author            = Author.Id;
                PageFolderFacade.AssignFolderDataSpecificValues(entry, page);
                entry = DataFacade.AddNew(entry);

                if (publicationStatus == GenericPublishProcessController.Published)
                {
                    entry.PublicationStatus = publicationStatus;
                    DataFacade.Update(entry);
                }
                return(entry.Id);
            }
            return(Guid.Empty);
        }
示例#3
0
        private void UnunsedTypesExist(object sender, ConditionalEventArgs e)
        {
            Type associatedType = TypeManager.GetType(this.Payload);

            IEnumerable <Type> associationTypes     = PageFolderFacade.GetAllFolderTypes();
            IEnumerable <Type> usedAssociationTypes = PageFolderFacade.GetDefinedFolderTypes(this.GetDataItemFromEntityToken <IPage>());

            e.Result = associationTypes.Except(usedAssociationTypes).Any();
        }
示例#4
0
        private void enterDataCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            var dataTypeDescriptor = GetBinding <DataTypeDescriptor>("DataTypeDescriptor");

            var type = TypeManager.GetType(dataTypeDescriptor.TypeManagerTypeName);

            Guid pageId = GetBinding <Guid>(BindingNames.PageId);

            var helper = new DataTypeDescriptorFormsHelper(dataTypeDescriptor, true, EntityToken)
            {
                LayoutIconHandle = "associated-data-add"
            };

            var generatedTypesHelper = new GeneratedTypesHelper(dataTypeDescriptor);

            helper.AddReadOnlyFields(generatedTypesHelper.NotEditableDataFieldDescriptorNames);

            IData newData;

            if (!BindingExist("NewData"))
            {
                newData = DataFacade.BuildNew(type);

                PageFolderFacade.AssignFolderDataSpecificValues(newData, pageId);

                var publishControlled = newData as IPublishControlled;
                if (publishControlled != null)
                {
                    publishControlled.PublicationStatus = GenericPublishProcessController.Draft;
                }

                var localizedData = newData as ILocalizedControlled;
                if (localizedData != null)
                {
                    var cultureInfo = UserSettings.ActiveLocaleCultureInfo ?? DataLocalizationFacade.DefaultLocalizationCulture;
                    localizedData.SourceCultureName = cultureInfo.Name;
                }

                Bindings.Add("NewData", newData);

                helper.UpdateWithNewBindings(Bindings);
                helper.ObjectToBindings(newData, Bindings);
            }
            else
            {
                newData = GetBinding <IData>("NewData");
            }

            DeliverFormData(
                type.Name,
                StandardUiContainerTypes.Document,
                helper.GetForm(),
                Bindings,
                helper.GetBindingsValidationRules(newData)
                );
        }
示例#5
0
        public List <Element> GetChildren(T data, EntityToken parentEntityToken)
        {
            var children = new List <Element>();

            PropertyInfo idPropertyInfo = typeof(T).GetKeyProperties()[0];

            foreach (Type type in PageFolderFacade.GetDefinedFolderTypes((IPage)data).OrderBy(t => t.Name))
            {
                var entityToken = new AssociatedDataElementProviderHelperEntityToken(
                    TypeManager.SerializeType(typeof(T)),
                    _elementProviderContext.ProviderName,
                    ValueTypeConverter.Convert <string>(idPropertyInfo.GetValue(data, null)),
                    TypeManager.SerializeType(type)
                    );

                DataTypeDescriptor dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(type);

                var element = new Element(_elementProviderContext.CreateElementHandle(entityToken))
                {
                    VisualData = new ElementVisualizedData
                    {
                        Label       = dataTypeDescriptor.Title ?? type.Name,
                        ToolTip     = dataTypeDescriptor.Title ?? type.Name,
                        Icon        = this.InterfaceClosedIcon,
                        OpenedIcon  = this.InterfaceOpenIcon,
                        HasChildren = true // This is sat to always true to boost performance.
                    }
                };


                element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Elements.ElementProviderHelpers.AssociatedDataElementProviderHelper.DeleteDataFolderWorkflow"), RemoveAssociatedTypePermissionTypes)))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label          = StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.RemoveAssociatedTypeLabel"),
                        ToolTip        = StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.RemoveAssociatedTypeToolTip"),
                        Icon           = this.RemoveDataAssociationTypeIcon,
                        Disabled       = false,
                        ActionLocation = new ActionLocation
                        {
                            ActionType  = ActionType.Delete,
                            IsInFolder  = false,
                            IsInToolbar = false,
                            ActionGroup = AppendedActionGroup
                        }
                    }
                });

                AddAddAssociatedDataAction(element, true);

                children.Add(element);
            }

            return(children);
        }
示例#6
0
        public void Pack(PackageCreator creator)
        {
            if (Id == _pagesName)
            {
                #region All Pages
                HashSet <Guid> pages;
                using (var scope = new DataScope(DataScopeIdentifier.Administrated))
                {
                    pages = DataFacade.GetData <IPage>().Select(p => p.Id).ToHashSet();
                }

                creator.AddData(typeof(IPage), DataScopeIdentifier.Public, d => pages.Contains((d as IPage).Id));
                creator.AddData(typeof(IPage), DataScopeIdentifier.Administrated, d => pages.Contains((d as IPage).Id));
                creator.AddData(typeof(IPagePlaceholderContent), DataScopeIdentifier.Public, d => pages.Contains((d as IPagePlaceholderContent).PageId));
                creator.AddData(typeof(IPagePlaceholderContent), DataScopeIdentifier.Administrated, d => pages.Contains((d as IPagePlaceholderContent).PageId));
                creator.AddData(typeof(IPageStructure), DataScopeIdentifier.Public, d => pages.Contains((d as IPageStructure).Id));
                #endregion
            }
            else if (Id == _mediasName)
            {
                creator.AddData(typeof(IMediaFileData));
                creator.AddData(typeof(IMediaFolderData));
                creator.AddFilesInDirectory(@"App_Data\Media\");
            }
            else if (Id == _datatypesName)
            {
                IEnumerable <Type> pageDataTypeInterfaces = PageFolderFacade.GetAllFolderTypes();
                IEnumerable <Type> pageMetaTypeInterfaces = PageMetaDataFacade.GetAllMetaDataTypes();

                foreach (var pageDataType in pageDataTypeInterfaces)
                {
                    creator.AddDataTypeData(pageDataType);
                }
                foreach (var pageMetaType in pageMetaTypeInterfaces)
                {
                    creator.AddDataTypeData(pageMetaType);
                }
            }
            else if (Id == _applicationsName)
            {
                creator.AddData <IDataItemTreeAttachmentPoint>();
            }
            else if (Id == _metatypesName)
            {
                IEnumerable <Type> pageMetaTypeInterfaces = PageMetaDataFacade.GetAllMetaDataTypes();

                foreach (var pageMetaType in pageMetaTypeInterfaces)
                {
                    creator.AddDataTypeData(pageMetaType);
                }
            }
            return;
        }
示例#7
0
        internal static void DeleteType(string providerName, DataTypeDescriptor dataTypeDescriptor, bool makeAFlush)
        {
            using (GlobalInitializerFacade.CoreLockScope)
            {
                PageFolderFacade.RemoveAllFolderDefinitions(dataTypeDescriptor.DataTypeId, false);
                PageMetaDataFacade.RemoveAllDefinitions(dataTypeDescriptor.DataTypeId, false);

                _generatedTypesFacade.DeleteType(providerName, dataTypeDescriptor, makeAFlush);

                if (_deleteTypeDelegate != null)
                {
                    DeleteTypeDelegate deleteDelegate = _deleteTypeDelegate;
                    deleteDelegate(new DeleteTypeEventArgs());
                }
            }
        }
示例#8
0
        private void selectTypeCodeActivity_Initialize_ExecuteCode(object sender, EventArgs e)
        {
            Type associatedType = TypeManager.GetType(this.Payload);

            IEnumerable <Type> associationTypes     = PageFolderFacade.GetAllFolderTypes();
            IEnumerable <Type> usedAccociationTypes = PageFolderFacade.GetDefinedFolderTypes(this.GetDataItemFromEntityToken <IPage>());

            var types = new Dictionary <Type, string>();

            foreach (var kvp in associationTypes.Except(usedAccociationTypes).ToDictionary(f => f, f => f.GetTypeTitle()))
            {
                types.Add(kvp.Key, kvp.Value);
            }

            this.Bindings.Add(this.TypesBindingName, types);
            this.Bindings.Add(this.SelectedTypeBindingName, types.Keys.First());
        }
        private bool IsDataFieldBindable(DataTypeDescriptor dataTypeDescriptor, DataFieldDescriptor dataFieldDescriptor)
        {
            if (dataFieldDescriptor.Inherited)
            {
                Type superInterface = dataTypeDescriptor.SuperInterfaces.FirstOrDefault(type => type.GetProperty(dataFieldDescriptor.Name) != null);

                if (superInterface != null && superInterface.Assembly == typeof(IData).Assembly)
                {
                    return(false);
                }
            }

            if ((dataFieldDescriptor.Name == IdFieldName || dataFieldDescriptor.Name == CompositionDescriptionFieldName) &&
                dataTypeDescriptor.IsPageMetaDataType)
            {
                return(false);
            }

            if (PageFolderFacade.GetAllFolderTypes().Contains(this._oldType) && dataFieldDescriptor.Name == PageReferenceFieldName)
            {
                return(false);
            }

            if (dataFieldDescriptor.ForeignKeyReferenceTypeName != null)
            {
                DataTypeAssociationDescriptor dataTypeAssociationDescriptor = dataTypeDescriptor.DataAssociations.FirstOrDefault();

                if (dataTypeAssociationDescriptor != null)
                {
                    if (!this.AllowForeignKeyEditing &&
                        dataFieldDescriptor.Name == dataTypeAssociationDescriptor.ForeignKeyPropertyName)
                    {
                        return(false);
                    }

                    if (dataFieldDescriptor.Name == CompositionDescriptionFieldName && dataTypeDescriptor.IsPageMetaDataType)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
示例#10
0
        private void noTypesToAddCodeActivity_ShowMessage_ExecuteCode(object sender, EventArgs e)
        {
            Type associatedType   = TypeManager.GetType(this.Payload);
            var  associationTypes = PageFolderFacade.GetAllFolderTypes();

            if (!associationTypes.Any())
            {
                this.ShowMessage(
                    DialogType.Message,
                    "${Composite.Management, AssociatedDataElementProviderHelper.AddDataFolderExWorkflow.NoTypesTitle}",
                    "${Composite.Management, AssociatedDataElementProviderHelper.AddDataFolderExWorkflow.NoTypesMessage}"
                    );
            }
            else
            {
                this.ShowMessage(
                    DialogType.Message,
                    "${Composite.Management, AssociatedDataElementProviderHelper.AddDataFolderExWorkflow.NoUnusedTypesTitle}",
                    "${Composite.Management, AssociatedDataElementProviderHelper.AddDataFolderExWorkflow.NoUnusedTypesMessage}"
                    );
            }
        }
示例#11
0
        public Dictionary <EntityToken, IEnumerable <EntityToken> > GetParents(IEnumerable <EntityToken> entityTokens)
        {
            var result = new Dictionary <EntityToken, IEnumerable <EntityToken> >();

            foreach (EntityToken entityToken in entityTokens)
            {
                var dataEntityToken = entityToken as DataEntityToken;
                if (dataEntityToken.Data == null)
                {
                    continue;
                }

                Type interfaceType = dataEntityToken.InterfaceType;

                if (!PageFolderFacade.GetAllFolderTypes().Contains(interfaceType))
                {
                    continue;
                }

                IData data           = dataEntityToken.Data;
                IPage referencedPage = PageFolderFacade.GetReferencedPage(data);
                if (referencedPage == null)
                {
                    continue;                         // TODO: check this branch
                }
                result.Add(entityToken,
                           new []
                {
                    new AssociatedDataElementProviderHelperEntityToken(
                        TypeManager.SerializeType(typeof(T)),
                        _elementProviderContext.ProviderName,
                        ValueTypeConverter.Convert <string>(referencedPage.Id),
                        TypeManager.SerializeType(interfaceType))
                });
            }

            return(result);
        }
示例#12
0
        internal void AddDataTypeData(Type type)
        {
            IEnumerable <Type> globalDataTypeInterfaces = DataFacade
                                                          .GetAllInterfaces(UserType.Developer)
                                                          .Where(interfaceType => interfaceType.Assembly != typeof(IData).Assembly)
                                                          .OrderBy(t => t.FullName)
                                                          .Except(PageFolderFacade.GetAllFolderTypes())
                                                          .Except(PageMetaDataFacade.GetAllMetaDataTypes());

            IEnumerable <Type> pageDataTypeInterfaces = PageFolderFacade.GetAllFolderTypes();
            IEnumerable <Type> pageMetaTypeInterfaces = PageMetaDataFacade.GetAllMetaDataTypes();

            DataTypeDescriptor dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(type);

            var resolvedType = dataTypeDescriptor.GetInterfaceType();

            // TODO: make by association
            if (globalDataTypeInterfaces.Contains(resolvedType))
            {
                AddData(type);
            }
            else if (pageDataTypeInterfaces.Contains(resolvedType))
            {
                AddData <IPageFolderDefinition>(d => d.FolderTypeId == dataTypeDescriptor.DataTypeId);
                AddData(type);
            }
            else if (pageMetaTypeInterfaces.Contains(resolvedType))
            {
                foreach (var j in DataFacade.GetData <IPageMetaDataDefinition>(d => d.MetaDataTypeId == dataTypeDescriptor.DataTypeId))
                {
                    //Add only one MetaTypeTab
                    AddData <ICompositionContainer>(d => d.Id == j.MetaDataContainerId);
                }
                AddData <IPageMetaDataDefinition>(d => d.MetaDataTypeId == dataTypeDescriptor.DataTypeId);
                AddData(type);
            }
        }
示例#13
0
        private void initializeCodeActivity_UpdateBindings_ExecuteCode(object sender, EventArgs e)
        {
            IPageType pageType = (IPageType)((DataEntityToken)this.EntityToken).Data;

            CleanDeadLinks(pageType.Id);

            this.Bindings.Add("PageType", pageType);

            List <KeyValuePair <Guid, string> > pageTypes =
                DataFacade.GetData <IPageType>().
                OrderBy(f => f.Name).
                ToList(f => new KeyValuePair <Guid, string>(f.Id, f.Name));

            var defaultPageTypeOptions = new List <KeyValuePair <Guid, string> >
            {
                new KeyValuePair <Guid, string>(Guid.Empty,
                                                Texts.PageType_EditPageTypeWorkflow_DefaultChildPageTypeKeySelector_NoneSelectedLabel)
            };

            defaultPageTypeOptions.AddRange(pageTypes);

            this.Bindings.Add("DefaultChildPageTypeOptions", defaultPageTypeOptions);


            Func <PageTypeHomepageRelation, KeyValuePair <string, string> > getOption =
                relation =>
                new KeyValuePair <string, string>(
                    relation.ToString(),
                    GetText($"PageType.EditPageTypeWorkflow.HomepageRelationKeySelector.{relation}Label"));

            this.Bindings.Add("HomepageRelationOptions", new List <KeyValuePair <string, string> > {
                getOption(PageTypeHomepageRelation.NoRestriction),
                getOption(PageTypeHomepageRelation.OnlyHomePages),
                getOption(PageTypeHomepageRelation.OnlySubPages),
            });


            List <KeyValuePair <Guid, string> > pageTemplates =
                PageTemplateFacade.GetPageTemplates().
                OrderBy(f => f.Title).
                ToList(f => new KeyValuePair <Guid, string>(f.Id, f.Title));

            var defaultPageTemplateOptions = new List <KeyValuePair <Guid, string> >
            {
                new KeyValuePair <Guid, string>(Guid.Empty,
                                                Texts.PageType_EditPageTypeWorkflow_DefaultPageTemplateKeySelector_NoneSelectedLabel)
            };

            defaultPageTemplateOptions.AddRange(pageTemplates);

            this.Bindings.Add("DefaultTemplateOptions", defaultPageTemplateOptions);


            this.Bindings.Add("TemplateRestrictionOptions", pageTemplates);


            List <Guid> selectedPageTemplateIds =
                DataFacade.GetData <IPageTypePageTemplateRestriction>().
                Where(f => f.PageTypeId == pageType.Id).
                Select(f => f.PageTemplateId).
                ToList();

            this.Bindings.Add("TemplateRestrictionSelected", selectedPageTemplateIds);


            List <KeyValuePair <Guid, string> > parentRestrictingPageTypes =
                DataFacade.GetData <IPageType>().
                OrderBy(f => f.Name).
                ToList(f => new KeyValuePair <Guid, string>(f.Id, f.Name));

            this.Bindings.Add("PageTypeChildRestrictionOptions", parentRestrictingPageTypes);


            List <Guid> selectedPageTypeParentRestrictions =
                DataFacade.GetData <IPageTypeParentRestriction>().
                Where(f => f.PageTypeId == pageType.Id).
                Select(f => f.AllowedParentPageTypeId).
                ToList();

            this.Bindings.Add("PageTypeChildRestrictionSelected", selectedPageTypeParentRestrictions);


            List <KeyValuePair <Guid, string> > dataFolderTypes =
                PageFolderFacade.GetAllFolderTypes().
                OrderBy(f => f.FullName).
                ToList(f => new KeyValuePair <Guid, string>(f.GetImmutableTypeId(), f.GetTypeTitle()));

            this.Bindings.Add("DataFolderOptions", dataFolderTypes);


            List <Guid> selectedDataFolderTypes =
                DataFacade.GetData <IPageTypeDataFolderTypeLink>().
                Where(f => f.PageTypeId == pageType.Id).
                Select(f => f.DataTypeId).
                ToList();

            this.Bindings.Add("DataFolderSelected", selectedDataFolderTypes);


            List <KeyValuePair <string, string> > applications =
                TreeFacade.AllTrees.
                Where(f => !string.IsNullOrEmpty(f.AllowedAttachmentApplicationName)).
                OrderBy(f => f.TreeId).
                ToList(f => new KeyValuePair <string, string>(f.TreeId, f.AllowedAttachmentApplicationName));

            this.Bindings.Add("ApplicationOptions", applications);


            List <string> selectedApplications =
                DataFacade.GetData <IPageTypeTreeLink>().
                Where(f => f.PageTypeId == pageType.Id).
                Select(f => f.TreeId).
                ToList();

            this.Bindings.Add("ApplicationSelected", selectedApplications);
        }
示例#14
0
        public static void InsertForm(Control control, ParameterList parameters)
        {
            Page currentPageHandler = HttpContext.Current.Handler as Page;


            if (currentPageHandler == null)
            {
                throw new InvalidOperationException("The Current HttpContext Handler must be a System.Web.Ui.Page");
            }

            Type dataType = null;
            DataTypeDescriptor dataTypeDescriptor = null;

            string dataTypeName = parameters.GetParameter <string>("DataType");

            dataType           = TypeManager.GetType(dataTypeName);
            dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(dataType);

            IFormChannelIdentifier channelIdentifier = FormsRendererChannel.Identifier;

            formHelper = new DataTypeDescriptorFormsHelper(dataTypeDescriptor);

            newData = DataFacade.BuildNew(dataType);
            GeneratedTypesHelper.SetNewIdFieldValue(newData);

            //Hide not editable fields, fox example - PageId
            GeneratedTypesHelper generatedTypesHelper = new GeneratedTypesHelper(dataTypeDescriptor);

            formHelper.AddReadOnlyFields(generatedTypesHelper.NotEditableDataFieldDescriptorNames);


            //If is Page Datatype
            if (PageFolderFacade.GetAllFolderTypes().Contains(dataType))
            {
                IPage currentPage = PageRenderer.CurrentPage;

                if (currentPage.GetDefinedFolderTypes().Contains(dataType) == false)
                {
                    currentPage.AddFolderDefinition(dataType.GetImmutableTypeId());
                }
                PageFolderFacade.AssignFolderDataSpecificValues(newData, currentPage);
            }

            _compiler = new FormTreeCompiler();

            //bindings = formHelper.GetBindings(newData);
            bindings = new Dictionary <string, object>();
            formHelper.UpdateWithNewBindings(bindings);
            formHelper.ObjectToBindings(newData, bindings);


            using (XmlReader reader = XDocument.Parse(formHelper.GetForm()).CreateReader())
            {
                try
                {
                    _compiler.Compile(reader, channelIdentifier, bindings, formHelper.GetBindingsValidationRules(newData));

                    #region ClientValidationRules
                    clientValidationRules = new Dictionary <string, List <ClientValidationRule> >();
                    foreach (var item in _compiler.GetField <object>("_context").GetProperty <IEnumerable>("Rebindings"))
                    {
                        var SourceProducer = item.GetProperty <object>("SourceProducer");
                        var uiControl      = SourceProducer as IWebUiControl;
                        if (uiControl != null)
                        {
                            clientValidationRules[uiControl.UiControlID] = uiControl.ClientValidationRules;
                        }
                    }
                    #endregion
                }
                catch (ConfigurationErrorsException e)
                {
                    if (e.Message.Contains("Failed to load the configuration for IUiControlFactory"))
                    {
                        throw new ConfigurationErrorsException("Composite.Forms.Renderer does not support widget. " + e.Message);
                    }
                    else
                    {
                        throw new ConfigurationErrorsException(e.Message);
                    }
                }
            }
            webUiControl = (IWebUiControl)_compiler.UiControl;

            Control form = webUiControl.BuildWebControl();
            control.Controls.Add(form);

            /*if (currentPageHandler.IsPostBack)
             *  try
             *  {
             *      compiler.SaveControlProperties();
             *  }
             *  catch { }*/

            if (!currentPageHandler.IsPostBack)
            {
                webUiControl.InitializeViewState();
            }



            return;
        }
    private void AttachPageElements(XElement infoDocumentRoot)
    {
        XName pageName = "Page";

        List <IPage> actionRequiredPages =
            (from page in DataFacade.GetData <IPage>()
             where page.PublicationStatus != "published"
             select page).ToList();

        //            Dictionary<Type, List<IPublishControlled>> unpublishedData = GetDataRequiringAction();
        List <Type> pageFolderTypes = new List <Type>();
        Dictionary <Guid, List <IPublishControlled> > pageFolderDataItems = new Dictionary <Guid, List <IPublishControlled> >();

        // Add pages that lead to page folder

        Dictionary <Type, List <IPublishControlled> > unpublishedPageFolderData = GetDataRequiringAction(PageFolderFacade.GetAllFolderTypes());

        foreach (var unpublishedDataGroup in unpublishedPageFolderData)
        {
            Type dataType = unpublishedDataGroup.Key;
            if (PageFolderFacade.GetAllFolderTypes().Contains(dataType) == true)
            {
                if (dataType.GetDataPropertyRecursivly("IPageIdForeignKey") != null)
                {
                    pageFolderTypes.Add(dataType);

                    foreach (IPublishControlled data in unpublishedDataGroup.Value)
                    {
                        IPage page = (IPage)data.GetReferenced("IPageIdForeignKey");
                        if (actionRequiredPages.Any(f => f.Id == page.Id) == false)
                        {
                            actionRequiredPages.Add(page);
                        }

                        if (pageFolderDataItems.ContainsKey(page.Id) == false)
                        {
                            pageFolderDataItems.Add(page.Id, new List <IPublishControlled>());
                        }

                        pageFolderDataItems[page.Id].Add(data);
                    }
                }
            }
        }


        UserToken userToken = UserValidationFacade.GetUserToken();
        List <UserPermissionDefinition>      userPermissionDefinitions      = PermissionTypeFacade.GetUserPermissionDefinitions(userToken.Username).ToList();
        List <UserGroupPermissionDefinition> userGroupPermissionDefinitions = PermissionTypeFacade.GetUserGroupPermissionDefinitions(userToken.Username).ToList();

        foreach (IPage page in actionRequiredPages.ToList())
        {
            DataEntityToken entityToken = page.GetDataEntityToken();
            var             permissions = PermissionTypeFacade.GetCurrentPermissionTypes(userToken, entityToken, userPermissionDefinitions, userGroupPermissionDefinitions).ToList();

            if (permissions.Contains(PermissionType.Read) == false)
            {
                actionRequiredPages.Remove(page);
            }
        }


        var allSitemapElements = PageStructureInfo.GetSiteMap().DescendantsAndSelf();
        var relevantElements   = allSitemapElements.Where(f => actionRequiredPages.Any(g => g.Id.ToString() == f.Attribute("Id").Value));
        var minimalTree        = relevantElements.AncestorsAndSelf().Distinct().ToList();

        var documentOrdered = minimalTree.InDocumentOrder().Where(f => f.Name.LocalName == "Page").ToList();


        int preDepth = 0;

        XName actionPageName = "Page";

        Stack <XElement> workingContainerStack = new Stack <XElement>();

        workingContainerStack.Push(infoDocumentRoot);
        XElement lastActionPageElement = null;

        foreach (XElement pageElement in documentOrdered)
        {
            int depth = pageElement.Ancestors().Count(f => f.Name.LocalName == "Page");

            if (preDepth == depth - 1)
            {
                workingContainerStack.Push(lastActionPageElement);
                preDepth++;
            }
            else if (preDepth > depth)
            {
                while (preDepth != depth)
                {
                    workingContainerStack.Pop();
                    preDepth--;
                }
            }
            else if (depth != preDepth)
            {
                throw new InvalidOperationException("Unexpected depth jump in document ordered minimal tree.");
            }

            Guid pageId = new Guid(pageElement.Attribute("Id").Value);

            var    statusInfo   = actionRequiredPages.FirstOrDefault(f => f.Id == pageId);
            string statusString = (statusInfo == null ? "published" : statusInfo.PublicationStatus);

            XElement actionPage = new XElement(actionPageName,
                                               new XAttribute("Id", pageId),
                                               new XAttribute("Title", pageElement.Attribute("Title").Value),
                                               new XAttribute("Status", statusString)
                                               );


            if (statusInfo != null)
            {
                actionPage.Add(
                    new XAttribute("changedate", statusInfo.ChangeDate.ToShortDateString() + " " + statusInfo.ChangeDate.ToShortTimeString()),
                    new XAttribute("changedby", statusInfo.ChangedBy ?? "?"));
            }

            // Inject page folder data
            if (pageFolderDataItems.ContainsKey(pageId) == true)
            {
                foreach (Type t in pageFolderDataItems[pageId].Select(f => f.GetType()).Distinct().OrderBy(f => f.GetTypeTitle()))
                {
                    XElement pageFolderElement = new XElement("PageFolder",
                                                              new XAttribute("Title", t.GetTypeTitle()));

                    foreach (IPublishControlled dataItem in pageFolderDataItems[pageId].Where(f => f.GetType() == t))
                    {
                        pageFolderElement.Add(new XElement("DataItem",
                                                           new XAttribute("Title", dataItem.GetLabel()),
                                                           new XAttribute("Status", dataItem.PublicationStatus)));
                    }

                    actionPage.Add(pageFolderElement);
                }
            }

            workingContainerStack.Peek().Add(actionPage);
            lastActionPageElement = actionPage;
        }

        while (workingContainerStack.Count > 1)
        {
            workingContainerStack.Pop();
        }

//        XElement inputRoot = workingContainerStack.Peek();
    }
    private IEnumerable <Type> GetGlobalDataTypes()
    {
        Func <Type, bool> typePredicate = f => (f != typeof(IPage)) && (PageFolderFacade.GetAllFolderTypes().Contains(f) == false) && (PageMetaDataFacade.GetAllMetaDataTypes().Contains(f) == false);

        return(DataFacade.GetGeneratedInterfaces().Where(typePredicate).OrderBy(t => t.FullName));
    }
示例#17
0
 public bool HasChildren(T data)
 {
     return(PageFolderFacade.HasFolderDefinitions((IPage)data));
 }
        private void initializeCodeActivity_Copy_ExecuteCode(object sender, EventArgs e)
        {
            var castedEntityToken = (DataEntityToken)this.EntityToken;

            IPage newPage;

            using (var transactionScope = TransactionsFacade.CreateNewScope())
            {
                CultureInfo sourceCultureInfo = UserSettings.ForeignLocaleCultureInfo;

                IPage sourcePage;
                List <IPagePlaceholderContent> sourcePagePlaceholders;
                List <IData> sourceMetaDataSet;

                using (new DataScope(sourceCultureInfo))
                {
                    var  pageFromEntityToken = (IPage)castedEntityToken.Data;
                    Guid sourcePageId        = pageFromEntityToken.Id;
                    Guid sourcePageVersionId = pageFromEntityToken.VersionId;

                    using (new DataScope(DataScopeIdentifier.Administrated))
                    {
                        sourcePage = DataFacade.GetData <IPage>(f => f.Id == sourcePageId).Single();
                        sourcePage = sourcePage.GetTranslationSource();

                        using (new DataScope(sourcePage.DataSourceId.DataScopeIdentifier))
                        {
                            sourcePagePlaceholders = DataFacade
                                                     .GetData <IPagePlaceholderContent>(f => f.PageId == sourcePageId && f.VersionId == sourcePageVersionId)
                                                     .ToList();
                            sourceMetaDataSet = sourcePage.GetMetaData().ToList();
                        }
                    }
                }


                CultureInfo targetCultureInfo = UserSettings.ActiveLocaleCultureInfo;

                using (new DataScope(targetCultureInfo))
                {
                    newPage = DataFacade.BuildNew <IPage>();
                    sourcePage.ProjectedCopyTo(newPage);

                    newPage.SourceCultureName = targetCultureInfo.Name;
                    newPage.PublicationStatus = GenericPublishProcessController.Draft;
                    newPage = DataFacade.AddNew <IPage>(newPage);

                    foreach (IPagePlaceholderContent sourcePagePlaceholderContent in sourcePagePlaceholders)
                    {
                        IPagePlaceholderContent newPagePlaceholderContent = DataFacade.BuildNew <IPagePlaceholderContent>();
                        sourcePagePlaceholderContent.ProjectedCopyTo(newPagePlaceholderContent);

                        newPagePlaceholderContent.SourceCultureName = targetCultureInfo.Name;
                        newPagePlaceholderContent.PublicationStatus = GenericPublishProcessController.Draft;
                        DataFacade.AddNew <IPagePlaceholderContent>(newPagePlaceholderContent);
                    }

                    foreach (IData metaData in sourceMetaDataSet)
                    {
                        ILocalizedControlled localizedData = metaData as ILocalizedControlled;

                        if (localizedData == null)
                        {
                            continue;
                        }

                        IEnumerable <ReferenceFailingPropertyInfo> referenceFailingPropertyInfos = DataLocalizationFacade.GetReferencingLocalizeFailingProperties(localizedData).Evaluate();

                        if (!referenceFailingPropertyInfos.Any())
                        {
                            IData newMetaData = DataFacade.BuildNew(metaData.DataSourceId.InterfaceType);
                            metaData.ProjectedCopyTo(newMetaData);

                            ILocalizedControlled localizedControlled = newMetaData as ILocalizedControlled;
                            localizedControlled.SourceCultureName = targetCultureInfo.Name;

                            IPublishControlled publishControlled = newMetaData as IPublishControlled;
                            publishControlled.PublicationStatus = GenericPublishProcessController.Draft;

                            DataFacade.AddNew(newMetaData);
                        }
                        else
                        {
                            foreach (ReferenceFailingPropertyInfo referenceFailingPropertyInfo in referenceFailingPropertyInfos)
                            {
                                Log.LogVerbose("LocalizePageWorkflow",
                                               "Meta data of type '{0}' is not localized because the field '{1}' is referring some not yet localzed data"
                                               .FormatWith(metaData.DataSourceId.InterfaceType, referenceFailingPropertyInfo.DataFieldDescriptor.Name));
                            }
                        }
                    }
                }

                EntityTokenCacheFacade.ClearCache(sourcePage.GetDataEntityToken());
                EntityTokenCacheFacade.ClearCache(newPage.GetDataEntityToken());

                foreach (var folderType in PageFolderFacade.GetDefinedFolderTypes(newPage))
                {
                    EntityTokenCacheFacade.ClearCache(new AssociatedDataElementProviderHelperEntityToken(
                                                          TypeManager.SerializeType(typeof(IPage)),
                                                          PageElementProvider.DefaultConfigurationName,
                                                          newPage.Id.ToString(),
                                                          TypeManager.SerializeType(folderType)));
                }


                transactionScope.Complete();
            }

            ParentTreeRefresher parentTreeRefresher = this.CreateParentTreeRefresher();

            parentTreeRefresher.PostRefreshMesseges(newPage.GetDataEntityToken(), 2);

            this.ExecuteWorklow(newPage.GetDataEntityToken(), typeof(EditPageWorkflow));
        }
示例#19
0
        private void initializeCodeActivity_UpdateBindings_ExecuteCode(object sender, EventArgs e)
        {
            IPageType pageType = (IPageType)((DataEntityToken)this.EntityToken).Data;

            CleanDeadLinks(pageType.Id);

            this.Bindings.Add("PageType", pageType);

            List <KeyValuePair <Guid, string> > pageTypes =
                DataFacade.GetData <IPageType>().
                OrderBy(f => f.Name).
                ToList(f => new KeyValuePair <Guid, string>(f.Id, f.Name));

            List <KeyValuePair <Guid, string> > defaultPageTypeOptions = new List <KeyValuePair <Guid, string> >();

            defaultPageTypeOptions.Add(new KeyValuePair <Guid, string>(Guid.Empty, StringResourceSystemFacade.GetString("Composite.Plugins.PageTypeElementProvider", "PageType.EditPageTypeWorkflow.DefaultChildPageTypeKeySelector.NoneSelectedLabel")));
            defaultPageTypeOptions.AddRange(pageTypes);

            this.Bindings.Add("DefaultChildPageTypeOptions", defaultPageTypeOptions);



            this.Bindings.Add("HomepageRelationOptions", new List <KeyValuePair <string, string> > {
                new KeyValuePair <string, string>(PageTypeHomepageRelation.NoRestriction.ToPageTypeHomepageRelationString(), StringResourceSystemFacade.GetString("Composite.Plugins.PageTypeElementProvider", string.Format("PageType.EditPageTypeWorkflow.HomepageRelationKeySelector.{0}Label", PageTypeHomepageRelation.NoRestriction))),
                new KeyValuePair <string, string>(PageTypeHomepageRelation.OnlyHomePages.ToPageTypeHomepageRelationString(), StringResourceSystemFacade.GetString("Composite.Plugins.PageTypeElementProvider", string.Format("PageType.EditPageTypeWorkflow.HomepageRelationKeySelector.{0}Label", PageTypeHomepageRelation.OnlyHomePages))),
                new KeyValuePair <string, string>(PageTypeHomepageRelation.OnlySubPages.ToPageTypeHomepageRelationString(), StringResourceSystemFacade.GetString("Composite.Plugins.PageTypeElementProvider", string.Format("PageType.EditPageTypeWorkflow.HomepageRelationKeySelector.{0}Label", PageTypeHomepageRelation.OnlySubPages))),
            });


            List <KeyValuePair <Guid, string> > pageTemplates =
                PageTemplateFacade.GetPageTemplates().
                OrderBy(f => f.Title).
                ToList(f => new KeyValuePair <Guid, string>(f.Id, f.Title));

            List <KeyValuePair <Guid, string> > defaultPageTempatesOptions = new List <KeyValuePair <Guid, string> >();

            defaultPageTempatesOptions.Add(new KeyValuePair <Guid, string>(Guid.Empty, StringResourceSystemFacade.GetString("Composite.Plugins.PageTypeElementProvider", "PageType.EditPageTypeWorkflow.DefaultPageTemplateKeySelector.NoneSelectedLabel")));
            defaultPageTempatesOptions.AddRange(pageTemplates);

            this.Bindings.Add("DefaultTemplateOptions", defaultPageTempatesOptions);


            this.Bindings.Add("TemplateRestrictionOptions", pageTemplates);


            List <Guid> selectedPageTemplateIds =
                DataFacade.GetData <IPageTypePageTemplateRestriction>().
                Where(f => f.PageTypeId == pageType.Id).
                Select(f => f.PageTemplateId).
                ToList();

            this.Bindings.Add("TemplateRestrictionSelected", selectedPageTemplateIds);


            List <KeyValuePair <Guid, string> > parentRestrictingPageTypes =
                DataFacade.GetData <IPageType>().
                OrderBy(f => f.Name).
                ToList(f => new KeyValuePair <Guid, string>(f.Id, f.Name));

            this.Bindings.Add("PageTypeChildRestrictionOptions", parentRestrictingPageTypes);


            List <Guid> selectedPageTypeParentRestrictions =
                DataFacade.GetData <IPageTypeParentRestriction>().
                Where(f => f.PageTypeId == pageType.Id).
                Select(f => f.AllowedParentPageTypeId).
                ToList();

            this.Bindings.Add("PageTypeChildRestrictionSelected", selectedPageTypeParentRestrictions);


            List <KeyValuePair <Guid, string> > dataFolderTypes =
                PageFolderFacade.GetAllFolderTypes().
                OrderBy(f => f.FullName).
                ToList(f => new KeyValuePair <Guid, string>(f.GetImmutableTypeId(), f.GetTypeTitle()));

            this.Bindings.Add("DataFolderOptions", dataFolderTypes);


            List <Guid> selectedDataFolderTypes =
                DataFacade.GetData <IPageTypeDataFolderTypeLink>().
                Where(f => f.PageTypeId == pageType.Id).
                Select(f => f.DataTypeId).
                ToList();

            this.Bindings.Add("DataFolderSelected", selectedDataFolderTypes);


            List <KeyValuePair <string, string> > applications =
                TreeFacade.AllTrees.
                Where(f => string.IsNullOrEmpty(f.AllowedAttachmentApplicationName) == false).
                OrderBy(f => f.TreeId).
                ToList(f => new KeyValuePair <string, string>(f.TreeId, f.AllowedAttachmentApplicationName));

            this.Bindings.Add("ApplicationOptions", applications);


            List <string> selectedApplications =
                DataFacade.GetData <IPageTypeTreeLink>().
                Where(f => f.PageTypeId == pageType.Id).
                Select(f => f.TreeId).
                ToList();

            this.Bindings.Add("ApplicationSelected", selectedApplications);
        }
        private void initializeCodeActivity_BuildNewData_ExecuteCode(object sender, EventArgs e)
        {
            Initialize();

            this.FormsHelper.UpdateWithNewBindings(this.Bindings);

            IData newData = DataFacade.BuildNew(InterfaceType);

            if (PageFolderFacade.GetAllFolderTypes().Contains(InterfaceType))
            {
                Dictionary <string, string> piggybag = PiggybagSerializer.Deserialize(this.ExtraPayload);
                var   piggybagDataFinder             = new PiggybagDataFinder(piggybag, this.EntityToken);
                IPage page = (IPage)piggybagDataFinder.TryGetData(typeof(IPage));
                if (page != null)
                {
                    PageFolderFacade.AssignFolderDataSpecificValues(newData, page);
                }
            }

            var publishControlled = newData as IPublishControlled;

            if (publishControlled != null)
            {
                publishControlled.PublicationStatus = GenericPublishProcessController.Draft;
            }


            var values            = new Dictionary <string, string>();
            var castedEntityToken = this.EntityToken as TreeDataFieldGroupingElementEntityToken;

            if (castedEntityToken != null)
            {
                Tree tree     = TreeFacade.GetTree(castedEntityToken.Source);
                var  treeNode = (DataFolderElementsTreeNode)tree.GetTreeNode(castedEntityToken.TreeNodeId);

                if (treeNode.Range == null && !treeNode.FirstLetterOnly)
                {
                    foreach (var kvp in castedEntityToken.DeserializedGroupingValues)
                    {
                        values.Add(kvp.Key, ValueTypeConverter.Convert <string>(kvp.Value));
                    }
                }
            }

            var props = InterfaceType.GetPropertiesRecursively().ToDictionary(prop => prop.Name);

            foreach (var kvp in this.DataPayload)
            {
                // Filtering payload data which is not default field values
                if (props.ContainsKey(kvp.Key))
                {
                    values[kvp.Key] = StringConversionServices.DeserializeValueString(kvp.Value);
                }
            }

            newData.SetValues(values);



            this.FormsHelper.ObjectToBindings(newData, this.Bindings);

            GeneratedTypesHelper.SetNewIdFieldValue(newData);

            this.Bindings.Add("NewData", newData);
        }
示例#21
0
        public static IEnumerable <XElement> SaveComment(string name, string email, string commentTitle, string commentText, string Captcha)
        {
            var currentPageId = SitemapNavigator.CurrentPageId;

            yield return(new XElement("SubmittedData",
                                      new XAttribute("Fieldname", "Name"),
                                      new XAttribute("Value", name)));

            yield return(new XElement("SubmittedData",
                                      new XAttribute("Fieldname", "Email"),
                                      new XAttribute("Value", email)));

            yield return(new XElement("SubmittedData",
                                      new XAttribute("Fieldname", "CommentTitle"),
                                      new XAttribute("Value", commentTitle)));

            yield return(new XElement("SubmittedData",
                                      new XAttribute("Fieldname", "CommentText"),
                                      new XAttribute("Value", commentText)));

            yield return(new XElement("SubmittedData",
                                      new XAttribute("Fieldname", "Captcha"),
                                      new XAttribute("Value", Captcha)));

            // Input error ?
            if (Captcha != "true" || string.IsNullOrEmpty(name) || !Validate(RegExpLib.Email, email, true) || string.IsNullOrEmpty(commentTitle) || string.IsNullOrEmpty(commentText))
            {
                var errorText = new Hashtable();

                if (Captcha != "true")
                {
                    errorText.Add("Captcha", "Incorrect Captcha value");
                }
                if (string.IsNullOrEmpty(name))
                {
                    errorText.Add("Name", "Incorrect Name value");
                }
                if (!Validate(RegExpLib.Email, email, true))
                {
                    errorText.Add("Email", "Incorrect E-mail value");
                }
                if (string.IsNullOrEmpty(commentTitle))
                {
                    errorText.Add("Title", "Incorrect Title value");
                }
                if (string.IsNullOrEmpty(commentText))
                {
                    errorText.Add("Comment", "Incorrect Comment value");
                }

                foreach (string key in errorText.Keys)
                {
                    yield return(new XElement("Error",
                                              new XAttribute("Fieldname", key),
                                              new XAttribute("ErrorDescription", errorText[key].ToString())));
                }
            }
            else
            {
                using (DataConnection conn = new DataConnection())
                {
                    var currentPage = conn.Get <IPage>().Where(p => p.Id == currentPageId).SingleOrDefault();

                    if (!currentPage.GetDefinedFolderTypes().Contains(typeof(Item)))
                    {
                        currentPage.AddFolderDefinition(typeof(Item).GetImmutableTypeId());
                    }

                    //add data
                    var commentItem = conn.CreateNew <Item>();

                    commentItem.Name    = name;
                    commentItem.Email   = email;
                    commentItem.Title   = commentTitle;
                    commentItem.Date    = DateTime.Now;
                    commentItem.Comment = commentText;

                    PageFolderFacade.AssignFolderDataSpecificValues(commentItem, currentPage);
                    conn.Add <Item>(commentItem);

                    // Redirect to view newly added comment
                    string pageUrl;
                    var    found = PageStructureInfo.TryGetPageUrl(currentPageId, out pageUrl);

                    if (found)
                    {
                        PrepareMail(currentPageId, pageUrl, name, email, commentTitle, commentText, DateTime.Now.ToString());
                        HttpContext.Current.Response.Redirect(pageUrl, false);
                    }
                }
            }
        }