/*****************************************************************************/ /************ **********/ /************ task instance 相关的持久化方法 **********/ /************ Persistence methods for task instance **********/ /************ **********/ /******************************************************************************/ /// <summary> /// <para>插入或者更新TaskInstance。</para> /// <para>Save or update task instance. If the taskInstance.id is null then insert a new task instance record</para> /// <para>and generate a new id for it { throw new NotImplementedException(); }</para> /// <para>otherwise update the existent one. </para> /// </summary> public bool SaveOrUpdateTaskInstance(ITaskInstance taskInstance) { if (String.IsNullOrEmpty(taskInstance.Id)) { ((TaskInstance)taskInstance).Id = Guid.NewGuid().ToString().Replace("-", ""); string insert = "INSERT INTO T_FF_RT_TASKINSTANCE (" + "ID, BIZ_TYPE, TASK_ID, ACTIVITY_ID, NAME, " + "DISPLAY_NAME, STATE, SUSPENDED, TASK_TYPE, CREATED_TIME, " + "STARTED_TIME, EXPIRED_TIME, END_TIME, ASSIGNMENT_STRATEGY, PROCESSINSTANCE_ID, " + "PROCESS_ID, VERSION, TARGET_ACTIVITY_ID, FROM_ACTIVITY_ID, STEP_NUMBER, " + "CAN_BE_WITHDRAWN, BIZ_INFO )VALUES(@1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11, @12, @13, @14, @15, @16, @17, @18, @19, @20, @21, @22)"; SqlParameter[] insertParms = { SqlServerHelper.NewSqlParameter("@1", SqlDbType.VarChar, 50, taskInstance.Id), SqlServerHelper.NewSqlParameter("@2", SqlDbType.VarChar, 250, taskInstance.GetType().Name), SqlServerHelper.NewSqlParameter("@3", SqlDbType.VarChar, 300, taskInstance.TaskId), SqlServerHelper.NewSqlParameter("@4", SqlDbType.VarChar, 200, taskInstance.ActivityId), SqlServerHelper.NewSqlParameter("@5", SqlDbType.VarChar, 100, taskInstance.Name), SqlServerHelper.NewSqlParameter("@6", SqlDbType.VarChar, 128, taskInstance.DisplayName), SqlServerHelper.NewSqlParameter("@7", SqlDbType.Int, (int)taskInstance.State), SqlServerHelper.NewSqlParameter("@8", SqlDbType.SmallInt, SqlServerHelper.OraBit(taskInstance.IsSuspended())), SqlServerHelper.NewSqlParameter("@9", SqlDbType.VarChar, 10, taskInstance.TaskType), SqlServerHelper.NewSqlParameter("@10", SqlDbType.DateTime, 11, taskInstance.CreatedTime), SqlServerHelper.NewSqlParameter("@11", SqlDbType.DateTime, 11, taskInstance.StartedTime), SqlServerHelper.NewSqlParameter("@12", SqlDbType.DateTime, 11, taskInstance.ExpiredTime), SqlServerHelper.NewSqlParameter("@13", SqlDbType.DateTime, 11, taskInstance.EndTime), SqlServerHelper.NewSqlParameter("@14", SqlDbType.VarChar, 10, taskInstance.AssignmentStrategy), SqlServerHelper.NewSqlParameter("@15", SqlDbType.VarChar, 50, taskInstance.ProcessInstanceId), SqlServerHelper.NewSqlParameter("@16", SqlDbType.VarChar, 100, taskInstance.ProcessId), SqlServerHelper.NewSqlParameter("@17", SqlDbType.Int, taskInstance.Version), SqlServerHelper.NewSqlParameter("@18", SqlDbType.VarChar, 100, taskInstance.TargetActivityId), SqlServerHelper.NewSqlParameter("@19", SqlDbType.VarChar, 600, ((TaskInstance) taskInstance).FromActivityId), SqlServerHelper.NewSqlParameter("@20", SqlDbType.Int, taskInstance.StepNumber), SqlServerHelper.NewSqlParameter("@21", SqlDbType.SmallInt, SqlServerHelper.OraBit(((TaskInstance) taskInstance).CanBeWithdrawn)), SqlServerHelper.NewSqlParameter("@22", SqlDbType.VarChar, 500, taskInstance.BizInfo) }; if (SqlServerHelper.ExecuteNonQuery(connectionString, CommandType.Text, insert, insertParms) != 1) return false; else return true; } else { string update = "UPDATE T_FF_RT_TASKINSTANCE SET " + "BIZ_TYPE=@2, TASK_ID=@3, ACTIVITY_ID=@4, NAME=@5, DISPLAY_NAME=@6, " + "STATE=@7, SUSPENDED=@8, TASK_TYPE=@9, CREATED_TIME=@10, STARTED_TIME=@11, " + "EXPIRED_TIME=@12, END_TIME=@13, ASSIGNMENT_STRATEGY=@14, PROCESSINSTANCE_ID=@15, PROCESS_ID=@16, " + "VERSION=@17, TARGET_ACTIVITY_ID=@18, FROM_ACTIVITY_ID=@19, STEP_NUMBER=@20, CAN_BE_WITHDRAWN=@21, BIZ_INFO=@22" + " WHERE ID=@1"; SqlParameter[] updateParms = { SqlServerHelper.NewSqlParameter("@2", SqlDbType.VarChar, 250, taskInstance.GetType().Name), SqlServerHelper.NewSqlParameter("@3", SqlDbType.VarChar, 300, taskInstance.TaskId), SqlServerHelper.NewSqlParameter("@4", SqlDbType.VarChar, 200, taskInstance.ActivityId), SqlServerHelper.NewSqlParameter("@5", SqlDbType.VarChar, 100, taskInstance.Name), SqlServerHelper.NewSqlParameter("@6", SqlDbType.VarChar, 128, taskInstance.DisplayName), SqlServerHelper.NewSqlParameter("@7", SqlDbType.Int, (int)taskInstance.State), SqlServerHelper.NewSqlParameter("@8", SqlDbType.SmallInt, SqlServerHelper.OraBit(taskInstance.IsSuspended())), SqlServerHelper.NewSqlParameter("@9", SqlDbType.VarChar, 10, taskInstance.TaskType), SqlServerHelper.NewSqlParameter("@10", SqlDbType.DateTime, 11, taskInstance.CreatedTime), SqlServerHelper.NewSqlParameter("@11", SqlDbType.DateTime, 11, taskInstance.StartedTime), SqlServerHelper.NewSqlParameter("@12", SqlDbType.DateTime, 11, taskInstance.ExpiredTime), SqlServerHelper.NewSqlParameter("@13", SqlDbType.DateTime, 11, taskInstance.EndTime), SqlServerHelper.NewSqlParameter("@14", SqlDbType.VarChar, 10, taskInstance.AssignmentStrategy), SqlServerHelper.NewSqlParameter("@15", SqlDbType.VarChar, 50, taskInstance.ProcessInstanceId), SqlServerHelper.NewSqlParameter("@16", SqlDbType.VarChar, 100, taskInstance.ProcessId), SqlServerHelper.NewSqlParameter("@17", SqlDbType.Int, taskInstance.Version), SqlServerHelper.NewSqlParameter("@18", SqlDbType.VarChar, 100, taskInstance.TargetActivityId), SqlServerHelper.NewSqlParameter("@19", SqlDbType.VarChar, 600, ((TaskInstance) taskInstance).FromActivityId), SqlServerHelper.NewSqlParameter("@20", SqlDbType.Int, taskInstance.StepNumber), SqlServerHelper.NewSqlParameter("@21", SqlDbType.SmallInt, SqlServerHelper.OraBit(((TaskInstance) taskInstance).CanBeWithdrawn)), SqlServerHelper.NewSqlParameter("@22", SqlDbType.VarChar, 500, taskInstance.BizInfo), SqlServerHelper.NewSqlParameter("@1", SqlDbType.VarChar, 50, taskInstance.Id) }; if (SqlServerHelper.ExecuteNonQuery(connectionString, CommandType.Text, update, updateParms) != 1) return false; else return true; } }
/*****************************************************************************/ /************ **********/ /************ task instance 相关的持久化方法 **********/ /************ Persistence methods for task instance **********/ /************ **********/ /******************************************************************************/ /// <summary> /// <para>插入或者更新TaskInstance。</para> /// <para>Save or update task instance. If the taskInstance.id is null then insert a new task instance record</para> /// <para>and generate a new id for it { throw new NotImplementedException(); }</para> /// <para>otherwise update the existent one. </para> /// </summary> public bool SaveOrUpdateTaskInstance(ITaskInstance taskInstance) { if (String.IsNullOrEmpty(taskInstance.Id)) { ((TaskInstance)taskInstance).Id = Guid.NewGuid().ToString().Replace("-", ""); string insert = "INSERT INTO T_FF_RT_TASKINSTANCE (" + "ID, BIZ_TYPE, TASK_ID, ACTIVITY_ID, NAME, " + "DISPLAY_NAME, STATE, SUSPENDED, TASK_TYPE, CREATED_TIME, " + "STARTED_TIME, EXPIRED_TIME, END_TIME, ASSIGNMENT_STRATEGY, PROCESSINSTANCE_ID, " + "PROCESS_ID, VERSION, TARGET_ACTIVITY_ID, FROM_ACTIVITY_ID, STEP_NUMBER, " + "CAN_BE_WITHDRAWN, BIZ_INFO )VALUES(:1, :2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19, :20, :21, :22)"; OracleParameter[] insertParms = { OracleHelper.NewOracleParameter(":1", OracleType.VarChar, 50, taskInstance.Id), OracleHelper.NewOracleParameter(":2", OracleType.VarChar, 250, taskInstance.GetType().Name), OracleHelper.NewOracleParameter(":3", OracleType.VarChar, 300, taskInstance.TaskId), OracleHelper.NewOracleParameter(":4", OracleType.VarChar, 200, taskInstance.ActivityId), OracleHelper.NewOracleParameter(":5", OracleType.VarChar, 100, taskInstance.Name), OracleHelper.NewOracleParameter(":6", OracleType.VarChar, 128, taskInstance.DisplayName), OracleHelper.NewOracleParameter(":7", OracleType.Int32, (int)taskInstance.State), OracleHelper.NewOracleParameter(":8", OracleType.Int16, OracleHelper.OraBit(taskInstance.IsSuspended())), OracleHelper.NewOracleParameter(":9", OracleType.VarChar, 10, taskInstance.TaskType), OracleHelper.NewOracleParameter(":10", OracleType.Timestamp, 11, taskInstance.CreatedTime), OracleHelper.NewOracleParameter(":11", OracleType.Timestamp, 11, taskInstance.StartedTime), OracleHelper.NewOracleParameter(":12", OracleType.Timestamp, 11, taskInstance.ExpiredTime), OracleHelper.NewOracleParameter(":13", OracleType.Timestamp, 11, taskInstance.EndTime), OracleHelper.NewOracleParameter(":14", OracleType.VarChar, 10, taskInstance.AssignmentStrategy), OracleHelper.NewOracleParameter(":15", OracleType.VarChar, 50, taskInstance.ProcessInstanceId), OracleHelper.NewOracleParameter(":16", OracleType.VarChar, 100, taskInstance.ProcessId), OracleHelper.NewOracleParameter(":17", OracleType.Int32, taskInstance.Version), OracleHelper.NewOracleParameter(":18", OracleType.VarChar, 100, taskInstance.TargetActivityId), OracleHelper.NewOracleParameter(":19", OracleType.VarChar, 600, ((TaskInstance) taskInstance).FromActivityId), OracleHelper.NewOracleParameter(":20", OracleType.Int32, taskInstance.StepNumber), OracleHelper.NewOracleParameter(":21", OracleType.Int16, OracleHelper.OraBit(((TaskInstance) taskInstance).CanBeWithdrawn)), OracleHelper.NewOracleParameter(":22", OracleType.VarChar, 500, taskInstance.BizInfo) }; if (OracleHelper.ExecuteNonQuery(connectionString, CommandType.Text, insert, insertParms) != 1) return false; else return true; } else { string update = "UPDATE T_FF_RT_TASKINSTANCE SET " + "BIZ_TYPE=:2, TASK_ID=:3, ACTIVITY_ID=:4, NAME=:5, DISPLAY_NAME=:6, " + "STATE=:7, SUSPENDED=:8, TASK_TYPE=:9, CREATED_TIME=:10, STARTED_TIME=:11, " + "EXPIRED_TIME=:12, END_TIME=:13, ASSIGNMENT_STRATEGY=:14, PROCESSINSTANCE_ID=:15, PROCESS_ID=:16, " + "VERSION=:17, TARGET_ACTIVITY_ID=:18, FROM_ACTIVITY_ID=:19, STEP_NUMBER=:20, CAN_BE_WITHDRAWN=:21, BIZ_INFO=:22" + " WHERE ID=:1"; OracleParameter[] updateParms = { OracleHelper.NewOracleParameter(":2", OracleType.VarChar, 250, taskInstance.GetType().Name), OracleHelper.NewOracleParameter(":3", OracleType.VarChar, 300, taskInstance.TaskId), OracleHelper.NewOracleParameter(":4", OracleType.VarChar, 200, taskInstance.ActivityId), OracleHelper.NewOracleParameter(":5", OracleType.VarChar, 100, taskInstance.Name), OracleHelper.NewOracleParameter(":6", OracleType.VarChar, 128, taskInstance.DisplayName), OracleHelper.NewOracleParameter(":7", OracleType.Int32, (int)taskInstance.State), OracleHelper.NewOracleParameter(":8", OracleType.Int16, OracleHelper.OraBit(taskInstance.IsSuspended())), OracleHelper.NewOracleParameter(":9", OracleType.VarChar, 10, taskInstance.TaskType), OracleHelper.NewOracleParameter(":10", OracleType.Timestamp, 11, taskInstance.CreatedTime), OracleHelper.NewOracleParameter(":11", OracleType.Timestamp, 11, taskInstance.StartedTime), OracleHelper.NewOracleParameter(":12", OracleType.Timestamp, 11, taskInstance.ExpiredTime), OracleHelper.NewOracleParameter(":13", OracleType.Timestamp, 11, taskInstance.EndTime), OracleHelper.NewOracleParameter(":14", OracleType.VarChar, 10, taskInstance.AssignmentStrategy), OracleHelper.NewOracleParameter(":15", OracleType.VarChar, 50, taskInstance.ProcessInstanceId), OracleHelper.NewOracleParameter(":16", OracleType.VarChar, 100, taskInstance.ProcessId), OracleHelper.NewOracleParameter(":17", OracleType.Int32, taskInstance.Version), OracleHelper.NewOracleParameter(":18", OracleType.VarChar, 100, taskInstance.TargetActivityId), OracleHelper.NewOracleParameter(":19", OracleType.VarChar, 600, ((TaskInstance) taskInstance).FromActivityId), OracleHelper.NewOracleParameter(":20", OracleType.Int32, taskInstance.StepNumber), OracleHelper.NewOracleParameter(":21", OracleType.Int16, OracleHelper.OraBit(((TaskInstance) taskInstance).CanBeWithdrawn)), OracleHelper.NewOracleParameter(":22", OracleType.VarChar, 500, taskInstance.BizInfo), OracleHelper.NewOracleParameter(":1", OracleType.VarChar, 50, taskInstance.Id) }; if (OracleHelper.ExecuteNonQuery(connectionString, CommandType.Text, update, updateParms) != 1) return false; else return true; } }