cases 4366, 4365

This commit is contained in:
2022-12-30 20:05:43 +00:00
parent fd21d72ad3
commit 39676319bb
3 changed files with 82 additions and 88 deletions

View File

@@ -72,7 +72,7 @@ namespace AyaNova.PlugIn.V8
this.Text = this.Text + " (v" +util.RELEASE_VERSION_STRING+")"; this.Text = this.Text + " (v" +util.RELEASE_VERSION_STRING+")";
#if (DEBUG) #if (DEBUG)
edServerUrl.Text = "http://192.168.1.56:7575"; edServerUrl.Text = "http://192.168.1.253:7575";
edUserName.Text = "superuser"; edUserName.Text = "superuser";
edPassword.Text = "l3tm3in"; edPassword.Text = "l3tm3in";
#endif #endif

View File

@@ -3660,7 +3660,12 @@ namespace AyaNova.PlugIn.V8
} }
else else
dwip.partId = tryPartId; dwip.partId = tryPartId;
dwip.partWarehouseId = await Getv7v8IdMap(wip.PartWarehouseID, RootObjectTypes.PartWarehouse); //case 4366 use inventory is false so it should not even be trying here
if (V7UseInventory == true)
dwip.partWarehouseId = await Getv7v8IdMap(wip.PartWarehouseID, RootObjectTypes.PartWarehouse);
else
dwip.partWarehouseId = 1;//this is the v8 default when no inventory is in use
dwip.taxPartSaleId = await Getv7v8IdMapNullOk(wip.TaxPartSaleID, RootObjectTypes.TaxCode); dwip.taxPartSaleId = await Getv7v8IdMapNullOk(wip.TaxPartSaleID, RootObjectTypes.TaxCode);
if (wip.Discount != 0) if (wip.Discount != 0)
dwip.priceOverride = wip.Price - (wip.Price * wip.Discount); dwip.priceOverride = wip.Price - (wip.Price * wip.Discount);
@@ -6077,115 +6082,104 @@ namespace AyaNova.PlugIn.V8
{ {
if (!progress.KeepGoing) return null; if (!progress.KeepGoing) return null;
FileInfo fi = null;
//is it a local file? try//case 4365 moved up to here
if (!new Uri(doc.URL).IsFile)
{ {
NonFileUrls += (doc.Description + "(v8Migrate) " + doc.URL + "\n"); progress.SubOp("Processing assigned doc: \"" + doc.URL + "\"...");
continue; //is it a local file?
} if (!new Uri(doc.URL).IsFile)
//can we see it? {
if (!File.Exists(doc.URL)) NonFileUrls += (doc.Description + "(v8Migrate) " + doc.URL + "\n");
{ continue;
NonFileUrls += ("v8Migrate - Assigned doc. file not found: " + doc.Description + " " + doc.URL + "\n"); }
continue; //can we see it?
} if (!File.Exists(doc.URL))
{
NonFileUrls += ("v8Migrate - Assigned doc. file not found: " + doc.Description + " " + doc.URL + "\n");
continue;
}
//get the file info //get the file info
FileInfo fi = new FileInfo(doc.URL); fi = new FileInfo(doc.URL);
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) if (fi.Length > SmallestFileUploadRejectedAsTooBig)
{ {
progress.Append("Assigned doc. file " + doc.Description + " " + doc.URL + " too large (" + AyaBizUtils.FileSizeDisplay(fi.Length) + "). " + MaxFileSizeInfo(fi.Length)); progress.Append("Assigned doc. file " + doc.Description + " " + doc.URL + " too large (" + AyaBizUtils.FileSizeDisplay(fi.Length) + "). " + MaxFileSizeInfo(fi.Length));
NonFileUrls += ("v8Migrate - Assigned doc. file " + doc.Description + " " + doc.URL + " too large (" + AyaBizUtils.FileSizeDisplay(fi.Length) + ")." + MaxFileSizeInfo(fi.Length) + "\n"); NonFileUrls += ("v8Migrate - Assigned doc. file " + doc.Description + " " + doc.URL + " too large (" + AyaBizUtils.FileSizeDisplay(fi.Length) + ")." + MaxFileSizeInfo(fi.Length) + "\n");
continue; continue;
} }
//Compile the FileData property //Compile the FileData property
DateTimeOffset dtLastModified = fi.LastWriteTimeUtc; DateTimeOffset dtLastModified = fi.LastWriteTimeUtc;
dynamic dFileData = new JArray(); dynamic dFileData = new JArray();
dynamic dFile = new JObject(); dynamic dFile = new JObject();
dFile.name = fi.Name; dFile.name = fi.Name;
dFile.lastModified = dtLastModified.ToUnixTimeMilliseconds(); dFile.lastModified = dtLastModified.ToUnixTimeMilliseconds();
dFileData.Add(dFile); dFileData.Add(dFile);
//Upload //Upload
MultipartFormDataContent formDataContent = new MultipartFormDataContent(); MultipartFormDataContent formDataContent = new MultipartFormDataContent();
//Form data like the bizobject type and id //Form data like the bizobject type and id
string RavenTypeAsString = ""; string RavenTypeAsString = "";
int ravenType = 0;//notype is default for orphaned objects // int ravenType = 0;//notype is default for orphaned objects
long v8Id = await Getv7v8IdMap(tid.ID, tid.RootObjectType, false, true);//default to 0 id if no match which is good for raven as it puts it into a list users can deal with in UI long v8Id = await Getv7v8IdMap(tid.ID, tid.RootObjectType, false, true);//default to 0 id if no match which is good for raven as it puts it into a list users can deal with in UI
if (v8Id != 0) if (v8Id != 0)
{ {
if (specificRavenType != util.AyaType.NoType) if (specificRavenType != util.AyaType.NoType)
RavenTypeAsString = ((int)specificRavenType).ToString(); RavenTypeAsString = ((int)specificRavenType).ToString();
else else
RavenTypeAsString = ((int)util.RootObjectToAyaType(tid.RootObjectType)).ToString(); RavenTypeAsString = ((int)util.RootObjectToAyaType(tid.RootObjectType)).ToString();
} }
formDataContent.Add(new StringContent(RavenTypeAsString), name: "AttachToAType");
formDataContent.Add(new StringContent(v8Id.ToString()), name: "AttachToObjectId");
formDataContent.Add(new StringContent(doc.Description + " (v8Migrate)"), name: "Notes");
formDataContent.Add(new StringContent(dFileData.ToString()), name: "FileData");
// string RavenTypeAsString = ""; StreamContent AttachmentFile = new StreamContent(fi.OpenRead());
// if (specificRavenType != util.AyaType.NoType) AttachmentFile.Headers.ContentType = new MediaTypeHeaderValue(MimeTypeMap.GetMimeType(fi.Extension));
// RavenTypeAsString = ((int)specificRavenType).ToString(); AttachmentFile.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
// else AttachmentFile.Headers.ContentDisposition.FileName = fi.Name;
// RavenTypeAsString = ((int)util.RootObjectToAyaType(tid.RootObjectType)).ToString();
formDataContent.Add(new StringContent(RavenTypeAsString), name: "AttachToAType");
// formDataContent.Add(new StringContent(Map[tid.ID].ToString()), name: "AttachToObjectId");
formDataContent.Add(new StringContent(v8Id.ToString()), name: "AttachToObjectId");
AttachmentFile.Headers.ContentDisposition.ModificationDate = dtLastModified;
formDataContent.Add(AttachmentFile);
//Upload
formDataContent.Add(new StringContent(doc.Description + " (v8Migrate)"), name: "Notes");
formDataContent.Add(new StringContent(dFileData.ToString()), name: "FileData");
StreamContent AttachmentFile = new StreamContent(fi.OpenRead());
AttachmentFile.Headers.ContentType = new MediaTypeHeaderValue(MimeTypeMap.GetMimeType(fi.Extension));
AttachmentFile.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
AttachmentFile.Headers.ContentDisposition.FileName = fi.Name;
AttachmentFile.Headers.ContentDisposition.ModificationDate = dtLastModified;
formDataContent.Add(AttachmentFile);
//Upload
try
{
#if(DEBUG)
progress.Append("Sending file " + fi.Name);
#endif
await util.PostFormDataAsync("attachment", formDataContent); await util.PostFormDataAsync("attachment", formDataContent);
} }
catch (Exception ex) catch (Exception ex)
{ {
#if(DEBUG) if (fi != null)
progress.Append("ERROR Sending file " + fi.Name);
#endif
if (ex.Message.Contains("413"))
{ {
if (SmallestFileUploadRejectedAsTooBig > fi.Length) if (ex.Message.Contains("413"))
SmallestFileUploadRejectedAsTooBig = fi.Length; {
progress.Append("Assigned doc. file " + doc.Description + " " + doc.URL + " too large (" + AyaBizUtils.FileSizeDisplay(fi.Length) + "). " + MaxFileSizeInfo(fi.Length)); if (SmallestFileUploadRejectedAsTooBig > fi.Length)
NonFileUrls += ("v8Migrate - Assigned doc. file " + doc.Description + " " + doc.URL + " too large (" + AyaBizUtils.FileSizeDisplay(fi.Length) + ")." + MaxFileSizeInfo(fi.Length) + "\n"); SmallestFileUploadRejectedAsTooBig = fi.Length;
continue; progress.Append("Assigned doc. file " + doc.Description + " " + doc.URL + " too large (" + AyaBizUtils.FileSizeDisplay(fi.Length) + "). " + MaxFileSizeInfo(fi.Length));
NonFileUrls += ("v8Migrate - Assigned doc. file " + doc.Description + " " + doc.URL + " too large (" + AyaBizUtils.FileSizeDisplay(fi.Length) + ")." + MaxFileSizeInfo(fi.Length) + "\n");
continue;
}
else
{
throw;
}
} }
else else
{ {
throw; progress.Append("Error processing assigned doc: \"" + doc.URL + "\" skipping it. Error:" + ex.Message);
} }
} }
//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
#if(DEBUG)
progress.Append("File attached successfully " + fi.Name);
#endif
} }

