Example #1
0
        public override CargoResult Process()
        {
            if (CargoID != null)
            {
                RemovedCargo = _cargoHandler.RemoveStatefulCargo((int)CargoID);
            }
            else
            {
                RemovedCargo = _cargoHandler.RemoveStatefulCargo(CargoType);
            }
            if (RemovedCargo != null)
            {
                ResultCompletionSource.SetResult(CargoResult.Success);
            }
            else
            {
                ResultCompletionSource.SetResult(CargoResult.CargoNotInHolds);
            }


            if (!IsInSequence && ResultTask.Result == CargoResult.Success)
            {
                CloseTransaction();
            }
            return(ResultTask.Result);
        }
Example #2
0
 public override CargoResult Process()
 {
     ResultCompletionSource.SetResult(_cargoHandler.RemoveStatelessCargo(CargoType, Quantity));
     if (!IsInSequence && ResultTask.Result == CargoResult.Success)
     {
         CloseTransaction();
     }
     return(ResultTask.Result);
 }
Example #3
0
        public override void Rollback()
        {
            if (!ResultTask.IsCompleted)
            {
                throw new Exception("Error: attempted to rollback a transaction before it was processed.");
            }

            if (ResultTask.Result != CargoResult.Success)
            {
                return;//This state probably isn't valid, but just in case...
            }
            _cargoHandler.AddStatelessCargo(CargoType, Quantity, true);
            ResultCompletionSource.SetResult(CargoResult.RolledBack);
        }
Example #4
0
        public override CargoResult Process()
        {
            if (CargoObject == null)
            {
                throw new Exception("Error: CargoObject not set in TransactionAddStatefulCargo before processing.");
            }

            ResultCompletionSource.SetResult(_cargoHandler.AddStatefulCargo(CargoObject, suspendBoundsChecking));
            if (!IsInSequence && ResultTask.Result == CargoResult.Success)
            {
                CloseTransaction();
            }
            return(ResultTask.Result);
        }