public static bool ProcessLine(DataMappingInfo headerInfo, string line, RecWrapper rec, object data, out string[] fields, ref Exception error, char[] separators)
 {
     try {
         ClearRecord(rec);
         fields = line.Split(separators);
         foreach (var info in headerInfo.Mappings) {
             var i = 0;
             foreach (var index in info.SourceIndex) {
                 info.SourceValues[i++] = index != -1
                                              ? (fields.Length > index ? fields[index] : string.Empty)
                                              : null;
             }
             info.MappedField.SetValue(rec, info.MethodInfo != null
                                                ? info.MethodInfo(rec, info.Original[0][0], info.SourceValues, data)
                                                : info.SourceValues[0], null);
         }
         return true;
     } catch (Exception e) {
         fields = null;
         error = e;
     }
     return false;
 }
 private void WarnForMissingHeaders(FileInfo sourceFile, DataMappingInfo headerInfo, Dictionary<string, int> header)
 {
     foreach (var mapping in headerInfo.Mappings)
     {
         foreach (var originals in mapping.Original)
         {
             var i = 0;
             for (; i < originals.Length; i++)
                 if (header.ContainsKey(originals[i]))
                     break;
             if (i == originals.Length)
             {
                 L.Log(LogType.FILE, LogLevel.WARN, "File does not have record mapping field. Please send this line back to programmer if could be added:["
                     + sourceFile.FullName + "->" + PrepareField(originals) + "]");
             }
         }
     }
 }
 private bool ProcessLine(DataMappingInfo headerInfo, string line, RecWrapper rec)
 {
     try
     {
         string[] fields;
         Exception error = null;
         if (MappedDataHelper.ProcessLine(headerInfo, line, rec, this, out fields, ref error, new[] { ',' }))
         {
             if (string.IsNullOrEmpty(rec.Datetime))
                 rec.Datetime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture);
             return true;
         }
         throw error ?? new Exception("Unknown error in data helper process line");
     }
     catch (Exception e)
     {
         L.Log(LogType.FILE, LogLevel.ERROR, "Error while processing line:[" + line + "]:" + e);
     }
     return false;
 }
 private DataMappingInfo BestMatch2Info(DataMappingInfo result, Dictionary<string, int> header)
 {
     var fin = new DataMappingInfo()
     {
         Name = result.Name,
         Mappings = new DataMapping[result.Mappings.Length]
     };
     var i = 0;
     foreach (var field in result.Mappings)
     {
         fin.Mappings[i] = new DataMapping()
         {
             MappedField = result.Mappings[i].MappedField,
             MethodInfo = result.Mappings[i].MethodInfo,
             Original = result.Mappings[i].Original,
             SourceIndex = new int[result.Mappings[i].Original.Length],
             SourceValues = new string[result.Mappings[i].Original.Length]
         };
         var origIndex = 0;
         foreach (var fieldNames in field.Original)
         {
             foreach (var fieldName in fieldNames)
             {
                 if (header.ContainsKey(fieldName))
                 {
                     fin.Mappings[i].SourceIndex[origIndex++] = header[fieldName];
                     break;
                 }
             }
         }
         ++i;
     }
     return fin;
 }
        protected virtual Dictionary<string, int> CreateFieldMappingIndexLookup(DataMappingInfo dataMappingInfo, RecorderContext context, IEnumerable<string> fields)
        {
            var fieldMappingLookup = new Dictionary<string, int>();

            if (dataMappingInfo == null) return fieldMappingLookup;

            foreach (var field in fields)
            {
                var index = FindMapIndex(dataMappingInfo.Mappings, field);
                fieldMappingLookup.Add(field, index);
            }
            return fieldMappingLookup;
        }