private static void AddTestData()
{
var transactRepo = new TransactionRepository();
var custRepo = new CustomerRepository();
var customers = custRepo.GetAllCustomers().ToList();
int productCount = 3;
List<string> prodIDs = new List<string>();
for (int i = 1; i <= productCount; i++)
{
prodIDs.Add("Signature" + i);
}
DateTime minDt = new DateTime(2015, 1, 1, 0, 0, 0, DateTimeKind.Utc);
DateTime maxDt = DateTime.UtcNow;
TimeSpan timeSpan = maxDt - minDt;
var transactionBatch = new List<Transaction>(100);
Stopwatch sw = Stopwatch.StartNew();
for (int i = 0; i < 50000; i++)
{
string prodId = prodIDs[_rand.Next(0, productCount)];
TimeSpan randSpan = new TimeSpan(0, 0, _rand.Next(0, (int)timeSpan.TotalSeconds));
DateTime date = minDt + randSpan;
var curCustomer = customers[_rand.Next(0, customers.Count)];
Guid clientId = curCustomer.InternalID.Value;
int transactDuplicates = _rand.Next(0, 10) >= 9 ? 2 : 1;
Transaction t = new Transaction
{
MvaNumber = curCustomer.MvaNumber,
ExternalRef = curCustomer.ExternalIDs.First(),
//InternalRef = curCustomer.InternalID,
CustomerNumber = curCustomer.CustomerNumber,
Date = date,
Description = "test item",
ProductID = prodId,
Amount = transactDuplicates
};
//transactRepo.AddTransactionToUpdateQueue(t);
transactionBatch.Add(t);
if (i % 100 == 0)
{
transactRepo.AddOrUpdateTransactionBatch(transactionBatch);
transactionBatch.Clear();
Console.WriteLine($"{i} transactions have been added :: {sw.ElapsedMilliseconds} ms");
WriteQueueLengthAsync();
sw.Restart();
}
}
}