Ejemplo n.º 1
0
 private List <StatementRow> ReadStatementFile(StatementImport statement)
 {
     try
     {
         var    statementRows = new List <StatementRow>();
         Stream stream        = new MemoryStream(statement.FileContent);
         using (var reader = new CsvReader(new StreamReader(stream)))
         {
             reader.Configuration.HasHeaderRecord = false;
             Type statementMap = GetStatementMap(statement.AccountID);
             reader.Configuration.RegisterClassMap(statementMap);
             statementRows = reader.GetRecords <StatementRow>().ToList();
         }
         return(statementRows);
     }
     catch (CsvTypeConverterException ex)
     {
         var msg = ex.Data["CsvHelper"];
         throw new Exception(msg.ToString(), ex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 2
0
        private void ImportFile(StatementImport statementFile, List <StatementRow> statementRows)
        {
            var bankFile        = CreateBankStatmentFile(statementFile);
            var bankTransaction = CreateBankTransaction(statementRows);

            transactionRepository.AddTransactions(bankFile, bankTransaction);
        }
Ejemplo n.º 3
0
        public void ImportFile(StatementImport statement)
        {
            var statementRows = ReadStatementFile(statement);

            if (statementRows.Any())
            {
                ImportFile(statement, statementRows);
            }
        }
Ejemplo n.º 4
0
 private BankFile CreateBankStatmentFile(StatementImport statementFile)
 {
     return(new BankFile()
     {
         AccountID = statementFile.AccountID,
         FileName = statementFile.FileName,
         FileContent = statementFile.FileContent,
         ContentType = statementFile.ContentType
     });
 }