public static AccountStatusQueryResult GetAccountReportData(string exchangeCode, Guid accountId, string selectedPrice, string accountXml, HashSet<Guid> instrumentIds) { string instrumentXmlString = GetInstrumentPermisstionString(instrumentIds); AccountStatusQueryResult queryResult = new AccountStatusQueryResult(); string sql = string.Format("exec dbo.P_ReportAccountStatusAllDataForManager @accountId='{0}',@xmlAccounts='{1}',@xmlInstruments='{2}',@queryType='{3}'", accountId, accountXml, instrumentXmlString, selectedPrice); DataAccess.GetInstance(exchangeCode).ExecuteReader(sql, CommandType.Text, delegate(SqlDataReader reader) { while (reader.Read()) { decimal uncleared = Decimal.Zero; Decimal.TryParse(reader["Uncleared"].ToString(), out uncleared); queryResult.AccountStatusEntity.Uncleared = uncleared; } reader.NextResult(); while (reader.Read()) { AccountReportDataHelper.ConvertReportEntity(queryResult.AccountStatusEntity, reader); } reader.NextResult(); while (reader.Read()) { queryResult.AccountStatusEntity.TradeDay = (string)reader["TradeDay"]; } reader.NextResult(); int i = 0; while (reader.Read()) { if (i < 1) { AccountReportDataHelper.ConvertReportEntity(queryResult.AccountTradingSummary, queryResult.AccountCurrencies, reader); } else { AccountReportDataHelper.ConvertReportEntity(null, queryResult.AccountCurrencies, reader); } i++; } reader.NextResult(); while (reader.Read()) { if (reader["OverNightNecessary"] == DBNull.Value) { queryResult.AccountStatusEntity.OverNightNecessary = decimal.Zero; } else { queryResult.AccountStatusEntity.OverNightNecessary = (decimal)(double)reader["OverNightNecessary"]; } } reader.NextResult(); while (reader.Read()) { AccountReportDataHelper.ConvertReportEntity(queryResult.AccountHedgingLevel, reader); } reader.NextResult(); while (reader.Read()) { queryResult.AccountStatusEntity.AccDeposit = (decimal)reader["AccDeposit"]; queryResult.AccountTradingSummary.Deposit = queryResult.AccountStatusEntity.AccDeposit; } reader.NextResult(); while (reader.Read()) { queryResult.AccountStatusEntity.AccAdjustment = (decimal)reader["AccAdjustment"]; queryResult.AccountTradingSummary.Adjustment = queryResult.AccountStatusEntity.AccAdjustment; } reader.NextResult(); //Order Data List<AccountStatusOrder> accountOpenLists = new List<AccountStatusOrder>(); while (reader.Read()) { AccountReportDataHelper.ConvertReportEntity(accountOpenLists, reader); } queryResult.AccountOpenPostions = accountOpenLists; reader.NextResult(); while (reader.Read()) { AccountReportDataHelper.ConvertReportEntity(accountOpenLists, reader); } reader.NextResult(); while (reader.Read()) { } reader.NextResult(); }); return queryResult; }
private void GetAccountReportDataCallback(AccountStatusQueryResult accountQueryData) { this.Dispatcher.BeginInvoke((Action<AccountStatusQueryResult>)delegate(AccountStatusQueryResult result) { this._BusyDecorator.Stop(); if (result == null) return; this._AccountStatusModel = new AccountStatusModel(); this._AccountStatusModel.AccountStatusEntity = result.AccountStatusEntity; this._AccountStatusModel.AccountTradingSummary = result.AccountTradingSummary; this._AccountStatusModel.AccountCurrencies = result.AccountCurrencies; this._AccountStatusModel.AccountHedgingLevel = result.AccountHedgingLevel; this._AccountStatusModel.AccountOpenPostions = result.AccountOpenPostions; this._AccountStatusModel.FillAccountItems(); this.SetBinding(); }, accountQueryData); }