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

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,60 @@
<?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>
<ItemGroup>
<Reference Include="Lers.System">
<HintPath>..\..\Lers.System\bin\x86\Release\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,20 @@

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|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{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|x86.ActiveCfg = Release|x86
{1E9BFBEA-6183-416C-B5EA-C883CD62277E}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

109
GetDataSample/Program.cs Normal file
View File

@ -0,0 +1,109 @@
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());
// Получаем точку учета по уникальному номеру, который задается в свойствах точки учета.
MeasurePoint measurePoint = server.MeasurePoints.GetByNumber(123);
// Убеждаемся, что мы получили указатель на объект MeasurePoint.
// Если точки учета с таким номером не существует или она недоступна для текущего пользовтеля, то метод GetByNumber() вернет null.
if (measurePoint != null)
{
// Выводим полное наименование точки учета.
Console.WriteLine("Точка учета \'{0}\'", measurePoint.FullTitle);
if (measurePoint.SystemType != SystemType.Gas)
{
Console.WriteLine("Точка учета должна иметь систему Газонабжение.");
Console.Read();
return;
}
// Сохраняем суточные данные о потреблении по точке учета.
// Чтобы сохранить данные по воде, используйте Lers.Data.WaterConsumptionRecord, по электроэнергии - Lers.Data.ElectricConsumptionRecord.
MeasurePointConsumptionRecordCollection data = new MeasurePointConsumptionRecordCollection(DeviceDataType.Day);
MeasurePointConsumptionRecordGas record = new MeasurePointConsumptionRecordGas(DateTime.Today.AddDays(-1)); // За вчерашние сутки
record.V = 100; // Объем газа
record.T = 20; // Температура газа
data.Add(record);
MeasurePointConsumptionRecordGas record2 = new Lers.Data.MeasurePointConsumptionRecordGas(DateTime.Today); // За сегодняшние сутки
record2.V = 80; // Объем газа
record2.T = 15; // Температура газа
data.Add(record2);
// Устанавливаем флаг для перезаписи существующих данных и сохраняем данные.
MeasurePointSetConsumptionOptions options = new MeasurePointSetConsumptionOptions();
options.OverwriteExistingRecords = true;
measurePoint.Data.SetConsumption(data, options);
// Запрашиваем данные о суточном потреблении газа за двое суток.
MeasurePointConsumptionRecordCollection consumption = measurePoint.Data.GetConsumption(DateTime.Today.AddDays(-1), DateTime.Today, Lers.Data.DeviceDataType.Day);
// Выводим данные на экран.
foreach (MeasurePointConsumptionRecordGas recordGas in consumption)
{
Console.WriteLine("{0}: V = {1}, T = {2}", recordGas.DateTime, recordGas.V, recordGas.T);
}
}
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")]