/// <summary>
        /// 虚拟操作实例
        /// </summary>
        /// <param name="keyValue"></param>
        /// <param name="state">0暂停,1启用,2取消(召回)</param>
        /// <returns></returns>
        public int OperateVirtualProcess(string keyValue, int state)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                WFProcessInstanceEntity entity = this.BaseRepository().FindEntity <WFProcessInstanceEntity>(keyValue);
                if (entity.isFinish == 1)
                {
                    throw new Exception("实例已经审核完成,操作失败");
                }
                else if (entity.isFinish == 2)
                {
                    throw new Exception("实例已经取消,操作失败");
                }
                /// 流程是否完成(0运行中,1运行结束,2被召回,3不同意,4表示被驳回)
                string content = "";
                switch (state)
                {
                case 0:
                    if (entity.EnabledMark == 0)
                    {
                        return(1);
                    }
                    entity.EnabledMark = 0;
                    content            = "【暂停】" + OperatorProvider.Provider.Current().LoginInfo.UserName + "暂停了一个流程进程【" + entity.Code + "/" + entity.CustomName + "】";
                    break;

                case 1:
                    if (entity.EnabledMark == 1)
                    {
                        return(1);
                    }
                    entity.EnabledMark = 1;
                    content            = "【启用】" + OperatorProvider.Provider.Current().LoginInfo.UserName + "启用了一个流程进程【" + entity.Code + "/" + entity.CustomName + "】";
                    break;

                case 2:
                    entity.isFinish = 2;
                    content         = "【召回】" + OperatorProvider.Provider.Current().LoginInfo.UserName + "召回了一个流程进程【" + entity.Code + "/" + entity.CustomName + "】";
                    break;
                }



                db.Update <WFProcessInstanceEntity>(entity);
                WFProcessOperationHistoryEntity processOperationHistoryEntity = new WFProcessOperationHistoryEntity();
                processOperationHistoryEntity.Create();
                processOperationHistoryEntity.ProcessId = entity.Id;
                processOperationHistoryEntity.Content   = content;
                db.Insert(processOperationHistoryEntity);
                db.Commit();
                return(1);
            }
            catch
            {
                db.Rollback();
                throw;
            }
        }
示例#2
0
        /// <summary>
        /// 存储工作流实例进程(创建实例进程)
        /// </summary>
        /// <param name="wfRuntimeModel"></param>
        /// <param name="processInstanceEntity"></param>
        /// <param name="processSchemeEntity"></param>
        /// <param name="processOperationHistoryEntity"></param>
        /// <param name="delegateRecordEntity"></param>
        /// <returns></returns>
        public int SaveProcess(WF_RuntimeModel wfRuntimeModel, WFProcessInstanceEntity processInstanceEntity, WFProcessSchemeEntity processSchemeEntity, WFProcessOperationHistoryEntity processOperationHistoryEntity, WFProcessTransitionHistoryEntity processTransitionHistoryEntity, List <WFDelegateRecordEntity> delegateRecordEntityList)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                if (string.IsNullOrEmpty(processInstanceEntity.Id))
                {
                    processSchemeEntity.Create();
                    db.Insert(processSchemeEntity);

                    processInstanceEntity.Create();
                    processInstanceEntity.Id = wfRuntimeModel.processId;
                    processInstanceEntity.ProcessSchemeId = processSchemeEntity.Id;
                    db.Insert(processInstanceEntity);
                }
                else
                {
                    processInstanceEntity.Modify(processInstanceEntity.Id);
                    db.Update(processSchemeEntity);
                    db.Update(processInstanceEntity);
                }
                processOperationHistoryEntity.Create();
                processOperationHistoryEntity.ProcessId = processInstanceEntity.Id;
                db.Insert(processOperationHistoryEntity);

                if (processTransitionHistoryEntity != null)
                {
                    processTransitionHistoryEntity.Create();
                    processTransitionHistoryEntity.ProcessId = processInstanceEntity.Id;
                    db.Insert(processTransitionHistoryEntity);
                }
                foreach (var item in delegateRecordEntityList)
                {
                    item.Create();
                    item.ProcessId = processInstanceEntity.Id;
                    db.Insert(item);
                }
                //if (processInstanceEntity.FrmType == 0)
                //{
                //    DataBaseLinkEntity dataBaseLinkEntity = dataBaseLinkService.GetEntity(wfRuntimeModel.schemeContentJson.Frm.FrmDbId.Value);//获取
                //    if (wfRuntimeModel.schemeContentJson.Frm.isSystemTable.Value != 0)
                //    {
                //        this.BaseRepository(dataBaseLinkEntity.DbConnection).ExecuteBySql(wfRuntimeModel.sqlFrm);
                //    }
                //}
                db.Commit();
                return(1);
            }
            catch
            {
                db.Rollback();
                throw;
            }
        }
