Ejemplo n.º 1
0
        public bool IsValidForStartProcess()
        {
            _errores.Clear();
            WorkflowValidator validator = new WorkflowValidator();
            long IdTarea = Workflow.GetIdTakByName(_taskName);
            bool IsValid = validator.IsValidForStartProcess(this._processManager.Process.IdProcess, IdTarea, this);

            _errores.AddAll(validator.GetErrors());
            return(IsValid);
        }
        internal void Workflows(string url)
        {
            using (var cc = TestCommon.CreateClientContext(url))
            {
                ProvisioningTemplateCreationInformation ptci = new ProvisioningTemplateCreationInformation(cc.Web);
                ptci.HandlersToProcess = Handlers.Lists | Handlers.Workflows;
                ptci.FileConnector     = new FileSystemConnector(string.Format(@"{0}\..\..\Framework\Functional", AppDomain.CurrentDomain.BaseDirectory), "Templates");


                var result           = TestProvisioningTemplate(cc, "workflows_add_1605.xml", Handlers.Lists | Handlers.Workflows, null, ptci);
                WorkflowValidator wv = new WorkflowValidator();
                Assert.IsTrue(wv.Validate(result.SourceTemplate.Workflows, result.TargetTemplate.Workflows, result.TargetTokenParser));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds a workflow to this controller.
        /// </summary>
        /// <remarks>
        /// Format for the content names string:
        ///
        /// stage/content name(dynamic arg, :const arg);another stage(args, ...)
        ///
        /// A name, referring to the IInterfaceContent name, followed by optional
        /// argument list (which are passed to the content's Activate method).
        /// dynamic arguments are specified when the workflow is invoked, via
        /// a 'workflow(arg1, arg2, ...)' format, and constant arguments are
        /// specified in the workflow, by preceeding the argument name by a colon.
        /// The argument name is then used as the argument, so ':text' would be
        /// passed as 'text', regardless if ':text' is in the argument dictionary.
        /// Arguments starting with an exlamation mark with reference the current
        /// values, rather than the arguments.
        /// </remarks>
        /// <param name="name">The name of the workflow</param>
        /// <param name="contentnames">A semi-colon separated list of content names to iterate over.</param>
        /// <param name="validators">The validators for the contents, or null if data should always be accepted.</param>
        public void AddWorkflow(string name, string contentnames, WorkflowDataAcceptor finish, WorkflowRedirector redirector = null, params WorkflowValidator[] validators)
        {
            Tuple <string[], List <List <string> > > flow = ParseWorkflow(contentnames);

            // if the validators weren't specified, create them
            if (validators == null || validators.Length == 0)
            {
                validators = new WorkflowValidator[flow.Item1.Length];
            }

            // fill the validators with the identity version if they're null
            for (int i = 0; i < validators.Length; i++)
            {
                if (validators[i] == null)
                {
                    validators[i] = IDENTITY_VALIDATOR;
                }
            }

            // ensure there's a correct number of validators
            if (flow.Item1.Length != validators.Length)
            {
                throw new ArgumentException("Workflow length and validators length do not match");
            }

            // ensure there's atleast one stage
            if (flow.Item1.Length == 0)
            {
                throw new ArgumentException("Workflow must have atleast one content");
            }

            // ensure the name is valid
            if (name == null || name.Length == 0)
            {
                throw new ArgumentException("Invalid workflow name");
            }

            Workflow workflow = new Workflow
            {
                stages     = flow.Item1,
                arguments  = flow.Item2.ToArray(),
                validators = validators,
                acceptor   = finish,
                redirector = redirector
            };

            workflows[name] = workflow;
        }
        internal void Workflows(string url)
        {
            using (var cc = TestCommon.CreateClientContext(url))
            {
                ProvisioningTemplateCreationInformation ptci = new ProvisioningTemplateCreationInformation(cc.Web);
                ptci.HandlersToProcess = Handlers.Lists | Handlers.Workflows;
                ptci.FileConnector     = new FileSystemConnector(string.Format(@"{0}\..\..\Framework\Functional", AppDomain.CurrentDomain.BaseDirectory), "Templates");

                string xmlFileName = null;
#if SP2013
                // pnp:WorkflowSubscription ParentContentTypeId="" not availiable for comparing
                xmlFileName = "workflows_add_1605.SP2013.xml";
#else
                xmlFileName = "workflows_add_1605.xml";
#endif

                var result           = TestProvisioningTemplate(cc, xmlFileName, Handlers.Lists | Handlers.Workflows, null, ptci);
                WorkflowValidator wv = new WorkflowValidator();
                Assert.IsTrue(wv.Validate(result.SourceTemplate.Workflows, result.TargetTemplate.Workflows, result.TargetTokenParser));
            }
        }
Ejemplo n.º 5
0
        public void UserIsInForbidenAndInGroup_ValidTest()
        {
            //Arrange
            var group1 = new Group();
            var group2 = new Group();
            var user   = new User();

            user.UserGroups = new System.Collections.Generic.List <UserGroup>
            {
                new UserGroup {
                    UserToken = user.Token, GroupToken = group1.Token
                },
                new UserGroup {
                    UserToken = user.Token, GroupToken = group2.Token
                },
            };
            Workflow workflow = new Workflow();

            workflow.WorkflowGroups = new System.Collections.Generic.List <WorkflowGroup>
            {
                new WorkflowGroup {
                    GroupToken    = group1,
                    WorkflowToken = workflow
                }
            };

            workflow.ForbidenGroupsTokens = new System.Collections.Generic.List <WorkflowGroup>
            {
                new WorkflowGroup {
                    GroupToken = group2, WorkflowToken = workflow
                }
            };

            //Act
            var validator = new WorkflowValidator();
            var expected  = false;

            //Assert
            Assert.AreEqual(expected, validator.CanUserSeeWorkflow(workflow, user));
        }
Ejemplo n.º 6
0
 protected override void SetupValidators(ChangeSetItems <long, Domain.Workflow> items)
 {
     validator         = new WorkflowValidator();
     deletionValidator = new WorkflowDeleteValidator();
 }