Distance Matrix API, noch auf app5
This commit is contained in:
@@ -199,6 +199,7 @@
|
||||
<Compile Include="DefaultHibernateSessionManager.cs" />
|
||||
<Compile Include="Entities\AbwesenheitsInformationPrint.cs" />
|
||||
<Compile Include="Entities\AddressHistory.cs" />
|
||||
<Compile Include="Entities\AddressRoute.cs" />
|
||||
<Compile Include="Entities\ConfirmationReceiptSignature.cs" />
|
||||
<Compile Include="Entities\Dienstvertretung.cs" />
|
||||
<Compile Include="Entities\Dokumentvorlage.cs" />
|
||||
@@ -709,6 +710,9 @@
|
||||
<EmbeddedResource Include="Mappings\RegelmaessigerDienst.hbm.xml" />
|
||||
<EmbeddedResource Include="Mappings\GeschenkterUrlaubstag.hbm.xml" />
|
||||
<EmbeddedResource Include="Mappings\AbwesenheitsInformationPrint.hbm.xml" />
|
||||
<EmbeddedResource Include="Mappings\AddressRoute.hbm.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Content Include="Mappings\Timesheet2Mail.hbm.xml" />
|
||||
<EmbeddedResource Include="Mappings\ContactHistory.hbm.xml">
|
||||
<SubType>Designer</SubType>
|
||||
|
||||
@@ -161,5 +161,10 @@ namespace BeWo.Data.Entities
|
||||
Town = this.Town
|
||||
};
|
||||
}
|
||||
|
||||
public string ToGoogle()
|
||||
{
|
||||
return $"{Street}, {PostalCode}, {Town}, {State}, {Country}";
|
||||
}
|
||||
}
|
||||
}
|
||||
115
Data/Entities/AddressRoute.cs
Normal file
115
Data/Entities/AddressRoute.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using BS.Shared;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeWo.Data.Entities
|
||||
{
|
||||
public class AddressRoute : BeWoEntityBase
|
||||
{
|
||||
private long address1_oid;
|
||||
private long address1_version;
|
||||
private long address2_oid;
|
||||
private long address2_version;
|
||||
|
||||
private int distance_in_meter;
|
||||
private int time_in_seconds;
|
||||
|
||||
public AddressRoute()
|
||||
{
|
||||
_Tid = TableID.AddressRoute;
|
||||
}
|
||||
|
||||
public virtual long Address1_Oid
|
||||
{
|
||||
get
|
||||
{
|
||||
return address1_oid;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (AreDifferent(address1_oid, value))
|
||||
{
|
||||
address1_oid = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual long Address1_Version
|
||||
{
|
||||
get
|
||||
{
|
||||
return address1_version;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (AreDifferent(address1_version, value))
|
||||
{
|
||||
address1_version = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual long Address2_Oid
|
||||
{
|
||||
get
|
||||
{
|
||||
return address2_oid;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (AreDifferent(address2_oid, value))
|
||||
{
|
||||
address2_oid = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual long Address2_Version
|
||||
{
|
||||
get
|
||||
{
|
||||
return address2_version;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (AreDifferent(address2_version, value))
|
||||
{
|
||||
address2_version = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual int Distance_in_meter
|
||||
{
|
||||
get
|
||||
{
|
||||
return distance_in_meter;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (AreDifferent(distance_in_meter, value))
|
||||
{
|
||||
distance_in_meter = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual int Time_in_seconds
|
||||
{
|
||||
get
|
||||
{
|
||||
return time_in_seconds;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (AreDifferent(time_in_seconds, value))
|
||||
{
|
||||
time_in_seconds = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
25
Data/Mappings/AddressRoute.hbm.xml
Normal file
25
Data/Mappings/AddressRoute.hbm.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
|
||||
<class name="BeWo.Data.Entities.AddressRoute,BeWo.Data" table="AddressRoute">
|
||||
<id name="Oid" column="Oid" type="Int64" unsaved-value="null">
|
||||
<generator class="identity" />
|
||||
</id>
|
||||
|
||||
<version column="Version" type="Int64" name="Version" />
|
||||
|
||||
<property column="Tid" type="BS.Shared.TableID, BS.Shared" name="_Tid" access="field" />
|
||||
<property column="IsActive" type="BS.Shared.ActivationTypeId, BS.Shared" name="IsActive" />
|
||||
<property column="Notice" type="String" name="Notice" length="1024" />
|
||||
<property column="InsTs" type="DateTime" name="InsTs" />
|
||||
<property column="InsUser" type="String" name="InsUser" length="256" />
|
||||
<property column="UdpUser" type="String" name="UdpUser" length="256" />
|
||||
<property column="SystemEntryID" type="BS.Shared.SystemEntryID, BS.Shared" name="SystemEntryID" />
|
||||
|
||||
<property column="Address1Oid" type="Int64" name="Address1_Oid" />
|
||||
<property column="Address1Version" type="Int64" name="Address1_Version" />
|
||||
<property column="Address2Oid" type="Int64" name="Address2_Oid" />
|
||||
<property column="Address2Version" type="Int64" name="Address2_Version" />
|
||||
<property column="DistanceMeter" type="Int32" name="Distance_in_meter" />
|
||||
<property column="TimeSec" type="Int32" name="Time_in_seconds" />
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
@@ -219,6 +219,8 @@
|
||||
<add key="RssFeedUrl" value="http://188.40.45.85/news_rss.php?ClientOID=236180486&CategoryOID=2002858128" />
|
||||
<add key="ICD10File" value="icd10.xml" />
|
||||
<add key="FileRootDirectory" value="\BWP-Files" />
|
||||
<add key="GoogleDistanceMatrixApiUrl" value="https://maps.googleapis.com/maps/api/distancematrix/json" />
|
||||
<add key="GoogleDistanceMatrixApiKey" value="AIzaSyDZ_tfNwm_YWC9JiCLQtHsd9X2OUUKuL0c" />
|
||||
</appSettings>
|
||||
<devExpress>
|
||||
<themes enableThemesAssembly="true" styleSheetTheme="" theme="" />
|
||||
|
||||
18
Model/Changes_2023_03_09_AddressRoute.txt
Normal file
18
Model/Changes_2023_03_09_AddressRoute.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
CREATE TABLE `AddressRoute` (
|
||||
`Oid` bigint NOT NULL AUTO_INCREMENT,
|
||||
`Tid` int DEFAULT NULL,
|
||||
`IsActive` tinyint DEFAULT NULL,
|
||||
`Notice` varchar(1024) DEFAULT NULL,
|
||||
`InsTs` datetime DEFAULT NULL,
|
||||
`InsUser` varchar(256) DEFAULT NULL,
|
||||
`Version` bigint DEFAULT NULL,
|
||||
`UdpUser` varchar(256) DEFAULT NULL,
|
||||
`SystemEntryID` int DEFAULT NULL,
|
||||
`Address1Oid` bigint DEFAULT NULL,
|
||||
`Address1Version` bigint DEFAULT NULL,
|
||||
`Address2Oid` bigint DEFAULT NULL,
|
||||
`Address2Version` bigint DEFAULT NULL,
|
||||
`DistanceMeter` int DEFAULT NULL,
|
||||
`TimeSec` int DEFAULT NULL,
|
||||
PRIMARY KEY (`Oid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
64
Service/DCEntityMapper/AddressRouteDC_AddressRoute.cs
Normal file
64
Service/DCEntityMapper/AddressRouteDC_AddressRoute.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using BeWo.Data.Entities;
|
||||
using BS.Shared.DataContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeWo.Service.DCEntityMapper
|
||||
{
|
||||
public class AddressRouteDC_AddressRoute : AbstractIDCEntityMapper<AddressRoute, AddressRouteDC>
|
||||
{
|
||||
public override AddressRouteDC MergeWithDC(AddressRoute pEntity, AddressRouteDC pDataContract)
|
||||
{
|
||||
pDataContract.Oid = pEntity.Oid;
|
||||
pDataContract.IsActive = pEntity.IsActive;
|
||||
pDataContract.Notice = pEntity.Notice;
|
||||
pDataContract.InsTs = pEntity.InsTs;
|
||||
pDataContract.InsUser = pEntity.InsUser;
|
||||
pDataContract.Version = pEntity.Version;
|
||||
pDataContract.UdpUser = pEntity.UdpUser;
|
||||
pDataContract.SystemEntryID = pEntity.SystemEntryID;
|
||||
|
||||
pDataContract.Address1_Oid = pEntity.Address1_Oid;
|
||||
pDataContract.Address1_Version = pEntity.Address1_Version;
|
||||
pDataContract.Address2_Oid = pEntity.Address2_Oid;
|
||||
pDataContract.Address2_Version = pEntity.Address2_Version;
|
||||
|
||||
pDataContract.Distance_in_meter = pEntity.Distance_in_meter;
|
||||
pDataContract.Time_in_sec = pEntity.Time_in_seconds;
|
||||
|
||||
return pDataContract;
|
||||
}
|
||||
|
||||
public override AddressRoute MergeWithEntity(AddressRouteDC pDataContract, AddressRoute pEntity)
|
||||
{
|
||||
this.ConcurrencyCheck(pDataContract.Version, pEntity);
|
||||
|
||||
pEntity.Oid = pDataContract.Oid;
|
||||
pEntity.Notice = pDataContract.Notice;
|
||||
pEntity.SystemEntryID = pDataContract.SystemEntryID;
|
||||
|
||||
pEntity.Address1_Oid = pDataContract.Address1_Oid;
|
||||
pEntity.Address1_Version = pDataContract.Address1_Version;
|
||||
pEntity.Address2_Oid = pDataContract.Address2_Oid;
|
||||
pEntity.Address2_Version = pDataContract.Address2_Version;
|
||||
|
||||
pEntity.Distance_in_meter = pDataContract.Distance_in_meter;
|
||||
pEntity.Time_in_seconds = pDataContract.Time_in_sec;
|
||||
|
||||
return pEntity;
|
||||
}
|
||||
|
||||
protected override bool AreDCAndEntityEqual(AddressRouteDC pDC, AddressRoute pEntity)
|
||||
{
|
||||
if (pDC.Oid == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return pDC.Oid == pEntity.Oid;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,6 +288,8 @@ namespace BeWo.Service.DCEntityMapper
|
||||
|
||||
private static AbwesenheitsInformationPrintDC_AbwesenheitsInformationPrint _AbwesenheitsInformationPrintDC_AbwesenheitsInformationPrint;
|
||||
|
||||
private static AddressRouteDC_AddressRoute _AddressRouteDC_AddressRoute;
|
||||
|
||||
|
||||
public static MedRecordDC_MedRecord MedRecordDC_MedRecord =>
|
||||
_MedRecordDC_MedRecord ?? (_MedRecordDC_MedRecord = new MedRecordDC_MedRecord());
|
||||
@@ -723,5 +725,8 @@ namespace BeWo.Service.DCEntityMapper
|
||||
|
||||
public static AbwesenheitsInformationPrintDC_AbwesenheitsInformationPrint AbwesenheitsInformationPrintDC_AbwesenheitsInformationPrint =>
|
||||
_AbwesenheitsInformationPrintDC_AbwesenheitsInformationPrint ?? (_AbwesenheitsInformationPrintDC_AbwesenheitsInformationPrint = new AbwesenheitsInformationPrintDC_AbwesenheitsInformationPrint());
|
||||
|
||||
public static AddressRouteDC_AddressRoute AddressRouteDC_AddressRoute =>
|
||||
_AddressRouteDC_AddressRoute ?? (_AddressRouteDC_AddressRoute = new AddressRouteDC_AddressRoute());
|
||||
}
|
||||
}
|
||||
@@ -169,6 +169,7 @@
|
||||
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http" />
|
||||
<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>
|
||||
@@ -218,6 +219,7 @@
|
||||
<Compile Include="Core\SettingsLogic.cs" />
|
||||
<Compile Include="Core\Utils.cs" />
|
||||
<Compile Include="DCEntityMapper\AbwesenheitsInformationPrintDC_AbwesenheitsInformationPrint.cs" />
|
||||
<Compile Include="DCEntityMapper\AddressRouteDC_AddressRoute.cs" />
|
||||
<Compile Include="DCEntityMapper\ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature.cs" />
|
||||
<Compile Include="DCEntityMapper\DienstvertretungDC_Dienstvertretung.cs" />
|
||||
<Compile Include="DCEntityMapper\DokumentvorlageDC_Dokumentvorlage.cs" />
|
||||
@@ -481,6 +483,8 @@
|
||||
<Compile Include="Configuration\AppSettings.cs" />
|
||||
<Compile Include="ServiceProxy\ServiceFacade.cs" />
|
||||
<Compile Include="ServiceProxy\ServiceGenerated.cs" />
|
||||
<Compile Include="ServiceUtils\Generell\AddressRouteManager.cs" />
|
||||
<Compile Include="ServiceUtils\API\GoogleDistanceMatrixAPI.cs" />
|
||||
<Compile Include="ServiceUtils\Paths\ServerFilePaths.cs" />
|
||||
<Compile Include="ServiceUtils\Update\UpdateFileLimiter.cs" />
|
||||
<Compile Include="ServiceUtils\Update\UpdateServerSession.cs" />
|
||||
@@ -527,7 +531,6 @@
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="ServiceUtils\Generell\" />
|
||||
<Folder Include="Utils\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -15,6 +15,7 @@ using BeWo.Service.Plugins;
|
||||
using BeWo.Service.SBD;
|
||||
using BeWo.Service.Security;
|
||||
using BeWo.Service.ServiceContracts;
|
||||
using BeWo.Service.ServiceUtils.Generell;
|
||||
using BeWo.Service.Vorlagen;
|
||||
using BS.Shared;
|
||||
using BS.Shared.Core;
|
||||
@@ -7265,5 +7266,23 @@ namespace BeWo.Service.ServiceImplementations
|
||||
DAOFactory.GenericDAO.Delete(signatures2Delete);
|
||||
}
|
||||
}
|
||||
|
||||
public AddressRouteDC GetAddressRouteInfo(long adr1_oid, long adr1_ver, long adr2_oid, long adr2_ver)
|
||||
{
|
||||
try
|
||||
{
|
||||
var address1 = DAOFactory.GenericDAO.LoadByID<Address>(adr1_oid);
|
||||
var address2 = DAOFactory.GenericDAO.LoadByID<Address>(adr2_oid);
|
||||
|
||||
var res = AddressRouteManager.GetAddressRoute(address1, address2);
|
||||
|
||||
return MapperFactory.AddressRouteDC_AddressRoute.MapToNewDC(res);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw Utils.CreateBeWoFaultException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
106
Service/ServiceUtils/API/GoogleDistanceMatrixAPI.cs
Normal file
106
Service/ServiceUtils/API/GoogleDistanceMatrixAPI.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using BeWo.Data.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace BeWo.Service.ServiceUtils.API
|
||||
{
|
||||
public class GoogleDistanceMatrixApi
|
||||
{
|
||||
public class Response
|
||||
{
|
||||
public string Status { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "origin_addresses")]
|
||||
public string[] OriginAddresses { get; set; }
|
||||
|
||||
[JsonProperty(PropertyName = "destination_addresses")]
|
||||
public string[] DestinationAddresses { get; set; }
|
||||
|
||||
public Row[] Rows { get; set; }
|
||||
|
||||
public class Data
|
||||
{
|
||||
public int Value { get; set; }
|
||||
public string Text { get; set; }
|
||||
}
|
||||
|
||||
public class Element
|
||||
{
|
||||
public string Status { get; set; }
|
||||
public Data Duration { get; set; }
|
||||
public Data Distance { get; set; }
|
||||
}
|
||||
|
||||
public class Row
|
||||
{
|
||||
public Element[] Elements { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
private string Key { get; set; }
|
||||
private string Url { get; set; }
|
||||
|
||||
private string[] OriginAddresses { get; set; }
|
||||
private string[] DestinationAddresses { get; set; }
|
||||
|
||||
public GoogleDistanceMatrixApi(Address originAddress, Address destinationAddress) : this(new string[] { originAddress.ToGoogle() }, new string[] { destinationAddress.ToGoogle() })
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public GoogleDistanceMatrixApi(string[] originAddresses, string[] destinationAddresses)
|
||||
{
|
||||
OriginAddresses = originAddresses;
|
||||
DestinationAddresses = destinationAddresses;
|
||||
|
||||
var appSettings = ConfigurationManager.AppSettings;
|
||||
|
||||
if (string.IsNullOrEmpty(appSettings["GoogleDistanceMatrixApiUrl"]))
|
||||
{
|
||||
throw new Exception("GoogleDistanceMatrixApiUrl is not set in AppSettings.");
|
||||
}
|
||||
Url = appSettings["GoogleDistanceMatrixApiUrl"];
|
||||
|
||||
if (string.IsNullOrEmpty(appSettings["GoogleDistanceMatrixApiKey"]))
|
||||
{
|
||||
throw new Exception("GoogleDistanceMatrixApiKey is not set in AppSettings.");
|
||||
}
|
||||
Key = appSettings["GoogleDistanceMatrixApiKey"];
|
||||
}
|
||||
|
||||
public async Task<Response> GetResponse()
|
||||
{
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
var uri = new Uri(GetRequestUrl());
|
||||
|
||||
HttpResponseMessage response = await client.GetAsync(uri);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
throw new Exception("GoogleDistanceMatrixApi failed with status code: " + response.StatusCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
return JsonConvert.DeserializeObject<Response>(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string GetRequestUrl()
|
||||
{
|
||||
OriginAddresses = OriginAddresses.Select(HttpUtility.UrlEncode).ToArray();
|
||||
var origins = string.Join("|", OriginAddresses);
|
||||
DestinationAddresses = DestinationAddresses.Select(HttpUtility.UrlEncode).ToArray();
|
||||
var destinations = string.Join("|", DestinationAddresses);
|
||||
return $"{Url}?origins={origins}&destinations={destinations}&key={Key}";
|
||||
}
|
||||
}
|
||||
}
|
||||
95
Service/ServiceUtils/Generell/AddressRouteManager.cs
Normal file
95
Service/ServiceUtils/Generell/AddressRouteManager.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
using BeWo.Service.DCEntityMapper;
|
||||
using BeWo.Service.ServiceUtils.API;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeWo.Service.ServiceUtils.Generell
|
||||
{
|
||||
public static class AddressRouteManager
|
||||
{
|
||||
public static AddressRoute GetAddressRoute(Address address1, Address address2)
|
||||
{
|
||||
var routes = DAOFactory.GenericDAO.GetAll<AddressRoute>();
|
||||
|
||||
foreach (var route in routes)
|
||||
{
|
||||
if (route.Address1_Oid == address1.Oid && route.Address2_Oid == address2.Oid)
|
||||
{
|
||||
if (route.Address1_Version == address1.Version && route.Address2_Version == address2.Version)
|
||||
{
|
||||
// Route korrekt vorhanden
|
||||
return route;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Route vorhanden, aber Addresse hat update
|
||||
return UpdateAddressRoute(route, address1, address2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Route nicht vorhanden
|
||||
return InsertNewAddressRoute(address1, address2);
|
||||
}
|
||||
|
||||
public static void DeleteAddressRoute(long oid) => DeleteAddressRoute(DAOFactory.GenericDAO.LoadByID<AddressRoute>(oid));
|
||||
|
||||
public static void DeleteAddressRoute(AddressRoute route)
|
||||
{
|
||||
if (route is object)
|
||||
DAOFactory.GenericDAO.Delete(route);
|
||||
}
|
||||
|
||||
public static AddressRoute InsertNewAddressRoute(Address address1, Address address2)
|
||||
{
|
||||
var newRoute = new AddressRoute
|
||||
{
|
||||
Address1_Oid = address1.Oid.Value,
|
||||
Address2_Oid = address2.Oid.Value
|
||||
};
|
||||
|
||||
RequestAddressRoute(ref newRoute, address1, address2);
|
||||
|
||||
DAOFactory.GenericDAO.Insert(newRoute);
|
||||
|
||||
return newRoute;
|
||||
}
|
||||
|
||||
public static AddressRoute UpdateAddressRoute(AddressRoute route, Address address1, Address address2)
|
||||
{
|
||||
RequestAddressRoute(ref route, address1, address2);
|
||||
|
||||
DAOFactory.GenericDAO.Update(route);
|
||||
|
||||
return route;
|
||||
}
|
||||
|
||||
public static AddressRoute RequestAddressRoute(ref AddressRoute route, Address address1, Address address2)
|
||||
{
|
||||
route.Address1_Version = address1.Version.Value;
|
||||
route.Address2_Version = address2.Version.Value;
|
||||
|
||||
// Calculate Distance
|
||||
|
||||
var api = new GoogleDistanceMatrixApi(address1, address2);
|
||||
var task = api.GetResponse();
|
||||
|
||||
task.Wait();
|
||||
|
||||
if(task.Exception is object)
|
||||
{
|
||||
throw task.Exception;
|
||||
}
|
||||
|
||||
route.Distance_in_meter = task.Result.Rows[0].Elements[0].Distance.Value;
|
||||
route.Time_in_seconds = task.Result.Rows[0].Elements[0].Duration.Value;
|
||||
|
||||
return route;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,8 @@ namespace BS.Shared
|
||||
RegelmaessigerDienst = 153,
|
||||
GeschenkterUrlaubstag = 154,
|
||||
Preis = 155,
|
||||
AbwesenheitsInformationPrint = 156
|
||||
AbwesenheitsInformationPrint = 156,
|
||||
AddressRoute = 160
|
||||
}
|
||||
|
||||
public enum SystemEntryID
|
||||
|
||||
55
Shared/DataContracts/AddressRouteDC.cs
Normal file
55
Shared/DataContracts/AddressRouteDC.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BS.Shared.DataContracts
|
||||
{
|
||||
public class AddressRouteDC : IDataContract
|
||||
{
|
||||
[DataMember]
|
||||
public long? Oid { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public ActivationTypeId IsActive { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string Notice { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public DateTime? InsTs { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string InsUser { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public long? Version { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string UdpUser { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public SystemEntryID? SystemEntryID { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public long Address1_Oid { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public long Address1_Version { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public long Address2_Oid { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public long Address2_Version { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public int Distance_in_meter { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public int Time_in_sec { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -154,6 +154,7 @@
|
||||
<Compile Include="DataContracts\AdditionalServiceGroupOfPeopleDC.cs" />
|
||||
<Compile Include="DataContracts\AdditionalServiceGroupOfPeopleRelationDC.cs" />
|
||||
<Compile Include="DataContracts\AdditionalServiceRegionDC.cs" />
|
||||
<Compile Include="DataContracts\AddressRouteDC.cs" />
|
||||
<Compile Include="DataContracts\ClientPartials\ContactDC.cs" />
|
||||
<Compile Include="DataContracts\BesetzungsstatusDC.cs" />
|
||||
<Compile Include="DataContracts\ConfirmationReceiptSignatureDC.cs" />
|
||||
|
||||
Reference in New Issue
Block a user