Beispiel #1
0
        //This method is called when the module is initialized
        public void Initialize()
        {
            //Create the Base Flow Folder which will take on the implemented behavior if it doesn't already exist
            //This folder will be added for everyone
            SystemUserContext suc = new SystemUserContext();

            if (FolderService.Instance.Exists(suc, RESTRICTED_STEPS_FOLDER_EXAMPLE) == false)
            {
                //Create the folder at the root
                FolderService.Instance.CreateRootFolder(suc, RESTRICTED_STEPS_FOLDER_EXAMPLE, "Restricted Flow Steps", typeof(RestrictedStepsFolderBehavior).FullName);

                //Add all Permissions besides ADMIN for the DESIGNERS group so DESIGNERS can create flows in this folder.
                //IF we want to always ensure this permission we would move it OUT of this if block.
                FolderService.Instance.AddGroupPermission(UserContextHolder.GetCurrent(), RESTRICTED_STEPS_FOLDER_EXAMPLE, Constants.DESIGNERS_GROUP_ID, FolderPermission.AllButAdmin);
            }

            //Example Call to REMOVE the created folder
            //FolderService.Instance.DeleteFolder(suc, RESTRICTED_STEPS_FOLDER_EXAMPLE, false);
        }
        public void ListFlowToolboxSteps(string csvOutputPath, string csvFileName)
        {
            AbstractUserContext userContext   = UserContextHolder.GetCurrent();
            FlowEngine          currentEngine = FlowEngine.CurrentEngine;
            string flowId = currentEngine.CurrentTrackingData.FlowId;

            FlowEditSession flowEditSession = FlowEditService.Instance.OpenFlowForEditing(userContext, flowId);

            string[] toolboxCategories =
                FlowEditService.Instance.GetToolboxCategories(userContext, flowEditSession.FlowSessionId, new string[] {});

            List <string> stepInfos = new List <string>();

            foreach (string category in toolboxCategories)
            {
                stepInfos.AddRange(GetStepsInSubCategory(userContext, flowEditSession.FlowSessionId, new [] { category }));
            }

            string filePath = Path.Combine(csvOutputPath, csvFileName);

            File.WriteAllLines(filePath, stepInfos);
        }
        //Method to create a flow with the implemented behavior using Element Registration Helper
        //entityId is the ID of the folder being acted on
        //answer is the text provided by the user who triggered the GetStringAction and will become the name of the rule
        private void CreateRestrictedFlow(AbstractUserContext userContext, string entityID, string answer)
        {
            //Create the flow with the implemented flow behavior
            ElementContextInfo info = new ElementContextInfo(entityID, ElementType.Flow, null,
                                                             typeof(RestrictedStepsFlowBehavior).FullName, null, answer);

            string createdElementRegistrationId = null;

            if (info.ShowIntent)
            {
                FlowInputDataDescription[] inputs = (info.ShowData) ? info.FlowInputs : null;
                string flowExecutionsInFolderId   = (info.ShowTracking && info.SetupReportingOnFlowExecution) ? info.StoreFlowExecutionsInFolderId : null;
                string flowRunIdPrefix            = (info.ShowTracking && info.SetupReportingOnFlowExecution) ? info.Prefix : null;

                // we are going to create based on intent
                createdElementRegistrationId =
                    ConfigurationStorageService.Instance.CreateFlowWithExtraSettings(UserContextHolder.GetCurrent(),
                                                                                     info.FolderId, info.Name, inputs, flowExecutionsInFolderId, flowRunIdPrefix);
            }
            else
            if (info.BasedOn == CreateElementBasedOn.Template && !string.IsNullOrEmpty(info.TemplateId))
            {
                createdElementRegistrationId =
                    ConfigurationStorageService.Instance.CreateFlowFromTemplate(UserContextHolder.GetCurrent(), info.FolderId, info.Name, info.TemplateId);
            }
            else
            if (info.BasedOn == CreateElementBasedOn.Behavior && !string.IsNullOrWhiteSpace(info.BehaviorType))
            {
                createdElementRegistrationId =
                    ConfigurationStorageService.Instance.CreateFlowFromTemplateAndBehaviorType(UserContextHolder.GetCurrent(), info.FolderId, info.Name, null, info.BehaviorType);
            }

            if (string.IsNullOrEmpty(createdElementRegistrationId))
            {
                ConfigurationStorageService.Instance.CreateFlow(UserContextHolder.GetCurrent(), info.FolderId, info.Name);
            }
        }
Beispiel #4
0
 public override bool IsVisible(Folder f)
 {
     return(UserContextHolder.GetCurrent().StudioPortal);
 }