/// <summary>
        /// Creates the instance.
        /// </summary>
        /// <param name="master">The master.</param>
        /// <returns></returns>
        public override object CreateInstance()
        {
            BlockActivity retVal = new BlockActivity();
            retVal.Name = "blockActivity_" + Guid.NewGuid().ToString("N");
            retVal.Type = this.CompletionType;

            return retVal;
        }
        /// <summary>
        /// Creates the instance.
        /// </summary>
        /// <param name="master">The master.</param>
        /// <returns></returns>
        public override object CreateInstance()
        {
            BlockActivity retVal = new BlockActivity();

            retVal.Name = "blockActivity_" + Guid.NewGuid().ToString("N");
            retVal.Type = this.CompletionType;

            return(retVal);
        }
Esempio n. 3
0
        /// <summary>
        /// Sets the type of the block activity.
        /// </summary>
        /// <param name="activity">The activity.</param>
        /// <param name="type">The type.</param>
        public static void SetBlockActivityType(object activity, BlockActivityType type)
        {
            BlockActivity block = activity as BlockActivity;

            if (block == null)
            {
                throw new ArgumentException("The activity should be CompositeActivity.", "activity");
            }

            block.Type = type;
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the type of the block activity.
        /// </summary>
        /// <param name="activity">The activity.</param>
        /// <returns></returns>
        public static BlockActivityType GetBlockActivityType(object activity)
        {
            BlockActivity block = activity as BlockActivity;

            if (block == null)
            {
                throw new ArgumentException("The activity should be CompositeActivity.", "activity");
            }

            return(block.Type);
        }
Esempio n. 5
0
        public static DataTable GetChildActivityList(WorkflowDescription wfDescription, object activity)
        {
            DataTable dt = new DataTable();

            dt.Locale = CultureInfo.InvariantCulture;
            dt.Columns.Add("Id", typeof(string));
            dt.Columns.Add("Number", typeof(int));
            dt.Columns.Add("Subject", typeof(string));
            dt.Columns.Add("User", typeof(int));
            dt.Columns.Add("DueDate", typeof(DateTime));
            dt.Columns.Add("State", typeof(ActivityStatus));
            dt.Columns.Add("IsBlock", typeof(bool));
            dt.Columns.Add("ReadOnlyLibraryAccess", typeof(bool));

            if (activity is SequentialWorkflowActivity)
            {
                SequentialWorkflowActivity block = (SequentialWorkflowActivity)activity;

                foreach (Activity child in block.Activities)
                {
                    ProcessChildActivity(wfDescription, child, dt);
                }
            }
            else if (activity is StateMachineWorkflowActivity)
            {
                StateMachineWorkflowActivity block = (StateMachineWorkflowActivity)activity;

                foreach (Activity child in block.Activities)
                {
                    ProcessChildActivity(wfDescription, child, dt);
                }
            }
            else if (activity is BlockActivity)
            {
                BlockActivity block = (BlockActivity)activity;

                foreach (Activity child in block.Activities)
                {
                    ProcessChildActivity(wfDescription, child, dt);
                }
            }

            return(dt);
        }
Esempio n. 6
0
        void IActivityEventListener <ActivityExecutionStatusChangedEventArgs> .OnEvent(object sender, ActivityExecutionStatusChangedEventArgs e)
        {
            if (sender == null)
            {
                throw new ArgumentNullException("sender");
            }
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            ActivityExecutionContext context = sender as ActivityExecutionContext;

            if (context == null)
            {
                throw new ArgumentException("Sender must be ActivityExecutionContext", "sender");
            }

            BlockActivity activity = context.Activity as BlockActivity;

            e.Activity.UnregisterForStatusChange(Activity.ClosedEvent, this);

            ActivityExecutionStatus result = ActivityExecutionStatus.Initialized;

            switch (this.Type)
            {
            case BlockActivityType.All:
                result = ProcessClosedEvenForAllActivities(context, e.Activity);
                break;

            case BlockActivityType.Any:
                result = ProcessClosedEvenForAnyActivities(context, e.Activity);
                break;

            default:
                throw new ArgumentOutOfRangeException("Unknown Type");
            }

            if (result == ActivityExecutionStatus.Closed)
            {
                context.CloseActivity();
            }
        }
Esempio n. 7
0
        private static void ProcessActivity(WorkflowDescription wfDescription, Activity activity, DataTable dt, int level)
        {
            DataRow row = dt.NewRow();

            row["Id"]     = activity.QualifiedName;
            row["Number"] = dt.Rows.Count + 1;

            if (activity is SequentialWorkflowActivity)
            {
                row["Subject"] = wfDescription.Name;
                row["IsBlock"] = true;
            }
            else if (activity is StateMachineWorkflowActivity)
            {
                row["Subject"] = wfDescription.Name;
                row["IsBlock"] = true;
            }
            else if (activity is BlockActivity)
            {
                if (((BlockActivity)activity).Type == BlockActivityType.All)
                {
                    row["Subject"] = "{IbnFramework.BusinessProcess:BlockActivityTypeAll}";
                }
                else
                {
                    row["Subject"] = "{IbnFramework.BusinessProcess:BlockActivityTypeAny}";
                }

                row["IsBlock"] = true;
            }
            else if (activity is CreateAssignmentAndWaitResultActivity)
            {
                PropertyValueCollection properties = ((CreateAssignmentAndWaitResultActivity)activity).AssignmentProperties;
                row["Subject"] = properties[AssignmentEntity.FieldSubject].ToString();
                row["User"]    = (int)properties[AssignmentEntity.FieldUserId];
                if (properties[AssignmentEntity.FieldPlanFinishDate] != null)
                {
                    row["DueDate"] = (DateTime)properties[AssignmentEntity.FieldPlanFinishDate];
                }
                row["IsBlock"] = false;
            }
            if (row["Subject"] == DBNull.Value)
            {
                row["Subject"] = "{IbnFramework.BusinessProcess:NoSubject}";
            }

            row["State"] = GetActivityStatus(wfDescription, activity);
            row["Level"] = level;
            dt.Rows.Add(row);

            level++;
            if (activity is SequentialWorkflowActivity)
            {
                SequentialWorkflowActivity block = (SequentialWorkflowActivity)activity;

                foreach (Activity child in block.Activities)
                {
                    ProcessActivity(wfDescription, child, dt, level);
                }
            }
            else if (activity is StateMachineWorkflowActivity)
            {
                StateMachineWorkflowActivity block = (StateMachineWorkflowActivity)activity;

                foreach (Activity child in block.Activities)
                {
                    ProcessActivity(wfDescription, child, dt, level);
                }
            }
            else if (activity is BlockActivity)
            {
                BlockActivity block = (BlockActivity)activity;

                foreach (Activity child in block.Activities)
                {
                    ProcessActivity(wfDescription, child, dt, level);
                }
            }
        }