/// <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;
 }
        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);
        }
        public BaseWorkFlowActivityEntity GetNextWorkFlowActivity(BaseWorkFlowCurrentEntity workFlowCurrentEntity)
        {
            BaseWorkFlowActivityEntity workFlowActivityEntity = null;
            DataTable dataTable = null;

            // 工作流主键
            string workFlowId = workFlowCurrentEntity.WorkFlowId.ToString();

            // 1. 从工作流审核步骤里选取审核步骤
            BaseWorkFlowStepManager workFlowStepManager = new BaseWorkFlowStepManager(this.DbHelper, this.UserInfo);

            List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>();
            parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldCategoryCode, workFlowCurrentEntity.CategoryCode));
            parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldObjectId, workFlowCurrentEntity.ObjectId));
            parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldWorkFlowId, workFlowId));
            parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldEnabled, 1));
            parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowStepEntity.FieldDeletionStateCode, 0));

            dataTable = workFlowStepManager.GetDataTable(parameters, BaseWorkFlowStepEntity.FieldSortCode);

            if (dataTable.Rows.Count > 0)
            {
                dataTable.Columns.Remove(BaseWorkFlowStepEntity.FieldId);
                dataTable.Columns[BaseWorkFlowStepEntity.FieldActivityId].ColumnName = BaseWorkFlowStepEntity.FieldId;
            }
            else
            {
                // 2. 从工作流审核模板里选取审核步骤 下一步是多少?按工作流进行查找审核步骤
                BaseWorkFlowActivityManager workFlowActivityManager = new BaseWorkFlowActivityManager(this.DbHelper, this.UserInfo);

                parameters = new List<KeyValuePair<string, object>>();
                parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowActivityEntity.FieldWorkFlowId, workFlowId));
                parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowActivityEntity.FieldEnabled, 1));
                parameters.Add(new KeyValuePair<string, object>(BaseWorkFlowActivityEntity.FieldDeletionStateCode, 0));

                dataTable = workFlowActivityManager.GetDataTable(parameters, BaseWorkFlowActivityEntity.FieldSortCode);
            }

            // 审核步骤主键
            string activityId = string.Empty;
            if (workFlowCurrentEntity.ActivityId != null)
            {
                activityId = workFlowCurrentEntity.ActivityId.ToString();
            }
            if (dataTable.Rows.Count == 0)
            {
                return workFlowActivityEntity;
            }
            string nextActivityId = string.Empty;
            if (!string.IsNullOrEmpty(activityId))
            {
                nextActivityId = BaseSortLogic.GetNextId(dataTable, activityId.ToString());
            }
            else
            {
                nextActivityId = dataTable.Rows[0][BaseWorkFlowActivityEntity.FieldId].ToString();
            }
            if (!string.IsNullOrEmpty(nextActivityId))
            {
                // workFlowActivityEntity = workFlowActivityManager.GetEntity(nextActivityId);
                DataRow dataRow = BaseBusinessLogic.GetDataRow(dataTable, nextActivityId);
                workFlowActivityEntity = new BaseWorkFlowActivityEntity(dataRow);
            }
            return workFlowActivityEntity;
        }
        // 这个是声明扩展方法