示例#3
0
 /// <summary>
 /// 虚拟操作实例
 /// </summary>
 /// <param name="keyValue"></param>
 /// <param name="state">0暂停,1启用,2取消(召回)</param>
 /// <returns></returns>
 public int OperateVirtualProcess(string keyValue,int state)
 {
     IRepository db = this.BaseRepository().BeginTrans();
     try
     {
         WFProcessInstanceEntity entity = this.BaseRepository().FindEntity<WFProcessInstanceEntity>(keyValue);
         
         // 流程是否完成(0运行中,1运行结束,2被召回,3不同意,4表示被驳回)
         string content = "";
         switch (state)
         {
             case 0:
                 if (entity.F_EnabledMark == 0)
                 {
                     return 1;
                 }
                 entity.F_EnabledMark = 0;
                 content = "【暂停】" + OperatorProvider.Provider.Current().UserName + "暂停了一个流程进程【" + entity.F_Code + "/" + entity.F_Name + "】";
                 break;
             case 1:
                 if (entity.F_EnabledMark == 1)
                 {
                     return 1;
                 }
                 entity.F_EnabledMark = 1;
                 content = "【启用】" + OperatorProvider.Provider.Current().UserName + "启用了一个流程进程【" + entity.F_Code + "/" + entity.F_Name + "】";
                 break;
             case 2:
                 entity.F_EnabledMark = 2;
                 content = "【召回】" + OperatorProvider.Provider.Current().UserName + "召回了一个流程进程【" + entity.F_Code + "/" + entity.F_Name + "】";
                 break;
         }
         db.Update<WFProcessInstanceEntity>(entity);
         WFProcessOperationHistoryEntity processOperationHistoryEntity = new WFProcessOperationHistoryEntity();
         processOperationHistoryEntity.F_Type = 4;
         processOperationHistoryEntity.Create();
         processOperationHistoryEntity.F_ProcessId = entity.F_Id;
         processOperationHistoryEntity.F_Content = content;
         db.Insert(processOperationHistoryEntity);
         db.Commit();
         return 1;
     }
     catch
     {
         db.Rollback();
         throw;
     }
 }
