示例#1
0
        public void LogMessage(string message, IEntity referencedObject = null)
        {
            var logActivity = new LogActivity
            {
                Name = "Log",
            };

            logActivity.Save( );
            ToDelete.Add(logActivity.Id);

            var nextActivity = ( LogActivityImplementation )logActivity.As <WfActivity>( ).CreateWindowsActivity( );

            var inputs = new Dictionary <string, object>
            {
                {
                    "Message", message
                },
                {
                    "Object", referencedObject
                }
            };

            using (new WorkflowRunContext {
                RunTriggersInCurrentThread = true
            })
            {
                RunActivity(nextActivity, inputs);
            }
        }
示例#2
0
        static Workflow AddLog_imp(this Workflow wf, string name, string template, string fromNamed, string fromExit, bool isTemplate)
        {
            var log = new LogActivity
            {
                Name = name
            };
            var logAs = log.As <WfActivity>();

            AddExpressionToActivityArgument(wf, logAs, "Message", template, isTemplate);


            wf.AddActivity(logAs, fromNamed, fromExit);
            AddMissingExpressionParametersToWorkflow(wf);

            return(wf);
        }
示例#3
0
        public void PassingValuesBetweenActivities( )
        {
            // This test creates a person with an age of ten and a workflow that takes the persons resource id as inputs, reads that persons age and writes it out to the log embedded in a message.
            // Testing:
            //      Mapping workflow input arguments.
            //      Mapping an output argument to a variable.
            //      Using an expression that contains an input parameter.

            var personType = CodeNameResolver.GetTypeByName("AA_Person").As <EntityType>();
            var ageField   = personType.Fields.First(f => f.Name == "Age");

            var peter = Entity.Create(personType).As <Resource>();

            peter.Name = "Peter" + DateTime.Now;

            peter.SetField(ageField, 10);
            peter.Save( );
            ToDelete.Add(peter.Id);

            var workflow = new Workflow
            {
                Name = "Wf" + DateTime.Now
            };

            workflow.AddDefaultExitPoint( );

            var resourceIdArg = new ResourceArgument
            {
                Name           = "ResourceId",
                ConformsToType = personType
            };
            var resourceIdArgAs = resourceIdArg.As <ActivityArgument>( );

            workflow.InputArguments.Add(resourceIdArg.As <ActivityArgument>( ));
            //workflow.Save( );
            var workflowAs = workflow.As <WfActivity>( );



            // log activity
            var log = new LogActivity
            {
                Name = "log" + DateTime.Now
            };
            var logAs = log.As <WfActivity>( );

            workflow.ContainedActivities.Add(logAs);
            workflow.FirstActivity = logAs;

            ActivityTestHelper.AddExpressionToActivityArgument(workflow, logAs, "Message", "'Peters age is ' + ResourceId.Age", false);

            ActivityTestHelper.AddTermination(workflow, logAs);

            workflow.Save( );
            ToDelete.Add(workflow.Id);

            ActivityImplementationBase nextActivity = workflow.Cast <WfActivity>( ).CreateWindowsActivity( );

            var input = new Dictionary <string, object>
            {
                {
                    "ResourceId", peter
                }
            };

            var run = (RunWorkflow(workflow, input));


            Assert.AreEqual(WorkflowRunState_Enumeration.WorkflowRunCompleted, run.WorkflowRunStatus_Enum, "The workflow run and completed without error");

            //RunActivity( nextActivity, input );
        }