Example #1
0
        /// <summary>
        /// Constructor: A metadata wrapper for different types of
        ///     unique/redundant primary or composite keyed CSV document classes.
        /// </summary>
        /// <param name="data">Data from which to derive a key, if any.</param>
        /// <param name="sampleColumnTypes">A dictionary of column types in the derived type of Record</param>
        /// <param name="keyIsUniqueIdentifier">Is the primary or composite key a unique identifier?
        /// <br>(Sometimes they're not.)</br></param>
        public BasicRecord(
            StringMap data
            , TableHeaders sampleColumnTypes
            , bool keyIsUniqueIdentifier = true) : base()
        {
            try
            {
                foreach (KeyValuePair <string, string> record in data)
                {
                    Add(record.Key, record.Value);
                }

                recordKey = new KeyStrings();

                // TO DO: Decouple from clientETLProcess (should be providable from FileDataRecords).
                foreach (KeyValuePair <string, (Type colType, bool isKey)> headerData
                         in sampleColumnTypes.Where((x) => x.Value.isKey == true))
                {
                    bool success = data.TryGetValue(headerData.Key, out string dataValue);
                    if (success)
                    {
                        recordKey.Add((dataValue ??= data[headerData.Key], headerData.Key));
                    }
                    else
                    {
                        Log.WriteException("Bad key assignent or unknown failure in TryGetValue.");
                    }
                }
            }catch (WarningException err)
            {
                Log.Write("ETLProcess threw Warning: " + err.ToString() + "at BasicRecord constructor.");
            }
            this.keyIsUniqueIdentifier = keyIsUniqueIdentifier;
            //this.headers = keyHeaders;
        }
Example #2
0
 /// <summary>
 /// Copy Constructor
 /// </summary>
 /// <param name="record">Object to be copied from</param>
 public BasicRecord(BasicRecord <T> record)
 {
     this.recordKey             = record.recordKey.ToArray().ToList() as KeyStrings; // force copy
     this.keyIsUniqueIdentifier = record.keyIsUniqueIdentifier;
     foreach (KeyValuePair <string, string> cell in record)
     {
         Add(cell.Key, cell.Value);
     }
 }