/// <summary> /// Cancels action. Returns to previous view. /// </summary> public async void PopulateAccounts(object passwordEntry) { // Retrieve password from entry var passwordBox = passwordEntry as PasswordBox; var password = passwordBox?.Password; // Reset account retrieval failed indicator AccountRetrievalFailed = false; // Clear current list of accounts AvailableAccounts = null; // Form Credentials var fiCredentials = new OFX.Types.Credentials(FinancialInstitutionUsername, password); try { // Retrieve accounts from fI AvailableAccounts = await UpdateService.EnumerateNewAccounts(SelectedFinancialInstitution, fiCredentials) .ConfigureAwait(false); // If no accounts were retrieved, notify user NoAccountsRetrieved = !AvailableAccounts.Any(); } catch (Exception) { // Error retrieving accounts AccountRetrievalFailed = true; } }
/// <summary> /// Handles the SelectionChanged event of the btnAddAccount control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected new void btnAddAccount_SelectionChanged(object sender, EventArgs e) { btnAddAccount = ((ButtonDropDownList)RockTransactionEntry.FindControl("btnAddAccount")); var selected = AvailableAccounts.Where(a => a.Id == (btnAddAccount.SelectedValueAsId() ?? 0)).ToList(); AvailableAccounts = AvailableAccounts.Except(selected).ToList(); GetSelectedAccounts().AddRange(selected); }
private void InfoClient_OnInfoAccount(InfoAccount account) { if (account.status == RowStatus.ACTIVE && account.type == AccountType.ACC_NORMAL) { accounts[account.code] = account; //firms.Add(account.firm); AvailableAccounts.Add(account.code); } }
/// <summary> /// Обработчик события получения списка счетов /// </summary> private void AccountResolved(AdapterEventArgs <AccountsReport> args) { args.MarkHandled(); // Инициализируем счета if (args.Message.brokerage != null) { using (accountsLock.WriteLock()) { foreach ( var account in from brokerage in args.Message.brokerage from ss in brokerage.sales_series from account in ss.account select account) { Logger.Debug().PrintFormat("Account resolved: {0};{1};{2}", account.brokerage_account_id, account.account_id, account.name); AddAccount(account.name); accountCodesById[account.account_id] = account.name; accountIdsByCode[account.name] = account.account_id; } } OnMessageReceived( new InitResponseMessage { OrderRouters = new Dictionary <string, string[]> { { ServiceCode, AvailableAccounts.ToArray() } } }); } // Подписываемся на счета var subscription = new TradeSubscription { publication_type = (uint)TradeSubscription.PublicationType.ALL_AUTHORIZED, subscription_scope = { (uint)TradeSubscription.SubscriptionScope.ORDERS, (uint)TradeSubscription.SubscriptionScope.POSITIONS, (uint)TradeSubscription.SubscriptionScope.COLLATERAL }, subscribe = true, id = adapter.GetNextRequestId() }; adapter.SendMessage(subscription); }
private bool TryGetAccount(string accountId, out IbkrAccount account) { var acct = AvailableAccounts.Find(x => x.AccountId == accountId); if (acct != null) { account = acct as IbkrAccount; return(true); } else { account = null; return(false); } }
public ManualImportViewModel PreSelect(int accountId, ImporterType importer) { var selectedAccount = AvailableAccounts.FirstOrDefault(x => x.Value == accountId.ToString(CultureInfo.InvariantCulture)); if (selectedAccount != null) { selectedAccount.Selected = true; } var selectedImporter = AvailableImporters.FirstOrDefault(x => x.Value == importer.ToString()); if (selectedImporter != null) { selectedImporter.Selected = true; } return(this); }
/// <summary> /// Сохраняет свою сделку. /// </summary> /// <param name="fill">Данные своей сделки.</param> protected void AddFill(FillMessage fill) { if (!storeFillsInMemory) { return; } if (!IsPermittedAccount(fill.Account)) { return; } using (SyncRoot.Lock()) { Dictionary <Instrument, List <FillMessage> > accountFills; if (!AvailableAccounts.Contains(fill.Account)) { AvailableAccounts.Add(fill.Account); accountFills = new Dictionary <Instrument, List <FillMessage> >(); Fills.Add(fill.Account, accountFills); } else { accountFills = Fills[fill.Account]; } List <FillMessage> instrumentFills; if (!accountFills.TryGetValue(fill.Instrument, out instrumentFills)) { instrumentFills = new List <FillMessage>(); accountFills.Add(fill.Instrument, instrumentFills); } instrumentFills.Add(fill); } }
protected bool AddAccount(string account) { if (string.IsNullOrWhiteSpace(account)) { return(false); } if (!IsPermittedAccount(account)) { return(false); } using (SyncRoot.Lock()) { if (AvailableAccounts.Contains(account)) { return(false); } AvailableAccounts.Add(account); Fills.Add(account, new Dictionary <Instrument, List <FillMessage> >()); return(true); } }