} //end method /// <summary> /// Method to initialize IO_SQLOut with a datatable from Record_Members File Data Records, /// instantiate it, and export it. This fires the SQLBulkCopy adapter. /// </summary> public void ExportSQLOutput(FileDataRecords<Record_Members, ClientETLProcess> dataTable) { Out_SQLBulkProfile<FileDataRecords<Record_Members, ClientETLProcess>>.Init(new object[] {dataTable}); var sqlOutput = new Out_SQLBulkProfile<FileDataRecords<Record_Members, ClientETLProcess>>( "ETLProcess_Record_Members", SqlBulkCopyOptions.Default); sqlOutput.Export(GetCheck_SQL_Output(new object[] { statementRecords })); } //end method
} // end method #endregion #endregion #region Private Core Algorithm /// <summary> /// Populate documents with information, in the proper order. /// </summary> /// <param name="files"></param> private void PopulateRecords(string[] files) { RecordType recordType; string filename , fileExtension; Queue<string> fileList = OrderFileList(files); foreach (string filePath in fileList) { filename = Path.GetFileName(filePath); fileExtension = Path.GetExtension(filePath); recordType = (RecordType)IdentifyRecordFile(filename); DataColumn[] _parentColumns; String[] _childColumns; // put each document type into its headersource (struct of Stringmap and headers list) switch (recordType) { case (RecordType.Statements): List<string> StatementRecordData = CSV.ImportRows(filePath); HeaderSource<List<StringMap>, List<string>> statementSrcData = Record_Statement.Sample.ParseRows(StatementRecordData.ToArray()); statementRecords = new FileDataRecords<Record_Statement, ClientETLProcess>( statementSrcData , AllTableHeadersByType , new ForeignKeyConstraintElements(this, typeof(Record_Statement).Name)); Log.Write("Statement Records files populated."); if (!TablesByType.ContainsKey(typeof(Record_Statement))) { TablesByType.Add(typeof(Record_Statement), new List<DataTable>() { statementRecords }); } else { TablesByType[typeof(Record_Statement)].Add(statementRecords); } break; case (RecordType.Members): // TO DO: once-over post-DataSet/DataTable type changes. // statementTable already populated, per OrderFileList(files) method. var membersByAcctID = CSV.ImportCSVWithHeader( filePath , delimiter: "|" , useQuotes: false); _parentColumns = new DataColumn[] { Tables[statementRecords.TableName].Columns["Group Billing Acct ID"] }; // parent key columns. _childColumns = new String[] { "Billing Account Number" }; // "must belong to a column" error. memberRecords = new FileDataRecords<Record_Members, ClientETLProcess>( membersByAcctID , AllTableHeadersByType , new ForeignKeyConstraintElements( this , _parentColumns , _childColumns ) ); if (!TablesByType.ContainsKey(typeof(Record_Members))) { TablesByType.Add(typeof(Record_Members), new List<DataTable>() { memberRecords }); } else { TablesByType[typeof(Record_Members)].Add(memberRecords); } Log.Write("Member Records populated."); break; case (RecordType.BalancesForward): // TO DO: once-over post-DataSet/DataTable type changes. // balfwdfile has no internal headers. List<string> headers = Record_BalFwd.Sample.Headers; // TO DO: var balFwdByAcctID = CSV.ImportCSVWithHeader( filePath , "," , useQuotes: true , headers); _parentColumns = new DataColumn[] { Tables[statementRecords.TableName].Columns["Group Billing Acct ID"] }; // parent key columns. _childColumns = new String[] { "Account ID" }; balFwdRecords = new FileDataRecords<Record_BalFwd, ClientETLProcess>( balFwdByAcctID , AllTableHeadersByType , new ForeignKeyConstraintElements( this , _parentColumns , _childColumns ) ); Log.Write("Balance Forward Records populated."); if (!TablesByType.ContainsKey(typeof(Record_BalFwd))) { TablesByType.Add(typeof(Record_BalFwd), new List<DataTable>() { balFwdRecords }); } else { TablesByType[typeof(Record_BalFwd)].Add(balFwdRecords); } break; case (RecordType.Error): throw new Exception($"Unexpected file found: {filePath}"); } } }