MET08DDUPSFS6420 - v2.43.0 - SPC and APC Bug Fix
This commit is contained in:
		| @ -8,6 +8,7 @@ using System.Collections.Generic; | ||||
| using System.IO; | ||||
| using System.Linq; | ||||
| using System.Text.Json; | ||||
| using System.Threading; | ||||
|  | ||||
| namespace Adaptation.FileHandlers.MoveMatchingFiles; | ||||
|  | ||||
| @ -152,8 +153,9 @@ public class FileRead : Shared.FileRead, IFileRead | ||||
|         return results; | ||||
|     } | ||||
|  | ||||
|     private void MoveCollection(long ticks, List<(string matchingFile, string checkFile)> collection) | ||||
|     private void MoveCollection(DateTime dateTime, List<(string matchingFile, string checkFile)> collection) | ||||
|     { | ||||
|         long preWait; | ||||
|         string errFile; | ||||
|         string checkDirectory; | ||||
|         foreach ((string matchingFile, string checkFile) in collection) | ||||
| @ -163,35 +165,44 @@ public class FileRead : Shared.FileRead, IFileRead | ||||
|             if (!Directory.Exists(checkDirectory)) | ||||
|                 _ = Directory.CreateDirectory(checkDirectory); | ||||
|             File.Move(matchingFile, checkFile); | ||||
|             if (_FileConnectorConfiguration?.FileHandleWaitTime is null) | ||||
|                 preWait = DateTime.Now.AddMilliseconds(1234).Ticks; | ||||
|             else | ||||
|                 preWait = DateTime.Now.AddMilliseconds(_FileConnectorConfiguration.FileHandleWaitTime.Value).Ticks; | ||||
|             for (short i = 0; i < short.MaxValue; i++) | ||||
|             { | ||||
|                 if (DateTime.Now.Ticks > preWait) | ||||
|                     break; | ||||
|                 Thread.Sleep(500); | ||||
|             } | ||||
|             for (int i = 0; i < int.MaxValue; i++) | ||||
|             { | ||||
|                 if (File.Exists(errFile)) | ||||
|                     throw new Exception(File.ReadAllText(errFile)); | ||||
|                 if (!File.Exists(checkFile)) | ||||
|                     break; | ||||
|                 if (new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds > _BreakAfterSeconds) | ||||
|                 if (new TimeSpan(DateTime.Now.Ticks - dateTime.Ticks).TotalSeconds > _BreakAfterSeconds) | ||||
|                     throw new Exception($"Not all files were consumned after {_BreakAfterSeconds} second(s)!"); | ||||
|                 Thread.Sleep(500); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private Tuple<string, Test[], JsonElement[], List<FileInfo>> GetExtractResult(string reportFullPath, DateTime dateTime) | ||||
|     { | ||||
|         if (dateTime == DateTime.MinValue) | ||||
|         { } | ||||
|         Tuple<string, Test[], JsonElement[], List<FileInfo>> results = new(string.Empty, null, null, new List<FileInfo>()); | ||||
|         Tuple<string, string[], string[]> pdsf = ProcessDataStandardFormat.GetLogisticsColumnsAndBody(reportFullPath); | ||||
|         _Logistics = new Logistics(reportFullPath, pdsf.Item1); | ||||
|         SetFileParameterLotIDToLogisticsMID(); | ||||
|         int numberLength = 2; | ||||
|         long ticks = DateTime.Now.Ticks; | ||||
|         string parentDirectory = Path.GetDirectoryName(Path.GetDirectoryName(reportFullPath)); | ||||
|         List<string> searchDirectories = GetSearchDirectories(numberLength, parentDirectory); | ||||
|         long ticks = dateTime.Ticks; | ||||
|         string parentParentDirectory = GetParentParent(reportFullPath); | ||||
|         List<string> searchDirectories = GetSearchDirectories(numberLength, parentParentDirectory); | ||||
|         List<string> matchingFiles = GetMatchingFiles(ticks, reportFullPath, searchDirectories); | ||||
|         if (matchingFiles.Count != searchDirectories.Count) | ||||
|             throw new Exception($"Didn't find all files after {_BreakAfterSeconds} second(s)!"); | ||||
|         List<(string matchingFile, string checkFile)> collection = GetCollection(numberLength, parentDirectory, matchingFiles); | ||||
|         MoveCollection(ticks, collection); | ||||
|         List<(string matchingFile, string checkFile)> collection = GetCollection(numberLength, parentParentDirectory, matchingFiles); | ||||
|         MoveCollection(dateTime, collection); | ||||
|         return results; | ||||
|     } | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user