Add project

Basic formatting applied. Unnecessary comments have been removed. Suspicious code is covered by TODO.
This commit is contained in:
2025-08-12 11:21:10 +09:00
parent bbcbe841a7
commit 33ab055b43
546 changed files with 176950 additions and 0 deletions

View File

@ -0,0 +1,52 @@
using Hcs.ClientApi;
using Hcs.ClientApi.DebtRequestsApi;
using System;
namespace Hcs.ClientDemo
{
public class DebtRequestsDemo
{
public static void DemoExportManySubrequests(HcsClient client)
{
Action<HcsDebtSubrequest> handler = delegate (HcsDebtSubrequest s)
{
client.Log($"Получен: {s}");
};
var date = new DateTime(2024, 1, 22);
int n = client.DebtRequests.ExportDSRsByPeriodOfSending(date, date, null, handler).Result;
client.Log($"Получено запросов: {n}");
}
public static void DemoExportOneDebtRequest(HcsClient client)
{
HcsDebtSubrequest s;
if (client.IsPPAK) s = client.DebtRequests.ExportDSRByRequestNumber("01202411454682").Result;
else s = client.DebtRequests.ExportDSRByRequestNumber("0120241061").Result;
client.Log($"Получен: {s}");
}
public static void DemoImportOneDebtResponse(HcsClient client)
{
HcsDebtSubrequest s;
if (client.IsPPAK) s = client.DebtRequests.ExportDSRByRequestNumber("01202411454682").Result;
else s = client.DebtRequests.ExportDSRByRequestNumber("0120241061").Result;
if (s == null) Console.WriteLine("Ошибка: подзапрос не найден");
var response = new HcsDebtResponse();
response.TransportGuid = Guid.NewGuid();
response.SubrequestGuid = s.SubrequestGuid;
// Если указывается наличие долга обязательно указание ФИО должников
response.HasDebt = false;
//response.PersonalData = new HcsPersonalData[] { new HcsPersonalData() {
// FirstName = "A", MiddleName = "B", LastName = "C"
//}};
var result = client.DebtRequests.ImportDSRResponse(response).Result;
if (result.HasError) Console.WriteLine("Возникла ошибка по время отправки: " + result.Error);
else Console.WriteLine("Запрос успешно выполнен: " + result.UpdateDate);
}
}
}

View File

@ -0,0 +1,67 @@
using Hcs.ClientApi;
using System;
using System.IO;
using System.Threading;
namespace Hcs.ClientDemo
{
public class FileStoreDemo
{
public static void DemoDownloadFile(HcsClient hcsClient)
{
Guid fileGuid = new Guid("e4c3b39f-ad59-11ef-bc8e-0242ac120002");
var file = hcsClient.FileStoreService.DownloadFile(
fileGuid, HcsFileStoreContext.homemanagement, CancellationToken.None).Result;
Console.WriteLine("\nКонтент len=" + file.Length +
" type=" + file.ContentType + " streamLength=" + file.Stream.Length +
" hash=" + hcsClient.ComputeGost94Hash(file.Stream));
using (var s = new FileStream(@"D:\temp\teplo0.pdf", FileMode.CreateNew, FileAccess.Write))
{
file.Stream.Seek(0, SeekOrigin.Begin);
file.Stream.CopyTo(s);
s.Close();
}
}
public static void DemoUploadFile(HcsClient hcsClient)
{
string sourceFileName = @"D:\temp\Проект договора.docx";
var contentType = HcsFile.GetMimeContentTypeForFileName(sourceFileName);
if (contentType == null) throw new HcsException("Не найден тип mime для файла");
Console.WriteLine("Выгружаем файл: " + sourceFileName);
using (var stream = new FileStream(sourceFileName, FileMode.Open, FileAccess.Read))
{
var file = new HcsFile(Path.GetFileName(sourceFileName), contentType, stream);
var guid = hcsClient.FileStoreService.UploadFile(
file, HcsFileStoreContext.homemanagement, CancellationToken.None).Result;
Console.WriteLine("Выгруженный файл GUID=" + guid);
}
}
public static void DemoGetFileLength(HcsClient hcsClient)
{
Guid fileGuid = new Guid("33ddc355-60bd-4537-adf6-fbb31322e16f");
var length = hcsClient.FileStoreService.GetFileLength(
HcsFileStoreContext.homemanagement, fileGuid, CancellationToken.None).Result;
Console.WriteLine($"\nДлина = {length} для файла с GUID " + fileGuid);
}
public static void DemoGostHash(HcsClient hcsClient)
{
PrintFileHash(hcsClient, @"D:\temp\teplo0.pdf");
}
public static void PrintFileHash(HcsClient hcsClient, string fileName)
{
using (var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read))
{
var hash = hcsClient.ComputeGost94Hash(stream);
Console.WriteLine($"{fileName} hash=" + hash + " len=" + new FileInfo(fileName).Length);
}
}
}
}

View File

