public static void Configure(ProjectionGatewayConfiguration projectionGatewayConfiguration, IPEndPoint httpEndPoint, UserCredentials credentials)
            {
                var projectionManager = new ProjectionsManager(new ConsoleLogger(), httpEndPoint, new TimeSpan(1, 0, 0, 0));
                var byCategoryProjectionStatus = ((JObject)JsonConvert.DeserializeObject(projectionManager.GetStatusAsync("$by_category", credentials).Result))["status"].ToString();
                var streamByCategoryProjectionStatus = ((JObject)JsonConvert.DeserializeObject(projectionManager.GetStatusAsync("$stream_by_category", credentials).Result))["status"].ToString();

                if (byCategoryProjectionStatus == "Stopped")
                {
                    projectionManager.EnableAsync("$by_category", credentials).Wait();
                }

                if (streamByCategoryProjectionStatus == "Stopped")
                {
                    projectionManager.EnableAsync("$stream_by_category", credentials).Wait();
                }
                const string projectionPattern = @"fromCategory('{0}')
                .foreachStream()
                .whenAny(function(state, event){{
                    linkTo('{1}', event);
                }})";

                foreach (var aggregateRootName in projectionGatewayConfiguration.Subscriptions.Keys)
                {
                    projectionManager.CreateContinuousAsync(
                        string.Format("{0}Projection", aggregateRootName),
                        string.Format(projectionPattern, aggregateRootName, aggregateRootName + "View"), credentials).Wait();
                }
            }
Exemple #2
0
        public static void Status(ProjectionsManager manager, string[] commandArgs)
        {
            var nameAndCredentials = GetProjectionNameAndCredentials(commandArgs);
            if (nameAndCredentials == null)
            {
                Log("Invalid arguments, should be: <projection-name> [<login> <password>].");
                return;
            }

            var name = nameAndCredentials.Item1;
            Log("{0} is '{1}'", name, manager.GetStatusAsync(name, nameAndCredentials.Item2).Result);
        }