Загрузил проекты примеров

This commit is contained in:
2016-04-08 14:43:07 +10:00
parent 6cb8d0c91f
commit 3074b6115e
17 changed files with 1848 additions and 0 deletions

View File

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{1E9BFBEA-6183-416C-B5EA-C883CD62277E}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LersSample</RootNamespace>
<AssemblyName>LersSample</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="Lers.System, Version=3.0.0.0, Culture=neutral, PublicKeyToken=e7c6d6299713498c, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Lers.System\bin\x64\Debug\Lers.System.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LersSample", "LersSample.csproj", "{1E9BFBEA-6183-416C-B5EA-C883CD62277E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1E9BFBEA-6183-416C-B5EA-C883CD62277E}.Debug|x64.ActiveCfg = Debug|x64
{1E9BFBEA-6183-416C-B5EA-C883CD62277E}.Debug|x64.Build.0 = Debug|x64
{1E9BFBEA-6183-416C-B5EA-C883CD62277E}.Debug|x86.ActiveCfg = Debug|x86
{1E9BFBEA-6183-416C-B5EA-C883CD62277E}.Debug|x86.Build.0 = Debug|x86
{1E9BFBEA-6183-416C-B5EA-C883CD62277E}.Release|x64.ActiveCfg = Release|x86
{1E9BFBEA-6183-416C-B5EA-C883CD62277E}.Release|x64.Build.0 = Release|x86
{1E9BFBEA-6183-416C-B5EA-C883CD62277E}.Release|x86.ActiveCfg = Release|x86
{1E9BFBEA-6183-416C-B5EA-C883CD62277E}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

126
AttributesSample/Program.cs Normal file
View File

@ -0,0 +1,126 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security;
using Lers.Core;
using Lers.Data;
namespace LersSample
{
class Program
{
static void Main(string[] args)
{
// Создаем экземпляр объекта LersServer, через который осуществляется работа с сервером ЛЭРС УЧЕТ.
Lers.LersServer server = new Lers.LersServer();
// Создаем данные для авторизации в системе (логин и пароль).
string login = "admin";
SecureString password = Lers.Networking.SecureStringHelper.ConvertToSecureString("admin");
Lers.Networking.BasicAuthenticationInfo authInfo = new Lers.Networking.BasicAuthenticationInfo(login, password);
// Выполняем подключение к серверу, указывая имя компьютера и TCP-порт, а так же данные для авторизации.
try
{
server.Connect("localhost", 10000, authInfo);
}
catch (Exception exc)
{
Console.WriteLine("Ошибка подключения к серверу.\r\n" + exc.Message);
Console.Read();
return;
}
Console.WriteLine("Версия сервера: " + server.Version.ToString());
// Получаем объект учета по уникальному номеру, который задается в свойствах объекта учета.
// Указываем через флаг, что нам нужны атрибуты и системы объекта учета.
Node node = server.Nodes.GetByNumber(1232, NodeInfoFlags.Attributes | NodeInfoFlags.Systems);
// Убеждаемся, что мы получили указатель на объект Node.
// Если объект учета с таким номером не существует или он недоступна для текущего пользовтеля, то метод GetByNumber() вернет null.
if (node != null)
{
// Выводим наименование Объекта учета.
Console.WriteLine("Объект учета \'{0}\'", node.Title);
MeasurePoint[] measurePoints = node.Systems.HotWater.MeasurePoints.ToArray();
// Запрашиваем данные о суточном потреблении гвс за двое суток.
MeasurePointConsumptionRecord[] consumption1 = measurePoints[0].Data.GetConsumption(DateTime.Today.AddDays(-1), DateTime.Today, Lers.Data.DeviceDataType.Day).ToArray();
MeasurePointConsumptionRecord[] consumption2 = measurePoints[1].Data.GetConsumption(DateTime.Today.AddDays(-1), DateTime.Today, Lers.Data.DeviceDataType.Day).ToArray();
string scheme = (string)node.Attributes["схема"];
MeasurePointConsumptionRecord[] consumption = new MeasurePointConsumptionRecord[consumption1.Length];
switch (scheme)
{
// Первая схема измерения
case "1":
// Здесь реализуем расчет по схеме измерения, например складываем потребления по двум точкам учета.
for (int i = 0; i < consumption1.Length; i++)
{
MeasurePointConsumptionRecordWater record = new MeasurePointConsumptionRecordWater(consumption1[i].DateTime);
record.M_in = ((MeasurePointConsumptionRecordWater)consumption1[i]).M_in + ((MeasurePointConsumptionRecordWater)consumption2[i]).M_in;
record.M_out = ((MeasurePointConsumptionRecordWater)consumption1[i]).M_out + ((MeasurePointConsumptionRecordWater)consumption2[i]).M_out;
consumption[i] = record;
}
break;
// Вторая схема измерения
case "2":
// Здесь реализуем расчет по схеме измерения, например вычисляем разницу потребления по двум точкам учета.
for (int i = 0; i < consumption1.Length; i++)
{
MeasurePointConsumptionRecordWater record = new MeasurePointConsumptionRecordWater(consumption1[i].DateTime);
record.M_in = ((MeasurePointConsumptionRecordWater)consumption1[i]).M_in - ((MeasurePointConsumptionRecordWater)consumption2[i]).M_in;
record.M_out = ((MeasurePointConsumptionRecordWater)consumption1[i]).M_out - ((MeasurePointConsumptionRecordWater)consumption2[i]).M_out;
consumption[i] = record;
}
break;
default:
throw new Exception("Неподдерживаемый номер схемы измерения.");
}
// Выводим данные на экран.
foreach (MeasurePointConsumptionRecordWater recordWater in consumption)
{
Console.WriteLine("{0}: M1 = {1}, M2 = {2}", recordWater.DateTime, recordWater.M_in, recordWater.M_out);
}
}
else
{
Console.WriteLine("Объект учета не существует или недоступен для данной учетной записи.");
}
Console.ReadLine();
// Отключаемся от сервера.
// Указываем таймаут 2 секунды на нормальное завершение сеанса, после выхода которого, соединение будет разорвано.
server.Disconnect(2000);
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("LersSample")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LersSample")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("6a23aa78-7b98-4b51-bad6-69ea6363f58c")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]