private bool ValidateValues(DataElement element, IObserver <IElement> sink) { var fields = _schema.GetTableSchemaDictionary(element.Name); var data = element.Data.Schema.ToDictionary(x => x.Key, x => element.Data.Values[x.Value]); var names = fields.Keys.Concat(data.Keys).Distinct(); foreach (string name in names) { SchemaValidationErrorType error = SchemaValidationErrorType.None; if (!fields.ContainsKey(name)) { error = SchemaValidationErrorType.UnknownField; } else if (!data.ContainsKey(name)) { error = SchemaValidationErrorType.MissingField; } else { error = CheckValue(fields[name], data[name]); } if (error != SchemaValidationErrorType.None) { SchemaValidationDecision decision = OnHandleError(element, error, name); switch (decision) { case SchemaValidationDecision.PassElement: return(true); case SchemaValidationDecision.SkipElement: return(false); case SchemaValidationDecision.DoComplete: sink.OnCompleted(); return(false); case SchemaValidationDecision.DoError: sink.OnError(new SchemaValidationException(error)); return(false); case SchemaValidationDecision.IgnoreError: default: break; } } } return(true); }
protected virtual bool MapReferences(DataElement element, IObserver <IElement> sink) { var fields = _schema.GetTableSchemaDictionary(element.Name); var data = element.Data.Schema.Where(x => fields.ContainsKey(x.Key) && !String.IsNullOrEmpty(fields[x.Key].ValueAlias)); foreach (var item in data) { string sql = GetSqlForValueAlias(fields[item.Key].ValueAlias); object value = element.Data.Values[item.Value]; if (value != null) { object newvalue = QueryValue(sql, value); if (newvalue == null) { OnHandleError(element, item.Key, sql, value); } else { element.Data.Values[item.Value] = newvalue; } } } return(true); }