View File

@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<!-- Development test MSSQL DB --> <!-- Development test MSSQL DB
<ConnectionType>DataBase</ConnectionType> <ConnectionType>DataBase</ConnectionType>
<DataBaseType>MSSQL</DataBaseType> <DataBaseType>MSSQL</DataBaseType>
<DataBaseConnectionString>Server=DEV-V7-LAPTOP\SQLEXPRESS;initial catalog=AyaNova;User Id=sa; Password = abraxis;</DataBaseConnectionString> <DataBaseConnectionString>Server=DEV-V7-LAPTOP\SQLEXPRESS;initial catalog=AyaNova;User Id=sa; Password = abraxis;</DataBaseConnectionString>
-->
<!-- DEVELOPMENT embedded Firebird database <!-- DEVELOPMENT embedded Firebird database
@@ -27,11 +27,11 @@
<PortalServer>http://XXXX.XXXXX/AyaNovaDP/DataPortal.rem</PortalServer> <PortalServer>http://XXXX.XXXXX/AyaNovaDP/DataPortal.rem</PortalServer>
--> -->
<!-- Customer restored MSSQL DB <!-- Customer restored MSSQL DB -->
<ConnectionType>DataBase</ConnectionType> <ConnectionType>DataBase</ConnectionType>
<DataBaseType>MSSQL</DataBaseType> <DataBaseType>MSSQL</DataBaseType>
<DataBaseConnectionString>Server=DEV-V7-LAPTOP\SQLEXPRESS;initial catalog=AyaNova-XXXXX;User Id=sa; Password=abraxis;</DataBaseConnectionString> <DataBaseConnectionString>Server=DEV-V7-LAPTOP\SQLEXPRESS;initial catalog=odAyaNova;User Id=sa; Password=abraxis;</DataBaseConnectionString>
-->
<!-- Test data portal server <!-- Test data portal server
<ConnectionType>DataPortal</ConnectionType> <ConnectionType>DataPortal</ConnectionType>
<PortalServer>http://xxxx.aya.haveabyte.com/DP/DataPortal.rem</PortalServer> <PortalServer>http://xxxx.aya.haveabyte.com/DP/DataPortal.rem</PortalServer>