Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            using (ExchangeService.TradeServiceClient proxy = new ExchangeService.TradeServiceClient())
            {
                Console.WriteLine("\nTrade IBM");
                decimal result = proxy.TradeSecurityAtMarket(MakeTrade("IBM", 1000));
                Console.WriteLine("Cost was " + result);

                Console.WriteLine("\nTrade MSFT");
                result = proxy.TradeSecurityAtMarket(MakeTrade("MSFT", 2000));
                Console.WriteLine("Cost was " + result);

                try
                {
                    Console.WriteLine("\nTrade ATT");
                    result = proxy.TradeSecurityAtMarket(MakeTrade("T", 3000));
                    Console.WriteLine("Cost was " + result);
                }
                catch (Exception ex)
                {
                    Console.Write("Exception was: " + ex.Message);
                }

                Console.WriteLine("\n\nPress <enter> to exit...");
                Console.ReadLine();
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            using (ExchangeService.TradeServiceClient proxy = new ExchangeService.TradeServiceClient())
            {
                Console.WriteLine("wait for Server - Press <Enter> to continue...");
                Console.ReadLine();

                Console.WriteLine("\nTrade IBM");
                decimal result = proxy.TradeSecurityNow("IBM", 1000);
                Console.WriteLine("Cost was " + result);

                Console.WriteLine("\nTrade MSFT");
                result = proxy.TradeSecurityNow("MSFT", 2000);
                Console.WriteLine("Cost was " + result);

                try
                {
                    Console.WriteLine("\nTrade ATT");
                    result = proxy.TradeSecurityNow("T", 3000);
                    Console.WriteLine("Cost was " + result);
                }
                catch (Exception ex)
                {
                    Console.Write("Exception was: " + ex.Message);
                }

                Console.WriteLine("Can't use this proxy anymore as it's had a fault");
                Console.WriteLine("You will now see an exception appear");
                Console.WriteLine("\n\nPress <enter> to exit...");
                Console.ReadLine();

                proxy.Close();
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            try
            {
                using (ExchangeService.TradeServiceClient proxy = new ExchangeService.TradeServiceClient())
                {
                    Console.WriteLine("\nTrade MSFT");
                    ExchangeService.Trade     trade1    = MakeTrade("MSFT", 2000);
                    ExchangeService.Execution execution =
                        proxy.TradeSecurity(
                            trade1.Participant,
                            trade1.Publisher,
                            trade1.Ticker,
                            trade1);

                    Console.WriteLine("Cost was " + execution.ExecutionAmount);
                }
            }
            catch (FaultException <ArgumentException> ex)
            {
                Console.WriteLine("ArgumentException Occured");
                Console.WriteLine("\tAction:\t" + ex.Action);
                Console.WriteLine("\tName:\t" + ex.Code.Name);
                Console.WriteLine("\tMessage:\t" + ex.Detail.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("General Exception");
                Console.WriteLine('\t' + ex.Message);
            }
            Console.WriteLine("\n\nPress <enter> to exit...");
            Console.ReadLine();
        }