AutoGRAPH.NET Service (EN) — различия между версиями

Материал из TK
Перейти к: навигация, поиск
м (Admin переименовал страницу En:AutoGRAPH.NET Service в AutoGRAPH.NET Service (EN) без оставления перенаправления)
Строка 1: Строка 1:
  +
AutoGRAPH.NET Service provide different protocols for integration with external systems. Currently we have two protocols for this: WCF (Windows communication foundation) and JSON for accessing to [[AutoGRAPH.NET]] core. Schemas configuration can be changed by AutoGRAPH.NET software. AutoGRAPH.NET Service can be run in two modes: as console application and as system service.
d
 
  +
  +
== Minimal requirements for hardware and software environment ==
  +
  +
*RAM – from 1 GB
  +
*Windows 2003 or latest
  +
*.NET Framework 4.0 or latest
  +
*Installed ([[AGDataLoader|AutoGRAPH DataLoader]]) or [[AutoGRAPH Server 5|AutoGRAPH Server 3.x or 4.x or 5.x]]
  +
  +
== Download links ==
  +
  +
Last version: 2015.7.18.1, [[Media:AutoGRAPHNETService20150718 1.zip|Download]]
  +
  +
== Console mode ==
  +
  +
This mode designed for debugging and testing. Simply run '''AutoGRAPHNETService.exe''' in console.
  +
  +
== Service mode ==
  +
  +
Installed as system Windows service and working autonomous. Command line for installing:
  +
  +
<pre>
  +
sc create AutoGRAPHNETService binPath= "C:\TK\WebMapK\Build-Svc\AutoGRAPHNETService.exe"
  +
</pre>
  +
  +
<span class="marker">&nbsp;Don't forget space between binPath= and full path &nbsp;</span>
  +
  +
== Configuring ==
  +
  +
1. Extracting archive with AutoGRAPH.NET Service in some directory 2. Open '''AutoGRAPHNETService.exe.config''' in Notepad. You can see next keys in .config file:
  +
  +
<pre>
  +
<add key="key-file" value="N:\AGServer\AutoGRAPHServer_3.0\30008_4x4_magnitka.agkey"/>
  +
<add key="address" value="http://localhost:800/"/>
  +
<add key="address-json" value="http://localhost:810/"/>
  +
<add key="common-directory" value="C:\ProgramData\AutoGRAPH Shell"/>
  +
<add key="data-directory" value="C:\Users\denisio\AppData\Roaming\AutoGRAPH Shell\Data"/>
  +
