public static Sale GetSale(string filePath)
        {
            var sale = new Sale();

            sale.Items = SaleLineItemsParser.ParseCSV(filePath).ToList();
            return sale;
        }
        public TransactionAmountForm()
        {
            InitializeComponent();
            Region = Region.FromHrgn(CreateRoundRectRgn(0, 0, this.Width, this.Height, 20, 20));

            Sale = new Sale();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adapted from: http://stackoverflow.com/a/6956513/697567
        /// </summary>
        /// <param name="action"></param>
        private SaleInfo ExecuteWithRetry(SubmitSaleDelegate action, Sale sale, string transactionId)
        {
            const int maxRetries = 5;

            int attempts = 0;

            for (int i = 0; i < maxRetries; i++)
            {
                try
                {
                    return action.Invoke(sale, transactionId);
                }
                catch (WebException ex)
                {
                    if ((maxRetries - i) == 1)
                    { // last iteration

                        this.saleRepository.AddSale(sale, transactionId);

                        throw new CouldNotSubmitSaleException(ex);
                    }

                    // Back-off and retry a bit later, don't just repeatedly hammer the connection
                    Thread.Sleep(SleepTime(attempts));
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return null;
        }
Exemplo n.º 4
0
        public SaleInfo SubmitSale(Sale sale, string transactionId)
        {
            var saleService = new API.Services.SaleService();

            SubmitSaleDelegate s = saleService.SubmitSale;

            return this.ExecuteWithRetry(s, sale, transactionId);
        }
Exemplo n.º 5
0
        public SalesForm(string[][] SaleData)
        {
            InitializeComponent();
            Region = Region.FromHrgn(CreateRoundRectRgn(0, 0, this.Width, this.Height, 20, 20));
            this.BackColor = Color.FromArgb(198, 191, 185);
            WireUpEvents();

            sale = GetSale(SaleData);

            this.Initialize();
        }
Exemplo n.º 6
0
        public SalesForm(List<SalesLineItem> items)
        {
            InitializeComponent();
            Region = Region.FromHrgn(CreateRoundRectRgn(0, 0, this.Width, this.Height, 20, 20));
            this.BackColor = Color.FromArgb(198, 191, 185);
            WireUpEvents();

            this.sale = new Sale()
            {
                Items = items
            };

            this.Initialize();
        }
Exemplo n.º 7
0
        public SalesForm(Sale sale, string writeToPath, string salesFileName, bool externalRedeem = false, bool disableCancellation = false, bool disableSale = false)
        {
            InitializeComponent();
            Region = Region.FromHrgn(CreateRoundRectRgn(0, 0, this.Width, this.Height, 20, 20));

            this.BackColor = Color.FromArgb(198, 191, 185);
            WireUpEvents();

            this.sale = sale;
            this.WriteToPath = writeToPath;
            this.ProcessMode = true;
            this.salesFileName = salesFileName;
            this.ExternalRedeem = externalRedeem;
            this.DisableCancellation = disableCancellation;
            this.DisableSale = disableSale;

            this.Initialize();
        }
Exemplo n.º 8
0
        private Sale GetSale(string[][] SaleData)
        {
            var theSale = new Sale { Items = new List<SalesLineItem>() };

            foreach (var item in SaleData)
            {
                theSale.Items.Add(SaleLineItemsParser.GetSalesLineItem(item));
            }

            return theSale;
        }