//
// 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
// Note that for quotes we use in-page script to generate our repeating data for the HTML (based on the List
// returned of QuoteDataUI elements); vs. using databound Repeater controls as we do in the AccountOrders
// (control), Portfolio (page), and MarketSummary (control).
// The choice of display method is up to the architect; Repeaters and GridViews have many features you do not
// get with in-page script; there is however a performance tradeoff (~20% for this page); we opted to use
// in-page script vs. Repeaters/Gridviews here becuase the Quotes page is likely to be the most-often called
// page in the application; we did the same for the OrdersAltert control that is embedded in every authenticaterd
// display page. We utilize Repeaters elsehwhere. Note Trade 6.1 uses in-page JSP script in all pages.
using System;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using Trade.BusinessServiceClient;
using Trade.StockTraderWebApplicationModelClasses;
using Trade.Utility;
namespace Trade.Web
{
///
/// Gets/displays a list of quotes by querying Business Services.
///
public partial class Quotes : System.Web.UI.Page
{
public List quoteList;
protected void Page_Load(object sender, EventArgs e)
{
BSLClient businessServicesClient = new BSLClient();
string requestedSymbols = Input.InputText(Request["symbols"], StockTraderUtility.SYMBOLSTRING_MAXLENGTH);
if (string.IsNullOrEmpty(requestedSymbols)
&& PreviousPage != null)
{
// Get the data posted from another page's PostBackUrl method
TextBox symbolsText = RecursivelyFindControl(PreviousPage.Controls, "symbols") as TextBox;
if (symbolsText != null)
requestedSymbols = symbolsText.Text;
}
if (string.IsNullOrEmpty(requestedSymbols))
{
// if its still null use the default
requestedSymbols = this.symbols.Text;
}
quoteList = businessServicesClient.getQuotes(requestedSymbols);
}
public Control RecursivelyFindControl(ControlCollection controls, string name)
{
foreach(Control c in controls)
{
if (c.ID == name)
return c;
Control resultFromChildren = RecursivelyFindControl(c.Controls, name);
if (resultFromChildren != null)
return resultFromChildren;
}
return null;
}
}
}