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+")";
#if (DEBUG)
edServerUrl.Text = "http://192.168.1.56:7575";
edServerUrl.Text = "http://192.168.1.253:7575";
edUserName.Text = "superuser";
edPassword.Text = "l3tm3in";
#endif

View File

@@ -168,7 +168,7 @@ namespace AyaNova.PlugIn.V8
if (MessageBox.Show("Warning: if you continue the AyaNova 8 destination server's database will be erased.\r\nAre you sure you want to continue?", "Erase data warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) return;
if (MessageBox.Show("Last chance: the next step will start migration and the AyaNova 8 target server's data will be erased.\r\nAre you sure you want to proceed?", "Continue migration", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) return;
//Only one command
DoExport();
}
@@ -3660,7 +3660,12 @@ namespace AyaNova.PlugIn.V8
}
else
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);
if (wip.Discount != 0)
dwip.priceOverride = wip.Price - (wip.Price * wip.Discount);
@@ -6077,115 +6082,104 @@ namespace AyaNova.PlugIn.V8
{
if (!progress.KeepGoing) return null;
//is it a local file?
if (!new Uri(doc.URL).IsFile)
FileInfo fi = null;
try//case 4365 moved up to here
{
NonFileUrls += (doc.Description + "(v8Migrate) " + 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;
}
progress.SubOp("Processing assigned doc: \"" + doc.URL + "\"...");
//is it a local file?
if (!new Uri(doc.URL).IsFile)
{
NonFileUrls += (doc.Description + "(v8Migrate) " + 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
FileInfo fi = new FileInfo(doc.URL);
//get the file info
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)
{
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;
}
//Compile the FileData property
if (fi.Length > SmallestFileUploadRejectedAsTooBig)
{
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;
}
//Compile the FileData property
DateTimeOffset dtLastModified = fi.LastWriteTimeUtc;
DateTimeOffset dtLastModified = fi.LastWriteTimeUtc;
dynamic dFileData = new JArray();
dynamic dFile = new JObject();
dFile.name = fi.Name;
dFile.lastModified = dtLastModified.ToUnixTimeMilliseconds();
dFileData.Add(dFile);
dynamic dFileData = new JArray();
dynamic dFile = new JObject();
dFile.name = fi.Name;
dFile.lastModified = dtLastModified.ToUnixTimeMilliseconds();
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 = "";
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
if (v8Id != 0)
{
if (specificRavenType != util.AyaType.NoType)
RavenTypeAsString = ((int)specificRavenType).ToString();
else
RavenTypeAsString = ((int)util.RootObjectToAyaType(tid.RootObjectType)).ToString();
}
string RavenTypeAsString = "";
// 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
if (v8Id != 0)
{
if (specificRavenType != util.AyaType.NoType)
RavenTypeAsString = ((int)specificRavenType).ToString();
else
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 = "";
// if (specificRavenType != util.AyaType.NoType)
// RavenTypeAsString = ((int)specificRavenType).ToString();
// else
// 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");
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);
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
//Upload
await util.PostFormDataAsync("attachment", formDataContent);
}
catch (Exception ex)
{
#if(DEBUG)
progress.Append("ERROR Sending file " + fi.Name);
#endif
if (ex.Message.Contains("413"))
if (fi != null)
{
if (SmallestFileUploadRejectedAsTooBig > fi.Length)
SmallestFileUploadRejectedAsTooBig = 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");
continue;
if (ex.Message.Contains("413"))
{
if (SmallestFileUploadRejectedAsTooBig > fi.Length)
SmallestFileUploadRejectedAsTooBig = 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");
continue;
}
else
{
throw;
}
}
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
#if(DEBUG)
progress.Append("File attached successfully " + fi.Name);
#endif
}

View File

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