using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using GB5Shared.DTO.Framework.Login; namespace GB5Shared.DTO.Qualifier { public class QualifierDefinitionDTO { public int Id { get; set; } public string? Code { get; set; } public string? Name { get; set; } public int EntityId { get; set; } public QualifierStage Stage { get; set; } public QualifierType QualifierType { get; set; } public string ExecutorKey { get; set; } = default!; public int Priority { get; set; } public bool IsActive { get; set; } public string? ConditionExpression { get; set; } public int RetryCount { get; set; } = 0; public bool StopOnFailure { get; set; } = true; public bool RunParallel { get; set; } public Dictionary? Config { get; set; } } public enum QualifierStage { PreValidate = 1, PreWorkflow = 2, PrePersist = 3, PostPersist = 4, PreEventPublish = 5 } public class ValidationError { public string? Field { get; set; } public string Message { get; set; } = default!; } public class QualifierExecutionLog { public int EntityId { get; set; } public int QualifierId { get; set; } public QualifierStage Stage { get; set; } public bool IsSuccess { get; set; } public long DurationMs { get; set; } public string? Error { get; set; } public DateTime CreatedOn { get; set; } } public class ExecuteContext { public string EntityName { get; set; } = null!; public int EntityId { get; set; } public int ObjectId { get; set; } public int EventTypeId { get; set; } public int BizTransactionTypeId { get; set; } = -1; public string? Comment { get; set; } public QualifierType QualifierType { get; set; } public object? Data { get; init; } private readonly Dictionary _bag = new(); private readonly Dictionary _cache = new(); public void Set(string key, object value) => _bag[key] = value; public T Get(string key) => _bag.TryGetValue(key, out var v) ? (T)v : default!; public bool TryGetCached(string key, out T value) { if (_cache.TryGetValue(key, out var v)) { value = (T)v; return true; } value = default!; return false; } public IReadOnlyDictionary ExportBag() => _bag; public IReadOnlyDictionary Facts { get; set; } = new Dictionary(); public LoginDTO? Login { get; set; } public void SetCached(string key, object value) => _cache[key] = value; } public enum QualifierType { Validate, Enrich, Derive, Normalize, Classify, Workflow, Event, BusinessRule } }