Example #1
0
 public static void ThrowOnInconsistentEventIds(IShipmentEvent oe, IItemIssuanceEvent e)
 {
     if (!oe.ShipmentEventId.ShipmentId.Equals(e.ItemIssuanceEventId.ShipmentId))
     {
         throw DomainError.Named("inconsistentEventIds", "Outer Id ShipmentId {0} but inner id ShipmentId {1}",
                                 oe.ShipmentEventId.ShipmentId, e.ItemIssuanceEventId.ShipmentId);
     }
 }
Example #2
0
        public void Save(IItemIssuanceEvent stateEvent)
        {
            CurrentSession.Save(stateEvent);
            var saveable = stateEvent as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
        }
Example #3
0
        protected void ThrowOnWrongEvent(IItemIssuanceEvent e)
        {
            var id = new System.Text.StringBuilder();

            id.Append("[").Append("ItemIssuance|");

            var stateEntityIdShipmentId = (this as IGlobalIdentity <ShipmentItemIssuanceId>).GlobalId.ShipmentId;
            var eventEntityIdShipmentId = e.ItemIssuanceEventId.ShipmentId;

            if (stateEntityIdShipmentId != eventEntityIdShipmentId)
            {
                throw DomainError.Named("mutateWrongEntity", "Entity Id ShipmentId {0} in state but entity id ShipmentId {1} in event", stateEntityIdShipmentId, eventEntityIdShipmentId);
            }
            id.Append(stateEntityIdShipmentId).Append(",");

            var stateEntityIdItemIssuanceSeqId = (this as IGlobalIdentity <ShipmentItemIssuanceId>).GlobalId.ItemIssuanceSeqId;
            var eventEntityIdItemIssuanceSeqId = e.ItemIssuanceEventId.ItemIssuanceSeqId;

            if (stateEntityIdItemIssuanceSeqId != eventEntityIdItemIssuanceSeqId)
            {
                throw DomainError.Named("mutateWrongEntity", "Entity Id ItemIssuanceSeqId {0} in state but entity id ItemIssuanceSeqId {1} in event", stateEntityIdItemIssuanceSeqId, eventEntityIdItemIssuanceSeqId);
            }
            id.Append(stateEntityIdItemIssuanceSeqId).Append(",");

            id.Append("]");

            if (ForReapplying)
            {
                return;
            }
            var stateVersion = this.Version;
            var stateEvent   = e is IItemIssuanceStateEvent ? (IItemIssuanceStateEvent)e : null;

            if (e == null)
            {
                return;
            }
            stateEvent.Version = stateVersion;
            //var stateEventStateVersion = stateEvent.Version;
            //if (ItemIssuanceState.VersionZero == stateEventStateVersion)
            //{
            //    stateEventStateVersion = stateEvent.Version = stateVersion;
            //}
            //if (stateVersion != stateEventStateVersion)
            //{
            //    throw OptimisticConcurrencyException.Create(stateVersion, stateEventStateVersion, id.ToString());
            //}
        }
 public void AddItemIssuanceEvent(IItemIssuanceEvent e)
 {
     _innerStateEvents.Add((ItemIssuanceStateCreatedOrMergePatchedOrRemovedDto)e);
 }
