Update() приватный Метод

private Update ( ActivityInstanceEntity entity, IDbSession session ) : void
entity Slickflow.Engine.Business.Entity.ActivityInstanceEntity
session IDbSession
Результат void
Пример #1
0
        /// <summary>
        /// 创建新的委托任务
        /// </summary>
        /// <param name="entity">任务委托实体</param>
        /// <param name="cancalOriginalTask">是否取消原始任务</param>
        internal bool Entrust(TaskEntrustedEntity entity, bool cancalOriginalTask = true)
        {
            var isOk    = false;
            var session = SessionFactory.CreateSession();

            try
            {
                //获取活动实例信息
                session.BeginTrans();

                var am = new ActivityInstanceManager();
                var activityInstance = am.GetByTask(entity.TaskID, session);

                if (activityInstance.ActivityState != (short)ActivityStateEnum.Ready &&
                    activityInstance.ActivityState != (short)ActivityStateEnum.Running)
                {
                    throw new WorkflowException(LocalizeHelper.GetEngineMessage("taskmanager.entrust.warn"));
                }

                //更新AssignedToUsers 信息
                activityInstance.AssignedToUserIDs   = activityInstance.AssignedToUserIDs + "," + entity.EntrustToUserID;
                activityInstance.AssignedToUserNames = activityInstance.AssignedToUserNames + "," + entity.EntrustToUserName;
                activityInstance.ActivityState       = (int)ActivityStateEnum.Ready;
                am.Update(activityInstance, session);

                //更新原委托任务的状态为关闭
                if (cancalOriginalTask == true)
                {
                    var task = GetTask(entity.TaskID);
                    task.TaskState = (short)TaskStateEnum.Closed;
                    Update(task, session);
                }

                //插入委托任务
                Insert(activityInstance, entity.EntrustToUserID, entity.EntrustToUserName,
                       entity.RunnerID, entity.RunnerName, session, entity.TaskID);

                session.Commit();

                isOk = true;
            }
            catch (System.Exception e)
            {
                session.Rollback();
                throw new WorkflowException(LocalizeHelper.GetEngineMessage("taskmanager.entrust.error"),
                                            e);
            }
            finally
            {
                session.Dispose();
            }
            return(isOk);
        }
Пример #2
0
        /// <summary>
        /// 创建新的委托任务
        /// </summary>
        /// <param name="entity">任务委托实体</param>
        /// <param name="cancalOriginalTask">是否取消原始任务</param>
        internal Boolean Entrust(TaskEntrustedEntity entity, bool cancalOriginalTask = true)
        {
            var isOk = false;

            using (var session = DbFactory.CreateSession())
            {
                var transaction = session.DbContext.Database.BeginTransaction();
                try
                {
                    var am = new ActivityInstanceManager();
                    var activityInstance = am.GetByTask(entity.TaskID, session);

                    if (activityInstance.ActivityState != (short)ActivityStateEnum.Ready &&
                        activityInstance.ActivityState != (short)ActivityStateEnum.Running)
                    {
                        throw new WorkflowException("没有可以委托的任务,因为活动实例的状态不在运行状态!");
                    }

                    //更新AssignedToUsers 信息
                    activityInstance.AssignedToUserIDs   = activityInstance.AssignedToUserIDs + "," + entity.EntrustToUserID;
                    activityInstance.AssignedToUserNames = activityInstance.AssignedToUserNames + "," + entity.EntrustToUserName;
                    activityInstance.ActivityState       = (int)ActivityStateEnum.Ready;
                    am.Update(activityInstance, session);

                    //更新原委托任务的状态为关闭
                    if (cancalOriginalTask == true)
                    {
                        var task = GetTask(entity.TaskID);
                        task.TaskState = (short)TaskStateEnum.Closed;
                        Update(task, session);
                    }

                    //插入委托任务
                    Insert(activityInstance, entity.EntrustToUserID, entity.EntrustToUserName,
                           entity.RunnerID, entity.RunnerName, session, entity.TaskID);

                    transaction.Commit();
                    isOk = true;
                }
                catch (System.Exception ex)
                {
                    transaction.Rollback();
                    throw new WorkflowException(string.Format("委托任务时出错!,详细错误:{0}", ex.Message), ex);
                }
            }
            return(isOk);
        }
        /// <summary>
        /// 创建新的委托任务
        /// </summary>
        /// <param name="entity"></param>
        internal bool Entrust(TaskEntrustedEntity entity)
        {
            var isOk    = false;
            var session = SessionFactory.CreateSession();

            try
            {
                //获取活动实例信息
                session.BeginTrans();

                var am = new ActivityInstanceManager();
                var activityInstance = am.GetByTask(entity.ID, session);

                if (activityInstance.ActivityState != (short)ActivityStateEnum.Ready &&
                    activityInstance.ActivityState != (short)ActivityStateEnum.Running)
                {
                    throw new WorkflowException("没有可以委托的任务,因为活动实例的状态不在运行状态!");
                }

                //更新AssignedToUsers 信息
                activityInstance.AssignedToUserIDs   = activityInstance.AssignedToUserIDs + "," + entity.EntrustToUserID;
                activityInstance.AssignedToUserNames = activityInstance.AssignedToUserNames + "," + entity.EntrustToUserName;
                am.Update(activityInstance, session);

                //插入委托任务
                Insert(activityInstance, entity.EntrustToUserID, entity.EntrustToUserName,
                       entity.RunnerID, entity.RunnerName, session);

                session.Commit();

                isOk = true;
            }
            catch (System.Exception e)
            {
                session.Rollback();
                throw new WorkflowException("任务委托失败,请查看异常信息!", e);
            }
            finally
            {
                session.Dispose();
            }
            return(isOk);
        }
Пример #4
0
        /// <summary>
        /// 创建新的委托任务
        /// </summary>
        /// <param name="entity"></param>
        internal void Entrust(TaskEntrustedEntity entity)
        {
            var session = SessionFactory.CreateSession();
            try
            {
                //获取活动实例信息
                session.BeginTrans();

                var am = new ActivityInstanceManager();
                var activityInstance = am.GetByTask(entity.ID, session);

                if (activityInstance.ActivityState != (short)ActivityStateEnum.Ready
                    && activityInstance.ActivityState != (short)ActivityStateEnum.Running)
                {
                    throw new WorkflowException("没有可以委托的任务,因为活动实例的状态不在运行状态!");
                }

                //更新AssignedToUsers 信息
                activityInstance.AssignedToUsers = activityInstance.AssignedToUsers + "," + entity.EntrustToUserID;
                am.Update(activityInstance, session);

                //插入委托任务
                Insert(activityInstance, entity.EntrustToUserID, entity.EntrustToUserName,
                    entity.RunnerID, entity.RunnerName, session);

                session.Commit();
            }
            catch(System.Exception e)
            {
                session.Rollback();
                throw new WorkflowException("任务委托失败,请查看异常信息!", e);
            }
            finally
            {
                session.Dispose();
            }
        }