private decimal GetOutputQuantity(IInventoryPostingRuleState pr, IInventoryItemEntryStateCreated sourceEntry) { var accountName = pr.TriggerAccountName; decimal srcAmount = Convert.ToDecimal(ReflectUtils.GetPropertyValue(accountName, sourceEntry)); return(pr.IsOutputNegated ? -srcAmount : srcAmount); }
public IInventoryPostingRuleState Get(string id) { IInventoryPostingRuleState state = CurrentSession.Get <InventoryPostingRuleState>(id); if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IInventoryPostingRuleState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
private InventoryItemId GetOutputInventoryItemId(IInventoryPostingRuleState pr, InventoryItemId triggerItemId) { var productId = pr.OutputInventoryItemId.ProductId == InventoryItemIds.SameAsSource ? triggerItemId.ProductId : pr.OutputInventoryItemId.ProductId; var locatorId = pr.OutputInventoryItemId.LocatorId == InventoryItemIds.SameAsSource ? triggerItemId.LocatorId : pr.OutputInventoryItemId.LocatorId; var attrInstSetId = pr.OutputInventoryItemId.AttributeSetInstanceId == InventoryItemIds.SameAsSource ? triggerItemId.AttributeSetInstanceId : pr.OutputInventoryItemId.AttributeSetInstanceId; var outputItemId = new InventoryItemId(productId, locatorId, attrInstSetId); return(outputItemId); }
// /////////////////////////////////// private InventoryPRTriggeredId GetOrCreateInventoryPRTriggered(IInventoryPostingRuleState pr, IInventoryItemEntryStateCreated iie) { var createTriggered = new CreateInventoryPRTriggered(); var sourceEntryId = new InventoryItemEntryId(iie.InventoryItemEntryEventId.InventoryItemId, iie.InventoryItemEntryEventId.EntrySeqId); string postingRuleId = pr.InventoryPostingRuleId; var tid = new InventoryPRTriggeredId(sourceEntryId, postingRuleId); createTriggered.InventoryPRTriggeredId = tid; createTriggered.CommandId = Guid.NewGuid().ToString(); createTriggered.IsProcessed = true; // now we use database strong consistency! InventoryPRTriggeredApplicationService.When(createTriggered); return(tid); //todo If existed?? }
public IInventoryPostingRuleState Get(string id, bool nullAllowed) { IInventoryPostingRuleState state = CurrentSession.Get <InventoryPostingRuleState> (id); if (!nullAllowed && state == null) { state = new InventoryPostingRuleState(); (state as InventoryPostingRuleState).InventoryPostingRuleId = id; } if (ReadOnlyProxyGenerator != null && state != null) { return(ReadOnlyProxyGenerator.CreateProxy <IInventoryPostingRuleState>(state, new Type[] { }, _readOnlyPropertyNames)); } return(state); }
public async Task <IInventoryPostingRuleState> GetAsync(string inventoryPostingRuleId) { IInventoryPostingRuleState state = null; var idObj = inventoryPostingRuleId; var uriParameters = new InventoryPostingRuleUriParameters(); uriParameters.Id = idObj; var req = new InventoryPostingRuleGetRequest(uriParameters); var resp = await _ramlClient.InventoryPostingRule.Get(req); InventoryPostingRuleProxyUtils.ThrowOnHttpResponseError(resp); state = (resp.Content == null) ? null : resp.Content.ToInventoryPostingRuleState(); return(state); }
public void Save(IInventoryPostingRuleState state) { IInventoryPostingRuleState s = state; if (ReadOnlyProxyGenerator != null) { s = ReadOnlyProxyGenerator.GetTarget <IInventoryPostingRuleState>(state); } CurrentSession.SaveOrUpdate(s); var saveable = s as ISaveable; if (saveable != null) { saveable.Save(); } CurrentSession.Flush(); }
public override IInventoryPostingRuleAggregate GetInventoryPostingRuleAggregate(IInventoryPostingRuleState state) { return(new InventoryPostingRuleAggregate(state)); }
public static TCreateInventoryPostingRule ToCreateInventoryPostingRule <TCreateInventoryPostingRule>(this IInventoryPostingRuleState state) where TCreateInventoryPostingRule : ICreateInventoryPostingRule, new() { var cmd = new TCreateInventoryPostingRule(); cmd.Version = ((IInventoryPostingRuleStateProperties)state).Version; cmd.InventoryPostingRuleId = state.InventoryPostingRuleId; cmd.TriggerInventoryItemId = state.TriggerInventoryItemId; cmd.OutputInventoryItemId = state.OutputInventoryItemId; cmd.TriggerAccountName = state.TriggerAccountName; cmd.OutputAccountName = state.OutputAccountName; cmd.IsOutputNegated = state.IsOutputNegated; cmd.Active = ((IInventoryPostingRuleStateProperties)state).Active; return(cmd); }
public static TMergePatchInventoryPostingRule ToMergePatchInventoryPostingRule <TMergePatchInventoryPostingRule>(this IInventoryPostingRuleState state) where TMergePatchInventoryPostingRule : IMergePatchInventoryPostingRule, new() { var cmd = new TMergePatchInventoryPostingRule(); cmd.Version = ((IInventoryPostingRuleStateProperties)state).Version; cmd.InventoryPostingRuleId = state.InventoryPostingRuleId; cmd.TriggerInventoryItemId = state.TriggerInventoryItemId; cmd.OutputInventoryItemId = state.OutputInventoryItemId; cmd.TriggerAccountName = state.TriggerAccountName; cmd.OutputAccountName = state.OutputAccountName; cmd.IsOutputNegated = state.IsOutputNegated; cmd.Active = ((IInventoryPostingRuleStateProperties)state).Active; if (state.TriggerInventoryItemId == null) { cmd.IsPropertyTriggerInventoryItemIdRemoved = true; } if (state.OutputInventoryItemId == null) { cmd.IsPropertyOutputInventoryItemIdRemoved = true; } if (state.TriggerAccountName == null) { cmd.IsPropertyTriggerAccountNameRemoved = true; } if (state.OutputAccountName == null) { cmd.IsPropertyOutputAccountNameRemoved = true; } return(cmd); }
public static TDeleteInventoryPostingRule ToDeleteInventoryPostingRule <TDeleteInventoryPostingRule>(this IInventoryPostingRuleState state) where TDeleteInventoryPostingRule : IDeleteInventoryPostingRule, new() { var cmd = new TDeleteInventoryPostingRule(); cmd.InventoryPostingRuleId = state.InventoryPostingRuleId; cmd.Version = ((IInventoryPostingRuleStateProperties)state).Version; return(cmd); }
public static IInventoryPostingRuleCommand ToCreateOrMergePatchInventoryPostingRule <TCreateInventoryPostingRule, TMergePatchInventoryPostingRule>(this IInventoryPostingRuleState state) where TCreateInventoryPostingRule : ICreateInventoryPostingRule, new() where TMergePatchInventoryPostingRule : IMergePatchInventoryPostingRule, new() { bool bUnsaved = ((IInventoryPostingRuleState)state).IsUnsaved; if (bUnsaved) { return(state.ToCreateInventoryPostingRule <TCreateInventoryPostingRule>()); } else { return(state.ToMergePatchInventoryPostingRule <TMergePatchInventoryPostingRule>()); } }
protected bool IsRepeatedCommand(IInventoryPostingRuleCommand command, IEventStoreAggregateId eventStoreAggregateId, IInventoryPostingRuleState state) { bool repeated = false; if (((IInventoryPostingRuleStateProperties)state).Version > command.AggregateVersion) { var lastEvent = EventStore.GetEvent(typeof(IInventoryPostingRuleEvent), eventStoreAggregateId, command.AggregateVersion); if (lastEvent != null && lastEvent.CommandId == command.CommandId) { repeated = true; } } return(repeated); }
private void Persist(IEventStoreAggregateId eventStoreAggregateId, IInventoryPostingRuleAggregate aggregate, IInventoryPostingRuleState state) { EventStore.AppendEvents(eventStoreAggregateId, ((IInventoryPostingRuleStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); }); if (AggregateEventListener != null) { AggregateEventListener.EventAppended(new AggregateEvent <IInventoryPostingRuleAggregate, IInventoryPostingRuleState>(aggregate, state, aggregate.Changes)); } }
public abstract IInventoryPostingRuleAggregate GetInventoryPostingRuleAggregate(IInventoryPostingRuleState state);
public InventoryPostingRuleStateDtoWrapper() { this._state = new InventoryPostingRuleState(); }
public InventoryPostingRuleStateDtoWrapper(IInventoryPostingRuleState state) { this._state = state; }
public InventoryPostingRuleAggregate(IInventoryPostingRuleState state) { _state = state; }