public static string ToIdString(PhysicalInventoryLineId id)
        {
            var formatter = (new ValueObjectTextFormatter <PhysicalInventoryLineId>());
            var idStr     = formatter.ToString(id);

            return(idStr);
        }
示例#2
0
        public override EventStream LoadEventStream(Type eventType, IEventStoreAggregateId eventStoreAggregateId, long version)
        {
            Type supportedEventType = typeof(PhysicalInventoryLineMvoEventBase);

            if (!eventType.IsAssignableFrom(supportedEventType))
            {
                throw new NotSupportedException();
            }
            PhysicalInventoryLineId idObj = (PhysicalInventoryLineId)(eventStoreAggregateId as EventStoreAggregateId).Id;
            var criteria = CurrentSession.CreateCriteria <PhysicalInventoryLineMvoEventBase>();

            criteria.Add(Restrictions.Eq("PhysicalInventoryLineMvoEventId.PhysicalInventoryLineIdPhysicalInventoryDocumentNumber", idObj.PhysicalInventoryDocumentNumber));
            criteria.Add(Restrictions.Eq("PhysicalInventoryLineMvoEventId.PhysicalInventoryLineIdInventoryItemIdProductId", idObj.InventoryItemId.ProductId));
            criteria.Add(Restrictions.Eq("PhysicalInventoryLineMvoEventId.PhysicalInventoryLineIdInventoryItemIdLocatorId", idObj.InventoryItemId.LocatorId));
            criteria.Add(Restrictions.Eq("PhysicalInventoryLineMvoEventId.PhysicalInventoryLineIdInventoryItemIdAttributeSetInstanceId", idObj.InventoryItemId.AttributeSetInstanceId));
            criteria.Add(Restrictions.Le("PhysicalInventoryLineMvoEventId.PhysicalInventoryVersion", version));
            criteria.AddOrder(global::NHibernate.Criterion.Order.Asc("PhysicalInventoryLineMvoEventId.PhysicalInventoryVersion"));
            var es = criteria.List <IEvent>();

            foreach (PhysicalInventoryLineMvoEventBase e in es)
            {
                e.EventReadOnly = true;
            }
            return(new EventStream()
            {
                SteamVersion = es.Count > 0 ? ((PhysicalInventoryLineMvoEventBase)es.Last()).PhysicalInventoryLineMvoEventId.PhysicalInventoryVersion : default(long),
                Events = es
            });
        }
