Beispiel #1
0
        public RepopulateView(IEnvelopeStreamer serializer, LocalEventStore localEventStore, ShellServices services)
        {
            _services = services;
            _manager  = new DomainQueryManager(serializer, localEventStore, _services);

            InitializeComponent();
            ViewLoad();
        }
Beispiel #2
0
        DirectoryInfo[] ObserveViews(ViewMapInfo[] handlers, DomainQueryManager queryManager)
        {
            WriteLine("Configuring {0} view handlers", handlers.Length);

            var name     = string.Format("view-{0:yyyy-MM-dd-HH-mm-ss}", DateTime.Now);
            var combined = Path.Combine(Path.GetTempPath(), name);

            WriteLine("Redirecting atomic views to {0}", combined);
            var directoryInfo = new DirectoryInfo(combined);

            var file    = FileStorage.CreateConfig(combined, reset: true);
            var nuclear = file.CreateNuclear(new ProjectionStrategy());

            var watch           = Stopwatch.StartNew();
            var projectionTypes = new HashSet <Type>(handlers.Select(v => v.Projection));

            WriteLine("Building consumers...");

            var projections =
                BootstrapProjections.BuildProjectionsWithWhenConvention(nuclear.Factory).Where(
                    x => projectionTypes.Contains(x.GetType()));

            var wire = new RedirectToDynamicEvent();

            foreach (var projection in projections)
            {
                wire.WireToWhen(projection);
            }
            var handlersWatch = Stopwatch.StartNew();


            queryManager.QueryConsumer(envelope => CallHandlers(wire, envelope));
            WriteLine("Saved to {0}.", directoryInfo.FullName);


            var timeTotal      = watch.Elapsed.TotalSeconds;
            var handlerTicks   = handlersWatch.ElapsedTicks;
            var timeInHandlers = Math.Round(TimeSpan.FromTicks(handlerTicks).TotalSeconds, 1);

            WriteLine("Total Elapsed: {0}sec ({1}sec in handlers)", Math.Round(timeTotal, 0), timeInHandlers);

            WriteLine("Saved to {0}.", directoryInfo.FullName);

            var directoryInfos = handlers
                                 .Select(h => _strategy.GetFolderForEntity(h.ViewType, h.KeyType))
                                 .Distinct()
                                 .Select(f => new DirectoryInfo(Path.Combine(directoryInfo.FullName, f.ToString())))
                                 .ToArray();

            return(directoryInfos);
        }