@ -0,0 +1,153 @@
using Hcs.ClientApi;
using Hcs.ClientApi.DataTypes;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Hcs.ClientDemo
{
public class HouseManagementDemo
{
public static void DemoExportOrgRegistry(HcsClient client)
{
string ogrn = "1061001043421";
string kpp = "";
var orgs = client.OrgRegistryCommon.GetOrgByOgrn(ogrn, kpp).Result;
Console.WriteLine($"Организация с ОГРН={ogrn} имеет {orgs.Count()} orgs:");
foreach (var org in orgs)
Console.WriteLine($" {org}");
}
public static void DemoExportOneContract(HcsClient client)
{
var guid = new Guid("2d393e41-b7e2-4125-9593-c4127617e3f8");
var договор = client.HouseManagement.ПолучитьДоговорРСО(guid).Result;
Console.WriteLine($"Получен договор №{договор.НомерДоговора} Статус={договор.СтатусВерсииДоговора}");
if (договор.ПриложенияДоговора != null && договор.ПриложенияДоговора.Length > 0)
{
var приложение = договор.ПриложенияДоговора[0];
Console.WriteLine($"Приложение: {приложение.ИмяПриложения} HASH={приложение.ХэшПриложения}");
FileStoreDemo.PrintFileHash(client, $"d:\\\\temp\\{приложение.ИмяПриложения}");
}
}
public static void DemoTerminateOneContract(HcsClient client)
{
var guid = new Guid("c7418f95-8ec5-40a3-9474-c4924e17409e");
var договор = client.HouseManagement.ПолучитьДоговорРСО(guid).Result;
Console.WriteLine($"Получен договор №{договор.НомерДоговора} Статус={договор.СтатусВерсииДоговора}");
var d = client.HouseManagement.РасторгнутьДоговор(договор, new DateTime(2019, 4, 1)).Result;
Console.WriteLine($"Дата внесения расторжения договора: {d}");
}
public static void DemoImportNewContract(HcsClient client)
{
var договор = new ГисДоговор();
договор.ТипДоговораРСО = ГисТипДоговораРСО.ПубличныйИлиНежилые;
договор.НомерДоговора = "100-1-41-21900-01";
договор.ДатаЗаключения = new DateTime(2007, 7, 1);
// TODO: Заполнить контрагента получив его GUID через OrgRegistryService по ОГРН
договор.Контрагент = new ГисКонтрагент();
// TODO: Заполнить хотя бы один адрес
var адреса = new List<ГисАдресныйОбъект>();
var d = client.HouseManagement.РазместитьДоговор(договор, адреса).Result;
Console.WriteLine($"Дата внесения нового договора: {d}");
}
public static void DemoExportContractTrees(HcsClient client)
{
var stopwatch = System.Diagnostics.Stopwatch.StartNew();
Func<ГисДоговор, bool> contractFilter = (договор) =>
{
if (договор.СтатусВерсииДоговора == ГисСтатусВерсииДоговора.Аннулирован) return false;
if (договор.СтатусВерсииДоговора == ГисСтатусВерсииДоговора.Расторгнут) return false;
// ГИС возвращает проекты, но не может их найти по коду
if (договор.СтатусВерсииДоговора == ГисСтатусВерсииДоговора.Проект) return false;
if ("ЭККУК" == договор.НомерДоговора) return false;
if ("ЭККЧС" == договор.НомерДоговора) return false;
if ("ЭККНСУ" == договор.НомерДоговора) return false;
return true;
};
var все = client.HouseManagement.ПолучитьВсеДоговорыИПриборы(contractFilter).Result;
using (StreamWriter file = File.CreateText(@"all.json"))
{
JsonSerializer serializer = new JsonSerializer();
serializer.Serialize(file, все);
}
stopwatch.Stop();
Console.WriteLine($"{все}: {stopwatch.Elapsed}");
}
public static void DemoExportMeteringDevices(HcsClient client)
{
Action<ГисПриборУчета> resultHandler = (прибор) =>
{
Console.WriteLine("" + прибор);
};
// ул. Мурманская, 1А
var houseGuid = new Guid("0c94cace-2030-4b0a-97c4-de85eef83282");
var n = client.HouseManagement.ПолучитьПриборыУчетаПоЗданию(houseGuid, resultHandler).Result;
Console.WriteLine("n = " + n);
}
public static void DemoExportContractAddressObjects(HcsClient client)
{
Action<ГисАдресныйОбъект> resultHandler = (адрес) =>
{
Console.WriteLine("" + адрес);
};
var гуидДоговора = new Guid("4f8b6688-ef14-43e6-99a9-846e59cd82e8");
var договор = new ГисДоговор() { ГуидДоговора = гуидДоговора };
var n = client.HouseManagement.ПолучитьАдресаДоговораРСО(договор, resultHandler).Result;
Console.WriteLine("n = " + n);
}
public static void DemoExportAccounts(HcsClient client)
{
Action<ГисЛицевойСчет> resultHandler = (лс) =>
{
Console.WriteLine("" + лс);
};
// ул. Мурманская, 1А
var houseGuid = new Guid("0c94cace-2030-4b0a-97c4-de85eef83282");
var n = client.HouseManagement.ПолучитьЛицевыеСчетаПоЗданию(houseGuid, resultHandler).Result;
Console.WriteLine("n = " + n);
}
public static void DemoExportSupplyResourceContracts(HcsClient client)
{
var договоры = new List<ГисДоговор>();
Action<ГисДоговор> resultHandler = (договорРСО) => { договоры.Add(договорРСО); };
var n = client.HouseManagement.ПолучитьДоговорыРСО(resultHandler).Result;
договоры.Sort((x, y) => string.Compare(x.НомерДоговора, y.НомерДоговора));
договоры.ForEach(x => Console.WriteLine(x.ToString()));
Console.WriteLine("n = " + n);
}
public static void DemoExportOneHouse(HcsClient client)
{
// Петрозаводск, Лисицыной, 19
var guid = Guid.Parse("6596ad9d-fee2-4c5b-8249-dbf78b0281b9");
var здание = client.HouseManagement.ПолучитьЗданиеПоГуидФиас(guid).Result;
Console.WriteLine("ГисЗдание = " + здание);
foreach (var помещение in здание.Помещения)
{
Console.WriteLine(помещение.ToString());
}
}
}
}