示例#3
0
        public IPhysicalInventoryLineMvoState Get(PhysicalInventoryLineId id)
        {
            IPhysicalInventoryLineMvoState state = CurrentSession.Get <PhysicalInventoryLineMvoState>(id);

            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IPhysicalInventoryLineMvoState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public async Task <IPhysicalInventoryLineMvoState> GetHistoryStateAsync(PhysicalInventoryLineId physicalInventoryLineId, long version)
        {
            var idObj         = PhysicalInventoryLineMvoProxyUtils.ToIdString(physicalInventoryLineId);
            var uriParameters = new PhysicalInventoryLineMvoHistoryStateUriParameters();

            uriParameters.Id      = idObj;
            uriParameters.Version = version.ToString();

            var req  = new PhysicalInventoryLineMvoHistoryStateGetRequest(uriParameters);
            var resp = await _ramlClient.PhysicalInventoryLineMvoHistoryState.Get(req);

            PhysicalInventoryLineMvoProxyUtils.ThrowOnHttpResponseError(resp);
            return((resp.Content == null) ? null : resp.Content.ToPhysicalInventoryLineMvoState());
        }
        public async Task <IPhysicalInventoryLineMvoEvent> GetStateEventAsync(PhysicalInventoryLineId physicalInventoryLineId, long version)
        {
            var idObj         = PhysicalInventoryLineMvoProxyUtils.ToIdString(physicalInventoryLineId);
            var uriParameters = new PhysicalInventoryLineMvoStateEventUriParameters();

            uriParameters.Id      = idObj;
            uriParameters.Version = version.ToString();

            var req  = new PhysicalInventoryLineMvoStateEventGetRequest(uriParameters);
            var resp = await _ramlClient.PhysicalInventoryLineMvoStateEvent.Get(req);

            PhysicalInventoryLineMvoProxyUtils.ThrowOnHttpResponseError(resp);
            return(resp.Content);
        }
示例#6
0
        public virtual IPhysicalInventoryLineMvoEvent GetEvent(PhysicalInventoryLineId physicalInventoryLineId, long version)
        {
            var e = (IPhysicalInventoryLineMvoEvent)EventStore.GetEvent(ToEventStoreAggregateId(physicalInventoryLineId), version);

            if (e != null)
            {
                e.ReadOnly = true;
            }
            else if (version == -1)
            {
                return(GetEvent(physicalInventoryLineId, 0));
            }
            return(e);
        }
示例#7
0
        public IPhysicalInventoryLineMvoState Get(PhysicalInventoryLineId id, bool nullAllowed)
        {
            IPhysicalInventoryLineMvoState state = CurrentSession.Get <PhysicalInventoryLineMvoState> (id);

            if (!nullAllowed && state == null)
            {
                state = new PhysicalInventoryLineMvoState();
                (state as PhysicalInventoryLineMvoState).PhysicalInventoryLineId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IPhysicalInventoryLineMvoState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public async Task <IPhysicalInventoryLineMvoState> GetAsync(PhysicalInventoryLineId physicalInventoryLineId)
        {
            IPhysicalInventoryLineMvoState state = null;
            var idObj         = PhysicalInventoryLineMvoProxyUtils.ToIdString(physicalInventoryLineId);
            var uriParameters = new PhysicalInventoryLineMvoUriParameters();

            uriParameters.Id = idObj;

            var req = new PhysicalInventoryLineMvoGetRequest(uriParameters);

            var resp = await _ramlClient.PhysicalInventoryLineMvo.Get(req);

            PhysicalInventoryLineMvoProxyUtils.ThrowOnHttpResponseError(resp);
            state = (resp.Content == null) ? null : resp.Content.ToPhysicalInventoryLineMvoState();
            return(state);
        }
 public virtual IPhysicalInventoryLineMvoState GetHistoryState(PhysicalInventoryLineId physicalInventoryLineId, long version)
 {
     return(GetHistoryStateAsync(physicalInventoryLineId, version).GetAwaiter().GetResult());
 }
 public IPhysicalInventoryLineMvoState Get(PhysicalInventoryLineId physicalInventoryLineId)
 {
     return(GetAsync(physicalInventoryLineId).GetAwaiter().GetResult());
 }
        public virtual IPhysicalInventoryLineState GetPhysicalInventoryLine(string physicalInventoryDocumentNumber, InventoryItemId inventoryItemId)
        {
            var entityId = new PhysicalInventoryLineId(physicalInventoryDocumentNumber, inventoryItemId);

            return(CurrentSession.Get <PhysicalInventoryLineState>(entityId));
        }
示例#12
0
 public abstract IEventStoreAggregateId ToEventStoreAggregateId(PhysicalInventoryLineId aggregateId);
示例#13
0
        public virtual IPhysicalInventoryLineMvoState GetHistoryState(PhysicalInventoryLineId physicalInventoryLineId, long version)
        {
            var eventStream = EventStore.LoadEventStream(typeof(IPhysicalInventoryLineMvoEvent), ToEventStoreAggregateId(physicalInventoryLineId), version - 1);

            return(new PhysicalInventoryLineMvoState(eventStream.Events));
        }
 public override IEventStoreAggregateId ToEventStoreAggregateId(PhysicalInventoryLineId aggregateId)
 {
     return(new EventStoreAggregateId(aggregateId));
 }
 public IPhysicalInventoryLineMvoEvent GetEvent(PhysicalInventoryLineId physicalInventoryLineId, long version)
 {
     return(GetStateEventAsync(physicalInventoryLineId, version).GetAwaiter().GetResult());
 }
 public PhysicalInventoryLineMvoEventId(PhysicalInventoryLineId physicalInventoryLineId, long physicalInventoryVersion)
 {
     this._physicalInventoryLineId  = physicalInventoryLineId;
     this._physicalInventoryVersion = physicalInventoryVersion;
 }
示例#17
0
        public virtual IPhysicalInventoryLineMvoState Get(PhysicalInventoryLineId physicalInventoryLineId)
        {
            var state = StateRepository.Get(physicalInventoryLineId, true);

            return(state);
        }