partial         void SetEntityExpand(SQLBuilder sqlBuilder, BaseWorkFlowCurrentEntity baseWorkFlowCurrentEntity);
 /// <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);
 }
 /// <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();
 }
 /// <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;
 }
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="baseWorkFlowCurrentEntity">实体</param>
 /// <param name="identity">自增量方式</param>
 /// <param name="returnId">返回主键</param>
 /// <returns>主键</returns>
 public string Add(BaseWorkFlowCurrentEntity baseWorkFlowCurrentEntity, bool identity, bool returnId)
 {
     this.Identity = identity;
     this.ReturnId = returnId;
     return this.AddEntity(baseWorkFlowCurrentEntity);
 }
 /// <summary>
 /// 添加实体
 /// </summary>
 /// <param name="baseWorkFlowCurrentEntity">实体</param>
 public string AddEntity(BaseWorkFlowCurrentEntity baseWorkFlowCurrentEntity)
 {
     string sequence = string.Empty;
     this.Identity = false;
     if (baseWorkFlowCurrentEntity.SortCode == null || baseWorkFlowCurrentEntity.SortCode == 0)
     {
         BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
         sequence = sequenceManager.GetSequence(this.CurrentTableName);
         baseWorkFlowCurrentEntity.SortCode = int.Parse(sequence);
     }
     if (baseWorkFlowCurrentEntity.Id != null)
     {
         sequence = baseWorkFlowCurrentEntity.Id.ToString();
     }
     SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);
     sqlBuilder.BeginInsert(this.CurrentTableName, BaseWorkFlowCurrentEntity.FieldId);
     if (!this.Identity)
     {
         if (string.IsNullOrEmpty(baseWorkFlowCurrentEntity.Id))
         {
             sequence = BaseBusinessLogic.NewGuid();
             baseWorkFlowCurrentEntity.Id = sequence ;
         }
         sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldId, baseWorkFlowCurrentEntity.Id);
     }
     else
     {
         if (!this.ReturnId && (DbHelper.CurrentDbType == DbTypes.Oracle || DbHelper.CurrentDbType == DbTypes.DB2))
         {
             if (DbHelper.CurrentDbType == DbTypes.Oracle)
             {
                 sqlBuilder.SetFormula(BaseWorkFlowCurrentEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
             }
             if (DbHelper.CurrentDbType == DbTypes.DB2)
             {
                 sqlBuilder.SetFormula(BaseWorkFlowCurrentEntity.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
             }
         }
         else
         {
             if (this.Identity && (DbHelper.CurrentDbType == DbTypes.Oracle || DbHelper.CurrentDbType == DbTypes.DB2))
             {
                 if (string.IsNullOrEmpty(baseWorkFlowCurrentEntity.Id))
                 {
                     if (string.IsNullOrEmpty(sequence))
                     {
                         BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                         sequence = sequenceManager.GetSequence(this.CurrentTableName);
                     }
                     baseWorkFlowCurrentEntity.Id = sequence;
                 }
                 sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldId, baseWorkFlowCurrentEntity.Id);
             }
         }
     }
     this.SetEntity(sqlBuilder, baseWorkFlowCurrentEntity);
     if (UserInfo != null)
     {
         sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldCreateUserId, UserInfo.Id);
         sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldCreateBy, UserInfo.RealName);
     }
     sqlBuilder.SetDBNow(BaseWorkFlowCurrentEntity.FieldCreateOn);
     if (UserInfo != null)
     {
         sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldModifiedUserId, UserInfo.Id);
         sqlBuilder.SetValue(BaseWorkFlowCurrentEntity.FieldModifiedBy, UserInfo.RealName);
     }
     sqlBuilder.SetDBNow(BaseWorkFlowCurrentEntity.FieldModifiedOn);
     if (this.Identity && (DbHelper.CurrentDbType == DbTypes.SqlServer || DbHelper.CurrentDbType == DbTypes.Access))
     {
         sequence = sqlBuilder.EndInsert().ToString();
     }
     else
     {
         sqlBuilder.EndInsert();
     }
     return sequence;
 }
 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);
 }
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="baseWorkFlowCurrentEntity">实体</param>
 /// <returns>主键</returns>
 public string Add(BaseWorkFlowCurrentEntity baseWorkFlowCurrentEntity)
 {
     return this.AddEntity(baseWorkFlowCurrentEntity);
 }
 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;
 }
 /// <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;
 }
        /// <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;
        }
 /// <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;
 }
 /// <summary>
 /// 获取实体
 /// </summary>
 /// <param name="id">主键</param>
 public BaseWorkFlowCurrentEntity GetEntity(string id)
 {
     BaseWorkFlowCurrentEntity baseWorkFlowCurrentEntity = new BaseWorkFlowCurrentEntity(this.GetDataTable(new KeyValuePair<string, object>(BaseWorkFlowCurrentEntity.FieldId, id)));
     return baseWorkFlowCurrentEntity;
 }
 /// <summary>
 /// 重置单据
 /// (单据发生错误时)紧急情况下实用
 /// </summary>
 /// <param name="currentId">审批流当前主键</param>
 /// <param name="categoryCode">单据分类</param>
 /// <param name="auditIdea">批示</param>
 /// <returns>影响行数</returns>
 public override bool OnReset(BaseWorkFlowCurrentEntity workFlowCurrentEntity)
 {
     // 若还需要有其他处理,就这后面继续处理
     return true;
 }
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="baseWorkFlowCurrentEntity">实体</param>
 public int Update(BaseWorkFlowCurrentEntity baseWorkFlowCurrentEntity)
 {
     return this.UpdateEntity(baseWorkFlowCurrentEntity);
 }
示例#19
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;
 }
 /// <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;
 }