Example #5
0
        protected virtual IShipmentStateMergePatched Map(IMergePatchShipment c)
        {
            var stateEventId             = new ShipmentEventId(c.ShipmentId, c.Version);
            IShipmentStateMergePatched e = NewShipmentStateMergePatched(stateEventId);

            e.ShipmentTypeId        = c.ShipmentTypeId;
            e.StatusId              = c.StatusId;
            e.PrimaryOrderId        = c.PrimaryOrderId;
            e.PrimaryReturnId       = c.PrimaryReturnId;
            e.PrimaryShipGroupSeqId = c.PrimaryShipGroupSeqId;
            e.PicklistBinId         = c.PicklistBinId;
            e.BolNumber             = c.BolNumber;
            e.SealNumber            = c.SealNumber;
            e.VehicleId             = c.VehicleId;
            e.ExternalOrderNumber   = c.ExternalOrderNumber;
            e.Carrier                    = c.Carrier;
            e.DateShipped                = c.DateShipped;
            e.EstimatedReadyDate         = c.EstimatedReadyDate;
            e.EstimatedShipDate          = c.EstimatedShipDate;
            e.EstimatedShipWorkEffId     = c.EstimatedShipWorkEffId;
            e.EstimatedArrivalDate       = c.EstimatedArrivalDate;
            e.EstimatedArrivalWorkEffId  = c.EstimatedArrivalWorkEffId;
            e.LatestCancelDate           = c.LatestCancelDate;
            e.EstimatedShipCost          = c.EstimatedShipCost;
            e.CurrencyUomId              = c.CurrencyUomId;
            e.HandlingInstructions       = c.HandlingInstructions;
            e.OriginFacilityId           = c.OriginFacilityId;
            e.DestinationFacilityId      = c.DestinationFacilityId;
            e.OriginContactMechId        = c.OriginContactMechId;
            e.OriginTelecomNumberId      = c.OriginTelecomNumberId;
            e.DestinationContactMechId   = c.DestinationContactMechId;
            e.DestinationTelecomNumberId = c.DestinationTelecomNumberId;
            e.PartyIdTo                  = c.PartyIdTo;
            e.PartyIdFrom                = c.PartyIdFrom;
            e.AdditionalShippingCharge   = c.AdditionalShippingCharge;
            e.AddtlShippingChargeDesc    = c.AddtlShippingChargeDesc;
            e.Active = c.Active;
            e.IsPropertyShipmentTypeIdRemoved        = c.IsPropertyShipmentTypeIdRemoved;
            e.IsPropertyStatusIdRemoved              = c.IsPropertyStatusIdRemoved;
            e.IsPropertyPrimaryOrderIdRemoved        = c.IsPropertyPrimaryOrderIdRemoved;
            e.IsPropertyPrimaryReturnIdRemoved       = c.IsPropertyPrimaryReturnIdRemoved;
            e.IsPropertyPrimaryShipGroupSeqIdRemoved = c.IsPropertyPrimaryShipGroupSeqIdRemoved;
            e.IsPropertyPicklistBinIdRemoved         = c.IsPropertyPicklistBinIdRemoved;
            e.IsPropertyBolNumberRemoved             = c.IsPropertyBolNumberRemoved;
            e.IsPropertySealNumberRemoved            = c.IsPropertySealNumberRemoved;
            e.IsPropertyVehicleIdRemoved             = c.IsPropertyVehicleIdRemoved;
            e.IsPropertyExternalOrderNumberRemoved   = c.IsPropertyExternalOrderNumberRemoved;
            e.IsPropertyCarrierRemoved                    = c.IsPropertyCarrierRemoved;
            e.IsPropertyDateShippedRemoved                = c.IsPropertyDateShippedRemoved;
            e.IsPropertyEstimatedReadyDateRemoved         = c.IsPropertyEstimatedReadyDateRemoved;
            e.IsPropertyEstimatedShipDateRemoved          = c.IsPropertyEstimatedShipDateRemoved;
            e.IsPropertyEstimatedShipWorkEffIdRemoved     = c.IsPropertyEstimatedShipWorkEffIdRemoved;
            e.IsPropertyEstimatedArrivalDateRemoved       = c.IsPropertyEstimatedArrivalDateRemoved;
            e.IsPropertyEstimatedArrivalWorkEffIdRemoved  = c.IsPropertyEstimatedArrivalWorkEffIdRemoved;
            e.IsPropertyLatestCancelDateRemoved           = c.IsPropertyLatestCancelDateRemoved;
            e.IsPropertyEstimatedShipCostRemoved          = c.IsPropertyEstimatedShipCostRemoved;
            e.IsPropertyCurrencyUomIdRemoved              = c.IsPropertyCurrencyUomIdRemoved;
            e.IsPropertyHandlingInstructionsRemoved       = c.IsPropertyHandlingInstructionsRemoved;
            e.IsPropertyOriginFacilityIdRemoved           = c.IsPropertyOriginFacilityIdRemoved;
            e.IsPropertyDestinationFacilityIdRemoved      = c.IsPropertyDestinationFacilityIdRemoved;
            e.IsPropertyOriginContactMechIdRemoved        = c.IsPropertyOriginContactMechIdRemoved;
            e.IsPropertyOriginTelecomNumberIdRemoved      = c.IsPropertyOriginTelecomNumberIdRemoved;
            e.IsPropertyDestinationContactMechIdRemoved   = c.IsPropertyDestinationContactMechIdRemoved;
            e.IsPropertyDestinationTelecomNumberIdRemoved = c.IsPropertyDestinationTelecomNumberIdRemoved;
            e.IsPropertyPartyIdToRemoved                  = c.IsPropertyPartyIdToRemoved;
            e.IsPropertyPartyIdFromRemoved                = c.IsPropertyPartyIdFromRemoved;
            e.IsPropertyAdditionalShippingChargeRemoved   = c.IsPropertyAdditionalShippingChargeRemoved;
            e.IsPropertyAddtlShippingChargeDescRemoved    = c.IsPropertyAddtlShippingChargeDescRemoved;
            e.IsPropertyActiveRemoved = c.IsPropertyActiveRemoved;

            e.CommandId = c.CommandId;


            e.CreatedBy = (string)c.RequesterId;
            e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>();

            var version = c.Version;

            foreach (IShipmentImageCommand innerCommand in c.ShipmentImageCommands)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                IShipmentImageEvent innerEvent = Map(innerCommand, c, version, _state);
                e.AddShipmentImageEvent(innerEvent);
            }

            foreach (IShipmentItemCommand innerCommand in c.ShipmentItemCommands)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                IShipmentItemEvent innerEvent = Map(innerCommand, c, version, _state);
                e.AddShipmentItemEvent(innerEvent);
            }

            foreach (IShipmentReceiptCommand innerCommand in c.ShipmentReceiptCommands)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                IShipmentReceiptEvent innerEvent = Map(innerCommand, c, version, _state);
                e.AddShipmentReceiptEvent(innerEvent);
            }

            foreach (IItemIssuanceCommand innerCommand in c.ItemIssuanceCommands)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                IItemIssuanceEvent innerEvent = Map(innerCommand, c, version, _state);
                e.AddItemIssuanceEvent(innerEvent);
            }


            return(e);
        }
