/// <summary>
        /// 返回taskinstance (共21个字段)
        /// </summary>
        /// <param name="rs"></param>
        /// <param name="rowNum"></param>
        /// <returns></returns>
        public static ITaskInstance GetTaskInstance(IDataReader dr)
        {
            ITaskInstance taskInstance = new TaskInstance();
            taskInstance.Id=Convert.ToString(dr["id"]);
            // 20090922 wmj2003 没有给biz_type赋值 是否需要给基于jdbc的数据增加 setBizType()方法?
            taskInstance.TaskId=Convert.ToString(dr["task_id"]);
            taskInstance.ActivityId=Convert.ToString(dr["activity_id"]);
            taskInstance.Name=Convert.ToString(dr["name"]);

            taskInstance.DisplayName=Convert.ToString(dr["display_name"]);
            taskInstance.State=(TaskInstanceStateEnum)Convert.ToInt32(dr["state"]);
            taskInstance.Suspended=Convert.ToInt32(dr["suspended"]) == 1 ? true : false;
            taskInstance.TaskType=(TaskTypeEnum)Enum.Parse(typeof(TaskTypeEnum),Convert.ToString(dr["task_type"]));
            if (!(dr["created_time"] is DBNull)) taskInstance.CreatedTime=Convert.ToDateTime(dr["created_time"]);

            if (!(dr["started_time"] is DBNull)) taskInstance.StartedTime = Convert.ToDateTime(dr["started_time"]);
            if (!(dr["end_time"] is DBNull)) taskInstance.EndTime = Convert.ToDateTime(dr["end_time"]);
            if (!(dr["expired_time"] is DBNull)) taskInstance.ExpiredTime = Convert.ToDateTime(dr["expired_time"]);

            taskInstance.AssignmentStrategy=(FormTaskEnum)Enum.Parse(typeof(FormTaskEnum), Convert.ToString((dr["assignment_strategy"])));
            taskInstance.ProcessInstanceId=Convert.ToString(dr["processinstance_id"]);
            taskInstance.ProcessId=Convert.ToString(dr["process_id"]);

            taskInstance.Version=Convert.ToInt32(dr["version"]);
            taskInstance.TargetActivityId=Convert.ToString(dr["target_activity_id"]);
            taskInstance.FromActivityId=Convert.ToString(dr["from_activity_id"]);
            taskInstance.StepNumber=Convert.ToInt32(dr["step_number"]);
            taskInstance.CanBeWithdrawn=Convert.ToInt32(dr["can_be_withdrawn"]) == 1 ? true : false;
            taskInstance.BizInfo = Convert.ToString(dr["biz_info"]);

            return taskInstance;
        }
Exemple #2
0
        /// <summary>
        /// <para>结束当前WorkItem;并由工作流引擎根据流程定义决定下一步操作。引擎的执行规则如下</para>
        /// <para>1、工作流引擎首先判断该WorkItem对应的TaskInstance是否可以结束。</para>
        /// <para>   如果TaskInstance的assignment策略为ANY,或者,assignment策略为ALL且它所有的WorkItem都已经完成</para>
        /// <para>   则结束当前TaskInstance</para>
        /// <para>2、判断TaskInstance对应的ActivityInstance是否可以结束。如果ActivityInstance的complete strategy为ANY,</para>
        /// <para>   或者,complete strategy为ALL且他的所有的TaskInstance都已经结束,则结束当前ActivityInstance</para>
        /// <para>3、根据流程定义,启动下一个Activity,并创建相关的TaskInstance和WorkItem</para>
        /// </summary>
        /// <param name="dynamicAssignmentHandler">通过动态分配句柄指定下一个环节的操作者。</param>
        /// <param name="comments">备注信息</param>
        public void complete(DynamicAssignmentHandler dynamicAssignmentHandler, String comments)
        {
            if (this._workflowSession == null)
            {
                new EngineException(this.TaskInstance.ProcessInstanceId,
                                    this.TaskInstance.WorkflowProcess, this.TaskInstance.TaskId,
                                    "The current workflow session is null.");
            }
            if (this.RuntimeContext == null)
            {
                new EngineException(this.TaskInstance.ProcessInstanceId,
                                    this.TaskInstance.WorkflowProcess, this.TaskInstance.TaskId,
                                    "The current runtime context is null.");
            }

            if (this.State != WorkItemEnum.RUNNING)
            {
                TaskInstance thisTaskInst = (TaskInstance)this.TaskInstance;
                //			System.out.println("WorkItem的当前状态为"+this.State+",不可以执行complete操作。");
                throw new EngineException(thisTaskInst.ProcessInstanceId, thisTaskInst.WorkflowProcess, thisTaskInst.TaskId,
                                          "Complete work item failed . The state of the work item [id=" + this.Id + "] is " + this.State);
            }

            if (dynamicAssignmentHandler != null)
            {
                this._workflowSession.setDynamicAssignmentHandler(dynamicAssignmentHandler);
            }
            ITaskInstanceManager taskInstanceManager = this.RuntimeContext.TaskInstanceManager;

            taskInstanceManager.completeWorkItem(this, null, comments);
        }
