This commit is contained in:
273
server/AyaNova/DataList/HeadOfficeDataList.cs
Normal file
273
server/AyaNova/DataList/HeadOfficeDataList.cs
Normal file
@@ -0,0 +1,273 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using AyaNova.Biz;
|
||||||
|
namespace AyaNova.DataList
|
||||||
|
{
|
||||||
|
internal class HeadOfficeDataList : AyaDataList
|
||||||
|
{
|
||||||
|
public HeadOfficeDataList()
|
||||||
|
{
|
||||||
|
DefaultListObjectType = AyaType.HeadOffice;
|
||||||
|
SQLFrom = "from aheadoffice left outer join acontract on (aheadoffice.contractid=acontract.id)";
|
||||||
|
var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType);
|
||||||
|
AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
|
||||||
|
|
||||||
|
//######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############
|
||||||
|
//Default ListView
|
||||||
|
dynamic dlistView = new JArray();
|
||||||
|
|
||||||
|
dynamic cm = new JObject();
|
||||||
|
cm.fld = "headofficename";
|
||||||
|
cm.sort = "+";
|
||||||
|
dlistView.Add(cm);
|
||||||
|
|
||||||
|
cm = new JObject();
|
||||||
|
cm.fld = "headofficephone1";
|
||||||
|
dlistView.Add(cm);
|
||||||
|
|
||||||
|
cm = new JObject();
|
||||||
|
cm.fld = "headofficeemail";
|
||||||
|
dlistView.Add(cm);
|
||||||
|
DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None);
|
||||||
|
|
||||||
|
|
||||||
|
//NOTE: Due to the join, all the sql id and name fields that can conflict with the joined table need to be specified completely
|
||||||
|
FieldDefinitions = new List<AyaDataListFieldDefinition>();
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "HeadOfficeName",
|
||||||
|
FieldKey = "headofficename",
|
||||||
|
AyaObjectType = (int)AyaType.HeadOffice,
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||||
|
SqlIdColumnName = "aheadoffice.id",
|
||||||
|
SqlValueColumnName = "aheadoffice.name",
|
||||||
|
IsRowId = true
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "HeadOfficeNotes",
|
||||||
|
FieldKey = "headofficenotes",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||||
|
SqlValueColumnName = "aheadoffice.notes"
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "Active",
|
||||||
|
FieldKey = "headofficeactive",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
||||||
|
SqlValueColumnName = "aheadoffice.active"
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "Tags",
|
||||||
|
FieldKey = "headofficetags",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.Tags,
|
||||||
|
SqlValueColumnName = "aheadoffice.tags"
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "WebAddress",
|
||||||
|
FieldKey = "headofficewebaddress",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.HTTP,
|
||||||
|
SqlValueColumnName = "aheadoffice.webaddress"
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "HeadOfficeAccountNumber",
|
||||||
|
FieldKey = "headofficeaccountnumber",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||||
|
SqlValueColumnName = "aheadoffice.accountnumber"
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "UsesBanking",
|
||||||
|
FieldKey = "headofficeusesbanking",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.Bool,
|
||||||
|
SqlValueColumnName = "aheadoffice.usesbanking"
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "Contract",
|
||||||
|
FieldKey = "headofficecontract",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||||
|
AyaObjectType = (int)AyaType.Contract,
|
||||||
|
SqlIdColumnName = "acontract.id",
|
||||||
|
SqlValueColumnName = "acontract.name"
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "ContractExpires",
|
||||||
|
FieldKey = "headofficecontractexpires",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.DateTime,
|
||||||
|
SqlValueColumnName = "aheadoffice.contractexpires"
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "HeadOfficePhone1",
|
||||||
|
FieldKey = "headofficephone1",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.PhoneNumber,
|
||||||
|
SqlValueColumnName = "aheadoffice.phone1"
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "HeadOfficePhone2",
|
||||||
|
FieldKey = "headofficephone2",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.PhoneNumber,
|
||||||
|
SqlValueColumnName = "aheadoffice.phone2"
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "HeadOfficePhone3",
|
||||||
|
FieldKey = "headofficephone3",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.PhoneNumber,
|
||||||
|
SqlValueColumnName = "aheadoffice.phone3"
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "HeadOfficePhone4",
|
||||||
|
FieldKey = "headofficephone4",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.PhoneNumber,
|
||||||
|
SqlValueColumnName = "aheadoffice.phone4"
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "HeadOfficePhone5",
|
||||||
|
FieldKey = "headofficephone5",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.PhoneNumber,
|
||||||
|
SqlValueColumnName = "aheadoffice.phone5"
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "HeadOfficeEmail",
|
||||||
|
FieldKey = "headofficeemail",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.EmailAddress,
|
||||||
|
SqlValueColumnName = "aheadoffice.emailaddress"
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "AddressPostalDeliveryAddress",
|
||||||
|
FieldKey = "headofficepostaddress",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||||
|
SqlValueColumnName = "aheadoffice.postaddress"
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "AddressPostalCity",
|
||||||
|
FieldKey = "headofficepostcity",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||||
|
SqlValueColumnName = "aheadoffice.postcity"
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "AddressPostalStateProv",
|
||||||
|
FieldKey = "headofficepostregion",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||||
|
SqlValueColumnName = "aheadoffice.postregion"
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "AddressPostalCountry",
|
||||||
|
FieldKey = "headofficepostcountry",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||||
|
SqlValueColumnName = "aheadoffice.postcountry"
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "AddressPostalPostal",
|
||||||
|
FieldKey = "headofficepostcode",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||||
|
SqlValueColumnName = "aheadoffice.postcode"
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "AddressDeliveryAddress",
|
||||||
|
FieldKey = "headofficeaddress",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||||
|
SqlValueColumnName = "aheadoffice.address"
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "AddressCity",
|
||||||
|
FieldKey = "headofficecity",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||||
|
SqlValueColumnName = "aheadoffice.city"
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "AddressStateProv",
|
||||||
|
FieldKey = "headofficeregion",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||||
|
SqlValueColumnName = "aheadoffice.region"
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "AddressCountry",
|
||||||
|
FieldKey = "headofficecountry",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
||||||
|
SqlValueColumnName = "aheadoffice.country"
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "AddressLatitude",
|
||||||
|
FieldKey = "headofficelatitude",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.Decimal,
|
||||||
|
SqlValueColumnName = "aheadoffice.latitude"
|
||||||
|
});
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||||
|
{
|
||||||
|
TKey = "AddressLongitude",
|
||||||
|
FieldKey = "headofficelongitude",
|
||||||
|
UiFieldDataType = (int)UiFieldDataType.Decimal,
|
||||||
|
SqlValueColumnName = "aheadoffice.longitude"
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "HeadOfficeCustom1", FieldKey = "headofficecustom1", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aheadoffice.customfields" });
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "HeadOfficeCustom2", FieldKey = "headofficecustom2", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aheadoffice.customfields" });
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "HeadOfficeCustom3", FieldKey = "headofficecustom3", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aheadoffice.customfields" });
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "HeadOfficeCustom4", FieldKey = "headofficecustom4", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aheadoffice.customfields" });
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "HeadOfficeCustom5", FieldKey = "headofficecustom5", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aheadoffice.customfields" });
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "HeadOfficeCustom6", FieldKey = "headofficecustom6", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aheadoffice.customfields" });
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "HeadOfficeCustom7", FieldKey = "headofficecustom7", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aheadoffice.customfields" });
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "HeadOfficeCustom8", FieldKey = "headofficecustom8", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aheadoffice.customfields" });
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "HeadOfficeCustom9", FieldKey = "headofficecustom9", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aheadoffice.customfields" });
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "HeadOfficeCustom10", FieldKey = "headofficecustom10", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aheadoffice.customfields" });
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "HeadOfficeCustom11", FieldKey = "headofficecustom11", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aheadoffice.customfields" });
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "HeadOfficeCustom12", FieldKey = "headofficecustom12", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aheadoffice.customfields" });
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "HeadOfficeCustom13", FieldKey = "headofficecustom13", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aheadoffice.customfields" });
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "HeadOfficeCustom14", FieldKey = "headofficecustom14", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aheadoffice.customfields" });
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "HeadOfficeCustom15", FieldKey = "headofficecustom15", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aheadoffice.customfields" });
|
||||||
|
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "HeadOfficeCustom16", FieldKey = "headofficecustom16", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "aheadoffice.customfields" });
|
||||||
|
}
|
||||||
|
}//eoc
|
||||||
|
}//eons
|
||||||
@@ -41,7 +41,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//CUSTOMER
|
//CUSTOMER
|
||||||
//
|
// (any change copy to customer notes, head office)
|
||||||
roles.Add(AyaType.Customer, new BizRoleSet()
|
roles.Add(AyaType.Customer, new BizRoleSet()
|
||||||
{
|
{
|
||||||
Change = AuthorizationRoles.BizAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.SalesFull | AuthorizationRoles.TechFull | AuthorizationRoles.AccountingFull,
|
Change = AuthorizationRoles.BizAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.SalesFull | AuthorizationRoles.TechFull | AuthorizationRoles.AccountingFull,
|
||||||
@@ -70,7 +70,7 @@ namespace AyaNova.Biz
|
|||||||
});
|
});
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//HeadOffice
|
//HeadOffice (duplicate of customer)
|
||||||
//
|
//
|
||||||
roles.Add(AyaType.HeadOffice, new BizRoleSet()
|
roles.Add(AyaType.HeadOffice, new BizRoleSet()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -154,7 +154,8 @@ namespace AyaNova.Biz
|
|||||||
#region Created processing
|
#region Created processing
|
||||||
//------------------------------
|
//------------------------------
|
||||||
// AyaType Specific created related subscriptions
|
// AyaType Specific created related subscriptions
|
||||||
//
|
// Note: these are for specific things only in this block
|
||||||
|
// generally being created notifications are further down below
|
||||||
switch (newObject.AyaType)
|
switch (newObject.AyaType)
|
||||||
{
|
{
|
||||||
//AyaTypes with their own special notification related events
|
//AyaTypes with their own special notification related events
|
||||||
|
|||||||
@@ -225,6 +225,11 @@ namespace AyaNova.Util
|
|||||||
//CUSTOMERS
|
//CUSTOMERS
|
||||||
await GenSeedCustomerAsync(log, 100);
|
await GenSeedCustomerAsync(log, 100);
|
||||||
|
|
||||||
|
//HEAD-OFFICES
|
||||||
|
await GenSeedHeadOfficeAsync(log, 2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//PERF
|
//PERF
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
await LogStatusAsync(JobId, LogJob, log, $"Small level sample data seeded in {watch.ElapsedMilliseconds} ms");
|
await LogStatusAsync(JobId, LogJob, log, $"Small level sample data seeded in {watch.ElapsedMilliseconds} ms");
|
||||||
@@ -280,6 +285,9 @@ namespace AyaNova.Util
|
|||||||
//CUSTOMERS
|
//CUSTOMERS
|
||||||
await GenSeedCustomerAsync(log, 500);
|
await GenSeedCustomerAsync(log, 500);
|
||||||
|
|
||||||
|
//HEAD-OFFICES
|
||||||
|
await GenSeedHeadOfficeAsync(log, 4);
|
||||||
|
|
||||||
//PERF
|
//PERF
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
await LogStatusAsync(JobId, LogJob, log, $"MEDIUM level sample data seeded in {watch.ElapsedMilliseconds} ms");
|
await LogStatusAsync(JobId, LogJob, log, $"MEDIUM level sample data seeded in {watch.ElapsedMilliseconds} ms");
|
||||||
@@ -351,6 +359,9 @@ namespace AyaNova.Util
|
|||||||
//CUSTOMERS
|
//CUSTOMERS
|
||||||
await GenSeedCustomerAsync(log, 5000);
|
await GenSeedCustomerAsync(log, 5000);
|
||||||
|
|
||||||
|
//HEAD-OFFICES
|
||||||
|
await GenSeedHeadOfficeAsync(log, 8);
|
||||||
|
|
||||||
//PERF
|
//PERF
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
await LogStatusAsync(JobId, LogJob, log, $"LARGE level sample data seeded in {watch.ElapsedMilliseconds} ms");
|
await LogStatusAsync(JobId, LogJob, log, $"LARGE level sample data seeded in {watch.ElapsedMilliseconds} ms");
|
||||||
@@ -422,6 +433,9 @@ namespace AyaNova.Util
|
|||||||
//CUSTOMERS
|
//CUSTOMERS
|
||||||
await GenSeedCustomerAsync(log, 20000);
|
await GenSeedCustomerAsync(log, 20000);
|
||||||
|
|
||||||
|
//HEAD-OFFICES
|
||||||
|
await GenSeedHeadOfficeAsync(log, 16);
|
||||||
|
|
||||||
//PERF
|
//PERF
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
await LogStatusAsync(JobId, LogJob, log, $"HUGE level sample data seeded in {watch.ElapsedMilliseconds} ms");
|
await LogStatusAsync(JobId, LogJob, log, $"HUGE level sample data seeded in {watch.ElapsedMilliseconds} ms");
|
||||||
@@ -637,7 +651,7 @@ namespace AyaNova.Util
|
|||||||
var NewObject = await Biz.CreateAsync(u);
|
var NewObject = await Biz.CreateAsync(u);
|
||||||
if (NewObject == null)
|
if (NewObject == null)
|
||||||
{
|
{
|
||||||
log.LogError($"Seeder::GenSeedUser error creating user {u.Name}\r\n" + Biz.GetErrorsAsString());
|
log.LogError($"Seeder::GenSeedUser error creating {u.Name}\r\n" + Biz.GetErrorsAsString());
|
||||||
throw new System.Exception("Seeder::GenSeedUser error creating user\r\n" + Biz.GetErrorsAsString());
|
throw new System.Exception("Seeder::GenSeedUser error creating user\r\n" + Biz.GetErrorsAsString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -692,7 +706,7 @@ namespace AyaNova.Util
|
|||||||
var NewObject = await biz.CreateAsync(o);
|
var NewObject = await biz.CreateAsync(o);
|
||||||
if (NewObject == null)
|
if (NewObject == null)
|
||||||
{
|
{
|
||||||
log.LogError($"Seeder::GenSeedWidget error creating widget {o.Name}\r\n" + biz.GetErrorsAsString());
|
log.LogError($"Seeder::GenSeedWidget error creating {o.Name}\r\n" + biz.GetErrorsAsString());
|
||||||
throw new System.Exception("Seeder::GenSeedWidget error creating widget\r\n" + biz.GetErrorsAsString());
|
throw new System.Exception("Seeder::GenSeedWidget error creating widget\r\n" + biz.GetErrorsAsString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -706,7 +720,7 @@ namespace AyaNova.Util
|
|||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
//CUSTOMER
|
//CUSTOMER
|
||||||
//
|
//
|
||||||
public async Task GenSeedCustomerAsync(ILogger log, int count)
|
public async Task GenSeedCustomerAsync(ILogger log, int count, long? headOfficeId = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
DateTime seedStartWindow = DateTime.Now.AddYears(-1);
|
DateTime seedStartWindow = DateTime.Now.AddYears(-1);
|
||||||
@@ -733,6 +747,12 @@ namespace AyaNova.Util
|
|||||||
o.WebAddress = Fake.Internet.Url();
|
o.WebAddress = Fake.Internet.Url();
|
||||||
o.EmailAddress = Fake.Internet.ExampleEmail();
|
o.EmailAddress = Fake.Internet.ExampleEmail();
|
||||||
|
|
||||||
|
if (headOfficeId != null)
|
||||||
|
{
|
||||||
|
o.HeadOfficeId = headOfficeId;
|
||||||
|
o.BillHeadOffice = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//This seems wrong to do in a loop but is 4 times faster this way ?!?
|
//This seems wrong to do in a loop but is 4 times faster this way ?!?
|
||||||
@@ -743,7 +763,7 @@ namespace AyaNova.Util
|
|||||||
|
|
||||||
if (NewObject == null)
|
if (NewObject == null)
|
||||||
{
|
{
|
||||||
var err = $"Seeder::GenSeedCustomer error creating customer {o.Name}\r\n{biz.GetErrorsAsString()}";
|
var err = $"Seeder::GenSeedCustomer error creating {o.Name}\r\n{biz.GetErrorsAsString()}";
|
||||||
log.LogError(err);
|
log.LogError(err);
|
||||||
throw new System.Exception(err);
|
throw new System.Exception(err);
|
||||||
}
|
}
|
||||||
@@ -756,6 +776,58 @@ namespace AyaNova.Util
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
//HEADOFFICE
|
||||||
|
//
|
||||||
|
public async Task GenSeedHeadOfficeAsync(ILogger log, int count)
|
||||||
|
{
|
||||||
|
|
||||||
|
DateTime seedStartWindow = DateTime.Now.AddYears(-1);
|
||||||
|
DateTime seedEndWindow = DateTime.Now.AddYears(1);
|
||||||
|
for (int x = 0; x < count; x++)
|
||||||
|
{
|
||||||
|
HeadOffice o = new HeadOffice();
|
||||||
|
o.Name = Uniquify(Fake.Company.CompanyName());
|
||||||
|
o.Active = true;
|
||||||
|
o.Notes = Fake.Company.CatchPhrase();
|
||||||
|
o.Tags = RandomTags();
|
||||||
|
|
||||||
|
o.AccountNumber = Fake.Finance.Account();
|
||||||
|
o.Latitude = (decimal)Fake.Address.Latitude();
|
||||||
|
o.Longitude = (decimal)Fake.Address.Longitude();
|
||||||
|
o.Address = Fake.Address.StreetAddress();
|
||||||
|
o.City = Fake.Address.City();
|
||||||
|
o.Region = Fake.Address.State();
|
||||||
|
o.Country = Fake.Address.Country();
|
||||||
|
|
||||||
|
o.Phone1 = Fake.Phone.PhoneNumber();
|
||||||
|
o.Phone2 = Fake.Phone.PhoneNumber();
|
||||||
|
o.Phone3 = Fake.Phone.PhoneNumber();
|
||||||
|
o.WebAddress = Fake.Internet.Url();
|
||||||
|
o.EmailAddress = Fake.Internet.ExampleEmail();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//This seems wrong to do in a loop but is 4 times faster this way ?!?
|
||||||
|
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||||
|
{
|
||||||
|
HeadOfficeBiz biz = HeadOfficeBiz.GetBiz(ct);
|
||||||
|
var NewObject = await biz.CreateAsync(o);
|
||||||
|
|
||||||
|
if (NewObject == null)
|
||||||
|
{
|
||||||
|
var err = $"Seeder::GenSeedHeadOffice error creating {o.Name}\r\n{biz.GetErrorsAsString()}";
|
||||||
|
log.LogError(err);
|
||||||
|
throw new System.Exception(err);
|
||||||
|
}
|
||||||
|
//HeadOffice contacts
|
||||||
|
await GenSeedUserAsync(log, 1, AuthorizationRoles.CustomerFull, UserType.HeadOffice, true, null, null, 0, null, null, null, NewObject.Id);
|
||||||
|
//HeadOffice Customer
|
||||||
|
await GenSeedCustomerAsync(log, 1, NewObject.Id);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user