diff --git a/source/Plugins/AyaNova.Plugin.V8/Auth.cs b/source/Plugins/AyaNova.Plugin.V8/Auth.cs index 19641e1..336c37d 100644 --- a/source/Plugins/AyaNova.Plugin.V8/Auth.cs +++ b/source/Plugins/AyaNova.Plugin.V8/Auth.cs @@ -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 diff --git a/source/Plugins/AyaNova.Plugin.V8/V8.cs b/source/Plugins/AyaNova.Plugin.V8/V8.cs index ef47a57..18717a3 100644 --- a/source/Plugins/AyaNova.Plugin.V8/V8.cs +++ b/source/Plugins/AyaNova.Plugin.V8/V8.cs @@ -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 } diff --git a/source/WinFormApp/config.txt b/source/WinFormApp/config.txt index 4f2f11b..c9b503b 100644 --- a/source/WinFormApp/config.txt +++ b/source/WinFormApp/config.txt @@ -1,11 +1,11 @@ - + - DataBase MSSQL - Server=DEV-V7-LAPTOP\SQLEXPRESS;initial catalog=AyaNova-XXXXX;User Id=sa; Password=abraxis; - --> + Server=DEV-V7-LAPTOP\SQLEXPRESS;initial catalog=odAyaNova;User Id=sa; Password=abraxis; +