Пример #1
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);
        }
Пример #2
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="workFlowProcessEntity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <returns>影响行数</returns>
        public int Update(BaseWorkFlowProcessEntity workFlowProcessEntity, out string statusCode)
        {
            int returnValue = 0;

            // 检查编号是否重复
            if (this.Exists(new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldDeletionStateCode, 0), new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldCode, workFlowProcessEntity.Code), workFlowProcessEntity.Id))
            {
                // 文件夹名已重复
                statusCode = StatusCode.ErrorCodeExist.ToString();
            }
            else
            {
                // 进行更新操作
                returnValue = this.UpdateEntity(workFlowProcessEntity);
                if (returnValue == 1)
                {
                    statusCode = StatusCode.OKUpdate.ToString();
                }
                else
                {
                    // 数据可能被删除
                    statusCode = StatusCode.ErrorDeleted.ToString();
                }
            }
            return(returnValue);
        }
        private void grdWorkFlow_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
        {
            // 判断是否有删除权限
            if (!this.PermissionDelete)
            {
                e.Cancel = true;
                return;
            }
            // 当前记录是否允许被删除
            BaseWorkFlowProcessEntity workFlowProcessEntity = new BaseWorkFlowProcessEntity();
            DataRow dataRow = BaseBusinessLogic.GetDataRow(this.DTWorkFlow, this.EntityId);

            workFlowProcessEntity.GetFrom(dataRow);
            if (this.DTWorkFlow.Rows.Count < 0)
            {
                MessageBox.Show(AppMessage.MSG0017, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Question);
                e.Cancel = true;
            }
            else
            {
                if (MessageBox.Show(AppMessage.MSG0015, AppMessage.MSG0000, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
                {
                    e.Cancel = true;
                }
            }
        }
 /// <summary>
 /// 加载窗体
 /// </summary>
 public override void FormOnLoad()
 {
     // 获取分类列表
     this.BindItemDetails();
     // 获取单据数据
     this.GetBillList(false);
     // 实体信息
     this.WorkFlowProcessEntity = DotNetService.Instance.WorkFlowProcessAdminService.GetEntity(this.UserInfo, this.EntityId);
     // 显示内容
     this.ShowEntity();
 }
        /// <summary>
        /// 添加工作流
        /// </summary>
        /// <param name="userInfo">当前用户</param>
        /// <param name="workFlowProcessEntity">工作流定义实体</param>
        /// <param name="statusCode">状态码</param>
        /// <param name="statusMessage">状态信息</param>
        /// <returns>主键</returns>
        public string Add(BaseUserInfo userInfo, BaseWorkFlowProcessEntity workFlowProcessEntity, out string statusCode, out string statusMessage)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            statusCode    = string.Empty;
            statusMessage = string.Empty;
            string returnValue = string.Empty;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.WorkFlowDbType))
            {
                try
                {
                    dbHelper.Open(WorkFlowDbConnection);
                    // 数据库事务开始
                    // dbHelper.BeginTransaction();
                    BaseWorkFlowProcessManager workFlowManager = new BaseWorkFlowProcessManager(dbHelper, userInfo);
                    returnValue = workFlowManager.Add(workFlowProcessEntity, out statusCode);
                    // 获得状态消息
                    statusMessage = workFlowManager.GetStateMessage(statusCode);
                    // 写入日志信息
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, MethodBase.GetCurrentMethod());
                    // 数据库事务提交
                    // dbHelper.CommitTransaction();
                }
                catch (Exception ex)
                {
                    // 数据库事务回滚
                    // dbHelper.RollbackTransaction();
                    // 记录异常信息
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

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

            return(returnValue);
        }
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="baseWorkFlowProcessEntity">实体</param>
        public int UpdateEntity(BaseWorkFlowProcessEntity baseWorkFlowProcessEntity)
        {
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper);

            sqlBuilder.BeginUpdate(this.CurrentTableName);
            this.SetEntity(sqlBuilder, baseWorkFlowProcessEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseWorkFlowProcessEntity.FieldModifiedOn);
            sqlBuilder.SetWhere(BaseWorkFlowProcessEntity.FieldId, baseWorkFlowProcessEntity.Id);
            return(sqlBuilder.EndUpdate());
        }
 /// <summary>
 /// 设置实体
 /// </summary>
 /// <param name="baseWorkFlowProcessEntity">实体</param>
 private void SetEntity(SQLBuilder sqlBuilder, BaseWorkFlowProcessEntity baseWorkFlowProcessEntity)
 {
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldUserId, baseWorkFlowProcessEntity.UserId);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldOrganizeId, baseWorkFlowProcessEntity.OrganizeId);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldBillTemplateId, baseWorkFlowProcessEntity.BillTemplateId);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldAuditCategoryCode, baseWorkFlowProcessEntity.AuditCategoryCode);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldCallBackClass, baseWorkFlowProcessEntity.CallBackClass);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldCallBackTable, baseWorkFlowProcessEntity.CallBackTable);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldCategoryCode, baseWorkFlowProcessEntity.CategoryCode);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldCode, baseWorkFlowProcessEntity.Code);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldFullName, baseWorkFlowProcessEntity.FullName);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldContents, baseWorkFlowProcessEntity.Contents);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldSortCode, baseWorkFlowProcessEntity.SortCode);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldEnabled, baseWorkFlowProcessEntity.Enabled);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldDeletionStateCode, baseWorkFlowProcessEntity.DeletionStateCode);
     sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldDescription, baseWorkFlowProcessEntity.Description);
 }
