diff --git a/Adaptation/FileHandlers/OpenInsightMetrologyViewer/WSRequest.cs b/Adaptation/FileHandlers/OpenInsightMetrologyViewer/WSRequest.cs index 9d465e8..d63378b 100644 --- a/Adaptation/FileHandlers/OpenInsightMetrologyViewer/WSRequest.cs +++ b/Adaptation/FileHandlers/OpenInsightMetrologyViewer/WSRequest.cs @@ -285,13 +285,13 @@ public class WSRequest pdDocument.close(); } - internal static long GetHeaderId(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, DateTime dateTime, int weekOfYear, string json, List descriptions) + internal static long GetHeaderId(IFileRead fileRead, Logistics logistics, string openInsightMetrologyViewerAPI, string openInsightMetrologyViewerFileShare, int weekOfYear, string json, List descriptions) { long result; if (string.IsNullOrEmpty(json)) { WSRequest wsRequest = new(fileRead, logistics, descriptions); - string directory = Path.Combine(openInsightMetrologyViewerAPI, dateTime.Year.ToString(), $"WW{weekOfYear:00}"); + string directory = Path.Combine(openInsightMetrologyViewerFileShare, logistics.DateTimeFromSequence.Year.ToString(), $"WW{weekOfYear:00}"); (json, WS.Results wsResults) = WS.SendData(openInsightMetrologyViewerAPI, logistics.Sequence, directory, wsRequest); if (!wsResults.Success) throw new Exception(wsResults.ToString()); diff --git a/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs b/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs index 876e809..29a7698 100644 --- a/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs +++ b/Adaptation/FileHandlers/OpenInsightMetrologyViewerAttachments/FileRead.cs @@ -111,13 +111,14 @@ public class FileRead : Shared.FileRead, IFileRead #nullable enable - private string? GetHeaderIdDirectory(DateTime[] dateTimes, long headerId) + private string? GetHeaderIdDirectory(long headerId) { string? result = null; int weekNum; string year; string weekDirectory; string checkDirectory; + DateTime[] dateTimes = new DateTime[] { _Logistics.DateTimeFromSequence, _Logistics.DateTimeFromSequence.AddDays(-6.66) }; foreach (DateTime dateTime in dateTimes) { year = dateTime.Year.ToString(); @@ -134,7 +135,7 @@ public class FileRead : Shared.FileRead, IFileRead return result; } - private void PostOpenInsightMetrologyViewerAttachments(DateTime dateTime, List descriptions) + private void PostOpenInsightMetrologyViewerAttachments(List descriptions) { string? json; string? subGroupId; @@ -154,16 +155,17 @@ public class FileRead : Shared.FileRead, IFileRead lock (_StaticRuns) _ = _StaticRuns.Remove(_Logistics.Sequence); } - DateTime[] dateTimes = new DateTime[] { dateTime, dateTime.AddDays(-6.66) }; - int weekOfYear = _Calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday); - long headerId = OpenInsightMetrologyViewer.WSRequest.GetHeaderId(this, _Logistics, _OpenInsightMetrologyViewerAPI, dateTime, weekOfYear, json, descriptions); - string? headerIdDirectory = GetHeaderIdDirectory(dateTimes, headerId); + int weekOfYear = _Calendar.GetWeekOfYear(_Logistics.DateTimeFromSequence, CalendarWeekRule.FirstDay, DayOfWeek.Sunday); + long headerId = !_IsEAFHosted ? -1 : OpenInsightMetrologyViewer.WSRequest.GetHeaderId(this, _Logistics, _OpenInsightMetrologyViewerAPI, _OpenInsightMetrologyViewerFileShare, weekOfYear, json, descriptions); + string? headerIdDirectory = GetHeaderIdDirectory(headerId); if (string.IsNullOrEmpty(headerIdDirectory)) throw new Exception($"Didn't find header id directory <{headerId}>"); OpenInsightMetrologyViewer.WSRequest.PostOpenInsightMetrologyViewerAttachments(this, _Logistics, _OpenInsightMetrologyViewerAPI, descriptions, matchDirectories[0], subGroupId, headerId, headerIdDirectory); } +#pragma warning disable IDE0060 private Tuple> GetExtractResult(string reportFullPath, DateTime dateTime) +#pragma warning restore IDE0060 { Tuple> results; Tuple pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath); @@ -173,7 +175,7 @@ public class FileRead : Shared.FileRead, IFileRead List descriptions = pcl.ProcessData.GetDescriptions(jsonElements); Test[] tests = (from l in descriptions select (Test)l.Test).ToArray(); if (_IsEAFHosted && _FileConnectorConfiguration.FileScanningIntervalInSeconds > 0) - PostOpenInsightMetrologyViewerAttachments(dateTime, descriptions); + PostOpenInsightMetrologyViewerAttachments(descriptions); results = new Tuple>(pdsf.Item1, tests, jsonElements, new List()); return results; } diff --git a/Adaptation/Shared/Metrology/WS.cs b/Adaptation/Shared/Metrology/WS.cs index 4e43fa3..c49e61d 100644 --- a/Adaptation/Shared/Metrology/WS.cs +++ b/Adaptation/Shared/Metrology/WS.cs @@ -78,20 +78,32 @@ public partial class WS { foreach (Attachment attachment in headerAttachments) { - directory = Path.GetDirectoryName(attachment.HeaderIdDirectory) ?? throw new Exception(); - File.Copy(attachment.SourceFileName, Path.Combine(directory, attachment.AttachmentId, attachment.DestinationFileName), overwrite: true); - AttachFile(url, attachment); + directory = Path.Combine(Path.GetDirectoryName(attachment.HeaderIdDirectory), attachment.AttachmentId) ?? throw new Exception(); + if (!Directory.Exists(directory)) + _ = Directory.CreateDirectory(directory); + File.Copy(attachment.SourceFileName, Path.Combine(directory, attachment.DestinationFileName), overwrite: true); } } if (dataAttachments is not null) { foreach (Attachment attachment in dataAttachments) { - directory = Path.GetDirectoryName(attachment.HeaderIdDirectory) ?? throw new Exception(); - File.Copy(attachment.SourceFileName, Path.Combine(directory, attachment.AttachmentId, attachment.DestinationFileName), overwrite: true); - AttachFile(url, attachment); + directory = Path.Combine(Path.GetDirectoryName(attachment.HeaderIdDirectory.Replace("Header", "Data")), attachment.AttachmentId) ?? throw new Exception(); + if (!Directory.Exists(directory)) + _ = Directory.CreateDirectory(directory); + File.Copy(attachment.SourceFileName, Path.Combine(directory, attachment.DestinationFileName), overwrite: true); } } + if (headerAttachments is not null) + { + foreach (Attachment attachment in headerAttachments) + AttachFile(url, attachment); + } + if (dataAttachments is not null) + { + foreach (Attachment attachment in dataAttachments) + AttachFile(url, attachment); + } //MessageBox.Show(r.ToString()); } catch (Exception e) diff --git a/Adaptation/_Tests/Extract/Staging/v2.56.0/MET08DDUPSFS6420.cs b/Adaptation/_Tests/Extract/Staging/v2.56.0/MET08DDUPSFS6420.cs index 5dca436..122a533 100644 --- a/Adaptation/_Tests/Extract/Staging/v2.56.0/MET08DDUPSFS6420.cs +++ b/Adaptation/_Tests/Extract/Staging/v2.56.0/MET08DDUPSFS6420.cs @@ -94,6 +94,22 @@ public class MET08DDUPSFS6420 [TestMethod] public void Staging__v2_56_0__MET08DDUPSFS6420__OpenInsightMetrologyViewerAttachments() => _MET08DDUPSFS6420.Staging__v2_56_0__MET08DDUPSFS6420__OpenInsightMetrologyViewerAttachments(); +#if DEBUG + [Ignore] +#endif + [TestMethod] + public void Staging__v2_56_0__MET08DDUPSFS6420__OpenInsightMetrologyViewerAttachments638519735942138814__HeaderId() + { + string check = "*.pdsf"; + MethodBase methodBase = new StackFrame().GetMethod(); + _MET08DDUPSFS6420.Staging__v2_56_0__MET08DDUPSFS6420__OpenInsightMetrologyViewerAttachments(); + string[] variables = _MET08DDUPSFS6420.AdaptationTesting.GetVariables(methodBase, check, validatePDSF: false); + IFileRead fileRead = _MET08DDUPSFS6420.AdaptationTesting.Get(methodBase, sourceFileLocation: variables[2], sourceFileFilter: variables[3], useCyclicalForDescription: false); + Logistics logistics = new(fileRead); + _ = Shared.AdaptationTesting.ReExtractCompareUpdatePassDirectory(variables, fileRead, logistics); + NonThrowTryCatch(); + } + #if DEBUG [Ignore] #endif diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 145459d..ea0135a 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.52.0.0")] -[assembly: AssemblyFileVersion("2.52.0.0")] +[assembly: AssemblyVersion("2.56.0.0")] +[assembly: AssemblyFileVersion("2.56.0.0")]