示例#4
0
        /// <summary>
        ///  更新流程实例 审核节点用
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="dbbaseId"></param>
        /// <param name="processInstanceEntity"></param>
        /// <param name="processSchemeEntity"></param>
        /// <param name="processOperationHistoryEntity"></param>
        /// <param name="delegateRecordEntityList"></param>
        /// <param name="processTransitionHistoryEntity"></param>
        /// <returns></returns>
        public int SaveProcess(string sql, string dbbaseId, WFProcessInstanceEntity processInstanceEntity, WFProcessSchemeEntity processSchemeEntity, WFProcessOperationHistoryEntity processOperationHistoryEntity, List <WFDelegateRecordEntity> delegateRecordEntityList, WFProcessTransitionHistoryEntity processTransitionHistoryEntity = null)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                processInstanceEntity.Modify(processInstanceEntity.Id);
                db.Update(processSchemeEntity);
                db.Update(processInstanceEntity);

                processOperationHistoryEntity.Create();
                processOperationHistoryEntity.ProcessId = processInstanceEntity.Id;
                db.Insert(processOperationHistoryEntity);

                if (processTransitionHistoryEntity != null)
                {
                    processTransitionHistoryEntity.Create();
                    processTransitionHistoryEntity.ProcessId = processInstanceEntity.Id;
                    db.Insert(processTransitionHistoryEntity);
                }
                if (delegateRecordEntityList != null)
                {
                    foreach (var item in delegateRecordEntityList)
                    {
                        item.Create();
                        item.ProcessId = processInstanceEntity.Id;
                        db.Insert(item);
                    }
                }
                //if (!string.IsNullOrEmpty(dbbaseId) && !string.IsNullOrEmpty(sql))//测试环境不允许执行sql语句
                //{
                //    DataBaseLinkEntity dataBaseLinkEntity = dataBaseLinkService.GetEntity(dbbaseId);//获取
                //    this.BaseRepository(dataBaseLinkEntity.DbConnection).ExecuteBySql(sql.Replace("{0}", processInstanceEntity.Id));
                //}
                db.Commit();
                return(1);
            }
            catch
            {
                db.Rollback();
                throw;
            }
        }
 /// <summary>
 /// 保存或更新实体对象
 /// </summary>
 /// <param name="keyValue"></param>
 /// <param name="entity"></param>
 public void SaveEntity(string keyValue, WFProcessOperationHistoryEntity entity)
 {
     try
     {
         if (string.IsNullOrEmpty(keyValue))
         {
             entity.Create();
             this.BaseRepository().Insert(entity);
         }
         else
         {
             entity.Modify(keyValue);
             this.BaseRepository().Update(entity);
         }
     }
     catch
     {
         throw;
     }
 }
        /// <summary>
        ///  更新流程实例 审核节点用
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="dbbaseId"></param>
        /// <param name="processInstanceEntity"></param>
        /// <param name="processSchemeEntity"></param>
        /// <param name="processOperationHistoryEntity"></param>
        /// <param name="delegateRecordEntityList"></param>
        /// <param name="processTransitionHistoryEntity"></param>
        /// <returns></returns>
        public int SaveProcess(string sql, string dbbaseId, WFProcessInstanceEntity processInstanceEntity, WFProcessSchemeEntity processSchemeEntity, WFProcessOperationHistoryEntity processOperationHistoryEntity, List <WFDelegateRecordEntity> delegateRecordEntityList, WFProcessTransitionHistoryEntity processTransitionHistoryEntity = null)
        {
            #region 这里才是正常流程处理

            IRepository db2 = this.BaseRepository().BeginTrans();
            try
            {
                processInstanceEntity.Modify(processInstanceEntity.Id);
                db2.Update(processSchemeEntity);
                db2.Update(processInstanceEntity);

                processOperationHistoryEntity.Create();
                processOperationHistoryEntity.ProcessId = processInstanceEntity.Id;
                db2.Insert(processOperationHistoryEntity);

                if (processTransitionHistoryEntity != null)
                {
                    processTransitionHistoryEntity.Create();
                    processTransitionHistoryEntity.ProcessId = processInstanceEntity.Id;
                    db2.Insert(processTransitionHistoryEntity);
                }
                if (delegateRecordEntityList != null)
                {
                    foreach (var item in delegateRecordEntityList)
                    {
                        item.Create();
                        item.ProcessId = processInstanceEntity.Id;
                        db2.Insert(item);
                    }
                }
                db2.Commit();
                return(1);
            }
            catch
            {
                db2.Rollback();
                throw;
            }

            #endregion
        }
        /// <summary>
        /// 存储工作流实例进程(编辑草稿用)
        /// </summary>
        /// <param name="processInstanceEntity"></param>
        /// <param name="processSchemeEntity"></param>
        /// <param name="wfOperationHistoryEntity"></param>
        /// <returns></returns>
        public int SaveProcess(string processId, WFProcessInstanceEntity processInstanceEntity, WFProcessSchemeEntity processSchemeEntity, WFProcessOperationHistoryEntity wfOperationHistoryEntity = null)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                //草稿不需要流程编号
                processInstanceEntity.Code = "";
                if (string.IsNullOrEmpty(processInstanceEntity.Id))
                {
                    processSchemeEntity.Create();
                    db.Insert(processSchemeEntity);

                    processInstanceEntity.Create();
                    processInstanceEntity.Id = processId;
                    processInstanceEntity.ProcessSchemeId = processSchemeEntity.Id;
                    db.Insert(processInstanceEntity);
                }
                else
                {
                    processInstanceEntity.Modify(processId);
                    db.Update(processInstanceEntity);

                    processSchemeEntity.Modify(processInstanceEntity.ProcessSchemeId);
                    db.Update(processSchemeEntity);
                }
                if (wfOperationHistoryEntity != null)
                {
                    wfOperationHistoryEntity.Create();
                    wfOperationHistoryEntity.ProcessId = processId;
                    db.Insert(wfOperationHistoryEntity);
                }
                db.Commit();
                return(1);
            }
            catch
            {
                db.Rollback();
                throw;
            }
        }
        /// <summary>
        /// 存储工作流实例进程(创建实例进程)
        /// </summary>
        /// <param name="wfRuntimeModel"></param>
        /// <param name="processInstanceEntity"></param>
        /// <param name="processSchemeEntity"></param>
        /// <param name="processOperationHistoryEntity"></param>
        /// <param name="delegateRecordEntity"></param>
        /// <returns></returns>
        public int SaveProcess(WF_RuntimeModel wfRuntimeModel, WFProcessInstanceEntity processInstanceEntity, WFProcessSchemeEntity processSchemeEntity, WFProcessOperationHistoryEntity processOperationHistoryEntity, WFProcessTransitionHistoryEntity processTransitionHistoryEntity, List <WFDelegateRecordEntity> delegateRecordEntityList)
        {
            IRepository db = this.BaseRepository().BeginTrans();

            try
            {
                //占用单据号
                coderuleService.UseRuleSeed(OperatorProvider.Provider.Current().LoginInfo.UserId, "", "10007", db);

                if (string.IsNullOrEmpty(processInstanceEntity.Id))
                {
                    processSchemeEntity.Create();
                    db.Insert(processSchemeEntity);

                    processInstanceEntity.Create();
                    processInstanceEntity.Id = wfRuntimeModel.processId;
                    processInstanceEntity.ProcessSchemeId = processSchemeEntity.Id;
                    db.Insert(processInstanceEntity);
                }
                else
                {
                    processInstanceEntity.Modify(processInstanceEntity.Id);
                    db.Update(processSchemeEntity);
                    db.Update(processInstanceEntity);
                }
                processOperationHistoryEntity.Create();
                processOperationHistoryEntity.ProcessId = processInstanceEntity.Id;
                db.Insert(processOperationHistoryEntity);

                if (processTransitionHistoryEntity != null)
                {
                    processTransitionHistoryEntity.Create();
                    processTransitionHistoryEntity.ProcessId = processInstanceEntity.Id;
                    db.Insert(processTransitionHistoryEntity);
                }
                foreach (var item in delegateRecordEntityList)
                {
                    item.Create();
                    item.ProcessId = processInstanceEntity.Id;
                    db.Insert(item);
                }
                if (processInstanceEntity.FrmType == 0)
                {
                    DataBaseLinkEntity dataBaseLinkEntity = dataBaseLinkService.GetEntity(wfRuntimeModel.schemeContentJson.Frm.FrmDbId.Value);//获取
                    if (wfRuntimeModel.schemeContentJson.Frm.isSystemTable.Value != 0)
                    {
                        //是否执行插入数据  外包员工薪资申请流程处理  create by chand 2016-11-29
                        if (processSchemeEntity.WFSchemeInfoId != "3416863b-d5c1-4b31-b59f-e5fd8cd2d5f1")
                        {
                            this.BaseRepository(dataBaseLinkEntity.DbConnection).ExecuteBySql(wfRuntimeModel.sqlFrm);
                        }
                    }
                }
                db.Commit();
                return(1);
            }
            catch
            {
                db.Rollback();
                throw;
            }
        }