2024-11-26 15:14:31 +01:00
|
|
|
|
namespace AutoClient.Modes.FolderStore
|
|
|
|
|
|
{
|
|
|
|
|
|
public class FolderWorkDispatcher
|
|
|
|
|
|
{
|
2024-11-26 15:57:34 +01:00
|
|
|
|
private readonly string[] files = Array.Empty<string>();
|
|
|
|
|
|
private int index = 0;
|
2024-11-26 15:14:31 +01:00
|
|
|
|
|
|
|
|
|
|
public FolderWorkDispatcher(string folder)
|
|
|
|
|
|
{
|
|
|
|
|
|
var fs = Directory.GetFiles(folder);
|
2024-11-26 15:57:34 +01:00
|
|
|
|
var result = new List<string>();
|
2024-11-26 15:14:31 +01:00
|
|
|
|
foreach (var f in fs)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!f.ToLowerInvariant().Contains(".json"))
|
|
|
|
|
|
{
|
|
|
|
|
|
var info = new FileInfo(f);
|
|
|
|
|
|
if (info.Exists && info.Length > 1024 * 1024) // larger than 1MB
|
|
|
|
|
|
{
|
2024-11-26 15:57:34 +01:00
|
|
|
|
result.Add(f);
|
2024-11-26 15:14:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-11-26 15:57:34 +01:00
|
|
|
|
files = result.ToArray();
|
2024-11-26 15:14:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-26 16:22:43 +01:00
|
|
|
|
public FileIndex GetFileToCheck()
|
2024-11-26 15:14:31 +01:00
|
|
|
|
{
|
2024-11-26 16:22:43 +01:00
|
|
|
|
var file = new FileIndex(files[index], index);
|
2024-11-26 15:57:34 +01:00
|
|
|
|
index = (index + 1) % files.Length;
|
|
|
|
|
|
return file;
|
2024-11-26 15:14:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-26 15:57:34 +01:00
|
|
|
|
public void ResetIndex()
|
2024-11-26 15:14:31 +01:00
|
|
|
|
{
|
2024-11-26 15:57:34 +01:00
|
|
|
|
index = 0;
|
2024-11-26 15:14:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-11-26 16:22:43 +01:00
|
|
|
|
|
|
|
|
|
|
public class FileIndex
|
|
|
|
|
|
{
|
|
|
|
|
|
public FileIndex(string file, int index)
|
|
|
|
|
|
{
|
|
|
|
|
|
File = file;
|
|
|
|
|
|
Index = index;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public string File { get; }
|
|
|
|
|
|
public int Index { get; }
|
|
|
|
|
|
}
|
2024-11-26 15:14:31 +01:00
|
|
|
|
}
|