private IEnumerable <BaseRow> GetRows(O2GSummaryTable table) { var rows = new List <SummaryTableRow>(); for (var i = 0; i < table.Count; i++) { rows.Add(this.GetRow <SummaryTableRow, O2GSummaryTableRow>(table.getRow(i))); } return(rows); }
public Summary(MainForm CurrentForm, O2GTableManager mTblMgr) { CreateTable(); CurrentForm.PopulateTable(SummaryTable); while (mTblMgr.getStatus() != O2GTableManagerStatus.TablesLoaded && mTblMgr.getStatus() != O2GTableManagerStatus.TablesLoadFailed) { Thread.Sleep(50); } O2GSummaryTable table = (O2GSummaryTable)mTblMgr.getTable(O2GTableType.Summary); SummaryListener listener = new SummaryListener(); O2GSummaryTableRow row = null; for (int i = 0; i < table.Count; i++) { DataRow CurrentRow = SummaryTable.NewRow(); SummaryTable.Rows.Add(CurrentRow); } CurrentForm.GetTableData(table, listener, row, mTblMgr); }
// **AFTER LOG IN** // Background worker for table listeners private void priceBW_DoWork(object sender, DoWorkEventArgs e) { Console.WriteLine("Entered BW"); mSession.useTableManager(O2GTableManagerMode.Yes, null); tableManager = mSession.getTableManager(); managerStatus = tableManager.getStatus(); while (managerStatus == O2GTableManagerStatus.TablesLoading) { Thread.Sleep(50); managerStatus = tableManager.getStatus(); } if (managerStatus == O2GTableManagerStatus.TablesLoadFailed) { this.Invoke(new MethodInvoker(delegate { actiBox.AppendText("WARNING: LOADING TABLES FAILED!" + Environment.NewLine); })); return; } // Check Accounts Table and Grab Information try { O2GLoginRules loginRules = mSession.getLoginRules(); Console.WriteLine("Tables are loaded!"); // Check if Accounts table is loaded automatically if (loginRules != null && loginRules.isTableLoadedByDefault(O2GTableType.Accounts)) { // If table is loaded, use getTableRefreshResponse method O2GResponse accountsResponse = loginRules.getTableRefreshResponse(O2GTableType.Accounts); O2GResponseReaderFactory responseFactory = mSession.getResponseReaderFactory(); if (responseFactory != null) { O2GAccountsTableResponseReader accountsReader = responseFactory.createAccountsTableReader(accountsResponse); for (int i = 0; i < accountsReader.Count; i++) { account = accountsReader.getRow(i); accountValue = account.Balance; this.Invoke(new MethodInvoker(delegate { accountValueBox.Text = "$" + Convert.ToString(accountValue); })); acctEq = account.Balance; this.Invoke(new MethodInvoker(delegate { accountLevBox.Text = "$" + Convert.ToString(acctEq); })); this.Invoke(new MethodInvoker(delegate { accountEquityBox.Text = "$" + Convert.ToString(acctEq); })); sAccountID = account.AccountID.ToString(); amountLimit = account.AmountLimit; baseSize = account.BaseUnitSize; if (account.MaintenanceType == "Y") { this.Invoke(new MethodInvoker(delegate { hedgingBox.Text = "Yes"; })); hedgingLong = true; Settings.Default.hedgeLong = true; hedgingShort = true; Settings.Default.hedgeShort = true; this.Invoke(new MethodInvoker(delegate { longCheckBox.Checked = true; })); this.Invoke(new MethodInvoker(delegate { shortCheckBox.Checked = true; })); } else { this.Invoke(new MethodInvoker(delegate { hedgingBox.Text = "No"; })); if (hedgingShort == false) { hedgingLong = true; this.Invoke(new MethodInvoker(delegate { longCheckBox.Checked = true; })); this.Invoke(new MethodInvoker(delegate { shortCheckBox.Checked = false; })); } else { hedgingShort = true; this.Invoke(new MethodInvoker(delegate { longCheckBox.Checked = false; })); this.Invoke(new MethodInvoker(delegate { shortCheckBox.Checked = true; })); } } } } } else { // If table is not loaded, use createRefreshTableRequest method O2GRequestFactory requestFactory = mSession.getRequestFactory(); if (requestFactory != null) { O2GRequest request = requestFactory.createRefreshTableRequest(O2GTableType.Accounts); mSession.sendRequest(request); Thread.Sleep(1000); } } } catch (Exception acctErr) { Console.WriteLine(acctErr); } // Check if all 20 pairs needed are subscribed to on the account. try { O2GLoginRules loginRules = mSession.getLoginRules(); if (loginRules != null && loginRules.isTableLoadedByDefault(O2GTableType.Offers)) { O2GResponse offersResponse = loginRules.getTableRefreshResponse(O2GTableType.Offers); O2GResponseReaderFactory responseFactory = mSession.getResponseReaderFactory(); if (responseFactory != null) { O2GOffersTableResponseReader offersReader = responseFactory.createOffersTableReader(offersResponse); for (int i = 0; i < offersReader.Count; i++) { O2GOfferRow offers = offersReader.getRow(i); string checkOffer = offers.OfferID; } } } } catch (Exception mmrErr) { Console.WriteLine(mmrErr); } Console.WriteLine("Initializing needed table events."); // Initiate Table Getters O2GOffersTable offersTable = (O2GOffersTable)tableManager.getTable(O2GTableType.Offers); accountsTable = (O2GAccountsTable)tableManager.getTable(O2GTableType.Accounts); O2GSummaryTable summaryTable = (O2GSummaryTable)tableManager.getTable(O2GTableType.Summary); O2GClosedTradesTable closedTable = (O2GClosedTradesTable)tableManager.getTable(O2GTableType.ClosedTrades); // Trigger Table Events for Subscription offersTable.RowChanged += new EventHandler <RowEventArgs>(offersTable_RowChanged); accountsTable.RowChanged += new EventHandler <RowEventArgs>(accountsTable_RowChanged); summaryTable.RowChanged += new EventHandler <RowEventArgs>(summaryTable_RowChanged); closedTable.RowChanged += new EventHandler <RowEventArgs>(closedTable_RowChanged); // Check pair subscription status, and add if needed. this.Invoke(new MethodInvoker(delegate { actiBox.AppendText("Connection Established.... Monitoring Pairs..." + Environment.NewLine); })); pastTimer.Start(); }