upd
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 17s

This commit is contained in:
2026-05-26 14:02:32 +03:00
parent bf51924adb
commit eb6235bd3e
41 changed files with 1509 additions and 61 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ namespace AddHostToProxy
var lsDomain = new List<string>();
var _meta = new Meta();
host.meta = _meta;
lsDomain.Add(item.Value+".vnk.security.local");
lsDomain.Add(item.Value+"-vnk.security.local");
host.domain_names = lsDomain;
host.forward_host = item.Key;
var str2 = await AddProxyHostAsync(str, host);
+8 -8
View File
@@ -1,12 +1,8 @@
using CheckEVS;
using System;
using System.Net.Http;
using System.Net.Http.Json;
using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace DahuaDiskChecker
{
@@ -18,10 +14,11 @@ namespace DahuaDiskChecker
//Console.WriteLine("=== ПРОВЕРКА СОСТОЯНИЯ ДИСКА DAHUA ===");
#if DEBUG
Console.WriteLine("Введи ip-адрес EVS:");
server = Console.ReadLine();
Console.WriteLine("Введи номер диска: (0 - количество неисправных, 1-24 - статус указанного");
int diskNumber = Convert.ToInt32(Console.ReadLine());
Start:
//Console.WriteLine("Введи ip-адрес EVS:");
server = "172.16.48.144";
//Console.WriteLine("Введи номер диска: (0 - количество неисправных, 1-24 - статус указанного");
int diskNumber = 6;
#else
// Парсинг аргументов
@@ -74,6 +71,8 @@ namespace DahuaDiskChecker
}
#if DEBUG
Console.ReadKey();
Console.WriteLine("=======================================");
goto Start;
#endif
//Console.WriteLine(new string('=', 40));
@@ -82,6 +81,7 @@ namespace DahuaDiskChecker
{
Console.WriteLine($"❌ Ошибка: {ex.Message}");
}
}
private static async Task PromoPrint()
+6
View File
@@ -8,4 +8,10 @@
</PropertyGroup>
<ItemGroup>
<None Update="listCam.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
+52 -2
View File
@@ -1,4 +1,5 @@
using System.Net;
using System.Net.NetworkInformation;
namespace ChekTimeDahua
{
@@ -8,7 +9,7 @@ namespace ChekTimeDahua
{
#if DEBUG
args = new string[4];
args[0] = "check";
args[0] = "set";
args[1] = "172.16.50.14";
args[2] = "admin";
args[3] = "4NUDZhJ7";
@@ -55,7 +56,7 @@ namespace ChekTimeDahua
string baseUrlU = $"http://{server}";
var credCacheU = new CredentialCache();
credCacheU.Add(new Uri(baseUrlU), "Digest", new NetworkCredential(login, password));
using (var handler = new HttpClientHandler
using (var handler = new HttpClientHandler
{
Credentials = credCacheU,
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true
@@ -82,6 +83,55 @@ namespace ChekTimeDahua
else Console.WriteLine("1");
}
break;
case "set":
var list = new List<string>();
var lines = File.ReadAllLines("listCam.csv");
foreach (var line in lines)
{
list.Add(line);
}
foreach (var host in list)
{
using (Ping ping = new Ping())
{
PingReply pingReply = ping.Send(host);
if (pingReply.Status != IPStatus.Success)
{
Console.WriteLine($"{host}\t NO PING");
continue;
}
}
string baseUrlS = $"http://{host}";
var credCacheS = new CredentialCache();
credCacheS.Add(new Uri(baseUrlS), "Digest", new NetworkCredential(login, password));
using (var handler = new HttpClientHandler
{
Credentials = credCacheS,
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true
})
using (var httpClient = new HttpClient(handler))
{
string requestUrl = $"{baseUrlS}/cgi-bin/global.cgi?action=setCurrentTime&time={DateTime.Now:yyyy-MM-dd HH:mm:ss}";
var response = await httpClient.GetAsync(requestUrl);
try
{
response.EnsureSuccessStatusCode();
}
catch (Exception)
{
Console.WriteLine($"{host}\t Rechek");
}
var r = await response.Content.ReadAsStringAsync();
//r = r.Replace("\r\n", "");
if (r.StartsWith("OK"))
{
Console.WriteLine($"{host}\t OK");
}
else Console.WriteLine($"{host}\t Rechek");
}
}
break;
default:
break;
}
+16
View File
@@ -0,0 +1,16 @@
172.16.54.28
172.16.54.29
172.16.54.30
172.16.54.31
172.16.54.32
172.16.54.33
172.16.54.34
172.16.54.35
172.16.54.36
172.16.54.37
172.16.54.38
172.16.54.39
172.16.54.40
172.16.54.41
172.16.54.42
172.16.54.43
1 172.16.54.28
2 172.16.54.29
3 172.16.54.30
4 172.16.54.31
5 172.16.54.32
6 172.16.54.33
7 172.16.54.34
8 172.16.54.35
9 172.16.54.36
10 172.16.54.37
11 172.16.54.38
12 172.16.54.39
13 172.16.54.40
14 172.16.54.41
15 172.16.54.42
16 172.16.54.43
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Text.Encoding.CodePages" Version="10.0.8" />
</ItemGroup>
<ItemGroup>
<None Update="hosts.yaml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="listCam.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
+39
View File
@@ -0,0 +1,39 @@
using System.Text;
namespace GenerateYAMLforZabbix
{
internal class Program
{
static void Main(string[] args)
{
var list = new List<string[]>();
var lines = File.ReadAllLines("listCam.txt", Encoding.UTF8);
foreach (var line in lines)
{
var uzel = line.Split(';');
list.Add(uzel);
}
foreach (var host in list)
{
//var act4 = host[0].Split(".")[3];
var text = $""+
$" - host: {host[0]}\r\n" +
$" name: (СПб){host[1]}\r\n" +
$" templates:\r\n" +
$" - name: 'SEC Dahua Camera SNMP'\r\n" +
$" groups:\r\n" +
$" - name: dahua.cam.spb\r\n" +
$" interfaces:\r\n" +
$" - type: SNMP\r\n" +
$" ip: {host[0]}\r\n" +
$" port: '161'\r\n" +
$" details:\r\n" +
$" community: '{{$SNMP_COMMUNITY}}'\r\n" +
$" interface_ref: if1\r\n" +
$" inventory_mode: DISABLED\r\n";
File.AppendAllText("hosts.yaml", text, Encoding.UTF8);
}
}
}
}
+6
View File
@@ -0,0 +1,6 @@
zabbix_export:
version: '7.0'
host_groups:
- uuid: 1c44fc80770242e5a82b2e06b9b368b2
name: dahua.cam.spb
hosts:
+42
View File
@@ -0,0 +1,42 @@
172.22.10.51;Пом.545-2
172.22.10.52;Пом.519-1
172.22.10.53;Пом.511-1
172.22.10.54;Пом.517-2
172.22.10.55;Эвак. Выход-3
172.22.10.56;Пом.545-коридор
172.22.10.57;Ресепшн-1
172.22.10.58;Пом.545-3
172.22.10.59;Пом.521-3
172.22.10.60;Пом.535 к лифтам
172.22.10.61;Пом.515-2
172.22.10.62;Пом.511-2
172.22.10.63;Пом.517-1
172.22.10.64;Пом.521-1
172.22.10.65;Пом.535-коридор
172.22.10.66;Пом.526-столовая
172.22.10.67;Пом.545-4
172.22.10.68;Пом.532-2
172.22.10.69;Пом.515-1
172.22.10.70;Пом.535-1
172.22.10.71;Эвак. Выход-2
172.22.10.72;Пом.545-1
172.22.10.73;Ресепшн-2
172.22.10.74;Пом.521-2
172.22.10.93;Пом.319-столовая
172.22.10.94;Пом.313-1
172.22.10.95;Пом.321-1
172.22.10.96;Коридор от лифт. холла
172.22.10.97;Пом.321-2
172.22.10.98;Коридор к лифт. холлу
172.22.10.99;Пом.313-2
172.22.10.100;Пом.323-2
172.22.10.101;Пом.323-1
172.22.10.102;Эвак. Выход
172.22.10.103;Кроссовая
172.22.10.104;Пом.304-1
172.22.10.105;Пом.304-2
172.22.10.106;Пом.312
172.22.10.107;Пом.237
172.22.10.108;Пом.519-2
172.22.10.109;Пом.244-1
172.22.10.110;Пом.244-2
+1 -1
View File
@@ -10,7 +10,7 @@
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.6" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.7" />
<PackageReference Include="Telegram.Bot" Version="19.0.0" />
</ItemGroup>
+29 -1
View File
@@ -7,7 +7,35 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-6.0.3.0" newVersion="6.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.5" newVersion="10.0.0.5" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.4.0" newVersion="4.2.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.5" newVersion="10.0.0.5" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Channels" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.5" newVersion="10.0.0.5" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.5" newVersion="10.0.0.5" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.5.0" newVersion="4.0.5.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
+24 -21
View File
@@ -67,43 +67,44 @@
<SignManifests>true</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=10.0.0.5, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.10.0.5\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
<Reference Include="System.Buffers, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
<Reference Include="System.IO.Pipelines, Version=10.0.0.5, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Pipelines.10.0.5\lib\net462\System.IO.Pipelines.dll</HintPath>
</Reference>
<Reference Include="System.Memory, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.6.3\lib\net462\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
<Reference Include="System.Numerics.Vectors, Version=4.1.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.6.1\lib\net462\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encodings.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
<Reference Include="System.Text.Encodings.Web, Version=10.0.0.5, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.10.0.5\lib\net462\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=8.0.0.5, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.8.0.5\lib\net462\System.Text.Json.dll</HintPath>
<Reference Include="System.Text.Json, Version=10.0.0.5, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.10.0.5\lib\net462\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Channels, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Channels.8.0.0\lib\net462\System.Threading.Channels.dll</HintPath>
<Reference Include="System.Threading.Channels, Version=10.0.0.5, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Channels.10.0.5\lib\net462\System.Threading.Channels.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -177,5 +178,7 @@
<ErrorText>Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Selenium.WebDriver.4.41.0\build\Selenium.WebDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.4.41.0\build\Selenium.WebDriver.targets'))" />
<Error Condition="!Exists('..\packages\System.ValueTuple.4.6.2\build\net471\System.ValueTuple.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.ValueTuple.4.6.2\build\net471\System.ValueTuple.targets'))" />
</Target>
<Import Project="..\packages\System.ValueTuple.4.6.2\build\net471\System.ValueTuple.targets" Condition="Exists('..\packages\System.ValueTuple.4.6.2\build\net471\System.ValueTuple.targets')" />
</Project>
+11 -10
View File
@@ -1,15 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net48" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="10.0.5" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.4" targetFramework="net48" />
<package id="Selenium.WebDriver" version="4.41.0" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net48" />
<package id="System.Text.Encodings.Web" version="8.0.0" targetFramework="net48" />
<package id="System.Text.Json" version="8.0.5" targetFramework="net48" />
<package id="System.Threading.Channels" version="8.0.0" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
<package id="System.Buffers" version="4.6.1" targetFramework="net48" />
<package id="System.IO.Pipelines" version="10.0.5" targetFramework="net48" />
<package id="System.Memory" version="4.6.3" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.6.1" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.1.2" targetFramework="net48" />
<package id="System.Text.Encodings.Web" version="10.0.5" targetFramework="net48" />
<package id="System.Text.Json" version="10.0.5" targetFramework="net48" />
<package id="System.Threading.Channels" version="10.0.5" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.6.3" targetFramework="net48" />
<package id="System.ValueTuple" version="4.6.2" targetFramework="net48" />
</packages>
+67
View File
@@ -0,0 +1,67 @@
using System.Net;
using System.Net.NetworkInformation;
using System.Text;
namespace SetVideoDataHikvision
{
internal class Program
{
static void Main(string[] args)
{
var list = new List<string>();
var lines = File.ReadAllLines("listCam.csv");
foreach (var line in lines)
{
list.Add(line);
}
foreach (var host in list)
{
using (Ping ping = new Ping())
{
PingReply pingReply = ping.Send(host);
if (pingReply.Status != IPStatus.Success)
{
Console.WriteLine($"{host}\t NO PING");
continue;
}
}
string baseUrlU = $"http://{server}";
var credCacheU = new CredentialCache();
credCacheU.Add(new Uri(baseUrlU), "Digest", new NetworkCredential(login, password));
using (var handler = new HttpClientHandler
{
Credentials = credCacheU,
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true
})
using (var httpClient = new HttpClient(handler))
{
string requestUrl = $"{baseUrlU}/ISAPI/System/time";
string xmlBody = $@"<?xml version=""1.0"" encoding=""UTF-8""?><Time><timeMode>manual</timeMode><localTime>{DateTime.Now:yyyy-MM-ddTHH:mm:ss}</localTime><timeZone>CST-3:00:00</timeZone></Time>";
// Создаем контент для PUT запроса
var content = new StringContent(xmlBody, Encoding.UTF8, "application/xml");
// Выполняем PUT запрос
var response = await httpClient.PutAsync(requestUrl, content);
try
{
response.EnsureSuccessStatusCode();
}
catch (Exception)
{
Console.WriteLine("1");
return;
}
var r = await response.Content.ReadAsStringAsync();
//r = r.Replace("\r\n", "");
if (r.StartsWith("OK"))
{
Console.WriteLine("0");
}
else Console.WriteLine("1");
}
}
}
}
}
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
+149
View File
@@ -0,0 +1,149 @@
using System.Net;
using System.Net.NetworkInformation;
internal class Program
{
private static async Task Main(string[] args)
{
#if DEBUG
args = new string[4];
args[0] = "set";
args[1] = "172.16.51.2";
args[2] = "admin";
args[3] = "4NUDZhJ7";
#endif
string server, login, password;
if (args.Length != 4) return;
server = args[1];
login = args[2];
password = args[3];
switch (args[0])
{
case "check":
string baseUrl = $"http://{server}";
var credCache = new CredentialCache();
credCache.Add(new Uri(baseUrl), "Digest", new NetworkCredential(login, password));
using (var handler = new HttpClientHandler
{
Credentials = credCache,
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true
})
using (var httpClient = new HttpClient(handler))
{
string requestUrl = $"{baseUrl}/cgi-bin/global.cgi?action=getCurrentTime";
var response = await httpClient.GetAsync(requestUrl);
try
{
response.EnsureSuccessStatusCode();
}
catch (Exception)
{
Console.WriteLine("1");
return;
}
var r = await response.Content.ReadAsStringAsync();
var r2 = Convert.ToDateTime(r.Split("=")[1]);
if (r2 <= DateTime.Now.AddMinutes(2) && r2 >= DateTime.Now.AddMinutes(-2))
Console.WriteLine("0");
else Console.WriteLine("1");
}
break;
case "update":
string baseUrlU = $"http://{server}";
var credCacheU = new CredentialCache();
credCacheU.Add(new Uri(baseUrlU), "Digest", new NetworkCredential(login, password));
using (var handler = new HttpClientHandler
{
Credentials = credCacheU,
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true
})
using (var httpClient = new HttpClient(handler))
{
string requestUrl = $"{baseUrlU}/cgi-bin/global.cgi?action=setCurrentTime&time={DateTime.Now:yyyy-MM-dd HH:mm:ss}";
var response = await httpClient.GetAsync(requestUrl);
try
{
response.EnsureSuccessStatusCode();
}
catch (Exception)
{
Console.WriteLine("1");
return;
}
var r = await response.Content.ReadAsStringAsync();
//r = r.Replace("\r\n", "");
if (r.StartsWith("OK"))
{
Console.WriteLine("0");
}
else Console.WriteLine("1");
}
break;
case "set":
var list = new List<string>();
var lines = File.ReadAllLines("listCam.csv");
foreach (var line in lines)
{
list.Add(line);
}
foreach (var host in list)
{
using (Ping ping = new Ping())
{
PingReply pingReply = ping.Send(host);
if (pingReply.Status != IPStatus.Success)
{
Console.WriteLine($"{host}\t NO PING");
continue;
}
}
string baseUrlS = $"http://{host}";
var credCacheS = new CredentialCache();
credCacheS.Add(new Uri(baseUrlS), "Digest", new NetworkCredential(login, password));
using (var handler = new HttpClientHandler
{
Credentials = credCacheS,
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true
})
using (var httpClient = new HttpClient(handler))
{
string requestUrl = $"{baseUrlS}/cgi-bin/configManager.cgi?" +
$"action=setConfig&" +
$"SNMP.Enable=true&" +
$"SNMP.V2Enable=false&" +
$"SNMP.V1Enable=false&" +
$"SNMP.V3Enable=false&" +
$"SNMP.Port=161&" +
$"SNMP.ReadCommon=public&" +
$"SNMP.WriteCommon=private";
var response = await httpClient.GetAsync(requestUrl);
response.EnsureSuccessStatusCode();
var r = await response.Content.ReadAsStringAsync();
if (r.StartsWith("OK"))
{
string requestUrl2 = $"{baseUrlS}/cgi-bin/configManager.cgi?" +
$"action=setConfig&" +
$"SNMP.Enable=true&" +
$"SNMP.V2Enable=true&" +
$"SNMP.V1Enable=false&" +
$"SNMP.V3Enable=false&" +
$"SNMP.Port=161&" +
$"SNMP.ReadCommon=public&" +
$"SNMP.WriteCommon=private";
var response2 = await httpClient.GetAsync(requestUrl2);
var r2 = await response2.Content.ReadAsStringAsync();
if (r2.StartsWith("OK")) Console.WriteLine("0");
else Console.WriteLine("1");
}
else Console.WriteLine("1");
}
}
break;
default:
break;
}
}
}
+16
View File
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<None Update="listCam.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
+255
View File
@@ -0,0 +1,255 @@
172.16.54.1
172.16.54.2
172.16.54.3
172.16.54.4
172.16.54.5
172.16.54.6
172.16.54.7
172.16.54.8
172.16.54.9
172.16.54.10
172.16.54.11
172.16.54.12
172.16.54.13
172.16.54.14
172.16.54.15
172.16.54.16
172.16.54.17
172.16.54.18
172.16.54.19
172.16.54.20
172.16.54.21
172.16.54.22
172.16.54.23
172.16.54.24
172.16.54.25
172.16.54.26
172.16.54.27
172.16.54.28
172.16.54.29
172.16.54.30
172.16.54.31
172.16.54.32
172.16.54.33
172.16.54.34
172.16.54.35
172.16.54.36
172.16.54.37
172.16.54.38
172.16.54.39
172.16.54.40
172.16.54.41
172.16.54.42
172.16.54.43
172.16.54.44
172.16.54.45
172.16.54.46
172.16.54.47
172.16.54.48
172.16.54.49
172.16.54.50
172.16.54.51
172.16.53.52
172.16.53.53
172.16.53.54
172.16.53.55
172.16.53.56
172.16.53.57
172.16.53.58
172.16.53.59
172.16.53.60
172.16.53.61
172.16.53.62
172.16.53.63
172.16.53.64
172.16.53.65
172.16.53.66
172.16.53.67
172.16.53.68
172.16.53.69
172.16.53.70
172.16.53.71
172.16.53.72
172.16.53.73
172.16.53.74
172.16.53.75
172.16.53.76
172.16.53.77
172.16.53.78
172.16.53.79
172.16.53.80
172.16.53.81
172.16.53.82
172.16.53.83
172.16.53.84
172.16.53.85
172.16.53.86
172.16.53.87
172.16.53.88
172.16.53.89
172.16.53.90
172.16.53.91
172.16.53.92
172.16.53.93
172.16.53.94
172.16.53.95
172.16.53.96
172.16.53.97
172.16.53.98
172.16.53.99
172.16.53.100
172.16.53.101
172.16.53.102
172.16.53.103
172.16.53.104
172.16.53.105
172.16.53.106
172.16.53.107
172.16.53.108
172.16.53.109
172.16.53.110
172.16.53.111
172.16.53.112
172.16.53.113
172.16.53.114
172.16.53.115
172.16.53.116
172.16.53.117
172.16.53.118
172.16.53.119
172.16.53.120
172.16.53.121
172.16.53.122
172.16.53.123
172.16.53.124
172.16.53.125
172.16.53.126
172.16.53.127
172.16.53.128
172.16.53.129
172.16.53.130
172.16.53.131
172.16.53.132
172.16.53.133
172.16.53.134
172.16.53.135
172.16.53.136
172.16.53.137
172.16.53.138
172.16.53.139
172.16.53.140
172.16.53.141
172.16.53.142
172.16.53.143
172.16.53.144
172.16.53.145
172.16.53.146
172.16.53.147
172.16.53.148
172.16.53.149
172.16.53.150
172.16.53.151
172.16.53.152
172.16.53.153
172.16.53.154
172.16.53.155
172.16.53.156
172.16.53.157
172.16.53.158
172.16.53.159
172.16.53.160
172.16.53.161
172.16.53.162
172.16.53.163
172.16.53.164
172.16.53.165
172.16.53.166
172.16.53.167
172.16.53.168
172.16.53.169
172.16.53.170
172.16.53.171
172.16.53.172
172.16.53.173
172.16.53.174
172.16.53.175
172.16.53.176
172.16.53.177
172.16.53.178
172.16.53.179
172.16.53.180
172.16.53.181
172.16.53.182
172.16.53.183
172.16.53.184
172.16.53.185
172.16.53.186
172.16.53.187
172.16.53.188
172.16.53.189
172.16.53.190
172.16.53.191
172.16.53.192
172.16.53.193
172.16.53.194
172.16.53.195
172.16.53.196
172.16.53.197
172.16.53.198
172.16.53.199
172.16.53.200
172.16.53.201
172.16.53.202
172.16.53.203
172.16.53.204
172.16.53.205
172.16.53.206
172.16.53.207
172.16.53.208
172.16.53.209
172.16.53.210
172.16.53.211
172.16.53.212
172.16.53.213
172.16.53.214
172.16.53.215
172.16.53.216
172.16.53.217
172.16.53.218
172.16.53.219
172.16.53.220
172.16.53.221
172.16.53.222
172.16.53.223
172.16.53.224
172.16.53.225
172.16.53.226
172.16.53.227
172.16.53.228
172.16.53.229
172.16.53.230
172.16.53.231
172.16.53.232
172.16.53.233
172.16.53.234
172.16.53.235
172.16.53.236
172.16.53.237
172.16.53.238
172.16.53.239
172.16.53.240
172.16.53.241
172.16.53.242
172.16.53.243
172.16.53.244
172.16.53.245
172.16.53.246
172.16.53.247
172.16.53.248
172.16.53.249
172.16.53.250
172.16.53.251
172.16.53.252
172.16.53.253
172.16.53.254
172.16.53.255
1 172.16.54.1
2 172.16.54.2
3 172.16.54.3
4 172.16.54.4
5 172.16.54.5
6 172.16.54.6
7 172.16.54.7
8 172.16.54.8
9 172.16.54.9
10 172.16.54.10
11 172.16.54.11
12 172.16.54.12
13 172.16.54.13
14 172.16.54.14
15 172.16.54.15
16 172.16.54.16
17 172.16.54.17
18 172.16.54.18
19 172.16.54.19
20 172.16.54.20
21 172.16.54.21
22 172.16.54.22
23 172.16.54.23
24 172.16.54.24
25 172.16.54.25
26 172.16.54.26
27 172.16.54.27
28 172.16.54.28
29 172.16.54.29
30 172.16.54.30
31 172.16.54.31
32 172.16.54.32
33 172.16.54.33
34 172.16.54.34
35 172.16.54.35
36 172.16.54.36
37 172.16.54.37
38 172.16.54.38
39 172.16.54.39
40 172.16.54.40
41 172.16.54.41
42 172.16.54.42
43 172.16.54.43
44 172.16.54.44
45 172.16.54.45
46 172.16.54.46
47 172.16.54.47
48 172.16.54.48
49 172.16.54.49
50 172.16.54.50
51 172.16.54.51
52 172.16.53.52
53 172.16.53.53
54 172.16.53.54
55 172.16.53.55
56 172.16.53.56
57 172.16.53.57
58 172.16.53.58
59 172.16.53.59
60 172.16.53.60
61 172.16.53.61
62 172.16.53.62
63 172.16.53.63
64 172.16.53.64
65 172.16.53.65
66 172.16.53.66
67 172.16.53.67
68 172.16.53.68
69 172.16.53.69
70 172.16.53.70
71 172.16.53.71
72 172.16.53.72
73 172.16.53.73
74 172.16.53.74
75 172.16.53.75
76 172.16.53.76
77 172.16.53.77
78 172.16.53.78
79 172.16.53.79
80 172.16.53.80
81 172.16.53.81
82 172.16.53.82
83 172.16.53.83
84 172.16.53.84
85 172.16.53.85
86 172.16.53.86
87 172.16.53.87
88 172.16.53.88
89 172.16.53.89
90 172.16.53.90
91 172.16.53.91
92 172.16.53.92
93 172.16.53.93
94 172.16.53.94
95 172.16.53.95
96 172.16.53.96
97 172.16.53.97
98 172.16.53.98
99 172.16.53.99
100 172.16.53.100
101 172.16.53.101
102 172.16.53.102
103 172.16.53.103
104 172.16.53.104
105 172.16.53.105
106 172.16.53.106
107 172.16.53.107
108 172.16.53.108
109 172.16.53.109
110 172.16.53.110
111 172.16.53.111
112 172.16.53.112
113 172.16.53.113
114 172.16.53.114
115 172.16.53.115
116 172.16.53.116
117 172.16.53.117
118 172.16.53.118
119 172.16.53.119
120 172.16.53.120
121 172.16.53.121
122 172.16.53.122
123 172.16.53.123
124 172.16.53.124
125 172.16.53.125
126 172.16.53.126
127 172.16.53.127
128 172.16.53.128
129 172.16.53.129
130 172.16.53.130
131 172.16.53.131
132 172.16.53.132
133 172.16.53.133
134 172.16.53.134
135 172.16.53.135
136 172.16.53.136
137 172.16.53.137
138 172.16.53.138
139 172.16.53.139
140 172.16.53.140
141 172.16.53.141
142 172.16.53.142
143 172.16.53.143
144 172.16.53.144
145 172.16.53.145
146 172.16.53.146
147 172.16.53.147
148 172.16.53.148
149 172.16.53.149
150 172.16.53.150
151 172.16.53.151
152 172.16.53.152
153 172.16.53.153
154 172.16.53.154
155 172.16.53.155
156 172.16.53.156
157 172.16.53.157
158 172.16.53.158
159 172.16.53.159
160 172.16.53.160
161 172.16.53.161
162 172.16.53.162
163 172.16.53.163
164 172.16.53.164
165 172.16.53.165
166 172.16.53.166
167 172.16.53.167
168 172.16.53.168
169 172.16.53.169
170 172.16.53.170
171 172.16.53.171
172 172.16.53.172
173 172.16.53.173
174 172.16.53.174
175 172.16.53.175
176 172.16.53.176
177 172.16.53.177
178 172.16.53.178
179 172.16.53.179
180 172.16.53.180
181 172.16.53.181
182 172.16.53.182
183 172.16.53.183
184 172.16.53.184
185 172.16.53.185
186 172.16.53.186
187 172.16.53.187
188 172.16.53.188
189 172.16.53.189
190 172.16.53.190
191 172.16.53.191
192 172.16.53.192
193 172.16.53.193
194 172.16.53.194
195 172.16.53.195
196 172.16.53.196
197 172.16.53.197
198 172.16.53.198
199 172.16.53.199
200 172.16.53.200
201 172.16.53.201
202 172.16.53.202
203 172.16.53.203
204 172.16.53.204
205 172.16.53.205
206 172.16.53.206
207 172.16.53.207
208 172.16.53.208
209 172.16.53.209
210 172.16.53.210
211 172.16.53.211
212 172.16.53.212
213 172.16.53.213
214 172.16.53.214
215 172.16.53.215
216 172.16.53.216
217 172.16.53.217
218 172.16.53.218
219 172.16.53.219
220 172.16.53.220
221 172.16.53.221
222 172.16.53.222
223 172.16.53.223
224 172.16.53.224
225 172.16.53.225
226 172.16.53.226
227 172.16.53.227
228 172.16.53.228
229 172.16.53.229
230 172.16.53.230
231 172.16.53.231
232 172.16.53.232
233 172.16.53.233
234 172.16.53.234
235 172.16.53.235
236 172.16.53.236
237 172.16.53.237
238 172.16.53.238
239 172.16.53.239
240 172.16.53.240
241 172.16.53.241
242 172.16.53.242
243 172.16.53.243
244 172.16.53.244
245 172.16.53.245
246 172.16.53.246
247 172.16.53.247
248 172.16.53.248
249 172.16.53.249
250 172.16.53.250
251 172.16.53.251
252 172.16.53.252
253 172.16.53.253
254 172.16.53.254
255 172.16.53.255
@@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Mvc;
namespace Strela.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries =
[
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
];
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}
}
+35
View File
@@ -0,0 +1,35 @@
namespace Strela
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
builder.Services.AddOpenApi();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseAuthorization();
app.MapControllers();
app.MapGet("/", () => "OK");
app.Run();
}
}
}
+37
View File
@@ -0,0 +1,37 @@
{
"profiles": {
"http": {
"commandName": "Project",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5294"
},
"Container (.NET SDK)": {
"commandName": "SdkContainer",
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"environmentVariables": {
"ASPNETCORE_HTTP_PORTS": "8080"
},
"publishAllPorts": true,
"useSSL": false
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
},
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:53994/",
"sslPort": 44312
}
}
}
+18
View File
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
<ContainerRuntimeIdentifier>win-x64</ContainerRuntimeIdentifier>
<EnableSdkContainerDebugging>True</EnableSdkContainerDebugging>
<ContainerBaseImage>mcr.microsoft.com/dotnet/aspnet:10.0-nanoserver-ltsc2022</ContainerBaseImage>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.5" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.7" />
</ItemGroup>
</Project>
+6
View File
@@ -0,0 +1,6 @@
@Strela_HostAddress = http://localhost:5294
GET {{Strela_HostAddress}}/weatherforecast/
Accept: application/json
###
+13
View File
@@ -0,0 +1,13 @@
namespace Strela
{
public class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
}
+8
View File
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
+1 -1
View File
@@ -78,7 +78,7 @@
// comboBox1
//
comboBox1.FormattingEnabled = true;
comboBox1.Items.AddRange(new object[] { "172.16.48.9\tkr0-1-sw1", "172.16.48.10\tkr0-1-sw2", "172.16.48.11\tkr0-1-sw3", "172.16.48.12\tkr0-1-sw4", "172.16.48.13\tkr0-2-sw1", "172.16.48.14\tkr0-2-sw2", "172.16.48.15\tkr0-2-sw3", "172.16.48.16\tkr0-2-sw4", "172.16.48.17\tkr1_sw1", "172.16.48.18\tkr1_sw2", "172.16.48.19\tkr1_sw3", "172.16.48.20\tkr1_sw4", "172.16.48.21\tkr1_sw5", "172.16.48.22\tkr1_sw6", "172.16.48.23\tkr2-sw1", "172.16.48.24\tkr2-sw2", "172.16.48.25\tkr2-sw3", "172.16.48.26\tkr2-sw4", "172.16.48.27\tkr2-sw5", "172.16.48.28\tkr2-sw6", "172.16.48.29\tkr2-sw7", "172.16.48.30\tkr2-sw8", "172.16.48.31\tkr3-sw1", "172.16.48.32\tkr3-sw2", "172.16.48.33\tkr3-sw3", "172.16.48.34\tkr3-sw4", "172.16.48.35\tkr3-sw5", "172.16.48.36\tkr3-sw6", "172.16.48.37\tkr4-sw1", "172.16.48.38\tkr4-sw2", "172.16.48.39\tkr4-sw3", "172.16.48.40\tkr4-sw4", "172.16.48.41\tkr4-sw5", "172.16.48.42\tkr4-sw6", "172.16.48.43\tkr4-sw7", "172.16.48.44\tkr4-sw8", "172.16.48.45\tkr5-sw1", "172.16.48.46\tkr6-sw1", "172.16.48.47\tkr6-sw2", "172.16.48.48\tkr7-sw1", "172.16.48.49\tkr7-sw2", "172.16.48.50\tkr8-sw1", "172.16.48.51\tkr8-sw2", "172.16.48.52\tkr9-sw1", "172.16.48.53\tkr10-sw1", "172.16.48.54\tkr10-sw2", "172.16.48.55\tkr10-sw3", "172.16.48.56\tkr11-sw1", "172.16.48.57\tkr11-sw2", "172.16.48.58\tkr11-sw3", "172.16.48.59\tkr11-sw4", "172.16.48.60\tkr12-sw1", "172.16.48.61\tkr12-sw2", "172.16.48.62\tkr13-sw1", "172.16.48.63\tkr13-sw2", "172.16.48.64\tkr14-sw1", "172.16.48.65\tkr14-sw2", "172.16.48.66\tkr15-sw1", "172.16.48.67\tkr15-sw2", "172.16.48.68\tkr15-sw3", "172.16.48.69\tkr15-sw4", "172.16.48.70\tkr16-sw1", "172.16.48.71\tkr16-sw2", "172.16.48.72\tkr16-sw3", "172.16.48.73\tkr16-sw4", "172.16.48.74\tkr16-sw5", "172.16.48.75\tkr16-sw6", "172.16.48.76\tkr2_sw9", "172.16.48.77\tsw_rum111", "172.16.48.78\tkr15_sw5" });
comboBox1.Items.AddRange(new object[] { "172.22.10.2\t", "172.22.10.3\t", "172.22.10.6\t", "172.22.10.7\t", "172.22.10.8\t", "172.22.10.9\t", "172.22.10.12\t", "172.22.10.13\t" });
comboBox1.Location = new Point(32, 20);
comboBox1.Name = "comboBox1";
comboBox1.Size = new Size(147, 21);
+4 -3
View File
@@ -19,7 +19,7 @@ namespace SwitchDahua
{
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true
};
server = "172.16.48.9";
server = "172.22.10.7";
_httpClient = new HttpClient(handler);
_httpClient.Timeout = TimeSpan.FromSeconds(30);
@@ -193,9 +193,10 @@ namespace SwitchDahua
var responseJson = await response.Content.ReadAsStringAsync();
LLDP ListDev = JsonConvert.DeserializeObject<LLDP>(responseJson);
var DevList = ListDev.Params;
DevList = DevList.OrderBy(item => item.ManagerIP).ToList();
string txt = string.Empty;
foreach (var dev in ListDev.Params)
foreach (var dev in DevList)
{
txt += dev.LocalInterface.Substring(dev.LocalInterface.LastIndexOf('/') + 1) + "\t" + dev.ManagerIP + Environment.NewLine;
}
+1 -1
View File
@@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.5" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.7" />
</ItemGroup>
<ItemGroup>
+69
View File
@@ -0,0 +1,69 @@
using Renci.SshNet;
namespace getSwitch
{
internal class Program
{
static void Main(string[] args)
{
Dictionary<string, string> listSw = new Dictionary<string, string>
{
{"GE1/0/1", "kr1_sw1"},{"GE1/0/2", "kr1_sw2"},{"GE1/0/3", "kr1_sw3"},{"GE1/0/4", "kr1_sw4"},
{"GE1/0/5", "kr1_sw5"},{"GE1/0/6", "kr1_sw6"},{"GE1/0/7", "kr2_sw1"},{"GE1/0/8", "kr2_sw2"},
{"GE1/0/9", "kr2_sw3"},{"GE1/0/10", "kr2_sw4"},{"GE1/0/11", "kr2_sw5"},{"GE1/0/12", "kr2_sw6"},
{"GE1/0/13", "kr2_sw7"},{"GE1/0/14", "kr2_sw8"},{"GE1/0/15", "kr2_sw9"},{"GE1/0/16", "kr3_sw2"},
{"GE1/0/17", "kr3_sw1"},{"GE1/0/18", "kr3_sw3"},{"GE1/0/19", "kr3_sw4"},{"GE1/0/20", "kr3_sw5"},
{"GE1/0/21", "kr3_sw6"},{"GE1/0/22", "kr4_sw1"},{"GE1/0/23", "kr4_sw2"},{"GE1/0/24", "kr4_sw3"},
{"GE2/0/1", "kr4_sw4"},{"GE2/0/2", "kr4_sw5"},{"GE2/0/3", "kr4_sw6"},{"GE2/0/4", "kr4_sw7"},
{"GE2/0/5", "kr4_sw8"},{"GE2/0/6", "kr5_sw1"},{"GE2/0/7", "kr6_sw1"},{"GE2/0/8", "kr6_sw2"},
{"GE2/0/9", "kr7_sw1"},{"GE2/0/10", "kr7_sw2"},{"GE2/0/11", "kr8_sw1"},{"GE2/0/12", "kr8_sw2"},
{"GE2/0/13", "kr9_sw1"},{"GE2/0/14", "kr10_sw1"},{"GE2/0/15", "kr10_sw2"},{"GE2/0/16", "kr10_sw3"},
{"GE2/0/17", "kr11_sw1"},{"GE2/0/18", "kr11_sw2"},{"GE2/0/19", "kr11_sw3"},{"GE2/0/20", "kr11_sw4"},
{"GE2/0/21", "kr12_sw1"},{"GE2/0/22", "kr12_sw2"},{"GE2/0/23", "kr13_sw1"},{"GE2/0/24", "kr14_sw1"},
{"GE3/0/1", "kr14_sw2"},{"GE3/0/2", "kr13_sw2"},{"GE3/0/3", "kr15_sw1"},{"GE3/0/4", "kr15_sw3"},{"GE3/0/5", "kr15_sw2"},
{"GE3/0/6", "kr15_sw4"},{"GE3/0/7", "kr15_sw5"},{"GE3/0/8", "kr16_sw1"},{"GE3/0/9", "kr16_sw2"},{"GE3/0/10", "kr16_sw3"},
{"GE3/0/11", "kr16_sw4"},{"GE3/0/12", "kr16_sw5"},{"GE3/0/13", "kr16_sw6"},{"GE3/0/14", "kr0_1_sw1"},{"GE3/0/15", "kr0_1_sw2"},
{"GE3/0/16", "kr0_1_sw3"},{"GE3/0/17", "kr0_1_sw4"},{"GE3/0/18", "kr00_2_sw1"},{"GE3/0/19", "kr00_2_sw2"},{"GE3/0/20", "kr00_2_sw3"},{"GE3/0/21", "kr0_2_sw4"}
};
string host = "172.16.48.4";
string username = "admin";
string password = "4NUDZhJ789";
int port = 22; // стандартный порт SSH
#if DEBUG
args = new string[] { "9BBB" };
#endif
using (var client = new SshClient(host, port, username, password))
{
try
{
// Подключаемся
client.Connect();
//Console.WriteLine("Подключение установлено!");
var command = client.RunCommand($"show mac-address | include {args[0]}");
var otvet = command.Result;
otvet = otvet.Split("\r\n")[1];
otvet = otvet.Substring(45, 8);
Console.WriteLine(listSw[otvet]);
//Console.ReadKey();
}
catch (Exception ex)
{
Console.WriteLine($"Ошибка: {ex.Message}");
}
finally
{
if (client.IsConnected)
{
client.Disconnect();
// Console.WriteLine("Отключено.");
}
}
}
}
}
}
+14
View File
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SSH.NET" Version="2025.1.0" />
</ItemGroup>
</Project>
+1 -9
View File
@@ -75,15 +75,7 @@ Dictionary<string, string> listSw = new Dictionary<string, string>
};
List<string> listMac = new List<string>()
{
"2959",
"5c09",
"2827",
"84e8",
"848d",
"8413",
"88a0",
"0db0",
"8b4e"
"b13b"
};
string host = "172.16.48.4";
+1 -1
View File
@@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
+12 -2
View File
@@ -1,17 +1,27 @@
<Solution>
<Folder Name="/LC/">
<Project Path="Strela/Strela.csproj" Id="c2c611c9-aab3-482a-8c7c-35339b6310e7" />
</Folder>
<Folder Name="/Zabbix/">
<Project Path="GenerateYAMLforZabbix/GenerateYAMLforZabbix.csproj" Id="b1c151d7-8be1-45e7-92f3-8420eb873b16" />
<Project Path="getSwitch/getSwitch.csproj" Id="9e9bbe58-b5f9-4865-8565-2be53226e9cd" />
<Project Path="snmp_dahua/snmp_dahua.csproj" Id="de86e14b-d805-4963-9286-2316d5404476" />
<Project Path="sync_time_dh/sync_time_dh.csproj" Id="e46668f1-c9e3-4f9a-b5c3-e8f7f57adabc" />
<Project Path="sync_time_hik/sync_time_hik.csproj" Id="2d2429b1-621a-4df6-a298-d23877e8dd2f" />
</Folder>
<Project Path="AddHostToProxy/AddHostToProxy.csproj" Id="3dc81096-172f-420c-85b1-d7af5e6caf5c" />
<Project Path="AspireApp1/AspireApp1.AppHost/AspireApp1.AppHost.csproj" />
<Project Path="CheckEVS/CheckEVS.csproj" />
<Project Path="CheckTimeHikvision/CheckTimeHikvision.csproj" Id="5cbd52dc-caba-426b-9b32-1583f10f60a2" />
<Project Path="ChekTimeDahua/ChekTimeDahua.csproj" Id="e570bdbe-62ad-476b-b36c-5f6ecf3028b1" />
<Project Path="DahuaIPCRename/DahuaIPCRename.csproj" Id="1e5671da-7b44-4818-8942-d73d2148c853" />
<Project Path="GetMACtoIP/SettingCam.csproj" />
<Project Path="LC_AddCheckToDb/LC_AddCheckToDb.csproj" />
<Project Path="LC_Api/LC_Api.csproj" />
<Project Path="LC_Bot/LC_Bot.csproj" />
<Project Path="LC_ConfigCamer/LC_ConfigCamer.csproj" Id="a07ea5c9-9e54-4455-a8ff-2f8d6dad7ed1" />
<Project Path="LC_Error/LC_Error.csproj" Id="84dfc2ef-9a72-434e-a5fa-0e02f2bdcd16" />
<Project Path="lsConsole/lsConsole.csproj" />
<Project Path="SettingSNMPDahua/SettingSNMPDahua.csproj" Id="6a5aeee0-a683-473f-87b7-2815c2144027" />
<Project Path="SetVideoDataHikvision/SetVideoDataHikvision.csproj" Id="c4e10081-462c-4be5-9f58-9e1926325c9d" />
<Project Path="SwitchDahua/SwitchDahua.csproj" Id="12504b58-758f-444b-a79b-4ce2db8398cc" />
<Project Path="Web/Web.csproj" />
<Project Path="Wiking/Wiking.csproj" Id="fa0eb4bd-8bfb-4873-bb71-1c2a608ab911" />
+40
View File
@@ -0,0 +1,40 @@
namespace snmp_dahua
{
using System.Net;
using System.Net.NetworkInformation;
internal class Program
{
static async Task Main(string[] args)
{
#if DEBUG
args = new string[2];
args[0] = "172.16.50.14";
#endif
string baseUrlS = $"http://{args[0]}";
var credCacheS = new CredentialCache();
credCacheS.Add(new Uri(baseUrlS), "Digest", new NetworkCredential("admin", "4NUDZhJ7"));
using (var handler = new HttpClientHandler
{
Credentials = credCacheS,
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true
})
using (var httpClient = new HttpClient(handler))
{
string requestUrl = $"{baseUrlS}/cgi-bin/configManager.cgi?action=setConfig&SNMP.Enable=false";
var response = await httpClient.GetAsync(requestUrl);
response.EnsureSuccessStatusCode();
var r = response.ReasonPhrase;// .Content.ReadAsStringAsync();
if (r.StartsWith("OK"))
{
string requestUrl2 = $"{baseUrlS}/cgi-bin/configManager.cgi?action=setConfig&SNMP.Enable=true";
var response2 = await httpClient.GetAsync(requestUrl2);
var r2 = response2.ReasonPhrase;//.Content.ReadAsStringAsync();
if (r2.StartsWith("OK")) Console.WriteLine("0");
else Console.WriteLine("1");
}
else Console.WriteLine("1");
}
}
}
}
+10
View File
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
+51
View File
@@ -0,0 +1,51 @@
using System.Net;
namespace sync_time_dh
{
internal class Program
{
static async Task Main(string[] args)
{
#if DEBUG
args = new string[1];
args[0] = "172.16.54.30";
#endif
string baseUrlU = $"http://{args[0]}";
var credCacheU = new CredentialCache();
credCacheU.Add(new Uri(baseUrlU), "Digest", new NetworkCredential("admin", "4NUDZhJ7"));
using (var handler = new HttpClientHandler
{
Credentials = credCacheU,
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true
})
using (var httpClient = new HttpClient(handler))
{
string requestUrl1 = $"{baseUrlU}/cgi-bin/global.cgi?action=setCurrentTime&time={DateTime.Now:yyyy-MM-dd HH:mm:ss}";
string requestUrl2 = $"{baseUrlU}/cgi-bin/configManager.cgi?action=setConfig&NTP.Enable=false&NTP.TimeZone=3&NTP.TimeZoneDesc=Moscow";
string requestUrl3 = $"{baseUrlU}/cgi-bin/configManager.cgi?action=setConfig&Locales.TimeFormat=dd-MM-yyyy HH:mm:ss";
var response1 = await httpClient.GetAsync(requestUrl1);
var response2 = await httpClient.GetAsync(requestUrl2);
var response3 = await httpClient.GetAsync(requestUrl3);
try
{
response1.EnsureSuccessStatusCode();
response2.EnsureSuccessStatusCode();
response3.EnsureSuccessStatusCode();
}
catch (Exception)
{
Console.WriteLine("1");
return;
}
var r1 = await response1.Content.ReadAsStringAsync();
var r2 = await response2.Content.ReadAsStringAsync();
var r3 = await response3.Content.ReadAsStringAsync();
if (r1.StartsWith("OK") && r2.StartsWith("OK") && r3.StartsWith("OK"))
{
Console.WriteLine("0");
}
else Console.WriteLine("1");
}
}
}
}
+10
View File
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
+46
View File
@@ -0,0 +1,46 @@
using System.Net;
using System.Text;
namespace sync_time_hik
{
internal class Program
{
static async Task Main(string[] args)
{
#if DEBUG
args = new string[1];
args[0] = "172.16.50.13";
#endif
string baseUrlU = $"http://{args[0]}";
var credCacheU = new CredentialCache();
credCacheU.Add(new Uri(baseUrlU), "Digest", new NetworkCredential("admin", "4NUDZhJ7"));
using (var handler = new HttpClientHandler
{
Credentials = credCacheU,
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true
})
using (var httpClient = new HttpClient(handler))
{
string requestUrl = $"{baseUrlU}/ISAPI/System/time";
string xmlBody = $@"<?xml version=""1.0"" encoding=""UTF-8""?><Time><timeMode>manual</timeMode><localTime>{DateTime.Now:yyyy-MM-ddTHH:mm:ss}</localTime><timeZone>CST-3:00:00</timeZone></Time>";
// Создаем контент для PUT запроса
var content = new StringContent(xmlBody, Encoding.UTF8, "application/xml");
// Выполняем PUT запрос
var response = await httpClient.PutAsync(requestUrl, content);
response.EnsureSuccessStatusCode();
var r = response.ReasonPhrase;
if (r.StartsWith("OK"))
{
Console.WriteLine("0");
}
else Console.WriteLine("1");
}
#if DEBUG
Console.ReadKey();
#endif
}
}
}
+10
View File
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
+332
View File
@@ -0,0 +1,332 @@
#
# Copyright (c) Samsung Electronics. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
#
<#
.SYNOPSIS
Installs Tizen workload manifest.
.DESCRIPTION
Installs the WorkloadManifest.json and WorkloadManifest.targets files for Tizen to the dotnet sdk.
.PARAMETER Version
Use specific VERSION
.PARAMETER DotnetInstallDir
Dotnet SDK Location installed
#>
[cmdletbinding()]
param(
[Alias('v')][string]$Version="<latest>",
[Alias('d')][string]$DotnetInstallDir="<auto>",
[Alias('t')][string]$DotnetTargetVersionBand="<auto>",
[Alias('u')][switch]$UpdateAllWorkloads
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"
$ManifestBaseName = "Samsung.NET.Sdk.Tizen.Manifest"
$global:FallbackId = ""
$LatestVersionMap = [ordered]@{
"$ManifestBaseName-6.0.100" = "7.0.101";
"$ManifestBaseName-6.0.200" = "7.0.100-preview.13.6";
"$ManifestBaseName-6.0.300" = "8.0.133";
"$ManifestBaseName-6.0.400" = "9.0.104";
"$ManifestBaseName-7.0.100-preview.6" = "7.0.100-preview.6.14";
"$ManifestBaseName-7.0.100-preview.7" = "7.0.100-preview.7.20";
"$ManifestBaseName-7.0.100-rc.1" = "7.0.100-rc.1.22";
"$ManifestBaseName-7.0.100-rc.2" = "7.0.100-rc.2.24";
"$ManifestBaseName-7.0.100" = "7.0.103";
"$ManifestBaseName-7.0.200" = "7.0.105";
"$ManifestBaseName-7.0.300" = "7.0.120";
"$ManifestBaseName-7.0.400" = "10.0.106";
"$ManifestBaseName-8.0.100-alpha.1" = "7.0.104";
"$ManifestBaseName-8.0.100-preview.2" = "7.0.106";
"$ManifestBaseName-8.0.100-preview.3" = "7.0.107";
"$ManifestBaseName-8.0.100-preview.4" = "7.0.108";
"$ManifestBaseName-8.0.100-preview.5" = "7.0.110";
"$ManifestBaseName-8.0.100-preview.6" = "7.0.121";
"$ManifestBaseName-8.0.100-preview.7" = "7.0.122";
"$ManifestBaseName-8.0.100-rc.1" = "7.0.124";
"$ManifestBaseName-8.0.100-rc.2" = "7.0.125";
"$ManifestBaseName-8.0.100-rtm" = "7.0.127";
"$ManifestBaseName-8.0.100" = "8.0.144";
"$ManifestBaseName-8.0.200" = "8.0.157";
"$ManifestBaseName-8.0.300" = "8.0.156";
"$ManifestBaseName-8.0.400" = "10.0.109";
"$ManifestBaseName-9.0.100-alpha.1" = "8.0.134";
"$ManifestBaseName-9.0.100-preview.1" = "8.0.135";
"$ManifestBaseName-9.0.100-preview.2" = "8.0.137";
"$ManifestBaseName-9.0.100" = "10.0.104";
"$ManifestBaseName-9.0.200" = "10.0.110";
"$ManifestBaseName-9.0.300" = "10.0.111";
}
function New-TemporaryDirectory {
$parent = [System.IO.Path]::GetTempPath()
$name = [System.IO.Path]::GetRandomFileName()
New-Item -ItemType Directory -Path (Join-Path $parent $name)
}
function Ensure-Directory([string]$TestDir) {
Try {
New-Item -ItemType Directory -Path $TestDir -Force -ErrorAction stop | Out-Null
[io.file]::OpenWrite($(Join-Path -Path $TestDir -ChildPath ".test-write-access")).Close()
Remove-Item -Path $(Join-Path -Path $TestDir -ChildPath ".test-write-access") -Force
}
Catch [System.UnauthorizedAccessException] {
Write-Error "No permission to install. Try run with administrator mode."
}
}
function Get-LatestVersion([string]$Id) {
$attempts=3
$sleepInSeconds=3
do
{
try
{
$Response = Invoke-WebRequest -Uri https://api.nuget.org/v3-flatcontainer/$($Id.ToLowerInvariant())/index.json -UseBasicParsing | ConvertFrom-Json
return $Response.versions | Select-Object -Last 1
}
catch {
Write-Host "Id: $Id"
Write-Host "An exception was caught: $($_.Exception.Message)"
}
$attempts--
if ($attempts -gt 0) { Start-Sleep $sleepInSeconds }
} while ($attempts -gt 0)
if ($LatestVersionMap.Contains($Id))
{
Write-Host "Return cached latest version."
return $LatestVersionMap.$Id
}
else
{
$SubStringId = $Id.Substring(0, $ManifestBaseName.Length + 2);
$MatchingFallbackId = @()
$MatchingFallbackVersion = @()
foreach ($key in $LatestVersionMap.Keys) {
if ($key -like "$SubStringId*") {
$MatchingFallbackId += $key
$MatchingFallbackVersion += $LatestVersionMap[$key]
}
}
if ($MatchingFallbackVersion)
{
$global:FallbackId = $MatchingFallbackId[-1]
$FallbackVersion = $MatchingFallbackVersion[-1]
Write-Host "Return fallback version: $FallbackVersion"
return $FallbackVersion
}
}
Write-Error "Wrong Id: $Id"
}
function Get-Package([string]$Id, [string]$Version, [string]$Destination, [string]$FileExt = "nupkg") {
$OutFileName = "$Id.$Version.$FileExt"
$OutFilePath = Join-Path -Path $Destination -ChildPath $OutFileName
if ($Id -match ".net[0-9]+$") {
$Id = $Id -replace (".net[0-9]+", "")
}
Invoke-WebRequest -Uri "https://www.nuget.org/api/v2/package/$Id/$Version" -OutFile $OutFilePath
return $OutFilePath
}
function Install-Pack([string]$Id, [string]$Version, [string]$Kind) {
$TempZipFile = $(Get-Package -Id $Id -Version $Version -Destination $TempDir -FileExt "zip")
$TempUnzipDir = Join-Path -Path $TempDir -ChildPath "unzipped\$Id"
switch ($Kind) {
"manifest" {
Expand-Archive -Path $TempZipFile -DestinationPath $TempUnzipDir
New-Item -Path $TizenManifestDir -ItemType "directory" -Force | Out-Null
Copy-Item -Path "$TempUnzipDir\data\*" -Destination $TizenManifestDir -Force
}
{($_ -eq "sdk") -or ($_ -eq "framework")} {
Expand-Archive -Path $TempZipFile -DestinationPath $TempUnzipDir
if ( ($kind -eq "sdk") -and ($Id -match ".net[0-9]+$")) {
$Id = $Id -replace (".net[0-9]+", "")
}
$TargetDirectory = $(Join-Path -Path $DotnetInstallDir -ChildPath "packs\$Id\$Version")
New-Item -Path $TargetDirectory -ItemType "directory" -Force | Out-Null
Copy-Item -Path "$TempUnzipDir/*" -Destination $TargetDirectory -Recurse -Force
}
"template" {
$TargetFileName = "$Id.$Version.nupkg".ToLower()
$TargetDirectory = $(Join-Path -Path $DotnetInstallDir -ChildPath "template-packs")
New-Item -Path $TargetDirectory -ItemType "directory" -Force | Out-Null
Copy-Item $TempZipFile -Destination $(Join-Path -Path $TargetDirectory -ChildPath "$TargetFileName") -Force
}
}
}
function Remove-Pack([string]$Id, [string]$Version, [string]$Kind) {
switch ($Kind) {
"manifest" {
Remove-Item -Path $TizenManifestDir -Recurse -Force
}
{($_ -eq "sdk") -or ($_ -eq "framework")} {
$TargetDirectory = $(Join-Path -Path $DotnetInstallDir -ChildPath "packs\$Id\$Version")
Remove-Item -Path $TargetDirectory -Recurse -Force
}
"template" {
$TargetFileName = "$Id.$Version.nupkg".ToLower();
Remove-Item -Path $(Join-Path -Path $DotnetInstallDir -ChildPath "template-packs\$TargetFileName") -Force
}
}
}
function Install-TizenWorkload([string]$DotnetVersion)
{
$VersionSplitSymbol = '.'
$SplitVersion = $DotnetVersion.Split($VersionSplitSymbol)
$CurrentDotnetVersion = [Version]"$($SplitVersion[0]).$($SplitVersion[1])"
$DotnetVersionBand = $SplitVersion[0] + $VersionSplitSymbol + $SplitVersion[1] + $VersionSplitSymbol + $SplitVersion[2][0] + "00"
$ManifestName = "$ManifestBaseName-$DotnetVersionBand"
if ($DotnetTargetVersionBand -eq "<auto>" -or $UpdateAllWorkloads.IsPresent) {
if ($CurrentDotnetVersion -ge "7.0")
{
$IsPreviewVersion = $DotnetVersion.Contains("-preview") -or $DotnetVersion.Contains("-rc") -or $DotnetVersion.Contains("-alpha")
if ($IsPreviewVersion -and ($SplitVersion.Count -ge 4)) {
$DotnetTargetVersionBand = $DotnetVersionBand + $SplitVersion[2].SubString(3) + $VersionSplitSymbol + $($SplitVersion[3])
$ManifestName = "$ManifestBaseName-$DotnetTargetVersionBand"
}
elseif ($DotnetVersion.Contains("-rtm") -and ($SplitVersion.Count -ge 3)) {
$DotnetTargetVersionBand = $DotnetVersionBand + $SplitVersion[2].SubString(3)
$ManifestName = "$ManifestBaseName-$DotnetTargetVersionBand"
}
else {
$DotnetTargetVersionBand = $DotnetVersionBand
}
}
else {
$DotnetTargetVersionBand = $DotnetVersionBand
}
}
# Check latest version of manifest.
if ($Version -eq "<latest>" -or $UpdateAllWorkloads.IsPresent) {
$Version = Get-LatestVersion -Id $ManifestName
}
# Check workload manifest directory.
$ManifestDir = Join-Path -Path $DotnetInstallDir -ChildPath "sdk-manifests" | Join-Path -ChildPath $DotnetTargetVersionBand
$TizenManifestDir = Join-Path -Path $ManifestDir -ChildPath "samsung.net.sdk.tizen"
$TizenManifestFile = Join-Path -Path $TizenManifestDir -ChildPath "WorkloadManifest.json"
# Check and remove already installed old version.
if (Test-Path $TizenManifestFile) {
$ManifestJson = $(Get-Content $TizenManifestFile | ConvertFrom-Json)
$OldVersion = $ManifestJson.version
if ($OldVersion -eq $Version) {
$DotnetWorkloadList = Invoke-Expression "& '$DotnetCommand' workload list | Select-String -Pattern '^tizen'"
if ($DotnetWorkloadList)
{
Write-Host "Tizen Workload $Version version is already installed."
Continue
}
}
Ensure-Directory $ManifestDir
Write-Host "Removing $ManifestName/$OldVersion from $ManifestDir..."
Remove-Pack -Id $ManifestName -Version $OldVersion -Kind "manifest"
$ManifestJson.packs.PSObject.Properties | ForEach-Object {
Write-Host "Removing $($_.Name)/$($_.Value.version)..."
Remove-Pack -Id $_.Name -Version $_.Value.version -Kind $_.Value.kind
}
}
Ensure-Directory $ManifestDir
$TempDir = $(New-TemporaryDirectory)
# Install workload manifest.
Write-Host "Installing $ManifestName/$Version to $ManifestDir..."
if ($global:FallbackId) {
Install-Pack -Id $global:FallbackId -Version $Version -Kind "manifest"
} else {
Install-Pack -Id $ManifestName -Version $Version -Kind "manifest"
}
# Download and install workload packs.
$NewManifestJson = $(Get-Content $TizenManifestFile | ConvertFrom-Json)
$NewManifestJson.packs.PSObject.Properties | ForEach-Object {
Write-Host "Installing $($_.Name)/$($_.Value.version)..."
Install-Pack -Id $_.Name -Version $_.Value.version -Kind $_.Value.kind
}
# Add tizen to the installed workload metadata.
# Featured version band for metadata does NOT include any preview specifier.
# https://github.com/dotnet/sdk/blob/main/documentation/general/workloads/user-local-workloads.md
New-Item -Path $(Join-Path -Path $DotnetInstallDir -ChildPath "metadata\workloads\$DotnetVersionBand\InstalledWorkloads\tizen") -Force | Out-Null
if (Test-Path $(Join-Path -Path $DotnetInstallDir -ChildPath "metadata\workloads\$DotnetVersionBand\InstallerType\msi")) {
New-Item -Path "HKLM:\SOFTWARE\Microsoft\dotnet\InstalledWorkloads\Standalone\x64\$DotnetTargetVersionBand\tizen" -Force | Out-Null
}
# Clean up
Remove-Item -Path $TempDir -Force -Recurse
Write-Host "Done installing Tizen workload $Version"
}
# Check dotnet install directory.
if ($DotnetInstallDir -eq "<auto>") {
if ($Env:DOTNET_ROOT -And $(Test-Path "$Env:DOTNET_ROOT")) {
$DotnetInstallDir = $Env:DOTNET_ROOT
} else {
$DotnetInstallDir = Join-Path -Path $Env:Programfiles -ChildPath "dotnet"
}
}
if (-Not $(Test-Path "$DotnetInstallDir")) {
Write-Error "No installed dotnet '$DotnetInstallDir'."
}
# Check installed dotnet version
$DotnetCommand = "$DotnetInstallDir\dotnet"
if (Get-Command $DotnetCommand -ErrorAction SilentlyContinue)
{
if ($UpdateAllWorkloads.IsPresent)
{
$InstalledDotnetSdks = Invoke-Expression "& '$DotnetCommand' --list-sdks | Select-String -Pattern '^6|^7'" | ForEach-Object {$_ -replace (" \[.*","")}
}
else
{
$InstalledDotnetSdks = Invoke-Expression "& '$DotnetCommand' --version"
}
}
else
{
Write-Error "'$DotnetCommand' occurs an error."
}
if (-Not $InstalledDotnetSdks)
{
Write-Host "`n.NET SDK version 6 or later is required to install Tizen Workload."
}
else
{
foreach ($DotnetSdk in $InstalledDotnetSdks)
{
try {
Write-Host "`nCheck Tizen Workload for sdk $DotnetSdk"
Install-TizenWorkload -DotnetVersion $DotnetSdk
}
catch {
Write-Host "Failed to install Tizen Workload for sdk $DotnetSdk"
Write-Host "$_"
Continue
}
}
}
Write-Host "`nDone"