Exemple #1
0
        public static void Create(ProjectionsManager manager, string[] commandArgs)
        {
            if (commandArgs.Length < 2)
            {
                Log("Invalid argument value (projection type)");
                return;
            }

            var type = commandArgs[0].Trim().ToLower();
            var queryInfo = GetQueryAndCredentials(commandArgs.Skip(1).ToArray());
            if (queryInfo == null || (type != "onetime" && string.IsNullOrEmpty(queryInfo.Item1)))
            {
                Log("Invalid arguments");
                return;
            }
            var pname = queryInfo.Item1;
            var query = queryInfo.Item2;
            var userCredentials = queryInfo.Item3;

            switch (type)
            {
                case "onetime":
                    Log("Creating onetime projection...");
                    manager.CreateOneTimeAsync(query, userCredentials).Wait();
                    Log("Created");
                    break;
                case "continuous":
                    Log("Creating continuous projection {0}...", pname);
                    manager.CreateContinuousAsync(pname, query, userCredentials).Wait();
                    Log("Created");
                    break;
                default:
                    Log("projection type not recognized");
                    break;
            }
        }