public void Generate() { var random = new Random(); client.PutIndex(new RavenDocumentsByEntityName()); client.PutIndex(new OrdersByCompany()); client.PutIndex(new OrdersTotals()); client.PutIndex(new ProductSales()); client.PutIndex(new OrdersByEmployeeAndCompany()); client.PutIndex(new OrdersByEmployeeAndCompanyReduce()); var nextOrderId = 1; var nextCompanyId = 1; var nextProductId = 1; var nextEmployeeId = 1; for (var it = 0; it < numberOfIterations; it++) { var entities = new List <object>(); for (var i = 0; i < NumberOfOrdersPerIteration; i++) { entities.Add(new Order { Id = "orders/" + nextOrderId++, Company = "companies/" + random.Next(1, ExpectedNumberOfCompanies - 1), Lines = CollectionData.GetElement(10, new List <OrderLine> { new OrderLine { Product = "products/" + random.Next(1, ExpectedNumberOfProducts - 1), Quantity = random.Next(1, 100), PricePerUnit = random.Next(1000) } }).ToList(), Employee = "employees/" + random.Next(1, ExpectedNumberOfEmployees - 1), OrderedAt = DateTimeData.GetDatetime(), RequireAt = DateTime.UtcNow.AddDays(7), ShipTo = new Address { Country = PlaceData.GetCountry(), City = PlaceData.GetCity(), PostalCode = PlaceData.GetZipCode(), Line1 = PlaceData.GetStreetName() } }); } for (var i = 0; i < NumberOfCompaniesPerIteration; i++) { entities.Add(new Company { Id = "companies/" + nextCompanyId++, Name = NameData.GetCompanyName(), Fax = PhoneNumberData.GetInternationalPhoneNumber(), Address = new Address { Country = PlaceData.GetCountry(), City = PlaceData.GetCity(), PostalCode = PlaceData.GetZipCode(), Line1 = PlaceData.GetStreetName() } }); } for (var i = 0; i < NumberOfEmployeesPerIteration; i++) { entities.Add(new Employee { Id = "employees/" + nextEmployeeId++, Birthday = DateTimeData.GetDatetime(), FirstName = NameData.GetFirstName(), LastName = NameData.GetSurname(), HomePhone = PhoneNumberData.GetPhoneNumber(), HiredAt = DateTimeData.GetDatetime(), Address = new Address { Country = PlaceData.GetCountry(), City = PlaceData.GetCity(), PostalCode = PlaceData.GetZipCode(), Line1 = PlaceData.GetStreetName() } }); } for (var i = 0; i < NumberOfProductsPerIteration; i++) { entities.Add(new Product { Id = "products/" + nextProductId++, Category = TextData.GetAlphabetical(5), Name = NameData.GetSurname(), Discontinued = BooleanData.GetBoolean(), PricePerUnit = NumberData.GetNumber() }); } client.PutEntities(entities); } }
public dynamic GetReportData() { // Generating employee list var employees = Enumerable .Range(0, NumberData.GetNumber(10, 50)) .Select(i => { dynamic newEmployee = new ExpandoObject(); newEmployee.BirthDate = DateTimeData.GetDatetime(new DateTime(1973, 1, 1), new DateTime(1997, 12, 1)); newEmployee.FirstName = NameData.GetFirstName(); newEmployee.LastName = NameData.GetSurname(); newEmployee.Company = NameData.GetCompanyName(); newEmployee.Email = NetworkData.GetEmail(); newEmployee.PhoneNumber = PhoneNumberData.GetInternationalPhoneNumber(); newEmployee.Address = string.Format("{0} {1} {2}\n{3},{4} {5}", PlaceData.GetStreetName(), PlaceData.GetStreetNumber(), PlaceData.GetAddress(), PlaceData.GetCity(), PlaceData.GetState(), PlaceData.GetZipCode()); newEmployee.PersonalQuote = TextData.GetSentences(5); // NOTE: Even though ExpandoObject is compatible with IDictionary<string,object>, // The template engine only accepts Dictionary<string,object> return(new Dictionary <string, object>(newEmployee)); }) .ToList(); dynamic reportData = new ExpandoObject(); reportData.Employees = employees; return(reportData); }