Example #6
0
 public virtual void AddItemIssuanceEvent(IItemIssuanceEvent e)
 {
     ThrowOnInconsistentEventIds(e);
     this._itemIssuanceEvents[e.ItemIssuanceEventId] = e;
 }
Example #7
0
 protected void ThrowOnInconsistentEventIds(IItemIssuanceEvent e)
 {
     ThrowOnInconsistentEventIds(this, e);
 }
Example #8
0
 void IShipmentStateMergePatched.AddItemIssuanceEvent(IItemIssuanceEvent e)
 {
     this._itemIssuanceEvents.AddItemIssuanceEvent(e);
 }
 public virtual ItemIssuanceStateCreatedOrMergePatchedOrRemovedDto ToItemIssuanceStateEventDto(IItemIssuanceEvent stateEvent)
 {
     if (stateEvent.EventType == StateEventType.Created)
     {
         var e = (IItemIssuanceStateCreated)stateEvent;
         return(ToItemIssuanceStateCreatedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.MergePatched)
     {
         var e = (IItemIssuanceStateMergePatched)stateEvent;
         return(ToItemIssuanceStateMergePatchedDto(e));
     }
     else if (stateEvent.EventType == StateEventType.Removed)
     {
         var e = (IItemIssuanceStateRemoved)stateEvent;
         return(ToItemIssuanceStateRemovedDto(e));
     }
     throw DomainError.Named("invalidEventType", String.Format("Invalid state event type: {0}", stateEvent.EventType));
 }