This commit is contained in:
@@ -56,7 +56,7 @@ If ContractExpires is omitted then it is set to the import date and time minus 1
|
|||||||
|
|
||||||
## JSON file format
|
## JSON file format
|
||||||
|
|
||||||
The .json file must contain an array of Customer objects, so even a single object must be within [] square brackets in the import file.
|
The .json file must contain an array of one or more Customer objects.
|
||||||
|
|
||||||
The first Customer record here illustrates importing a Customer with a link to existing Contract and Head office objects.
|
The first Customer record here illustrates importing a Customer with a link to existing Contract and Head office objects.
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ If ContractExpires is omitted then it is set to the import date and time minus 1
|
|||||||
|
|
||||||
## JSON file format
|
## JSON file format
|
||||||
|
|
||||||
The .json file must contain an array of Head office objects, so even a single object must be within [] square brackets in the import file.
|
The .json file must contain an array of one or more Head office objects.
|
||||||
|
|
||||||
The first Head office record here illustrates importing a Head office with a link to an existing Contract.
|
The first Head office record here illustrates importing a Head office with a link to an existing Contract.
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ The following linked objects are importable / updateable:
|
|||||||
|
|
||||||
## JSON file format
|
## JSON file format
|
||||||
|
|
||||||
The .json file must contain an array of Part assembly objects, so even a single object must be within [] square brackets in the import file.
|
The .json file must contain an array of one or more Part assembly objects.
|
||||||
|
|
||||||
The first Part assembly record here illustrates importing a Part assembly with links to existing Manufacturer, Wholesaler and Alternative Wholesaler and also how to include serial numbers.
|
The first Part assembly record here illustrates importing a Part assembly with links to existing Manufacturer, Wholesaler and Alternative Wholesaler and also how to include serial numbers.
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ The following linked objects are importable / updateable:
|
|||||||
|
|
||||||
## JSON file format
|
## JSON file format
|
||||||
|
|
||||||
The .json file must contain an array of Part objects, so even a single object must be within [] square brackets in the import file.
|
The .json file must contain an array of one or more Part objects.
|
||||||
|
|
||||||
The first Part record here illustrates importing a Part with links to existing Manufacturer, Wholesaler and Alternative Wholesaler and also how to include serial numbers.
|
The first Part record here illustrates importing a Part with links to existing Manufacturer, Wholesaler and Alternative Wholesaler and also how to include serial numbers.
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ The following linked objects are supported for import / update:
|
|||||||
|
|
||||||
## JSON file format
|
## JSON file format
|
||||||
|
|
||||||
The .json file must contain an array of Project objects, so even a single object must be within [] square brackets in the import file.
|
The .json file must contain an array of one or more Project objects.
|
||||||
|
|
||||||
The first Customer record here illustrates importing a Customer with a link to existing Contract and Head office objects.
|
The first Customer record here illustrates importing a Customer with a link to existing Contract and Head office objects.
|
||||||
|
|
||||||
|
|||||||
95
docs/8.0/ayanova/docs/adm-import-service-rate.md
Normal file
95
docs/8.0/ayanova/docs/adm-import-service-rate.md
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
# Service rate import / update specifications
|
||||||
|
|
||||||
|
Names of fields listed here are the exact case and spelling required to be recognized by AyaNova for [importing / updating](adm-import.md).
|
||||||
|
|
||||||
|
Any field in the import file that is not listed on this page will be removed before sending to the server for import.
|
||||||
|
|
||||||
|
## Required fields
|
||||||
|
|
||||||
|
- Name
|
||||||
|
|
||||||
|
## Key field used to match to existing records
|
||||||
|
|
||||||
|
- Name
|
||||||
|
|
||||||
|
## Fields directly importable / updateable
|
||||||
|
|
||||||
|
- Name (import only)
|
||||||
|
- Active
|
||||||
|
- Notes
|
||||||
|
- Wiki
|
||||||
|
- Tags
|
||||||
|
- AccountNumber
|
||||||
|
- Cost
|
||||||
|
- Charge
|
||||||
|
- Unit
|
||||||
|
- ContractOnly
|
||||||
|
|
||||||
|
## JSON file format
|
||||||
|
|
||||||
|
The .json file must contain an array of one or more Service rate objects.
|
||||||
|
|
||||||
|
```JSON
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"Name": "On-site service rate",
|
||||||
|
"Active": true,
|
||||||
|
"Notes": "Ullam et aliquid reiciendis iure voluptatem minus doloremque doloribus ipsum ut.",
|
||||||
|
"Wiki": null,
|
||||||
|
"Tags": [
|
||||||
|
"blue",
|
||||||
|
"brown",
|
||||||
|
"mauve",
|
||||||
|
"quince",
|
||||||
|
"zone6"
|
||||||
|
],
|
||||||
|
"AccountNumber": "55753867",
|
||||||
|
"Cost": 25.410000000000000000,
|
||||||
|
"Charge": 39.390000000000000000,
|
||||||
|
"Unit": "hour",
|
||||||
|
"ContractOnly": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Shop rate",
|
||||||
|
"Active": true,
|
||||||
|
"Notes": "Possimus maiores reprehenderit aut tempora in eos dolor.",
|
||||||
|
"Wiki": null,
|
||||||
|
"Tags": [
|
||||||
|
"blue",
|
||||||
|
"green",
|
||||||
|
"silver",
|
||||||
|
"zone0"
|
||||||
|
],
|
||||||
|
"AccountNumber": "71071010",
|
||||||
|
"Cost": 12.490000000000000000,
|
||||||
|
"Charge": 19.360000000000000000,
|
||||||
|
"Unit": "hour",
|
||||||
|
"ContractOnly": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Day rate",
|
||||||
|
"Active": true,
|
||||||
|
"Notes": "Dolores quo et ipsum ut.",
|
||||||
|
"Wiki": null,
|
||||||
|
"Tags": [
|
||||||
|
"silver"
|
||||||
|
],
|
||||||
|
"AccountNumber": "50669139",
|
||||||
|
"Cost": 300.000000000000000000,
|
||||||
|
"Charge": 500.000000000000000000,
|
||||||
|
"Unit": "day",
|
||||||
|
"ContractOnly": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
## CSV file format
|
||||||
|
|
||||||
|
The first row of the .csv file must contain column headers that match the field names listed above.
|
||||||
|
|
||||||
|
```
|
||||||
|
Name,Active,Notes,Wiki,Tags,AccountNumber,Cost,Charge,Unit,ContractOnly
|
||||||
|
On-site service rate,true,Ullam et aliquid reiciendis iure voluptatem minus doloremque doloribus ipsum ut.,,"blue,brown,mauve,quince,zone6",55753867,25.41,39.39,hour,false
|
||||||
|
Shop rate,true,Possimus maiores reprehenderit aut tempora in eos dolor.,,"blue,green,silver,zone0",71071010,12.49,19.36,hour,true
|
||||||
|
Day rate,true,Dolores quo et ipsum ut.,,silver,50669139,300,500,day,false
|
||||||
|
```
|
||||||
@@ -22,7 +22,7 @@ Any field in the import file that is not listed on this page will be removed bef
|
|||||||
|
|
||||||
## JSON file format
|
## JSON file format
|
||||||
|
|
||||||
The .json file must contain an array of Warehouse objects, so even a single object must be within [] square brackets in the import file.
|
The .json file must contain an array of one or more Warehouse objects.
|
||||||
|
|
||||||
```JSON
|
```JSON
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
//populate viz fields from provided object
|
//populate viz fields from provided object
|
||||||
private async Task PopulateVizFields(Project o)
|
private async Task PopulateVizFields(Project o)
|
||||||
{
|
{
|
||||||
if (o.ProjectOverseerId != null)
|
if (o.ProjectOverseerId != null)
|
||||||
{
|
{
|
||||||
if (!vc.Has("user", o.ProjectOverseerId))
|
if (!vc.Has("user", o.ProjectOverseerId))
|
||||||
@@ -330,24 +330,74 @@ namespace AyaNova.Biz
|
|||||||
public async Task<List<string>> ImportData(AyImportData importData)
|
public async Task<List<string>> ImportData(AyImportData importData)
|
||||||
{
|
{
|
||||||
List<string> ImportResult = new List<string>();
|
List<string> ImportResult = new List<string>();
|
||||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
string ImportTag = ImportUtil.GetImportTag();
|
||||||
|
//ignore these fields
|
||||||
var jsset = JsonSerializer.CreateDefault(new JsonSerializerSettings { ContractResolver = new AyaNova.Util.JsonUtil.ShouldSerializeContractResolver(new string[] { "Concurrency", "Id", "CustomFields" }) });
|
var jsset = JsonSerializer.CreateDefault(new JsonSerializerSettings { ContractResolver = new AyaNova.Util.JsonUtil.ShouldSerializeContractResolver(new string[] { "Concurrency", "Id", "CustomFields" }) });
|
||||||
foreach (JObject j in importData.Data)
|
foreach (JObject j in importData.Data)
|
||||||
{
|
{
|
||||||
var w = j.ToObject<Project>(jsset);
|
|
||||||
if (j["CustomFields"] != null)
|
//Compile linked objects if specified
|
||||||
w.CustomFields = j["CustomFields"].ToString();
|
long? ImportProjectOverseer = -1;//default meaning not included / don't set
|
||||||
w.Tags.Add(ImportTag);//so user can find them all and revert later if necessary
|
if (j["ProjectOverseerViz"] != null)
|
||||||
var res = await CreateAsync(w);
|
|
||||||
if (res == null)
|
|
||||||
{
|
{
|
||||||
ImportResult.Add($"* {w.Name} - {this.GetErrorsAsString()}");
|
//something was specified, may be deliberate attempt to null it out so default to that
|
||||||
this.ClearErrors();
|
ImportProjectOverseer = null;
|
||||||
|
if (!JsonUtil.JTokenIsNullOrEmpty(j["ProjectOverseerViz"]))
|
||||||
|
{
|
||||||
|
//a name was specified so attempt to find it
|
||||||
|
ImportProjectOverseer = await ct.User.AsNoTracking().Where(z => z.Name == (string)j["ProjectOverseerViz"]).Select(x => x.Id).FirstOrDefaultAsync();
|
||||||
|
if (ImportProjectOverseer == 0)
|
||||||
|
AddError(ApiErrorCode.NOT_FOUND, "ProjectOverseerViz", $"'{(string)j["ProjectOverseerViz"]}'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
long existingId = await ct.Project.AsNoTracking().Where(z => z.Name == (string)j["Name"]).Select(x => x.Id).FirstOrDefaultAsync();
|
||||||
|
if (existingId == 0)
|
||||||
|
{
|
||||||
|
if (importData.DoImport)
|
||||||
|
{
|
||||||
|
//import this record
|
||||||
|
var Target = j.ToObject<Project>(jsset);
|
||||||
|
Target.Tags.Add(ImportTag);
|
||||||
|
if (ImportProjectOverseer != -1)
|
||||||
|
Target.ProjectOverseerId = ImportProjectOverseer;
|
||||||
|
var res = await CreateAsync(Target);
|
||||||
|
if (res == null)
|
||||||
|
{
|
||||||
|
ImportResult.Add($"❌ {Target.Name}\r\n{this.GetErrorsAsString()}");
|
||||||
|
this.ClearErrors();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImportResult.Add($"✔️ {Target.Name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ImportResult.Add($"{w.Name} - ok");
|
if (importData.DoUpdate)
|
||||||
|
{
|
||||||
|
//update this record with any data provided
|
||||||
|
//load existing record
|
||||||
|
var Target = await GetAsync((long)existingId);
|
||||||
|
var Source = j.ToObject<Project>(jsset);
|
||||||
|
var propertiesToUpdate = j.Properties().Select(p => p.Name).ToList();
|
||||||
|
propertiesToUpdate.Remove("Name");
|
||||||
|
ImportUtil.Update(Source, Target, propertiesToUpdate);
|
||||||
|
if (ImportProjectOverseer != -1)
|
||||||
|
Target.ProjectOverseerId = ImportProjectOverseer;
|
||||||
|
var res = await PutAsync(Target);
|
||||||
|
if (res == null)
|
||||||
|
{
|
||||||
|
ImportResult.Add($"❌ {Target.Name} - {this.GetErrorsAsString()}");
|
||||||
|
this.ClearErrors();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImportResult.Add($"✔️ {Target.Name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ImportResult;
|
return ImportResult;
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ namespace AyaNova.Biz
|
|||||||
await ValidateCanDeleteAsync(dbObject);
|
await ValidateCanDeleteAsync(dbObject);
|
||||||
if (HasErrors)
|
if (HasErrors)
|
||||||
return false;
|
return false;
|
||||||
{
|
{
|
||||||
var IDList = await ct.Review.AsNoTracking().Where(x => x.AType == AyaType.ServiceRate && x.ObjectId == id).Select(x => x.Id).ToListAsync();
|
var IDList = await ct.Review.AsNoTracking().Where(x => x.AType == AyaType.ServiceRate && x.ObjectId == id).Select(x => x.Id).ToListAsync();
|
||||||
if (IDList.Count() > 0)
|
if (IDList.Count() > 0)
|
||||||
{
|
{
|
||||||
@@ -314,7 +314,7 @@ namespace AyaNova.Biz
|
|||||||
var batchResults = await ct.ServiceRate.AsNoTracking().Where(z => batch.Contains(z.Id)).ToArrayAsync();
|
var batchResults = await ct.ServiceRate.AsNoTracking().Where(z => batch.Contains(z.Id)).ToArrayAsync();
|
||||||
//order the results back into original
|
//order the results back into original
|
||||||
var orderedList = from id in batch join z in batchResults on id equals z.Id select z;
|
var orderedList = from id in batch join z in batchResults on id equals z.Id select z;
|
||||||
batchResults=null;
|
batchResults = null;
|
||||||
foreach (ServiceRate w in orderedList)
|
foreach (ServiceRate w in orderedList)
|
||||||
{
|
{
|
||||||
if (!ReportRenderManager.KeepGoing(jobId)) return null;
|
if (!ReportRenderManager.KeepGoing(jobId)) return null;
|
||||||
@@ -323,7 +323,7 @@ namespace AyaNova.Biz
|
|||||||
jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]);
|
jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]);
|
||||||
ReportData.Add(jo);
|
ReportData.Add(jo);
|
||||||
}
|
}
|
||||||
orderedList=null;
|
orderedList = null;
|
||||||
}
|
}
|
||||||
return ReportData;
|
return ReportData;
|
||||||
}
|
}
|
||||||
@@ -343,28 +343,56 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public async Task<List<string>> ImportData(AyImportData importData)
|
public async Task<List<string>> ImportData(AyImportData importData)
|
||||||
{
|
{
|
||||||
List<string> ImportResult = new List<string>();
|
List<string> ImportResult = new List<string>();
|
||||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
string ImportTag = ImportUtil.GetImportTag();
|
||||||
|
//ignore these fields
|
||||||
var jsset = JsonSerializer.CreateDefault(new JsonSerializerSettings { ContractResolver = new AyaNova.Util.JsonUtil.ShouldSerializeContractResolver(new string[] { "Concurrency", "Id", "CustomFields" }) });
|
var jsset = JsonSerializer.CreateDefault(new JsonSerializerSettings { ContractResolver = new AyaNova.Util.JsonUtil.ShouldSerializeContractResolver(new string[] { "Concurrency", "Id", "CustomFields" }) });
|
||||||
foreach (JObject j in importData.Data)
|
foreach (JObject j in importData.Data)
|
||||||
{
|
{
|
||||||
var w = j.ToObject<ServiceRate>(jsset);
|
long existingId = await ct.ServiceRate.AsNoTracking().Where(z => z.Name == (string)j["Name"]).Select(x => x.Id).FirstOrDefaultAsync();
|
||||||
if (j["CustomFields"] != null)
|
if (existingId == 0)
|
||||||
w.CustomFields = j["CustomFields"].ToString();
|
|
||||||
w.Tags.Add(ImportTag);//so user can find them all and revert later if necessary
|
|
||||||
var res = await CreateAsync(w);
|
|
||||||
if (res == null)
|
|
||||||
{
|
{
|
||||||
ImportResult.Add($"* {w.Name} - {this.GetErrorsAsString()}");
|
if (importData.DoImport)
|
||||||
this.ClearErrors();
|
{
|
||||||
|
//import this record
|
||||||
|
var Target = j.ToObject<ServiceRate>(jsset);
|
||||||
|
Target.Tags.Add(ImportTag);
|
||||||
|
var res = await CreateAsync(Target);
|
||||||
|
if (res == null)
|
||||||
|
{
|
||||||
|
ImportResult.Add($"❌ {Target.Name}\r\n{this.GetErrorsAsString()}");
|
||||||
|
this.ClearErrors();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImportResult.Add($"✔️ {Target.Name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ImportResult.Add($"{w.Name} - ok");
|
if (importData.DoUpdate)
|
||||||
|
{
|
||||||
|
//update this record with any data provided
|
||||||
|
//load existing record
|
||||||
|
var Target = await GetAsync((long)existingId);
|
||||||
|
var Source = j.ToObject<ServiceRate>(jsset);
|
||||||
|
var propertiesToUpdate = j.Properties().Select(p => p.Name).ToList();
|
||||||
|
propertiesToUpdate.Remove("Name");
|
||||||
|
ImportUtil.Update(Source, Target, propertiesToUpdate);
|
||||||
|
var res = await PutAsync(Target);
|
||||||
|
if (res == null)
|
||||||
|
{
|
||||||
|
ImportResult.Add($"❌ {Target.Name} - {this.GetErrorsAsString()}");
|
||||||
|
this.ClearErrors();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ImportResult.Add($"✔️ {Target.Name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ImportResult;
|
return ImportResult;
|
||||||
@@ -466,7 +494,7 @@ namespace AyaNova.Biz
|
|||||||
public async Task HandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
public async Task HandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
||||||
{
|
{
|
||||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<ServiceRateBiz>();
|
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<ServiceRateBiz>();
|
||||||
if(ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
if (ServerBootConfig.SEEDING || ServerBootConfig.MIGRATING) return;
|
||||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{this.BizType}, AyaEvent:{ayaEvent}]");
|
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{this.BizType}, AyaEvent:{ayaEvent}]");
|
||||||
|
|
||||||
bool isNew = currentObj == null;
|
bool isNew = currentObj == null;
|
||||||
|
|||||||
Reference in New Issue
Block a user