コード例 #1
0
        public override EventStream LoadEventStream(Type eventType, IEventStoreAggregateId eventStoreAggregateId, long version)
        {
            Type supportedEventType = typeof(RolePermissionStateEventBase);

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

            criteria.Add(Restrictions.Eq("StateEventId.IdRoleId", idObj.RoleId));
            criteria.Add(Restrictions.Eq("StateEventId.IdPermissionId", idObj.PermissionId));
            criteria.Add(Restrictions.Le("StateEventId.Version", version));
            criteria.AddOrder(Order.Asc("StateEventId.Version"));
            var es = criteria.List <IEvent>();

            foreach (RolePermissionStateEventBase e in es)
            {
                e.StateEventReadOnly = true;
            }
            return(new EventStream()
            {
                SteamVersion = es.Count > 0 ? ((RolePermissionStateEventBase)es.Last()).StateEventId.Version : default(long),
                Events = es
            });
        }
コード例 #2
0
        public static string ToIdString(RolePermissionId id)
        {
            var formatter = new RolePermissionIdFlattenedDtoFormatter();
            var idDto     = new RolePermissionIdFlattenedDto(id);
            var idStr     = formatter.ToString(idDto);

            return(idStr);
        }
コード例 #3
0
        public IRolePermissionState Get(RolePermissionId id)
        {
            IRolePermissionState state = CurrentSession.Get <RolePermissionState>(id);

            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IRolePermissionState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
コード例 #4
0
        public IRolePermissionState Get(RolePermissionId id)
        {
            IRolePermissionState state = CurrentSession.Get <RolePermissionState> (id);

            if (state == null)
            {
                state = new RolePermissionState();
                (state as RolePermissionState).Id = id;
            }
            return(state);
        }
コード例 #5
0
        public async Task <IRolePermissionStateEvent> GetStateEventAsync(RolePermissionId id, long version)
        {
            var idObj         = RolePermissionProxyUtils.ToIdString(id);
            var uriParameters = new RolePermissionStateEventUriParameters();

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

            var req  = new RolePermissionStateEventGetRequest(uriParameters);
            var resp = await _ramlClient.RolePermissionStateEvent.Get(req);

            RolePermissionProxyUtils.ThrowOnHttpResponseError(resp);
            return(resp.Content);
        }
コード例 #6
0
        public virtual IRolePermissionEvent GetEvent(RolePermissionId id, long version)
        {
            var e = (IRolePermissionEvent)EventStore.GetEvent(ToEventStoreAggregateId(id), version);

            if (e != null)
            {
                e.ReadOnly = true;
            }
            else if (version == -1)
            {
                return(GetEvent(id, 0));
            }
            return(e);
        }
コード例 #7
0
        public IRolePermissionState Get(RolePermissionId id, bool nullAllowed)
        {
            IRolePermissionState state = CurrentSession.Get <RolePermissionState> (id);

            if (!nullAllowed && state == null)
            {
                state = new RolePermissionState();
                (state as RolePermissionState).Id = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IRolePermissionState>(state, new Type[] {  }, _readOnlyPropertyNames));
            }
            return(state);
        }
コード例 #8
0
        public async Task <IRolePermissionState> GetAsync(RolePermissionId id)
        {
            IRolePermissionState state = null;
            var idObj         = RolePermissionProxyUtils.ToIdString(id);
            var uriParameters = new RolePermissionUriParameters();

            uriParameters.Id = idObj;

            var req = new RolePermissionGetRequest(uriParameters);

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

            RolePermissionProxyUtils.ThrowOnHttpResponseError(resp);
            state = resp.Content;
            return(state);
        }
コード例 #9
0
 public IRolePermissionStateEvent GetStateEvent(RolePermissionId id, long version)
 {
     return(GetStateEventAsync(id, version).GetAwaiter().GetResult());
 }
コード例 #10
0
 public IRolePermissionState Get(RolePermissionId id)
 {
     return(GetAsync(id).GetAwaiter().GetResult());
 }
コード例 #11
0
ファイル: RolePermissionEventId.cs プロジェクト: uwitec/wms-8
 public RolePermissionEventId(RolePermissionId id, long version)
 {
     this._id      = id;
     this._version = version;
 }
コード例 #12
0
 public abstract IEventStoreAggregateId ToEventStoreAggregateId(RolePermissionId aggregateId);
コード例 #13
0
        public virtual IRolePermissionState GetHistoryState(RolePermissionId id, long version)
        {
            var eventStream = EventStore.LoadEventStream(typeof(IRolePermissionEvent), ToEventStoreAggregateId(id), version - 1);

            return(new RolePermissionState(eventStream.Events));
        }
コード例 #14
0
        public virtual IRolePermissionState Get(RolePermissionId id)
        {
            var state = StateRepository.Get(id, true);

            return(state);
        }
コード例 #15
0
 public override IEventStoreAggregateId ToEventStoreAggregateId(RolePermissionId aggregateId)
 {
     return(new EventStoreAggregateId(aggregateId));
 }