Exemple #1
0
        public static string ToIdString(InOutLineId id)
        {
            var formatter = (new ValueObjectTextFormatter <InOutLineId>());
            var idStr     = formatter.ToString(id);

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

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

            criteria.Add(Restrictions.Eq("InOutLineMvoEventId.InOutLineIdInOutDocumentNumber", idObj.InOutDocumentNumber));
            criteria.Add(Restrictions.Eq("InOutLineMvoEventId.InOutLineIdLineNumber", idObj.LineNumber));
            criteria.Add(Restrictions.Le("InOutLineMvoEventId.InOutVersion", version));
            criteria.AddOrder(global::NHibernate.Criterion.Order.Asc("InOutLineMvoEventId.InOutVersion"));
            var es = criteria.List <IEvent>();

            foreach (InOutLineMvoEventBase e in es)
            {
                e.EventReadOnly = true;
            }
            return(new EventStream()
            {
                SteamVersion = es.Count > 0 ? ((InOutLineMvoEventBase)es.Last()).InOutLineMvoEventId.InOutVersion : default(long),
                Events = es
            });
        }
Exemple #3
0
        public static string ToIdString(InOutLineId id)
        {
            var formatter = new InOutLineIdFlattenedDtoFormatter();
            var idDto     = new InOutLineIdFlattenedDto(id);
            var idStr     = formatter.ToString(idDto);

            return(idStr);
        }
        public IInOutLineMvoState Get(InOutLineId id)
        {
            IInOutLineMvoState state = CurrentSession.Get <InOutLineMvoState>(id);

            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IInOutLineMvoState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
Exemple #5
0
        public IInOutLineMvoState Get(InOutLineId id)
        {
            IInOutLineMvoState state = CurrentSession.Get <InOutLineMvoState> (id);

            if (state == null)
            {
                state = new InOutLineMvoState();
                (state as InOutLineMvoState).InOutLineId = id;
            }
            return(state);
        }
Exemple #6
0
        public async Task <IInOutLineMvoState> GetHistoryStateAsync(InOutLineId inOutLineId, long version)
        {
            var idObj         = InOutLineMvoProxyUtils.ToIdString(inOutLineId);
            var uriParameters = new InOutLineMvoHistoryStateUriParameters();

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

            var req  = new InOutLineMvoHistoryStateGetRequest(uriParameters);
            var resp = await _ramlClient.InOutLineMvoHistoryState.Get(req);

            InOutLineMvoProxyUtils.ThrowOnHttpResponseError(resp);
            return((resp.Content == null) ? null : resp.Content.ToInOutLineMvoState());
        }
Exemple #7
0
        public async Task <IInOutLineMvoStateEvent> GetStateEventAsync(InOutLineId inOutLineId, long version)
        {
            var idObj         = InOutLineMvoProxyUtils.ToIdString(inOutLineId);
            var uriParameters = new InOutLineMvoStateEventUriParameters();

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

            var req  = new InOutLineMvoStateEventGetRequest(uriParameters);
            var resp = await _ramlClient.InOutLineMvoStateEvent.Get(req);

            InOutLineMvoProxyUtils.ThrowOnHttpResponseError(resp);
            return(resp.Content);
        }
Exemple #8
0
        public virtual IInOutLineMvoStateEvent GetStateEvent(InOutLineId inOutLineId, long version)
        {
            var e = (IInOutLineMvoStateEvent)EventStore.GetStateEvent(ToEventStoreAggregateId(inOutLineId), version);

            if (e != null)
            {
                e.ReadOnly = true;
            }
            else if (version == -1)
            {
                return(GetStateEvent(inOutLineId, 0));
            }
            return(e);
        }
Exemple #9
0
        public IInOutLineState Get(InOutLineId id, bool nullAllowed)
        {
            IInOutLineState state = CurrentSession.Get <InOutLineState>(id);

            if (!nullAllowed && state == null)
            {
                state = new InOutLineState();
                (state as InOutLineState).InOutLineId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IInOutLineState>(state, new Type[] { typeof(ISaveable) }, _readOnlyPropertyNames));
            }
            return(state);
        }
Exemple #10
0
        public async Task <IInOutLineMvoState> GetAsync(InOutLineId inOutLineId)
        {
            IInOutLineMvoState state = null;
            var idObj         = InOutLineMvoProxyUtils.ToIdString(inOutLineId);
            var uriParameters = new InOutLineMvoUriParameters();

            uriParameters.Id = idObj;

            var req = new InOutLineMvoGetRequest(uriParameters);

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

            InOutLineMvoProxyUtils.ThrowOnHttpResponseError(resp);
            state = (resp.Content == null) ? null : resp.Content.ToInOutLineMvoState();
            return(state);
        }
Exemple #11
0
        public virtual IInOutLineMvoState Get(InOutLineId inOutLineId)
        {
            var state = StateRepository.Get(inOutLineId, true);

            return(state);
        }
Exemple #12
0
 public virtual IInOutLineMvoState GetHistoryState(InOutLineId inOutLineId, long version)
 {
     return(GetHistoryStateAsync(inOutLineId, version).GetAwaiter().GetResult());
 }
Exemple #13
0
 public IInOutLineMvoStateEvent GetStateEvent(InOutLineId inOutLineId, long version)
 {
     return(GetStateEventAsync(inOutLineId, version).GetAwaiter().GetResult());
 }
Exemple #14
0
 public IInOutLineMvoState Get(InOutLineId inOutLineId)
 {
     return(GetAsync(inOutLineId).GetAwaiter().GetResult());
 }
Exemple #15
0
 public InOutLineMvoEventId(InOutLineId inOutLineId, long inOutVersion)
 {
     this._inOutLineId  = inOutLineId;
     this._inOutVersion = inOutVersion;
 }
Exemple #16
0
 public abstract IEventStoreAggregateId ToEventStoreAggregateId(InOutLineId aggregateId);
Exemple #17
0
        public virtual IInOutLineMvoState GetHistoryState(InOutLineId inOutLineId, long version)
        {
            var eventStream = EventStore.LoadEventStream(typeof(IInOutLineMvoStateEvent), ToEventStoreAggregateId(inOutLineId), version - 1);

            return(new InOutLineMvoState(eventStream.Events));
        }
Exemple #18
0
 public override IEventStoreAggregateId ToEventStoreAggregateId(InOutLineId aggregateId)
 {
     return(new EventStoreAggregateId(aggregateId));
 }
Exemple #19
0
        public virtual IInOutLineState GetInOutLine(string inOutDocumentNumber, long lineNumber)
        {
            var entityId = new InOutLineId(inOutDocumentNumber, lineNumber);

            return(CurrentSession.Get <InOutLineState>(entityId));
        }