This commit is contained in:
@@ -45,7 +45,7 @@ namespace AyaNova.Api.Controllers
|
||||
/// <param name="apiVersion">From route path</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> PostImportData([FromBody] AyImportObject importData, ApiVersion apiVersion)
|
||||
public async Task<IActionResult> PostImportData([FromBody] AyImportData importData, ApiVersion apiVersion)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
@@ -54,135 +54,133 @@ namespace AyaNova.Api.Controllers
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
await Task.CompletedTask;
|
||||
return Ok();
|
||||
|
||||
// if (o == null)
|
||||
// return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
// else
|
||||
// return CreatedAtAction(nameof(CustomerController.GetCustomer), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
||||
}
|
||||
|
||||
public class AyImportObject
|
||||
{
|
||||
public AyaType AType { get; set; }
|
||||
public JArray Data { get; set; }
|
||||
public bool DoImport {get;set;}
|
||||
public bool DoUpdate {get;set;}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Upload and import file
|
||||
/// Max 100MiB total
|
||||
/// </summary>
|
||||
/// <returns>Results</returns>
|
||||
[Authorize]
|
||||
[HttpPost("upload")]
|
||||
[DisableFormValueModelBinding]
|
||||
[RequestSizeLimit(AyaNova.Util.ServerBootConfig.MAX_IMPORT_FILE_UPLOAD_BYTES)]
|
||||
public async Task<IActionResult> UploadAsync()
|
||||
{
|
||||
//Adapted from the example found here: https://docs.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads#uploading-large-files-with-streaming
|
||||
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
|
||||
//This route is ONLY available to users with full rights to Global object
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.Global))
|
||||
{
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
}
|
||||
|
||||
// AyaTypeId attachToObject = null;
|
||||
ApiUploadProcessor.ApiUploadedFilesResult uploadFormData = null;
|
||||
List<string> ImportResult = new List<string>();
|
||||
ImportResult.Add("Import results\n");
|
||||
try
|
||||
{
|
||||
if (!MultipartRequestHelper.IsMultipartContentType(Request.ContentType))
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, $"Expected a multipart request, but got {Request.ContentType}"));
|
||||
log.LogDebug($"Instantiating biz object handler for {importData.AType}");
|
||||
var biz = BizObjectFactory.GetBizObject(importData.AType, ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
||||
|
||||
//Save uploads to disk under temporary file names until we decide how to handle them
|
||||
// uploadFormData = await ApiUploadProcessor.ProcessUploadAsync(HttpContext);xx
|
||||
|
||||
|
||||
string UploadAType = string.Empty;
|
||||
|
||||
string errorMessage = string.Empty;
|
||||
string Notes = string.Empty;
|
||||
List<UploadFileData> FileData = new List<UploadFileData>();
|
||||
|
||||
//Save uploads to disk under temporary file names until we decide how to handle them
|
||||
uploadFormData = await ApiUploadProcessor.ProcessUploadAsync(HttpContext);
|
||||
if (!string.IsNullOrWhiteSpace(uploadFormData.Error))
|
||||
{
|
||||
errorMessage = uploadFormData.Error;
|
||||
//delete temp files
|
||||
ApiUploadProcessor.DeleteTempUploadFile(uploadFormData);
|
||||
//file too large is most likely issue so in that case return this localized properly
|
||||
if (errorMessage.Contains("413"))
|
||||
{
|
||||
var TransId = UserTranslationIdFromContext.Id(HttpContext.Items);
|
||||
return BadRequest(new ApiErrorResponse(
|
||||
ApiErrorCode.VALIDATION_LENGTH_EXCEEDED,
|
||||
null,
|
||||
String.Format(await TranslationBiz.GetTranslationStaticAsync("AyaFileFileTooLarge", TransId, ct), AyaNova.Util.FileUtil.GetBytesReadable(AyaNova.Util.ServerBootConfig.MAX_IMPORT_FILE_UPLOAD_BYTES))));
|
||||
}
|
||||
else//not too big, something else
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, null, errorMessage));
|
||||
}
|
||||
|
||||
if (!uploadFormData.FormFieldData.ContainsKey("FileData"))//only filedata is required
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Missing required FormFieldData value: FileData"));
|
||||
|
||||
|
||||
if (uploadFormData.FormFieldData.ContainsKey("AType"))
|
||||
UploadAType = uploadFormData.FormFieldData["AType"].ToString();
|
||||
else
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Missing required FormFieldData value: AType"));
|
||||
|
||||
//fileData in JSON stringify format which contains the actual last modified dates etc
|
||||
//"[{\"name\":\"Client.csv\",\"lastModified\":1582822079618},{\"name\":\"wmi4fu06nrs41.jpg\",\"lastModified\":1586900220990}]"
|
||||
FileData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<UploadFileData>>(uploadFormData.FormFieldData["FileData"].ToString());
|
||||
|
||||
|
||||
|
||||
//Instantiate the business object handler
|
||||
AyaType TheType = System.Enum.Parse<AyaType>(UploadAType, true);
|
||||
log.LogDebug($"Instantiating biz object handler for {TheType}");
|
||||
var biz = BizObjectFactory.GetBizObject(TheType, ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
||||
|
||||
if (!(biz is IImportAbleObject))
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, $"Import not supported for {TheType} objects"));
|
||||
|
||||
//We have our files now can parse and insert into db
|
||||
if (uploadFormData.UploadedFiles.Count > 0)
|
||||
{
|
||||
//deserialize each file and import
|
||||
foreach (UploadedFileInfo a in uploadFormData.UploadedFiles)
|
||||
{
|
||||
JArray ja = JArray.Parse(System.IO.File.ReadAllText(a.InitialUploadedPathName));
|
||||
ImportResult.AddRange(await ((IImportAbleObject)biz).ImportData(ja));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.IO.InvalidDataException ex)
|
||||
{
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, ex.Message));
|
||||
}
|
||||
finally
|
||||
{
|
||||
//delete all the files temporarily uploaded and return bad request
|
||||
|
||||
ApiUploadProcessor.DeleteTempUploadFile(uploadFormData);
|
||||
}
|
||||
if (!(biz is IImportAbleObject))
|
||||
return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, $"Import not supported for {importData.AType} objects"));
|
||||
ImportResult.AddRange(await ((IImportAbleObject)biz).ImportData(importData));
|
||||
|
||||
return Ok(ApiOkResponse.Response(ImportResult));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// Upload and import file
|
||||
// /// Max 100MiB total
|
||||
// /// </summary>
|
||||
// /// <returns>Results</returns>
|
||||
// [Authorize]
|
||||
// [HttpPost("upload")]
|
||||
// [DisableFormValueModelBinding]
|
||||
// [RequestSizeLimit(AyaNova.Util.ServerBootConfig.MAX_IMPORT_FILE_UPLOAD_BYTES)]
|
||||
// public async Task<IActionResult> UploadAsync()
|
||||
// {
|
||||
// //Adapted from the example found here: https://docs.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads#uploading-large-files-with-streaming
|
||||
|
||||
// if (!serverState.IsOpen)
|
||||
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
|
||||
// //This route is ONLY available to users with full rights to Global object
|
||||
// if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.Global))
|
||||
// {
|
||||
// return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
// }
|
||||
|
||||
// // AyaTypeId attachToObject = null;
|
||||
// ApiUploadProcessor.ApiUploadedFilesResult uploadFormData = null;
|
||||
// List<string> ImportResult = new List<string>();
|
||||
// ImportResult.Add("Import results\n");
|
||||
// try
|
||||
// {
|
||||
// if (!MultipartRequestHelper.IsMultipartContentType(Request.ContentType))
|
||||
// return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, $"Expected a multipart request, but got {Request.ContentType}"));
|
||||
|
||||
// //Save uploads to disk under temporary file names until we decide how to handle them
|
||||
// // uploadFormData = await ApiUploadProcessor.ProcessUploadAsync(HttpContext);xx
|
||||
|
||||
|
||||
// string UploadAType = string.Empty;
|
||||
|
||||
// string errorMessage = string.Empty;
|
||||
// string Notes = string.Empty;
|
||||
// List<UploadFileData> FileData = new List<UploadFileData>();
|
||||
|
||||
// //Save uploads to disk under temporary file names until we decide how to handle them
|
||||
// uploadFormData = await ApiUploadProcessor.ProcessUploadAsync(HttpContext);
|
||||
// if (!string.IsNullOrWhiteSpace(uploadFormData.Error))
|
||||
// {
|
||||
// errorMessage = uploadFormData.Error;
|
||||
// //delete temp files
|
||||
// ApiUploadProcessor.DeleteTempUploadFile(uploadFormData);
|
||||
// //file too large is most likely issue so in that case return this localized properly
|
||||
// if (errorMessage.Contains("413"))
|
||||
// {
|
||||
// var TransId = UserTranslationIdFromContext.Id(HttpContext.Items);
|
||||
// return BadRequest(new ApiErrorResponse(
|
||||
// ApiErrorCode.VALIDATION_LENGTH_EXCEEDED,
|
||||
// null,
|
||||
// String.Format(await TranslationBiz.GetTranslationStaticAsync("AyaFileFileTooLarge", TransId, ct), AyaNova.Util.FileUtil.GetBytesReadable(AyaNova.Util.ServerBootConfig.MAX_IMPORT_FILE_UPLOAD_BYTES))));
|
||||
// }
|
||||
// else//not too big, something else
|
||||
// return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, null, errorMessage));
|
||||
// }
|
||||
|
||||
// if (!uploadFormData.FormFieldData.ContainsKey("FileData"))//only filedata is required
|
||||
// return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Missing required FormFieldData value: FileData"));
|
||||
|
||||
|
||||
// if (uploadFormData.FormFieldData.ContainsKey("AType"))
|
||||
// UploadAType = uploadFormData.FormFieldData["AType"].ToString();
|
||||
// else
|
||||
// return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, "Missing required FormFieldData value: AType"));
|
||||
|
||||
// //fileData in JSON stringify format which contains the actual last modified dates etc
|
||||
// //"[{\"name\":\"Client.csv\",\"lastModified\":1582822079618},{\"name\":\"wmi4fu06nrs41.jpg\",\"lastModified\":1586900220990}]"
|
||||
// FileData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<UploadFileData>>(uploadFormData.FormFieldData["FileData"].ToString());
|
||||
|
||||
|
||||
|
||||
// //Instantiate the business object handler
|
||||
// AyaType TheType = System.Enum.Parse<AyaType>(UploadAType, true);
|
||||
// log.LogDebug($"Instantiating biz object handler for {TheType}");
|
||||
// var biz = BizObjectFactory.GetBizObject(TheType, ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
||||
|
||||
// if (!(biz is IImportAbleObject))
|
||||
// return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, $"Import not supported for {TheType} objects"));
|
||||
|
||||
// //We have our files now can parse and insert into db
|
||||
// if (uploadFormData.UploadedFiles.Count > 0)
|
||||
// {
|
||||
// //deserialize each file and import
|
||||
// foreach (UploadedFileInfo a in uploadFormData.UploadedFiles)
|
||||
// {
|
||||
// JArray ja = JArray.Parse(System.IO.File.ReadAllText(a.InitialUploadedPathName));
|
||||
// ImportResult.AddRange(await ((IImportAbleObject)biz).ImportData(ja));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (System.IO.InvalidDataException ex)
|
||||
// {
|
||||
// return BadRequest(new ApiErrorResponse(ApiErrorCode.INVALID_OPERATION, null, ex.Message));
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// //delete all the files temporarily uploaded and return bad request
|
||||
|
||||
// ApiUploadProcessor.DeleteTempUploadFile(uploadFormData);
|
||||
// }
|
||||
|
||||
// return Ok(ApiOkResponse.Response(ImportResult));
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
|
||||
@@ -427,13 +427,13 @@ namespace AyaNova.Biz
|
||||
return await GetReportData(dataListSelectedRequest, jobId);
|
||||
}
|
||||
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
public async Task<List<string>> ImportData(AyImportData importData)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
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 importData.Data)
|
||||
{
|
||||
var w = j.ToObject<Customer>(jsset);
|
||||
if (j["CustomFields"] != null)
|
||||
|
||||
@@ -334,13 +334,13 @@ namespace AyaNova.Biz
|
||||
return await GetReportData(dataListSelectedRequest, jobId);
|
||||
}
|
||||
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
public async Task<List<string>> ImportData(AyImportData importData)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
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 importData.Data)
|
||||
{
|
||||
var w = j.ToObject<CustomerServiceRequest>(jsset);
|
||||
if (j["CustomFields"] != null)
|
||||
|
||||
@@ -343,13 +343,13 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
public async Task<List<string>> ImportData(AyImportData importData)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
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 importData.Data)
|
||||
{
|
||||
var w = j.ToObject<HeadOffice>(jsset);
|
||||
if (j["CustomFields"] != null)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.Generic;
|
||||
using AyaNova.Models;
|
||||
|
||||
namespace AyaNova.Biz
|
||||
{
|
||||
@@ -9,7 +9,7 @@ namespace AyaNova.Biz
|
||||
/// </summary>
|
||||
internal interface IImportAbleObject
|
||||
{
|
||||
Task<List<string>> ImportData(JArray ja);
|
||||
Task<List<string>> ImportData(AyImportData importData);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -351,13 +351,13 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
public async Task<List<string>> ImportData(AyImportData importData)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
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 importData.Data)
|
||||
{
|
||||
var w = j.ToObject<LoanUnit>(jsset);
|
||||
if (j["CustomFields"] != null)
|
||||
|
||||
@@ -336,13 +336,13 @@ namespace AyaNova.Biz
|
||||
return await GetReportData(dataListSelectedRequest, jobId);
|
||||
}
|
||||
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
public async Task<List<string>> ImportData(AyImportData importData)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
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 importData.Data)
|
||||
{
|
||||
var w = j.ToObject<Memo>(jsset);
|
||||
if (j["CustomFields"] != null)
|
||||
|
||||
@@ -379,13 +379,13 @@ namespace AyaNova.Biz
|
||||
return await GetReportData(dataListSelectedRequest, jobId);
|
||||
}
|
||||
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
public async Task<List<string>> ImportData(AyImportData importData)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
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 importData.Data)
|
||||
{
|
||||
var w = j.ToObject<PartAssembly>(jsset);
|
||||
if (j["CustomFields"] != null)
|
||||
|
||||
@@ -554,13 +554,13 @@ namespace AyaNova.Biz
|
||||
return await GetReportData(dataListSelectedRequest, jobId);
|
||||
}
|
||||
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
public async Task<List<string>> ImportData(AyImportData importData)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
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 importData.Data)
|
||||
{
|
||||
var w = j.ToObject<Part>(jsset);
|
||||
if (j["CustomFields"] != null)
|
||||
|
||||
@@ -327,13 +327,13 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
public async Task<List<string>> ImportData(AyImportData importData)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
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 importData.Data)
|
||||
{
|
||||
var w = j.ToObject<PartWarehouse>(jsset);
|
||||
if (j["CustomFields"] != null)
|
||||
|
||||
@@ -327,13 +327,13 @@ namespace AyaNova.Biz
|
||||
return await GetReportData(dataListSelectedRequest, jobId);
|
||||
}
|
||||
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
public async Task<List<string>> ImportData(AyImportData importData)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
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 importData.Data)
|
||||
{
|
||||
var w = j.ToObject<Project>(jsset);
|
||||
if (j["CustomFields"] != null)
|
||||
|
||||
@@ -325,13 +325,13 @@ namespace AyaNova.Biz
|
||||
return await GetReportData(dataListSelectedRequest, jobId);
|
||||
}
|
||||
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
public async Task<List<string>> ImportData(AyImportData importData)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
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 importData.Data)
|
||||
{
|
||||
var w = j.ToObject<Reminder>(jsset);
|
||||
if (j["CustomFields"] != null)
|
||||
|
||||
@@ -403,13 +403,13 @@ namespace AyaNova.Biz
|
||||
return await GetReportData(dataListSelectedRequest, jobId);
|
||||
}
|
||||
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
public async Task<List<string>> ImportData(AyImportData importData)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
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 importData.Data)
|
||||
{
|
||||
var w = j.ToObject<Review>(jsset);
|
||||
if (j["CustomFields"] != null)
|
||||
|
||||
@@ -344,13 +344,13 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
public async Task<List<string>> ImportData(AyImportData importData)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
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 importData.Data)
|
||||
{
|
||||
var w = j.ToObject<ServiceRate>(jsset);
|
||||
if (j["CustomFields"] != null)
|
||||
|
||||
@@ -325,13 +325,13 @@ namespace AyaNova.Biz
|
||||
return await GetReportData(dataListSelectedRequest, jobId);
|
||||
}
|
||||
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
public async Task<List<string>> ImportData(AyImportData importData)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
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 importData.Data)
|
||||
{
|
||||
var w = j.ToObject<TaskGroup>(jsset);
|
||||
// if (j["CustomFields"] != null)
|
||||
|
||||
@@ -373,13 +373,13 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
public async Task<List<string>> ImportData(AyImportData importData)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
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 importData.Data)
|
||||
{
|
||||
var w = j.ToObject<TaxCode>(jsset);
|
||||
if (j["CustomFields"] != null)
|
||||
|
||||
@@ -340,13 +340,13 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
public async Task<List<string>> ImportData(AyImportData importData)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
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 importData.Data)
|
||||
{
|
||||
var w = j.ToObject<TravelRate>(jsset);
|
||||
if (j["CustomFields"] != null)
|
||||
|
||||
@@ -419,13 +419,13 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
public async Task<List<string>> ImportData(AyImportData importData)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
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 importData.Data)
|
||||
{
|
||||
var w = j.ToObject<Unit>(jsset);
|
||||
if (j["CustomFields"] != null)
|
||||
|
||||
@@ -327,13 +327,13 @@ namespace AyaNova.Biz
|
||||
return await GetReportData(dataListSelectedRequest, jobId);
|
||||
}
|
||||
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
public async Task<List<string>> ImportData(AyImportData importData)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
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 importData.Data)
|
||||
{
|
||||
var w = j.ToObject<UnitModel>(jsset);
|
||||
if (j["CustomFields"] != null)
|
||||
|
||||
@@ -1089,13 +1089,13 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
public async Task<List<string>> ImportData(AyImportData importData)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
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 importData.Data)
|
||||
{
|
||||
var w = j.ToObject<User>(jsset);
|
||||
if (j["CustomFields"] != null)
|
||||
|
||||
@@ -357,13 +357,13 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
public async Task<List<string>> ImportData(AyImportData importData)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
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 importData.Data)
|
||||
{
|
||||
var w = j.ToObject<Vendor>(jsset);
|
||||
if (j["CustomFields"] != null)
|
||||
|
||||
19
server/AyaNova/models/dto/AyImportData.cs
Normal file
19
server/AyaNova/models/dto/AyImportData.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using AyaNova.Biz;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Import data object used by admin->import feature
|
||||
/// </summary>
|
||||
public class AyImportData
|
||||
{
|
||||
public AyaType AType { get; set; }
|
||||
public JArray Data { get; set; }
|
||||
public bool DoImport {get;set;}
|
||||
public bool DoUpdate {get;set;}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user