Ejemplo n.º 1
0
        private void initializeCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            UpdateTreeRefresher updateTreeRefresher = this.CreateUpdateTreeRefresher(this.EntityToken);

            WorkflowActionToken workflowActionToken = (WorkflowActionToken)this.ActionToken;

            string folderPath = null;

            if (this.EntityToken is WebsiteFileElementProviderRootEntityToken)
            {
                folderPath = "";
            }
            else
            {
                WebsiteFileElementProviderEntityToken entityToken = (WebsiteFileElementProviderEntityToken)this.EntityToken;
                folderPath = entityToken.Path;
            }

            string keyName = workflowActionToken.Payload;

            string relativeFolderPath = IFolderWhiteListExtensions.GetTildePath(folderPath);

            if (!DataFacade.GetData <IFolderWhiteList>().Any(f => f.TildeBasedPath == relativeFolderPath && f.KeyName == keyName))
            {
                IFolderWhiteList folderWhiteList = DataFacade.BuildNew <IFolderWhiteList>();
                folderWhiteList.KeyName        = keyName;
                folderWhiteList.TildeBasedPath = IFolderWhiteListExtensions.GetTildePath(folderPath);
                DataFacade.AddNew(folderWhiteList);
            }

            updateTreeRefresher.PostRefreshMesseges(this.EntityToken);
        }
        private void initializeCodeActivity_ExecuteCode(object sender, EventArgs e)
        {
            WorkflowActionToken workflowActionToken = (WorkflowActionToken)this.ActionToken;
            string folderPath = null;

            if (this.EntityToken is WebsiteFileElementProviderRootEntityToken)
            {
                folderPath = "";
            }
            else
            {
                WebsiteFileElementProviderEntityToken entityToken = (WebsiteFileElementProviderEntityToken)this.EntityToken;
                folderPath = entityToken.Path;
            }

            UpdateTreeRefresher updateTreeRefresher = this.CreateUpdateTreeRefresher(this.EntityToken);

            string keyName = workflowActionToken.Payload;

            DataFacade.Delete <IFolderWhiteList>(f => f.TildeBasedPath == IFolderWhiteListExtensions.GetTildePath(folderPath) && f.KeyName == keyName);

            updateTreeRefresher.PostRefreshMesseges(this.EntityToken);
        }
Ejemplo n.º 3
0
        private IEnumerable <WebsiteFile> GetFilesOnPath(string parentPath, SearchToken searchToken)
        {
            if (string.IsNullOrEmpty(_folderWhiteListKeyName) == false)
            {
                string parentTildaPath = IFolderWhiteListExtensions.GetTildePath(parentPath);
                // NOTE: linq2sql conversion doesn't support xxx.StartsWith(someParameter) construction, that's why we're using two ling statements to get the data
                bool isWhitelisted = (from path in ((from item in DataFacade.GetData <IFolderWhiteList>()
                                                     where item.KeyName == _folderWhiteListKeyName
                                                     select item.TildeBasedPath) as IEnumerable <string>)
                                      where parentTildaPath.StartsWith(path)
                                      select path).Any();

                if (!isWhitelisted)
                {
                    yield break;
                }
            }

            IEnumerable <WebsiteFile> files =
                from filename in Directory.GetFiles(parentPath)
                orderby filename
                select new WebsiteFile(filename);

            if (searchToken.IsValidKeyword())
            {
                files =
                    from file in files
                    where file.FileName.ToLowerInvariant().Contains(searchToken.Keyword.ToLowerInvariant())
                    select file;
            }

            foreach (var file in files)
            {
                yield return(file);
            }
        }
Ejemplo n.º 4
0
        private void AppendFolderManagementActions(string websiteFolderPath, IEnumerable <IFolderWhiteList> manageableFolderWhiteLists, IList <ElementAction> folderActions)
        {
            for (int i = 0; i < _manageableKeyNames.Count; i++)
            {
                string keyName   = _manageableKeyNames[i];
                string itemLabel = StringResourceSystemFacade.ParseString(_manageableKeyNameLabels[i]);

                ResourceHandle      icon                = null;
                string              label               = null;
                string              tooltip             = null;
                WorkflowActionToken workflowActionToken = null;

                ActionCheckedStatus checkedStatus = ActionCheckedStatus.Uncheckable;

                if (manageableFolderWhiteLists.Where(f => f.KeyName == keyName && f.TildeBasedPath == IFolderWhiteListExtensions.GetTildePath(websiteFolderPath)).Any())
                {
                    workflowActionToken = new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.WebsiteFileElementProvider.RemoveWebsiteFolderFromWhiteListWorkflow"), _changeWhiteListPermissionTypes);
                    label         = StringResourceSystemFacade.GetString("Composite.Plugins.WebsiteFileElementProvider", "RemoveFolderFromWhiteListTitle");
                    tooltip       = StringResourceSystemFacade.GetString("Composite.Plugins.WebsiteFileElementProvider", "RemoveFolderFromWhiteListToolTip");
                    icon          = WebsiteFileElementProvider.RemoveFolderFromWhiteList;
                    checkedStatus = ActionCheckedStatus.Checked;
                }
                else
                {
                    workflowActionToken = new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.WebsiteFileElementProvider.AddWebsiteFolderToWhiteListWorkflow"), _changeWhiteListPermissionTypes);
                    label         = StringResourceSystemFacade.GetString("Composite.Plugins.WebsiteFileElementProvider", "AddFolderToWhiteListTitle");
                    tooltip       = StringResourceSystemFacade.GetString("Composite.Plugins.WebsiteFileElementProvider", "AddFolderToWhiteListToolTip");
                    icon          = WebsiteFileElementProvider.AddFolderToWhiteList;
                    checkedStatus = ActionCheckedStatus.Unchecked;
                }

                label   = string.Format(label, itemLabel);
                tooltip = string.Format(tooltip, itemLabel);

                workflowActionToken.Payload = keyName;

                folderActions.Add(
                    new ElementAction(new ActionHandle(workflowActionToken))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label          = label,
                        ToolTip        = tooltip,
                        Icon           = icon,
                        Disabled       = false,
                        ActionLocation = new ActionLocation
                        {
                            ActionType  = ActionType.Other,
                            IsInFolder  = false,
                            IsInToolbar = false,
                            ActionGroup = PrimaryFolderToolsActionGroup
                        },
                        ActionCheckedStatus = checkedStatus
                    }
                });
            }
        }