コード例 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Input card number.");
            var cardnumber = Console.ReadLine();

            try {
                var saldo = RiksLunchenSaldoProvider.GetSaldo(cardnumber);
                PresentBalance(saldo);
            } catch (Exception e) {
                Console.WriteLine("Fel uppstod. Kunde inte hämta saldo.");
            }

            Console.WriteLine("Programkörning avslutad. tryck valfri tangent för att avsluta.");
            Console.ReadKey();
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BalanceData = new RiksLunchenSaldoData();

            var cardnumber = Page.RouteData.Values["cardId"] as string;

            if (cardnumber == null)
            {
                Response.Redirect("index.html");
            }

            IncomingCardNo = cardnumber;
            var success  = false;
            int counter  = 0;
            int maxtries = 10;

            while (!success && counter < maxtries)
            {
                try
                {
                    BalanceData = RiksLunchenSaldoProvider.GetSaldo(cardnumber);
                    success     = true;
                    HasData     = true;
                }
                catch (Exception) { }
                counter++;
            }

            if (BalanceData.lastTopupDate.CompareTo(DateTime.MinValue) == 0)
            {
                HasData = false;
            }

            //     HasData = true;

            panelHasData.Visible   = HasData;
            panelHasNoData.Visible = !HasData;
            panelHasError.Visible  = !BalanceData.valid;
        }