private void btnTest_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; ProcessOrders po = new ProcessOrders(); string lsResult = ""; po.Process(out lsResult); MessageBox.Show("Orders have been processed. " + lsResult); this.Cursor = Cursors.Default; }
// Main method where the execution begins public static void Main() { try { Console.WriteLine("Do you want to test fixed input or user input? Enter 1 for fixed system input, 2 for user input:"); INPUT_TYPE inputType = (INPUT_TYPE)Convert.ToInt32(Console.ReadLine()); if (inputType != INPUT_TYPE.SYSTEM && inputType != INPUT_TYPE.USER) { throw new Exception("Invalid input! Please enter either 1 or 2."); } List <Product> products = new List <Product>(); if (inputType == INPUT_TYPE.SYSTEM) // System input { Console.WriteLine("Which test case do you want to test? 1, 2, or 3?"); int intTestCase = Convert.ToInt32(Console.ReadLine()); if (intTestCase < 1 || intTestCase > 3) { throw new Exception("Invalid test case! Please enter either 1, 2 or 3."); } products = GetFixedInput(intTestCase); } else // User input { products = GetUserInput(); } if (products.Count <= 0) { throw new Exception("Product list is empty. System is unable to process the orders and generate the invoice."); } ProcessOrders objProcessOrders = new ProcessOrders(products); Invoice objInvoice = objProcessOrders.Process(); objInvoice.Print(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void DoPoll(object state) { bool started = false; try { if (Util.GetBoolean(Util.AppSettingValue("DebugMessages"))) { Log.LogError("Enter DoPoll", "OrderImportService.DoPoll"); } if (!polling) { started = true; polling = true; if (Util.GetBoolean(Util.AppSettingValue("DebugMessages"))) { Log.LogError("Call ProcessOrders.Process()", "OrderImportService.DoPoll", 0); } ProcessOrders loPO = new ProcessOrders(); string lsMessage = ""; bool lbResult = loPO.Process(out lsMessage); polling = false; } } catch (Exception ex) { Log.LogError(ex.ToString(), "OrderImportService.DoPoll", 0); } finally { if (started == true && polling == true) { polling = false; } } }