This commit is contained in:
2021-08-30 17:23:53 +00:00
parent a1510c0feb
commit d962931512
2 changed files with 54 additions and 21 deletions

View File

@@ -240,6 +240,7 @@ namespace AyaNova.PlugIn.V8
private string MissingDataNamePrefix = "zV8migrate_substitute";//append guid to ensure uniqueness private string MissingDataNamePrefix = "zV8migrate_substitute";//append guid to ensure uniqueness
private async System.Threading.Tasks.Task CreateSubstitute(Guid id, RootObjectTypes desiredType, long? extraV8Id = null) private async System.Threading.Tasks.Task CreateSubstitute(Guid id, RootObjectTypes desiredType, long? extraV8Id = null)
{ {
//create the simplest possible version of this object desired //create the simplest possible version of this object desired
@@ -373,7 +374,7 @@ namespace AyaNova.PlugIn.V8
private bool V7UseInventory = false; private bool V7UseInventory = false;
private List<long> Allv8WarehouseIds = new List<long>(); private List<long> Allv8WarehouseIds = new List<long>();
private long SmallestFileUploadRejectedAsTooBig = long.MaxValue;
@@ -406,6 +407,9 @@ namespace AyaNova.PlugIn.V8
V7ToV8WorkOrderItemStatusIdMap.Clear(); V7ToV8WorkOrderItemStatusIdMap.Clear();
TagMap.Clear(); TagMap.Clear();
LocaleMap.Clear(); LocaleMap.Clear();
SmallestFileUploadRejectedAsTooBig = long.MaxValue;
//add default raven language and codes //add default raven language and codes
LocaleMap.Add("English", 1); LocaleMap.Add("English", 1);
LocaleMap.Add("Español", 2); LocaleMap.Add("Español", 2);
@@ -4334,7 +4338,7 @@ namespace AyaNova.PlugIn.V8
v8FollowId = await Getv7v8IdMapNullOk(c.FollowID, RootObjectTypes.Workorder, false, true); v8FollowId = await Getv7v8IdMapNullOk(c.FollowID, RootObjectTypes.Workorder, false, true);
if (v8FollowId == null) if (v8FollowId == null)
{ {
progress.Append("Follow up for WO skipped due to WO non-existance"); progress.Append("Follow up for WO with ID: " + c.FollowID.ToString() + " skipped due to WO non-existance");
continue; continue;
} }
d.objectId = v8FollowId; d.objectId = v8FollowId;
@@ -4343,17 +4347,17 @@ namespace AyaNova.PlugIn.V8
break; break;
case RootObjectTypes.WorkorderQuote: case RootObjectTypes.WorkorderQuote:
{ {
Guid woid=Guid.Empty; Guid woid = Guid.Empty;
try try
{ {
Workorder o = Workorder.GetWorkorderByRelativeNoMRU(RootObjectTypes.WorkorderQuote, c.FollowID); Workorder o = Workorder.GetWorkorderByRelativeNoMRU(RootObjectTypes.WorkorderQuote, c.FollowID);
woid=o.ID; woid = o.ID;
} }
catch (Exception ex) catch (Exception ex)
{ {
if (ex is FetchException || ex is System.Security.SecurityException)//Note: workorder will throw a security exception if resulting ID is guid.empty for...reasons.. if (ex is FetchException || ex is System.Security.SecurityException)//Note: workorder will throw a security exception if resulting ID is guid.empty for...reasons..
{ {
progress.Append("Follow up for Quote skipped due to Quote non-existance"); progress.Append("Follow up for Quote with ID: " + c.FollowID.ToString() + " skipped due to Quote non-existance");
continue; continue;
} }
throw; throw;
@@ -4361,7 +4365,7 @@ namespace AyaNova.PlugIn.V8
v8FollowId = await Getv7v8IdMapNullOk(woid, RootObjectTypes.Workorder, false, true); v8FollowId = await Getv7v8IdMapNullOk(woid, RootObjectTypes.Workorder, false, true);
if (v8FollowId == null) if (v8FollowId == null)
{ {
progress.Append("Follow up for quote skipped due to quote non-existance"); progress.Append("Follow up for Quote with ID: " + c.FollowID.ToString() + " skipped due to quote non-existance");
continue; continue;
} }
d.objectId = v8FollowId; d.objectId = v8FollowId;
@@ -4380,7 +4384,7 @@ namespace AyaNova.PlugIn.V8
{ {
if (ex is FetchException || ex is System.Security.SecurityException)//Note: workorder will throw a security exception if resulting ID is guid.empty for...reasons.. if (ex is FetchException || ex is System.Security.SecurityException)//Note: workorder will throw a security exception if resulting ID is guid.empty for...reasons..
{ {
progress.Append("Follow up for PM skipped due to PM non-existance"); progress.Append("Follow up for PM with ID: " + c.FollowID.ToString() + " skipped due to PM non-existance");
continue; continue;
} }
throw; throw;
@@ -4388,7 +4392,7 @@ namespace AyaNova.PlugIn.V8
v8FollowId = await Getv7v8IdMapNullOk(woid, RootObjectTypes.Workorder, false, true); v8FollowId = await Getv7v8IdMapNullOk(woid, RootObjectTypes.Workorder, false, true);
if (v8FollowId == null) if (v8FollowId == null)
{ {
progress.Append("Follow up for PM skipped due to PM non-existance"); progress.Append("Follow up for PM with ID: " + c.FollowID.ToString() + " skipped due to PM non-existance");
continue; continue;
} }
d.objectId = v8FollowId; d.objectId = v8FollowId;
@@ -5594,6 +5598,7 @@ namespace AyaNova.PlugIn.V8
//iterate the files //iterate the files
foreach (AssignedDoc doc in docs) foreach (AssignedDoc doc in docs)
{ {
if (!progress.KeepGoing) return null; if (!progress.KeepGoing) return null;
//is it a local file? //is it a local file?
@@ -5614,6 +5619,13 @@ namespace AyaNova.PlugIn.V8
progress.SubOp("Assigned doc: \"" + doc.URL + "\" " + AyaBizUtils.FileSizeDisplay((decimal)fi.Length)); progress.SubOp("Assigned doc: \"" + doc.URL + "\" " + AyaBizUtils.FileSizeDisplay((decimal)fi.Length));
if (fi.Length > SmallestFileUploadRejectedAsTooBig)
{
progress.Append("Assigned doc. file " + doc.Description + " " + doc.URL + " too large (" + fi.Length.ToString() + ") for this server. Adjust destination server settings to allow");
NonFileUrls += (ImportTag + " - Assigned doc. file " + doc.Description + " " + doc.URL + " too large (" + fi.Length.ToString() + ") for this server. Adjust destination server settings to allow.\n");
continue;
}
//Compile the FileData property //Compile the FileData property
DateTimeOffset dtLastModified = fi.LastWriteTimeUtc; DateTimeOffset dtLastModified = fi.LastWriteTimeUtc;
@@ -5666,7 +5678,26 @@ namespace AyaNova.PlugIn.V8
formDataContent.Add(AttachmentFile); formDataContent.Add(AttachmentFile);
//Upload //Upload
try
{
await util.PostFormDataAsync("attachment", formDataContent); await util.PostFormDataAsync("attachment", formDataContent);
}
catch (Exception ex)
{
if (ex.Message.Contains("413"))
{
if (SmallestFileUploadRejectedAsTooBig > fi.Length)
SmallestFileUploadRejectedAsTooBig = fi.Length;
progress.Append("Assigned doc. file " + doc.Description + " " + doc.URL + " too large (" + fi.Length.ToString() + ") for this server. Adjust destination server settings to allow");
NonFileUrls += (ImportTag + " - Assigned doc. file " + doc.Description + " " + doc.URL + " too large (" + fi.Length.ToString() + ") for this server. Adjust destination server settings to allow.\n");
continue;
}
else
{
throw;
}
}
//No need to map it or save response as long as it works that's all that matters //No need to map it or save response as long as it works that's all that matters

View File

@@ -165,7 +165,7 @@ namespace AyaNova.PlugIn.V8
var responseAsString = await response.Content.ReadAsStringAsync(); var responseAsString = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode) if (!response.IsSuccessStatusCode)
{ {
throw new Exception("GET error, route: " + route + "\r\n" + responseAsString + "\r\n" + response.ReasonPhrase); throw new Exception("GET error, code: " + (int)response.StatusCode + ", route: " + route + "\r\n" + responseAsString + "\r\n" + response.ReasonPhrase);
} }
else else
return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) }; return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) };
@@ -247,7 +247,7 @@ namespace AyaNova.PlugIn.V8
{ {
if (string.IsNullOrWhiteSpace(postJson)) if (string.IsNullOrWhiteSpace(postJson))
postJson = "n/a"; postJson = "n/a";
throw new Exception("POST error, route: " + route + "\r\n" + responseAsString + "\r\n" + response.ReasonPhrase + "\r\nPOSTED OBJECT:\r\n" + postJson); throw new Exception("POST error, code: " + (int)response.StatusCode + ", route: " + route + "\r\n" + responseAsString + "\r\n" + response.ReasonPhrase + "\r\nPOSTED OBJECT:\r\n" + postJson);
} }
else else
return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) }; return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) };
@@ -333,7 +333,7 @@ namespace AyaNova.PlugIn.V8
{ {
if (string.IsNullOrWhiteSpace(putJson)) if (string.IsNullOrWhiteSpace(putJson))
putJson = "n/a"; putJson = "n/a";
throw new Exception("PUT error, route: " + route + "\r\n" + responseAsString + "\r\n" + response.ReasonPhrase + "\r\nPUT OBJECT:\r\n" + putJson); throw new Exception("PUT error, code: " + (int)response.StatusCode + ", route: " + route + "\r\n" + responseAsString + "\r\n" + response.ReasonPhrase + "\r\nPUT OBJECT:\r\n" + putJson);
} }
else else
return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) }; return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) };
@@ -370,6 +370,8 @@ namespace AyaNova.PlugIn.V8
} }
private async static Task<ApiResponse> TryPostFormDataAsync(string route, MultipartFormDataContent formContent) private async static Task<ApiResponse> TryPostFormDataAsync(string route, MultipartFormDataContent formContent)
{ {
var requestMessage = new HttpRequestMessage(HttpMethod.Post, ApiBaseUrl + route); var requestMessage = new HttpRequestMessage(HttpMethod.Post, ApiBaseUrl + route);
@@ -398,7 +400,7 @@ namespace AyaNova.PlugIn.V8
var responseAsString = await response.Content.ReadAsStringAsync(); var responseAsString = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode) if (!response.IsSuccessStatusCode)
{ {
throw new Exception("POST FORMDATA error, route: " + route + "\r\n" + responseAsString + "\r\n" + response.ReasonPhrase); throw new Exception("POST FORMDATA error, code: "+ (int)response.StatusCode + ", route: " + route + "\r\n" + responseAsString + "\r\n" + response.ReasonPhrase);
} }
else else
return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) }; return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) };