//
// 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.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using Trade.StockTraderWebApplicationSettings;
using Trade.BusinessServiceClient;
using Trade.StockTraderWebApplicationModelClasses;
namespace Trade.Web
{
///
/// Displays the Market Summary tables using repeaters. Used on TradeHome.aspx. This control should
/// implement output caching as the query for determining stock index is a killer. Trade 6.1 does the same,
/// as no matter the DB (SQL, Oracle, DB/2), the query (as implemented by IBM and also for equivalence by .NET StockTrader)
/// forces a table scan. Fine for a DB with 100 quote symbols loaded;
/// not OK for a table with 100,000 quotes. For the benchmark, both .NET and IBM Trade 6.1 (via Servlet Caching) were
/// configured to cache market summary for 60 seconds---so users get 60-second updates. A good use of caching of read-only data,
/// where user can stand to be seeing data 60 seconds old.
///
public partial class MarketSummary : System.Web.UI.UserControl
{
public MarketSummaryDataUI marketSummaryData = null;
protected override void OnLoad(EventArgs e)
{
BSLClient businessServicesClient = new BSLClient();
marketSummaryData = businessServicesClient.getMarketSummary();
List topGainers = marketSummaryData.topGainers;
List topLosers = marketSummaryData.topLosers;
summaryDate.Text = DateTime.Now.ToString("f");
TSIA.Text = String.Format("{0:N}",marketSummaryData.TSIA);
decimal gainpercent = marketSummaryData.gainPercent;
if (gainpercent > 0)
{
GainPercent.CssClass = Settings.GAINSTYLECSS;
}
else if (gainpercent < 0)
{
GainPercent.CssClass = Settings.LOSSSTYLECSS;
}
GainPercent.Text = String.Format("{0:N}", gainpercent);
Volume.Text = String.Format("{0:N}", marketSummaryData.volume);
TopGainers.DataSource = marketSummaryData.topGainers;
TopLosers.DataSource = marketSummaryData.topLosers;
TopGainers.DataBind();
TopLosers.DataBind();
}
}
}