This commit is contained in:
@@ -2733,6 +2733,7 @@ namespace AyaNova.Util
|
||||
{
|
||||
DateTime seedStartWindow = DateTime.UtcNow.AddMonths(-3);
|
||||
DateTime seedEndWindow = DateTime.UtcNow.AddMonths(3);
|
||||
bool isPast = false;
|
||||
for (int x = 0; x < count; x++)
|
||||
{
|
||||
WorkOrder o = new WorkOrder();
|
||||
@@ -2743,7 +2744,8 @@ namespace AyaNova.Util
|
||||
var tempDate = Fake.Date.Between(seedStartWindow, seedEndWindow);
|
||||
var tempHour = Fake.Random.Int(9, 17);//9am to 5 pm (except some times may be in different dst state so this will be out by an hour for example depending on time of year and time zone in question)
|
||||
var woDate = DesiredTimeInUtc(new DateTime(tempDate.Year, tempDate.Month, tempDate.Day, tempHour, 0, 0));
|
||||
|
||||
if (woDate < DateTime.UtcNow)
|
||||
isPast = true;
|
||||
o.CreatedDate = woDate > DateTime.UtcNow ? DateTime.UtcNow : woDate;//no created dates in future but want a range of past dates to show off age of wo
|
||||
o.CompleteByDate = woDate.AddDays(5);
|
||||
// o.CustomerContactName = "contact name here";
|
||||
@@ -3202,21 +3204,45 @@ namespace AyaNova.Util
|
||||
Created = ((DateTime)o.ServiceDate).AddHours(2)
|
||||
};
|
||||
o.States.Add(WoState);
|
||||
o.LastStatusId = WoState.WorkOrderStatusId;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//if it's in the past tag it with a completed type status
|
||||
if (isPast)
|
||||
{
|
||||
|
||||
var WoState = new WorkOrderState()
|
||||
{
|
||||
WorkOrderStatusId = (long)Fake.Random.Enum<SeedWOStatus>(SeedWOStatus.Scheduled),
|
||||
UserId = RandomServiceTechUserId(),
|
||||
Created = ((DateTime)o.ServiceDate).AddHours(2)
|
||||
};
|
||||
o.States.Add(WoState);
|
||||
o.LastStatusId = WoState.WorkOrderStatusId;//simulate if user added state to wo so it gets set
|
||||
var WoState = new WorkOrderState()
|
||||
{
|
||||
WorkOrderStatusId = (long)SeedWOStatus.Closed,
|
||||
UserId = RandomServiceTechUserId(),
|
||||
Created = ((DateTime)o.ServiceDate).AddHours(2)
|
||||
};
|
||||
o.States.Add(WoState);
|
||||
o.LastStatusId = WoState.WorkOrderStatusId;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//current-future
|
||||
//10% chance it's not left in a scheduled state
|
||||
//this is because we want to have users be generally available to play with appointments in the schedule form
|
||||
if (Fake.Random.Int(1, 10) == 3)
|
||||
{
|
||||
var WoState = new WorkOrderState()
|
||||
{
|
||||
WorkOrderStatusId = (long)Fake.Random.Enum<SeedWOStatus>(new[] { SeedWOStatus.Scheduled, SeedWOStatus.Closed, SeedWOStatus.ServiceCompleted }),
|
||||
UserId = RandomServiceTechUserId(),
|
||||
Created = ((DateTime)o.ServiceDate).AddHours(2)
|
||||
};
|
||||
o.States.Add(WoState);
|
||||
o.LastStatusId = WoState.WorkOrderStatusId;//simulate if user added state to wo so it gets set
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//This seems wrong to do in a loop but is 4 times faster this way ?!?
|
||||
|
||||
Reference in New Issue
Block a user