private async Task CreateTicketDocumentIfNotExists(int totalDocs) { int index = 100000; while (index < totalDocs) //async Parallel.For(0, totalDocs, index => { try { TicketInfo ts = issueNewTicket(index); await this.client .CreateDocumentAsync( UriFactory.CreateDocumentCollectionUri(dbName, collection) , ts ); if (index % 100 == 0) { Console.WriteLine("Created Document: " + index.ToString()); } //await this.client.ReadDocumentAsync(UriFactory.CreateDocumentUri(databaseName, collectionName, transaction.Id)); } catch (Exception ex) { Console.WriteLine("Index: " + index.ToString() + " Error Occured: " + ex.Message); } finally { index++; } // Thread.Sleep(10000); } }
private TicketInfo issueNewTicket(int id) { string fname = GenerateName(5); string lname = GenerateName(5); string city = cities[id % cities.Length]; TicketInfo ts = new TicketInfo() { Id = id.ToString(), UserId = fname + "@test.com", firstName = fname, lastName = lname, pnr = "tag" + id.ToString(), cityOfOrigin = city }; return(ts); }