Finish clientCollector
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="NLog" Version="4.7.10" />
|
||||
<PackageReference Include="SharpZipLib" Version="1.3.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@@ -15,6 +15,8 @@ using System.Text;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using ICSharpCode.SharpZipLib.GZip;
|
||||
using ICSharpCode.SharpZipLib.Tar;
|
||||
|
||||
namespace ClientCollector
|
||||
{
|
||||
@@ -27,19 +29,35 @@ namespace ClientCollector
|
||||
LogConf();
|
||||
log.Info("Start Client Collector.");
|
||||
Task taskPasp = null;
|
||||
var workPasp = false;
|
||||
Task taskData = null;
|
||||
var workData = false;
|
||||
|
||||
foreach(var arg in args)
|
||||
{
|
||||
if(int.TryParse(arg, out int flag))
|
||||
switch (flag)
|
||||
{
|
||||
case 1:
|
||||
workPasp = true;
|
||||
break;
|
||||
case 2:
|
||||
workData = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (taskPasp == null || taskPasp.IsCompleted)
|
||||
{
|
||||
log.Info("Start Pasport Task.");
|
||||
taskPasp = WorkPasport();
|
||||
log.Info(workPasp ? "Start Pasport Task." : "Skip Pasport Task.");
|
||||
taskPasp = workPasp ? WorkPasport() : Task.Delay(int.MaxValue);
|
||||
}
|
||||
if (taskData == null || taskData.IsCompleted)
|
||||
{
|
||||
log.Info("Start Data Task.");
|
||||
taskData = WorkData();
|
||||
log.Info(workData ? "Start Data Task." : "Skip Data Task.");
|
||||
taskData = workData ? WorkData() : Task.Delay(int.MaxValue);
|
||||
}
|
||||
log.Info("Wait tasks.");
|
||||
Task.WaitAny(new Task[] { taskPasp, taskData });
|
||||
@@ -160,7 +178,6 @@ namespace ClientCollector
|
||||
var currDate = GetCurrData(nameCurrDate);
|
||||
if (!currDate.HasValue)
|
||||
currDate = new DateTime(2001, 02, 01);
|
||||
var flagcycle = false;
|
||||
while (currDate.Value < DateTime.Now.AddDays(-1))
|
||||
{
|
||||
try
|
||||
@@ -200,25 +217,67 @@ namespace ClientCollector
|
||||
}
|
||||
else
|
||||
{
|
||||
var listVDP = new List<string>();
|
||||
for (var i = 0; i < 50; i++) listVDP.Add(i.ToString("D2"));
|
||||
for (var i = 90; i < 95; i++) listVDP.Add(i.ToString("D2"));
|
||||
var listVDP = new List<int>();
|
||||
for (var i = 0; i < 50; i++) listVDP.Add(i);
|
||||
for (var i = 90; i < 95; i++) listVDP.Add(i);
|
||||
foreach (var vdp in listVDP)
|
||||
{
|
||||
var pathTmp = Path.Combine(Directory.GetCurrentDirectory(), "tmpData");
|
||||
if (Directory.Exists(pathTmp)) Directory.Delete(pathTmp, true);
|
||||
Directory.CreateDirectory(pathTmp);
|
||||
for (var numFile = 0; numFile < 16; numFile++)
|
||||
{
|
||||
var pathTmp = Path.Combine(Directory.GetCurrentDirectory(), "tmpData");
|
||||
if (!Directory.Exists(pathTmp)) Directory.CreateDirectory(pathTmp);
|
||||
var nc = new NETClient(IpSTP, PortSTP);
|
||||
while (!nc.Connected())
|
||||
if(nc.ReConnect())
|
||||
await Task.Delay(2000);
|
||||
var name = currDate.Value.ToString("yyyyMMdd") + "." + vdp.ToString("D2") + numFile.ToString("X1");
|
||||
try
|
||||
{
|
||||
var nc = new NETClient(IpSTP, PortSTP);
|
||||
while (!nc.Connected())
|
||||
if (!nc.ReConnect())
|
||||
{
|
||||
log.Warn("Can't connect to STP.");
|
||||
await Task.Delay(5000);
|
||||
}
|
||||
log.Info("Try download " + name);
|
||||
var array = nc.Full_Download_NH(currDate.Value, vdp, numFile);
|
||||
nc.Close();
|
||||
if (array == null || array.Length == 0)
|
||||
{
|
||||
log.Warn("Can't connect to STP.");
|
||||
|
||||
log.Info("File " + name + " not exist.");
|
||||
continue;
|
||||
}
|
||||
|
||||
File.WriteAllBytes(Path.Combine(pathTmp, name), array);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.Warn(e.Message);
|
||||
log.Warn("Can't download " + name);
|
||||
}
|
||||
}
|
||||
{
|
||||
var files = Directory.GetFiles(pathTmp);
|
||||
if (files.Length > 0)
|
||||
{
|
||||
var targzFile = vdp.ToString("D2") + ".tar.gz";
|
||||
using (var outStream = File.Create(Path.Combine(pathTmp, targzFile)))
|
||||
using (var gzoStream = new GZipOutputStream(outStream))
|
||||
using (var tarArchive = TarArchive.CreateOutputTarArchive(gzoStream))
|
||||
foreach (var file in files)
|
||||
{
|
||||
tarArchive.RootPath = Path.GetDirectoryName(file);
|
||||
var tarEntry = TarEntry.CreateEntryFromFile(file);
|
||||
tarEntry.Name = Path.GetFileName(file);
|
||||
tarArchive.WriteEntry(tarEntry, true);
|
||||
}
|
||||
var fileStruct = File.ReadAllBytes(Path.Combine(pathTmp, targzFile));
|
||||
while (!SendData(currDate.Value, Path.GetFileName(targzFile), fileStruct))
|
||||
{
|
||||
log.Warn("Can't send data to API.");
|
||||
await Task.Delay(10000);
|
||||
}
|
||||
}
|
||||
Directory.Delete(pathTmp, true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
log.Info("End day: " + subDir);
|
||||
|
@@ -4,6 +4,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<History>True|2021-08-03T04:16:13.2186336Z;True|2021-08-03T09:08:23.8217457+05:00;True|2021-08-03T06:22:57.0758714+05:00;True|2021-08-03T06:18:08.6594656+05:00;True|2021-08-02T22:58:49.1867297+05:00;True|2021-08-02T22:56:02.6749724+05:00;True|2021-08-02T22:50:24.0842490+05:00;True|2021-08-02T22:46:50.7307549+05:00;True|2021-08-02T22:46:32.2783734+05:00;True|2021-08-02T22:37:45.7957317+05:00;True|2021-08-02T22:34:37.2905589+05:00;True|2021-08-02T22:31:30.3451541+05:00;True|2021-08-02T12:26:02.5496847+05:00;True|2021-08-01T23:12:48.3492831+05:00;True|2021-08-01T22:53:02.2382201+05:00;True|2021-08-01T22:48:16.9658882+05:00;True|2021-08-01T22:40:58.1479436+05:00;True|2021-08-01T22:28:58.9840017+05:00;True|2021-08-01T20:16:20.5210616+05:00;True|2021-08-01T19:27:43.9900600+05:00;True|2021-08-01T19:18:48.8000969+05:00;True|2021-08-01T19:15:19.9257002+05:00;True|2021-08-01T19:08:17.1315589+05:00;True|2021-07-31T20:35:08.9408458+05:00;True|2021-07-31T20:20:29.0886405+05:00;</History>
|
||||
<History>True|2021-08-03T12:34:00.5000813Z;True|2021-08-03T16:17:51.6290703+05:00;True|2021-08-03T16:09:52.5362744+05:00;True|2021-08-03T16:06:46.4824852+05:00;True|2021-08-03T15:36:41.6609527+05:00;True|2021-08-03T15:35:25.5203278+05:00;True|2021-08-03T15:31:12.5276170+05:00;True|2021-08-03T09:16:13.2186336+05:00;True|2021-08-03T09:08:23.8217457+05:00;True|2021-08-03T06:22:57.0758714+05:00;True|2021-08-03T06:18:08.6594656+05:00;True|2021-08-02T22:58:49.1867297+05:00;True|2021-08-02T22:56:02.6749724+05:00;True|2021-08-02T22:50:24.0842490+05:00;True|2021-08-02T22:46:50.7307549+05:00;True|2021-08-02T22:46:32.2783734+05:00;True|2021-08-02T22:37:45.7957317+05:00;True|2021-08-02T22:34:37.2905589+05:00;True|2021-08-02T22:31:30.3451541+05:00;True|2021-08-02T12:26:02.5496847+05:00;True|2021-08-01T23:12:48.3492831+05:00;True|2021-08-01T22:53:02.2382201+05:00;True|2021-08-01T22:48:16.9658882+05:00;True|2021-08-01T22:40:58.1479436+05:00;True|2021-08-01T22:28:58.9840017+05:00;True|2021-08-01T20:16:20.5210616+05:00;True|2021-08-01T19:27:43.9900600+05:00;True|2021-08-01T19:18:48.8000969+05:00;True|2021-08-01T19:15:19.9257002+05:00;True|2021-08-01T19:08:17.1315589+05:00;True|2021-07-31T20:35:08.9408458+05:00;True|2021-07-31T20:20:29.0886405+05:00;</History>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@@ -10,7 +10,8 @@
|
||||
"dependencies": {
|
||||
"DataClient": "0.0.3",
|
||||
"NLog": "4.7.10",
|
||||
"Newtonsoft.Json": "13.0.1"
|
||||
"Newtonsoft.Json": "13.0.1",
|
||||
"SharpZipLib": "1.3.2"
|
||||
},
|
||||
"runtime": {
|
||||
"ClientCollector.dll": {}
|
||||
@@ -117,6 +118,14 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"SharpZipLib/1.3.2": {
|
||||
"runtime": {
|
||||
"lib/netstandard2.1/ICSharpCode.SharpZipLib.dll": {
|
||||
"assemblyVersion": "1.3.2.10",
|
||||
"fileVersion": "1.3.2.10"
|
||||
}
|
||||
}
|
||||
},
|
||||
"DataClient/0.0.3": {
|
||||
"dependencies": {
|
||||
"NLog": "4.7.10",
|
||||
@@ -205,6 +214,13 @@
|
||||
"path": "nlog.extensions.logging/1.7.2",
|
||||
"hashPath": "nlog.extensions.logging.1.7.2.nupkg.sha512"
|
||||
},
|
||||
"SharpZipLib/1.3.2": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-WSdeDReL8eugMCw5BH/tFAZpgR+YsYMwm6kIvqg3J8LbfRjbbebmEzn63AbEveqyMOljBO68g6tCCv165wMkSg==",
|
||||
"path": "sharpziplib/1.3.2",
|
||||
"hashPath": "sharpziplib.1.3.2.nupkg.sha512"
|
||||
},
|
||||
"DataClient/0.0.3": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
ClientCollector/bin/Release/ICSharpCode.SharpZipLib.dll
Normal file
BIN
ClientCollector/bin/Release/ICSharpCode.SharpZipLib.dll
Normal file
Binary file not shown.
@@ -10,7 +10,8 @@
|
||||
"dependencies": {
|
||||
"DataClient": "0.0.3",
|
||||
"NLog": "4.7.10",
|
||||
"Newtonsoft.Json": "13.0.1"
|
||||
"Newtonsoft.Json": "13.0.1",
|
||||
"SharpZipLib": "1.3.2"
|
||||
},
|
||||
"runtime": {
|
||||
"ClientCollector.dll": {}
|
||||
@@ -117,6 +118,14 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"SharpZipLib/1.3.2": {
|
||||
"runtime": {
|
||||
"lib/netstandard2.1/ICSharpCode.SharpZipLib.dll": {
|
||||
"assemblyVersion": "1.3.2.10",
|
||||
"fileVersion": "1.3.2.10"
|
||||
}
|
||||
}
|
||||
},
|
||||
"DataClient/0.0.3": {
|
||||
"dependencies": {
|
||||
"NLog": "4.7.10",
|
||||
@@ -205,6 +214,13 @@
|
||||
"path": "nlog.extensions.logging/1.7.2",
|
||||
"hashPath": "nlog.extensions.logging.1.7.2.nupkg.sha512"
|
||||
},
|
||||
"SharpZipLib/1.3.2": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-WSdeDReL8eugMCw5BH/tFAZpgR+YsYMwm6kIvqg3J8LbfRjbbebmEzn63AbEveqyMOljBO68g6tCCv165wMkSg==",
|
||||
"path": "sharpziplib/1.3.2",
|
||||
"hashPath": "sharpziplib.1.3.2.nupkg.sha512"
|
||||
},
|
||||
"DataClient/0.0.3": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
ClientCollector/bin/Release/net5.0/ICSharpCode.SharpZipLib.dll
Normal file
BIN
ClientCollector/bin/Release/net5.0/ICSharpCode.SharpZipLib.dll
Normal file
Binary file not shown.
Binary file not shown.
@@ -58,6 +58,10 @@
|
||||
"Newtonsoft.Json": {
|
||||
"target": "Package",
|
||||
"version": "[13.0.1, )"
|
||||
},
|
||||
"SharpZipLib": {
|
||||
"target": "Package",
|
||||
"version": "[1.3.2, )"
|
||||
}
|
||||
},
|
||||
"imports": [
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
f5ac1b027043c0866452d0818c2e30c594726673
|
||||
b8ef049e49398d7019ddc75458087be327b62a97
|
||||
|
@@ -60,3 +60,4 @@ F:\GIT\ASCKU_PC\ClientCollector\obj\Release\net5.0\ClientCollector.dll
|
||||
F:\GIT\ASCKU_PC\ClientCollector\obj\Release\net5.0\ref\ClientCollector.dll
|
||||
F:\GIT\ASCKU_PC\ClientCollector\obj\Release\net5.0\ClientCollector.pdb
|
||||
F:\GIT\ASCKU_PC\ClientCollector\obj\Release\net5.0\ClientCollector.genruntimeconfig.cache
|
||||
D:\GIT\ASCKU_PC\ClientCollector\bin\Release\net5.0\ICSharpCode.SharpZipLib.dll
|
||||
|
Binary file not shown.
Binary file not shown.
@@ -15,5 +15,6 @@ D:\GIT\ASCKU_PC\ClientCollector\bin\Release\Microsoft.Extensions.Primitives.dll
|
||||
D:\GIT\ASCKU_PC\ClientCollector\bin\Release\Newtonsoft.Json.dll
|
||||
D:\GIT\ASCKU_PC\ClientCollector\bin\Release\NLog.dll
|
||||
D:\GIT\ASCKU_PC\ClientCollector\bin\Release\NLog.Extensions.Logging.dll
|
||||
D:\GIT\ASCKU_PC\ClientCollector\bin\Release\ICSharpCode.SharpZipLib.dll
|
||||
D:\GIT\ASCKU_PC\ClientCollector\bin\Release\DataClient.dll
|
||||
D:\GIT\ASCKU_PC\ClientCollector\bin\Release\DataClient.pdb
|
||||
|
Binary file not shown.
@@ -113,6 +113,15 @@
|
||||
"lib/net5.0/NLog.Extensions.Logging.dll": {}
|
||||
}
|
||||
},
|
||||
"SharpZipLib/1.3.2": {
|
||||
"type": "package",
|
||||
"compile": {
|
||||
"lib/netstandard2.1/ICSharpCode.SharpZipLib.dll": {}
|
||||
},
|
||||
"runtime": {
|
||||
"lib/netstandard2.1/ICSharpCode.SharpZipLib.dll": {}
|
||||
}
|
||||
},
|
||||
"DataClient/0.0.3": {
|
||||
"type": "project",
|
||||
"framework": ".NETCoreApp,Version=v5.0",
|
||||
@@ -367,6 +376,27 @@
|
||||
"nlog.extensions.logging.nuspec"
|
||||
]
|
||||
},
|
||||
"SharpZipLib/1.3.2": {
|
||||
"sha512": "WSdeDReL8eugMCw5BH/tFAZpgR+YsYMwm6kIvqg3J8LbfRjbbebmEzn63AbEveqyMOljBO68g6tCCv165wMkSg==",
|
||||
"type": "package",
|
||||
"path": "sharpziplib/1.3.2",
|
||||
"files": [
|
||||
".nupkg.metadata",
|
||||
".signature.p7s",
|
||||
"images/sharpziplib-nuget-256x256.png",
|
||||
"lib/net45/ICSharpCode.SharpZipLib.dll",
|
||||
"lib/net45/ICSharpCode.SharpZipLib.pdb",
|
||||
"lib/net45/ICSharpCode.SharpZipLib.xml",
|
||||
"lib/netstandard2.0/ICSharpCode.SharpZipLib.dll",
|
||||
"lib/netstandard2.0/ICSharpCode.SharpZipLib.pdb",
|
||||
"lib/netstandard2.0/ICSharpCode.SharpZipLib.xml",
|
||||
"lib/netstandard2.1/ICSharpCode.SharpZipLib.dll",
|
||||
"lib/netstandard2.1/ICSharpCode.SharpZipLib.pdb",
|
||||
"lib/netstandard2.1/ICSharpCode.SharpZipLib.xml",
|
||||
"sharpziplib.1.3.2.nupkg.sha512",
|
||||
"sharpziplib.nuspec"
|
||||
]
|
||||
},
|
||||
"DataClient/0.0.3": {
|
||||
"type": "project",
|
||||
"path": "../DataClient/DataClient.csproj",
|
||||
@@ -377,7 +407,8 @@
|
||||
"net5.0": [
|
||||
"DataClient >= 0.0.3",
|
||||
"NLog >= 4.7.10",
|
||||
"Newtonsoft.Json >= 13.0.1"
|
||||
"Newtonsoft.Json >= 13.0.1",
|
||||
"SharpZipLib >= 1.3.2"
|
||||
]
|
||||
},
|
||||
"packageFolders": {
|
||||
@@ -440,6 +471,10 @@
|
||||
"Newtonsoft.Json": {
|
||||
"target": "Package",
|
||||
"version": "[13.0.1, )"
|
||||
},
|
||||
"SharpZipLib": {
|
||||
"target": "Package",
|
||||
"version": "[1.3.2, )"
|
||||
}
|
||||
},
|
||||
"imports": [
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "4epxhxxqM5SAn5/9F6/bGIHXw5/ScXkV3Fnpxx1s5LXd8HLEicu36cn+HzGRnZuZrclSVkG7GSGYyc/b7S5lXA==",
|
||||
"dgSpecHash": "4l57LQEQv639e2VbxIp9WkcTInbDK0EZx777bBv5wjTKDBusTXiAgsFdOFRmSsl+EQmDdrGC6PetLc3CUFikGg==",
|
||||
"success": true,
|
||||
"projectFilePath": "D:\\GIT\\ASCKU_PC\\ClientCollector\\ClientCollector.csproj",
|
||||
"expectedPackageFiles": [
|
||||
@@ -13,7 +13,8 @@
|
||||
"C:\\Users\\google\\.nuget\\packages\\microsoft.extensions.primitives\\5.0.0\\microsoft.extensions.primitives.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\google\\.nuget\\packages\\newtonsoft.json\\13.0.1\\newtonsoft.json.13.0.1.nupkg.sha512",
|
||||
"C:\\Users\\google\\.nuget\\packages\\nlog\\4.7.10\\nlog.4.7.10.nupkg.sha512",
|
||||
"C:\\Users\\google\\.nuget\\packages\\nlog.extensions.logging\\1.7.2\\nlog.extensions.logging.1.7.2.nupkg.sha512"
|
||||
"C:\\Users\\google\\.nuget\\packages\\nlog.extensions.logging\\1.7.2\\nlog.extensions.logging.1.7.2.nupkg.sha512",
|
||||
"C:\\Users\\google\\.nuget\\packages\\sharpziplib\\1.3.2\\sharpziplib.1.3.2.nupkg.sha512"
|
||||
],
|
||||
"logs": []
|
||||
}
|
Reference in New Issue
Block a user