//=========================================================================// //EXTERNAL public Int16 LoadArraysFromDisk(out int Bcount, out int Ccount) //=========================================================================// { ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // We iterate through all Bank .BNK files cos we can also read the relevant // Customer # from it, and then load that to the Customer array - Clever eh ? ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Int16 count = 0; Bcount = 0; Ccount = 0; Int32[] custno = new int[100]; int custcount = 0; bool duplicated = false; // start with BankAccounts string dir = BankAccount.ReadBankFilePath(); string dir2 = Customer.GetCustFilePath(); string[] bankfiles = System.IO.Directory.GetFiles(dir, "Bankobject*.bnk"); // initilaize our check array for (int i = 0; i < 100; i++) { custno[i] = 0; } // Iterate trhu them and handle as required foreach (var fi in bankfiles) { bool result = fi.Contains("BankObject"); if (result) { // Got a bank account object BankAccount B = (BankAccount)SerializeData.ReadBankAccountFromDisk(fi); if (B != null) { DataArray.ArrayAddBank(B); // Add to bank ArrayList Bcount++; BankAccount.BankAccountsLinkedList.AddLast(B); Customer C = (Customer)SerializeData.ReadCustomerDiskObject(dir2 + "Custobj" + B.CustAccountNumber + ".cust"); if (C != null) { // add to our test array // check to see if it has been added before ? for (int i = 0; i < custcount; i++) { if (custno[i] == C.CustomerNumber) { duplicated = true; break; } } custno[custcount++] = C.CustomerNumber; if (!duplicated) { DataArray.ArrayAddCust(C); // The one and only Customer ArrayList addition in this Fn() Ccount++; Customer.CustomersLinkedList.AddLast(C); } /* // Handle multiple a/c's held by this customer * if ( C . accountnums [ 1 ] != 0 ) * { * BankAccount Bk = ( BankAccount ) SerializeData . ReadBankAccountFromDisk ( dir + "Bankobject" + C . accountnums [ 1 ] + ".bnk" ); * DataArray . ArrayAddBank ( Bk );// Add to bank ArrayList * Bcount++; * Bk . Dispose ( ); * } * if ( C . accountnums [ 2 ] != 0 ) * { * BankAccount Bk = ( BankAccount ) SerializeData . ReadBankAccountFromDisk ( dir + "Bankobject" + C . accountnums [ 2 ] + ".bnk" ); * DataArray . ArrayAddBank ( Bk );// Add to bank ArrayList * Bcount++; * Bk . Dispose ( ); * } * if ( C . accountnums [ 3 ] != 0 ) * { * BankAccount Bk = ( BankAccount ) SerializeData . ReadBankAccountFromDisk ( dir + "Bankobject" + C . accountnums [ 3 ] + ".bnk" ); * DataArray . ArrayAddBank ( Bk );// Add to bank ArrayList * Bcount++; * Bk . Dispose ( ); * } */ if (C != null) { C.Dispose(); } } if (B != null) { B.Dispose(); } } count++; } } // save our Customer LinkedList to disk as binary and txt files Lists.SaveAllCustomerListData(Customer.CustomerFilePath + "CustSortedListData.cust"); // sort the arrays in Ascending v0 - 9 SortArray.SortBankArray(0); return(count); }