/// <summary>
        /// 最终审核通过(完成)
        /// </summary>
        /// <param name="currentId">当前主键</param>
        /// <param name="auditIdea">批示</param>
        /// <returns>影响行数</returns>
        private BaseWorkFlowCurrentEntity StepAuditComplete(string currentId, string auditIdea)
        {
            BaseWorkFlowCurrentEntity currentEntity = this.GetEntity(currentId);

            // 1.记录审核时间、审核人、审核意见
            currentEntity.AuditUserId       = this.UserInfo.Id;
            currentEntity.AuditUserRealName = this.UserInfo.RealName;
            currentEntity.AuditIdea         = auditIdea;
            currentEntity.AuditStatus       = AuditStatus.AuditComplete.ToString();
            currentEntity.AuditStatusName   = AuditStatus.AuditComplete.ToDescription();
            currentEntity.AuditDate         = DateTime.Now;
            currentEntity.ToUserId          = null;
            currentEntity.ToUserRealName    = null;
            currentEntity.ToDepartmentId    = null;
            currentEntity.ToDepartmentName  = null;
            currentEntity.ToRoleId          = null;
            currentEntity.ToRoleRealName    = null;
            // 审批好了,数据就生效了
            currentEntity.Enabled = 1;
            // 2.记录审核日志记录日志
            this.AddHistory(currentEntity);
            // 3.更新当前表
            this.UpdateEntity(currentEntity);
            return(currentEntity);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加到工作流审批流程历史
        /// </summary>
        /// <param name="currentId">当前工作流主键</param>
        /// <returns>主键</returns>
        private string AddHistory(string currentId)
        {
            // 读取一下,然后添加到历史记录表里
            BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetEntity(currentId);

            return(this.AddHistory(workFlowCurrentEntity));
        }
        /// <summary>
        /// 审核通过
        /// </summary>
        /// <param name="id">当前主键</param>
        /// <param name="auditIdea">批示</param>
        /// <returns>影响行数</returns>
        public int AuditPass(IWorkFlowManager workFlowManager, string currentId, string auditIdea, BaseWorkFlowActivityEntity workFlowActivityEntity)
        {
            int returnValue = 0;

            // 进行更新操作
            returnValue = this.StepAuditPass(currentId, auditIdea, workFlowActivityEntity);
            if (returnValue == 0)
            {
                // 数据可能被删除
                this.ReturnStatusCode = StatusCode.ErrorDeleted.ToString();
            }
            BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetEntity(currentId);

            // 发送提醒信息
            if (workFlowManager != null)
            {
                if (!string.IsNullOrEmpty(workFlowActivityEntity.AuditUserId))
                {
                    workFlowActivityEntity.AuditDepartmentId = null;
                    workFlowActivityEntity.AuditRoleId       = null;
                }
                workFlowManager.OnAutoAuditPass(workFlowCurrentEntity);
                workFlowManager.SendRemindMessage(workFlowCurrentEntity, AuditStatus.AuditPass, new string[] { workFlowCurrentEntity.CreateUserId, workFlowActivityEntity.AuditUserId }, workFlowActivityEntity.AuditDepartmentId, workFlowActivityEntity.AuditRoleId);
            }
            this.ReturnStatusMessage = this.GetStateMessage(this.ReturnStatusCode);
            return(returnValue);
        }
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="baseWorkFlowCurrentEntity">实体</param>
 private void SetEntity(SQLBuilder sqlBuilder, BaseWorkFlowCurrentEntity baseWorkFlowCurrentEntity)
 {
     SetEntityExpand(sqlBuilder, baseWorkFlowCurrentEntity);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldCategoryCode, baseWorkFlowCurrentEntity.CategoryCode);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldCategoryFullName, baseWorkFlowCurrentEntity.CategoryFullName);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldObjectId, baseWorkFlowCurrentEntity.ObjectId);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldObjectFullName, baseWorkFlowCurrentEntity.ObjectFullName);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldWorkFlowId, baseWorkFlowCurrentEntity.WorkFlowId);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldActivityId, baseWorkFlowCurrentEntity.ActivityId);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldActivityFullName, baseWorkFlowCurrentEntity.ActivityFullName);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldToDepartmentId, baseWorkFlowCurrentEntity.ToDepartmentId);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldToDepartmentName, baseWorkFlowCurrentEntity.ToDepartmentName);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldToUserId, baseWorkFlowCurrentEntity.ToUserId);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldToUserRealName, baseWorkFlowCurrentEntity.ToUserRealName);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldToRoleId, baseWorkFlowCurrentEntity.ToRoleId);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldToRoleRealName, baseWorkFlowCurrentEntity.ToRoleRealName);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldAuditUserId, baseWorkFlowCurrentEntity.AuditUserId);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldAuditUserCode, baseWorkFlowCurrentEntity.AuditUserCode);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldAuditUserRealName, baseWorkFlowCurrentEntity.AuditUserRealName);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldSendDate, baseWorkFlowCurrentEntity.SendDate);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldAuditDate, baseWorkFlowCurrentEntity.AuditDate);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldAuditIdea, baseWorkFlowCurrentEntity.AuditIdea);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldAuditStatus, baseWorkFlowCurrentEntity.AuditStatus);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldAuditStatusName, baseWorkFlowCurrentEntity.AuditStatusName);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldSortCode, baseWorkFlowCurrentEntity.SortCode);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldEnabled, baseWorkFlowCurrentEntity.Enabled);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldDeletionStateCode, baseWorkFlowCurrentEntity.DeletionStateCode);
     sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldDescription, baseWorkFlowCurrentEntity.Description);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 获取反射调用的类
        /// 回写状态时用
        /// </summary>
        /// <param name="currentId">当前工作流主键</param>
        /// <returns></returns>
        public IWorkFlowManager GetWorkFlowManager(string currentId)
        {
            IWorkFlowManager workFlowManager = new BaseUserBillManager();

            BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetEntity(currentId);

            workFlowManager.SetUserInfo(this.UserInfo);
            workFlowManager.CurrentTableName = workFlowCurrentEntity.CategoryCode;

            string workFlowId = this.GetEntity(currentId).WorkFlowId.ToString();

            if (!workFlowId.Equals("0"))
            {
                BaseWorkFlowProcessManager workFlowProcessManager = new BaseWorkFlowProcessManager(this.DbHelper, this.UserInfo);
                BaseWorkFlowProcessEntity  workFlowProcessEntity  = new BaseWorkFlowProcessEntity();
                if (!string.IsNullOrEmpty(workFlowId))
                {
                    workFlowProcessEntity = workFlowProcessManager.GetEntity(workFlowId);
                }
                if (!string.IsNullOrEmpty(workFlowProcessEntity.CallBackClass))
                {
                    // 这里本来是想动态创建类库 编码外包[100]
                    Type objType = Type.GetType(workFlowProcessEntity.CallBackClass, true);
                    workFlowManager = (IWorkFlowManager)Activator.CreateInstance(objType);
                    workFlowManager.SetUserInfo(this.UserInfo);
                }
                if (!string.IsNullOrEmpty(workFlowProcessEntity.CallBackTable))
                {
                    // 这里本来是想动态创建类库 编码外包[100]
                    workFlowManager.CurrentTableName = workFlowProcessEntity.CallBackTable;
                }
            }
            // workFlowManager = new BaseUserBillManager(this.DbHelper, this.UserInfo);
            return(workFlowManager);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 重置审批流程中的单据(撤销的没必要发送提醒信息)
        /// </summary>
        /// <param name="categoryCode">分类编号</param>
        /// <param name="objectId">实体主键</param>
        /// <param name="auditIdea">批示</param>
        /// <returns>影响行数</returns>
        public int Reset(BaseWorkFlowCurrentEntity workFlowCurrentEntity)
        {
            IWorkFlowManager workFlowManager = this.GetWorkFlowManager(workFlowCurrentEntity.Id);

            // 退回时,应该给创建者一个提醒消息
            return(workFlowManager.OnReset(workFlowCurrentEntity) ? 1 : 0);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 撤消审批流程中的单据(撤销的没必要发送提醒信息)
        /// </summary>
        /// <param name="currentId">当前主键</param>
        /// <param name="auditIdea">批示</param>
        /// <returns>影响行数</returns>
        public int AuditQuash(IWorkFlowManager workFlowManager, string currentId, string auditIdea)
        {
            int returnValue = 0;

            if (!string.IsNullOrEmpty(currentId))
            {
                // using (TransactionScope transactionScope = new TransactionScope())
                // {
                try
                {
                    BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetEntity(currentId);
                    // 只有待审核状态的,才可以撤销,被退回的也可以废弃
                    if (workFlowCurrentEntity.AuditStatus.Equals(AuditStatus.AuditComplete.ToString()) ||
                        workFlowCurrentEntity.AuditStatus.Equals(AuditStatus.AuditQuash.ToString()))
                    {
                        return(returnValue);
                    }
                    // 是超级管理员,或者创建者自己才可以撤销
                    if (!UserInfo.IsAdministrator && !workFlowCurrentEntity.CreateUserId.Equals(UserInfo.Id))
                    {
                        return(returnValue);
                    }
                    // 是自己的的单子需要被审核
                    // 最后修改人是自己,表明是自己发出的
                    // if ((baseWorkFlowCurrentEntity.ModifiedUserId == UserInfo.Id) || (baseWorkFlowCurrentEntity.CreateUserId == UserInfo.Id))
                    //{
                    // 进行更新操作
                    workFlowCurrentEntity = this.StepAuditQuash(currentId, auditIdea);
                    if (!string.IsNullOrEmpty(workFlowCurrentEntity.Id))
                    {
                        // 发送提醒信息
                        if (workFlowManager != null)
                        {
                            workFlowManager.OnAuditQuash(workFlowCurrentEntity);
                            returnValue = workFlowManager.SendRemindMessage(workFlowCurrentEntity, AuditStatus.AuditQuash, new string[] { workFlowCurrentEntity.CreateUserId }, null, null);
                        }
                    }
                    else
                    {
                        // 数据可能被删除
                        this.ReturnStatusCode = StatusCode.ErrorDeleted.ToString();
                    }
                    // }
                    this.ReturnStatusMessage = this.GetStateMessage(this.ReturnStatusCode);
                }
                catch (System.Exception ex)
                {
                    // 在本地记录异常
                    FileUtil.WriteException(UserInfo, ex);
                }
                finally
                {
                }
                // transactionScope.Complete();
                // }
            }
            return(returnValue);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 自由审批
        /// </summary>
        /// <param name="workFlowManager"></param>
        /// <param name="currentId"></param>
        /// <param name="toUserId"></param>
        /// <param name="toDepartmentId"></param>
        /// <param name="toRoleId"></param>
        /// <param name="auditIdea"></param>
        /// <returns></returns>
        public int FreeAuditPass(IWorkFlowManager workFlowManager, string currentId, string toUserId, string toDepartmentId = null, string toRoleId = null, string auditIdea = null)
        {
            // 返回值
            int returnValue = 0;

            // 这里用锁的机制,提高并发控制能力
            lock (WorkFlowCurrentLock)
            {
                BaseWorkFlowActivityEntity workFlowActivityEntity = new BaseWorkFlowActivityEntity();
                // FreeWorkFlow 自由工作流
                workFlowActivityEntity.WorkFlowId = 0;
                // 获取排序码
                workFlowActivityEntity.SortCode = int.Parse(new BaseSequenceManager().GetSequence("FreeWorkFlow", 10000000));
                // 是否提交给用户审批
                if (!string.IsNullOrEmpty(toUserId))
                {
                    workFlowActivityEntity.AuditUserId       = toUserId;
                    workFlowActivityEntity.AuditUserRealName = new BaseUserManager().GetEntity(toUserId).RealName;
                }
                // 是否提交给部门审批
                if (!string.IsNullOrEmpty(toDepartmentId))
                {
                    workFlowActivityEntity.AuditDepartmentId   = toDepartmentId;
                    workFlowActivityEntity.AuditDepartmentName = new BaseOrganizeManager().GetEntity(toDepartmentId).FullName;
                }
                // 是否提交给角色审批
                if (!string.IsNullOrEmpty(toRoleId))
                {
                    workFlowActivityEntity.AuditRoleId       = toRoleId;
                    workFlowActivityEntity.AuditRoleRealName = new BaseRoleManager().GetEntity(toRoleId).RealName;
                }
                // 进行更新操作
                returnValue = this.StepAuditPass(currentId, auditIdea, workFlowActivityEntity);
                if (returnValue == 0)
                {
                    // 数据可能被删除
                    this.ReturnStatusCode = StatusCode.ErrorDeleted.ToString();
                }
                BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetEntity(currentId);
                // 发送提醒信息
                if (workFlowManager != null)
                {
                    if (!string.IsNullOrEmpty(workFlowActivityEntity.AuditUserId))
                    {
                        workFlowActivityEntity.AuditDepartmentId = null;
                        workFlowActivityEntity.AuditRoleId       = null;
                    }
                    workFlowManager.OnAutoAuditPass(workFlowCurrentEntity);
                    workFlowManager.SendRemindMessage(workFlowCurrentEntity, AuditStatus.AuditPass, new string[] { workFlowCurrentEntity.CreateUserId, workFlowActivityEntity.AuditUserId }, workFlowActivityEntity.AuditDepartmentId, workFlowActivityEntity.AuditRoleId);
                }
                this.ReturnStatusMessage = this.GetStateMessage(this.ReturnStatusCode);
                return(returnValue);
            }
        }
Ejemplo n.º 9
0
        private void btnAuditDetail_Click(object sender, EventArgs e)
        {
            DataRow dataRow = BaseInterfaceLogic.GetDataGridViewEntity(this.grdWorkFlowCurrent);

            if (dataRow != null)
            {
                BaseWorkFlowCurrentEntity workFlowCurrentEntity  = new BaseWorkFlowCurrentEntity(dataRow);
                FrmWorkFlowAuditDetail    frmWorkFlowAuditDetail = new FrmWorkFlowAuditDetail(workFlowCurrentEntity.CategoryCode, workFlowCurrentEntity.ObjectId);
                frmWorkFlowAuditDetail.Show();
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 流程完成时
        /// 结束审核时,需要回调写入到表里,调用相应的事件
        /// 若成功可以执行完成的处理
        /// </summary>
        /// <param name="workFlowCurrentEntity">当前审批流程</param>
        /// <returns>成功失败</returns>
        public override bool OnAuditComplete(BaseWorkFlowCurrentEntity workFlowCurrentEntity)
        {
            // 审核通过后,需要把有效状态修改过来
            BaseWorkFlowCurrentManager workFlowCurrentManager = new BaseWorkFlowCurrentManager(this.UserInfo);
            //string objectId = workFlowCurrentManager.GetEntity(workFlowCurrentEntity.Id).ObjectId;
            string objectId = workFlowCurrentEntity.ObjectId;

            if (!string.IsNullOrEmpty(objectId))
            {
                // 这里写自己的方法(审核 过程中的回调),完成审核时
                IDbHelper dbHelper = new SqlHelper(BaseSystemInfo.BusinessDbConnection);
                dbHelper.Open();
                SQLBuilder sqlBuilder = new SQLBuilder(dbHelper);
                switch (workFlowCurrentEntity.CategoryCode)
                {
                case "PuTongCaiGouDan":
                case "GuoNeiCaiGouHeTong":
                case "PutongCaiGouDanDGM":
                case "PutongCaiGouDanManager":
                    sqlBuilder.BeginUpdate("WL物品申购");
                    sqlBuilder.SetValue("AuditStatus", AuditStatus.AuditComplete.ToString());
                    sqlBuilder.SetValue("审核", 1);
                    sqlBuilder.SetDBNow("审核日期");
                    sqlBuilder.SetValue("审核员", BaseSystemInfo.UserInfo.Code);
                    sqlBuilder.SetWhere("申请单号", objectId);
                    sqlBuilder.EndUpdate();
                    break;

                case "YuanFuCaiLiaoShenQingDan":
                    sqlBuilder.BeginUpdate("WL部门物品申购");
                    sqlBuilder.SetValue("AuditStatus", AuditStatus.AuditComplete.ToString());
                    sqlBuilder.SetValue("审核", 1);
                    sqlBuilder.SetValue("总审核", 1);
                    sqlBuilder.SetDBNow("审核日期");
                    sqlBuilder.SetDBNow("总审核日期");
                    sqlBuilder.SetValue("审核员", BaseSystemInfo.UserInfo.Code);
                    sqlBuilder.SetWhere("申购单号", objectId);
                    sqlBuilder.EndUpdate();
                    break;

                case "MoJuCaiGouHeTongP":
                case "MoJuCaiGouHeTongGM":
                    sqlBuilder.BeginUpdate("GCMJ模具申请");
                    sqlBuilder.SetValue("AuditStatus", AuditStatus.AuditComplete.ToString());
                    sqlBuilder.SetValue("审核", 1);
                    sqlBuilder.SetWhere("申请单号", objectId);
                    sqlBuilder.EndUpdate();
                    break;
                }
                dbHelper.Close();
            }
            // 若还需要有其他处理,就这后面继续处理
            return(true);
        }
Ejemplo n.º 11
0
        public string GetBackToUserId(BaseWorkFlowCurrentEntity entity)
        {
            string    userId = string.Empty;
            DataTable dt     = GetBackToDT(entity);

            if (dt.Rows.Count > 0)
            {
                userId = dt.Rows[0][BaseWorkFlowHistoryEntity.FieldAuditUserId].ToString();
            }
            return(userId);
        }
Ejemplo n.º 12
0
        private bool ucWorkFlowUser_BeforBtnAuditDetailClick(string categoryId, string objectId)
        {
            DataRow dataRow = BaseInterfaceLogic.GetDataGridViewEntity(this.grdWorkFlowCurrent);

            if (dataRow != null)
            {
                BaseWorkFlowCurrentEntity workFlowCurrentEntity  = new BaseWorkFlowCurrentEntity(dataRow);
                FrmWorkFlowAuditDetail    frmWorkFlowAuditDetail = new FrmWorkFlowAuditDetail(workFlowCurrentEntity.CategoryCode, workFlowCurrentEntity.ObjectId);
                frmWorkFlowAuditDetail.Show();
            }
            return(false);
        }
Ejemplo n.º 13
0
        private int UpdataAuditStatr(string id, string categoryCode, string categoryFullName, string objectId, string objectFullName, string auditIdea, BaseWorkFlowStepEntity workFlowStepEntity)
        {
            BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetEntity(id);

            workFlowCurrentEntity.CategoryCode     = categoryCode;
            workFlowCurrentEntity.CategoryFullName = categoryFullName;
            workFlowCurrentEntity.ObjectId         = objectId;
            workFlowCurrentEntity.ObjectFullName   = objectFullName;
            workFlowCurrentEntity.WorkFlowId       = workFlowStepEntity.WorkFlowId;
            workFlowCurrentEntity.ActivityId       = workFlowStepEntity.Id;
            workFlowCurrentEntity.SendDate         = DateTime.Now;
            workFlowCurrentEntity.AuditDate        = DateTime.Now;
            workFlowCurrentEntity.AuditStatus      = AuditStatus.StartAudit.ToString();
            workFlowCurrentEntity.AuditStatusName  = AuditStatus.StartAudit.ToDescription();

            // 是否提交给组织机构审批
            if (!string.IsNullOrEmpty(workFlowStepEntity.AuditDepartmentId))
            {
                workFlowCurrentEntity.ToDepartmentId   = workFlowStepEntity.AuditDepartmentId;
                workFlowCurrentEntity.ToDepartmentName = workFlowStepEntity.AuditDepartmentName;
            }
            // 是否提交给角色审批
            if (!string.IsNullOrEmpty(workFlowStepEntity.AuditRoleId))
            {
                workFlowCurrentEntity.ToDepartmentId   = workFlowStepEntity.AuditRoleId;
                workFlowCurrentEntity.ToDepartmentName = workFlowStepEntity.AuditRoleRealName;
            }
            // 是否提交给用户审批
            if (!string.IsNullOrEmpty(workFlowStepEntity.AuditUserId))
            {
                BaseUserManager userManager = new BaseUserManager(UserInfo);
                BaseUserEntity  userEntity  = userManager.GetEntity(workFlowStepEntity.AuditUserId);
                workFlowCurrentEntity.ToUserId       = workFlowStepEntity.AuditUserId;
                workFlowCurrentEntity.ToUserRealName = userEntity.RealName;
                // TODO 用户的部门信息需要处理
                if (!string.IsNullOrEmpty(userEntity.DepartmentId))
                {
                    BaseOrganizeManager organizeManager = new BaseOrganizeManager(UserInfo);
                    BaseOrganizeEntity  organizeEntity  = organizeManager.GetEntity(userEntity.DepartmentId);
                    workFlowCurrentEntity.ToDepartmentId   = userEntity.DepartmentId;
                    workFlowCurrentEntity.ToDepartmentName = organizeEntity.FullName;
                }
            }
            // 当前审核人的信息写入当前工作流
            // workFlowCurrentEntity.AuditUserId = this.UserInfo.Id;
            // workFlowCurrentEntity.AuditUserCode = this.UserInfo.Code;
            // workFlowCurrentEntity.AuditUserRealName = this.UserInfo.RealName;
            workFlowCurrentEntity.AuditIdea = auditIdea;
            workFlowCurrentEntity.AuditDate = DateTime.Now;
            return(this.UpdateEntity(workFlowCurrentEntity));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 审核退回详细步骤
        /// </summary>
        /// <param name="currentId">当前主键</param>
        /// <param name="auditIdea">批示</param>
        /// <param name="toUserId">发送给</param>
        /// <param name="activityId">退回到指定步骤</param>
        /// <returns>影响行数</returns>
        private BaseWorkFlowCurrentEntity StepAuditReject(string currentId, string auditIdea, string toUserId = null, string activityId = null)
        {
            BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetEntity(currentId);

            // 1.记录审核时间、审核人
            workFlowCurrentEntity.AuditUserId       = this.UserInfo.Id;
            workFlowCurrentEntity.AuditUserCode     = this.UserInfo.Code;
            workFlowCurrentEntity.AuditUserRealName = this.UserInfo.RealName;
            workFlowCurrentEntity.AuditStatus       = AuditStatus.AuditReject.ToString();
            workFlowCurrentEntity.AuditStatusName   = AuditStatus.AuditReject.ToDescription();
            workFlowCurrentEntity.AuditDate         = DateTime.Now;
            workFlowCurrentEntity.AuditIdea         = auditIdea;
            // 2.记录日志
            this.AddHistory(workFlowCurrentEntity);

            // 3.更新待审核情况,流程已经结束了
            workFlowCurrentEntity.ActivityId = null;
            if (!string.IsNullOrEmpty(activityId))
            {
                workFlowCurrentEntity.ActivityId = int.Parse(activityId);
                BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(this.DbHelper, this.UserInfo);
                BaseWorkFlowActivityEntity  workFlowActivityEntity  = workFlowActivityManager.GetEntity(activityId);
                workFlowCurrentEntity.SortCode         = workFlowActivityEntity.SortCode;
                workFlowCurrentEntity.ToUserId         = workFlowActivityEntity.AuditUserId;
                workFlowCurrentEntity.ToUserRealName   = workFlowActivityEntity.AuditUserRealName;
                workFlowCurrentEntity.ToDepartmentId   = workFlowActivityEntity.AuditDepartmentId;
                workFlowCurrentEntity.ToDepartmentName = workFlowActivityEntity.AuditDepartmentName;
                workFlowCurrentEntity.ToRoleId         = workFlowActivityEntity.AuditRoleId;
                workFlowCurrentEntity.ToRoleRealName   = workFlowActivityEntity.AuditRoleRealName;
            }
            else
            {
                if (!string.IsNullOrEmpty(toUserId))
                {
                    BaseUserManager userManager = new BaseUserManager(UserInfo);
                    BaseUserEntity  userEntity  = userManager.GetEntity(toUserId);
                    workFlowCurrentEntity.ToUserId         = userEntity.Id;
                    workFlowCurrentEntity.ToUserRealName   = userEntity.RealName;
                    workFlowCurrentEntity.ToDepartmentId   = userEntity.DepartmentId;
                    workFlowCurrentEntity.ToDepartmentName = userEntity.DepartmentName;
                }
                //workFlowCurrentEntity.SortCode = null;
            }
            workFlowCurrentEntity.SendDate = DateTime.Now;
            workFlowCurrentEntity.Enabled  = 0;
            // 4.生成审核结束的记录
            this.UpdateEntity(workFlowCurrentEntity);
            return(workFlowCurrentEntity);
        }
Ejemplo n.º 15
0
 /// <summary>
 /// (点通过时)当审核通过时
 /// </summary>
 /// <param name="workFlowCurrentEntity">当前审批流</param>
 /// <returns>成功失败</returns>
 public virtual bool OnAutoAuditPass(BaseWorkFlowCurrentEntity workFlowCurrentEntity)
 {
     if (!string.IsNullOrEmpty(workFlowCurrentEntity.ObjectId))
     {
         SQLBuilder sqlBuilder = new SQLBuilder(dbHelper);
         sqlBuilder.BeginUpdate(this.CurrentTableName);
         sqlBuilder.SetValue(BaseBusinessLogic.FieldAuditStatus, AuditStatus.AuditPass.ToString());
         sqlBuilder.SetDBNow(BaseBusinessLogic.FieldModifiedOn);
         sqlBuilder.SetValue(BaseBusinessLogic.FieldModifiedUserId, this.UserInfo.Id);
         sqlBuilder.SetValue(BaseBusinessLogic.FieldModifiedBy, this.UserInfo.RealName);
         sqlBuilder.SetWhere(BaseBusinessLogic.FieldId, workFlowCurrentEntity.ObjectId);
         sqlBuilder.EndUpdate();
     }
     return(true);
 }
Ejemplo n.º 16
0
        /// <summary>
        /// 审核明细
        /// </summary>
        /// <returns></returns>
        private bool AuditDetail()
        {
            // 返回值
            bool returnValue = false;
            // 根据工作流id获取单据类型主键和单据主键
            BaseWorkFlowCurrentManager workFlowCurrentManager = new BaseWorkFlowCurrentManager(this.UserInfo);
            BaseWorkFlowCurrentEntity  workFlowCurrentEntity  = workFlowCurrentManager.GetEntity(this.WorkFlowIds[0]);
            // 查看历史信息
            FrmWorkFlowAuditDetail frmWorkFlowAuditDetail = new FrmWorkFlowAuditDetail(workFlowCurrentEntity.CategoryCode, workFlowCurrentEntity.ObjectId);

            frmWorkFlowAuditDetail.ShowDialog(this);
            returnValue = true;
            // 返回
            return(returnValue);
        }
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="baseWorkFlowCurrentEntity">实体</param>
        public int UpdateEntity(BaseWorkFlowCurrentEntity baseWorkFlowCurrentEntity)
        {
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);

            sqlBuilder.BeginUpdate(this.CurrentTableName);
            this.SetEntity(sqlBuilder, baseWorkFlowCurrentEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseWorkFlowCurrentEntity.FieldModifiedOn);
            sqlBuilder.SetWhere(BaseWorkFlowCurrentEntity.FieldId, baseWorkFlowCurrentEntity.Id);
            return(sqlBuilder.EndUpdate());
        }
Ejemplo n.º 18
0
 /// <summary>
 /// 重置单据
 /// (单据发生错误时)紧急情况下实用
 /// </summary>
 /// <param name="currentId">审批流当前主键</param>
 /// <param name="categoryCode">单据分类</param>
 /// <param name="auditIdea">批示</param>
 /// <returns>影响行数</returns>
 public virtual bool OnReset(BaseWorkFlowCurrentEntity workFlowCurrentEntity)
 {
     // 审核通过后,需要把有效状态修改过来
     if (!string.IsNullOrEmpty(workFlowCurrentEntity.ObjectId))
     {
         SQLBuilder sqlBuilder = new SQLBuilder(dbHelper);
         sqlBuilder.BeginUpdate(this.CurrentTableName);
         sqlBuilder.SetValue(BaseBusinessLogic.FieldAuditStatus, AuditStatus.Draft.ToString());
         sqlBuilder.SetValue(BaseBusinessLogic.FieldEnabled, 1);
         sqlBuilder.SetDBNow(BaseBusinessLogic.FieldModifiedOn);
         sqlBuilder.SetValue(BaseBusinessLogic.FieldModifiedUserId, this.UserInfo.Id);
         sqlBuilder.SetValue(BaseBusinessLogic.FieldModifiedBy, this.UserInfo.RealName);
         sqlBuilder.SetWhere(BaseBusinessLogic.FieldId, workFlowCurrentEntity.ObjectId);
         sqlBuilder.EndUpdate();
     }
     // 若还需要有其他处理,就这后面继续处理
     return(true);
 }
Ejemplo n.º 19
0
        /// <summary>
        /// 下个流程发送给谁
        /// </summary>
        /// <param name="workFlowId">当前主键</param>
        /// <returns>影响行数</returns>
        public int AuditTransmit(string currentId, string workFlowCategory, string sendToUserId, string auditIdea)
        {
            int returnValue = 0;

            // 进行更新操作
            returnValue = this.StepAuditTransmit(currentId, workFlowCategory, sendToUserId, auditIdea);
            if (returnValue == 0)
            {
                // 数据可能被删除
                this.ReturnStatusCode = StatusCode.ErrorDeleted.ToString();
            }
            BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetEntity(currentId);

            // 发送提醒信息
            // this.SendRemindMessage(workFlowCurrentEntity.ObjectId, AuditStatus.Transmit, auditIdea, sendToUserId, null);
            this.ReturnStatusMessage = this.GetStateMessage(this.ReturnStatusCode);
            return(returnValue);
        }
Ejemplo n.º 20
0
        private string AddHistory(BaseWorkFlowCurrentEntity workFlowCurrentEntity)
        {
            BaseWorkFlowHistoryEntity workFlowHistoryEntity = new BaseWorkFlowHistoryEntity();

            // 这些是待审核信息
            workFlowHistoryEntity.CurrentFlowId    = workFlowCurrentEntity.Id;
            workFlowHistoryEntity.WorkFlowId       = workFlowCurrentEntity.WorkFlowId;
            workFlowHistoryEntity.ActivityId       = workFlowCurrentEntity.ActivityId;
            workFlowHistoryEntity.ActivityFullName = workFlowCurrentEntity.ActivityFullName;

            workFlowHistoryEntity.ToUserId       = workFlowCurrentEntity.ToUserId;
            workFlowHistoryEntity.ToUserRealName = workFlowCurrentEntity.ToUserRealName;
            workFlowHistoryEntity.ToRoleId       = workFlowCurrentEntity.ToRoleId;
            workFlowHistoryEntity.ToRoleRealName = workFlowCurrentEntity.ToRoleRealName;
            if (string.IsNullOrEmpty(workFlowCurrentEntity.ToDepartmentId))
            {
                workFlowHistoryEntity.ToDepartmentId   = this.UserInfo.DepartmentId;
                workFlowHistoryEntity.ToDepartmentName = this.UserInfo.DepartmentName;
            }
            else
            {
                workFlowHistoryEntity.ToDepartmentId   = workFlowCurrentEntity.ToDepartmentId;
                workFlowHistoryEntity.ToDepartmentName = workFlowCurrentEntity.ToDepartmentName;
            }

            workFlowHistoryEntity.AuditUserId       = workFlowCurrentEntity.AuditUserId;
            workFlowHistoryEntity.AuditUserRealName = workFlowCurrentEntity.AuditUserRealName;

            workFlowHistoryEntity.AuditIdea       = workFlowCurrentEntity.AuditIdea;
            workFlowHistoryEntity.AuditStatus     = workFlowCurrentEntity.AuditStatus;
            workFlowHistoryEntity.AuditStatusName = workFlowCurrentEntity.AuditStatusName;

            workFlowHistoryEntity.SendDate          = workFlowCurrentEntity.AuditDate;
            workFlowHistoryEntity.AuditDate         = DateTime.Now;
            workFlowHistoryEntity.Description       = workFlowCurrentEntity.Description;
            workFlowHistoryEntity.SortCode          = workFlowCurrentEntity.SortCode;
            workFlowHistoryEntity.DeletionStateCode = workFlowCurrentEntity.DeletionStateCode;
            workFlowHistoryEntity.Enabled           = workFlowCurrentEntity.Enabled;

            BaseWorkFlowHistoryManager workFlowHistoryManager = new BaseWorkFlowHistoryManager(DbHelper, UserInfo);

            return(workFlowHistoryManager.AddEntity(workFlowHistoryEntity));
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 发送即时通讯提醒
        /// </summary>
        /// <param name="workFlowCurrentEntity">当前审核流实体信息</param>
        /// <param name="auditStatus">审核状态</param>
        /// <param name="auditIdea">审核意见</param>
        /// <param name="userIds">发送给用户主键</param>
        /// <param name="roleIds">发送给角色主键</param>
        /// <returns>影响行数</returns>
        public virtual int SendRemindMessage(BaseWorkFlowCurrentEntity workFlowCurrentEntity, AuditStatus auditStatus, string[] userIds, string organizeId, string roleId)
        {
            // string currentId, string objectId, string objectFullName
            int returnValue = 0;

            // 不用给自己发消息了,消息多了也烦恼
            userIds = StringUtil.Remove(userIds, this.UserInfo.Id);
            // BaseUserEntity userEntity = userManager.GetEntity(userId);
            // 发送请求审核的信息
            BaseMessageEntity messageEntity = new BaseMessageEntity();

            messageEntity.Id = BaseBusinessLogic.NewGuid();
            // 这里是回调的类,用反射要回调的
            messageEntity.FunctionCode = MessageFunction.Remind.ToString();
            // messageEntity.FunctionCode = this.GetType().ToString();
            messageEntity.ObjectId = workFlowCurrentEntity.ObjectId;
            // 这里是网页上的显示地址
            // messageEntity.Title = this.GetUrl(id);
            string auditIdea = string.Empty;

            if (!string.IsNullOrEmpty(workFlowCurrentEntity.AuditIdea))
            {
                auditIdea = " 批示: " + workFlowCurrentEntity.AuditIdea;
            }
            // messageEntity.Contents = userEntity.DepartmentName + " " + userEntity.RealName
            messageEntity.Contents
                = workFlowCurrentEntity.CreateBy + " 发出审批申请: " + "<a title='点击这里,直接查看单据' target='_blank' href='" + this.GetUrl(workFlowCurrentEntity.Id) + "'>" + workFlowCurrentEntity.ObjectFullName + "</a> "
                  + Environment.NewLine
                  + this.UserInfo.RealName + " " + BaseBusinessLogic.GetAuditStatus(auditStatus) + " "
                  + Environment.NewLine
                  + auditIdea;

            messageEntity.Contents          = "有单据" + BaseBusinessLogic.GetAuditStatus(auditStatus);
            messageEntity.IsNew             = 1;
            messageEntity.ReadCount         = 0;
            messageEntity.Enabled           = 1;
            messageEntity.DeletionStateCode = 0;
            BaseMessageManager messageManager = new BaseMessageManager(this.UserInfo);

            returnValue = messageManager.BatchSend(userIds, organizeId, roleId, messageEntity, false);
            return(returnValue);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// (点通过时)当审核通过时
        /// </summary>
        /// <param name="workFlowCurrentEntity">当前审批流</param>
        /// <returns>成功失败</returns>
        public override bool OnAutoAuditPass(BaseWorkFlowCurrentEntity workFlowCurrentEntity)
        {
            string objectId = workFlowCurrentEntity.ObjectId;

            if (!string.IsNullOrEmpty(objectId))
            {
                // 这里写自己的方法(审核 过程中的回调),通过审核时
                IDbHelper dbHelper = new SqlHelper(BaseSystemInfo.BusinessDbConnection);
                dbHelper.Open();
                SQLBuilder sqlBuilder = new SQLBuilder(dbHelper);
                sqlBuilder.BeginUpdate("WL物品申购");
                sqlBuilder.SetDBNow("审核日期");
                sqlBuilder.SetValue("审核员", BaseSystemInfo.UserInfo.Code);
                sqlBuilder.SetValue("AuditStatus", AuditStatus.AuditPass.ToString());
                sqlBuilder.SetWhere("申请单号", objectId);
                sqlBuilder.EndUpdate();
                dbHelper.Close();
            }
            return(true);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 撤消审批流程中的单据
        /// </summary>
        /// <param name="id">当前主键</param>
        /// <returns>影响行数</returns>
        private BaseWorkFlowCurrentEntity StepAuditQuash(string currentId, string auditIdea)
        {
            BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetEntity(currentId);

            // 1.记录审核时间、审核人
            workFlowCurrentEntity.ToUserId          = this.UserInfo.Id;
            workFlowCurrentEntity.ToUserRealName    = this.UserInfo.RealName;
            workFlowCurrentEntity.AuditDate         = DateTime.Now;
            workFlowCurrentEntity.AuditIdea         = auditIdea;
            workFlowCurrentEntity.AuditStatus       = AuditStatus.AuditQuash.ToString();
            workFlowCurrentEntity.AuditStatusName   = AuditStatus.AuditQuash.ToDescription();
            workFlowCurrentEntity.ActivityId        = null;
            workFlowCurrentEntity.Enabled           = 1;
            workFlowCurrentEntity.DeletionStateCode = 0;
            // 4.生成审核结束的记录
            this.AddHistory(workFlowCurrentEntity);
            // 废弃的,就变成删除状态了
            this.UpdateEntity(workFlowCurrentEntity);
            // 5.把历史都设置为删除标志
            return(workFlowCurrentEntity);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 重置单据
        /// (发出单据时)当废弃审批流时需要做的事情
        /// </summary>
        /// <param name="id">主键</param>
        /// <param name="auditIdea">批示</param>
        /// <returns>影响行数</returns>
        public virtual int Reset(string id, string auditIdea)
        {
            int returnValeu = 0;
            // 只有还在审核中的才可以废弃
            string auditStatus = this.GetProperty(id, BaseBusinessLogic.FieldAuditStatus);

            if (!string.IsNullOrEmpty(auditStatus))
            {
                if (!(auditStatus.Equals(AuditStatus.StartAudit.ToString()) ||
                      auditStatus.Equals(AuditStatus.WaitForAudit.ToString())))
                {
                    return(returnValeu);
                }
            }

            // 若能撤销流程中的单据,才可以撤销本地的单据
            BaseWorkFlowCurrentManager workFlowCurrentManager = new BaseWorkFlowCurrentManager(this.UserInfo);
            BaseWorkFlowCurrentEntity  workFlowCurrentEntity  = workFlowCurrentManager.GetEntity(id);

            // 工作流里会进行撤销的工作
            return(workFlowCurrentManager.Reset(workFlowCurrentEntity));
        }
        /// <summary>
        /// 最终审核通过(完成)
        /// </summary>
        /// <param name="workFlowManager">当前审批流程接口</param>
        /// <param name="currentId">当前主键</param>
        /// <param name="auditIdea">批示</param>
        /// <returns>影响行数</returns>
        public int AuditComplete(IWorkFlowManager workFlowManager, string currentId, string auditIdea)
        {
            int returnValue = 0;
            // 1:进行更新操作
            BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.StepAuditComplete(currentId, auditIdea);

            if (workFlowCurrentEntity.Id != null)
            {
                // 2:对当前审批流程接口进行处理
                if (workFlowManager != null)
                {
                    // 3:进行审批处理完毕动作
                    workFlowManager.OnAuditComplete(workFlowCurrentEntity);
                    string[] userIds = null;

                    /*
                     * // 4:这里给所有相关的人发一个消息,告诉他们审批完成了
                     * BaseWorkFlowStepManager workFlowStepManager = new BaseWorkFlowStepManager(this.DbHelper, this.UserInfo);
                     * userIds = workFlowStepManager.GetProperties(new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldCategoryCode, workFlowCurrentEntity.CategoryCode)
                     *  , new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldObjectId, workFlowCurrentEntity.ObjectId)
                     *  , BaseWorkFlowStepEntity.FieldAuditUserId);
                     */
                    // 把创建人加上,发出者也需要获得提醒信息
                    userIds = StringUtil.Concat(userIds, workFlowCurrentEntity.CreateUserId);
                    // 当前操作者没必要参与进来,可以少发一个没必要的提示信息,减少没必要的提醒信息
                    userIds = StringUtil.Remove(userIds, this.UserInfo.Id);
                    workFlowManager.SendRemindMessage(workFlowCurrentEntity, AuditStatus.AuditComplete, userIds, null, null);
                    returnValue = 1;
                }
            }
            else
            {
                // 数据可能被删除
                this.ReturnStatusCode = StatusCode.ErrorDeleted.ToString();
            }
            // 应该给创建者一个提醒消息
            this.ReturnStatusMessage = this.GetStateMessage(this.ReturnStatusCode);
            return(returnValue);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 获取退回人员列表
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public DataTable GetBackToDT(BaseWorkFlowCurrentEntity entity)
        {
            string workFlowId = entity.WorkFlowId.ToString();
            string sortCode   = entity.SortCode.ToString();
            string sqlQuery   = @"  SELECT MAX(Id) AS Id, ActivityId, AuditUserId, AuditUserRealName
									FROM BaseWorkFlowHistory
									WHERE ( AuditStatus != 'AuditReject'
											AND CurrentFlowId = '"                                             + entity.Id + @"'
											AND WorkFlowId = "                                             + workFlowId + @"
											-- AND AuditUserId = ToUserId
											AND ActivityId IN
												(
												   SELECT Id
													 FROM BaseWorkFlowActivity
													WHERE (DeletionStateCode = 0) 
														  AND (Enabled = 1) 
														  AND (WorkFlowId = "                                                         + workFlowId + @") 
														  AND (SortCode < "                                                         + sortCode + @")                         
												)
										  )
								 GROUP BY ActivityId, AuditUserId, AuditUserRealName
								 ORDER BY MAX(SortCode) "                                ;
            // 发出人是否在单据里?
            DataTable dt = DbHelper.Fill(sqlQuery);

            dt.TableName = "BaseWorkFlowHistory";
            if (!BaseBusinessLogic.Exists(dt, "AuditUserId", entity.CreateUserId))
            {
                DataRow dataRow = dt.NewRow();
                dataRow["Id"]                = DBNull.Value;
                dataRow["ActivityId"]        = DBNull.Value;
                dataRow["AuditUserId"]       = entity.CreateUserId;
                dataRow["AuditUserRealName"] = entity.CreateBy;
                dt.Rows.InsertAt(dataRow, 0);
                dt.AcceptChanges();
            }
            return(dt);
        }
Ejemplo n.º 27
0
        private string StepAuditStatr(string categoryCode, string categoryFullName, string objectId, string objectFullName, string auditIdea, BaseWorkFlowStepEntity workFlowStepEntity)
        {
            BaseWorkFlowCurrentEntity workFlowCurrentEntity = new BaseWorkFlowCurrentEntity();

            // 1.这个是工作流的第一个发出日期,需要全局保留,其实也是创建日期了,但是有重新审核的这个说法,若有2次重新审核的事项,的确需要保留这个字段
            // workFlowCurrentEntity.CallBack = workFlowManager.GetType().ToString();
            workFlowCurrentEntity.WorkFlowId = workFlowStepEntity.WorkFlowId;
            workFlowCurrentEntity.ActivityId = workFlowStepEntity.Id;
            // 这里是为了优化越级审核用的,按排序嘛进行先后顺序排序
            BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(this.DbHelper, this.UserInfo);

            workFlowCurrentEntity.CategoryCode     = categoryCode;
            workFlowCurrentEntity.CategoryFullName = categoryFullName;
            workFlowCurrentEntity.ObjectId         = objectId;
            workFlowCurrentEntity.ObjectFullName   = objectFullName;
            // 2.当前审核人的信息写入当前工作流
            // workFlowCurrentEntity.AuditUserId = this.UserInfo.Id;
            // workFlowCurrentEntity.AuditUserCode = this.UserInfo.Code;
            // workFlowCurrentEntity.AuditUserRealName = this.UserInfo.RealName;
            workFlowCurrentEntity.AuditIdea       = auditIdea;
            workFlowCurrentEntity.AuditStatus     = AuditStatus.StartAudit.ToString();
            workFlowCurrentEntity.AuditStatusName = AuditStatus.StartAudit.ToDescription();
            workFlowCurrentEntity.SendDate        = DateTime.Now;
            // 3.接下来需要待审核的对象的信息
            workFlowCurrentEntity.ToUserId         = workFlowStepEntity.AuditUserId;
            workFlowCurrentEntity.ToUserRealName   = workFlowStepEntity.AuditUserRealName;
            workFlowCurrentEntity.ToDepartmentId   = workFlowStepEntity.AuditDepartmentId;
            workFlowCurrentEntity.ToDepartmentName = workFlowStepEntity.AuditDepartmentName;
            workFlowCurrentEntity.ToRoleId         = workFlowStepEntity.AuditRoleId;
            workFlowCurrentEntity.ToRoleRealName   = workFlowStepEntity.AuditRoleRealName;
            // 4.这些标志信息需要处理好,这里表示工作流还没完成生效,还在审批中的意思。
            workFlowCurrentEntity.SortCode          = workFlowStepEntity.SortCode;
            workFlowCurrentEntity.Enabled           = 0;
            workFlowCurrentEntity.DeletionStateCode = 0;
            return(this.AddEntity(workFlowCurrentEntity));
        }
Ejemplo n.º 28
0
        /// <summary>
        /// 审核通过(不需要再发给别人了)
        /// </summary>
        /// <param name="currentId">当前主键</param>
        /// <param name="auditIdea">批示</param>
        /// <returns>影响行数</returns>
        private int StepAuditReject(string currentId, string auditIdea, BaseWorkFlowActivityEntity workFlowActivityEntity)
        {
            BaseWorkFlowCurrentEntity workFlowCurrentEntity = this.GetEntity(currentId);

            // 1.记录当前的审核时间、审核人信息
            workFlowCurrentEntity.AuditDate         = DateTime.Now;
            workFlowCurrentEntity.AuditIdea         = auditIdea;
            workFlowCurrentEntity.AuditUserId       = this.UserInfo.Id;
            workFlowCurrentEntity.AuditUserRealName = this.UserInfo.RealName;
            workFlowCurrentEntity.AuditStatus       = AuditStatus.AuditReject.ToString();
            workFlowCurrentEntity.AuditStatusName   = AuditStatus.AuditReject.ToDescription();
            // 2.记录审核日志
            this.AddHistory(workFlowCurrentEntity);
            // 3.上一个审核结束了,新的审核又开始了,更新待审核情况
            workFlowCurrentEntity.ActivityId       = workFlowActivityEntity.Id;
            workFlowCurrentEntity.ToRoleId         = workFlowActivityEntity.AuditRoleId;
            workFlowCurrentEntity.ToRoleRealName   = workFlowActivityEntity.AuditRoleRealName;
            workFlowCurrentEntity.ToDepartmentId   = workFlowActivityEntity.AuditDepartmentId;
            workFlowCurrentEntity.ToDepartmentName = workFlowActivityEntity.AuditDepartmentName;
            workFlowCurrentEntity.ToUserId         = workFlowActivityEntity.AuditUserId;
            workFlowCurrentEntity.ToUserRealName   = workFlowActivityEntity.AuditUserRealName;
            workFlowCurrentEntity.SortCode         = workFlowActivityEntity.SortCode;
            return(this.UpdateEntity(workFlowCurrentEntity));
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 检查是否是步骤流
        /// </summary>
        /// <param name="userInfo">用户信息</param>
        /// <param name="currentFlowIds">主键组</param>
        /// <param name="returnStatusCode">返回代码</param>
        /// <param name="returnStatusMessage">返回信息</param>
        /// <returns></returns>
        public bool CheckIsAutoWorkFlow(BaseUserInfo userInfo, string[] currentFlowIds, out string returnStatusCode, out string returnStatusMessage)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
            LogOnService.UserIsLogOn(userInfo);
            #endif

            returnStatusCode    = string.Empty;
            returnStatusMessage = string.Empty;
            bool returnValue = false;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.WorkFlowDbType))
            {
                try
                {
                    // 打开数据库
                    dbHelper.Open(WorkFlowDbConnection);

                    BaseWorkFlowCurrentManager workFlowCurrentManager = new BaseWorkFlowCurrentManager(dbHelper, userInfo);
                    string processId = string.Empty;
                    for (int i = 0; i < currentFlowIds.Length; i++)
                    {
                        BaseWorkFlowCurrentEntity workFlowCurrentEntity = workFlowCurrentManager.GetEntity(currentFlowIds[i]);
                        if ((workFlowCurrentEntity != null) && (!string.IsNullOrEmpty(workFlowCurrentEntity.Id)))
                        {
                            if (workFlowCurrentEntity.AuditStatus.Equals(AuditStatus.StartAudit.ToString()) ||
                                workFlowCurrentEntity.AuditStatus.Equals(AuditStatus.AuditPass.ToString()) ||
                                workFlowCurrentEntity.AuditStatus.Equals(AuditStatus.WaitForAudit.ToString()) ||
                                workFlowCurrentEntity.AuditStatus.Equals(AuditStatus.AuditReject.ToString()))
                            {
                                // 不为空的话是步骤流
                                if (workFlowCurrentEntity.WorkFlowId != null)
                                {
                                    returnValue = true;
                                }
                                else
                                {
                                    // 判断是否是批量审核,只有自由流才限制批量审批
                                    if (i > 0)
                                    {
                                        returnStatusMessage = "你选中的记录里包含自由审批流程所以不能批量审批。";
                                    }
                                    return(false);
                                }
                            }
                            else
                            {
                                returnStatusMessage = "你选中的记录里包含状态不明确的记录。";
                                return(false);
                            }
                        }
                        else
                        {
                            returnStatusMessage = "你选中的记录里可能已被删除。";
                            return(false);
                        }
                    }

                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            // 写入调试信息
            #if (DEBUG)
            BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif

            return(returnValue);
        }
Ejemplo n.º 30
0
        //-----------------------------------------------------
        //                  启动工作流 步骤流
        //-----------------------------------------------------

        /// <summary>
        /// 启动工作流(步骤流转)
        /// </summary>
        /// <param name="workFlowManager">审批流程管理器</param>
        /// <param name="objectId">单据主键</param>
        /// <param name="objectFullName">单据名称</param>
        /// <param name="categoryCode">单据分类</param>
        /// <param name="categoryFullName">单据分类名称</param>
        /// <param name="workFlowCode">工作流程</param>
        /// <param name="auditIdea">审批意见</param>
        /// <param name="dtWorkFlowActivity">需要走的流程</param>
        /// <returns>主键</returns>
        public string AutoStatr(IWorkFlowManager workFlowManager, string objectId, string objectFullName, string categoryCode, string categoryFullName = null, string workFlowCode = null, string auditIdea = null, DataTable dtWorkFlowActivity = null)
        {
            string currentId = string.Empty;

            if (dtWorkFlowActivity == null || dtWorkFlowActivity.Rows.Count == 0)
            {
                return(currentId);
            }
            lock (WorkFlowCurrentLock)
            {
                BaseWorkFlowStepEntity workFlowStepEntity = null;
                // 这里需要读取一下
                if (dtWorkFlowActivity == null)
                {
                }
                workFlowStepEntity = new BaseWorkFlowStepEntity(dtWorkFlowActivity.Rows[0]);
                if (!string.IsNullOrEmpty(workFlowStepEntity.AuditUserId))
                {
                    // 若是任意人可以审核的,需要进行一次人工选任的工作
                    if (workFlowStepEntity.AuditUserId.Equals("Anyone"))
                    {
                        return(null);
                    }
                }
                // 1. 先把已有的流程设置功能都删除掉
                BaseWorkFlowStepManager workFlowStepManager = new BaseWorkFlowStepManager(this.DbHelper, this.UserInfo);
                workFlowStepManager.Delete(
                    new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldCategoryCode, categoryCode)
                    , new KeyValuePair <string, object>(BaseWorkFlowStepEntity.FieldObjectId, objectId));
                // 2. 把当前的流程设置保存好
                foreach (DataRow dataRow in dtWorkFlowActivity.Rows)
                {
                    workFlowStepEntity              = new BaseWorkFlowStepEntity(dataRow);
                    workFlowStepEntity.ActivityId   = workFlowStepEntity.Id;
                    workFlowStepEntity.CategoryCode = categoryCode;
                    workFlowStepEntity.ObjectId     = objectId;
                    workFlowStepEntity.Id           = null;
                    workFlowStepManager.Add(workFlowStepEntity);
                }
                workFlowStepEntity = new BaseWorkFlowStepEntity(dtWorkFlowActivity.Rows[0]);

                // 3. 启动审核流程
                currentId = this.GetCurrentId(categoryCode, objectId);
                BaseWorkFlowCurrentEntity workFlowCurrentEntity = null;
                if (currentId.Length > 0)
                {
                    // 获取当前处于什么状态
                    string auditstatus = this.GetProperty(currentId, BaseWorkFlowCurrentEntity.FieldAuditStatus);
                    // 如果还是开始审批状态的话,允许他再次提交把原来的覆盖掉
                    if (auditstatus == AuditStatus.StartAudit.ToString())
                    {
                        this.UpdataAuditStatr(currentId, categoryCode, categoryFullName, objectId, objectFullName, auditIdea, workFlowStepEntity);
                    }
                    // 不是的话则返回
                    else
                    {
                        // 该单据已进入审核状态不能在次提交
                        this.ReturnStatusCode = StatusCode.ErrorChanged.ToString();
                        // 返回为空可以判断
                        currentId = null;
                    }
                }
                else
                {
                    workFlowManager.BeforeAutoStatr(objectId);
                    currentId             = this.StepAuditStatr(categoryCode, categoryFullName, objectId, objectFullName, auditIdea, workFlowStepEntity);
                    workFlowCurrentEntity = this.GetEntity(currentId);
                    // 发送提醒信息,若发给指定的某个人了,就不发给部门的提示信息了
                    if (workFlowManager != null)
                    {
                        if (!string.IsNullOrEmpty(workFlowStepEntity.AuditUserId))
                        {
                            workFlowStepEntity.AuditDepartmentId = null;
                            workFlowStepEntity.AuditRoleId       = null;
                        }
                        workFlowManager.SendRemindMessage(workFlowCurrentEntity, AuditStatus.StartAudit, new string[] { workFlowCurrentEntity.CreateUserId, workFlowStepEntity.AuditUserId }, workFlowStepEntity.AuditDepartmentId, workFlowStepEntity.AuditRoleId);
                    }
                    // 成功工作流后的处理
                    if (!string.IsNullOrEmpty(objectId))
                    {
                        workFlowManager.AfterAutoStatr(objectId);
                    }
                    // 运行成功
                    this.ReturnStatusCode    = StatusCode.OK.ToString();
                    this.ReturnStatusMessage = this.GetStateMessage(this.ReturnStatusCode);
                }
            }
            return(currentId);
        }