This commit is contained in:
2021-03-25 16:47:18 +00:00
parent 58aa697369
commit c92c5424b0

View File

@@ -13,7 +13,7 @@ using Newtonsoft.Json;
namespace AyaNova.Biz namespace AyaNova.Biz
{ {
internal class WorkOrderBiz : BizObject, IJobObject, ISearchAbleObject, IReportAbleObject, IExportAbleObject, IImportAbleObject, INotifiableObject internal class WorkOrderBiz : BizObject, IJobObject, ISearchAbleObject, IReportAbleObject, IExportAbleObject, INotifiableObject
{ {
//Feature specific roles //Feature specific roles
internal static AuthorizationRoles RolesAllowedToChangeSerial = AuthorizationRoles.BizAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.AccountingFull; internal static AuthorizationRoles RolesAllowedToChangeSerial = AuthorizationRoles.BizAdminFull | AuthorizationRoles.DispatchFull | AuthorizationRoles.AccountingFull;
@@ -469,31 +469,31 @@ namespace AyaNova.Biz
return await GetReportData(idList); return await GetReportData(idList);
} }
public async Task<List<string>> ImportData(JArray ja) // public async Task<List<string>> ImportData(JArray ja)
{ // {
List<string> ImportResult = new List<string>(); // List<string> ImportResult = new List<string>();
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}"; // string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
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 ja) // foreach (JObject j in ja)
{ // {
var w = j.ToObject<WorkOrder>(jsset); // var w = j.ToObject<WorkOrder>(jsset);
if (j["CustomFields"] != null) // if (j["CustomFields"] != null)
w.CustomFields = j["CustomFields"].ToString(); // w.CustomFields = j["CustomFields"].ToString();
w.Tags.Add(ImportTag);//so user can find them all and revert later if necessary // w.Tags.Add(ImportTag);//so user can find them all and revert later if necessary
var res = await WorkOrderCreateAsync(w); // var res = await WorkOrderCreateAsync(w);
if (res == null) // if (res == null)
{ // {
ImportResult.Add($"* {w.Serial} - {this.GetErrorsAsString()}"); // ImportResult.Add($"* {w.Serial} - {this.GetErrorsAsString()}");
this.ClearErrors(); // this.ClearErrors();
} // }
else // else
{ // {
ImportResult.Add($"{w.Serial} - ok"); // ImportResult.Add($"{w.Serial} - ok");
} // }
} // }
return ImportResult; // return ImportResult;
} // }
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
//JOB / OPERATIONS //JOB / OPERATIONS