View File

@ -0,0 +1,78 @@
using Hcs.ClientApi;
using System;
namespace Hcs.ClientDemo
{
public class Program
{
/// <summary>
/// Демонстрационная программа вызова функций ГИС ЖКХ
/// </summary>
public static void Main(string[] args)
{
// Чтобы сообщения об ошибках показывались на английском языке
System.Threading.Thread.CurrentThread.CurrentUICulture =
new System.Globalization.CultureInfo("en-US");
var client = new HcsClient();
client.Logger = new HcsConsoleLogger();
// Чтобы создавались файлы сообщений и ответов системы
//client.MessageCapture = new HcsFileWriterMessageCapture(null, client.Logger);
var cert = client.FindCertificate(x => x.SerialNumber == "02DD0FE0006DB0C5B24666AB8F30C74780");
if (cert == null) return;
Console.WriteLine("Сертификат: " + cert.Subject);
client.SetSigningCertificate(cert);
// Промышленный или тестовый стенд
client.IsPPAK = false;
if (client.IsPPAK)
{
// GUID поставщика информации ЭКК ППАК (20.05.2022)
client.OrgPPAGUID = "488d95f6-4f6a-4e4e-b78a-ea259ef0ded2";
// Исполнитель/cотрудник ГИСЖКХ: ЛСА/КЛА
client.ExecutorGUID = "e0cba564-b675-4077-b7da-356b18301bc2";
}
else
{
// GUID поставщика информации ЭКК СИТ02 (18.01.2024)
client.OrgPPAGUID = "ee6b2615-c488-420c-a553-0ef31d65b77e";
// Сотрудник тестового стенда СИТ02
client.ExecutorGUID = "d284368e-849c-4002-a815-c8b199d35b05";
}
#pragma warning disable CS0162
try
{
if (false) DebtRequestsDemo.DemoExportOneDebtRequest(client);
if (false) DebtRequestsDemo.DemoExportManySubrequests(client);
if (false) DebtRequestsDemo.DemoImportOneDebtResponse(client);
if (false) HouseManagementDemo.DemoExportOneHouse(client);
if (false) HouseManagementDemo.DemoExportSupplyResourceContracts(client);
if (false) HouseManagementDemo.DemoExportAccounts(client);
if (false) HouseManagementDemo.DemoExportContractAddressObjects(client);
if (false) HouseManagementDemo.DemoExportMeteringDevices(client);
if (false) HouseManagementDemo.DemoExportOneContract(client);
if (false) HouseManagementDemo.DemoExportContractTrees(client);
if (false) HouseManagementDemo.DemoImportNewContract(client);
if (true) HouseManagementDemo.DemoExportOrgRegistry(client);
if (false) FileStoreDemo.DemoDownloadFile(client);
if (false) FileStoreDemo.DemoGostHash(client);
if (false) FileStoreDemo.DemoUploadFile(client);
if (false) FileStoreDemo.DemoGetFileLength(client);
if (false) FileStoreDemo.DemoGostHash(client);
}
catch (Exception ex)
{
Console.WriteLine(ex);
Console.ReadKey();
}
#pragma warning restore CS0162
}
}
}

View File

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{0EE8594D-D76E-4EE2-ACA2-87C49CF1FC71}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Hcs</RootNamespace>
<AssemblyName>Hcs.TestApp</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<LangVersion>12.0</LangVersion>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>Hcs.ClientDemo.Program</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="ClientDemo\DebtRequestsDemo.cs" />
<Compile Include="ClientDemo\FileStoreDemo.cs" />
<Compile Include="ClientDemo\HouseManagementDemo.cs" />
<Compile Include="ClientDemo\Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.8 %28x86 и x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Hcs.Client\Hcs.Client.csproj">
<Project>{3af820fd-6776-4c74-aa76-f918e60fe456}</Project>
<Name>Hcs.Client</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,19 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("GisGkh.ClientDemo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GisGkh.ClientDemo")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("0ee8594d-d76e-4ee2-aca2-87c49cf1fc71")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]