/// <summary> /// Find valid account /// </summary> /// <param name="tableManager"></param> /// <returns>account</returns> private static O2GAccountRow GetAccount(O2GTableManager tableManager, string sAccountID) { bool bHasAccount = false; O2GAccountRow account = null; O2GAccountsTable accountsTable = (O2GAccountsTable)tableManager.getTable(O2GTableType.Accounts); for (int i = 0; i < accountsTable.Count; i++) { account = accountsTable.getRow(i); string sAccountKind = account.AccountKind; if (sAccountKind.Equals("32") || sAccountKind.Equals("36")) { if (account.MarginCallFlag.Equals("N")) { if (string.IsNullOrEmpty(sAccountID) || sAccountID.Equals(account.AccountID)) { bHasAccount = true; break; } } } } if (!bHasAccount) { return(null); } else { return(account); } }
private IEnumerable <BaseRow> GetRows(O2GAccountsTable table) { var rows = new List <AccountTableRow>(); for (var i = 0; i < table.Count; i++) { // AccountTableRowEx - so we can get hold of O2GAccountRow internally when needed. rows.Add(this.GetRow <AccountTableRowEx, O2GAccountTableRow>(table.getRow(i))); } return(rows); }
/// <summary> /// Print accounts and get the first account /// </summary> /// <param name="session"></param> /// <returns></returns> private static O2GAccountRow GetAccount(O2GTableManager tableManager) { O2GAccountsTable accountsTable = (O2GAccountsTable)tableManager.getTable(O2GTableType.Accounts); O2GTableIterator accountsIterator = new O2GTableIterator(); O2GAccountTableRow accountRow = null; accountsTable.getNextRow(accountsIterator, out accountRow); while (accountRow != null) { Console.WriteLine("AccountID: {0}, Balance: {1}", accountRow.AccountID, accountRow.Balance); accountsTable.getNextRow(accountsIterator, out accountRow); } return(accountsTable.getRow(0)); }