mid work conf
This commit is contained in:
@@ -20,45 +20,22 @@ namespace DataClient
|
||||
{
|
||||
log.Trace("Create instance class.");
|
||||
GetConfig();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
log.Info("Test_Info");
|
||||
log.Warn("Test_Warn");
|
||||
log.Debug("Test_Debug");
|
||||
log.Error("Test_Error");
|
||||
log.Fatal("Test_Fatal");
|
||||
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
log.Warn(e, "Test_Exception");
|
||||
}
|
||||
}
|
||||
public STPClient(string confDir)
|
||||
{
|
||||
log.Trace("Create instance class.");
|
||||
this.confDir = confDir;
|
||||
GetConfig();
|
||||
try
|
||||
{
|
||||
log.Trace("Create STPClient instance.");
|
||||
log.Info("Test_Info");
|
||||
log.Warn("Test_Warn");
|
||||
log.Debug("Test_Debug");
|
||||
log.Error("Test_Error");
|
||||
log.Fatal("Test_Fatal");
|
||||
throw new Exception("MyException");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.Warn(e, "Test_Exception");
|
||||
}
|
||||
}
|
||||
public bool AddServer(string name, string ip, int port, string dir)
|
||||
{
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
private void GetConfig()
|
||||
{
|
||||
var jsonString = "";
|
||||
{
|
||||
log.Trace("Get config from: " + confDir);
|
||||
string jsonString;
|
||||
try
|
||||
{
|
||||
log.Trace("Read config file.");
|
||||
@@ -66,22 +43,42 @@ namespace DataClient
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.Error(e, "Can't read config file.");
|
||||
log.Warn(e, "Can't read config file.");
|
||||
return;
|
||||
}
|
||||
var conf = (JObject)JsonConvert.DeserializeObject(jsonString);
|
||||
if (!conf.HasValues && !conf["servers"].HasValues && conf["servers"].Type != JTokenType.Array)
|
||||
if (!conf.HasValues && !conf["servers"].HasValues && conf["servers"].Type != JTokenType.Array)
|
||||
{
|
||||
log.Warn("Exist servers object in config file.");
|
||||
log.Warn("Doesn't exist \"servers\" object in config file.");
|
||||
return;
|
||||
}
|
||||
foreach(var s in conf["servers"])
|
||||
{
|
||||
var name = (s["name"].Type == JTokenType.String) ? (string)s["name"] : "default";
|
||||
var ip = (s["ip"].Type == JTokenType.String && IPAddress.TryParse((string)s["ip"], out IPAddress address)) ? (string)s["name"] : null;
|
||||
var count = -1;
|
||||
foreach (var s in conf["servers"])
|
||||
{
|
||||
count++;
|
||||
var name = (s["name"].Type == JTokenType.String && ((string)s["name"]).Length > 0) ? (string)s["name"] : "default";
|
||||
var ip = (s["ip"].Type == JTokenType.String && IPAddress.TryParse((string)s["ip"], out _)) ? (string)s["ip"] : "";
|
||||
var port = (s["port"].Type == JTokenType.Integer) ? (int)s["port"] : -1;
|
||||
var dir = (s["dir"].Type == JTokenType.String && Directory.Exists((string)s["dir"])) ? (string)s["dir"] : "";
|
||||
if (ip == "")
|
||||
{
|
||||
log.Warn("servers[" + count.ToString() + "].ip - incorrect. Skip server.");
|
||||
continue;
|
||||
}
|
||||
if (port < 0 && port > 65535)
|
||||
{
|
||||
log.Warn("servers[" + count.ToString() + "].port - incorrect. Skip server.");
|
||||
continue;
|
||||
}
|
||||
if (dir == "")
|
||||
{
|
||||
log.Warn("servers[" + count.ToString() + "].dir - incorrect or not exist. Skip server.");
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -6,12 +6,12 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace DataClient.Struct
|
||||
{
|
||||
struct server
|
||||
public struct server
|
||||
{
|
||||
string name;
|
||||
string ip;
|
||||
int port;
|
||||
string dir;
|
||||
public string name;
|
||||
public string ip;
|
||||
public int port;
|
||||
public string dir;
|
||||
public server(string Ip, int Port, string Dir)
|
||||
{
|
||||
name = "default";
|
||||
|
Binary file not shown.
Binary file not shown.
@@ -1,25 +1,24 @@
|
||||
{
|
||||
"format": 1,
|
||||
"restore": {
|
||||
"D:\\GIT\\ASCKU_PC\\STPClient\\STPClient.csproj": {}
|
||||
"E:\\GIT\\ASCKU_PC\\STPClient\\STPClient.csproj": {}
|
||||
},
|
||||
"projects": {
|
||||
"D:\\GIT\\ASCKU_PC\\STPClient\\STPClient.csproj": {
|
||||
"E:\\GIT\\ASCKU_PC\\STPClient\\STPClient.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "D:\\GIT\\ASCKU_PC\\STPClient\\STPClient.csproj",
|
||||
"projectUniqueName": "E:\\GIT\\ASCKU_PC\\STPClient\\STPClient.csproj",
|
||||
"projectName": "STPClient",
|
||||
"projectPath": "D:\\GIT\\ASCKU_PC\\STPClient\\STPClient.csproj",
|
||||
"packagesPath": "C:\\Users\\google\\.nuget\\packages\\",
|
||||
"outputPath": "D:\\GIT\\ASCKU_PC\\STPClient\\obj\\",
|
||||
"projectPath": "E:\\GIT\\ASCKU_PC\\STPClient\\STPClient.csproj",
|
||||
"packagesPath": "C:\\Users\\Admin\\.nuget\\packages\\",
|
||||
"outputPath": "E:\\GIT\\ASCKU_PC\\STPClient\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages",
|
||||
"C:\\Program Files (x86)\\Microsoft\\Xamarin\\NuGet\\",
|
||||
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
|
||||
"C:\\Program Files (x86)\\Microsoft\\Xamarin\\NuGet\\"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\Users\\google\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
"C:\\Users\\Admin\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Xamarin.Offline.config"
|
||||
@@ -75,7 +74,7 @@
|
||||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.201\\RuntimeIdentifierGraph.json"
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.200\\RuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -5,15 +5,14 @@
|
||||
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
||||
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
|
||||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
|
||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\google\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages;C:\Program Files (x86)\Microsoft\Xamarin\NuGet\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder</NuGetPackageFolders>
|
||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Admin\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages;C:\Program Files (x86)\Microsoft\Xamarin\NuGet\</NuGetPackageFolders>
|
||||
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.9.0</NuGetToolVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<SourceRoot Include="C:\Users\google\.nuget\packages\" />
|
||||
<SourceRoot Include="C:\Users\Admin\.nuget\packages\" />
|
||||
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
|
||||
<SourceRoot Include="C:\Program Files (x86)\Microsoft\Xamarin\NuGet\" />
|
||||
<SourceRoot Include="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
|
@@ -361,27 +361,25 @@
|
||||
]
|
||||
},
|
||||
"packageFolders": {
|
||||
"C:\\Users\\google\\.nuget\\packages\\": {},
|
||||
"C:\\Users\\Admin\\.nuget\\packages\\": {},
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {},
|
||||
"C:\\Program Files (x86)\\Microsoft\\Xamarin\\NuGet\\": {},
|
||||
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder": {}
|
||||
"C:\\Program Files (x86)\\Microsoft\\Xamarin\\NuGet\\": {}
|
||||
},
|
||||
"project": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "D:\\GIT\\ASCKU_PC\\STPClient\\STPClient.csproj",
|
||||
"projectUniqueName": "E:\\GIT\\ASCKU_PC\\STPClient\\STPClient.csproj",
|
||||
"projectName": "STPClient",
|
||||
"projectPath": "D:\\GIT\\ASCKU_PC\\STPClient\\STPClient.csproj",
|
||||
"packagesPath": "C:\\Users\\google\\.nuget\\packages\\",
|
||||
"outputPath": "D:\\GIT\\ASCKU_PC\\STPClient\\obj\\",
|
||||
"projectPath": "E:\\GIT\\ASCKU_PC\\STPClient\\STPClient.csproj",
|
||||
"packagesPath": "C:\\Users\\Admin\\.nuget\\packages\\",
|
||||
"outputPath": "E:\\GIT\\ASCKU_PC\\STPClient\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages",
|
||||
"C:\\Program Files (x86)\\Microsoft\\Xamarin\\NuGet\\",
|
||||
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
|
||||
"C:\\Program Files (x86)\\Microsoft\\Xamarin\\NuGet\\"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\Users\\google\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
"C:\\Users\\Admin\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Xamarin.Offline.config"
|
||||
@@ -437,7 +435,7 @@
|
||||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.201\\RuntimeIdentifierGraph.json"
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.200\\RuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,19 +1,19 @@
|
||||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "s6KtP6sXTAN7Y3yYSD50B/Wtj4v4GMZxu5Xdpq2OtRWQcLti8Oz3L/gX/JPQIPIzj6moN4WT3fMrd4mtI7TE0A==",
|
||||
"dgSpecHash": "o6OPlvqTxZe87EkkLNG7xOH1lJZMPMyHMIDMPp42fdz3B4ER8i4Ky4UZZnOmWzYk7VdkNj7lD5UH+oB4UNPduA==",
|
||||
"success": true,
|
||||
"projectFilePath": "D:\\GIT\\ASCKU_PC\\STPClient\\STPClient.csproj",
|
||||
"projectFilePath": "E:\\GIT\\ASCKU_PC\\STPClient\\STPClient.csproj",
|
||||
"expectedPackageFiles": [
|
||||
"C:\\Users\\google\\.nuget\\packages\\microsoft.extensions.configuration.abstractions\\5.0.0\\microsoft.extensions.configuration.abstractions.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\google\\.nuget\\packages\\microsoft.extensions.dependencyinjection\\5.0.0\\microsoft.extensions.dependencyinjection.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\google\\.nuget\\packages\\microsoft.extensions.dependencyinjection.abstractions\\5.0.0\\microsoft.extensions.dependencyinjection.abstractions.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\google\\.nuget\\packages\\microsoft.extensions.logging\\5.0.0\\microsoft.extensions.logging.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\google\\.nuget\\packages\\microsoft.extensions.logging.abstractions\\5.0.0\\microsoft.extensions.logging.abstractions.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\google\\.nuget\\packages\\microsoft.extensions.options\\5.0.0\\microsoft.extensions.options.5.0.0.nupkg.sha512",
|
||||
"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\\Admin\\.nuget\\packages\\microsoft.extensions.configuration.abstractions\\5.0.0\\microsoft.extensions.configuration.abstractions.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\Admin\\.nuget\\packages\\microsoft.extensions.dependencyinjection\\5.0.0\\microsoft.extensions.dependencyinjection.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\Admin\\.nuget\\packages\\microsoft.extensions.dependencyinjection.abstractions\\5.0.0\\microsoft.extensions.dependencyinjection.abstractions.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\Admin\\.nuget\\packages\\microsoft.extensions.logging\\5.0.0\\microsoft.extensions.logging.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\Admin\\.nuget\\packages\\microsoft.extensions.logging.abstractions\\5.0.0\\microsoft.extensions.logging.abstractions.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\Admin\\.nuget\\packages\\microsoft.extensions.options\\5.0.0\\microsoft.extensions.options.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\Admin\\.nuget\\packages\\microsoft.extensions.primitives\\5.0.0\\microsoft.extensions.primitives.5.0.0.nupkg.sha512",
|
||||
"C:\\Users\\Admin\\.nuget\\packages\\newtonsoft.json\\13.0.1\\newtonsoft.json.13.0.1.nupkg.sha512",
|
||||
"C:\\Users\\Admin\\.nuget\\packages\\nlog\\4.7.10\\nlog.4.7.10.nupkg.sha512",
|
||||
"C:\\Users\\Admin\\.nuget\\packages\\nlog.extensions.logging\\1.7.2\\nlog.extensions.logging.1.7.2.nupkg.sha512"
|
||||
],
|
||||
"logs": []
|
||||
}
|
Reference in New Issue
Block a user