// // Licensed to the Apache Software Foundation (ASF) under one or more // contributor license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright ownership. // The ASF licenses this file to You under the Apache License, Version 2.0 // (the "License"); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // .NET StockTrader Sample WCF Application for Benchmarking, Performance Analysis and Design Considerations for Service-Oriented Applications using System; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI.WebControls; using Trade.BusinessServiceClient; using Trade.StockTraderWebApplicationModelClasses; using Trade.StockTraderWebApplicationSettings; namespace Trade.Web { /// /// Displays Portfolio info for a user, sorted and subtotaled by stock symbol. This is extra functionality /// not implemented by IBM in Trade 6.1. Note the WPF StockTrader.exe smart client app allows this as well, /// although a bit hidden: in the smart client/Windows app, click the sort field for a stock symbol on the Portfolio tab. /// public partial class PortfolioBySymbol : System.Web.UI.Page { public TotalHoldingsUI totalHoldings; protected void Page_Load(object sender, EventArgs e) { BSLClient businessServicesClient = new BSLClient(); string userid = null; totalHoldings = businessServicesClient.getHoldings(userid); var holdingsSubtotaled = from holding in totalHoldings.holdings orderby holding.quoteID group holding by holding.quoteID into holdings select new { quoteID = holdings.Key, quantity = holdings.Sum(h => h.quantityDouble), quotePrice = holdings.First().quotePrice, basis = holdings.Sum(h => h.basisDecimal), marketValue = holdings.Sum(h => h.marketValueDecimal), gain = DataFormatHelper.NumberWithStyledArrow(holdings.Sum(h => h.gainDecimal)), holdings }; PortfolioBySymbolList.DataSource = holdingsSubtotaled; PortfolioBySymbolList.DataBind(); } protected void PortfolioBySymbolList_DataBound(object sender, EventArgs e) { var uniqueLabel = PortfolioBySymbolList.FindControl("numOfUniqueStocks") as Label; if (uniqueLabel != null) { uniqueLabel.Text = PortfolioBySymbolList.Items.Count.ToString(); } } } }