///<summary>The entry point for the application.</summary> ///<param name="argv">A list of command line arguments</param> public static void Main ( string[] argv ) { Boolean booleanParseCommandLineArguments = false; String exceptionMessage = null; UtilityCommonwealthBankOfAustraliaTransactionArgument UtilityCommonwealthBankOfAustraliaTransactionArgument = null; UtilityCommonwealthBankOfAustraliaTransactionArgument = new UtilityCommonwealthBankOfAustraliaTransactionArgument(); booleanParseCommandLineArguments = UtilityParseCommandLineArgument.ParseCommandLineArguments ( argv, UtilityCommonwealthBankOfAustraliaTransactionArgument ); if (booleanParseCommandLineArguments == false) { // error encountered in arguments. Display usage message System.Console.Write ( UtilityParseCommandLineArgument.CommandLineArgumentsUsage(typeof(UtilityCommonwealthBankOfAustraliaTransactionArgument)) ); return; }//if ( booleanParseCommandLineArguments == false ) Import(ref UtilityCommonwealthBankOfAustraliaTransactionArgument, ref exceptionMessage); }
///<summary>Import</summary> public static void Import ( ref UtilityCommonwealthBankOfAustraliaTransactionArgument UtilityCommonwealthBankOfAustraliaTransactionArgument, ref string exceptionMessage ) { double debitCredit = 0.0; int rowCount = -1; int rowAffect = -1; string[] column = null; string commandText = null; string line = null; OleDbCommand oleDbCommand = null; OleDbConnection oleDbConnection = null; StreamReader streamReader = null; try { oleDbConnection = new OleDbConnection(DatabaseConnectionString); oleDbConnection.Open(); oleDbCommand = new OleDbCommand(DateFormat, oleDbConnection); oleDbCommand.ExecuteNonQuery(); foreach (string filenameSource in UtilityCommonwealthBankOfAustraliaTransactionArgument.filenameSource) { streamReader = new StreamReader(filenameSource); rowCount = 0; while (streamReader != StreamReader.Null) { line = streamReader.ReadLine(); if (line == null) { break; } ++rowCount; if (rowCount < UtilityCommonwealthBankOfAustraliaTransactionArgument.firstRow) { continue; } column = line.Split(','); column[1] = column[1].Replace("\"", ""); Double.TryParse(column[1], out debitCredit); column[2] = column[2].Replace("\"", ""); column[2] = column[2].Replace("'", "''"); commandText = string.Format ( SQLInsert, column[0], debitCredit, column[2], column[3] ); oleDbCommand = new OleDbCommand(commandText, oleDbConnection); rowAffect = oleDbCommand.ExecuteNonQuery(); } if (streamReader != null) { streamReader.Close(); } } } catch (SqlException exception) { UtilityException.ExceptionLog(exception, exception.GetType().Name, ref exceptionMessage); } catch (InvalidOperationException exception) { UtilityException.ExceptionLog(exception, exception.GetType().Name, ref exceptionMessage); } catch (Exception exception) { UtilityException.ExceptionLog(exception, exception.GetType().Name, ref exceptionMessage); } if (oleDbConnection != null) { oleDbConnection.Close(); } }