예제 #1
0
        private void CreateHooks(string parentId, IEnumerable <VirtualElementConfigurationElement> elements, List <EntityTokenHook> foundHooks)
        {
            var entityToken     = new VirtualElementProviderEntityToken(_context.ProviderName, parentId);
            var entityTokenHook = new EntityTokenHook(entityToken);

            foreach (var attachProviderElement in elements.OfType <AttachProviderVirtualElement>())
            {
                lock (_notLoadedVirtualElements)
                {
                    if (_notLoadedVirtualElements.Contains(attachProviderElement.Name))
                    {
                        continue;
                    }
                }


                string providerName  = attachProviderElement.ProviderName;
                var    childElements = ElementFacade.GetRootsWithNoSecurity(new ElementProviderHandle(providerName), null).ToList();

                foreach (Element childElement in childElements)
                {
                    entityTokenHook.AddHookie(childElement.ElementHandle.EntityToken);
                }
            }

            foundHooks.Add(entityTokenHook);

            foreach (var simpleElement in elements.OfType <SimpleVirtualElement>())
            {
                CreateHooks(simpleElement.Name, simpleElement.Elements, foundHooks);
            }
        }
예제 #2
0
        public IEnumerable <EntityToken> GetParents(EntityToken entityToken)
        {
            VirtualElementProviderEntityToken virtualEntityToken = (VirtualElementProviderEntityToken)entityToken;

            List <EntityToken> parentEntityTokens = new List <EntityToken>();

            VirtualElementProviderEntityToken parentToken = (VirtualElementProviderEntityToken)ElementFacade.GetData(new ElementProviderHandle(virtualEntityToken.Source), virtualEntityToken.Id);

            if (parentToken != null)
            {
                parentEntityTokens.Add(parentToken);
            }

            return(parentEntityTokens);
        }
        public override IEnumerable<System.Xml.Linq.XElement> Install()
        {
            // grant Perspective permissions to the current user
            string perspectiveName = "Composite.Tools.PackageCreator";
            EntityToken entityToken = new VirtualElementProviderEntityToken("VirtualElementProvider", perspectiveName);

            IUserActivePerspective activePerspective = DataFacade.BuildNew<IUserActivePerspective>();
            string Username = Composite.C1Console.Users.UserSettings.Username;
            activePerspective.Username = Username;
            activePerspective.SerializedEntityToken = EntityTokenSerializer.Serialize(entityToken);
            activePerspective.Id = Guid.NewGuid();

            DataFacade.AddNew<IUserActivePerspective>(activePerspective);
            LoggingService.LogInformation("Composite.Tools.PackageCreator", String.Format("Access to the {0} granted for the {1}.", perspectiveName, Username));

            yield break;
        }
예제 #4
0
        public IEnumerable <Element> GetRoots(SearchToken seachToken)
        {
            EntityToken entityToken = new VirtualElementProviderEntityToken(_context.ProviderName, RootElementId);

            var root = new Element(_context.CreateElementHandle(entityToken))
            {
                VisualData = new ElementVisualizedData
                {
                    Label      = "${Composite.Management, VirtualElementProviderElementProvider.ID01}",
                    Icon       = CommonElementIcons.Folder,
                    OpenedIcon = CommonElementIcons.FolderOpen,
                    ToolTip    = ""
                },
                TagValue = "Root"
            };

            root.ElementExternalActionAdding = root.ElementExternalActionAdding.Remove(ElementExternalActionAdding.AllowGlobal);

            AddRootActions(root);

            return(new [] { root });
        }
예제 #5
0
        private Element CreateElement(SimpleVirtualElement simpleElementNode)
        {
            EntityToken entityToken = new VirtualElementProviderEntityToken(_context.ProviderName, simpleElementNode.Name);

            Element element = new Element(_context.CreateElementHandle(entityToken))
            {
                TagValue   = simpleElementNode.Tag,
                VisualData = new ElementVisualizedData
                {
                    Label       = StringResourceSystemFacade.ParseString(simpleElementNode.Label),
                    HasChildren = true // fixing refresh problem easy way... was: HasChildren(baseElementNode)
                }
            };



            Action <IEnumerable> collectProviders = null;

            // Recursively searching for attached providers
            var attachedProviders = new List <AttachProviderVirtualElement>();

            collectProviders = currentElements =>
            {
                attachedProviders.AddRange(currentElements.OfType <AttachProviderVirtualElement>());
                currentElements.OfType <SimpleVirtualElement>().ForEach(e => collectProviders(e.Elements));
            };
            collectProviders(simpleElementNode.Elements);


            foreach (var attachedProvider in attachedProviders)
            {
                if (ElementFacade.ContainsLocalizedData(new ElementProviderHandle(attachedProvider.ProviderName)))
                {
                    element.IsLocaleAware = true;
                }
            }


            if (element.VisualData.HasChildren)
            {
                ResourceHandle openHandle  = IconResourceSystemFacade.GetResourceHandle(simpleElementNode.OpenFolderIconName);
                ResourceHandle closeHandle = IconResourceSystemFacade.GetResourceHandle(simpleElementNode.CloseFolderIconName);

                closeHandle = closeHandle ?? openHandle;
                openHandle  = openHandle ?? closeHandle;

                if (openHandle == null)
                {
                    openHandle  = CommonElementIcons.Folder;
                    closeHandle = CommonElementIcons.FolderOpen;
                }

                element.VisualData.Icon       = openHandle;
                element.VisualData.OpenedIcon = closeHandle;
            }
            else
            {
                element.VisualData.Icon = CommonElementIcons.FolderDisabled;
            }


            return(element);
        }