Пример #8
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="workFlowEntity">实体</param>
        /// <param name="statusCode">返回状态码</param>
        /// <returns>主键</returns>
        public string Add(BaseWorkFlowProcessEntity workFlowProcessEntity, out string statusCode)
        {
            string returnValue = string.Empty;

            // 检查编号是否重复
            if (this.Exists(new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldDeletionStateCode, 0), new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldCode, workFlowProcessEntity.Code)))
            {
                // 编号已重复
                statusCode = StatusCode.ErrorCodeExist.ToString();
            }
            else
            {
                returnValue = this.AddEntity(workFlowProcessEntity);
                // 运行成功
                statusCode = StatusCode.OKAdd.ToString();
            }
            return(returnValue);
        }
Пример #9
0
        /// <summary>
        /// 批量进行保存
        /// </summary>
        /// <param name="dataSet">数据权限</param>
        /// <returns>影响行数</returns>
        public new int BatchSave(DataTable dataTable)
        {
            int returnValue = 0;

            foreach (DataRow dataRow in dataTable.Rows)
            {
                BaseWorkFlowProcessEntity workFlowProcessEntity = new BaseWorkFlowProcessEntity(dataRow);
                // 删除状态
                if (dataRow.RowState == DataRowState.Deleted)
                {
                    string id = dataRow[BaseWorkFlowProcessEntity.FieldId, DataRowVersion.Original].ToString();
                    if (id.Length > 0)
                    {
                        returnValue += this.Delete(id);
                    }
                }
                // 被修改过
                if (dataRow.RowState == DataRowState.Modified)
                {
                    string id = dataRow[BaseWorkFlowProcessEntity.FieldId, DataRowVersion.Original].ToString();
                    if (id.Length > 0)
                    {
                        workFlowProcessEntity.GetFrom(dataRow);
                        // 判断是否允许编辑
                        returnValue += this.Update(workFlowProcessEntity);
                    }
                }
                // 添加状态
                if (dataRow.RowState == DataRowState.Added)
                {
                    workFlowProcessEntity.GetFrom(dataRow);
                    returnValue += this.Add(workFlowProcessEntity).Length > 0 ? 1 : 0;
                }
                if (dataRow.RowState == DataRowState.Unchanged)
                {
                    continue;
                }
                if (dataRow.RowState == DataRowState.Detached)
                {
                    continue;
                }
            }
            return(returnValue);
        }
