Stratus
This commit is contained in:
parent
13b9731edf
commit
e6442fff9f
142
.vscode/.UserSecrets/file-watcher.json
vendored
Normal file
142
.vscode/.UserSecrets/file-watcher.json
vendored
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
{
|
||||||
|
"CompassConfiguration": {
|
||||||
|
"Destination": "\\\\10.95.1.211\\Share\\RawData\\TRENDLOG",
|
||||||
|
"HoursBack": 4,
|
||||||
|
"MonthPattern": "MMM",
|
||||||
|
"Pattern": "*.csv",
|
||||||
|
"Source": "C:/Alerton/Compass/1.0/CLIMATEC/archive/trendlog",
|
||||||
|
"TriggerAppendage": ".trg",
|
||||||
|
"YearPattern": "yyyy"
|
||||||
|
},
|
||||||
|
"DriveConfiguration": {
|
||||||
|
"Letter": "s",
|
||||||
|
"Password": "zjtaxxwdEnJ/9tfXQFdj6TKiKBAmpCHWjdi6XYrflw4=",
|
||||||
|
"Share": "\\\\10.95.1.211\\Share",
|
||||||
|
"Use": true,
|
||||||
|
"User": "infineon\\ECMESEAF"
|
||||||
|
},
|
||||||
|
"EAFLogConfiguration": {
|
||||||
|
"SearchPattern": "*.log*"
|
||||||
|
},
|
||||||
|
"EAFProgramDataConfiguration": {
|
||||||
|
"Destination": "\\\\messa08ec.infineon.com\\d$\\ProgramData\\EC_Characterization_Si\\RawData",
|
||||||
|
"Source": "D:/ProgramData/EC_Characterization_Si/RawData"
|
||||||
|
},
|
||||||
|
"EDADatabaseConfiguration": {
|
||||||
|
"CSharpDateTimeFormat": "yyyy-MM-dd_hh:mm:ss tt",
|
||||||
|
"FileShare": "\\\\mesfs.infineon.com\\EC_EDA",
|
||||||
|
"Name": "Staging",
|
||||||
|
"OracleDateTimeFormat": "yyyy-MM-dd_hh:mi:ss AM",
|
||||||
|
"Password": "8vIs2nEZPkcdBUfXX0hHlA==",
|
||||||
|
"TNS": "(description=(address_list=(address=(protocol=tcp)(host=fimess-db.mes.infineon.com)(port=7001)))(connect_data=(sid=fimess)))",
|
||||||
|
"TNSX": "(description=(address_list=(address=(protocol=tcp)(host=fimesp-db.mes.infineon.com)(port=7002)))(connect_data=(sid=fimesp)))",
|
||||||
|
"UserName": "edastag"
|
||||||
|
},
|
||||||
|
"MetrologyConfiguration": {
|
||||||
|
"DeleteOlderThanWeeks": 16,
|
||||||
|
"DirectoriesBack": 2,
|
||||||
|
"HardcodedValues": [
|
||||||
|
"BIORAD2",
|
||||||
|
"BIORAD3",
|
||||||
|
"BIORAD4",
|
||||||
|
"BIORAD5",
|
||||||
|
"CDE2",
|
||||||
|
"CDE3",
|
||||||
|
"CDE4",
|
||||||
|
"CDE5",
|
||||||
|
"CDE6",
|
||||||
|
"HGCV1",
|
||||||
|
"HGCV2",
|
||||||
|
"HGCV3",
|
||||||
|
"TENCOR1",
|
||||||
|
"TENCOR2",
|
||||||
|
"TENCOR3",
|
||||||
|
"SP101",
|
||||||
|
"SPV01",
|
||||||
|
"SRP",
|
||||||
|
"WC6Inch",
|
||||||
|
"WC8Inch",
|
||||||
|
"Bio-Rad"
|
||||||
|
],
|
||||||
|
"SourceDirectories": [
|
||||||
|
"\\\\messa01ec.infineon.com\\apps\\Metrology\\Run Data Repository\\MET08ANLYSDIFAAST230\\Source\\MET08ANLYSDIFAAST230",
|
||||||
|
"\\\\messa01ec.infineon.com\\apps\\Metrology\\Run Data Repository\\MET08DDUPSFS6420\\Source\\MET08DDUPSFS6420",
|
||||||
|
"\\\\messa01ec.infineon.com\\apps\\Metrology\\Run Data Repository\\MET08DDUPSP1TBI\\Source\\MET08DDUPSP1TBI",
|
||||||
|
"\\\\messa01ec.infineon.com\\apps\\Metrology\\Run Data Repository\\MET08RESIHGCV\\Source\\MET08RESIHGCV",
|
||||||
|
"\\\\messa01ec.infineon.com\\apps\\Metrology\\Run Data Repository\\MET08RESIMAPCDE\\Source\\MET08RESIMAPCDE",
|
||||||
|
"\\\\messa01ec.infineon.com\\apps\\Metrology\\Run Data Repository\\MET08RESISRP2100\\Source\\MET08RESISRP2100",
|
||||||
|
"\\\\messa01ec.infineon.com\\apps\\Metrology\\Run Data Repository\\MET08THFTIRQS408M\\Source\\MET08THFTIRQS408M",
|
||||||
|
"\\\\messa01ec.infineon.com\\apps\\Metrology\\Run Data Repository\\MET08THFTIRSTRATUS\\Source\\MET08THFTIRSTRATUS"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"NugetConfiguration": {
|
||||||
|
"Destination": "L:/File-Watcher/Helper/Nuget/Packages",
|
||||||
|
"KeyFileExtension": ".nuspec",
|
||||||
|
"KeyFileExtensionB": "icon",
|
||||||
|
"KeyFileExtensionC": "readme",
|
||||||
|
"RenameToLower": true,
|
||||||
|
"SearchPattern": "*.nupkg",
|
||||||
|
"Source": "C:/Users/phares/.nuget/packages"
|
||||||
|
},
|
||||||
|
"SerialConfiguration": {
|
||||||
|
"Destination": "L:/DevOps/MESA_FI/File-Watcher/.vscode",
|
||||||
|
"GhostPCLFileName": "gpcl6win64.exe",
|
||||||
|
"LincPDFCFileName": "LincPDFC.exe",
|
||||||
|
"PortName": "COM37"
|
||||||
|
},
|
||||||
|
"StratusConfiguration": {
|
||||||
|
"Days": 4,
|
||||||
|
"Destination": "D:/Tmp",
|
||||||
|
"DestinationX": "\\\\10.95.1.211\\Share\\RawData\\BIORAD4",
|
||||||
|
"FileDelimiterPattern": "Mean [0-9.]*, STDD [0-9.]*",
|
||||||
|
"WatchFile": "DataBiorad.txt"
|
||||||
|
},
|
||||||
|
"TransmissionControlProtocolConfiguration": {
|
||||||
|
"Destination": "L:/DevOps/MESA_FI/File-Watcher/.vscode",
|
||||||
|
"GhostPCLFileName": "gpcl6win64.exe",
|
||||||
|
"IPAddress": "COM37",
|
||||||
|
"IPAddresses": {
|
||||||
|
"10.95.154.19": [
|
||||||
|
"EPP-WEST",
|
||||||
|
"6INCH",
|
||||||
|
"WC6INCH3"
|
||||||
|
],
|
||||||
|
"10.95.154.43": [
|
||||||
|
"FQA",
|
||||||
|
"6INCH",
|
||||||
|
"WC6INCH1"
|
||||||
|
],
|
||||||
|
"10.95.154.44": [
|
||||||
|
"MU",
|
||||||
|
"6INCH",
|
||||||
|
"WC6INCH2"
|
||||||
|
],
|
||||||
|
"10.95.154.46": [
|
||||||
|
"EPP-EAST",
|
||||||
|
"6INCH",
|
||||||
|
"WC6INCH4"
|
||||||
|
],
|
||||||
|
"10.95.154.47": [
|
||||||
|
"FQA",
|
||||||
|
"8INCH",
|
||||||
|
"WC8INCH1"
|
||||||
|
],
|
||||||
|
"10.95.154.48": [
|
||||||
|
"MU",
|
||||||
|
"8INCH",
|
||||||
|
"WC8INCH2"
|
||||||
|
],
|
||||||
|
"10.95.154.49": [
|
||||||
|
"EPP-WEST",
|
||||||
|
"8INCH",
|
||||||
|
"WC8INCH3"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Port": 950,
|
||||||
|
"Server": false
|
||||||
|
},
|
||||||
|
"WaferCounterConfiguration": {
|
||||||
|
"Destination": "\\\\mestsa01ec.infineon.com\\apps\\WaferCounter\\V203",
|
||||||
|
"MatchPath": false
|
||||||
|
}
|
||||||
|
}
|
51
.vscode/.UserSecrets/secrets.json
vendored
Normal file
51
.vscode/.UserSecrets/secrets.json
vendored
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
{
|
||||||
|
"_Application": "File-Watcher",
|
||||||
|
"_UserSecretsId": "6062c774-99a9-4f4a-b42d-a9cb7fcbd8be",
|
||||||
|
"BuildNumber": "1234",
|
||||||
|
"ConfigurationDirectoryNames": [
|
||||||
|
"Microsoft",
|
||||||
|
"UserSecrets",
|
||||||
|
"6062c774-99a9-4f4a-b42d-a9cb7fcbd8be"
|
||||||
|
],
|
||||||
|
"ConfigurationSpecialFolder": 26,
|
||||||
|
"ConfigurationFileName": "file-watcher.json",
|
||||||
|
"Company": "Infineon Technologies Americas Corp.",
|
||||||
|
"GitCommitSeven": "asdf",
|
||||||
|
"HelperX": "HelperTCP",
|
||||||
|
"HelperXX": "HelperNuget",
|
||||||
|
"HelperXXX": "HelperEAFLog",
|
||||||
|
"HelperXXXX": "HelperSerial",
|
||||||
|
"HelperXXXXX": "HelperCompass",
|
||||||
|
"Helper": "HelperStratus",
|
||||||
|
"HelperXXXXXXX": "HelperEventLog",
|
||||||
|
"HelperXXXXXXXX": "HelperInfinityQS",
|
||||||
|
"HelperXXXXXXXXX": "HelperWaferCounter",
|
||||||
|
"HelperXXXXXXXXXX": "HelperEAFProgramData",
|
||||||
|
"HelperXXXXXXXXXXX": "HelperMetrologyFiles",
|
||||||
|
"Logging:Console:FormatterName": "simple",
|
||||||
|
"Logging:Console:FormatterOptions:IncludeScopes": "True",
|
||||||
|
"Logging:Console:FormatterOptions:SingleLine": "True",
|
||||||
|
"Logging:Console:FormatterOptions:TimestampFormat": "HH:mm:ss ",
|
||||||
|
"Logging:Console:FormatterOptions:UseUtcTimestamp": "True",
|
||||||
|
"Logging:Console:LogLevel:Default": "Information",
|
||||||
|
"Logging:Console:LogLevel:Microsoft": "Warning",
|
||||||
|
"Logging:Console:LogLevel:Microsoft.Hosting.Lifetime": "Information",
|
||||||
|
"Logging:Debug:FormatterName": "simple",
|
||||||
|
"Logging:Debug:FormatterOptions:IncludeScopes": "True",
|
||||||
|
"Logging:Debug:FormatterOptions:SingleLine": "True",
|
||||||
|
"Logging:Debug:FormatterOptions:TimestampFormat": "HH:mm:ss ",
|
||||||
|
"Logging:Debug:FormatterOptions:UseUtcTimestamp": "True",
|
||||||
|
"Logging:Debug:LogLevel:Default": "Warning",
|
||||||
|
"Logging:Debug:LogLevel:Microsoft": "Information",
|
||||||
|
"Logging:Debug:LogLevel:Microsoft.Hosting.Lifetime": "Debug",
|
||||||
|
"Logging:EventLog:LogLevel:Default": "Warning",
|
||||||
|
"Logging:EventSource:LogLevel:Default": "Warning",
|
||||||
|
"Logging:LogLevel:Default": "Debug",
|
||||||
|
"Logging:LogLevel:Microsoft": "Information",
|
||||||
|
"Logging:LogLevel:Microsoft.Hosting.Lifetime": "Debug",
|
||||||
|
"MillisecondsDelay": 54000,
|
||||||
|
"URLs": "http://localhost:5003;",
|
||||||
|
"WatchDirectory": "D:/Tmp/Phares/Event-Log",
|
||||||
|
"WatchDirectoryXX": "D:/EAF/EAF Instances",
|
||||||
|
"WatchDirectoryXXX": "C:/software/WaferCounter/V203"
|
||||||
|
}
|
5
.vscode/mklink.md
vendored
Normal file
5
.vscode/mklink.md
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# mklink
|
||||||
|
|
||||||
|
```bash Wed Jul 24 2024 08:28:01 GMT-0700 (Mountain Standard Time)
|
||||||
|
mklink /J "L:\DevOps\Mesa_FI\File-Watcher\.vscode\.UserSecrets" "C:\Users\phares\AppData\Roaming\Microsoft\UserSecrets\6062c774-99a9-4f4a-b42d-a9cb7fcbd8be"
|
||||||
|
```
|
13
.vscode/tasks.json
vendored
13
.vscode/tasks.json
vendored
@ -71,16 +71,15 @@
|
|||||||
],
|
],
|
||||||
"problemMatcher": "$msCompile"
|
"problemMatcher": "$msCompile"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"label": "File-Folder-Helper AOT s V Helpers",
|
|
||||||
"type": "shell",
|
|
||||||
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe s V Helpers",
|
|
||||||
"problemMatcher": []
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"label": "File-Folder-Helper AOT s X Sort",
|
"label": "File-Folder-Helper AOT s X Sort",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe s X 'L:/DevOps/Mesa_FI/File-Watcher' Day-Helper-2024-01-08 'L:/DevOps/Mesa_FI/File-Watcher/Helpers'",
|
"command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe",
|
||||||
|
"args": [
|
||||||
|
"s",
|
||||||
|
"X",
|
||||||
|
"L:/DevOps/Mesa_FI/File-Watcher' Day-Helper-2024-01-08 'L:/DevOps/Mesa_FI/File-Watcher/Helpers"
|
||||||
|
],
|
||||||
"problemMatcher": []
|
"problemMatcher": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -10,15 +10,15 @@
|
|||||||
<UserSecretsId>6062c774-99a9-4f4a-b42d-a9cb7fcbd8be</UserSecretsId>
|
<UserSecretsId>6062c774-99a9-4f4a-b42d-a9cb7fcbd8be</UserSecretsId>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.5" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.7" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
|
||||||
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="23.4.0" />
|
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="23.5.0" />
|
||||||
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="8.0.5" />
|
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="8.0.7" />
|
||||||
<PackageReference Include="System.IO.Ports" Version="8.0.0" />
|
<PackageReference Include="System.IO.Ports" Version="8.0.0" />
|
||||||
<PackageReference Include="System.Text.Json" Version="8.0.3" />
|
<PackageReference Include="System.Text.Json" Version="8.0.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Condition="'$(Configuration)' == 'Debug'" Include="\\mestsa003.infineon.com\EC_EAFRepository\Staging\DeploymentStorage\GhostPCL\gpcl6win64\gpcl6dll64.dll">
|
<None Condition="'$(Configuration)' == 'Debug'" Include="\\mestsa003.infineon.com\EC_EAFRepository\Staging\DeploymentStorage\GhostPCL\gpcl6win64\gpcl6dll64.dll">
|
||||||
|
45
File-Watcher.yaml
Normal file
45
File-Watcher.yaml
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
trigger:
|
||||||
|
branches:
|
||||||
|
include:
|
||||||
|
- main
|
||||||
|
pool:
|
||||||
|
name: eaf
|
||||||
|
demands: eaf-ems-pc
|
||||||
|
variables:
|
||||||
|
buildConfiguration: "Release"
|
||||||
|
ASPNETCORE_ENVIRONMENT: "Production"
|
||||||
|
jobs:
|
||||||
|
- job: BuildTestPublish
|
||||||
|
steps:
|
||||||
|
- script: |
|
||||||
|
echo repo: $(Build.Repository.Name)
|
||||||
|
echo buildId: $(Build.BuildId)
|
||||||
|
echo build configuration: $(BuildConfiguration)
|
||||||
|
displayName: "Echo Check"
|
||||||
|
|
||||||
|
- task: DotNetCoreCLI@2
|
||||||
|
displayName: "dotnet build"
|
||||||
|
inputs:
|
||||||
|
command: "build"
|
||||||
|
configuration: $(BuildConfiguration)
|
||||||
|
|
||||||
|
- task: DotNetCoreCLI@2
|
||||||
|
displayName: "dotnet test"
|
||||||
|
inputs:
|
||||||
|
command: "test"
|
||||||
|
arguments: "-c $(BuildConfiguration)"
|
||||||
|
publishTestResults: true
|
||||||
|
projects: MesaProveInTests
|
||||||
|
|
||||||
|
- task: DotNetCoreCLI@2
|
||||||
|
displayName: "dotnet publish"
|
||||||
|
inputs:
|
||||||
|
command: "publish"
|
||||||
|
publishWebProjects: true
|
||||||
|
arguments: "-c $(BuildConfiguration) -o $(Build.ArtifactStagingDirectory) -r win-x64 /p:EnvironmentName=$(ASPNETCORE_ENVIRONMENT)"
|
||||||
|
|
||||||
|
- task: CopyFiles@2
|
||||||
|
displayName: "Copy Files"
|
||||||
|
inputs:
|
||||||
|
SourceFolder: "$(Build.ArtifactStagingDirectory)"
|
||||||
|
TargetFolder: 'D:\$(Build.Repository.Name)\$(Build.BuildId)\$(BuildConfiguration)'
|
@ -13,13 +13,14 @@ internal static partial class HelperStratus
|
|||||||
private static void TryMoveFile(AppSettings appSettings, string checkFile)
|
private static void TryMoveFile(AppSettings appSettings, string checkFile)
|
||||||
{
|
{
|
||||||
string line;
|
string line;
|
||||||
|
string checkDirectory;
|
||||||
string weekYearDirectory;
|
string weekYearDirectory;
|
||||||
List<string> collection = [];
|
List<string> collection = [];
|
||||||
DateTime dateTime = DateTime.Now;
|
FileInfo fileInfo = new(checkFile);
|
||||||
Calendar calendar = new CultureInfo("en-US").Calendar;
|
Calendar calendar = new CultureInfo("en-US").Calendar;
|
||||||
char start = appSettings.StratusConfiguration.FileDelimiterPattern[0];
|
char start = appSettings.StratusConfiguration.FileDelimiterPattern[0];
|
||||||
string[] lines = !File.Exists(checkFile) ? [] : File.ReadAllLines(checkFile);
|
string[] lines = !fileInfo.Exists ? [] : File.ReadAllLines(checkFile);
|
||||||
string weekOfYear = calendar.GetWeekOfYear(dateTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
string weekOfYear = calendar.GetWeekOfYear(fileInfo.CreationTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday).ToString("00");
|
||||||
for (int i = 0; i < lines.Length; i++)
|
for (int i = 0; i < lines.Length; i++)
|
||||||
{
|
{
|
||||||
line = lines[i];
|
line = lines[i];
|
||||||
@ -28,10 +29,11 @@ internal static partial class HelperStratus
|
|||||||
continue;
|
continue;
|
||||||
if (!Regex.Match(line, appSettings.StratusConfiguration.FileDelimiterPattern).Success)
|
if (!Regex.Match(line, appSettings.StratusConfiguration.FileDelimiterPattern).Success)
|
||||||
continue;
|
continue;
|
||||||
weekYearDirectory = Path.Combine(appSettings.WatchDirectory, $"{dateTime.Year}_Week_{weekOfYear}");
|
weekYearDirectory = Path.Combine(appSettings.WatchDirectory, $"{fileInfo.CreationTime.Year}_Week_{weekOfYear}");
|
||||||
if (!Directory.Exists(weekYearDirectory))
|
checkDirectory = Path.Combine(weekYearDirectory, fileInfo.CreationTime.ToString("yyyy-MM-dd"));
|
||||||
_ = Directory.CreateDirectory(weekYearDirectory);
|
if (!Directory.Exists(checkDirectory))
|
||||||
File.WriteAllLines(Path.Combine(weekYearDirectory, $"{dateTime.Ticks}.txt"), collection);
|
_ = Directory.CreateDirectory(checkDirectory);
|
||||||
|
File.WriteAllLines(Path.Combine(checkDirectory, $"{fileInfo.CreationTime.Ticks}.txt"), collection);
|
||||||
collection.Clear();
|
collection.Clear();
|
||||||
for (int j = i + 1; j < lines.Length; j++)
|
for (int j = i + 1; j < lines.Length; j++)
|
||||||
collection.Add(lines[j]);
|
collection.Add(lines[j]);
|
||||||
@ -41,8 +43,44 @@ internal static partial class HelperStratus
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void TryArchiveFilesFramework(string sourceDirectory, string pattern, string archiveDirectory, int days)
|
||||||
|
{
|
||||||
|
string checkFile;
|
||||||
|
FileInfo fileInfo;
|
||||||
|
string weekOfYear;
|
||||||
|
string checkDirectory;
|
||||||
|
string[] directorySegments;
|
||||||
|
DateTime dateTime = DateTime.Now.AddDays(-days);
|
||||||
|
Calendar calendar = new CultureInfo("en-US").Calendar;
|
||||||
|
string[] sourceDirectorySegments = sourceDirectory.Split(Path.DirectorySeparatorChar);
|
||||||
|
string[] files = Directory.GetFiles(sourceDirectory, pattern, SearchOption.AllDirectories);
|
||||||
|
if (sourceDirectorySegments.Length < 2)
|
||||||
|
throw new Exception("Can't be root drive!");
|
||||||
|
foreach (string file in files)
|
||||||
|
{
|
||||||
|
fileInfo = new FileInfo(file);
|
||||||
|
if (string.IsNullOrEmpty(fileInfo.DirectoryName) || fileInfo.LastWriteTime > dateTime)
|
||||||
|
continue;
|
||||||
|
directorySegments = fileInfo.DirectoryName.Split(Path.DirectorySeparatorChar);
|
||||||
|
if (directorySegments.Length < sourceDirectorySegments.Length)
|
||||||
|
continue;
|
||||||
|
weekOfYear = $"{fileInfo.CreationTime.Year}_Week_{calendar.GetWeekOfYear(fileInfo.CreationTime, CalendarWeekRule.FirstDay, DayOfWeek.Sunday):00}";
|
||||||
|
checkDirectory = string.Concat(archiveDirectory, Path.DirectorySeparatorChar, weekOfYear);
|
||||||
|
for (int i = sourceDirectorySegments.Length; i < directorySegments.Length; i++)
|
||||||
|
checkDirectory = string.Concat(checkDirectory, Path.DirectorySeparatorChar, directorySegments[i]);
|
||||||
|
checkDirectory = string.Concat(checkDirectory, Path.DirectorySeparatorChar, fileInfo.CreationTime.ToString("yyyy-MM-dd"));
|
||||||
|
if (!Directory.Exists(checkDirectory))
|
||||||
|
_ = Directory.CreateDirectory(checkDirectory);
|
||||||
|
checkFile = Path.Combine(checkDirectory, fileInfo.Name);
|
||||||
|
if (File.Exists(checkFile))
|
||||||
|
continue;
|
||||||
|
File.Move(fileInfo.FullName, checkFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal static bool MoveFile(AppSettings appSettings, ILogger<Worker> logger)
|
internal static bool MoveFile(AppSettings appSettings, ILogger<Worker> logger)
|
||||||
{
|
{
|
||||||
|
// http://10.95.154.10:8081/2023_Week_45/2023-11-08/a.txt
|
||||||
string checkFile = Path.Combine(appSettings.WatchDirectory, appSettings.StratusConfiguration.WatchFile);
|
string checkFile = Path.Combine(appSettings.WatchDirectory, appSettings.StratusConfiguration.WatchFile);
|
||||||
try
|
try
|
||||||
{ TryMoveFile(appSettings, checkFile); }
|
{ TryMoveFile(appSettings, checkFile); }
|
||||||
@ -51,6 +89,19 @@ internal static partial class HelperStratus
|
|||||||
logger.LogError(ex, "Inner loop error!");
|
logger.LogError(ex, "Inner loop error!");
|
||||||
Thread.Sleep(appSettings.MillisecondsDelay * 5);
|
Thread.Sleep(appSettings.MillisecondsDelay * 5);
|
||||||
}
|
}
|
||||||
|
Console.WriteLine("Hello");
|
||||||
|
int days = appSettings.StratusConfiguration.Days;
|
||||||
|
string sourceDirectory = appSettings.WatchDirectory;
|
||||||
|
int millisecondsDelay = appSettings.MillisecondsDelay;
|
||||||
|
string pattern = appSettings.StratusConfiguration.FileDelimiterPattern;
|
||||||
|
string archiveDirectory = Path.GetFullPath(appSettings.StratusConfiguration.Destination);
|
||||||
|
try
|
||||||
|
{ TryArchiveFilesFramework(sourceDirectory, pattern, archiveDirectory, days); }
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.LogError(ex, "Inner loop error!");
|
||||||
|
Thread.Sleep(millisecondsDelay * 5);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,8 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace File_Watcher.Models;
|
namespace File_Watcher.Models;
|
||||||
|
|
||||||
public record StratusConfiguration(string Destination,
|
public record StratusConfiguration(int Days,
|
||||||
|
string Destination,
|
||||||
string FileDelimiterPattern,
|
string FileDelimiterPattern,
|
||||||
string WatchFile)
|
string WatchFile)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user