예제 #1
0
        private static void ValidateFieldRules(Field field, IFieldRule[] fieldRules)
        {
            if (fieldRules == null || fieldRules.Length == 0)
            {
                return;
            }

            var tempValidationResultType = field.ValidationResult;

            foreach (var fieldRule in fieldRules)
            {
                ProcessRule(field, fieldRule);
                tempValidationResultType = ParsedDataProcessorHelper.GetMaxValidationResult(tempValidationResultType, field.ValidationResult);
            }

            field.ValidationResult     = tempValidationResultType;
            field.Row.ValidationResult = ParsedDataProcessorHelper.GetMaxValidationResult(field.Row.ValidationResult, field.ValidationResult);
        }
예제 #2
0
        private void SourceAfterProcessRow(object sender, ProcessRowEventArgs <ParserContext10> e)
        {
            e.Context.ValidationResult = ParsedDataProcessorHelper.GetMaxValidationResult(e.Context.ValidationResult, e.Row.ValidationResult);
            if (e.Context.ValidationResult == ValidationResultType.Critical)
            {
                e.Context.IsAborted = true;
            }

            if (IsHeaderRow(e.Row))
            {
                AfterProcessHeaderRow(e);
                return;
            }

            if (IsTrailerRow(e.Context.IsCurrentRowTheLast))
            {
                AfterProcessTrailerRow(e);
                return;
            }

            AfterProcessDataRow(e);
        }
예제 #3
0
        private static void DecodeField(string fieldName, string description, Field field, IFieldDecoder fieldDecoder)
        {
            DataProcessorGlobal.Debug($"Decoding Field: {fieldName}, Raw Value: '{field.Raw}'");
            fieldDecoder.Decode(field);

            if (field.ValidationResult == ValidationResultType.Valid)
            {
                return;
            }

            field.Row.ValidationResult = ParsedDataProcessorHelper.GetMaxValidationResult(field.Row.ValidationResult, field.ValidationResult);
            var message = $"Invalid {description} '{field.Raw}'";

            if (field.ValidationResult == ValidationResultType.Warning)
            {
                field.Row.Warnings.Add(message);
            }
            else
            {
                field.Row.Errors.Add(message);
            }
        }