public bool LoadPickups(DateTime pickupDate, string routeClass) { //Load pickup data bool loaded = false; try { //Apply simple business rules //Load pickups for today or a prior day if (pickupDate.CompareTo(DateTime.Today) > 0) { throw new ApplicationException("Pickups cannot be loaded for future dates."); } //Create the TransactionScope to execute the commands, guaranteeing that both commands can commit or roll back as a single unit of work using (TransactionScope scope = new TransactionScope()) { //Load pickups if they haven't been loaded yet DataSet pickups = ReadPickups(pickupDate, routeClass); if (pickups.Tables["PickupTable"].Rows.Count == 0) { loaded = new RoadshowGateway().LoadPickups(pickupDate, routeClass); } //Commits the transaction; if an exception is thrown, Complete is not called and the transaction is rolled back scope.Complete(); } } catch (ApplicationException aex) { throw new FaultException <RoadshowFault>(new RoadshowFault(aex.Message), "Gateway Error"); } catch (Exception ex) { throw new FaultException <RoadshowFault>(new RoadshowFault(ex.Message), "Unexpected Error"); } return(loaded); }
public DataSet GetRoadshowCustomers() { // DataSet customers = null; try { customers = new RoadshowGateway().GetDeliveryPointsCustomers(); } catch (Exception ex) { throw new FaultException <RoadshowFault>(new RoadshowFault(ex.Message), "Service Error"); } return(customers); }
public DataSet GetCustomers() { // DataSet customers = new DataSet(); try { DataSet ds = new RoadshowGateway().GetCustomers(); if (ds != null) { customers.Merge(ds); } } catch (Exception ex) { throw new FaultException <RoadshowFault>(new RoadshowFault(new ApplicationException("Unexpected error while reading customers.", ex))); } return(customers); }
public DataSet ReadPickups(DateTime pickupDate, string routeClass) { // DataSet pickups = new DataSet(); try { DataSet ds = new RoadshowGateway().ReadPickups(pickupDate, routeClass); if (ds != null) { pickups.Merge(ds); } } catch (ApplicationException aex) { throw new FaultException <RoadshowFault>(new RoadshowFault(aex.Message), "Gateway Error"); } catch (Exception ex) { throw new FaultException <RoadshowFault>(new RoadshowFault(ex.Message), "Unexpected Error"); } return(pickups); }
public DataSet GetUpdateUsers(string routeClass) { // DataSet users = new DataSet(); try { DataSet ds = new RoadshowGateway().GetUpdateUsers(routeClass); if (ds != null) { users.Merge(ds); } } catch (ApplicationException aex) { throw new FaultException <RoadshowFault>(new RoadshowFault(aex.Message), "Gateway Error"); } catch (Exception ex) { throw new FaultException <RoadshowFault>(new RoadshowFault(ex.Message), "Unexpected Error"); } return(users); }
public DataSet GetOrderTypes() { // DataSet types = new DataSet(); try { DataSet ds = new RoadshowGateway().GetOrderTypes(); if (ds != null) { types.Merge(ds); } } catch (ApplicationException aex) { throw new FaultException <RoadshowFault>(new RoadshowFault(aex.Message), "Gateway Error"); } catch (Exception ex) { throw new FaultException <RoadshowFault>(new RoadshowFault(ex.Message), "Unexpected Error"); } return(types); }
public Drivers GetDrivers(int depotNumber) { // Drivers drivers = new Drivers(); try { DataSet ds = new RoadshowGateway().GetDispatchDrivers(depotNumber); if (ds != null) { RoadshowDataset _drivers = new RoadshowDataset(); _drivers.Merge(ds); for (int i = 0; i < _drivers.DriverTable.Rows.Count; i++) { drivers.Add(new Driver(_drivers.DriverTable[i])); } } } catch (ApplicationException aex) { throw new FaultException <RoadshowFault>(new RoadshowFault(aex.Message), "Gateway Error"); } catch (Exception ex) { throw new FaultException <RoadshowFault>(new RoadshowFault(ex.Message), "Unexpected Error"); } return(drivers); }
public Customers2 GetCustomers2() { // Customers2 customers = new Customers2(); try { DataSet ds = new RoadshowGateway().GetDispatchCustomers2(); if (ds != null) { RoadshowDataset _customers = new RoadshowDataset(); _customers.Merge(ds); for (int i = 0; i < _customers.CustomerTable.Rows.Count; i++) { customers.Add(new Customer2(_customers.CustomerTable[i])); } } } catch (ApplicationException aex) { throw new FaultException <RoadshowFault>(new RoadshowFault(aex.Message), "Gateway Error"); } catch (Exception ex) { throw new FaultException <RoadshowFault>(new RoadshowFault(ex.Message), "Unexpected Error"); } return(customers); }
public bool AddPickup(Pickup pickup) { // bool added = false; try { //Apply simple business rules //Create the TransactionScope to execute the commands, guaranteeing that both commands can commit or roll back as a single unit of work using (TransactionScope scope = new TransactionScope()) { // added = new RoadshowGateway().CreatePickup(pickup); //Commits the transaction; if an exception is thrown, Complete is not called and the transaction is rolled back scope.Complete(); } } catch (ApplicationException aex) { throw new FaultException <RoadshowFault>(new RoadshowFault(aex.Message), "Gateway Error"); } catch (Exception ex) { throw new FaultException <RoadshowFault>(new RoadshowFault(ex.Message), "Unexpected Error"); } return(added); }