</pre>
  +
  +
{| border="1" cellspacing="0" cellpadding="5" style="width: 100%;"
  +
|-
  +
| style="width: 127px;" | key-file
  +
| style="width: 1145px;" | .agkey licensing file (from AutoGRAPH.Server), this file contain allowed devices.<br/><span class="marker"><span style="background-color:#FFFF00;">Required parameter!</span></span><br/>
  +
|-
  +
| style="width: 127px;" | address
  +
| style="width: 1145px;" | local address end point for working with [https://msdn.microsoft.com/en-us/library/dd699756(v=vs.110).aspx WCF] (<span style="line-height: 20.7999992370605px;">protocol (httpBinding mode)</span>. Uri can be set in url:port format<br/>Also, you can use next variations:
  +
*'''<tt>[http://192.168.1.3:8000 http://192.168.1.3:8000]</tt>''' - accept connections on local IP-address 192.168.1.3 and TCP-port 8000 (usually this mode used with several network cards)
  +
*'''<tt>[http://0.0.0.0:8000 http://0.0.0.0:8000]</tt>''' or '''<tt><code>[http://*:8000&nbsp http://*:8000]&nbsp;</code></tt>'''- <span style="line-height: 20.7999992370605px;">accept connections &nbsp;</span>on all enabled network interfaces and IP-addressed and TCP-port 8000
  +
*'''<tt>[http://127.0.0.1:8000 http://127.0.0.1:8000]</tt>''' - accept connections only locally (usually used with local installed software)
  +
  +
|-
  +
| style="width: 127px;" | address-json
  +
| style="width: 1145px;" | <span style="line-height: 20.7999992370605px;">локальный адрес, на котором обрабатываются запросы по протоколу [https://en.wikipedia.org/wiki/JSON JSON]</span><span style="line-height: 20.7999992370605px;">. Формат - url:port</span><br/><span style="line-height: 20.7999992370605px;">Варианты использования:</span><ul style="line-height: 20.7999992370605px;">
  +
<li>'''<tt>[http://192.168.1.3:8000 http://192.168.1.3:8000]</tt>'''&nbsp;- принимать подключения на локальном IP-адресе 192.168.1.3 и TCP-порт 8000 (обычно данный вариант используется, если в сервере установлено несколько сетевых карт или задано несколько IP-адресов)</li>
  +
<li>'''<tt>[http://0.0.0.0:8000 http://0.0.0.0:8000]</tt>'''&nbsp;или&nbsp;'''<tt>[http://*:8000&nbsp http://*:8000]&nbsp;</tt>'''-&nbsp;<span style="line-height: 20.7999992370605px;">принимать подключения&nbsp;</span>на всех доступных локальных IP-адресах и TCP-порту 8000</li>
  +
<li>'''<tt>[http://127.0.0.1:8000 http://127.0.0.1:8000]</tt>'''&nbsp;- принимать подключения только локально&nbsp;(обычно используется, когда приложение, которое работает со службой, установлено на том же компьютере, что и служба. При этом запросы, идущие через сетевые карты - будут игнорироваться в целях безопасности.&nbsp;Типичный пример - установка службы на сервере 1С:Предприятия.)</li>
  +
</ul>
  +
  +
|-
  +
| style="width: 127px;" | common-directory<br/>
  +
| style="width: 1145px;" | directory with common data files (directory structure same with directory of [[AutoGRAPH.NET]] software – with Schemes, GeoFences, Devices subdirectories with files)<br/>
  +
|-
  +
| style="width: 127px;" | data-directory<br/>
  +
| style="width: 1145px;" | devices data directory [[AGDataLoader|AutoGRAPH DataLoader]] or [[AutoGRAPH Server 5|AutoGRAPH Server 3.x or 4.x or 5.x]]<br/>
  +
|}
  +
  +
Save .config file after editing and run service or run in command line. Run next command line for generate .cs file with proxy-class:<br/><pre>
  +
svcutil.exe http://localhost:800/?wsdl /async /tcv:Version35 /ser:DataContractSerializer
  +
</pre><br/>AutoGRAPHSvc.cs and output.config file will created in current directory. This file configured for use WCF-endpoint of AutGRAPH.NET Service.
  +
  +
== Service methods ==
  +
  +
*[[AutoGRAPH.NET Service EnumSchemas (EN)|EnumSchemas]] – enumerate allowed schemas
  +
*[[AutoGRAPH.NET Service EnumDevices (EN)|EnumDevices]] – enumerate devices in schema
  +
*[[AutoGRAPH.NET Service EnumDrivers (EN)|EnumDrivers]] – enumerate drivers in schema
  +
*[[AutoGRAPH.NET Service EnumGeoFences (EN)|EnumGeoFences]] – enumerate geofences in schema
  +
*[[AutoGRAPH.NET Service GetGeoFences (EN)|GetGeoFences]] – get information about geofences (points, polygons, etc)
  +
*[[AutoGRAPH.NET Service GetDevicesInfo (EN)|GetDevicesInfo]] – get information about devices in schema
  +
*[[AutoGRAPH.NET Service EnumParameters (EN)|EnumParameters]] – get schema parameters
  +
*[[AutoGRAPH.NET Service GetOnlineInfo (EN)|GetOnlineInfo]] – get device(s) last position and last date/time information
  +
*[[AutoGRAPH.NET Service GetOnlineInfoAll (EN)|GetOnlineInfoAll]] - get device(s) last position and last date/time information (for ALL devices in schema)
  +
*''GetDataRanges – get allowed data files from devices''
  +
*[[AutoGRAPH.NET Service GetTrips (EN)|GetTrips]] – get trips information for specified device(s)
  +
*[[AutoGRAPH.NET Service GetTripsCustom (EN)|GetTripsCustom]] [[File:Tag-new.png]] – get trips information with custom geofences
  +
*[[AutoGRAPH.NET Service GetStage (EN)|GetStage]] [[File:Tag-new.png]] – get single stage information of specified device(s)
  +
*[[AutoGRAPH.NET Service GetTrack (EN)|GetTrack]] – get track information (date/time/coordinates/speed/...) of specified device(s)
  +
*[[AutoGRAPH.NET Service GetProperties (EN)|GetProperties]] – get property and values list of specified device(s)
  +
*[[AutoGRAPH.NET Service GetProperty (EN)|GetProperty]] – get single property value of specified device(s)
  +
*[[AutoGRAPH.NET Service GetRoute (EN)|GetRoute]] – calculate route between specified points
  +
*[[AutoGRAPH.NET Service WaitData (EN)|WaitData]] [[File:Tag-new.png]] - wait for new device data
  +
*[[AutoGRAPH.NET Service EnumReports (EN)|EnumReports]] [[File:Tag-new.png]] - get allowed reports
  +
*[[AutoGRAPH.NET Service GetReports (EN)|GetReports]] [[File:Tag-new.png]] - run reports and download in XML/PDF/DOCX/XLS/.../ZIP-file
  +
*[[AutoGRAPH.NET Service ExecuteReports (EN)|ExecuteReports]] [[File:Tag-new.png]] - run report asynchronously
  +
*[[AutoGRAPH.NET Service GetReportsStatus (EN)|GetReportsStatus]] [[File:Tag-new.png]] - get report executing status (for asynchronous executing)
  +
*''CancelReports - cancel report creating''
  +
  +
== Examples ==
  +
  +
<code><syntaxhighlight lang="csharp">
  +
using System;
  +
using System.Collections.Generic;
  +
using System.Globalization;
  +
using System.Linq;
  +
using System.Text;
  +
using AutoGRAPHService;
  +
  +
namespace AutoGRAPHSvcTest
  +
{
  +
class Program
  +
{
  +
static void Main(string[] args)
  +
{
  +
var svc = new AutoGRAPHSvcClient(); // make proxy class with default end points
  +
  +
RSchema[] schemas;
  +
using (var f = new TimeCalc("EnumSchemas")) // get schemas list
  +
schemas = svc.EnumSchemas();
  +
  +
REnumDevices devices;
  +
using (var f = new TimeCalc("EnumDevices"))
  +
devices = svc.EnumDevices(schemas[0].Name); // get device list for first allowed schema
  +
foreach (var item in devices.Items)
  +
Console.WriteLine("\t" + item.Name);
  +
  +
using (var f = new TimeCalc("EnumGeoFences")) // get geofences list
  +
svc.EnumGeoFences(schemas[0].Name);
  +
using (var f = new TimeCalc("GetDevicesInfo"))
  +
svc.GetDevicesInfo(schemas[0].Name);
  +
  +
using (var f = new TimeCalc("EnumParameters")) // get parameter list for all devices in schema
  +
svc.EnumParameters(schemas[0].Name, devices.Items.Select(p => p.ID).ToArray());
  +
  +
using (var f = new TimeCalc("GetOnlineInfo")) // get online status of devices
  +
svc.GetOnlineInfo(schemas[0].Name, devices.Items.Select(p => p.ID).ToArray());
  +
  +
using (var f = new TimeCalc("GetTrips")) // get trips list for last 5 days of all devices with numbers more than 9999998
  +
svc.GetTrips(schemas[0].Name,
  +
devices.Items.Where(p => p.Serial >= 9999998).Select(p => p.ID).ToArray(),
  +
DateTime.Now.AddDays(-5), DateTime.Now);
  +
  +
using (var f = new TimeCalc("GetTrack")) // get tracks for last 5 days of all devices with numbers more than 9999998
  +
{
  +
var t1 = svc.GetTrack(schemas[0].Name,
  +
devices.Items.Where(p => p.Serial >= 9999998).Select(p => p.ID).ToArray(),
  +
DateTime.Now.AddDays(-5), DateTime.Now);
  +
}
  +
  +
Console.ReadLine();
  +
}
  +
}
  +
  +
// simple class for calculating running time
  +
class TimeCalc:IDisposable
  +
{
  +
readonly DateTime DT;
  +
readonly string name;
  +
internal TimeCalc(string name) { DT = DateTime.Now; this.name = name; }
  +
void IDisposable.Dispose() { Console.WriteLine(name+": "+DateTime.Now.Subtract(DT).TotalSeconds.ToString("F3", CultureInfo.InvariantCulture)); }
  +
}
  +
}
  +
</syntaxhighlight></code>
  +
  +
<u>.exe.config of this example</u><br/><syntaxhighlight lang="xml">
  +
<?xml version="1.0" encoding="utf-8" ?>
  +
<configuration>
  +
<system.serviceModel>
  +
<bindings>
  +
<basicHttpBinding>
  +
<binding name="BasicHttpBinding_IAutoGRAPHSvc"
  +
closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
  +
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
  +
maxBufferPoolSize="524288" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
  +
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
  +
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16348"
  +
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
  +
<security mode="None">
  +
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
  +
<message clientCredentialType="UserName" algorithmSuite="Default" />
  +
</security>
  +
</binding>
  +
</basicHttpBinding>
  +
</bindings>
  +
<client>
  +
<endpoint address="http://localhost:800/" binding="basicHttpBinding"
  +
bindingConfiguration="BasicHttpBinding_IAutoGRAPHSvc" contract="IAutoGRAPHSvc"
  +
name="BasicHttpBinding_IAutoGRAPHSvc" />
  +
</client>
  +
</system.serviceModel>
  +
</configuration>
  +
</syntaxhighlight>
  +
  +
== [[AutoGRAPH.NET Service troubleshooting|Troubleshooting]] ==
  +
  +
[[AutoGRAPH.NET Service Диагностика неисправностей|здесь]].

Версия 22:17, 31 июля 2015

AutoGRAPH.NET Service provide different protocols for integration with external systems. Currently we have two protocols for this: WCF (Windows communication foundation) and JSON for accessing to AutoGRAPH.NET core. Schemas configuration can be changed by AutoGRAPH.NET software. AutoGRAPH.NET Service can be run in two modes: as console application and as system service.

Minimal requirements for hardware and software environment

Download links

Last version: 2015.7.18.1, Download

Console mode

This mode designed for debugging and testing. Simply run AutoGRAPHNETService.exe in console.

Service mode

Installed as system Windows service and working autonomous. Command line for installing:

sc create AutoGRAPHNETService binPath= "C:\TK\WebMapK\Build-Svc\AutoGRAPHNETService.exe"

 Don't forget space between binPath= and full path  

Configuring

1. Extracting archive with AutoGRAPH.NET Service in some directory 2. Open AutoGRAPHNETService.exe.config in Notepad. You can see next keys in .config file:

<add key="key-file" value="N:\AGServer\AutoGRAPHServer_3.0\30008_4x4_magnitka.agkey"/>
<add key="address" value="http://localhost:800/"/>
<add key="address-json" value="http://localhost:810/"/>
<add key="common-directory" value="C:\ProgramData\AutoGRAPH Shell"/>
<add key="data-directory" value="C:\Users\denisio\AppData\Roaming\AutoGRAPH Shell\Data"/>
key-file .agkey licensing file (from AutoGRAPH.Server), this file contain allowed devices.
Required parameter!
address local address end point for working with WCF (protocol (httpBinding mode). Uri can be set in url:port format
Also, you can use next variations:
address-json локальный адрес, на котором обрабатываются запросы по протоколу JSON. Формат - url:port
Варианты использования:
  • http://192.168.1.3:8000 - принимать подключения на локальном IP-адресе 192.168.1.3 и TCP-порт 8000 (обычно данный вариант используется, если в сервере установлено несколько сетевых карт или задано несколько IP-адресов)
  • http://0.0.0.0:8000 или http://*:8000 принимать подключения на всех доступных локальных IP-адресах и TCP-порту 8000
  • http://127.0.0.1:8000 - принимать подключения только локально (обычно используется, когда приложение, которое работает со службой, установлено на том же компьютере, что и служба. При этом запросы, идущие через сетевые карты - будут игнорироваться в целях безопасности. Типичный пример - установка службы на сервере 1С:Предприятия.)
common-directory
directory with common data files (directory structure same with directory of AutoGRAPH.NET software – with Schemes, GeoFences, Devices subdirectories with files)
data-directory
devices data directory AutoGRAPH DataLoader or AutoGRAPH Server 3.x or 4.x or 5.x

Save .config file after editing and run service or run in command line. Run next command line for generate .cs file with proxy-class:

svcutil.exe http://localhost:800/?wsdl /async /tcv:Version35 /ser:DataContractSerializer


AutoGRAPHSvc.cs and output.config file will created in current directory. This file configured for use WCF-endpoint of AutGRAPH.NET Service.

Service methods

  • EnumSchemas – enumerate allowed schemas
  • EnumDevices – enumerate devices in schema
  • EnumDrivers – enumerate drivers in schema
  • EnumGeoFences – enumerate geofences in schema
  • GetGeoFences – get information about geofences (points, polygons, etc)
  • GetDevicesInfo – get information about devices in schema
  • EnumParameters – get schema parameters
  • GetOnlineInfo – get device(s) last position and last date/time information
  • GetOnlineInfoAll - get device(s) last position and last date/time information (for ALL devices in schema)
  • GetDataRanges – get allowed data files from devices
  • GetTrips – get trips information for specified device(s)
  • GetTripsCustom Tag-new.png – get trips information with custom geofences
  • GetStage Tag-new.png – get single stage information of specified device(s)
  • GetTrack – get track information (date/time/coordinates/speed/...) of specified device(s)
  • GetProperties – get property and values list of specified device(s)
  • GetProperty – get single property value of specified device(s)
  • GetRoute – calculate route between specified points
  • WaitData Tag-new.png - wait for new device data
  • EnumReports Tag-new.png - get allowed reports
  • GetReports Tag-new.png - run reports and download in XML/PDF/DOCX/XLS/.../ZIP-file
  • ExecuteReports Tag-new.png - run report asynchronously
  • GetReportsStatus Tag-new.png - get report executing status (for asynchronous executing)
  • CancelReports - cancel report creating

Examples

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using AutoGRAPHService;

namespace AutoGRAPHSvcTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var svc = new AutoGRAPHSvcClient();            // make proxy class with default end points

            RSchema[] schemas;
            using (var f = new TimeCalc("EnumSchemas"))    // get schemas list
               schemas = svc.EnumSchemas();

            REnumDevices devices;
            using (var f = new TimeCalc("EnumDevices"))
               devices = svc.EnumDevices(schemas[0].Name); // get device list for first allowed schema
            foreach (var item in devices.Items)
               Console.WriteLine("\t" + item.Name);

            using (var f = new TimeCalc("EnumGeoFences"))  // get geofences list
               svc.EnumGeoFences(schemas[0].Name);
            using (var f = new TimeCalc("GetDevicesInfo"))
               svc.GetDevicesInfo(schemas[0].Name);
            
            using (var f = new TimeCalc("EnumParameters")) // get parameter list for all devices in schema
               svc.EnumParameters(schemas[0].Name, devices.Items.Select(p => p.ID).ToArray());
            
            using (var f = new TimeCalc("GetOnlineInfo"))  // get online status of devices
               svc.GetOnlineInfo(schemas[0].Name, devices.Items.Select(p => p.ID).ToArray());
            
            using (var f = new TimeCalc("GetTrips"))       // get trips list for last 5 days of all devices with numbers more than 9999998
                svc.GetTrips(schemas[0].Name,
                    devices.Items.Where(p => p.Serial >= 9999998).Select(p => p.ID).ToArray(),
                    DateTime.Now.AddDays(-5), DateTime.Now);
            
            using (var f = new TimeCalc("GetTrack"))       // get tracks for last 5 days of all devices with numbers more than 9999998
            {
                var t1 = svc.GetTrack(schemas[0].Name,
                    devices.Items.Where(p => p.Serial >= 9999998).Select(p => p.ID).ToArray(),
                    DateTime.Now.AddDays(-5), DateTime.Now);                
            }

            Console.ReadLine();
        }
    }

    // simple class for calculating running time
    class TimeCalc:IDisposable
    {
        readonly DateTime DT;
        readonly string name;
        internal TimeCalc(string name) { DT = DateTime.Now; this.name = name; }
        void IDisposable.Dispose() { Console.WriteLine(name+": "+DateTime.Now.Subtract(DT).TotalSeconds.ToString("F3", CultureInfo.InvariantCulture)); }
    }
}

.exe.config of this example

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
 <system.serviceModel>
 <bindings>
 <basicHttpBinding>
 <binding name="BasicHttpBinding_IAutoGRAPHSvc"
 closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
 allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
 maxBufferPoolSize="524288" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
 messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
 <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16348"
 maxBytesPerRead="4096" maxNameTableCharCount="16384" />
 <security mode="None">
 <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
 <message clientCredentialType="UserName" algorithmSuite="Default" />
 </security>
 </binding>
 </basicHttpBinding>
 </bindings>
 <client>
 <endpoint address="http://localhost:800/" binding="basicHttpBinding"
 bindingConfiguration="BasicHttpBinding_IAutoGRAPHSvc" contract="IAutoGRAPHSvc"
 name="BasicHttpBinding_IAutoGRAPHSvc" />
 </client>
 </system.serviceModel>
</configuration>

Troubleshooting

здесь.