示例#1
0
        public static object Evaluate(string sourceFieldName, EtlValueTranslation sourceFieldTranslation, IDataRecord sourceRecord, string defaultValue)
        {
            if (sourceRecord == null)
            {
                throw new ArgumentNullException("sourceRecord");
            }

            var sourceFieldValue = GetTranslatedFieldValue(sourceFieldName, sourceFieldTranslation, sourceRecord);

            if (sourceFieldValue == null || sourceFieldValue == DBNull.Value)
            {
                return(defaultValue);
            }
            else
            {
                return(sourceFieldValue);
            }
        }
示例#2
0
        private static object GetTranslatedFieldValue(string sourceFieldName, EtlValueTranslation sourceFieldTranslation, IDataRecord sourceRecord)
        {
            if (string.IsNullOrEmpty(sourceFieldName))
            {
                return(null);
            }

            var sourceFieldValue = sourceRecord[sourceFieldName];
            var translatedValue  = sourceFieldValue;

            if (sourceFieldTranslation != null)
            {
                try
                {
                    foreach (var func in sourceFieldTranslation.Functions)
                    {
                        translatedValue = func.Evaluate(translatedValue, sourceRecord);
                    }
                    return(translatedValue);
                }
                catch (Exception exc)
                {
                    throw new InvalidOperationException
                          (
                              string.Format
                              (
                                  Properties.Resources.ValueTranslationError,
                                  sourceFieldName,
                                  sourceFieldValue
                              ),
                              exc
                          );
                }
            }
            return(translatedValue);
        }
示例#3
0
 public static object Evaluate(string sourceFieldName, EtlValueTranslation sourceFieldTranslation, IDataRecord sourceRecord)
 {
     return(Evaluate(sourceFieldName, sourceFieldTranslation, sourceRecord, null));
 }