Esempio n. 1
0
        private static void ParseConnectionString(string unparsedConnectionString)
        {
            foreach (var part in unparsedConnectionString.Trim().Split(';'))
            {
                switch (CommandLineUtils.GetKeyFromPart(part.ToLower()))
                {
                case "accountendpoint":
                    _accountEndpoint = CommandLineUtils.GetValueFromPart(part);
                    break;

                case "accountkey":
                    _accountKey = CommandLineUtils.GetValueFromPart(part);
                    break;

                case "apikind":
                    _apiKind = CommandLineUtils.GetValueFromPart(part);
                    break;

                case "database":
                    _database = CommandLineUtils.GetValueFromPart(part);
                    break;

                case "collection":
                    _collection = CommandLineUtils.GetValueFromPart(part);
                    break;

                default:
                    break;
                }
            }
        }
Esempio n. 2
0
        private static void Main(string[] args)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            var resultFromParsing = Parser.Default.ParseArguments <CommandLineOptions>(args);

            if (resultFromParsing.Tag != ParserResultType.Parsed)
            {
                return;
            }

            var result = (Parsed <CommandLineOptions>)resultFromParsing;

            _unparsedConnectionString = result.Value.ConnectionString;
            _rootNodeId = result.Value.RootNode.Trim();
            _batchSize  = result.Value.BatchSize;
            _numberOfNodesOnEachLevel = result.Value.NumberOfNodesOnEachLevel;
            _numberOfTraversals       = result.Value.NumberOfTraversalsToAdd;

            ParseConnectionString(_unparsedConnectionString);

            if (CommandLineUtils.DoWeHaveAllParameters(_apiKind, _accountEndpoint, _accountKey, _database, _collection))
            {
                InitializeCosmosDbAsync().Wait();

                // Insert main hierarchy of nodes and edges as a tree
                InsertNodeAsync(_rootNodeId, string.Empty, string.Empty, 1).Wait();

                // Add random edges to nodes
                InsertRandomEdgesAsync(_rootNodeId, _numberOfTraversals).Wait();

                // Import remaining vertices and edges
                BulkImportToCosmosDbAsync().Wait();
            }
            else
            {
                Console.WriteLine("Check the parameters");
            }

            stopwatch.Stop();
            Console.WriteLine($"Added {_totalElements} graph elements in {stopwatch.ElapsedMilliseconds} ms");
        }