コード例 #1
0
 public ChoCSVRecordFieldConfiguration(string name, ChoCSVRecordFieldAttribute attr = null) : base(name, attr)
 {
     if (attr != null)
     {
         FieldPosition = attr.FieldPosition;
         FieldName     = attr.FieldName.IsNullOrWhiteSpace() ? Name : attr.FieldName;
     }
 }
コード例 #2
0
        internal ChoCSVRecordFieldConfiguration GetFieldConfiguration(string fn, ChoCSVRecordFieldAttribute attr = null, Attribute[] otherAttrs = null)
        {
            if (!CSVRecordFieldConfigurations.Any(fc => fc.Name == fn))
            {
                CSVRecordFieldConfigurations.Add(new ChoCSVRecordFieldConfiguration(fn, attr, otherAttrs));
            }

            return(CSVRecordFieldConfigurations.First(fc => fc.Name == fn));
        }
コード例 #3
0
 internal ChoCSVRecordFieldConfiguration(string name, ChoCSVRecordFieldAttribute attr = null) : base(name, attr)
 {
     FieldName = name;
     if (attr != null)
     {
         FieldPosition = attr.FieldPosition;
         FieldName     = attr.FieldName.IsNullOrWhiteSpace() ? Name.NTrim() : attr.FieldName.NTrim();
     }
 }
コード例 #4
0
 internal ChoCSVRecordFieldConfiguration(string name, ChoCSVRecordFieldAttribute attr = null, Attribute[] otherAttrs = null) : base(name, attr, otherAttrs)
 {
     FieldName = name;
     if (attr != null)
     {
         FieldPosition = attr.FieldPosition;
         FieldName     = attr.FieldName.IsNullOrWhiteSpace() ? Name : attr.FieldName;
         AltFieldNames = attr.AltFieldNames.IsNullOrWhiteSpace() ? AltFieldNames : attr.AltFieldNames;
     }
 }
コード例 #5
0
        private void LoadCSVRecordFieldOptions(ChoIniFile iniFile1)
        {
            ChoIniFile iniFile = iniFile1.GetSection("CSV_RECORD_FIELD");

            var dict = new Dictionary <string, ChoCSVRecordFieldAttribute>();
            ChoCSVRecordFieldAttribute  value;
            Dictionary <string, string> iniKeyValuesDict = iniFile.KeyValuesDict;

            if (iniKeyValuesDict.Count == 0)
            {
                throw new ApplicationException("Missing CSV field names in the '{0}' ini file.".FormatString(iniFile1.FilePath));
            }
            foreach (string fieldName in iniKeyValuesDict.Keys) //GetFieldNames(iniFile1))
            {
                if (fieldName.IsNullOrWhiteSpace())
                {
                    continue;
                }
                if (!iniKeyValuesDict.ContainsKey(fieldName))
                {
                    continue;
                }

                value = new ChoCSVRecordFieldAttribute(0);
                value.FieldValueTrimOption    = ChoFieldValueTrimOption.Trim;
                value.FieldValueJustification = ChoFieldValueJustification.Left;
                foreach (KeyValuePair <string, string> kvp in iniKeyValuesDict[fieldName].ToKeyValuePairs())
                {
                    try
                    {
                        ChoType.ConvertNSetMemberValue(value, kvp.Key, kvp.Value);
                    }
                    catch (Exception ex)
                    {
                        ChoETLFramework.WriteLog(ChoETLFramework.Switch.TraceError, "Error while loading record field '{0}' for '{1}' field. {2}".FormatString(iniKeyValuesDict[fieldName], fieldName, ex.Message));
                    }
                }
                value.Validate();
                dict.Add(fieldName, value);
            }
            _csvRecordFieldOptionCache.Add(iniFile1.Key, dict);
        }
コード例 #6
0
 public ChoCSVRecordFieldConfiguration(string name, int position, ChoCSVRecordFieldAttribute attr = null) : this(name, attr)
 {
     FieldPosition = position;
 }