Exemple #1
0
        public async Task <IActionResult> List()
        {
            IndexListDto result = new IndexListDto();

            foreach (var meta in indicesMeta.Items)
            {
                var id  = new EventStoreIndexManagerId(meta.GetContractId(), context.Tenant);
                var dto = await _projectionExplorer.ExploreAsync(id, typeof(EventStoreIndexStatus));

                EventStoreIndexStatusState state = dto?.State as EventStoreIndexStatusState;
                var metaIndex = new IndexMeta()
                {
                    IndexContractId = meta.GetContractId(),
                    IndexName       = meta.Name,
                };
                if (ReferenceEquals(null, state))
                {
                    metaIndex.Status = IndexStatus.NotPresent;
                }
                else
                {
                    metaIndex.Status = state.Status;
                }
                result.Indices.Add(metaIndex);
            }

            return(new OkObjectResult(new ResponseResult <IndexListDto>(result)));
        }
Exemple #2
0
        public async Task <IActionResult> List()
        {
            var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies().Where(assembly => assembly.IsDynamic == false);

            var projectionMetaData = loadedAssemblies
                                     .SelectMany(ass => ass.GetLoadableTypes()
                                                 .Where(x => typeof(IProjection).IsAssignableFrom(x) && x.GetCustomAttributes(typeof(DataContractAttribute), false).Length > 0));

            ProjectionListDto result = new ProjectionListDto();

            foreach (var meta in projectionMetaData)
            {
                var id  = new ProjectionVersionManagerId(meta.GetContractId(), context.Tenant);
                var dto = await _projectionExplorer.ExploreAsync(id, typeof(ProjectionVersionsHandler));

                ProjectionVersionsHandlerState state = dto?.State as ProjectionVersionsHandlerState;
                var metaProjection = new ProjectionMeta()
                {
                    ProjectionContractId = meta.GetContractId(),
                    ProjectionName       = meta.Name,
                    IsReplayable         = typeof(IAmEventSourcedProjection).IsAssignableFrom(meta)
                };
                if (ReferenceEquals(null, state))
                {
                    metaProjection.Versions.Add(new ProjectionVersionDto()
                    {
                        Status   = ProjectionStatus.NotPresent,
                        Hash     = projectionHasher.CalculateHash(meta),
                        Revision = 0
                    });
                }
                else
                {
                    foreach (var ver in state.AllVersions)
                    {
                        metaProjection.Versions.Add(new ProjectionVersionDto()
                        {
                            Hash     = ver.Hash,
                            Revision = ver.Revision,
                            Status   = ver.Status
                        });
                    }
                }
                result.Projections.Add(metaProjection);
            }

            return(new OkObjectResult(new ResponseResult <ProjectionListDto>(result)));
        }