Пример #10
0
        public IWorkFlowManager GetWorkFlowManager(string id)
        {
            IWorkFlowManager          workFlowManager       = null;
            BaseWorkFlowProcessEntity workFlowProcessEntity = this.GetEntity(id);

            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))
                {
                    workFlowManager.CurrentTableName = workFlowProcessEntity.CallBackTable;
                }
            }
            // workFlowManager = new BaseUserBillManager(this.DbHelper, this.UserInfo);
            return(workFlowManager);
        }
        public BaseWorkFlowProcessEntity GetEntity(BaseUserInfo userInfo, string id)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

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

            BaseWorkFlowProcessEntity workFlowEntity = new BaseWorkFlowProcessEntity();
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.WorkFlowDbType))
            {
                try
                {
                    dbHelper.Open(WorkFlowDbConnection);
                    // 创建实现类
                    BaseWorkFlowProcessManager workFlowManager = new BaseWorkFlowProcessManager(dbHelper, userInfo);
                    workFlowEntity = workFlowManager.GetEntity(id);
                    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(workFlowEntity);
        }
Пример #12
0
 /// <summary>
 /// 读取屏幕中输入的数据
 /// </summary>
 /// <returns>操作权限项实体</returns>
 private BaseWorkFlowProcessEntity GetEntity()
 {
     if (this.WorkFlowProcessEntity == null)
     {
         this.WorkFlowProcessEntity = new BaseWorkFlowProcessEntity();
     }
     if (!string.IsNullOrEmpty(this.ucOrganize.SelectedId))
     {
         this.WorkFlowProcessEntity.OrganizeId = this.ucOrganize.SelectedId;
     }
     if (!string.IsNullOrEmpty(this.ucUser.SelectedId))
     {
         this.WorkFlowProcessEntity.UserId = this.ucUser.SelectedId;
         //BaseUserEntity userEntity = DotNetService.Instance.UserService.GetEntity(this.UserInfo, this.ucUser.SelectedId);
         //if (userEntity != null)
         //{
         //    this.WorkFlowProcessEntity.OrganizeId = userEntity.DepartmentId;
         //}
     }
     //this.WorkFlowProcessEntity.AuditCategoryCode = this.cmbAuditCategoryCode.SelectedValue.ToString();
     if (this.cmbWorkFlowCategory.SelectedValue != null)
     {
         this.WorkFlowProcessEntity.CategoryCode = this.cmbWorkFlowCategory.SelectedValue.ToString();
     }
     if (this.lstbBillTemlate.SelectedValue != null)
     {
         this.WorkFlowProcessEntity.BillTemplateId = this.lstbBillTemlate.SelectedValue.ToString();
     }
     this.WorkFlowProcessEntity.Code              = this.txtCode.Text;
     this.WorkFlowProcessEntity.FullName          = this.txtFullName.Text;
     this.WorkFlowProcessEntity.CategoryCode      = this.cmbWorkFlowCategory.SelectedValue.ToString();
     this.WorkFlowProcessEntity.Enabled           = this.chkEnabled.Checked ? 1 : 0;
     this.WorkFlowProcessEntity.DeletionStateCode = 0;
     this.WorkFlowProcessEntity.Description       = this.txtDescription.Text;
     return(this.WorkFlowProcessEntity);
 }
        public BaseWorkFlowProcessEntity GetEntity(int id)
        {
            BaseWorkFlowProcessEntity baseWorkFlowProcessEntity = new BaseWorkFlowProcessEntity(this.GetDataTable(new KeyValuePair <string, object>(BaseWorkFlowProcessEntity.FieldId, id)));

            return(baseWorkFlowProcessEntity);
        }
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="baseWorkFlowProcessEntity">实体</param>
        public string AddEntity(BaseWorkFlowProcessEntity baseWorkFlowProcessEntity)
        {
            string sequence = string.Empty;

            if (baseWorkFlowProcessEntity.SortCode == null || baseWorkFlowProcessEntity.SortCode == 0)
            {
                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                baseWorkFlowProcessEntity.SortCode = int.Parse(sequence);
            }
            SQLBuilder sqlBuilder = new SQLBuilder(DbHelper, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, BaseWorkFlowProcessEntity.FieldId);
            if (!this.Identity)
            {
                sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldId, baseWorkFlowProcessEntity.Id);
            }
            else
            {
                if (!this.ReturnId && (DbHelper.CurrentDbType == DbTypes.Oracle || DbHelper.CurrentDbType == DbTypes.DB2))
                {
                    if (DbHelper.CurrentDbType == DbTypes.Oracle)
                    {
                        sqlBuilder.SetFormula(BaseWorkFlowProcessEntity.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DbHelper.CurrentDbType == DbTypes.DB2)
                    {
                        sqlBuilder.SetFormula(BaseWorkFlowProcessEntity.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DbHelper.CurrentDbType == DbTypes.Oracle || DbHelper.CurrentDbType == DbTypes.DB2))
                    {
                        if (baseWorkFlowProcessEntity.Id == null)
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                BaseSequenceManager sequenceManager = new BaseSequenceManager(DbHelper, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            baseWorkFlowProcessEntity.Id = int.Parse(sequence);
                        }
                        sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldId, baseWorkFlowProcessEntity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, baseWorkFlowProcessEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseWorkFlowProcessEntity.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldModifiedUserId, UserInfo.Id);
                sqlBuilder.SetValue(BaseWorkFlowProcessEntity.FieldModifiedBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(BaseWorkFlowProcessEntity.FieldModifiedOn);
            if (this.Identity && (DbHelper.CurrentDbType == DbTypes.SqlServer || DbHelper.CurrentDbType == DbTypes.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="baseWorkFlowProcessEntity">实体</param>
 public int Update(BaseWorkFlowProcessEntity baseWorkFlowProcessEntity)
 {
     return(this.UpdateEntity(baseWorkFlowProcessEntity));
 }
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="baseWorkFlowProcessEntity">实体</param>
 /// <param name="identity">自增量方式</param>
 /// <param name="returnId">返回主键</param>
 /// <returns>主键</returns>
 public string Add(BaseWorkFlowProcessEntity baseWorkFlowProcessEntity, bool identity, bool returnId)
 {
     this.Identity = identity;
     this.ReturnId = returnId;
     return(this.AddEntity(baseWorkFlowProcessEntity));
 }
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="baseWorkFlowProcessEntity">实体</param>
 /// <returns>主键</returns>
 public string Add(BaseWorkFlowProcessEntity baseWorkFlowProcessEntity)
 {
     return(this.AddEntity(baseWorkFlowProcessEntity));
 }