Exemple #3
0
 public WorkItem(WorkItemEnum state, DateTime createdTime, DateTime?signedTm,
                 DateTime?endTime, String comments, TaskInstance taskInstance)
 {
     this.State        = state;
     this.CreatedTime  = createdTime;
     this.ClaimedTime  = signedTm;
     this.EndTime      = endTime;
     this.Comments     = comments;
     this.TaskInstance = taskInstance;
 }
Exemple #4
0
 public WorkItem(WorkItemEnum state, DateTime createdTime, DateTime? signedTm,
     DateTime? endTime, String comments, TaskInstance taskInstance)
 {
     this.State = state;
     this.CreatedTime = createdTime;
     this.ClaimedTime = signedTm;
     this.EndTime = endTime;
     this.Comments = comments;
     this.TaskInstance = taskInstance;
 }
Exemple #5
0
 public WorkItem(TaskInstance taskInstance)
 {
     this.TaskInstance = taskInstance;
 }
 // throws EngineException
 public ITaskInstance createTaskInstance(IWorkflowSession currentSession, RuntimeContext runtimeContxt,
     IProcessInstance processInstance, Task task, Activity activity)
 {
     TaskInstance taskInstance = new TaskInstance();
     return taskInstance;
 }
Exemple #7
0
 public WorkItem(TaskInstance taskInstance)
 {
     this.TaskInstance = taskInstance;
 }
        /// <summary>
        /// 终止TaskInstance。将任务实例及其所有的“活的”WorkItem变成Canceled状态。
        /// "活的"WorkItem 是指状态等于INITIALIZED、STARTED或者SUSPENDED的WorkItem.
        /// </summary>
        public bool AbortTaskInstance(TaskInstance taskInstance)
        {
            SqlTransaction transaction = SqlServerHelper.GetSqlTransaction(connectionString);
            try
            {
                String sql = "update t_ff_rt_taskinstance set state=" + (int)TaskInstanceStateEnum.CANCELED + " ,end_time=@1 where id=@2 and (state=0 or state=1)";
                int count = SqlServerHelper.ExecuteNonQuery(transaction, CommandType.Text, sql,
                    SqlServerHelper.NewSqlParameter("@1", SqlDbType.DateTime, 11, this.RuntimeContext.CalendarService.getSysDate()),
                    SqlServerHelper.NewSqlParameter("@2", SqlDbType.VarChar, 50, taskInstance.Id)
                    );
                if (count <= 0)
                {
                    transaction.Rollback();
                    return false;
                }


                // 将与之关联的WorkItem取消掉
                String workItemSql = " update t_ff_rt_workitem set state=" + (int)WorkItemEnum.CANCELED + ",end_time=@1  "
                        + " where taskinstance_id =@2 ";
                count = SqlServerHelper.ExecuteNonQuery(transaction, CommandType.Text, workItemSql,
                    SqlServerHelper.NewSqlParameter("@1", SqlDbType.DateTime, 11, this.RuntimeContext.CalendarService.getSysDate()),
                    SqlServerHelper.NewSqlParameter("@2", SqlDbType.VarChar, 50, taskInstance.Id)
                    );
                if (count <= 0)
                {
                    transaction.Rollback();
                    return false;
                }

                taskInstance.State = TaskInstanceStateEnum.CANCELED;

                transaction.Commit();
                return true;

            }
            catch
            {
                transaction.Rollback();
                return false;
            }
            finally
            {
                if (transaction.Connection.State != ConnectionState.Closed)
                {
                    transaction.Connection.Close();
                    transaction.Dispose();
                }
            }
        }