Code: Select all
private bool LookupHistoryFile(string salesID, MapValueContainer folderInfo, string created)
{
var monthYearPath = GetMonthFolder(created);
var filename = salesID.RemoveLeadingZeros().ToXmlFileName("CD");
var path = $"{folderInfo.ShopType}\\{folderInfo.CustomerFolderName}\\Remote\\History\\{monthYearPath}";
var lookupPath = string.Format("{0}\\{1}\\", _remoteDrivePath, path);
var doesFolderHaveHistory = Directory.Exists(lookupPath);
if (!doesFolderHaveHistory) return false;
var dirInfo = new DirectoryInfo(lookupPath);
return dirInfo.EnumerateFiles(searchPattern: "*.xml", SearchOption.TopDirectoryOnly).Where(f => f.Name.EndsWith(filename)).Any();
}
< /code>
My foreach -Liste hat ungefähr 500 - 600 Elemente. Das [url=viewtopic.php?t=15738]Problem[/url] tritt auf, wenn ich ein Remote -Netzwerk -Laufwerk mit über 1000 Dateien aufzählt. Die Ausführung stoppt fast vollständig dirInfo.EnumerateFiles(searchPattern: "*.xml", SearchOption.TopDirectoryOnly).Where(f => f.Name.EndsWith(filename)).Any();
Code: Select all
public List LookupHistoryCDFiles(IEnumerable orderCompleteResults)
{
var results = orderCompleteResults.ToList();
for (int i = 0; i < orderCompleteResults.Count(); i++)
{
if (Constants.Maps.CustomerFolderMap.TryGetValue(results[i].CustomerNo, out var folderMap))
{
results[i].CustomerName = folderMap.CustomerFolderName;
results[i].CDHistoryFileExists = LookupHistoryFile(results[i].SalesId, folderMap, results[i].Created);
}
else
{
_logger.LogWarning($"Cannot locate order: {results[i].OrderId} the customer id: {results[i].CustomerNo} in customer folder maps");
}
}
return results;
}