private void GenerateEcommerceData(int siteID) { var siteName = SiteInfoProvider.GetSiteName(siteID); var currencyInfo = CurrencyInfoProvider.GetCurrencies(siteID) .Where("CurrencyIsMain", QueryOperator.Equals, 1).TopN(1).FirstOrDefault(); var list1 = PaymentOptionInfoProvider.GetPaymentOptions(siteID).ToList(); var list2 = ShippingOptionInfoProvider.GetShippingOptions(siteID).ToList(); var orderStatusList = OrderStatusInfoProvider.GetOrderStatuses(siteID).ToDictionary(status => status.StatusName); var manufacturerExceptionList = new List <int> { ManufacturerInfoProvider.GetManufacturerInfo("Aerobie", siteName).ManufacturerID, //ManufacturerInfoProvider.GetManufacturerInfo("Chemex", siteName).ManufacturerID, //ManufacturerInfoProvider.GetManufacturerInfo("Espro", siteName).ManufacturerID }; var list3 = SKUInfoProvider.GetSKUs(siteID).ToList().Where(sku => { if (sku.IsProduct) { return(!manufacturerExceptionList.Contains(sku.SKUManufacturerID)); } return(false); }).ToList(); int num1; IList <int> intList; if (CustomerInfoProvider.GetCustomers().WhereEquals("CustomerSiteID", siteID).Count < 50) { num1 = customerNames.Length; intList = new List <int>(); for (var index = 0; index < num1; ++index) { intList.Add(GenerateCustomer(customerNames[index], siteID).CustomerID); } } else { intList = DataHelper.GetIntegerValues(CustomerInfoProvider.GetCustomers().Column("CustomerID") .WhereEquals("CustomerSiteID", siteID).WhereNotEquals("CustomerEmail", "alex").Tables[0], "CustomerID"); num1 = intList.Count; } var num2 = 0; var num3 = 0; for (var index1 = 0; index1 <= 30; ++index1) { ++num2; var num4 = 0; if (index1 > 5) { num4 = rand.Next(-1, 2); } for (var index2 = 0; index2 < num2 / 2 + num4; ++index2) { var orderStatusInfo = index1 >= 25 ? index1 >= 29 ? orderStatusList["New"] : orderStatusList["InProgress"] : orderStatusList["Completed"]; var orderInfo = new OrderInfo { OrderCustomerID = intList[num3 % num1], OrderCurrencyID = currencyInfo.CurrencyID, OrderSiteID = siteID, OrderStatusID = orderStatusInfo.StatusID, OrderIsPaid = "Completed".Equals(orderStatusInfo.StatusName, StringComparison.Ordinal) || (uint)rand.Next(0, 2) > 0U, OrderShippingOptionID = list2[rand.Next(list2.Count)].ShippingOptionID, OrderPaymentOptionID = list1[rand.Next(list1.Count)].PaymentOptionID, OrderGrandTotal = decimal.Zero, OrderGrandTotalInMainCurrency = decimal.Zero, OrderTotalPrice = decimal.Zero, OrderTotalPriceInMainCurrency = decimal.Zero, OrderTotalShipping = new decimal(10), OrderTotalTax = new decimal(10) }; OrderInfoProvider.SetOrderInfo(orderInfo); var orderItems = GenerateOrderItems(orderInfo, list3); GenerateOrderAddress(orderInfo.OrderID, GetRandomCountryId(), AddressType.Billing); GenerateOrderAddress(orderInfo.OrderID, GetRandomCountryId(), AddressType.Shipping); orderInfo.OrderDate = DateTime.Now.AddDays(index1 - 30); orderInfo.OrderTotalPrice = orderItems; orderInfo.OrderTotalPriceInMainCurrency = orderItems; orderInfo.OrderGrandTotal = orderItems; orderInfo.OrderGrandTotalInMainCurrency = orderItems; var cartInfoFromOrder = ShoppingCartInfoProvider.GetShoppingCartInfoFromOrder(orderInfo.OrderID); orderInfo.OrderInvoiceNumber = OrderInfoProvider.GenerateInvoiceNumber(cartInfoFromOrder); orderInfo.OrderInvoice = ShoppingCartInfoProvider.GetOrderInvoice(cartInfoFromOrder); OrderInfoProvider.SetOrderInfo(orderInfo); ++num3; } } if (UserInfoProvider.GetUserInfo("alex") != null) { return; } var customerInfo = new CustomerInfo { CustomerEmail = "*****@*****.**", CustomerFirstName = "Alexander", CustomerLastName = "Adams", CustomerSiteID = siteID, CustomerCompany = "Alex & Co. Ltd", CustomerTaxRegistrationID = "12S379BDF798", CustomerOrganizationID = "WRQ7987VRG79" }; CustomerInfoProvider.SetCustomerInfo(customerInfo); var userInfo = CustomerInfoProvider.RegisterCustomer(customerInfo, "", "alex"); var roleInfo = RoleInfoProvider.GetRoleInfo("SilverPartner", siteID); if (roleInfo != null) { UserInfoProvider.AddUserToRole(userInfo.UserID, roleInfo.RoleID); } for (var index = 0; index < 5; ++index) { var cart = new ShoppingCartInfo(); cart.ShoppingCartCulture = CultureHelper.GetDefaultCultureCode(siteName); cart.ShoppingCartCurrencyID = currencyInfo.CurrencyID; cart.ShoppingCartSiteID = siteID; cart.ShoppingCartCustomerID = customerInfo.CustomerID; cart.ShoppingCartBillingAddress = GenerateAddress(GetRandomCountryId(), customerInfo.CustomerID); cart.ShoppingCartShippingAddress = GenerateAddress(GetRandomCountryId(), customerInfo.CustomerID); cart.User = userInfo; ShoppingCartInfoProvider.SetShoppingCartInfo(cart); ShoppingCartInfoProvider.SetShoppingCartItem(cart, new ShoppingCartItemParameters(list3.ElementAt(rand.Next(list3.Count)).SKUID, rand.Next(5))); cart.Evaluate(); ShoppingCartInfoProvider.SetOrder(cart); } }