Esempio n. 1
0
 internal ChoFixedLengthRecordFieldConfiguration(string name, ChoFixedLengthRecordFieldAttribute attr = null) : base(name, attr)
 {
     FieldName = name;
     if (attr != null)
     {
         StartIndex = attr.StartIndex;
         Size       = attr.Size;
         FieldName  = attr.FieldName.IsNullOrWhiteSpace() ? Name : attr.FieldName;
     }
 }
Esempio n. 2
0
 internal ChoFixedLengthRecordFieldConfiguration(string name, ChoFixedLengthRecordFieldAttribute attr = null, Attribute[] otherAttrs = null) : base(name, attr, otherAttrs)
 {
     FieldName = name;
     if (attr != null)
     {
         StartIndex    = attr.StartIndex;
         Size          = attr.Size;
         FieldName     = attr.FieldName.IsNullOrWhiteSpace() ? Name : attr.FieldName;
         AltFieldNames = attr.AltFieldNames.IsNullOrWhiteSpace() ? AltFieldNames : attr.AltFieldNames;
     }
 }
Esempio n. 3
0
        private void LoadFixedLengthRecordFieldOptions(ChoIniFile iniFile1)
        {
            ChoIniFile iniFile = iniFile1.GetSection("FIXED_LENGTH_RECORD_FIELD");

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

            if (iniKeyValuesDict.Count == 0)
            {
                throw new ApplicationException("Missing fixed length 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;
                }

                try
                {
                    value = new ChoFixedLengthRecordFieldAttribute();
                    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 option '{0}' for '{1}' field. {2}".FormatString(iniKeyValuesDict[fieldName], fieldName, ex.Message));
                        }
                    }
                    value.Validate();
                    dict.Add(fieldName, value);
                }
                catch (Exception ex)
                {
                    throw new ApplicationException("[FieldName: {0}] - {1}".FormatString(fieldName, ex.Message));
                }
            }
            _flRecordFieldOptionCache.Add(iniFile1.Key, dict);
        }
        internal ChoFixedLengthRecordFieldConfiguration GetFieldConfiguration(string propertyName, ChoFixedLengthRecordFieldAttribute attr = null, Attribute[] otherAttrs = null)
        {
            if (!FixedLengthRecordFieldConfigurations.Any(fc => fc.Name == propertyName))
            {
                FixedLengthRecordFieldConfigurations.Add(new ChoFixedLengthRecordFieldConfiguration(propertyName, attr, otherAttrs));
            }

            return(FixedLengthRecordFieldConfigurations.First(fc => fc.Name == propertyName));
        }