Exemple #1
0
        /// <summary>
        /// 验证入口节点
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="node"></param>
        /// <returns></returns>
        private async Task ValidateEntryNode(CommonSignConfiguration configuration, CommonSignConfigurationNode node)
        {
            //检查节点的状态,如果状态为不可用,则抛出异常
            if (node.Status != CommonSignConfigurationNodeStatus.Enabled)
            {
                var fragment = new TextFragment()
                {
                    Code = TextCodes.CommonSignConfigurationEntryNodeStatusError,
                    DefaultFormatting = "工作流资源类型为{0}的通用审批配置入口节点{1}的状态为{2},但要求的状态为{3}",
                    ReplaceParameters = new List <object>()
                    {
                        configuration.WorkflowResourceType, node.Name, node.Status, CommonSignConfigurationNodeStatus.Enabled
                    }
                };

                throw new UtilityException((int)Errors.CommonSignConfigurationEntryNodeStatusError, fragment);
            }
            //检查入口节点的所属配置是否与当前配置相同
            if (node.Configuration.ID != configuration.ID)
            {
                var fragment = new TextFragment()
                {
                    Code = TextCodes.CommonSignConfigurationEntryNodeNotSameConfiguration,
                    DefaultFormatting = "工作流资源类型为{0}的通用审批配置的入口节点{1}的所属配置为工作流资源类型为{2}的通用审批配置,两者不一致",
                    ReplaceParameters = new List <object>()
                    {
                        configuration.WorkflowResourceType, node.Name, node.Configuration.WorkflowResourceType
                    }
                };

                throw new UtilityException((int)Errors.CommonSignConfigurationEntryNodeNotSameConfiguration, fragment);
            }

            await Task.FromResult(0);
        }
Exemple #2
0
 /// <summary>
 /// 赋值通用审批配置数据操作
 /// </summary>
 public static void SetCommonSignConfigurationSelectFields(CommonSignConfiguration data, DbDataReader reader, string prefix)
 {
     data.ID = (Guid)reader[string.Format("{0}id", prefix)];
     data.WorkflowResourceType = reader[string.Format("{0}workflowresourcetype", prefix)].ToString();
     data.EntityType           = reader[string.Format("{0}entitytype", prefix)].ToString();
     data.WorkflowResourceDefaultCompleteStatus = (int)reader[string.Format("{0}workflowresourcedefaultcompletestatus", prefix)];
     data.CompleteServiceConfiguration          = reader[string.Format("{0}completeserviceconfiguration", prefix)].ToString();
     data.CompleteServiceName = reader[string.Format("{0}completeservicename", prefix)].ToString();
     data.CreateTime          = (DateTime)reader[string.Format("{0}createtime", prefix)];
     data.ModifyTime          = (DateTime)reader[string.Format("{0}modifytime", prefix)];
 }
Exemple #3
0
        public async Task <CommonSignConfiguration> QueryByWorkflowResourceType(string workflowResourceType)
        {
            CommonSignConfiguration result = null;
            await DBTransactionHelper.SqlTransactionWorkAsync(DBTypes.SqlServer, true, false, _dbConnectionFactory.CreateReadForWorkflow(), async (conn, transaction) =>
            {
                SqlTransaction sqlTran = null;
                if (transaction != null)
                {
                    sqlTran = (SqlTransaction)transaction;
                }

                await using (var command = new SqlCommand()
                {
                    Connection = (SqlConnection)conn,
                    CommandType = CommandType.Text,
                    Transaction = sqlTran,
                    CommandText = string.Format(@"SELECT {0}
                                                FROM [CommonSignConfiguration]
                                                WHERE [workflowresourcetype] = @workflowresourcetype
                                                ORDER BY [sequence] DESC; ", StoreHelper.GetCommonSignConfigurationSelectFields(string.Empty))
                })
                {
                    var parameter = new SqlParameter("@workflowresourcetype", SqlDbType.NVarChar, 500)
                    {
                        Value = workflowResourceType
                    };
                    command.Parameters.Add(parameter);
                    await command.PrepareAsync();

                    SqlDataReader reader = null;

                    await using (reader = await command.ExecuteReaderAsync())
                    {
                        if (await reader.ReadAsync())
                        {
                            result = new CommonSignConfiguration();
                            StoreHelper.SetCommonSignConfigurationSelectFields(result, reader, string.Empty);
                        }

                        await reader.CloseAsync();
                    }
                }
            });

            return(result);
        }
Exemple #4
0
        public async Task QueryByEntityType(string entityType, Func <CommonSignConfiguration, Task> callback)
        {
            var configurationList = new List <CommonSignConfiguration>();

            await DBTransactionHelper.SqlTransactionWorkAsync(DBTypes.SqlServer, true, false, _dbConnectionFactory.CreateReadForWorkflow(), async (conn, transaction) =>
            {
                long?sequence      = null;
                const int pageSize = 1000;

                while (true)
                {
                    configurationList.Clear();

                    SqlTransaction sqlTran = null;
                    if (transaction != null)
                    {
                        sqlTran = (SqlTransaction)transaction;
                    }

                    await using (var command = new SqlCommand()
                    {
                        Connection = (SqlConnection)conn,
                        CommandType = CommandType.Text,
                        Transaction = sqlTran,
                    })
                    {
                        if (!sequence.HasValue)
                        {
                            command.CommandText = string.Format(@"SELECT TOP (@pagesize) {0}                                                                    
                                                                FROM [CommonSignConfiguration]
                                                                WHERE [entitytype] = @entitytype 
                                                                ORDER BY [sequence]", StoreHelper.GetCommonSignConfigurationSelectFields(string.Empty));
                        }
                        else
                        {
                            command.CommandText = string.Format(@"SELECT TOP (@pagesize) {0}                                                                    
                                                                FROM [CommonSignConfiguration]
                                                                WHERE [entitytype] = @entitytype
                                                                      AND [sequence] > @sequence
                                                                ORDER BY [sequence];", StoreHelper.GetCommonSignConfigurationSelectFields(string.Empty));
                        }

                        var parameter = new SqlParameter("@entitytype", SqlDbType.NVarChar, 500)
                        {
                            Value = entityType
                        };
                        command.Parameters.Add(parameter);

                        parameter = new SqlParameter("@pagesize", SqlDbType.Int)
                        {
                            Value = pageSize
                        };
                        command.Parameters.Add(parameter);

                        if (sequence.HasValue)
                        {
                            parameter = new SqlParameter("@sequence", SqlDbType.BigInt)
                            {
                                Value = sequence
                            };
                            command.Parameters.Add(parameter);
                        }

                        await command.PrepareAsync();

                        SqlDataReader reader = null;

                        await using (reader = await command.ExecuteReaderAsync())
                        {
                            while (await reader.ReadAsync())
                            {
                                var date = new CommonSignConfiguration();
                                StoreHelper.SetCommonSignConfigurationSelectFields(date, reader, string.Empty);
                                sequence = (long)reader["sequence"];
                                configurationList.Add(date);
                            }
                            await reader.CloseAsync();
                        }
                    }

                    foreach (var workflowStep in configurationList)
                    {
                        await callback(workflowStep);
                    }

                    if (configurationList.Count != pageSize)
                    {
                        break;
                    }
                }
            });
        }