Exemplo n.º 1
0
        protected override void OnModifyWorkflow(WfExecutorDataContext dataContext)
        {
            int targetActivityIndex = FindTargetActivityIndex(this.OriginalActivity);

            (targetActivityIndex >= 0).FalseThrow <WfRuntimeException>("活动(ID={0}, Key={1})不能撤回", this.OriginalActivity.ID, this.OriginalActivity.Descriptor.Key);

            WfActivityCollection clonedElapsedActivities = new WfActivityCollection();

            IWfProcess process = this.OriginalActivity.Process;

            clonedElapsedActivities.CopyFrom(process.ElapsedActivities);

            dataContext["OriginalActivityID"] = process.CurrentActivity.ID;

            //将流程实例活动点的状态设置为未运行
            this.OriginalActivity.Process.Withdraw(clonedElapsedActivities[targetActivityIndex], this.CancelAllBranchProcesses);

            //删除掉动态添加的点
            for (int i = targetActivityIndex; i < clonedElapsedActivities.Count; i++)
            {
                IWfActivity act = clonedElapsedActivities[i];

                process.Activities.FindAll(a => a.CreatorInstanceID == act.ID).ForEach(a => a.Delete());
            }

            if (this.CancelProcess)
            {
                process.CancelProcess(this.CancelAllBranchProcesses);
            }
        }
Exemplo n.º 2
0
        public void Delete(WfActivityCollection pendingActivities)
        {
            pendingActivities.NullCheck("pendingActivities");

            InSqlClauseBuilder builder = new InSqlClauseBuilder("ACTIVITY_ID");

            pendingActivities.ForEach(pai => builder.AppendItem(pai.ID));

            if (builder.Count > 0)
            {
                string sql = string.Format("DELETE FROM WF.PENDING_ACTIVITIES WHERE {0}",
                                           builder.ToSqlString(TSqlBuilder.Instance));

                DbHelper.RunSql(sql, this.GetConnectionName());
            }
        }