public bool ChangeClientInboundFreight(ClientInboundFreight freight) { //Change an existing client inbound freight bool changed = false; try { //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()) { //Update appointment changed = new DispatchGateway().UpdateClientInboundFreight(freight); //Blog a notification when appointments arrive if (freight.ActualArrival > DateTime.MinValue) { BlogEntry entry = new BlogEntry(); entry.Date = DateTime.Now; entry.Comment = freight.VendorName + " appt# " + freight.ID.ToString() + " arrived " + freight.ActualArrival.ToString("HH:mm tt") + ", TDS# " + freight.TDSNumber; entry.UserID = "Dispatch"; AddBlogEntry(entry); } //Commits the transaction; if an exception is thrown, Complete is not called and the transaction is rolled back scope.Complete(); } } catch (Exception ex) { throw new FaultException <DispatchFault>(new DispatchFault(ex.Message), "Service Error"); } return(changed); }
public bool CancelLoadTenderEntry(int entryID, DateTime cancelled, string cancelledBy) { // bool result = false; try { //Apply simple business rules LoadTenderEntry entry = ReadLoadTenderEntry(entryID); if (entry.PickupNumber > 0) { //Get the pickup appointment or request and check if picked up if (entry.PickupNumber.ToString().Substring(0, 1) == "1") { ClientInboundFreight appt = null; if (appt != null && appt.ActualArrival != DateTime.MinValue) { throw new ApplicationException("This load tender has already been picked up."); } } else { PickupRequest pickup = null; if (pickup != null && pickup.ActualPickup != DateTime.MinValue) { throw new ApplicationException("This load tender has already been picked up."); } } } //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()) { if (entry.PickupNumber > 0) { //Get the pickup appointment or request and check if picked up if (entry.PickupNumber.ToString().Substring(0, 1) == "1") { //Cancel the pickup appointment new DispatchGateway().CancelClientInboundFreight(entry.PickupNumber, cancelled, cancelledBy); } else { //Cancel the pickup request new DispatchGateway().CancelPickupRequest(entry.PickupNumber, cancelled, cancelledBy); } } //Cancel the load tender entry result = new DispatchGateway().CancelLoadTenderEntry(entryID, cancelled, cancelledBy); //Commits the transaction; if an exception is thrown, Complete is not called and the transaction is rolled back scope.Complete(); } } catch (Exception ex) { throw new FaultException <DispatchFault>(new DispatchFault(ex.Message), "Service Error"); } return(result); }
public bool AddClientInboundFreight(ClientInboundFreight freight) { //Add a new client inbound freight 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 DispatchGateway().InsertClientInboundFreight(freight); //Commits the transaction; if an exception is thrown, Complete is not called and the transaction is rolled back scope.Complete(); } } catch (Exception ex) { throw new FaultException <DispatchFault>(new DispatchFault(ex.Message), "Service Error"); } return(added); }
public bool InsertClientInboundFreight(ClientInboundFreight freight) { //Insert a new client inbound freight into the Client Inbound Schedule bool inserted = false; try { inserted = new DataService().ExecuteNonQuery(SQL_CONNID, USP_CLIENTINBOUND_INSERT, new object[] { freight.Created, freight.CreateUserID, freight.ScheduleDate, freight.VendorName, freight.ConsigneeName, freight.CarrierName, freight.DriverName, freight.TrailerNumber, freight.ScheduledArrival, freight.IsLiveUnload, freight.Amount, freight.AmountType, freight.FreightType, (freight.SortDate != DateTime.MinValue ? freight.SortDate : null as object), freight.Comments, freight.IsTemplate, freight.LastUpdated, freight.UserID }); } catch (Exception ex) { throw new ApplicationException(ex.Message, ex); } return(inserted); }